NorMIT-nav  2023.01.05-dev+develop.0da12
An IGT application
cxDataRepContainer.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 "cxDataRepContainer.h"
13 
14 #include "cxView.h"
15 #include "cxSliceProxy.h"
16 #include "cxGeometricRep2D.h"
17 #include "cxSettings.h"
18 #include "cxData.h"
19 #include "cxMesh.h"
20 #include "cxImage.h"
21 #include "cxPointMetricRep2D.h"
22 #include "cxSphereMetricRep2D.h"
23 #include "cxSphereMetric.h"
24 #include "cxDistanceMetricRep2D.h"
25 #include "cxLogger.h"
26 
27 namespace cx
28 {
29 
31 {
32  mSliceProxy = sliceProxy;
33 }
34 
36 {
37  mView = view;
38 }
39 
41 {
42  for (RepMap::iterator iter=mDataReps.begin(); iter!=mDataReps.end(); ++iter)
43  {
44  this->updateSettings(iter->second);
45  }
46 }
47 
49 {
50  if (boost::dynamic_pointer_cast<Mesh>(data))
51  {
52  this->meshAdded(boost::dynamic_pointer_cast<Mesh>(data));
53  }
54  else if (boost::dynamic_pointer_cast<PointMetric>(data))
55  {
56  this->pointMetricAdded(boost::dynamic_pointer_cast<PointMetric>(data));
57  }
58  else if (boost::dynamic_pointer_cast<SphereMetric>(data))
59  {
60  this->sphereMetricAdded(boost::dynamic_pointer_cast<SphereMetric>(data));
61  }
62  else if (boost::dynamic_pointer_cast<DistanceMetric>(data))
63  {
64  this->distanceMetricAdded(boost::dynamic_pointer_cast<DistanceMetric>(data));
65  }
66 }
67 
69 {
70  if (!mDataReps.count(uid))
71  return;
72 
73  mView->removeRep(mDataReps[uid]);
74  mDataReps.erase(uid);
75 }
76 
77 void DataRepContainer::meshAdded(MeshPtr mesh)
78 {
79  if (!mesh)
80  return;
81  if (mDataReps.count(mesh->getUid()))
82  return;
83 
84  GeometricRep2DPtr rep = GeometricRep2D::New(mesh->getUid() + "_rep2D");
85  rep->setSliceProxy(mSliceProxy);
86  rep->setMesh(mesh);
87  mView->addRep(rep);
88  mDataReps[mesh->getUid()] = rep;
89 }
90 
91 void DataRepContainer::pointMetricAdded(PointMetricPtr mesh)
92 {
93  if (!mesh)
94  return;
95  if (mDataReps.count(mesh->getUid()))
96  return;
97 
98  PointMetricRep2DPtr rep = PointMetricRep2D::New(mesh->getUid() + "_rep2D");
99  rep->setSliceProxy(mSliceProxy);
100  rep->setDataMetric(mesh);
101  rep->setDynamicSize(true);
102  mView->addRep(rep);
103  mDataReps[mesh->getUid()] = rep;
104  this->updateSettings(rep);
105 }
106 
107 void DataRepContainer::distanceMetricAdded(DistanceMetricPtr mesh)
108 {
109  if (!mesh)
110  return;
111  if (mDataReps.count(mesh->getUid()))
112  return;
113 
114  DistanceMetricRep2DPtr rep = DistanceMetricRep2D::New(mesh->getUid() + "_rep2D");
115  rep->setSliceProxy(mSliceProxy);
116  rep->setDataMetric(mesh);
117  rep->setDynamicSize(true);
118  mView->addRep(rep);
119  mDataReps[mesh->getUid()] = rep;
120  this->updateSettings(rep);
121 }
122 
123 void DataRepContainer::sphereMetricAdded(SphereMetricPtr mesh)
124 {
125  if (!mesh)
126  return;
127  if (mDataReps.count(mesh->getUid()))
128  return;
129 
130  SphereMetricRep2DPtr rep = SphereMetricRep2D::New(mesh->getUid() + "_rep2D");
131  rep->setSliceProxy(mSliceProxy);
132  rep->setDataMetric(mesh);
133  mView->addRep(rep);
134  mDataReps[mesh->getUid()] = rep;
135  this->updateSettings(rep);
136 }
137 
139 {
140  DataMetricRepPtr val = boost::dynamic_pointer_cast<DataMetricRep>(rep);
141  if (!val)
142  return;
143 
144  val->setGraphicsSize(settings()->value("View3D/sphereRadius").toDouble());
145  val->setShowLabel(settings()->value("View/showLabels").toBool());
146  val->setLabelSize(settings()->value("View3D/labelSize").toDouble());
147  val->setShowAnnotation(!settings()->value("View/showMetricNamesInCorner").toBool());
148 }
149 
150 
151 } // namespace cx
cx::PointMetricRep2D::New
static PointMetricRep2DPtr New(const QString &uid="")
Definition: cxPointMetricRep2D.cpp:31
cxLogger.h
cx::PointMetricRep2DPtr
boost::shared_ptr< class PointMetricRep2D > PointMetricRep2DPtr
Definition: cxForwardDeclarations.h:86
cx::DataRepContainer::setView
void setView(ViewPtr view)
Definition: cxDataRepContainer.cpp:35
cxPointMetricRep2D.h
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cxImage.h
cx::GeometricRep2D::New
static GeometricRep2DPtr New(const QString &uid="")
Definition: cxGeometricRep2D.cpp:51
cx::DistanceMetricRep2D::New
static DistanceMetricRep2DPtr New(const QString &uid="")
Definition: cxDistanceMetricRep2D.cpp:32
cx::DataRepContainer::removeData
void removeData(QString uid)
Definition: cxDataRepContainer.cpp:68
cx::SliceProxyPtr
boost::shared_ptr< class SliceProxy > SliceProxyPtr
Definition: cxForwardDeclarations.h:96
cx::DataMetricRepPtr
boost::shared_ptr< class DataMetricRep > DataMetricRepPtr
Definition: cxViewWrapper3D.h:39
cxData.h
cx::SphereMetricPtr
boost::shared_ptr< class SphereMetric > SphereMetricPtr
Definition: cxDataRepContainer.h:22
cx::MeshPtr
boost::shared_ptr< class Mesh > MeshPtr
Definition: cxForwardDeclarations.h:48
cxDistanceMetricRep2D.h
cx::RepPtr
boost::shared_ptr< class Rep > RepPtr
Definition: cxRepManager.h:24
cx::DataPtr
boost::shared_ptr< class Data > DataPtr
Definition: cxRegistrationApplicator.h:22
cxSphereMetricRep2D.h
cxView.h
cx::DistanceMetricRep2DPtr
boost::shared_ptr< class DistanceMetricRep2D > DistanceMetricRep2DPtr
Definition: cxDistanceMetricRep2D.h:25
cxSettings.h
cx::ViewPtr
boost::shared_ptr< class View > ViewPtr
Definition: cxForwardDeclarations.h:110
cx::DataRepContainer::addData
void addData(DataPtr data)
Definition: cxDataRepContainer.cpp:48
cxSphereMetric.h
cx::DistanceMetricPtr
boost::shared_ptr< class DistanceMetric > DistanceMetricPtr
Definition: cxForwardDeclarations.h:67
cx::GeometricRep2DPtr
boost::shared_ptr< class GeometricRep2D > GeometricRep2DPtr
Definition: cxForwardDeclarations.h:69
cx::DataRepContainer::setSliceProxy
void setSliceProxy(SliceProxyPtr sliceProxy)
Definition: cxDataRepContainer.cpp:30
cxDataRepContainer.h
cx::PointMetricPtr
boost::shared_ptr< class PointMetric > PointMetricPtr
Definition: cxForwardDeclarations.h:84
cxSliceProxy.h
cxMesh.h
cxGeometricRep2D.h
cx::SphereMetricRep2DPtr
boost::shared_ptr< class SphereMetricRep2D > SphereMetricRep2DPtr
Definition: cxSphereMetricRep2D.h:25
cx::settings
Settings * settings()
Shortcut for accessing the settings instance.
Definition: cxSettings.cpp:21
cx::DataRepContainer::updateSettings
void updateSettings()
Definition: cxDataRepContainer.cpp:40
cx::SphereMetricRep2D::New
static SphereMetricRep2DPtr New(const QString &uid="")
Definition: cxSphereMetricRep2D.cpp:31