Fraxinus  2023.01.05-dev+develop.0da12
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) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 #ifndef CXPATIENTMODELSERVICE_H_
13 #define CXPATIENTMODELSERVICE_H_
14 
15 #include "cxResourceExport.h"
16 
17 #include <QObject>
18 #include <map>
19 #include "boost/shared_ptr.hpp"
20 #include "cxTransform3D.h"
21 #include "cxForwardDeclarations.h"
22 #include "vtkForwardDeclarations.h"
23 #include "cxDefinitions.h"
24 
25 class QDateTime;
26 class QDomElement;
27 
28 namespace cx
29 {
30 typedef boost::shared_ptr<class Data> DataPtr;
31 typedef boost::shared_ptr<class Image> ImagePtr;
32 }
33 
34 #define PatientModelService_iid "cx::PatientModelService"
35 
36 namespace cx
37 {
38 
39 class RegistrationTransform;
40 class LandmarkProperty;
41 typedef boost::shared_ptr<class PatientModelService> PatientModelServicePtr;
42 typedef boost::shared_ptr<class Landmarks> LandmarksPtr;
43 typedef boost::shared_ptr<class TransferFunctions3DPresets> PresetTransferFunctions3DPtr;
44 typedef boost::shared_ptr<class RegistrationHistory> RegistrationHistoryPtr;
45 
54 struct cxResource_EXPORT OperatingTable
55 {
56  explicit OperatingTable()
57  : rMot(Transform3D::Identity())
58  {}
60  : rMot(tr)
61  {}
63 
64  Vector3D getVectorUp() const {return rMot.vector(Vector3D(0,-1,0));}
65 };
66 
67 
85 class cxResource_EXPORT PatientModelService : public QObject
86 {
87  Q_OBJECT
88 public:
89  virtual ~PatientModelService() {}
90 
92  {
94  AllData
95  };
96 
97  // core Data interface
98  virtual void insertData(DataPtr data, bool overWrite = false) = 0;
99  virtual std::map<QString, DataPtr> getDatas(DataFilter filter = HideUnavailable) const = 0;
100  virtual std::map<QString, DataPtr> getChildren(QString parent_uid, QString of_type="") const = 0;
107  virtual DataPtr createData(QString type, QString uid, QString name="") = 0;
108  virtual void removeData(QString uid) = 0;
109 
110  // extended Data interface
111  template <class DATA>
112  std::map<QString, boost::shared_ptr<DATA> > getDataOfType() const;
113  DataPtr getData(const QString& uid) const;
114  template <class DATA>
115  boost::shared_ptr<DATA> getData(const QString& uid) const;
116  template<class DATA>
117  boost::shared_ptr<DATA> createSpecificData(QString uid, QString name="");
118 
119  // streams
120  virtual std::map<QString, VideoSourcePtr> getStreams() const = 0;
121  VideoSourcePtr getStream(const QString &uid) const;
122  // patient registration
123  virtual Transform3D get_rMpr() const;
124  virtual RegistrationHistoryPtr get_rMpr_History() const = 0;
125 
126  // active data
127  virtual ActiveDataPtr getActiveData() const = 0;
128 
129  // landmarks
130  virtual LandmarksPtr getPatientLandmarks() const = 0;
131 
135  virtual std::map<QString, LandmarkProperty> getLandmarkProperties() const = 0;
136  virtual void setLandmarkName(QString uid, QString name) = 0;
137  virtual void setLandmarkActive(QString uid, bool active) = 0;
138  virtual QString addLandmark() = 0;
139  virtual void deleteLandmarks() = 0;
140  // utility
141  virtual void updateRegistration_rMpr(const QDateTime& oldTime, const RegistrationTransform& newTransform);
142 
143  virtual QString getActivePatientFolder() const = 0;
144  QString generateFilePath(QString folderName, QString ending);
145 
146  virtual bool isPatientValid() const = 0;
147  virtual DataPtr importData(QString fileName, QString &infoText) = 0;
148  virtual void exportPatient(PATIENT_COORDINATE_SYSTEM externalSpace) = 0;
149 
150  virtual PresetTransferFunctions3DPtr getPresetTransferFunctions3D() const = 0;
151 
152  virtual void setCenter(const Vector3D& center) = 0;
153  virtual Vector3D getCenter() const = 0;
154 
155  virtual void setOperatingTable(const OperatingTable& ot) = 0;
156  virtual OperatingTable getOperatingTable() const = 0;
157 
158  virtual CLINICAL_VIEW getClinicalApplication() const = 0;
159  virtual void setClinicalApplication(CLINICAL_VIEW application) = 0;
160 
161  virtual void autoSave() = 0;//TODO remove, and integrate into other functions
162  virtual bool isNull() = 0;
163 
164  static PatientModelServicePtr getNullObject();
165 
166  virtual void makeAvailable(const QString& uid, bool available) = 0;
167 
168 signals:
169  void operatingTableChanged();
170  void centerChanged();
171  void dataAddedOrRemoved();
172  void landmarkPropertiesChanged();
173  void clinicalApplicationChanged();
174  void rMprChanged();
175  void streamLoaded();
176  void patientChanged();
177  void videoAddedToTrackedStream();
178 };
179 
180 
181 template <class DATA>
182 std::map<QString, boost::shared_ptr<DATA> > PatientModelService::getDataOfType() const
183 {
184  std::map<QString, DataPtr> data = this->getDatas();
185  std::map<QString, boost::shared_ptr<DATA> > retval;
186  for (std::map<QString, DataPtr>::const_iterator i=data.begin(); i!=data.end(); ++i)
187  {
188  boost::shared_ptr<DATA> val = boost::dynamic_pointer_cast<DATA>(i->second);
189  if (val)
190  retval[val->getUid()] = val;
191  }
192  return retval;
193 }
194 
195 template <class DATA>
196 boost::shared_ptr<DATA> PatientModelService::getData(const QString& uid) const
197 {
198  return boost::dynamic_pointer_cast<DATA>(this->getData(uid));
199 }
200 
201 template<class DATA>
202 boost::shared_ptr<DATA> PatientModelService::createSpecificData(QString uid, QString name)
203 {
204  DataPtr retval = this->createData(DATA::getTypeName(), uid, name);
205  return boost::dynamic_pointer_cast<DATA>(retval);
206 }
207 
208 } // namespace cx
210 
211 
212 #endif /* CXPATIENTMODELSERVICE_H_ */
The virtual patient.
boost::shared_ptr< class RegistrationHistory > RegistrationHistoryPtr
Definition: cxDataManager.h:37
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
boost::shared_ptr< class TransferFunctions3DPresets > PresetTransferFunctions3DPtr
Definition: cxDataManager.h:36
boost::shared_ptr< class Image > ImagePtr
Definition: cxDicomWidget.h:27
boost::shared_ptr< class ActiveData > ActiveDataPtr
Definition: cxColorWidget.h:21
boost::shared_ptr< class Landmarks > LandmarksPtr
Definition: cxData.h:41
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:42
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.