CustusX  18.04
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 
25 namespace cx
26 {
27 
29 {
30  mSliceProxy = sliceProxy;
31 }
32 
34 {
35  mView = view;
36 }
37 
39 {
40  for (RepMap::iterator iter=mDataReps.begin(); iter!=mDataReps.end(); ++iter)
41  {
42  this->updateSettings(iter->second);
43  }
44 }
45 
47 {
48  if (boost::dynamic_pointer_cast<Mesh>(data))
49  {
50  this->meshAdded(boost::dynamic_pointer_cast<Mesh>(data));
51  }
52  else if (boost::dynamic_pointer_cast<PointMetric>(data))
53  {
54  this->pointMetricAdded(boost::dynamic_pointer_cast<PointMetric>(data));
55  }
56  else if (boost::dynamic_pointer_cast<SphereMetric>(data))
57  {
58  this->sphereMetricAdded(boost::dynamic_pointer_cast<SphereMetric>(data));
59  }
60 }
61 
63 {
64  if (!mDataReps.count(uid))
65  return;
66 
67  mView->removeRep(mDataReps[uid]);
68  mDataReps.erase(uid);
69 }
70 
71 void DataRepContainer::meshAdded(MeshPtr mesh)
72 {
73  if (!mesh)
74  return;
75  if (mDataReps.count(mesh->getUid()))
76  return;
77 
78  GeometricRep2DPtr rep = GeometricRep2D::New(mesh->getUid() + "_rep2D");
79  rep->setSliceProxy(mSliceProxy);
80  rep->setMesh(mesh);
81  mView->addRep(rep);
82  mDataReps[mesh->getUid()] = rep;
83 }
84 
85 void DataRepContainer::pointMetricAdded(PointMetricPtr mesh)
86 {
87  if (!mesh)
88  return;
89  if (mDataReps.count(mesh->getUid()))
90  return;
91 
92  PointMetricRep2DPtr rep = PointMetricRep2D::New(mesh->getUid() + "_rep2D");
93  rep->setSliceProxy(mSliceProxy);
94  rep->setDataMetric(mesh);
95  rep->setDynamicSize(true);
96  mView->addRep(rep);
97  mDataReps[mesh->getUid()] = rep;
98  this->updateSettings(rep);
99 }
100 
101 void DataRepContainer::sphereMetricAdded(SphereMetricPtr mesh)
102 {
103  if (!mesh)
104  return;
105  if (mDataReps.count(mesh->getUid()))
106  return;
107 
108  SphereMetricRep2DPtr rep = SphereMetricRep2D::New(mesh->getUid() + "_rep2D");
109  rep->setSliceProxy(mSliceProxy);
110  rep->setDataMetric(mesh);
111  mView->addRep(rep);
112  mDataReps[mesh->getUid()] = rep;
113  this->updateSettings(rep);
114 }
115 
117 {
118  DataMetricRepPtr val = boost::dynamic_pointer_cast<DataMetricRep>(rep);
119  if (!val)
120  return;
121 
122  val->setGraphicsSize(settings()->value("View3D/sphereRadius").toDouble());
123  val->setShowLabel(settings()->value("View/showLabels").toBool());
124  val->setLabelSize(settings()->value("View3D/labelSize").toDouble());
125  val->setShowAnnotation(!settings()->value("View/showMetricNamesInCorner").toBool());
126 }
127 
128 
129 } // namespace cx
void setSliceProxy(SliceProxyPtr sliceProxy)
boost::shared_ptr< class SliceProxy > SliceProxyPtr
void setView(ViewPtr view)
boost::shared_ptr< class SphereMetric > SphereMetricPtr
void addData(DataPtr data)
boost::shared_ptr< class PointMetricRep2D > PointMetricRep2DPtr
Base class for all Data Metric reps.
boost::shared_ptr< class DataMetricRep > DataMetricRepPtr
boost::shared_ptr< class View > ViewPtr
static PointMetricRep2DPtr New(const QString &uid="")
static SphereMetricRep2DPtr New(const QString &uid="")
void removeData(QString uid)
boost::shared_ptr< class Data > DataPtr
Settings * settings()
Shortcut for accessing the settings instance.
Definition: cxSettings.cpp:21
static GeometricRep2DPtr New(const QString &uid="")
boost::shared_ptr< class SphereMetricRep2D > SphereMetricRep2DPtr
boost::shared_ptr< class Mesh > MeshPtr
boost::shared_ptr< class Rep > RepPtr
Definition: cxRepManager.h:24
boost::shared_ptr< class GeometricRep2D > GeometricRep2DPtr
void setGraphicsSize(double size)
Namespace for all CustusX production code.
boost::shared_ptr< class PointMetric > PointMetricPtr