CustusX  15.3.3-beta
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 
63 cxResourceVisualization_EXPORT int getPriority(DataPtr data);
64 
67 cxResourceVisualization_EXPORT bool dataTypeSort(const DataPtr data1, const DataPtr data2);
68 
69 typedef boost::shared_ptr<class SyncedValue> SyncedValuePtr;
70 typedef boost::shared_ptr<class ViewGroupData> ViewGroupDataPtr;
71 
74 class cxResourceVisualization_EXPORT DataViewProperties
75 {
76 public:
77  DataViewProperties() : mVolume3D(false), mSlice3D(false), mSlice2D(false) {}
78  static DataViewProperties createDefault();
79  static DataViewProperties createFull();
80  static DataViewProperties createVolume3D();
81  static DataViewProperties createSlice3D();
82  static DataViewProperties createSlice2D();
83  static DataViewProperties create3D();
84  void addXml(QDomNode& dataNode);
85  void parseXml(QDomNode dataNode);
86  bool empty() const;
87  DataViewProperties addFlagsIn(DataViewProperties rhs) const;
88  DataViewProperties removeFlagsIn(DataViewProperties rhs) const;
89  bool containsAnyFlagsIn(DataViewProperties required) const;
90 
91  bool hasVolume3D() const { return mVolume3D; }
92  bool hasSlice3D() const { return mSlice3D; }
93  bool hasSlice2D() const { return mSlice2D; }
94 
95 private:
96  bool mVolume3D;
97  bool mSlice3D;
98  bool mSlice2D;
99 };
100 
103 class cxResourceVisualization_EXPORT ViewGroupData: public QObject
104 {
105 Q_OBJECT
106 public:
107  explicit ViewGroupData(CoreServicesPtr backend);
108  void requestInitialize();
109 // std::vector<DataPtr> getData() const;
110  std::vector<DataPtr> getData(DataViewProperties properties=DataViewProperties::createFull()) const;
111  QString getVideoSource() const;
112  void addData(QString uid);
113  void addDataSorted(QString uid);
114  void setVideoSource(QString uid);
115  bool removeData(QString uid);
116  void clearData();
117  std::vector<ImagePtr> getImages(DataViewProperties properties) const;
118  std::vector<MeshPtr> getMeshes(DataViewProperties properties) const;
119  DataViewProperties getProperties(QString uid);
120  void setProperties(QString uid, DataViewProperties properties);
121 
122  void initializeGlobal2DZoom(SyncedValuePtr val);
123  SyncedValuePtr getGroup2DZoom();
124  SyncedValuePtr getGlobal2DZoom();
125 
126  CameraDataPtr getCamera3D() { return mCamera3D; }
127 
128 // std::vector<ImagePtr> get3DSliceImages();
129  PlaneTypeCollection getSliceDefinitions() { return mSliceDefinitions; }
130  void setSliceDefinitions(PlaneTypeCollection val) { mSliceDefinitions = val; emit optionsChanged(); }
131 
132  // view options for this group.
133  struct Options
134  {
135  Options();
139  };
140 
141  Options getOptions() const;
142  void setOptions(Options options);
143  void setRegistrationMode(REGISTRATION_STATUS mode);
144 
145 
146  void addXml(QDomNode& dataNode);
147  void parseXml(QDomNode dataNode);
148 
149 private slots:
150  void dataAddedOrRemovedInManager();
151 
152 signals:
153  void dataViewPropertiesChanged(QString uid);
154  void videoSourceChanged(QString uid);
155  void initialized();
156  void optionsChanged();
157 
158 private:
159  CoreServicesPtr mBackend;
160  QString mVideoSource;
161  typedef std::pair<QString, DataViewProperties> DataAndViewProperties;
162  std::vector<DataAndViewProperties> mData;
163  PlaneTypeCollection mSliceDefinitions;
164  CameraDataPtr mCamera3D;
165  Options mOptions;
166  SyncedValuePtr mGroup2DZoom;
167  SyncedValuePtr mGlobal2DZoom;
168  DataPtr getData(QString uid) const;
169 
170  struct data_equals
171  {
172  data_equals(QString uid) : mData(uid) {}
173  bool operator()(const DataAndViewProperties& 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 };
184 
185 
189 } //namespace cx
190 
191 #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
PlaneTypeCollection getSliceDefinitions()
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 CoreServices > CoreServicesPtr
Definition: cxCameraStyle.h:59
boost::shared_ptr< class SyncedValue > SyncedValuePtr
Definition: cxViewGroup.h:51
boost::shared_ptr< class Mesh > MeshPtr
void setSliceDefinitions(PlaneTypeCollection val)
bool hasSlice2D() const