CustusX  2023.01.05-dev+develop.0da12
An IGT application
cxSphereMetricRep2D.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 #include "cxSphereMetricRep2D.h"
13 
14 #include "boost/bind.hpp"
15 
16 #include <vtkActor.h>
17 #include <vtkPolyDataMapper.h>
18 #include <vtkProperty.h>
19 #include <vtkRenderer.h>
20 #include <vtkSectorSource.h>
21 
22 #include "cxSliceProxy.h"
23 #include "cxView.h"
24 #include "cxGraphicalDisk.h"
25 
26 #include "cxSphereMetric.h"
27 
28 namespace cx
29 {
30 
32 {
33  return wrap_new(new SphereMetricRep2D(), uid);
34 }
35 
36 SphereMetricRep2D::SphereMetricRep2D()
37 {
38 }
39 
41 {
43 }
44 
46 {
47  mDisk.reset();
49 }
50 
52 {
54 }
55 
56 SphereMetricPtr SphereMetricRep2D::getSphereMetric()
57 {
58  return boost::dynamic_pointer_cast<SphereMetric>(mMetric);
59 }
60 
62 {
63  SphereMetricPtr metric = this->getSphereMetric();
64 
65  if (!metric)
66  return;
67 
68  if (!mDisk && this->getView() && metric && mSliceProxy)
69  {
70  mDisk.reset(new GraphicalDisk());
71  mDisk->setRenderer(this->getRenderer());
72  }
73 
74  if (!mDisk)
75  return;
76 
77  Vector3D position = mSliceProxy->get_sMr() * mMetric->getRefCoord();
78 
79  mDisk->setColor(mMetric->getColor());
80  mDisk->setOutlineColor(mMetric->getColor());
81  mDisk->setOutlineWidth(0.31);
82  mDisk->setFillVisible(false);
83 
84  mDisk->setRadiusBySlicingSphere(metric->getRadius(), position[2]);
85 
86  Vector3D projectedPosition = position;
87  double offsetFromXYPlane = 0.01;
88  projectedPosition[2] = offsetFromXYPlane;
89  mDisk->setPosition(projectedPosition);
90 
91  mDisk->update();
92 }
93 
95 {
96  if (mSliceProxy)
97  disconnect(mSliceProxy.get(), SIGNAL(transformChanged(Transform3D)), this, SLOT(setModified()));
98  mSliceProxy = sliceProxy;
99  if (mSliceProxy)
100  connect(mSliceProxy.get(), SIGNAL(transformChanged(Transform3D)), this, SLOT(setModified()));
101  this->setModified();
102 }
103 
104 } // namespace cx
105 
106 
ViewPtr getView() const
Definition: cxRepImpl.cpp:83
vtkRendererPtr getRenderer()
Definition: cxRepImpl.cpp:88
virtual void removeRepActorsFromViewRenderer(ViewPtr view)
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
boost::shared_ptr< class SliceProxy > SliceProxyPtr
virtual void clear()
static boost::shared_ptr< REP > wrap_new(REP *object, QString uid)
Definition: cxRepImpl.h:62
boost::shared_ptr< class SphereMetric > SphereMetricPtr
virtual void addRepActorsToViewRenderer(ViewPtr view)
boost::shared_ptr< class View > ViewPtr
Data class that represents a donut.
static SphereMetricRep2DPtr New(const QString &uid="")
void addRepActorsToViewRenderer(ViewPtr view)
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:42
virtual void onModifiedStartRender()
void removeRepActorsFromViewRenderer(ViewPtr view)
boost::shared_ptr< class SphereMetricRep2D > SphereMetricRep2DPtr
DataMetricPtr mMetric
void setModified()
Definition: cxRepImpl.cpp:112
void setSliceProxy(SliceProxyPtr slicer)
Namespace for all CustusX production code.