CustusX  16.12
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 public:
133  explicit ViewGroupData(CoreServicesPtr services, QString uid);
134  void requestInitialize();
135  QString getUid() const { return mUid; }
136 // std::vector<DataPtr> getData() const;
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 
158  PlaneTypeCollection getSliceDefinitions();
159  void setSliceDefinitions(PlaneTypeCollection val);
160  StringListPropertyPtr getSliceDefinitionProperty();
161 
162  // view options for this group.
163  struct Options
164  {
165  Options();
168 // bool mLockToTable; ///< lock the 3D view orientation to have Table down.
171  };
172 
173  Options getOptions() const;
174  void setOptions(Options options);
175  void setRegistrationMode(REGISTRATION_STATUS mode);
176 
177 
178  void addXml(QDomNode& dataNode);
179  void parseXml(QDomNode dataNode);
180 
181 private slots:
182  void purgeDataNotExistingInPatientModelService();
183 
184 signals:
185  void dataViewPropertiesChanged(QString uid);
186  void videoSourceChanged(QString uid);
187  void initialized();
188  void optionsChanged();
189 
190 private:
191  QString mUid;
192  CoreServicesPtr mServices;
193  QString mVideoSource;
194  typedef std::pair<QString, DataViewProperties> DataAndViewProperties;
195  std::vector<DataAndViewProperties> mData;
196  CameraDataPtr mCamera3D;
197  Options mOptions;
198  SyncedValuePtr mGroup2DZoom;
199  SyncedValuePtr mGlobal2DZoom;
200  StringListPropertyPtr mSliceDefinitionProperty;
201  DataPtr getData(QString uid) const;
202 
203  struct data_equals
204  {
205  data_equals(QString uid) : mData(uid) {}
206  bool operator()(const DataAndViewProperties& right)
207  {
208  return mData == right.first;
209  }
210  QString mData;
211  };
212 
213  template<class DATA_TYPE>
214  std::vector<boost::shared_ptr<DATA_TYPE> > getDataOfType(DataViewProperties requiredProperties) const;
215  bool contains(QString uid) const;
216  void createSliceDefinitionProperty();
217 };
218 
219 
223 } //namespace cx
224 
225 #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:62
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
boost::shared_ptr< class SyncedValue > SyncedValuePtr
Definition: cxViewGroup.h:51
boost::shared_ptr< class Mesh > MeshPtr