Fraxinus  18.10
An IGT application
cxPatientModelService.cpp
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 #include "cxPatientModelService.h"
14 #include "cxImage.h"
15 #include "cxMesh.h"
16 #include "cxTrackedStream.h"
18 #include <QDir>
19 #include "cxTime.h"
20 #include "cxReporter.h"
21 #include "cxActiveData.h"
22 
23 namespace cx
24 {
26 {
27  static PatientModelServicePtr mNull;
28  if (!mNull)
29  mNull.reset(new PatientModelServiceNull);
30  return mNull;
31 }
32 
33 DataPtr PatientModelService::getData(const QString& uid) const
34 {
35  if (uid=="active")
36  return this->getActiveData()->getActive();
37 
38  std::map<QString, DataPtr> all = this->getDatas(AllData);
39  std::map<QString, DataPtr>::const_iterator iter = all.find(uid);
40  if (iter == all.end())
41  return DataPtr();
42  return iter->second;
43 }
44 
46 {
47  return this->get_rMpr_History()->getCurrentRegistration().mValue;
48 }
49 
50 void PatientModelService::updateRegistration_rMpr(const QDateTime& oldTime, const RegistrationTransform& newTransform)
51 {
52  this->get_rMpr_History()->addOrUpdateRegistration(oldTime, newTransform);
53 
54  if(!newTransform.mTemp)
55  this->autoSave();
56 }
57 
59 {
60  std::map<QString, VideoSourcePtr> streams = this->getStreams();
61  if (streams.count(uid))
62  return streams.find(uid)->second;
63  return VideoSourcePtr();
64 }
65 
66 QString PatientModelService::generateFilePath(QString folderName, QString ending)
67 {
68  QString folder = this->getActivePatientFolder() + "/" +folderName + "/";
69  QDir().mkpath(folder);
70  QString format = timestampSecondsFormat();
71  QString filename = QDateTime::currentDateTime().toString(format) + "." + ending;
72 
73  return folder+filename;
74 }
75 
76 } //cx
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
static PatientModelServicePtr getNullObject()
virtual ActiveDataPtr getActiveData() const =0
QString generateFilePath(QString folderName, QString ending)
QString timestampSecondsFormat()
Definition: cxTime.cpp:18
virtual void autoSave()=0
boost::shared_ptr< class Data > DataPtr
virtual std::map< QString, VideoSourcePtr > getStreams() const =0
virtual RegistrationHistoryPtr get_rMpr_History() const =0
DataPtr getData(const QString &uid) const
virtual QString getActivePatientFolder() const =0
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
boost::shared_ptr< class VideoSource > VideoSourcePtr
virtual void updateRegistration_rMpr(const QDateTime &oldTime, const RegistrationTransform &newTransform)
VideoSourcePtr getStream(const QString &uid) const
Convenience function getting a specified stream.
A registration event and its transform.
virtual std::map< QString, DataPtr > getDatas(DataFilter filter=HideUnavailable) const =0
Null Object Pattern for Registration service.
virtual Transform3D get_rMpr() const
Namespace for all CustusX production code.