NorMIT-nav  22.09
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 
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::DataMetricRep::clear
virtual void clear()
Definition: cxDataMetricRep.cpp:84
cx::SphereMetricRep2D::addRepActorsToViewRenderer
virtual void addRepActorsToViewRenderer(ViewPtr view)
Definition: cxSphereMetricRep2D.cpp:40
cx::RepImpl::getRenderer
vtkRendererPtr getRenderer()
Definition: cxRepImpl.cpp:88
cx::GraphicalDisk
Definition: cxGraphicalDisk.h:32
cx::RepImpl::getView
ViewPtr getView() const
Definition: cxRepImpl.cpp:83
cx::SliceProxyPtr
boost::shared_ptr< class SliceProxy > SliceProxyPtr
Definition: cxForwardDeclarations.h:96
cx::SphereMetricPtr
boost::shared_ptr< class SphereMetric > SphereMetricPtr
Definition: cxDataRepContainer.h:22
cx::DataMetricRep::removeRepActorsFromViewRenderer
void removeRepActorsFromViewRenderer(ViewPtr view)
Definition: cxDataMetricRep.cpp:100
cx::SphereMetricRep2D::clear
virtual void clear()
Definition: cxSphereMetricRep2D.cpp:51
cx::Transform3D
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
Definition: cxLandmarkPatientRegistrationWidget.h:33
cxSphereMetricRep2D.h
cxView.h
cxGraphicalDisk.h
cx::ViewPtr
boost::shared_ptr< class View > ViewPtr
Definition: cxForwardDeclarations.h:110
cxSphereMetric.h
cx::RepImpl::setModified
void setModified()
Definition: cxRepImpl.cpp:112
cx::SphereMetricRep2D::onModifiedStartRender
virtual void onModifiedStartRender()
Definition: cxSphereMetricRep2D.cpp:61
cx::SphereMetricRep2D::removeRepActorsFromViewRenderer
virtual void removeRepActorsFromViewRenderer(ViewPtr view)
Definition: cxSphereMetricRep2D.cpp:45
cx::SphereMetricRep2D
Definition: cxSphereMetricRep2D.h:35
cx::SphereMetricRep2D::setSliceProxy
void setSliceProxy(SliceProxyPtr slicer)
Definition: cxSphereMetricRep2D.cpp:94
cxSliceProxy.h
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::Vector3D
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:42
cx::SphereMetricRep2DPtr
boost::shared_ptr< class SphereMetricRep2D > SphereMetricRep2DPtr
Definition: cxSphereMetricRep2D.h:25
cx::SphereMetricRep2D::New
static SphereMetricRep2DPtr New(const QString &uid="")
Definition: cxSphereMetricRep2D.cpp:31