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