CustusX  15.8
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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) 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 
34 #include "cxAcquisitionData.h"
35 #include "cxUSAcquisition.h"
39 #include "cxXMLNodeWrapper.h"
40 #include "cxVisServices.h"
41 
42 namespace cx
43 {
44 
46  mContext(context),
47  mUsReconstructService(new UsReconstructionServiceProxy(context))
48 // mPatientModelService(new PatientModelServiceProxy(context)),
49 // mSession(SessionStorageServiceProxy::create(context))
50 {
51  mServices = VisServices::create(context);
52  mAcquisitionData.reset(new AcquisitionData(mServices, mUsReconstructService));
53  mAcquisition.reset(new Acquisition(mAcquisitionData));
54  mUsAcquisition.reset(new USAcquisition(mAcquisition));
55 
56  connect(mAcquisition.get(), &Acquisition::started, this, &AcquisitionService::started);
57  connect(mAcquisition.get(), &Acquisition::cancelled, this, &AcquisitionService::cancelled);
58  connect(mAcquisition.get(), &Acquisition::stateChanged, this, &AcquisitionService::stateChanged);
59  connect(mAcquisition.get(), &Acquisition::acquisitionStopped, this, &AcquisitionService::acquisitionStopped);
60 
62 
64  connect(mUsAcquisition.get(), &USAcquisition::saveDataCompleted, this, &AcquisitionService::saveDataCompleted);
65  connect(mUsAcquisition.get(), &USAcquisition::readinessChanged, this, &AcquisitionService::usReadinessChanged);
66 
67  connect(mServices->getSession().get(), &SessionStorageService::cleared, this, &AcquisitionImplService::duringClearPatientSlot);
68  connect(mServices->getSession().get(), &SessionStorageService::isLoading, this, &AcquisitionImplService::duringLoadPatientSlot);
69  connect(mServices->getSession().get(), &SessionStorageService::isSaving, this, &AcquisitionImplService::duringSavePatientSlot);
70 }
71 
73 {
74 }
75 
77 {
78  return false;
79 }
80 
81 void AcquisitionImplService::duringClearPatientSlot()
82 {
83  // clear data?
84  mAcquisitionData->clear();//TODO: Check if wee need this
85 }
86 
87 void AcquisitionImplService::duringSavePatientSlot(QDomElement& node)
88 {
89  XMLNodeAdder root(node);
90  QDomElement managerNode = root.descend("managers").node().toElement();
91  this->addXml(managerNode);
92 
93 // QDomElement managerNode = mPatientModelService->getCurrentWorkingElement("managers");
94 // if(managerNode.isNull())
95 // reportWarning("AcquisitionImplService::duringSavePatientSlot() Try managers node. Got null node");
96 // this->addXml(managerNode);
97 }
98 
99 void AcquisitionImplService::duringLoadPatientSlot(QDomElement& node)
100 {
101  XMLNodeParser root(node);
102  QDomElement stateManagerNode = root.descend("managers/stateManager").node().toElement();
103  if (!stateManagerNode.isNull())
104  this->parseXml(stateManagerNode);
105 
106 // QDomElement stateManagerNode = mPatientModelService->getCurrentWorkingElement("managers/stateManager");
107 // if(stateManagerNode.isNull())
108 // reportWarning("AcquisitionImplService::duringSavePatientSlot() Try stateManagerNode node. Got null node");
109 // this->parseXml(stateManagerNode);
110 }
111 
113 {
114  return mAcquisition->getLatestSession();
115 }
116 
117 std::vector<RecordSessionPtr> AcquisitionImplService::getSessions()
118 {
119  return mAcquisition->getPluginData()->getRecordSessions();
120 }
121 
123 {
124  return mUsAcquisition->isReady();
125 }
126 
128 {
129  return mUsAcquisition->getInfoText();
130 }
131 
133 {
134  return mAcquisition->getState();
135 }
136 
138 {
139  mAcquisition->toggleRecord();
140 }
141 
143 {
144  mAcquisition->startRecord();
145 }
146 
148 {
149  mAcquisition->stopRecord();
150 }
151 
153 {
154  mAcquisition->cancelRecord();
155 }
156 
158 {
159  mAcquisition->startPostProcessing();
160 }
161 
163 {
164  mAcquisition->stopPostProcessing();
165 }
166 
168 {
169  return mUsAcquisition->getNumberOfSavingThreads();
170 }
171 
172 void AcquisitionImplService::addXml(QDomNode &dataNode)
173 {
174  mAcquisitionData->addXml(dataNode);
175 }
176 
177 void AcquisitionImplService::parseXml(QDomNode &dataNode)
178 {
179  mAcquisitionData->parseXml(dataNode);
180 }
181 
182 } // cx
AcquisitionImplService(ctkPluginContext *context)
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
void saveDataCompleted(QString mhdFilename)
emitted when data has been saved to file
virtual QString getInfoText() const
virtual int getNumberOfSavingThreads() const
static VisServicesPtr create(ctkPluginContext *context)
boost::shared_ptr< class RecordSession > RecordSessionPtr
void recordedSessionsChanged()
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()