Fraxinus  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 }
ViewPtr getView() const
Definition: cxRepImpl.cpp:83
vtkRendererPtr getRenderer()
Definition: cxRepImpl.cpp:88
virtual void rescale()
virtual void clear()
static boost::shared_ptr< REP > wrap_new(REP *object, QString uid)
Definition: cxRepImpl.h:62
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:42
void removeRepActorsFromViewRenderer(ViewPtr view)
static PointMetricRepPtr New(const QString &uid="")
DataMetricPtr mMetric
boost::shared_ptr< class PointMetricRep > PointMetricRepPtr
Namespace for all CustusX production code.