Fraxinus  18.10
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  // view options for this group.
142  struct Options
143  {
144  Options();
149  };
150 
151  Options getOptions() const;
152  void setOptions(Options options);
153  void setRegistrationMode(REGISTRATION_STATUS mode);
154 
155  void addXml(QDomNode& dataNode);
156  void parseXml(QDomNode dataNode);
157 
158 private slots:
159  void purgeDataNotExistingInPatientModelService();
160 
161 signals:
162  void dataViewPropertiesChanged(QString uid);
163  void videoSourceChanged(QString uid);
164  void initialized();
165  void optionsChanged();
166 
167 private:
168  typedef std::pair<QString, DataViewProperties> DataAndViewPropertiesPair;
169 
170  struct data_equals
171  {
172  data_equals(QString uid) : mData(uid) {}
173  bool operator()(const DataAndViewPropertiesPair& right)
174  {
175  return mData == right.first;
176  }
177  QString mData;
178  };
179 
180  template<class DATA_TYPE>
181  std::vector<boost::shared_ptr<DATA_TYPE> > getDataOfType(DataViewProperties requiredProperties) const;
182  bool contains(QString uid) const;
183  void createSliceDefinitionProperty();
184  void insertData(std::vector<DataAndViewPropertiesPair>::iterator iter, DataAndViewPropertiesPair &item);
185 
186  QString mUid;
187  CoreServicesPtr mServices;
188  QString mVideoSource;
189  std::vector<DataAndViewPropertiesPair> mData;
190  CameraDataPtr mCamera3D;
191  Options mOptions;
192  SyncedValuePtr mGroup2DZoom;
193  SyncedValuePtr mGlobal2DZoom;
194  StringListPropertyPtr mSliceDefinitionProperty;
195  DataPtr getData(QString uid) const;
196  //SharedOpenGLContextPtr mSharedOpenGLContext;
197 
198 };
199 
200 
204 } //namespace cx
205 
206 #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:38
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.