NorMIT-nav  2023.01.05-dev+develop.0da12
An IGT application
cxAcquisitionImplService.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 
13 #include "cxAcquisitionData.h"
14 #include "cxUSAcquisition.h"
18 #include "cxXMLNodeWrapper.h"
19 #include "cxVisServices.h"
20 #include "cxTrackingService.h"
21 
22 namespace cx
23 {
24 
26  mContext(context),
27  mUsReconstructService(new UsReconstructionServiceProxy(context))
28 {
29  mServices = VisServices::create(context);
30  mAcquisitionData.reset(new AcquisitionData(mServices, mUsReconstructService));
31  mAcquisition.reset(new Acquisition(mAcquisitionData));
32  mUsAcquisition.reset(new USAcquisition(mAcquisition));
33 
34  connect(mAcquisition.get(), &Acquisition::started, this, &AcquisitionService::started);
35  connect(mAcquisition.get(), &Acquisition::cancelled, this, &AcquisitionService::cancelled);
36  connect(mAcquisition.get(), &Acquisition::stateChanged, this, &AcquisitionService::stateChanged);
37  connect(mAcquisition.get(), &Acquisition::acquisitionStopped, this, &AcquisitionService::acquisitionStopped);
38  connect(mAcquisition.get(), &Acquisition::readinessChanged, this, &AcquisitionService::usReadinessChanged);
39 
41 
43  connect(mUsAcquisition.get(), &USAcquisition::saveDataCompleted, this, &AcquisitionService::saveDataCompleted);
44  connect(mUsAcquisition.get(), &USAcquisition::readinessChanged, this, &AcquisitionService::usReadinessChanged);
45 
46  connect(mServices->session().get(), &SessionStorageService::cleared, this, &AcquisitionImplService::duringClearPatientSlot);
47  connect(mServices->session().get(), &SessionStorageService::isLoading, this, &AcquisitionImplService::duringLoadPatientSlot);
48  connect(mServices->session().get(), &SessionStorageService::isSaving, this, &AcquisitionImplService::duringSavePatientSlot);
49 }
50 
52 {
53 }
54 
56 {
57  return false;
58 }
59 
60 void AcquisitionImplService::duringClearPatientSlot()
61 {
62  // clear data?
63  mAcquisitionData->clear();//TODO: Check if wee need this
64 }
65 
66 void AcquisitionImplService::duringSavePatientSlot(QDomElement& node)
67 {
68  XMLNodeAdder root(node);
69  QDomElement managerNode = root.descend("managers").node().toElement();
70  this->addXml(managerNode);
71 }
72 
73 void AcquisitionImplService::duringLoadPatientSlot(QDomElement& node)
74 {
75  XMLNodeParser root(node);
76  QDomElement stateManagerNode = root.descend("managers/stateManager").node().toElement();
77  if (!stateManagerNode.isNull())
78  this->parseXml(stateManagerNode);
79 }
80 
82 {
83  return mAcquisition->getLatestSession();
84 }
85 
86 std::vector<RecordSessionPtr> AcquisitionImplService::getSessions()
87 {
88  return mAcquisition->getPluginData()->getRecordSessions();
89 }
90 
92 {
93  return mUsAcquisition->isReady(context)
94  && mAcquisition->isReady(context);
95 }
96 
98 {
99  QString text;
100  text = mAcquisition->getInfoText(context) + "<br>" + mUsAcquisition->getInfoText(context);
101 
102  // remove redundant line breaks
103  QStringList list = text.split("<br>", QString::SkipEmptyParts);
104  text = list.join("<br>");
105 
106  //Make sure we have at least 2 lines to avoid "bouncing buttons"
107  if (list.size() < 2)
108  text.append("<br>");
109 
110  return text;
111 }
112 
114 {
115  return mAcquisition->getState();
116 }
117 
118 void AcquisitionImplService::startRecord(TYPES context, QString category, RecordSessionPtr session)
119 {
120  mServices->tracking()->resetTimeSynchronization();
121  mAcquisition->startRecord(context, category, session);
122 }
123 
125 {
126  mAcquisition->stopRecord();
127 }
128 
130 {
131  mAcquisition->cancelRecord();
132 }
133 
135 {
136  mAcquisition->startPostProcessing();
137 }
138 
140 {
141  mAcquisition->stopPostProcessing();
142 }
143 
145 {
146  return mUsAcquisition->getNumberOfSavingThreads();
147 }
148 
149 void AcquisitionImplService::addXml(QDomNode &dataNode)
150 {
151  mAcquisitionData->addXml(dataNode);
152 }
153 
154 void AcquisitionImplService::parseXml(QDomNode &dataNode)
155 {
156  mAcquisitionData->parseXml(dataNode);
157 }
158 
159 } // cx
cxUSAcquisition.h
cx::USAcquisition::acquisitionDataReady
void acquisitionDataReady()
emitted when data is acquired and sent to the reconstruction module
cx::AcquisitionService::acquisitionStopped
void acquisitionStopped()
cx::Acquisition::started
void started()
cx::AcquisitionImplService::stopRecord
virtual void stopRecord()
Definition: cxAcquisitionImplService.cpp:124
cx::Acquisition
Definition: cxAcquisitionData.h:82
cx::AcquisitionImplService::~AcquisitionImplService
virtual ~AcquisitionImplService()
Definition: cxAcquisitionImplService.cpp:51
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::AcquisitionImplService::AcquisitionImplService
AcquisitionImplService(ctkPluginContext *context)
Definition: cxAcquisitionImplService.cpp:25
cx::AcquisitionService::saveDataCompleted
void saveDataCompleted(QString mhdFilename)
emitted when data has been saved to file
cxUsReconstructionServiceProxy.h
cx::AcquisitionImplService::isNull
virtual bool isNull()
Definition: cxAcquisitionImplService.cpp:55
cx::AcquisitionService::stateChanged
void stateChanged()
cx::USAcquisition::readinessChanged
void readinessChanged()
cxPatientModelServiceProxy.h
cxAcquisitionImplService.h
cxSessionStorageServiceProxy.h
cx::AcquisitionData
Definition: cxAcquisitionData.h:41
cx::AcquisitionImplService::cancelRecord
virtual void cancelRecord()
Definition: cxAcquisitionImplService.cpp:129
cxXMLNodeWrapper.h
cx::AcquisitionImplService::getState
virtual STATE getState() const
Definition: cxAcquisitionImplService.cpp:113
cx::AcquisitionImplService::isReady
virtual bool isReady(TYPES context) const
Definition: cxAcquisitionImplService.cpp:91
cx::SessionStorageService::isSaving
void isSaving(QDomElement &root)
xml storage is available
cx::Acquisition::stateChanged
void stateChanged()
cx::AcquisitionImplService::stopPostProcessing
virtual void stopPostProcessing()
Definition: cxAcquisitionImplService.cpp:139
cx::AcquisitionImplService::getInfoText
virtual QString getInfoText(TYPES context) const
Definition: cxAcquisitionImplService.cpp:97
cx::VisServices::create
static VisServicesPtr create(ctkPluginContext *context)
Definition: cxVisServices.cpp:17
cx::AcquisitionService::recordedSessionsChanged
void recordedSessionsChanged()
cx::AcquisitionService::TYPES
QFlags< TYPE > TYPES
Definition: cxAcquisitionService.h:48
cx::AcquisitionImplService::startPostProcessing
virtual void startPostProcessing()
Definition: cxAcquisitionImplService.cpp:134
cx::UsReconstructionServiceProxy
Definition: cxUsReconstructionServiceProxy.h:27
cx::AcquisitionService::usReadinessChanged
void usReadinessChanged()
cx::AcquisitionData::recordedSessionsChanged
void recordedSessionsChanged()
cx::AcquisitionService::cancelled
void cancelled()
cx::AcquisitionImplService::startRecord
virtual void startRecord(TYPES context, QString category, RecordSessionPtr session)
Definition: cxAcquisitionImplService.cpp:118
cx::USAcquisition::saveDataCompleted
void saveDataCompleted(QString mhdFilename)
emitted when data has been saved to file
cx::AcquisitionImplService::getNumberOfSavingThreads
virtual int getNumberOfSavingThreads() const
Definition: cxAcquisitionImplService.cpp:144
cx::SessionStorageService::isLoading
void isLoading(QDomElement &root)
emitted while loading a session. Xml storage is available, getRootFolder() is set to loaded value.
cx::AcquisitionService::acquisitionDataReady
void acquisitionDataReady()
emitted when data is acquired and sent to the reconstruction module
cx::Acquisition::readinessChanged
void readinessChanged()
cx::USAcquisition
Handles the us acquisition process.
Definition: cxUSAcquisition.h:57
cx::AcquisitionService::started
void started()
cxTrackingService.h
cx::Acquisition::cancelled
void cancelled()
cxAcquisitionData.h
cx::Acquisition::acquisitionStopped
void acquisitionStopped()
cx::RecordSessionPtr
boost::shared_ptr< class RecordSession > RecordSessionPtr
Definition: cxAcquisitionService.h:28
cx::SessionStorageService::cleared
void cleared()
emitted when session is cleared, before isLoading is called
cx::AcquisitionImplService::getLatestSession
virtual RecordSessionPtr getLatestSession()
Definition: cxAcquisitionImplService.cpp:81
cx::AcquisitionService::STATE
STATE
Definition: cxAcquisitionService.h:51
cx::AcquisitionImplService::getSessions
virtual std::vector< RecordSessionPtr > getSessions()
Definition: cxAcquisitionImplService.cpp:86
cxVisServices.h