CustusX  2021.09.21-dev+develop.e3cd0
An IGT application
cxViewGroupData.h
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 #ifndef CXVIEWGROUPDATA_H
12 #define CXVIEWGROUPDATA_H
13 
14 #include "cxResourceVisualizationExport.h"
15 
16 #include <vector>
17 #include <QVariant>
18 #include <QObject>
19 #include "cxDefinitions.h"
20 #include "vtkForwardDeclarations.h"
21 #include "cxForwardDeclarations.h"
22 #include "cxForwardDeclarations.h"
23 #include "cxPlaneTypeCollection.h"
24 #include "cxViewService.h"
25 class QDomNode;
26 
27 namespace cx
28 {
29 
30 typedef boost::shared_ptr<class CameraData> CameraDataPtr;
31 typedef boost::shared_ptr<class CoreServices> CoreServicesPtr;
32 typedef boost::shared_ptr<class VisServices> VisServicesPtr;
33 typedef boost::shared_ptr<class StringListProperty> StringListPropertyPtr;
34 
35 
41 struct cxResourceVisualization_EXPORT CameraStyleData
42 {
44  explicit CameraStyleData(CAMERA_STYLE_TYPE style);
45  void setCameraStyle(CAMERA_STYLE_TYPE style);
46  CAMERA_STYLE_TYPE getStyle();
47  void clear();
48  void addXml(QDomNode& dataNode);
49  void parseXml(QDomNode dataNode);
50 
56  bool mTableLock;
57  double mElevation;
58  bool mUniCam;
59  QString mCameraNotBehindROI; // never move camera behind this roi
60  QString mFocusROI; // name of ROI to set focus in.
61  QString mAutoZoomROI; // name of ROI to zoom to.
62 };
63 cxResourceVisualization_EXPORT bool operator==(const CameraStyleData& lhs, const CameraStyleData& rhs);
64 
68 cxResourceVisualization_EXPORT int getPriority(DataPtr data);
69 
72 cxResourceVisualization_EXPORT bool dataTypeSort(const DataPtr data1, const DataPtr data2);
73 
74 typedef boost::shared_ptr<class SyncedValue> SyncedValuePtr;
75 typedef boost::shared_ptr<class ViewGroupData> ViewGroupDataPtr;
76 
79 class cxResourceVisualization_EXPORT DataViewProperties
80 {
81 public:
82  DataViewProperties() : mVolume3D(false), mSlice3D(false), mSlice2D(false) {}
83  static DataViewProperties createDefault();
84  static DataViewProperties createFull();
85  static DataViewProperties createVolume3D();
86  static DataViewProperties createSlice3D();
87  static DataViewProperties createSlice2D();
88  static DataViewProperties create3D();
89  void addXml(QDomNode& dataNode);
90  void parseXml(QDomNode dataNode);
91  bool empty() const;
92  DataViewProperties addFlagsIn(DataViewProperties rhs) const;
93  DataViewProperties removeFlagsIn(DataViewProperties rhs) const;
94  bool containsAnyFlagsIn(DataViewProperties required) const;
95 
96  bool hasVolume3D() const { return mVolume3D; }
97  bool hasSlice3D() const { return mSlice3D; }
98  bool hasSlice2D() const { return mSlice2D; }
99 
100 private:
101  bool mVolume3D;
102  bool mSlice3D;
103  bool mSlice2D;
104 };
105 
108 class cxResourceVisualization_EXPORT ViewGroupData: public QObject
109 {
110 Q_OBJECT
111 
112 public:
113  explicit ViewGroupData(CoreServicesPtr services, QString uid);
114  void requestInitialize();
115  QString getUid() const { return mUid; }
116  std::vector<DataPtr> getData(DataViewProperties properties=DataViewProperties::createFull()) const;
117  QString getVideoSource() const;
118  void addData(QString uid);
119  void addDataSorted(QString uid);
120  void setVideoSource(QString uid);
121  bool removeData(QString uid);
122  void clearData();
123  std::vector<ImagePtr> getImages(DataViewProperties properties) const;
124  std::vector<MeshPtr> getMeshes(DataViewProperties properties) const;
125  std::vector<TrackedStreamPtr> getTrackedStreams(DataViewProperties properties) const;
126  std::vector<ImagePtr> getImagesAndChangingImagesFromTrackedStreams(DataViewProperties properties, bool include2D = false) const;
127  DataViewProperties getProperties(QString uid);
128  void setProperties(QString uid, DataViewProperties properties);
129 
130  void initializeGlobal2DZoom(SyncedValuePtr val);
131  SyncedValuePtr getGroup2DZoom();
132  SyncedValuePtr getGlobal2DZoom();
133 
134  CameraDataPtr getCamera3D() { return mCamera3D; }
135  void zoomCamera3D(int zoomFactor);
136 
137  PlaneTypeCollection getSliceDefinitions();
138  void setSliceDefinitions(PlaneTypeCollection val);
139  StringListPropertyPtr getSliceDefinitionProperty();
140 
141  ToolPtr getControllingTool();
142  void setControllingTool(ToolPtr tool);
143 
144  // view options for this group.
145  struct Options
146  {
147  Options();
152  };
153 
154  Options getOptions() const;
155  void setOptions(Options options);
156  void setRegistrationMode(REGISTRATION_STATUS mode);
157 
158  void addXml(QDomNode& dataNode);
159  void parseXml(QDomNode dataNode);
160 
161 private slots:
162  void purgeDataNotExistingInPatientModelService();
163 
164 signals:
165  void dataViewPropertiesChanged(QString uid);
166  void videoSourceChanged(QString uid);
167  void initialized();
168  void optionsChanged();
169 
170 private:
171  typedef std::pair<QString, DataViewProperties> DataAndViewPropertiesPair;
172 
173  struct data_equals
174  {
175  data_equals(QString uid) : mData(uid) {}
176  bool operator()(const DataAndViewPropertiesPair& right)
177  {
178  return mData == right.first;
179  }
180  QString mData;
181  };
182 
183  template<class DATA_TYPE>
184  std::vector<boost::shared_ptr<DATA_TYPE> > getDataOfType(DataViewProperties requiredProperties) const;
185  bool contains(QString uid) const;
186  void createSliceDefinitionProperty();
187  void insertData(std::vector<DataAndViewPropertiesPair>::iterator iter, DataAndViewPropertiesPair &item);
188 
189  QString mUid;
190  CoreServicesPtr mServices;
191  QString mVideoSource;
192  std::vector<DataAndViewPropertiesPair> mData;
193  CameraDataPtr mCamera3D;
194  Options mOptions;
195  SyncedValuePtr mGroup2DZoom;
196  SyncedValuePtr mGlobal2DZoom;
197  StringListPropertyPtr mSliceDefinitionProperty;
198  DataPtr getData(QString uid) const;
199  //SharedOpenGLContextPtr mSharedOpenGLContext;
200  ToolPtr mControllingTool;
201 
202 };
203 
204 
208 } //namespace cx
209 
210 #endif // CXVIEWGROUPDATA_H
int getPriority(DataPtr data)
boost::shared_ptr< class ViewGroupData > ViewGroupDataPtr
Definition: cxViewGroup.h:29
CameraDataPtr getCamera3D()
boost::shared_ptr< class CameraData > CameraDataPtr
Definition: cxViewWrapper.h:36
boost::shared_ptr< class VisServices > VisServicesPtr
Definition: cxMainWindow.h:40
bool hasSlice3D() const
Container for data shared between all members of a view group.
boost::shared_ptr< class Data > DataPtr
static DataViewProperties createFull()
bool dataTypeSort(const DataPtr data1, const DataPtr data2)
bool hasVolume3D() const
QString getUid() const
boost::shared_ptr< class StringListProperty > StringListPropertyPtr
bool operator==(const RegistrationTransform &lhs, const RegistrationTransform &rhs)
boost::shared_ptr< class CoreServices > CoreServicesPtr
Definition: cxCameraStyle.h:37
bool contains(std::string const &s, std::string const &infix)
Definition: catch.hpp:168
boost::shared_ptr< class SyncedValue > SyncedValuePtr
Definition: cxViewGroup.h:30
boost::shared_ptr< class Mesh > MeshPtr
bool hasSlice2D() const
Namespace for all CustusX production code.
boost::shared_ptr< class Tool > ToolPtr