Fraxinus  16.5.0-fx-rc3
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cxPointMetricRep.cpp
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 
33 
34 
35 #include "cxPointMetricRep.h"
36 #include "cxView.h"
37 #include "boost/bind.hpp"
38 
39 
40 namespace cx
41 {
42 
44 {
45  return wrap_new(new PointMetricRep(), uid);
46 }
47 
48 PointMetricRep::PointMetricRep()
49 {
50  mViewportListener.reset(new ViewportListener);
51  mViewportListener->setCallback(boost::bind(&PointMetricRep::rescale, this));
52 }
53 
55 {
57  mGraphicalPoint.reset();
58 }
59 
61 {
62  mViewportListener->startListen(view->getRenderer());
64 }
65 
67 {
69  mViewportListener->stopListen();
70 }
71 
73 {
74  if (!mMetric)
75  return;
76 
77  if (!mGraphicalPoint && this->getView() && mMetric)
78  mGraphicalPoint.reset(new GraphicalPoint3D(this->getRenderer()));
79 
80  if (!mGraphicalPoint)
81  return;
82 
83  Vector3D p0_r = mMetric->getRefCoord();
84 
85  mGraphicalPoint->setValue(p0_r);
86  mGraphicalPoint->setRadius(mGraphicsSize);
87  mGraphicalPoint->setColor(mMetric->getColor());
88 
89  this->drawText();
90 
91  this->rescale();
92 }
93 
101 {
102  if (!mGraphicalPoint)
103  return;
104 
105  double size = mViewportListener->getVpnZoom();
106  double sphereSize = mGraphicsSize / 100 / size;
107  mGraphicalPoint->setRadius(sphereSize);
108 }
109 
110 }
ViewPtr getView() const
Definition: cxRepImpl.cpp:104
vtkRendererPtr getRenderer()
Definition: cxRepImpl.cpp:109
virtual void rescale()
virtual void clear()
static boost::shared_ptr< REP > wrap_new(REP *object, QString uid)
Definition: cxRepImpl.h:83
virtual void clear()
Helper for rendering a point in 3D.
boost::shared_ptr< class View > ViewPtr
Listens to changes in viewport and camera matrix.
virtual void addRepActorsToViewRenderer(ViewPtr view)
void addRepActorsToViewRenderer(ViewPtr view)
virtual void onModifiedStartRender()
virtual void removeRepActorsFromViewRenderer(ViewPtr view)
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:63
void removeRepActorsFromViewRenderer(ViewPtr view)
static PointMetricRepPtr New(const QString &uid="")
DataMetricPtr mMetric
boost::shared_ptr< class PointMetricRep > PointMetricRepPtr