diff --git a/Plugins/org.mitk.gui.qt.matchpoint.algorithm.batch/src/internal/QmitkMatchPointBatchProcessor.cpp b/Plugins/org.mitk.gui.qt.matchpoint.algorithm.batch/src/internal/QmitkMatchPointBatchProcessor.cpp index c05d39ccfc..b86f2b2419 100644 --- a/Plugins/org.mitk.gui.qt.matchpoint.algorithm.batch/src/internal/QmitkMatchPointBatchProcessor.cpp +++ b/Plugins/org.mitk.gui.qt.matchpoint.algorithm.batch/src/internal/QmitkMatchPointBatchProcessor.cpp @@ -1,742 +1,742 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "org_mitk_gui_qt_matchpoint_algorithm_batch_Activator.h" // Blueberry #include #include #include #include // Mitk #include #include #include #include #include #include #include // Qt #include #include #include #include // MatchPoint #include #include #include #include #include #include #include // Qmitk #include "QmitkMatchPointBatchProcessor.h" const std::string QmitkMatchPointBatchProcessor::VIEW_ID = "org.mitk.views.matchpoint.algorithm.batchprocessing"; QmitkMatchPointBatchProcessor::QmitkMatchPointBatchProcessor() : m_Parent(nullptr), m_LoadedDLLHandle(nullptr), m_LoadedAlgorithm(nullptr) { m_CanLoadAlgorithm = false; m_ValidInputs = false; m_Working = false; } QmitkMatchPointBatchProcessor::~QmitkMatchPointBatchProcessor() { // remove selection service berry::ISelectionService* s = GetSite()->GetWorkbenchWindow()->GetSelectionService(); if (s) { s->RemoveSelectionListener(m_AlgorithmSelectionListener.data()); } } void QmitkMatchPointBatchProcessor::SetFocus() { } void QmitkMatchPointBatchProcessor::CreateConnections() { // show first page m_Controls.m_tabs->setCurrentIndex(0); // ------ // Tab 1 - Shared library loading interface // ------ connect(m_Controls.m_pbLoadSelected, SIGNAL(clicked()), this, SLOT(OnLoadAlgorithmButtonPushed())); // ----- // Tab 2 - Input // ----- connect(m_Controls.m_pbLockTarget, SIGNAL(clicked()), this, SLOT(OnLockTargetButtonPushed())); connect(m_Controls.m_pbLockMoving, SIGNAL(clicked()), this, SLOT(OnLockMovingButtonPushed())); // ----- // Tab 3 - Execution // ----- connect(m_Controls.m_pbStartReg, SIGNAL(clicked()), this, SLOT(OnStartRegBtnPushed())); } const map::deployment::DLLInfo* QmitkMatchPointBatchProcessor::GetSelectedAlgorithmDLL() const { return m_SelectedAlgorithmInfo; } void QmitkMatchPointBatchProcessor::OnSelectedAlgorithmChanged() { std::stringstream descriptionString; ::map::deployment::DLLInfo::ConstPointer currentItemInfo = GetSelectedAlgorithmDLL(); if (!currentItemInfo) { Error(QString("No valid algorithm is selected. ABORTING.")); return; } m_Controls.m_teAlgorithmDetails->updateInfo(currentItemInfo); m_Controls.m_lbSelectedAlgorithm->setText(QString::fromStdString( currentItemInfo->getAlgorithmUID().getName())); // enable loading m_CanLoadAlgorithm = true; this->UpdateAlgorithmSelectionGUI(); } void QmitkMatchPointBatchProcessor::OnLoadAlgorithmButtonPushed() { map::deployment::DLLInfo::ConstPointer dllInfo = GetSelectedAlgorithmDLL(); if (!dllInfo) { Error(QString("No valid algorithm is selected. Cannot load algorithm. ABORTING.")); return; } ::map::deployment::DLLHandle::Pointer tempDLLHandle = ::map::deployment::openDeploymentDLL( dllInfo->getLibraryFilePath()); ::map::algorithm::RegistrationAlgorithmBase::Pointer tempAlgorithm = ::map::deployment::getRegistrationAlgorithm(tempDLLHandle); if (tempAlgorithm.IsNull()) { Error(QString("Error. Cannot load selected algorithm.")); return; } this->m_LoadedAlgorithm = tempAlgorithm; this->m_LoadedDLLHandle = tempDLLHandle; this->m_Controls.m_AlgoConfigurator->setAlgorithm(m_LoadedAlgorithm); this->CheckInputs(); this->ConfigureRegistrationControls(); this->ConfigureProgressInfos(); this->m_Controls.m_tabs->setCurrentIndex(1); this->UpdateAlgorithmSelectionGUI(); } void QmitkMatchPointBatchProcessor::OnLockTargetButtonPushed() { if (this->m_Controls.m_pbLockTarget->isChecked()) { if (this->m_spSelectedTargetNode.IsNotNull()) { this->m_spSelectedTargetNode->SetSelected(false); this->GetDataStorage()->Modified(); } } this->CheckInputs(); this->ConfigureRegistrationControls(); } void QmitkMatchPointBatchProcessor::OnLockMovingButtonPushed() { if (this->m_Controls.m_pbLockMoving->isChecked()) { if (!this->m_selectedMovingNodes.empty()) { for (NodeListType::const_iterator pos = m_selectedMovingNodes.begin(); pos != m_selectedMovingNodes.end(); ++pos) { (*pos)->SetSelected(false); } this->GetDataStorage()->Modified(); } } this->CheckInputs(); this->ConfigureRegistrationControls(); } void QmitkMatchPointBatchProcessor::Error(QString msg) { mitk::StatusBar::GetInstance()->DisplayErrorText(msg.toLatin1()); MITK_ERROR << msg.toStdString().c_str(); m_Controls.m_teLog->append(QString("") + msg + QString("")); } void QmitkMatchPointBatchProcessor::UpdateAlgorithmSelectionGUI() { m_Controls.m_pbLoadSelected->setEnabled(m_CanLoadAlgorithm); } void QmitkMatchPointBatchProcessor::CreateQtPartControl(QWidget* parent) { // create GUI widgets from the Qt Designer's .ui file m_Controls.setupUi(parent); m_Parent = parent; m_AlgorithmSelectionListener.reset(new berry::SelectionChangedAdapter(this, &QmitkMatchPointBatchProcessor::OnAlgorithmSelectionChanged)); // register selection listener GetSite()->GetWorkbenchWindow()->GetSelectionService()->AddSelectionListener( m_AlgorithmSelectionListener.data()); this->CreateConnections(); this->UpdateAlgorithmSelectionGUI(); this->CheckInputs(); this->ConfigureProgressInfos(); this->ConfigureRegistrationControls(); berry::ISelection::ConstPointer selection = GetSite()->GetWorkbenchWindow()->GetSelectionService()->GetSelection("org.mitk.views.matchpoint.algorithm.browser"); this->UpdateAlgorithmSelection(selection); } void QmitkMatchPointBatchProcessor::CheckInputs() { bool validMoving = false; bool validTarget = false; NodeListType dataNodes = this->GetSelectedDataNodes(); //first set the internal nodes according to selection if (!m_Controls.m_pbLockTarget->isChecked()) { mitk::DataNode::Pointer targetNode = nullptr; if (dataNodes.size() > 0) { targetNode = dataNodes.front(); dataNodes.pop_front(); mitk::Image* targetImage = dynamic_cast(targetNode->GetData()); if (targetImage) { if (m_LoadedAlgorithm.IsNotNull()) { if (targetImage->GetDimension() != m_LoadedAlgorithm->getTargetDimensions()) { m_Controls.m_lbTargetName->setText(QString("wrong image dimension. ") + QString::number(m_LoadedAlgorithm->getTargetDimensions()) + QString("D needed")); } else { validTarget = true; } } else { validTarget = true; } if (validTarget) { m_Controls.m_lbTargetName->setText(QString::fromStdString(targetNode->GetName())); } } } this->m_spSelectedTargetNode = targetNode; } else { validTarget = true; } if (this->m_spSelectedTargetNode.IsNull()) { m_Controls.m_lbTargetName->setText(QString("no data selected!")); } if (!m_Controls.m_pbLockMoving->isChecked()) { m_selectedMovingNodes.clear(); this->m_Controls.m_listMovingNames->clear(); if (dataNodes.size() > 0) { for (NodeListType::const_iterator pos = dataNodes.begin(); pos != dataNodes.end(); ++pos) { this->m_Controls.m_listMovingNames->addItem(QString::fromStdString((*pos)->GetName())); } } m_selectedMovingNodes = dataNodes; validMoving = !m_selectedMovingNodes.empty(); } else { validMoving = true; } if (this->m_selectedMovingNodes.size() == 0) { this->m_Controls.m_listMovingNames->addItem(QString("no data selected!")); } this->m_Controls.m_pbLockMoving->setEnabled(this->m_selectedMovingNodes.size() > 0); this->m_Controls.m_pbLockTarget->setEnabled(this->m_spSelectedTargetNode.IsNotNull()); m_ValidInputs = validMoving && validTarget; } mitk::DataStorage::SetOfObjects::Pointer QmitkMatchPointBatchProcessor::GetRegNodes() const { mitk::DataStorage::SetOfObjects::ConstPointer nodes = this->GetDataStorage()->GetAll(); mitk::DataStorage::SetOfObjects::Pointer result = mitk::DataStorage::SetOfObjects::New(); for (mitk::DataStorage::SetOfObjects::const_iterator pos = nodes->begin(); pos != nodes->end(); ++pos) { if (mitk::MITKRegistrationHelper::IsRegNode(*pos)) { result->push_back(*pos); } } return result; } QList QmitkMatchPointBatchProcessor::GetSelectedDataNodes() { NodeListType nodes = m_currentlySelectedNodes; //this->GetDataManagerSelection(); NodeListType result; /**@TODO rework to use mitk node filter mechanism*/ for (NodeListType::iterator pos = nodes.begin(); pos != nodes.end(); ++pos) { mitk::Image* image = dynamic_cast((*pos)->GetData()); if (image) { result.push_back(*pos); } } return result; } std::string QmitkMatchPointBatchProcessor::GetDefaultRegJobName() const { mitk::DataStorage::SetOfObjects::ConstPointer nodes = this->GetRegNodes().GetPointer(); mitk::DataStorage::SetOfObjects::ElementIdentifier estimatedIndex = nodes->Size(); bool isUnique = false; std::string result = "Unnamed Reg"; while (!isUnique) { ++estimatedIndex; result = "Reg #" +::map::core::convert::toStr(estimatedIndex); isUnique = this->GetDataStorage()->GetNamedNode(result) == nullptr; } return result; } void QmitkMatchPointBatchProcessor::ConfigureRegistrationControls() { m_Controls.m_pageSelection->setEnabled(!m_Working); m_Controls.m_leRegJobName->setEnabled(!m_Working); m_Controls.m_pbStartReg->setEnabled(false); /**@TODO reactivate as soon as crex processor allows to stop batch processing.*/ //m_Controls.m_pbStopReg->setEnabled(false); //m_Controls.m_pbStopReg->setVisible(false); if (m_LoadedAlgorithm.IsNotNull()) { m_Controls.m_pageSettings->setEnabled(!m_Working); m_Controls.m_pageExecution->setEnabled(true); m_Controls.m_pbStartReg->setEnabled(m_ValidInputs && !m_Working); ///////////////////////////////////////////// - const IStoppableAlgorithm* pIterativ = dynamic_cast - (m_LoadedAlgorithm.GetPointer()); + //const IStoppableAlgorithm* pIterativ = dynamic_cast + // (m_LoadedAlgorithm.GetPointer()); /**@TODO reactivate as soon as crex processor allows to stop batch processing.*/ //if (pIterativ) //{ // m_Controls.m_pbStopReg->setVisible(pIterativ->isStoppable()); //} ////if the stop button is set to visible and the algorithm is working -> ////then the algorithm is stoppable, thus enable the button. //m_Controls.m_pbStopReg->setEnabled(m_Controls.m_pbStopReg->isVisible() && m_Working); this->m_Controls.m_lbLoadedAlgorithmName->setText( QString::fromStdString(m_LoadedAlgorithm->getUID()->toStr())); } else { m_Controls.m_pageSettings->setEnabled(false); m_Controls.m_pageExecution->setEnabled(false); this->m_Controls.m_lbLoadedAlgorithmName->setText( QString("no algorithm loaded!")); } if (!m_Working) { this->m_Controls.m_leRegJobName->setText(QString::fromStdString(this->GetDefaultRegJobName())); } } void QmitkMatchPointBatchProcessor::ConfigureProgressInfos() { const IIterativeAlgorithm* pIterative = dynamic_cast (m_LoadedAlgorithm.GetPointer()); const IMultiResAlgorithm* pMultiRes = dynamic_cast (m_LoadedAlgorithm.GetPointer()); m_Controls.m_progBarIteration->setVisible(pIterative); m_Controls.m_lbProgBarIteration->setVisible(pIterative); if (pIterative) { QString format = "%p% (%v/%m)"; if (!pIterative->hasMaxIterationCount()) { format = "%v"; m_Controls.m_progBarIteration->setMaximum(0); } else { m_Controls.m_progBarIteration->setMaximum(pIterative->getMaxIterations()); } m_Controls.m_progBarIteration->setFormat(format); } if (pMultiRes) { m_Controls.m_progBarLevel->setMaximum(pMultiRes->getResolutionLevels()); } else { m_Controls.m_progBarLevel->setMaximum(1); } m_Controls.m_progBarJob->setMaximum(this->m_selectedMovingNodes.size()); m_Controls.m_progBarJob->reset(); m_Controls.m_progBarIteration->reset(); m_Controls.m_progBarLevel->reset(); } void QmitkMatchPointBatchProcessor::OnSelectionChanged(berry::IWorkbenchPart::Pointer /*source*/, const QList& nodes) { m_currentlySelectedNodes = nodes; if (!m_Working) { CheckInputs(); ConfigureRegistrationControls(); } } void QmitkMatchPointBatchProcessor::OnStartRegBtnPushed() { this->m_Working = true; //////////////////////////////// //configure GUI this->ConfigureProgressInfos(); this->ConfigureRegistrationControls(); if (m_Controls.m_checkClearLog->checkState() == Qt::Checked) { this->m_Controls.m_teLog->clear(); } this->m_nextNodeToSpawn = 0; SpawnNextJob(); } bool QmitkMatchPointBatchProcessor::SpawnNextJob() { - if (this->m_nextNodeToSpawn < this->m_selectedMovingNodes.size()) + if (static_cast(this->m_nextNodeToSpawn) < this->m_selectedMovingNodes.size()) { QmitkRegistrationJob* pJob = new QmitkRegistrationJob(m_LoadedAlgorithm); pJob->setAutoDelete(true); pJob->m_spTargetData = this->m_spSelectedTargetNode->GetData(); pJob->m_spMovingData = this->m_selectedMovingNodes[m_nextNodeToSpawn]->GetData(); pJob->m_TargetDataUID = mitk::EnsureUID(this->m_spSelectedTargetNode->GetData()); pJob->m_MovingDataUID = mitk::EnsureUID(this->m_selectedMovingNodes[m_nextNodeToSpawn]->GetData()); QString jobName = m_Controls.m_leRegJobName->text() + QString(" ") + QString::fromStdString( this->m_selectedMovingNodes[m_nextNodeToSpawn]->GetName()); pJob->m_JobName = jobName.toStdString(); pJob->m_StoreReg = m_Controls.m_checkStoreReg->checkState() == Qt::Checked; connect(pJob, SIGNAL(Error(QString)), this, SLOT(OnRegJobError(QString))); connect(pJob, SIGNAL(Finished()), this, SLOT(OnRegJobFinished())); connect(pJob, SIGNAL(RegResultIsAvailable(mitk::MAPRegistrationWrapper::Pointer, const QmitkRegistrationJob*)), this, SLOT(OnRegResultIsAvailable(mitk::MAPRegistrationWrapper::Pointer, const QmitkRegistrationJob*)), Qt::BlockingQueuedConnection); connect(pJob, SIGNAL(MapResultNodeIsAvailable(mitk::BaseData::Pointer, const QmitkMappingJob*)), this, SLOT(OnMapResultIsAvailable(mitk::BaseData::Pointer, const QmitkMappingJob*)), Qt::BlockingQueuedConnection); connect(pJob, SIGNAL(AlgorithmInfo(QString)), this, SLOT(OnAlgorithmInfo(QString))); connect(pJob, SIGNAL(AlgorithmStatusChanged(QString)), this, SLOT(OnAlgorithmStatusChanged(QString))); connect(pJob, SIGNAL(AlgorithmIterated(QString, bool, unsigned long)), this, SLOT(OnAlgorithmIterated(QString, bool, unsigned long))); connect(pJob, SIGNAL(LevelChanged(QString, bool, unsigned long)), this, SLOT(OnLevelChanged(QString, bool, unsigned long))); QThreadPool* threadPool = QThreadPool::globalInstance(); threadPool->start(pJob); this->m_nextNodeToSpawn++; return true; } return false; } void QmitkMatchPointBatchProcessor::OnRegJobFinished() { if (SpawnNextJob()) { m_Controls.m_teLog->append( QString("

Commencing new registration job...

")); m_Controls.m_progBarJob->setValue(this->m_nextNodeToSpawn); } else { this->m_Working = false; this->GetRenderWindowPart()->RequestUpdate(); this->CheckInputs(); this->ConfigureRegistrationControls(); this->ConfigureProgressInfos(); } }; void QmitkMatchPointBatchProcessor::OnRegResultIsAvailable(mitk::MAPRegistrationWrapper::Pointer spResultRegistration, const QmitkRegistrationJob* pRegJob) { mitk::DataNode::Pointer spResultRegistrationNode = mitk::generateRegistrationResultNode( pRegJob->m_JobName, spResultRegistration, pRegJob->GetLoadedAlgorithm()->getUID()->toStr(), pRegJob->m_MovingDataUID, pRegJob->m_TargetDataUID); if (pRegJob->m_StoreReg) { m_Controls.m_teLog->append( QString(" Storing registration object in data manager ... ")); this->GetDataStorage()->Add(spResultRegistrationNode); this->GetRenderWindowPart()->RequestUpdate(); } if (m_Controls.m_checkMapEntity->checkState() == Qt::Checked) { QmitkMappingJob* pMapJob = new QmitkMappingJob(); pMapJob->setAutoDelete(true); pMapJob->m_spInputData = pRegJob->m_spMovingData; pMapJob->m_InputDataUID = pRegJob->m_MovingDataUID; pMapJob->m_spRegNode = spResultRegistrationNode; pMapJob->m_doGeometryRefinement = false; pMapJob->m_spRefGeometry = pRegJob->m_spTargetData->GetGeometry()->Clone().GetPointer(); pMapJob->m_MappedName = pRegJob->m_JobName + std::string(" mapped"); pMapJob->m_allowUndefPixels = true; pMapJob->m_paddingValue = 100; pMapJob->m_allowUnregPixels = true; pMapJob->m_errorValue = 200; pMapJob->m_InterpolatorLabel = "Linear Interpolation"; pMapJob->m_InterpolatorType = mitk::ImageMappingInterpolator::Linear; connect(pMapJob, SIGNAL(Error(QString)), this, SLOT(OnMapJobError(QString))); connect(pMapJob, SIGNAL(MapResultIsAvailable(mitk::BaseData::Pointer, const QmitkMappingJob*)), this, SLOT(OnMapResultIsAvailable(mitk::BaseData::Pointer, const QmitkMappingJob*)), Qt::BlockingQueuedConnection); connect(pMapJob, SIGNAL(AlgorithmInfo(QString)), this, SLOT(OnAlgorithmInfo(QString))); m_Controls.m_teLog->append( QString("Started mapping input data...")); QThreadPool* threadPool = QThreadPool::globalInstance(); threadPool->start(pMapJob); } }; void QmitkMatchPointBatchProcessor::OnMapJobError(QString err) { Error(err); }; void QmitkMatchPointBatchProcessor::OnMapResultIsAvailable(mitk::BaseData::Pointer spMappedData, const QmitkMappingJob* job) { m_Controls.m_teLog->append(QString("Mapped entity stored. Name: ") + QString::fromStdString(job->m_MappedName) + QString("")); mitk::DataNode::Pointer spMappedNode = mitk::generateMappedResultNode(job->m_MappedName, spMappedData, job->GetRegistration()->getRegistrationUID(), job->m_InputDataUID, job->m_doGeometryRefinement, job->m_InterpolatorLabel); this->GetDataStorage()->Add(spMappedNode); this->GetRenderWindowPart()->RequestUpdate(); }; void QmitkMatchPointBatchProcessor::OnStopRegBtnPushed() { if (m_LoadedAlgorithm.IsNotNull()) { IStoppableAlgorithm* pIterativ = dynamic_cast(m_LoadedAlgorithm.GetPointer()); if (pIterativ && pIterativ->isStoppable()) { if (pIterativ->stopAlgorithm()) { } else { } /**@TODO reactivate as soon as crex processor allows to stop batch processing.*/ //m_Controls.m_pbStopReg->setEnabled(false); } else { } } } void QmitkMatchPointBatchProcessor::OnRegJobError(QString err) { Error(err); }; void QmitkMatchPointBatchProcessor::OnAlgorithmIterated(QString info, bool hasIterationCount, unsigned long currentIteration) { if (hasIterationCount) { m_Controls.m_progBarIteration->setValue(currentIteration); } m_Controls.m_teLog->append(info); }; void QmitkMatchPointBatchProcessor::OnLevelChanged(QString info, bool hasLevelCount, unsigned long currentLevel) { if (hasLevelCount) { m_Controls.m_progBarLevel->setValue(currentLevel); } m_Controls.m_teLog->append(QString("") + info + QString("")); }; void QmitkMatchPointBatchProcessor::OnAlgorithmStatusChanged(QString info) { m_Controls.m_teLog->append(QString("") + info + QString(" ")); }; void QmitkMatchPointBatchProcessor::OnAlgorithmInfo(QString info) { m_Controls.m_teLog->append(QString("") + info + QString("")); }; void QmitkMatchPointBatchProcessor::UpdateAlgorithmSelection(berry::ISelection::ConstPointer selection) { mitk::MAPAlgorithmInfoSelection::ConstPointer currentSelection = selection.Cast(); if (currentSelection) { mitk::MAPAlgorithmInfoSelection::AlgorithmInfoVectorType infoVector = currentSelection->GetSelectedAlgorithmInfo(); if (!infoVector.empty()) { // only the first selection is of interest, the rest will be skipped. this->m_SelectedAlgorithmInfo = infoVector[0]; } } this->OnSelectedAlgorithmChanged(); }; void QmitkMatchPointBatchProcessor::OnAlgorithmSelectionChanged(const berry::IWorkbenchPart::Pointer& sourcepart, const berry::ISelection::ConstPointer& selection) { // check for null selection if (selection.IsNull()) { return; } if (sourcepart != this) { UpdateAlgorithmSelection(selection); } } diff --git a/Plugins/org.mitk.gui.qt.matchpoint.algorithm.batch/src/internal/QmitkMatchPointBatchProcessor.h b/Plugins/org.mitk.gui.qt.matchpoint.algorithm.batch/src/internal/QmitkMatchPointBatchProcessor.h index abf1cd2569..74afb22de7 100644 --- a/Plugins/org.mitk.gui.qt.matchpoint.algorithm.batch/src/internal/QmitkMatchPointBatchProcessor.h +++ b/Plugins/org.mitk.gui.qt.matchpoint.algorithm.batch/src/internal/QmitkMatchPointBatchProcessor.h @@ -1,201 +1,203 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef __Q_MITK_MATCHPOINT_BATCH_PROCESSOR_H #define __Q_MITK_MATCHPOINT_BATCH_PROCESSOR_H #include #include #include "ui_QmitkMatchPointBatchProcessor.h" // MatchPoint #include #include #include #include #include #include #include class QmitkRegistrationJob; class QmitkMappingJob; /*! \brief View for registration batch processing based on MatchPoint This view composes the GUI and implements the business logic needed to allow registration batch processing (one target, many moving images). \ingroup ${plugin_target}_internal */ class QmitkMatchPointBatchProcessor : public QmitkAbstractView { // this is needed for all Qt objects that should have a Qt meta-object // (everything that derives from QObject and wants to have signal/slots) Q_OBJECT public: static const std::string VIEW_ID; /** * Creates smartpointer typedefs */ berryObjectMacro(QmitkMatchPointBatchProcessor) QmitkMatchPointBatchProcessor(); ~QmitkMatchPointBatchProcessor(); protected slots: /** * @brief Connect all GUI elements to its corresponding slots */ virtual void CreateConnections(); /// \brief Called when the user clicks the GUI button void OnLoadAlgorithmButtonPushed(); void OnSelectedAlgorithmChanged(); void OnLockMovingButtonPushed(); void OnLockTargetButtonPushed(); void OnStartRegBtnPushed(); void OnStopRegBtnPushed(); void OnRegJobError(QString err); void OnRegResultIsAvailable(mitk::MAPRegistrationWrapper::Pointer spResultRegistration, const QmitkRegistrationJob* pRegJob); void OnRegJobFinished(); void OnMapJobError(QString err); void OnMapResultIsAvailable(mitk::BaseData::Pointer spMappedData, const QmitkMappingJob* job); void OnAlgorithmIterated(QString info, bool hasIterationCount, unsigned long currentIteration); void OnLevelChanged(QString info, bool hasLevelCount, unsigned long currentLevel); void OnAlgorithmStatusChanged(QString info); void OnAlgorithmInfo(QString info); protected: virtual void CreateQtPartControl(QWidget* parent); virtual void SetFocus(); /// \brief called by QmitkFunctionality when DataManager's selection has changed virtual void OnSelectionChanged(berry::IWorkbenchPart::Pointer source, const QList& nodes); private: typedef QList NodeListType; /** Spawns a registration job for the next selected moving node (see m_nextNodeToSpawn). * If no nodes are left, no job will be spawned and false is returned. * If at least one node is left, a job will be spawned, m_nextNodeToSpawn will be incremented * and true will be returned.*/ bool SpawnNextJob(); /** * @brief Adapt the visibility of GUI elements depending on the current data loaded */ void UpdateAlgorithmSelectionGUI(); void Error(QString msg); void UpdateAlgorithmList(); /** * checks if appropriated nodes are selected in the data manager. If nodes are selected, * they are stored in m_spSelectedTargetNode and m_selectedMovingNodes. It also sets the info labels accordingly.*/ void CheckInputs(); /** * Updates the state of registration control buttons. Regarding to selected * inputs, loaded algorithm and its state.*/ void ConfigureRegistrationControls(); /** * Configures the progress bars according to the chosen algorithm. */ void ConfigureProgressInfos(); /** Methods returns a list of all nodes selected in the data manager that do * NOT contain registration wrappers. The list may be empty if nothing is * selected or no appropriate data node is selected.*/ NodeListType GetSelectedDataNodes(); /** Methods returns a list of all nodes in the data manager containing a registration wrapper. * The list may be empty.*/ mitk::DataStorage::SetOfObjects::Pointer GetRegNodes() const; /** Returns a proposal for a (unique) default reg job name */ std::string GetDefaultRegJobName() const; /** Returns the Pointer to the DLL info of the algorithm currently selected by the system. The info is received via m_SelectionListener. @return If there is no item selected the returning pointer will be null. */ const map::deployment::DLLInfo* GetSelectedAlgorithmDLL() const; //! [Qt Selection Listener method and pointer] /** * @brief Method of berry::ISelectionListener that implements the selection listener functionality. * @param sourcepart The workbench part responsible for the selection change. * @param selection This parameter holds the current selection. * * @see ISelectionListener */ void OnAlgorithmSelectionChanged(const berry::IWorkbenchPart::Pointer& sourcepart, const berry::ISelection::ConstPointer& selection); void UpdateAlgorithmSelection(berry::ISelection::ConstPointer selection); friend struct berry::SelectionChangedAdapter; + + QWidget* m_Parent; + /** @brief this pointer holds the algorithm selection listener */ QScopedPointer m_AlgorithmSelectionListener; ::map::deployment::DLLHandle::Pointer m_LoadedDLLHandle; ::map::algorithm::RegistrationAlgorithmBase::Pointer m_LoadedAlgorithm; ::map::deployment::DLLInfo::ConstPointer m_SelectedAlgorithmInfo; typedef map::algorithm::facet::IterativeAlgorithmInterface IIterativeAlgorithm; typedef map::algorithm::facet::MultiResRegistrationAlgorithmInterface IMultiResAlgorithm; typedef map::algorithm::facet::StoppableAlgorithmInterface IStoppableAlgorithm; /**All selected nodes stored by OnSelectionChanged()*/ NodeListType m_currentlySelectedNodes; mitk::DataNode::Pointer m_spSelectedTargetNode; NodeListType m_selectedMovingNodes; /**indicates the next selected moving nodes that should be spawned as job.*/ unsigned int m_nextNodeToSpawn; // boolean variables to control visibility of GUI elements bool m_CanLoadAlgorithm; bool m_ValidInputs; bool m_Working; - QWidget* m_Parent; Ui::MatchPointAdvancedControls m_Controls; }; #endif // MatchPoint_h