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