Fraxinus  16.5.0-fx-rc5
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 class RegistrationTransform;
60 class LandmarkProperty;
61 typedef boost::shared_ptr<class PatientModelService> PatientModelServicePtr;
62 typedef boost::shared_ptr<class Landmarks> LandmarksPtr;
63 typedef boost::shared_ptr<class TransferFunctions3DPresets> PresetTransferFunctions3DPtr;
64 typedef boost::shared_ptr<class RegistrationHistory> RegistrationHistoryPtr;
65 
83 class cxResource_EXPORT PatientModelService : public QObject
84 {
85  Q_OBJECT
86 public:
87  virtual ~PatientModelService() {}
88 
89  // core Data interface
90  virtual void insertData(DataPtr data) = 0;
91  virtual std::map<QString, DataPtr> getData() const = 0;
98  virtual DataPtr createData(QString type, QString uid, QString name="") = 0;
99  virtual void removeData(QString uid) = 0;
100 
101  // extended Data interface
102  template <class DATA>
103  std::map<QString, boost::shared_ptr<DATA> > getDataOfType() const;
104  DataPtr getData(const QString& uid) const;
105  template <class DATA>
106  boost::shared_ptr<DATA> getData(const QString& uid) const;
107  template<class DATA>
108  boost::shared_ptr<DATA> createSpecificData(QString uid, QString name="");
109 
110  // streams
111  virtual std::map<QString, VideoSourcePtr> getStreams() const = 0;
112  VideoSourcePtr getStream(const QString &uid) const;
113  // patient registration
114  virtual Transform3D get_rMpr() const;
115  virtual RegistrationHistoryPtr get_rMpr_History() const = 0;
116 
117  // active data
118  virtual ActiveDataPtr getActiveData() const = 0;
119 
120  // landmarks
121  virtual LandmarksPtr getPatientLandmarks() const = 0;
122 
126  virtual std::map<QString, LandmarkProperty> getLandmarkProperties() const = 0;
127  virtual void setLandmarkName(QString uid, QString name) = 0;
128  virtual void setLandmarkActive(QString uid, bool active) = 0;
129  virtual QString addLandmark() = 0;
130  // utility
131  virtual void updateRegistration_rMpr(const QDateTime& oldTime, const RegistrationTransform& newTransform, bool continuous);
132 
133  virtual QString getActivePatientFolder() const = 0;
134  QString generateFilePath(QString folderName, QString ending);
135 
136  virtual bool isPatientValid() const = 0;
137  virtual DataPtr importData(QString fileName, QString &infoText) = 0;
138  virtual void exportPatient(PATIENT_COORDINATE_SYSTEM externalSpace) = 0;
139 
140  virtual PresetTransferFunctions3DPtr getPresetTransferFunctions3D() const = 0;
141 
142  virtual void setCenter(const Vector3D& center) = 0;
143  virtual Vector3D getCenter() const = 0;
144 
145  virtual CLINICAL_VIEW getClinicalApplication() const = 0;
146  virtual void setClinicalApplication(CLINICAL_VIEW application) = 0;
147 
148  virtual void autoSave() = 0;//TODO remove, and integrate into other functions
149  virtual bool isNull() = 0;
150 
151  static PatientModelServicePtr getNullObject();
152 
153 signals:
154  void centerChanged();
155  void dataAddedOrRemoved();
156  void landmarkPropertiesChanged();
157  void clinicalApplicationChanged();
158  void rMprChanged();
159  void streamLoaded();
160  void patientChanged();
161  void videoAddedToTrackedStream();
162 };
163 
164 
165 template <class DATA>
166 std::map<QString, boost::shared_ptr<DATA> > PatientModelService::getDataOfType() const
167 {
168  std::map<QString, DataPtr> data = this->getData();
169  std::map<QString, boost::shared_ptr<DATA> > retval;
170  for (std::map<QString, DataPtr>::const_iterator i=data.begin(); i!=data.end(); ++i)
171  {
172  boost::shared_ptr<DATA> val = boost::dynamic_pointer_cast<DATA>(i->second);
173  if (val)
174  retval[val->getUid()] = val;
175  }
176  return retval;
177 }
178 
179 template <class DATA>
180 boost::shared_ptr<DATA> PatientModelService::getData(const QString& uid) const
181 {
182  return boost::dynamic_pointer_cast<DATA>(this->getData(uid));
183 }
184 
185 template<class DATA>
186 boost::shared_ptr<DATA> PatientModelService::createSpecificData(QString uid, QString name)
187 {
188  DataPtr retval = this->createData(DATA::getTypeName(), uid, name);
189  return boost::dynamic_pointer_cast<DATA>(retval);
190 }
191 
192 } // namespace cx
194 
195 
196 #endif /* CXPATIENTMODELSERVICE_H_ */
The virtual patient.
boost::shared_ptr< class RegistrationHistory > RegistrationHistoryPtr
Definition: cxDataManager.h:57
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
boost::shared_ptr< class TransferFunctions3DPresets > PresetTransferFunctions3DPtr
Definition: cxDataManager.h:56
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
boost::shared_ptr< class Data > DataPtr
virtual DataPtr createData(QString type, QString uid, QString name="")=0
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
boost::shared_ptr< class VideoSource > VideoSourcePtr
std::map< QString, boost::shared_ptr< DATA > > getDataOfType() const
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:63
A registration event and its transform.
boost::shared_ptr< DATA > createSpecificData(QString uid, QString name="")
virtual std::map< QString, DataPtr > getData() const =0
#define PatientModelService_iid