CustusX  16.12
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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;
127  virtual DataPtr createData(QString type, QString uid, QString name="") = 0;
128  virtual void removeData(QString uid) = 0;
129 
130  // extended Data interface
131  template <class DATA>
132  std::map<QString, boost::shared_ptr<DATA> > getDataOfType() const;
133  DataPtr getData(const QString& uid) const;
134  template <class DATA>
135  boost::shared_ptr<DATA> getData(const QString& uid) const;
136  template<class DATA>
137  boost::shared_ptr<DATA> createSpecificData(QString uid, QString name="");
138 
139  // streams
140  virtual std::map<QString, VideoSourcePtr> getStreams() const = 0;
141  VideoSourcePtr getStream(const QString &uid) const;
142  // patient registration
143  virtual Transform3D get_rMpr() const;
144  virtual RegistrationHistoryPtr get_rMpr_History() const = 0;
145 
146  // active data
147  virtual ActiveDataPtr getActiveData() const = 0;
148 
149  // landmarks
150  virtual LandmarksPtr getPatientLandmarks() const = 0;
151 
155  virtual std::map<QString, LandmarkProperty> getLandmarkProperties() const = 0;
156  virtual void setLandmarkName(QString uid, QString name) = 0;
157  virtual void setLandmarkActive(QString uid, bool active) = 0;
158  virtual QString addLandmark() = 0;
159  // utility
160  virtual void updateRegistration_rMpr(const QDateTime& oldTime, const RegistrationTransform& newTransform);
161 
162  virtual QString getActivePatientFolder() const = 0;
163  QString generateFilePath(QString folderName, QString ending);
164 
165  virtual bool isPatientValid() const = 0;
166  virtual DataPtr importData(QString fileName, QString &infoText) = 0;
167  virtual void exportPatient(PATIENT_COORDINATE_SYSTEM externalSpace) = 0;
168 
169  virtual PresetTransferFunctions3DPtr getPresetTransferFunctions3D() const = 0;
170 
171  virtual void setCenter(const Vector3D& center) = 0;
172  virtual Vector3D getCenter() const = 0;
173 
174  virtual void setOperatingTable(const OperatingTable& ot) = 0;
175  virtual OperatingTable getOperatingTable() const = 0;
176 
177  virtual CLINICAL_VIEW getClinicalApplication() const = 0;
178  virtual void setClinicalApplication(CLINICAL_VIEW application) = 0;
179 
180  virtual void autoSave() = 0;//TODO remove, and integrate into other functions
181  virtual bool isNull() = 0;
182 
183  static PatientModelServicePtr getNullObject();
184 
185  virtual void makeAvailable(const QString& uid, bool available) = 0;
186 
187 signals:
188  void operatingTableChanged();
189  void centerChanged();
190  void dataAddedOrRemoved();
191  void landmarkPropertiesChanged();
192  void clinicalApplicationChanged();
193  void rMprChanged();
194  void streamLoaded();
195  void patientChanged();
196  void videoAddedToTrackedStream();
197 };
198 
199 
200 template <class DATA>
201 std::map<QString, boost::shared_ptr<DATA> > PatientModelService::getDataOfType() const
202 {
203  std::map<QString, DataPtr> data = this->getDatas();
204  std::map<QString, boost::shared_ptr<DATA> > retval;
205  for (std::map<QString, DataPtr>::const_iterator i=data.begin(); i!=data.end(); ++i)
206  {
207  boost::shared_ptr<DATA> val = boost::dynamic_pointer_cast<DATA>(i->second);
208  if (val)
209  retval[val->getUid()] = val;
210  }
211  return retval;
212 }
213 
214 template <class DATA>
215 boost::shared_ptr<DATA> PatientModelService::getData(const QString& uid) const
216 {
217  return boost::dynamic_pointer_cast<DATA>(this->getData(uid));
218 }
219 
220 template<class DATA>
221 boost::shared_ptr<DATA> PatientModelService::createSpecificData(QString uid, QString name)
222 {
223  DataPtr retval = this->createData(DATA::getTypeName(), uid, name);
224  return boost::dynamic_pointer_cast<DATA>(retval);
225 }
226 
227 } // namespace cx
229 
230 
231 #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
virtual DataPtr createData(QString type, QString uid, QString name="")=0
Vector3D getVectorUp() const
Returns the table'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.
virtual std::map< QString, DataPtr > getDatas(DataFilter filter=HideUnavailable) const =0
The OperatingTable class.
boost::shared_ptr< DATA > createSpecificData(QString uid, QString name="")
#define PatientModelService_iid