CustusX  15.8
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  {
105  std::map<QString, DataPtr> data = this->getData();
106  std::map<QString, boost::shared_ptr<DATA> > retval;
107  for (std::map<QString, DataPtr>::const_iterator i=data.begin(); i!=data.end(); ++i)
108  {
109  boost::shared_ptr<DATA> val = boost::dynamic_pointer_cast<DATA>(i->second);
110  if (val)
111  retval[val->getUid()] = val;
112  }
113  return retval;
114  }
115  DataPtr getData(const QString& uid) const;
116  template <class DATA>
117  boost::shared_ptr<DATA> getData(const QString& uid) const
118  {
119  return boost::dynamic_pointer_cast<DATA>(this->getData(uid));
120  }
121  template<class DATA>
122  boost::shared_ptr<DATA> createSpecificData(QString uid, QString name="")
123  {
124  DataPtr retval = this->createData(DATA::getTypeName(), uid, name);
125  return boost::dynamic_pointer_cast<DATA>(retval);
126  }
127 
128  QString getActiveImageUid();
129 
130  // streams
131  virtual std::map<QString, VideoSourcePtr> getStreams() const = 0;
132  VideoSourcePtr getStream(const QString &uid) const;
133  // patient registration
134  virtual Transform3D get_rMpr() const;
135  virtual RegistrationHistoryPtr get_rMpr_History() const = 0;
136  // active image
137  virtual ImagePtr getActiveImage() const = 0;
138  virtual void setActiveImage(ImagePtr activeImage) = 0;
139  // landmarks
140  virtual LandmarksPtr getPatientLandmarks() const = 0;
141 
145  virtual std::map<QString, LandmarkProperty> getLandmarkProperties() const = 0;
146  virtual void setLandmarkName(QString uid, QString name) = 0;
147  virtual void setLandmarkActive(QString uid, bool active) = 0;
148  virtual QString addLandmark() = 0;
149  // utility
150  virtual void updateRegistration_rMpr(const QDateTime& oldTime, const RegistrationTransform& newTransform);
151 
152  virtual QString getActivePatientFolder() const = 0;
153  QString generateFilePath(QString folderName, QString ending);
154 
155  virtual bool isPatientValid() const = 0;
156  virtual DataPtr importData(QString fileName, QString &infoText) = 0;
157  virtual void exportPatient(bool niftiFormat) = 0;
158 
159  virtual PresetTransferFunctions3DPtr getPresetTransferFunctions3D() const = 0;
160 
161  virtual void setCenter(const Vector3D& center) = 0;
162  virtual Vector3D getCenter() const = 0;
163 
164  virtual CLINICAL_VIEW getClinicalApplication() const = 0;
165  virtual void setClinicalApplication(CLINICAL_VIEW application) = 0;
166 
167 // virtual QDomElement getCurrentWorkingElement(QString path) = 0;
168 
169  virtual void autoSave() = 0;//TODO remove, and integrate into other functions
170  virtual bool isNull() = 0;
171 
172  static PatientModelServicePtr getNullObject();
173 
174 signals:
175  void centerChanged();
176  void dataAddedOrRemoved();
177  void activeImageChanged(const QString& uId);
178  void landmarkPropertiesChanged();
179  void clinicalApplicationChanged();
180  void rMprChanged();
181  void streamLoaded();
182  void patientChanged();
183 };
184 
185 } // namespace cx
187 
188 
189 #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< DATA > getData(const QString &uid) const
boost::shared_ptr< class Landmarks > LandmarksPtr
Definition: cxData.h:60
boost::shared_ptr< class Data > DataPtr
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
boost::shared_ptr< class VideoSource > VideoSourcePtr
boost::shared_ptr< DATA > createSpecificData(QString uid, QString name="")
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:63
A registration event and its transform.
std::map< QString, boost::shared_ptr< DATA > > getDataOfType() const
#define PatientModelService_iid