23 #include <QThreadPool>
32 #include <mapAlgorithmEvents.h>
33 #include <mapAlgorithmWrapperEvent.h>
34 #include <mapExceptionObjectMacros.h>
35 #include <mapImageRegistrationAlgorithmInterface.h>
36 #include <mapRegistrationAlgorithmInterface.h>
38 const mitk::Image *QmitkFramesRegistrationJob::GetTargetDataAsImage()
const
45 return m_spLoadedAlgorithm;
48 void QmitkFramesRegistrationJob::OnMapAlgorithmEvent(::itk::Object *,
const itk::EventObject &event)
50 const map::events::AlgorithmEvent *pAlgEvent =
dynamic_cast<const map::events::AlgorithmEvent *
>(&event);
51 const map::events::AlgorithmIterationEvent *pIterationEvent =
52 dynamic_cast<const map::events::AlgorithmIterationEvent *
>(&event);
53 const map::events::AlgorithmWrapperEvent *pWrapEvent =
54 dynamic_cast<const map::events::AlgorithmWrapperEvent *
>(&event);
55 const map::events::AlgorithmResolutionLevelEvent *pLevelEvent =
56 dynamic_cast<const map::events::AlgorithmResolutionLevelEvent *
>(&event);
58 const map::events::InitializingAlgorithmEvent *pInitEvent =
59 dynamic_cast<const map::events::InitializingAlgorithmEvent *
>(&event);
60 const map::events::StartingAlgorithmEvent *pStartEvent =
61 dynamic_cast<const map::events::StartingAlgorithmEvent *
>(&event);
62 const map::events::StoppingAlgorithmEvent *pStoppingEvent =
63 dynamic_cast<const map::events::StoppingAlgorithmEvent *
>(&event);
64 const map::events::StoppedAlgorithmEvent *pStoppedEvent =
65 dynamic_cast<const map::events::StoppedAlgorithmEvent *
>(&event);
66 const map::events::FinalizingAlgorithmEvent *pFinalizingEvent =
67 dynamic_cast<const map::events::FinalizingAlgorithmEvent *
>(&event);
68 const map::events::FinalizedAlgorithmEvent *pFinalizedEvent =
69 dynamic_cast<const map::events::FinalizedAlgorithmEvent *
>(&event);
70 const itk::ProgressEvent *pProgressEvent =
dynamic_cast<const itk::ProgressEvent *
>(&event);
71 const mitk::FrameRegistrationEvent *pFrameRegEvent =
dynamic_cast<const mitk::FrameRegistrationEvent *
>(&event);
72 const mitk::FrameMappingEvent *pFrameMapEvent =
dynamic_cast<const mitk::FrameMappingEvent *
>(&event);
78 else if (pFrameRegEvent)
82 else if (pFrameMapEvent)
94 else if (pStoppingEvent)
98 else if (pStoppedEvent)
102 if (!pStoppedEvent->getComment().empty())
104 emit
AlgorithmInfo(QString(
"Stopping condition: ") + QString::fromStdString(pStoppedEvent->getComment()));
107 else if (pFinalizingEvent)
111 else if (pFinalizedEvent)
115 else if (pIterationEvent)
117 const IIterativeAlgorithm *pIterative =
118 dynamic_cast<const IIterativeAlgorithm *
>(this->m_spLoadedAlgorithm.GetPointer());
120 map::algorithm::facet::IterativeAlgorithmInterface::IterationCountType count = 0;
121 bool hasCount =
false;
123 if (pIterative && pIterative->hasIterationCount())
126 count = pIterative->getCurrentIteration();
129 emit
AlgorithmIterated(QString::fromStdString(pIterationEvent->getComment()), hasCount, count);
131 else if (pLevelEvent)
133 const IMultiResAlgorithm *pResAlg =
134 dynamic_cast<const IMultiResAlgorithm *
>(this->m_spLoadedAlgorithm.GetPointer());
136 map::algorithm::facet::MultiResRegistrationAlgorithmInterface::ResolutionLevelCountType count = 0;
137 bool hasCount =
false;
138 QString
info = QString::fromStdString(pLevelEvent->getComment());
140 if (pResAlg && pResAlg->hasLevelCount())
142 count = pResAlg->getCurrentLevel() + 1;
144 info = QString(
"Level #") + QString::number(pResAlg->getCurrentLevel() + 1) + QString(
" ") +
info;
149 else if (pAlgEvent && !pWrapEvent)
151 emit
AlgorithmInfo(QString::fromStdString(pAlgEvent->getComment()));
156 : m_spLoadedAlgorithm(pAlgorithm), m_TargetDataUID(
"Missing target UID")
163 m_spCommand->SetCallbackFunction(
this, &QmitkFramesRegistrationJob::OnMapAlgorithmEvent);
164 m_ObserverID = m_spLoadedAlgorithm->AddObserver(::map::events::AlgorithmEvent(), m_spCommand);
169 m_spLoadedAlgorithm->RemoveObserver(m_ObserverID);
178 m_helper->Set4DImage(this->GetTargetDataAsImage());
180 m_helper->SetAlgorithm(this->m_spLoadedAlgorithm);
189 m_helper->AddObserver(::map::events::AnyMatchPointEvent(), m_spCommand);
190 m_helper->AddObserver(::itk::ProgressEvent(), m_spCommand);
193 m_spMappedImageNode = m_helper->GetRegisteredImage();
196 if (m_spMappedImageNode.IsNull())
198 emit
Error(QString(
"Error. No registration was determined. No results to store."));
205 catch (::std::exception &e)
207 emit
Error(QString(
"Error while registering data. Details: ") + QString::fromLatin1(e.what()));
211 emit
Error(QString(
"Unkown error when registering data."));
mitk::BaseData::ConstPointer m_spTargetData
void FrameRegistered(double progress)
void FrameMapped(double progress)
void AlgorithmStatusChanged(QString info)
QmitkFramesRegistrationJob(map::algorithm::RegistrationAlgorithmBase *pAlgorithm)
void AlgorithmIterated(QString info, bool hasIterationCount, unsigned long currentIteration)
const map::algorithm::RegistrationAlgorithmBase * GetLoadedAlgorithm() const
static void info(const char *fmt,...)
void LevelChanged(QString info, bool hasLevelCount, unsigned long currentLevel)
void FrameProcessed(double progress)
mitk::Image::ConstPointer m_spTargetMask
Image class for storing images.
mitk::ImageMappingInterpolator::Type m_InterpolatorType
~QmitkFramesRegistrationJob()
void AlgorithmInfo(QString info)
void ResultIsAvailable(mitk::Image::Pointer spResult, const QmitkFramesRegistrationJob *pJob)
mitk::TimeFramesRegistrationHelper::IgnoreListType m_IgnoreList
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.