NorMIT-nav  2023.01.05-dev+develop.0da12
An IGT application
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) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 
13 
14 #include "cxPointMetricRep.h"
15 #include "cxView.h"
16 #include "boost/bind.hpp"
17 #include "cxLogger.h"
18 
19 namespace cx
20 {
21 
23 {
24  return wrap_new(new PointMetricRep(), uid);
25 }
26 
27 PointMetricRep::PointMetricRep()
28 {
29  mViewportListener.reset(new ViewportListener);
30  mViewportListener->setCallback(boost::bind(&PointMetricRep::rescale, this));
31 }
32 
34 {
36  mGraphicalPoint.reset();
37 }
38 
40 {
41  mViewportListener->startListen(view->getRenderer());
43 }
44 
46 {
48  mViewportListener->stopListen();
49 }
50 
52 {
53  if (!mMetric)
54  return;
55 
56  if (!mGraphicalPoint && this->getView() && mMetric)
57  mGraphicalPoint.reset(new GraphicalPoint3D(this->getRenderer()));
58 
59  if (!mGraphicalPoint)
60  return;
61 
62  Vector3D p0_r = mMetric->getRefCoord();
63 
64  mGraphicalPoint->setValue(p0_r);
65  mGraphicalPoint->setRadius(mGraphicsSize);
66  mGraphicalPoint->setColor(mMetric->getColor());
67 
68  this->drawText();
69 
70  this->rescale();
71 }
72 
80 {
81  if (!mGraphicalPoint)
82  return;
83 
84  double size = mViewportListener->getVpnZoom(mMetric->getRefCoord());
85  double sphereSize = mGraphicsSize / 100 / size;
86  mGraphicalPoint->setRadius(sphereSize);
87 }
88 
89 }
cxLogger.h
cx::DataMetricRep::addRepActorsToViewRenderer
void addRepActorsToViewRenderer(ViewPtr view)
Definition: cxDataMetricRep.cpp:89
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::ViewportListener
Listens to changes in viewport and camera matrix.
Definition: cxViewportListener.h:67
cx::DataMetricRep::clear
virtual void clear()
Definition: cxDataMetricRep.cpp:84
cx::RepImpl::getRenderer
vtkRendererPtr getRenderer()
Definition: cxRepImpl.cpp:88
cx::PointMetricRep::rescale
virtual void rescale()
Definition: cxPointMetricRep.cpp:79
cx::PointMetricRep::addRepActorsToViewRenderer
virtual void addRepActorsToViewRenderer(ViewPtr view)
Definition: cxPointMetricRep.cpp:39
cx::PointMetricRepPtr
boost::shared_ptr< class PointMetricRep > PointMetricRepPtr
Definition: cxForwardDeclarations.h:85
cx::RepImpl::getView
ViewPtr getView() const
Definition: cxRepImpl.cpp:83
cx::DataMetricRep::removeRepActorsFromViewRenderer
void removeRepActorsFromViewRenderer(ViewPtr view)
Definition: cxDataMetricRep.cpp:100
cx::PointMetricRep::clear
virtual void clear()
Definition: cxPointMetricRep.cpp:33
cx::PointMetricRep::New
static PointMetricRepPtr New(const QString &uid="")
Definition: cxPointMetricRep.cpp:22
cxView.h
cx::DataMetricRep::drawText
void drawText()
Definition: cxDataMetricRep.cpp:109
cx::PointMetricRep
Definition: cxPointMetricRep.h:36
cx::ViewPtr
boost::shared_ptr< class View > ViewPtr
Definition: cxForwardDeclarations.h:110
cx::GraphicalPoint3D
Helper for rendering a point in 3D.
Definition: cxGraphicalPrimitives.h:122
cx::PointMetricRep::onModifiedStartRender
virtual void onModifiedStartRender()
Definition: cxPointMetricRep.cpp:51
cx::DataMetricRep::mGraphicsSize
double mGraphicsSize
Definition: cxDataMetricRep.h:62
cx::DataMetricRep::mMetric
DataMetricPtr mMetric
Definition: cxDataMetricRep.h:68
cx::RepImpl::wrap_new
static boost::shared_ptr< REP > wrap_new(REP *object, QString uid)
Definition: cxRepImpl.h:62
cx::PointMetricRep::removeRepActorsFromViewRenderer
virtual void removeRepActorsFromViewRenderer(ViewPtr view)
Definition: cxPointMetricRep.cpp:45
cx::Vector3D
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:42
cxPointMetricRep.h