Fraxinus  17.12-rc3
An IGT application
cxPatientModelService.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 
33 #ifndef CXPATIENTMODELSERVICE_H_
34 #define CXPATIENTMODELSERVICE_H_
35 
36 #include "cxResourceExport.h"
37 
38 #include <QObject>
39 #include <map>
40 #include "boost/shared_ptr.hpp"
41 #include "cxTransform3D.h"
42 #include "cxForwardDeclarations.h"
43 #include "vtkForwardDeclarations.h"
44 #include "cxDefinitions.h"
45 
46 class QDateTime;
47 class QDomElement;
48 
49 namespace cx
50 {
51 typedef boost::shared_ptr<class Data> DataPtr;
52 typedef boost::shared_ptr<class Image> ImagePtr;
53 }
54 
55 #define PatientModelService_iid "cx::PatientModelService"
56 
57 namespace cx
58 {
59 
60 class RegistrationTransform;
61 class LandmarkProperty;
62 typedef boost::shared_ptr<class PatientModelService> PatientModelServicePtr;
63 typedef boost::shared_ptr<class Landmarks> LandmarksPtr;
64 typedef boost::shared_ptr<class TransferFunctions3DPresets> PresetTransferFunctions3DPtr;
65 typedef boost::shared_ptr<class RegistrationHistory> RegistrationHistoryPtr;
66 
75 struct cxResource_EXPORT OperatingTable
76 {
77  explicit OperatingTable()
78  : rMot(Transform3D::Identity())
79  {}
81  : rMot(tr)
82  {}
84 
85  Vector3D getVectorUp() const {return rMot.vector(Vector3D(0,-1,0));}
86 };
87 
88 
106 class cxResource_EXPORT PatientModelService : public QObject
107 {
108  Q_OBJECT
109 public:
110  virtual ~PatientModelService() {}
111 
113  {
115  AllData
116  };
117 
118  // core Data interface
119  virtual void insertData(DataPtr data) = 0;
120  virtual std::map<QString, DataPtr> getDatas(DataFilter filter = HideUnavailable) const = 0;
121  virtual std::map<QString, DataPtr> getChildren(QString parent_uid, QString of_type="") const = 0;
128  virtual DataPtr createData(QString type, QString uid, QString name="") = 0;
129  virtual void removeData(QString uid) = 0;
130 
131  // extended Data interface
132  template <class DATA>
133  std::map<QString, boost::shared_ptr<DATA> > getDataOfType() const;
134  DataPtr getData(const QString& uid) const;
135  template <class DATA>
136  boost::shared_ptr<DATA> getData(const QString& uid) const;
137  template<class DATA>
138  boost::shared_ptr<DATA> createSpecificData(QString uid, QString name="");
139 
140  // streams
141  virtual std::map<QString, VideoSourcePtr> getStreams() const = 0;
142  VideoSourcePtr getStream(const QString &uid) const;
143  // patient registration
144  virtual Transform3D get_rMpr() const;
145  virtual RegistrationHistoryPtr get_rMpr_History() const = 0;
146 
147  // active data
148  virtual ActiveDataPtr getActiveData() const = 0;
149 
150  // landmarks
151  virtual LandmarksPtr getPatientLandmarks() const = 0;
152 
156  virtual std::map<QString, LandmarkProperty> getLandmarkProperties() const = 0;
157  virtual void setLandmarkName(QString uid, QString name) = 0;
158  virtual void setLandmarkActive(QString uid, bool active) = 0;
159  virtual QString addLandmark() = 0;
160  virtual void deleteLandmarks() = 0;
161  // utility
162  virtual void updateRegistration_rMpr(const QDateTime& oldTime, const RegistrationTransform& newTransform);
163 
164  virtual QString getActivePatientFolder() const = 0;
165  QString generateFilePath(QString folderName, QString ending);
166 
167  virtual bool isPatientValid() const = 0;
168  virtual DataPtr importData(QString fileName, QString &infoText) = 0;
169  virtual void exportPatient(PATIENT_COORDINATE_SYSTEM externalSpace) = 0;
170 
171  virtual PresetTransferFunctions3DPtr getPresetTransferFunctions3D() const = 0;
172 
173  virtual void setCenter(const Vector3D& center) = 0;
174  virtual Vector3D getCenter() const = 0;
175 
176  virtual void setOperatingTable(const OperatingTable& ot) = 0;
177  virtual OperatingTable getOperatingTable() const = 0;
178 
179  virtual CLINICAL_VIEW getClinicalApplication() const = 0;
180  virtual void setClinicalApplication(CLINICAL_VIEW application) = 0;
181 
182  virtual void autoSave() = 0;//TODO remove, and integrate into other functions
183  virtual bool isNull() = 0;
184 
185  static PatientModelServicePtr getNullObject();
186 
187  virtual void makeAvailable(const QString& uid, bool available) = 0;
188 
189 signals:
190  void operatingTableChanged();
191  void centerChanged();
192  void dataAddedOrRemoved();
193  void landmarkPropertiesChanged();
194  void clinicalApplicationChanged();
195  void rMprChanged();
196  void streamLoaded();
197  void patientChanged();
198  void videoAddedToTrackedStream();
199 };
200 
201 
202 template <class DATA>
203 std::map<QString, boost::shared_ptr<DATA> > PatientModelService::getDataOfType() const
204 {
205  std::map<QString, DataPtr> data = this->getDatas();
206  std::map<QString, boost::shared_ptr<DATA> > retval;
207  for (std::map<QString, DataPtr>::const_iterator i=data.begin(); i!=data.end(); ++i)
208  {
209  boost::shared_ptr<DATA> val = boost::dynamic_pointer_cast<DATA>(i->second);
210  if (val)
211  retval[val->getUid()] = val;
212  }
213  return retval;
214 }
215 
216 template <class DATA>
217 boost::shared_ptr<DATA> PatientModelService::getData(const QString& uid) const
218 {
219  return boost::dynamic_pointer_cast<DATA>(this->getData(uid));
220 }
221 
222 template<class DATA>
223 boost::shared_ptr<DATA> PatientModelService::createSpecificData(QString uid, QString name)
224 {
225  DataPtr retval = this->createData(DATA::getTypeName(), uid, name);
226  return boost::dynamic_pointer_cast<DATA>(retval);
227 }
228 
229 } // namespace cx
231 
232 
233 #endif /* CXPATIENTMODELSERVICE_H_ */
boost::shared_ptr< class RegistrationHistory > RegistrationHistoryPtr
Definition: cxDataManager.h:58
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
boost::shared_ptr< class TransferFunctions3DPresets > PresetTransferFunctions3DPtr
Definition: cxDataManager.h:57
boost::shared_ptr< class Image > ImagePtr
Definition: cxDicomWidget.h:48
boost::shared_ptr< class ActiveData > ActiveDataPtr
Definition: cxColorWidget.h:42
boost::shared_ptr< class Landmarks > LandmarksPtr
Definition: cxData.h:61
OperatingTable(Transform3D tr)
boost::shared_ptr< class Data > DataPtr
DataPtr getData(const QString &uid) const
Vector3D getVectorUp() const
Returns the table&#39;s up vector in R space.
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
boost::shared_ptr< class VideoSource > VideoSourcePtr
std::map< QString, boost::shared_ptr< DATA > > getDataOfType() const
Transform3D rMot
Transform from OT to reference space.
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:63
A registration event and its transform.
The OperatingTable class.
boost::shared_ptr< DATA > createSpecificData(QString uid, QString name="")
#define PatientModelService_iid
Namespace for all CustusX production code.