NorMIT-nav  2023.01.05-dev+develop.0da12
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
cx::PatientModelService::autoSave
virtual void autoSave()=0
cx::PatientModelService::get_rMpr_History
virtual RegistrationHistoryPtr get_rMpr_History() const =0
cx::PatientModelService::getDatas
virtual std::map< QString, DataPtr > getDatas(DataFilter filter=HideUnavailable) const =0
cxActiveData.h
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::PatientModelService::get_rMpr
virtual Transform3D get_rMpr() const
Definition: cxPatientModelService.cpp:45
cxImage.h
cx::PatientModelService::AllData
@ AllData
Definition: cxPatientModelService.h:94
cx::PatientModelService::updateRegistration_rMpr
virtual void updateRegistration_rMpr(const QDateTime &oldTime, const RegistrationTransform &newTransform)
Definition: cxPatientModelService.cpp:50
cxReporter.h
cx::VideoSourcePtr
boost::shared_ptr< class VideoSource > VideoSourcePtr
Definition: cxForwardDeclarations.h:109
cxPatientModelServiceNull.h
cx::PatientModelService::getData
DataPtr getData(const QString &uid) const
Definition: cxPatientModelService.cpp:33
cx::Transform3D
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
Definition: cxLandmarkPatientRegistrationWidget.h:33
cx::PatientModelService::getActiveData
virtual ActiveDataPtr getActiveData() const =0
cx::PatientModelServicePtr
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
Definition: cxLogicManager.h:25
cx::DataPtr
boost::shared_ptr< class Data > DataPtr
Definition: cxRegistrationApplicator.h:22
cxPatientModelService.h
cx::timestampSecondsFormat
QString timestampSecondsFormat()
Definition: cxTime.cpp:18
cx::RegistrationTransform::mTemp
bool mTemp
Definition: cxRegistrationTransform.h:48
cxRegistrationTransform.h
cxTime.h
cx::PatientModelService::getStreams
virtual std::map< QString, VideoSourcePtr > getStreams() const =0
cx::RegistrationTransform
A registration event and its transform.
Definition: cxRegistrationTransform.h:39
cx::PatientModelServiceNull
Null Object Pattern for Registration service.
Definition: cxPatientModelServiceNull.h:28
cxMesh.h
cx::PatientModelService::getActivePatientFolder
virtual QString getActivePatientFolder() const =0
cx::PatientModelService::getNullObject
static PatientModelServicePtr getNullObject()
Definition: cxPatientModelService.cpp:25
cx::PatientModelService::generateFilePath
QString generateFilePath(QString folderName, QString ending)
Definition: cxPatientModelService.cpp:66
cx::PatientModelService::getStream
VideoSourcePtr getStream(const QString &uid) const
Convenience function getting a specified stream.
Definition: cxPatientModelService.cpp:58
cxTrackedStream.h