15 #include <boost/bind.hpp>
16 #include <ctkPluginContext.h>
35 #define M_PI 3.14159265358979323846
43 mPatientModelService(patientModelService),
44 mViewService(viewService),
45 mFileManagerService(filemanagerservice)
51 connect(mParams.get(), SIGNAL(changedInputSettings()),
this, SLOT(setSettings()));
56 boost::bind(&UsReconstructionImplService::onServiceAdded,
this, _1),
57 boost::bind(&UsReconstructionImplService::onServiceModified,
this, _1),
58 boost::bind(&UsReconstructionImplService::onServiceRemoved,
this, _1)
61 mServiceListener->open();
73 void UsReconstructionImplService::patientChangedSlot()
75 this->
selectData(mPatientModelService->getActivePatientFolder() +
"/US_Acq/");
81 QString name = mParams->getParameter(
"Algorithm")->getValueAsVariant().toString();
84 return mServiceListener->getServiceFromName(name);
87 void UsReconstructionImplService::setSettings()
90 this->updateFromOriginalFileData();
97 if(!mOutputVolumeParams.
isValid())
99 reportError(
"Cannot reconstruct from invalid ultrasound data");
111 connect(executer.get(), SIGNAL(
reconstructFinished()),
this, SLOT(reconstructFinishedSlot()));
112 mExecuters.push_back(executer);
114 bool success = executer->startReconstruction(algo, par, fileData, mParams->getCreateBModeWhenAngio()->getValue());
116 CX_LOG_WARNING() <<
"US reconstruction failed. Probably an error with input data.";
121 std::set<cx::TimedAlgorithmPtr> retval;
122 for (
unsigned i=0; i<mExecuters.size(); ++i)
123 retval.insert(mExecuters[i]->getThread());
127 void UsReconstructionImplService::reconstructFinishedSlot()
129 mOriginalFileData.
mUsRaw->purgeAll();
131 for (
unsigned i=0; i<mExecuters.size(); ++i)
133 if (mExecuters[i]->getThread()->isFinished())
139 disconnect(executer.get(), SIGNAL(
reconstructFinished()),
this, SLOT(reconstructFinishedSlot()));
141 mExecuters.erase(mExecuters.begin()+i);
147 void UsReconstructionImplService::clearAll()
149 mOriginalFileData = USReconstructInputData();
150 mOutputVolumeParams = OutputVolumeParams();
155 return mOutputVolumeParams;
160 mOutputVolumeParams = par;
166 if (mAlgoOptions.empty())
191 return mOriginalFileData;
196 return mParams->getParameter(uid);
201 if (filename.isEmpty())
212 CX_LOG_WARNING() <<
"UsReconstructionImplService::selectData: Invalid input data";
221 mOriginalFileData = fileData;
222 this->updateFromOriginalFileData();
226 void UsReconstructionImplService::updateFromOriginalFileData()
228 if (mFileManagerService->isNull() || !mOriginalFileData.
isValid())
234 if (preprocessor->getOutputVolumeParams().isValid())
235 mOutputVolumeParams = preprocessor->getOutputVolumeParams();
238 reportError(
"Input ultrasound data not valid for reconstruction");
248 par.
mAlgorithmUid = mParams->getAlgorithmAdapter()->getValue();
251 par.
mAngio = mParams->getAngioAdapter()->getValue();
258 par.
mMaskReduce = mParams->getMaskReduce()->getValue().toDouble();
259 par.
mOrientation = mParams->getOrientationAdapter()->getValue();
265 QStringList range = mParams->getAlgorithmAdapter()->getValueRange();
267 mParams->getAlgorithmAdapter()->setValueRange(range);
270 PropertyPtr algoName = mParams->getParameter(
"Algorithm");
271 if (algoName->getValueAsVariant().value<QString>().isEmpty())
272 algoName->setValueFromVariant(service->
getName());
275 void UsReconstructionImplService::onServiceModified(ReconstructionMethodService* service)
277 reportWarning(
"ReconstructionMethodService modified... Do not know what to do. Contact developer.");
280 void UsReconstructionImplService::onServiceRemoved(ReconstructionMethodService* service)
282 QStringList range = mParams->getAlgorithmAdapter()->getValueRange();
283 range.removeAll(service->getName());
284 mParams->getAlgorithmAdapter()->setValueRange(range);
286 QString algoname = mParams->getParameter(
"Algorithm")->getValueAsVariant().toString();
287 if (algoname==service->getName())