Fraxinus  16.5.0-fx-rc8
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 class QDomNode;
46 
47 namespace cx
48 {
49 
50 typedef boost::shared_ptr<class CameraData> CameraDataPtr;
51 typedef boost::shared_ptr<class CoreServices> CoreServicesPtr;
52 typedef boost::shared_ptr<class VisServices> VisServicesPtr;
53 typedef boost::shared_ptr<class StringListProperty> StringListPropertyPtr;
54 
55 
66 cxResourceVisualization_EXPORT int getPriority(DataPtr data);
67 
70 cxResourceVisualization_EXPORT bool dataTypeSort(const DataPtr data1, const DataPtr data2);
71 
72 typedef boost::shared_ptr<class SyncedValue> SyncedValuePtr;
73 typedef boost::shared_ptr<class ViewGroupData> ViewGroupDataPtr;
74 
77 class cxResourceVisualization_EXPORT DataViewProperties
78 {
79 public:
80  DataViewProperties() : mVolume3D(false), mSlice3D(false), mSlice2D(false) {}
81  static DataViewProperties createDefault();
82  static DataViewProperties createFull();
83  static DataViewProperties createVolume3D();
84  static DataViewProperties createSlice3D();
85  static DataViewProperties createSlice2D();
86  static DataViewProperties create3D();
87  void addXml(QDomNode& dataNode);
88  void parseXml(QDomNode dataNode);
89  bool empty() const;
90  DataViewProperties addFlagsIn(DataViewProperties rhs) const;
91  DataViewProperties removeFlagsIn(DataViewProperties rhs) const;
92  bool containsAnyFlagsIn(DataViewProperties required) const;
93 
94  bool hasVolume3D() const { return mVolume3D; }
95  bool hasSlice3D() const { return mSlice3D; }
96  bool hasSlice2D() const { return mSlice2D; }
97 
98 private:
99  bool mVolume3D;
100  bool mSlice3D;
101  bool mSlice2D;
102 };
103 
106 class cxResourceVisualization_EXPORT ViewGroupData: public QObject
107 {
108 Q_OBJECT
109 public:
110  explicit ViewGroupData(CoreServicesPtr services);
111  void requestInitialize();
112 // std::vector<DataPtr> getData() const;
113  std::vector<DataPtr> getData(DataViewProperties properties=DataViewProperties::createFull()) const;
114  QString getVideoSource() const;
115  void addData(QString uid);
116  void addDataSorted(QString uid);
117  void setVideoSource(QString uid);
118  bool removeData(QString uid);
119  void clearData();
120  std::vector<ImagePtr> getImages(DataViewProperties properties) const;
121  std::vector<MeshPtr> getMeshes(DataViewProperties properties) const;
122  std::vector<TrackedStreamPtr> getTrackedStreams(DataViewProperties properties) const;
123  std::vector<TrackedStreamPtr> getTracked2DStreams(DataViewProperties properties) const;
124  std::vector<ImagePtr> getImagesAndChangingImagesFromTrackedStreams(DataViewProperties properties, bool include2D = false) const;
125  DataViewProperties getProperties(QString uid);
126  void setProperties(QString uid, DataViewProperties properties);
127 
128  void initializeGlobal2DZoom(SyncedValuePtr val);
129  SyncedValuePtr getGroup2DZoom();
130  SyncedValuePtr getGlobal2DZoom();
131 
132  CameraDataPtr getCamera3D() { return mCamera3D; }
133 
134  PlaneTypeCollection getSliceDefinitions();
135  void setSliceDefinitions(PlaneTypeCollection val);
136  StringListPropertyPtr getSliceDefinitionProperty();
137 
138  // view options for this group.
139  struct Options
140  {
141  Options();
145  };
146 
147  Options getOptions() const;
148  void setOptions(Options options);
149  void setRegistrationMode(REGISTRATION_STATUS mode);
150 
151 
152  void addXml(QDomNode& dataNode);
153  void parseXml(QDomNode dataNode);
154 
155 private slots:
156  void purgeDataNotExistingInPatientModelService();
157 
158 signals:
159  void dataViewPropertiesChanged(QString uid);
160  void videoSourceChanged(QString uid);
161  void initialized();
162  void optionsChanged();
163 
164 private:
165  CoreServicesPtr mServices;
166  QString mVideoSource;
167  typedef std::pair<QString, DataViewProperties> DataAndViewProperties;
168  std::vector<DataAndViewProperties> mData;
169  CameraDataPtr mCamera3D;
170  Options mOptions;
171  SyncedValuePtr mGroup2DZoom;
172  SyncedValuePtr mGlobal2DZoom;
173  StringListPropertyPtr mSliceDefinitionProperty;
174  DataPtr getData(QString uid) const;
175 
176  struct data_equals
177  {
178  data_equals(QString uid) : mData(uid) {}
179  bool operator()(const DataAndViewProperties& right)
180  {
181  return mData == right.first;
182  }
183  QString mData;
184  };
185 
186  template<class DATA_TYPE>
187  std::vector<boost::shared_ptr<DATA_TYPE> > getDataOfType(DataViewProperties requiredProperties) const;
188  bool contains(QString uid) const;
189  void createSliceDefinitionProperty();
190 };
191 
192 
196 } //namespace cx
197 
198 #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:54
boost::shared_ptr< class VisServices > VisServicesPtr
Definition: cxMainWindow.h:62
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
boost::shared_ptr< class StringListProperty > StringListPropertyPtr
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
bool hasSlice2D() const