Fraxinus  16.5.0-fx-rc9
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cxUsReconstructionServiceProxy.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 
35 #include <boost/bind.hpp>
36 //#include <QString.h>
37 
38 //#include "cxUSReconstructInputData.h"
39 #include "cxLogger.h"
40 
41 //#include <set>
42 //#include "cxForwardDeclarations.h"
43 //#include "cxXmlOptionItem.h"
44 //#include "cxReconstructCore.h"
46 //#include "cxReconstructedOutputVolumeParams.h"
47 //#include "cxReconstructionMethodService.h"
48 //#include "cxServiceTrackerListener.h"
49 
50 #include "cxNullDeleter.h"
51 
52 namespace cx {
53 
55  mPluginContext(pluginContext),
56  mUsReconstructionService(UsReconstructionService::getNullObject())
57 {
58  this->initServiceListener();
59 }
60 
61 
62 void UsReconstructionServiceProxy::initServiceListener()
63 {
64  mServiceListener.reset(new ServiceTrackerListener<UsReconstructionService>(
65  mPluginContext,
66  boost::bind(&UsReconstructionServiceProxy::onServiceAdded, this, _1),
67  boost::function<void (UsReconstructionService*)>(),
68  boost::bind(&UsReconstructionServiceProxy::onServiceRemoved, this, _1)
69  ));
70  mServiceListener->open();
71 }
72 void UsReconstructionServiceProxy::onServiceAdded(UsReconstructionService* service)
73 {
74  mUsReconstructionService.reset(service, null_deleter());
83 
84  if(mUsReconstructionService->isNull())
85  reportWarning("UsReconstructionServiceProxy::onServiceAdded mVideoService->isNull()");
86 
87  emit paramsChanged();
88  emit algorithmChanged();
89 }
90 
91 void UsReconstructionServiceProxy::onServiceRemoved(UsReconstructionService *service)
92 {
101  mUsReconstructionService = UsReconstructionService::getNullObject();
102 
103  emit paramsChanged();
104  emit algorithmChanged();
105 }
106 
108 {
109  return mUsReconstructionService->isNull();
110 }
111 
112 
113 
114 void UsReconstructionServiceProxy::selectData(QString filename, QString calFilesPath)
115 {
116  mUsReconstructionService->selectData(filename, calFilesPath);
117 }
118 
120 {
121  mUsReconstructionService->selectData(data);
122 }
123 
125 {
126  return mUsReconstructionService->getSelectedFilename();
127 }
128 
130 {
131  return mUsReconstructionService->getSelectedFileData();
132 }
133 
135 {
136  return mUsReconstructionService->getParam(uid);
137 }
138 
139 //ReconstructParamsPtr UsReconstructionServiceProxy::getParams()
140 //{
141 // return mUsReconstructionService->getParams();
142 //}
143 
145 {
146  return mUsReconstructionService->getAlgoOptions();
147 }
148 
150 {
151  return mUsReconstructionService->getSettings();
152 }
153 
155 {
156  return mUsReconstructionService->getOutputVolumeParams();
157 }
158 
160 {
161  mUsReconstructionService->setOutputVolumeParams(par);
162 }
163 
164 //void UsReconstructionServiceProxy::setOutputRelativePath(QString path)
165 //{
166 // mUsReconstructionService->setOutputRelativePath(path);
167 //}
168 
169 //void UsReconstructionServiceProxy::setOutputBasePath(QString path)
170 //{
171 // mUsReconstructionService->setOutputBasePath(path);
172 //}
173 
175 {
176  mUsReconstructionService->startReconstruction();
177 }
178 
180 {
181  return mUsReconstructionService->getThreadedReconstruction();
182 }
183 
185 {
186  return mUsReconstructionService->createAlgorithm();
187 }
188 
190 {
191  return mUsReconstructionService->createCoreParameters();
192 }
193 
195 {
196  return mUsReconstructionService->newDataOnDisk(mhdFilename);
197 }
198 
199 } //cx
void newInputDataAvailable(QString mhdFileName)
virtual void setOutputVolumeParams(const OutputVolumeParams &par)
Control the output volume.
void inputDataSelected(QString mhdFileName)
Abstract interface for reconstruction algorithm.
virtual std::vector< PropertyPtr > getAlgoOptions()
Return control parameters for the currently selected algorithm, adjustable like getParams() ...
virtual std::set< cx::TimedAlgorithmPtr > getThreadedReconstruction()
Return the currently reconstructing thread object(s).
virtual void selectData(QString filename, QString calFilesPath="")
Set input data for reconstruction.
virtual XmlOptionFile getSettings()
Return the settings xml file where parameters are stored.
static UsReconstructionServicePtr getNullObject()
virtual ReconstructionMethodService * createAlgorithm()
Helper struct for sending and controlling output volume properties.
boost::shared_ptr< class Property > PropertyPtr
void reportWarning(QString msg)
Definition: cxLogger.cpp:91
virtual OutputVolumeParams getOutputVolumeParams() const
Return params controlling the output data. These are data-dependent.
virtual USReconstructInputData getSelectedFileData()
Return the currently selected input data.
virtual ReconstructCore::InputParams createCoreParameters()
virtual void newDataOnDisk(QString mhdFilename)
UsReconstructionServiceProxy(ctkPluginContext *pluginContext)
Helper class for listening to services being added, modified and removed.
void newInputDataPath(QString path)
virtual PropertyPtr getParam(QString uid)
Return one of the standard parameters.
Helper class for xml files used to store ssc/cx data.
virtual QString getSelectedFilename() const
Get the currently selected filename.