36 #include <boost/bind.hpp>
37 #include <ctkPluginContext.h>
55 #define M_PI 3.14159265358979323846
63 mPatientModelService(patientModelService),
64 mViewService(viewService)
70 connect(mParams.get(), SIGNAL(changedInputSettings()),
this, SLOT(setSettings()));
75 boost::bind(&UsReconstructionImplService::onServiceAdded,
this, _1),
76 boost::bind(&UsReconstructionImplService::onServiceModified,
this, _1),
77 boost::bind(&UsReconstructionImplService::onServiceRemoved,
this, _1)
80 mServiceListener->open();
92 void UsReconstructionImplService::patientChangedSlot()
94 this->
selectData(mPatientModelService->getActivePatientFolder() +
"/US_Acq/");
100 QString name = mParams->getParameter(
"Algorithm")->getValueAsVariant().toString();
103 return mServiceListener->getServiceFromName(name);
106 void UsReconstructionImplService::setSettings()
108 mAlgoOptions.clear();
109 this->updateFromOriginalFileData();
116 if(!mOutputVolumeParams.
isValid())
118 reportError(
"Cannot reconstruct from invalid ultrasound data");
130 connect(executer.get(), SIGNAL(
reconstructFinished()),
this, SLOT(reconstructFinishedSlot()));
131 mExecuters.push_back(executer);
133 executer->startReconstruction(algo, par, fileData, mParams->getCreateBModeWhenAngio()->getValue());
138 std::set<cx::TimedAlgorithmPtr> retval;
139 for (
unsigned i=0; i<mExecuters.size(); ++i)
140 retval.insert(mExecuters[i]->getThread());
144 void UsReconstructionImplService::reconstructFinishedSlot()
146 mOriginalFileData.
mUsRaw->purgeAll();
148 for (
unsigned i=0; i<mExecuters.size(); ++i)
150 if (mExecuters[i]->getThread()->isFinished())
156 disconnect(executer.get(), SIGNAL(
reconstructFinished()),
this, SLOT(reconstructFinishedSlot()));
158 mExecuters.erase(mExecuters.begin()+i);
164 void UsReconstructionImplService::clearAll()
166 mOriginalFileData = USReconstructInputData();
167 mOutputVolumeParams = OutputVolumeParams();
172 return mOutputVolumeParams;
177 mOutputVolumeParams = par;
183 if (mAlgoOptions.empty())
208 return mOriginalFileData;
213 return mParams->getParameter(uid);
218 if (filename.isEmpty())
233 mOriginalFileData = fileData;
234 this->updateFromOriginalFileData();
238 void UsReconstructionImplService::updateFromOriginalFileData()
240 if (!mOriginalFileData.
isValid())
246 if (preprocessor->getOutputVolumeParams().isValid())
247 mOutputVolumeParams = preprocessor->getOutputVolumeParams();
250 reportError(
"Input ultrasound data not valid for reconstruction");
260 par.
mAlgorithmUid = mParams->getAlgorithmAdapter()->getValue();
263 par.
mAngio = mParams->getAngioAdapter()->getValue();
268 par.
mMaskReduce = mParams->getMaskReduce()->getValue().toDouble();
269 par.
mOrientation = mParams->getOrientationAdapter()->getValue();
275 QStringList range = mParams->getAlgorithmAdapter()->getValueRange();
277 mParams->getAlgorithmAdapter()->setValueRange(range);
280 PropertyPtr algoName = mParams->getParameter(
"Algorithm");
281 if (algoName->getValueAsVariant().value<QString>().isEmpty())
282 algoName->setValueFromVariant(service->
getName());
285 void UsReconstructionImplService::onServiceModified(ReconstructionMethodService* service)
287 reportWarning(
"ReconstructionMethodService modified... Do not know what to do. Contact developer.");
290 void UsReconstructionImplService::onServiceRemoved(ReconstructionMethodService* service)
292 QStringList range = mParams->getAlgorithmAdapter()->getValueRange();
293 range.removeAll(service->getName());
294 mParams->getAlgorithmAdapter()->setValueRange(range);
296 QString algoname = mParams->getParameter(
"Algorithm")->getValueAsVariant().toString();
297 if (algoname==service->getName())
void newInputDataAvailable(QString mhdFileName)
Reader class for the US Acquisition files.
void inputDataSelected(QString mhdFileName)
boost::shared_ptr< class ReconstructionExecuter > ReconstructionExecuterPtr
void reportError(QString msg)
virtual ~UsReconstructionImplService()
virtual PropertyPtr getParam(QString uid)
Return one of the standard parameters.
Abstract interface for reconstruction algorithm.
virtual QString getSelectedFilename() const
Get the currently selected filename.
virtual std::set< cx::TimedAlgorithmPtr > getThreadedReconstruction()
Return the currently reconstructing thread object(s).
void reconstructFinished()
virtual void selectData(QString filename, QString calFilesPath="")
Set input data for reconstruction.
virtual void newDataOnDisk(QString mhdFilename)
UsReconstructionImplService(ctkPluginContext *pluginContext, PatientModelServicePtr patientModelService, ViewServicePtr viewService, XmlOptionFile settings)
Helper struct for sending and controlling output volume properties.
QDomElement getElement()
return the current element
virtual std::vector< PropertyPtr > getSettings(QDomElement root)=0
virtual std::vector< PropertyPtr > getAlgoOptions()
Return control parameters for the currently selected algorithm, adjustable like getParams() ...
boost::shared_ptr< class UsReconstructionFileReader > UsReconstructionFileReaderPtr
boost::shared_ptr< class Property > PropertyPtr
void reportWarning(QString msg)
Collection of reconstruction parameters.
boost::shared_ptr< class ReconstructPreprocessor > ReconstructPreprocessorPtr
virtual QString getName() const =0
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
void reconstructStarted()
Settings * settings()
Shortcut for accessing the settings instance.
Algorithm part of reconstruction - no dependencies on parameter classes.
virtual void setOutputVolumeParams(const OutputVolumeParams &par)
Control the output volume.
void reconstructAboutToStart()
Helper class for listening to services being added, modified and removed.
virtual OutputVolumeParams getOutputVolumeParams() const
Return params controlling the output data. These are data-dependent.
virtual XmlOptionFile getSettings()
Return the settings xml file where parameters are stored.
cxLogicManager_EXPORT ViewServicePtr viewService()
virtual USReconstructInputData getSelectedFileData()
Return the currently selected input data.
void newInputDataPath(QString path)
virtual ReconstructionMethodService * createAlgorithm()
virtual void startReconstruction()
virtual ReconstructCore::InputParams createCoreParameters()
Helper class for xml files used to store ssc/cx data.