Fraxinus  17.12-rc3
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) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 #ifndef CXVIEWGROUPDATA_H
33 #define CXVIEWGROUPDATA_H
34 
35 #include "cxResourceVisualizationExport.h"
36 
37 #include <vector>
38 #include <QVariant>
39 #include <QObject>
40 #include "cxDefinitions.h"
41 #include "vtkForwardDeclarations.h"
42 #include "cxForwardDeclarations.h"
43 #include "cxForwardDeclarations.h"
44 #include "cxPlaneTypeCollection.h"
45 #include "cxViewService.h"
46 class QDomNode;
47 
48 namespace cx
49 {
50 
51 typedef boost::shared_ptr<class CameraData> CameraDataPtr;
52 typedef boost::shared_ptr<class CoreServices> CoreServicesPtr;
53 typedef boost::shared_ptr<class VisServices> VisServicesPtr;
54 typedef boost::shared_ptr<class StringListProperty> StringListPropertyPtr;
55 
56 
62 struct cxResourceVisualization_EXPORT CameraStyleData
63 {
65  explicit CameraStyleData(CAMERA_STYLE_TYPE style);
66  void setCameraStyle(CAMERA_STYLE_TYPE style);
67  CAMERA_STYLE_TYPE getStyle();
68  void clear();
69  void addXml(QDomNode& dataNode);
70  void parseXml(QDomNode dataNode);
71 
77  bool mTableLock;
78  double mElevation;
79  bool mUniCam;
80  QString mCameraNotBehindROI; // never move camera behind this roi
81  QString mFocusROI; // name of ROI to set focus in.
82  QString mAutoZoomROI; // name of ROI to zoom to.
83 };
84 cxResourceVisualization_EXPORT bool operator==(const CameraStyleData& lhs, const CameraStyleData& rhs);
85 
89 cxResourceVisualization_EXPORT int getPriority(DataPtr data);
90 
93 cxResourceVisualization_EXPORT bool dataTypeSort(const DataPtr data1, const DataPtr data2);
94 
95 typedef boost::shared_ptr<class SyncedValue> SyncedValuePtr;
96 typedef boost::shared_ptr<class ViewGroupData> ViewGroupDataPtr;
97 
100 class cxResourceVisualization_EXPORT DataViewProperties
101 {
102 public:
103  DataViewProperties() : mVolume3D(false), mSlice3D(false), mSlice2D(false) {}
104  static DataViewProperties createDefault();
105  static DataViewProperties createFull();
106  static DataViewProperties createVolume3D();
107  static DataViewProperties createSlice3D();
108  static DataViewProperties createSlice2D();
109  static DataViewProperties create3D();
110  void addXml(QDomNode& dataNode);
111  void parseXml(QDomNode dataNode);
112  bool empty() const;
113  DataViewProperties addFlagsIn(DataViewProperties rhs) const;
114  DataViewProperties removeFlagsIn(DataViewProperties rhs) const;
115  bool containsAnyFlagsIn(DataViewProperties required) const;
116 
117  bool hasVolume3D() const { return mVolume3D; }
118  bool hasSlice3D() const { return mSlice3D; }
119  bool hasSlice2D() const { return mSlice2D; }
120 
121 private:
122  bool mVolume3D;
123  bool mSlice3D;
124  bool mSlice2D;
125 };
126 
129 class cxResourceVisualization_EXPORT ViewGroupData: public QObject
130 {
131 Q_OBJECT
132 
133 public:
134  explicit ViewGroupData(CoreServicesPtr services, QString uid);
135  void requestInitialize();
136  QString getUid() const { return mUid; }
137  std::vector<DataPtr> getData(DataViewProperties properties=DataViewProperties::createFull()) const;
138  QString getVideoSource() const;
139  void addData(QString uid);
140  void addDataSorted(QString uid);
141  void setVideoSource(QString uid);
142  bool removeData(QString uid);
143  void clearData();
144  std::vector<ImagePtr> getImages(DataViewProperties properties) const;
145  std::vector<MeshPtr> getMeshes(DataViewProperties properties) const;
146  std::vector<TrackedStreamPtr> getTrackedStreams(DataViewProperties properties) const;
147  std::vector<TrackedStreamPtr> getTracked2DStreams(DataViewProperties properties) const;
148  std::vector<ImagePtr> getImagesAndChangingImagesFromTrackedStreams(DataViewProperties properties, bool include2D = false) const;
149  DataViewProperties getProperties(QString uid);
150  void setProperties(QString uid, DataViewProperties properties);
151 
152  void initializeGlobal2DZoom(SyncedValuePtr val);
153  SyncedValuePtr getGroup2DZoom();
154  SyncedValuePtr getGlobal2DZoom();
155 
156  CameraDataPtr getCamera3D() { return mCamera3D; }
157  void zoomCamera3D(int zoomFactor);
158 
159  PlaneTypeCollection getSliceDefinitions();
160  void setSliceDefinitions(PlaneTypeCollection val);
161  StringListPropertyPtr getSliceDefinitionProperty();
162 
163  // view options for this group.
164  struct Options
165  {
166  Options();
171  };
172 
173  Options getOptions() const;
174  void setOptions(Options options);
175  void setRegistrationMode(REGISTRATION_STATUS mode);
176 
177  void addXml(QDomNode& dataNode);
178  void parseXml(QDomNode dataNode);
179 
180 private slots:
181  void purgeDataNotExistingInPatientModelService();
182 
183 signals:
184  void dataViewPropertiesChanged(QString uid);
185  void videoSourceChanged(QString uid);
186  void initialized();
187  void optionsChanged();
188 
189 private:
190  typedef std::pair<QString, DataViewProperties> DataAndViewPropertiesPair;
191 
192  struct data_equals
193  {
194  data_equals(QString uid) : mData(uid) {}
195  bool operator()(const DataAndViewPropertiesPair& right)
196  {
197  return mData == right.first;
198  }
199  QString mData;
200  };
201 
202  template<class DATA_TYPE>
203  std::vector<boost::shared_ptr<DATA_TYPE> > getDataOfType(DataViewProperties requiredProperties) const;
204  bool contains(QString uid) const;
205  void createSliceDefinitionProperty();
206  void insertData(std::vector<DataAndViewPropertiesPair>::iterator iter, DataAndViewPropertiesPair &item);
207 
208  QString mUid;
209  CoreServicesPtr mServices;
210  QString mVideoSource;
211  std::vector<DataAndViewPropertiesPair> mData;
212  CameraDataPtr mCamera3D;
213  Options mOptions;
214  SyncedValuePtr mGroup2DZoom;
215  SyncedValuePtr mGlobal2DZoom;
216  StringListPropertyPtr mSliceDefinitionProperty;
217  DataPtr getData(QString uid) const;
218  //SharedOpenGLContextPtr mSharedOpenGLContext;
219 
220 };
221 
222 
226 } //namespace cx
227 
228 #endif // CXVIEWGROUPDATA_H
int getPriority(DataPtr data)
boost::shared_ptr< class ViewGroupData > ViewGroupDataPtr
Definition: cxViewGroup.h:50
CameraDataPtr getCamera3D()
boost::shared_ptr< class CameraData > CameraDataPtr
Definition: cxViewWrapper.h:57
boost::shared_ptr< class VisServices > VisServicesPtr
Definition: cxMainWindow.h:61
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)
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:59
bool contains(std::string const &s, std::string const &infix)
Definition: catch.hpp:168
boost::shared_ptr< class SyncedValue > SyncedValuePtr
Definition: cxViewGroup.h:51
boost::shared_ptr< class Mesh > MeshPtr
Namespace for all CustusX production code.