diff --git a/Plugins/org.mitk.gui.qt.segmentation/files.cmake b/Plugins/org.mitk.gui.qt.segmentation/files.cmake index 24a87be816..cde1e33fb3 100644 --- a/Plugins/org.mitk.gui.qt.segmentation/files.cmake +++ b/Plugins/org.mitk.gui.qt.segmentation/files.cmake @@ -1,78 +1,81 @@ set(SRC_CPP_FILES QmitkSegmentationPreferencePage.cpp ) set(INTERNAL_CPP_FILES mitkPluginActivator.cpp QmitkSegmentationView.cpp QmitkThresholdAction.cpp QmitkCreatePolygonModelAction.cpp #QmitkStatisticsAction.cpp QmitkAutocropAction.cpp QmitkDeformableClippingPlaneView.cpp Common/QmitkDataSelectionWidget.cpp SegmentationUtilities/QmitkSegmentationUtilitiesView.cpp SegmentationUtilities/QmitkSegmentationUtilityWidget.cpp SegmentationUtilities/BooleanOperations/QmitkBooleanOperationsWidget.cpp SegmentationUtilities/ImageMasking/QmitkImageMaskingWidget.cpp + SegmentationUtilities/ContourModelToImage/QmitkContourModelToImageWidget.cpp SegmentationUtilities/MorphologicalOperations/QmitkMorphologicalOperationsWidget.cpp SegmentationUtilities/SurfaceToImage/QmitkSurfaceToImageWidget.cpp SegmentationUtilities/CTKWidgets/QmitkCTKWidgetsWidget.cpp ) set(UI_FILES src/internal/QmitkSegmentationControls.ui src/internal/QmitkDeformableClippingPlaneViewControls.ui src/internal/Common/QmitkDataSelectionWidgetControls.ui src/internal/SegmentationUtilities/QmitkSegmentationUtilitiesViewControls.ui src/internal/SegmentationUtilities/BooleanOperations/QmitkBooleanOperationsWidgetControls.ui src/internal/SegmentationUtilities/ImageMasking/QmitkImageMaskingWidgetControls.ui + src/internal/SegmentationUtilities/ContourModelToImage/QmitkContourModelToImageWidgetControls.ui src/internal/SegmentationUtilities/MorphologicalOperations/QmitkMorphologicalOperationsWidgetControls.ui src/internal/SegmentationUtilities/SurfaceToImage/QmitkSurfaceToImageWidgetControls.ui ) set(MOC_H_FILES src/QmitkSegmentationPreferencePage.h src/internal/mitkPluginActivator.h src/internal/QmitkSegmentationView.h src/internal/QmitkThresholdAction.h src/internal/QmitkCreatePolygonModelAction.h #src/internal/QmitkStatisticsAction.h src/internal/QmitkAutocropAction.h src/internal/QmitkDeformableClippingPlaneView.h src/internal/Common/QmitkDataSelectionWidget.h src/internal/SegmentationUtilities/QmitkSegmentationUtilitiesView.h src/internal/SegmentationUtilities/QmitkSegmentationUtilityWidget.h src/internal/SegmentationUtilities/BooleanOperations/QmitkBooleanOperationsWidget.h src/internal/SegmentationUtilities/ImageMasking/QmitkImageMaskingWidget.h + src/internal/SegmentationUtilities/ContourModelToImage/QmitkContourModelToImageWidget.h src/internal/SegmentationUtilities/MorphologicalOperations/QmitkMorphologicalOperationsWidget.h src/internal/SegmentationUtilities/SurfaceToImage/QmitkSurfaceToImageWidget.h src/internal/SegmentationUtilities/CTKWidgets/QmitkCTKWidgetsWidget.h ) set(CACHED_RESOURCE_FILES resources/segmentation.png resources/deformablePlane.png resources/clipping_plane_translate_48x48.png resources/clipping_plane_rotate48x48.png resources/clipping_plane_deform48x48.png resources/SegmentationUtilities_48x48.png plugin.xml ) set(QRC_FILES resources/segmentation.qrc resources/SegmentationUtilities.qrc resources/BooleanOperationsWidget.qrc resources/MorphologicalOperationsWidget.qrc ) set(CPP_FILES) foreach(file ${SRC_CPP_FILES}) set(CPP_FILES ${CPP_FILES} src/${file}) endforeach(file ${SRC_CPP_FILES}) foreach(file ${INTERNAL_CPP_FILES}) set(CPP_FILES ${CPP_FILES} src/internal/${file}) endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/Plugins/org.mitk.gui.qt.segmentation/src/internal/Common/QmitkDataSelectionWidget.cpp b/Plugins/org.mitk.gui.qt.segmentation/src/internal/Common/QmitkDataSelectionWidget.cpp index 1df4b355ce..231887ec1c 100644 --- a/Plugins/org.mitk.gui.qt.segmentation/src/internal/Common/QmitkDataSelectionWidget.cpp +++ b/Plugins/org.mitk.gui.qt.segmentation/src/internal/Common/QmitkDataSelectionWidget.cpp @@ -1,158 +1,165 @@ /*=================================================================== 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 "QmitkDataSelectionWidget.h" #include +#include +#include #include #include #include #include #include +#include #include #include #include #include #include #include #include #include static mitk::NodePredicateBase::Pointer CreatePredicate(QmitkDataSelectionWidget::Predicate predicate) { switch(predicate) { case QmitkDataSelectionWidget::ImagePredicate: return mitk::NodePredicateAnd::New( mitk::TNodePredicateDataType::New(), mitk::NodePredicateNot::New(mitk::NodePredicateProperty::New("binary", mitk::BoolProperty::New(true))), mitk::NodePredicateNot::New(mitk::NodePredicateProperty::New("helper object"))).GetPointer(); case QmitkDataSelectionWidget::SegmentationPredicate: return mitk::NodePredicateAnd::New( mitk::TNodePredicateDataType::New(), mitk::NodePredicateProperty::New("binary", mitk::BoolProperty::New(true)), mitk::NodePredicateNot::New(mitk::NodePredicateProperty::New("helper object"))).GetPointer(); case QmitkDataSelectionWidget::SurfacePredicate: return mitk::NodePredicateAnd::New( mitk::TNodePredicateDataType::New(), mitk::NodePredicateNot::New(mitk::NodePredicateProperty::New("helper object"))).GetPointer(); case QmitkDataSelectionWidget::ImageAndSegmentationPredicate: return mitk::NodePredicateAnd::New( mitk::TNodePredicateDataType::New(), mitk::NodePredicateNot::New(mitk::NodePredicateProperty::New("helper object"))).GetPointer(); - + case QmitkDataSelectionWidget::ContourModelPredicate: + return mitk::NodePredicateAnd::New( + mitk::NodePredicateOr::New( mitk::TNodePredicateDataType::New(), + mitk::TNodePredicateDataType::New()), + mitk::NodePredicateNot::New(mitk::NodePredicateProperty::New("helper object"))).GetPointer(); default: assert(false && "Unknown predefined predicate!"); return NULL; } } QmitkDataSelectionWidget::QmitkDataSelectionWidget(QWidget* parent) : QWidget(parent) { m_Controls.setupUi(this); m_Controls.helpLabel->hide(); } QmitkDataSelectionWidget::~QmitkDataSelectionWidget() { } unsigned int QmitkDataSelectionWidget::AddDataStorageComboBox(QmitkDataSelectionWidget::Predicate predicate) { return this->AddDataStorageComboBox("", predicate); } unsigned int QmitkDataSelectionWidget::AddDataStorageComboBox(mitk::NodePredicateBase* predicate) { return this->AddDataStorageComboBox("", predicate); } unsigned int QmitkDataSelectionWidget::AddDataStorageComboBox(const QString &labelText, QmitkDataSelectionWidget::Predicate predicate) { return this->AddDataStorageComboBox(labelText, CreatePredicate(predicate)); } unsigned int QmitkDataSelectionWidget::AddDataStorageComboBox(const QString &labelText, mitk::NodePredicateBase* predicate) { int row = m_Controls.gridLayout->rowCount(); if (!labelText.isEmpty()) { QLabel* label = new QLabel(labelText, m_Controls.dataSelectionWidget); label->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); m_Controls.gridLayout->addWidget(label, row, 0); } QmitkDataStorageComboBox* comboBox = new QmitkDataStorageComboBox(this->GetDataStorage(), predicate, m_Controls.dataSelectionWidget); connect(comboBox, SIGNAL(OnSelectionChanged(const mitk::DataNode *)), this, SLOT(OnSelectionChanged(const mitk::DataNode *))); m_Controls.gridLayout->addWidget(comboBox, row, 1); m_DataStorageComboBoxes.push_back(comboBox); return static_cast(m_DataStorageComboBoxes.size() - 1); } mitk::DataStorage::Pointer QmitkDataSelectionWidget::GetDataStorage() const { mitk::IDataStorageService::Pointer service = berry::Platform::GetServiceRegistry().GetServiceById(mitk::IDataStorageService::ID); assert(service.IsNotNull()); return service->GetDefaultDataStorage()->GetDataStorage(); } mitk::DataNode::Pointer QmitkDataSelectionWidget::GetSelection(unsigned int index) { assert(index < m_DataStorageComboBoxes.size()); return m_DataStorageComboBoxes[index]->GetSelectedNode(); } void QmitkDataSelectionWidget::SetPredicate(unsigned int index, Predicate predicate) { this->SetPredicate(index, CreatePredicate(predicate)); } void QmitkDataSelectionWidget::SetPredicate(unsigned int index, mitk::NodePredicateBase* predicate) { assert(index < m_DataStorageComboBoxes.size()); m_DataStorageComboBoxes[index]->SetPredicate(predicate); } void QmitkDataSelectionWidget::SetHelpText(const QString& text) { if (!text.isEmpty()) { m_Controls.helpLabel->setText(text); if (!m_Controls.helpLabel->isVisible()) m_Controls.helpLabel->show(); } else { m_Controls.helpLabel->hide(); } } void QmitkDataSelectionWidget::OnSelectionChanged(const mitk::DataNode* selection) { std::vector::iterator it = std::find(m_DataStorageComboBoxes.begin(), m_DataStorageComboBoxes.end(), sender()); assert(it != m_DataStorageComboBoxes.end()); emit SelectionChanged(std::distance(m_DataStorageComboBoxes.begin(), it), selection); } diff --git a/Plugins/org.mitk.gui.qt.segmentation/src/internal/Common/QmitkDataSelectionWidget.h b/Plugins/org.mitk.gui.qt.segmentation/src/internal/Common/QmitkDataSelectionWidget.h index 8b0f44b17f..b0eaaf78bd 100644 --- a/Plugins/org.mitk.gui.qt.segmentation/src/internal/Common/QmitkDataSelectionWidget.h +++ b/Plugins/org.mitk.gui.qt.segmentation/src/internal/Common/QmitkDataSelectionWidget.h @@ -1,70 +1,71 @@ /*=================================================================== 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 QmitkDataSelectionWidget_h #define QmitkDataSelectionWidget_h #include #include #include #include namespace mitk { class NodePredicateBase; } class QmitkDataStorageComboBox; class QmitkDataSelectionWidget : public QWidget { Q_OBJECT public: enum Predicate { ImagePredicate, SegmentationPredicate, SurfacePredicate, - ImageAndSegmentationPredicate + ImageAndSegmentationPredicate, + ContourModelPredicate }; explicit QmitkDataSelectionWidget(QWidget* parent = NULL); ~QmitkDataSelectionWidget(); unsigned int AddDataStorageComboBox(Predicate predicate); unsigned int AddDataStorageComboBox(mitk::NodePredicateBase* predicate = NULL); unsigned int AddDataStorageComboBox(const QString &labelText, Predicate predicate); unsigned int AddDataStorageComboBox(const QString &labelText, mitk::NodePredicateBase* predicate = NULL); mitk::DataStorage::Pointer GetDataStorage() const; mitk::DataNode::Pointer GetSelection(unsigned int index); void SetPredicate(unsigned int index, Predicate predicate); void SetPredicate(unsigned int index, mitk::NodePredicateBase* predicate); void SetHelpText(const QString& text); signals: void SelectionChanged(unsigned int index, const mitk::DataNode* selection); private slots: void OnSelectionChanged(const mitk::DataNode* selection); private: Ui::QmitkDataSelectionWidgetControls m_Controls; std::vector m_DataStorageComboBoxes; }; #endif diff --git a/Plugins/org.mitk.gui.qt.segmentation/src/internal/SegmentationUtilities/ContourModelToImage/QmitkContourModelToImageWidget.cpp b/Plugins/org.mitk.gui.qt.segmentation/src/internal/SegmentationUtilities/ContourModelToImage/QmitkContourModelToImageWidget.cpp new file mode 100644 index 0000000000..4afbb2be02 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.segmentation/src/internal/SegmentationUtilities/ContourModelToImage/QmitkContourModelToImageWidget.cpp @@ -0,0 +1,226 @@ +/*=================================================================== + +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 "QmitkContourModelToImageWidget.h" +#include "mitkImage.h" +#include "../../Common/QmitkDataSelectionWidget.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +static const char* const HelpText = "Select a binary image and a contour(set)"; + +QmitkContourModelToImageWidget::QmitkContourModelToImageWidget(mitk::SliceNavigationController* timeNavigationController, QWidget* parent) + : QmitkSegmentationUtilityWidget(timeNavigationController, parent) +{ + m_Controls.setupUi(this); + + m_Controls.dataSelectionWidget->AddDataStorageComboBox(QmitkDataSelectionWidget::SegmentationPredicate); + m_Controls.dataSelectionWidget->AddDataStorageComboBox(QmitkDataSelectionWidget::ContourModelPredicate); + m_Controls.dataSelectionWidget->SetHelpText(HelpText); + + this->EnableButtons(false); + + connect (m_Controls.btnProcess, SIGNAL(pressed()), this, SLOT(OnProcessPressed())); + + connect(m_Controls.dataSelectionWidget, SIGNAL(SelectionChanged(unsigned int, const mitk::DataNode*)), + this, SLOT(OnSelectionChanged(unsigned int, const mitk::DataNode*))); + + if( m_Controls.dataSelectionWidget->GetSelection(0).IsNotNull() && + m_Controls.dataSelectionWidget->GetSelection(1).IsNotNull() ) + { + this->OnSelectionChanged( 0, m_Controls.dataSelectionWidget->GetSelection(0)); + } +} + +QmitkContourModelToImageWidget::~QmitkContourModelToImageWidget() +{ +} + +void QmitkContourModelToImageWidget::OnSelectionChanged(unsigned int index, const mitk::DataNode* selection) +{ + QmitkDataSelectionWidget* dataSelectionWidget = m_Controls.dataSelectionWidget; + mitk::DataNode::Pointer node0 = dataSelectionWidget->GetSelection(0); + mitk::DataNode::Pointer node1 = dataSelectionWidget->GetSelection(1); + + if (node0.IsNull() || node1.IsNull() ) + { + this->EnableButtons(false); + } + else + { + this->SelectionControl(index, selection); + } +} + +void QmitkContourModelToImageWidget::SelectionControl(unsigned int index, const mitk::DataNode* /*selection*/) +{ + QmitkDataSelectionWidget* dataSelectionWidget = m_Controls.dataSelectionWidget; + mitk::DataNode::Pointer node = dataSelectionWidget->GetSelection(index); + + //TODO check if contours are inside the image! + + dataSelectionWidget->SetHelpText(""); + this->EnableButtons(); +} + +void QmitkContourModelToImageWidget::EnableButtons(bool enable) +{ + m_Controls.btnProcess->setEnabled(enable); +} + +void QmitkContourModelToImageWidget::OnProcessPressed() +{ + //Disable Buttons during calculation and initialize Progressbar + this->EnableButtons(false); + mitk::ProgressBar::GetInstance()->AddStepsToDo(4); + mitk::ProgressBar::GetInstance()->Progress(); + + QmitkDataSelectionWidget* dataSelectionWidget = m_Controls.dataSelectionWidget; + + //create result image, get mask node and reference image + mitk::Image::Pointer resultImage(0); + mitk::DataNode::Pointer segmentationNode = dataSelectionWidget->GetSelection(0); + mitk::Image::Pointer segmentationImage = static_cast(segmentationNode->GetData()); + + //TODO Use one ContourModelSet!!! + //TODO Extract logic to somewhere + std::vector contourList; + mitk::DataNode::Pointer contourNode = dataSelectionWidget->GetSelection(1); + mitk::ContourModel::Pointer contour = static_cast(contourNode->GetData()); + if (contour.IsNotNull()) + { + contourList.push_back(contour); + } + else + { + // TODO move to utils! + mitk::ContourModelSet::Pointer contourSet = static_cast(contourNode->GetData()); + mitk::ContourModelSet::ContourModelSetIterator it = contourSet->Begin(); + while (it != contourSet->End()) + { + contourList.push_back(*it); + ++it; + } + } + + // Do actual filling + mitk::Geometry3D::Pointer segmentationGeometry = segmentationImage->GetGeometry(); + mitk::PlaneGeometry::Pointer plane = mitk::PlaneGeometry::New(); + mitk::Point3D point3D; + mitk::Vector3D normal; + + mitk::ExtractSliceFilter::Pointer extractor = mitk::ExtractSliceFilter::New(); + mitk::Image::Pointer slice; + mitk::ContourModel::Pointer projectedContour; + + unsigned int timeStep = this->GetTimeNavigationController()->GetTime()->GetPos(); + int sliceIndex; + bool isFrontside = true; + bool isRotated = false; + + foreach (mitk::ContourModel::Pointer contour, contourList) + { + //Check Controls + // BUG save project with contours not working!! +// contour->GetGeometry()->Print(std::cout); + + // 1. construct geometry -> extract slice + // TODO Detect contour orientation + point3D = contour->GetVertexAt(0)->Coordinates; + segmentationGeometry->WorldToIndex(point3D, point3D); + plane->InitializeStandardPlane(segmentationGeometry, mitk::PlaneGeometry::Axial, point3D[2], isFrontside, isRotated); + point3D = plane->GetOrigin(); + normal = plane->GetNormal(); + normal.Normalize(); + point3D += normal * 0.5;//pixelspacing is 1, so half the spacing is 0.5 + plane->SetOrigin(point3D); + + // 2. fill into it + extractor->SetInput( segmentationImage ); +// extractor->SetTimeStep( timeStep ); + extractor->SetWorldGeometry( plane ); + extractor->SetVtkOutputRequest(false); + extractor->SetResliceTransformByGeometry( segmentationImage->GetTimeGeometry()->GetGeometryForTimeStep( timeStep ) ); + + extractor->Modified(); + extractor->Update(); + + slice = extractor->GetOutput(); + projectedContour = mitk::ContourModelUtils::ProjectContourTo2DSlice(slice, contour, true, false); + mitk::ContourModelUtils::FillContourInSlice(projectedContour, slice); + mitk::DataNode::Pointer filled = mitk::DataNode::New(); + filled->SetName("FILLED"); + filled->SetData(slice); + dataSelectionWidget->GetDataStorage()->Add(filled); + + } + + if(segmentationNode.IsNull() || contourNode.IsNull() ) + { + MITK_ERROR << "Selection does not contain valid data"; + QMessageBox::information( this, "Contour To Image", + "Selection does not contain valid data, please select a binary image and a contour(set)", QMessageBox::Ok ); + m_Controls.btnProcess->setEnabled(false); + return; + } + + //Do Image-Masking + mitk::ProgressBar::GetInstance()->Progress(); + + // Do contour filling + + mitk::ProgressBar::GetInstance()->Progress(); + + if( resultImage.IsNull() ) + { + MITK_ERROR << "Contour To Image failed"; + QMessageBox::information( this, "Contour To Image", "Failed to write contours into image. For more information please see logging window.", QMessageBox::Ok ); + this->EnableButtons(); + mitk::ProgressBar::GetInstance()->Progress(4); + return; + } + + //Add result to data storage + this->AddToDataStorage( + dataSelectionWidget->GetDataStorage(), + resultImage, + dataSelectionWidget->GetSelection(0)->GetName() + "_" + dataSelectionWidget->GetSelection(1)->GetName(), + dataSelectionWidget->GetSelection(0)); + + this->EnableButtons(); + + mitk::ProgressBar::GetInstance()->Progress(); +} + + +void QmitkContourModelToImageWidget::AddToDataStorage(mitk::DataStorage::Pointer dataStorage, mitk::Image::Pointer segmentation, const std::string& name, mitk::DataNode::Pointer parent ) +{ + mitk::DataNode::Pointer dataNode = mitk::DataNode::New(); + + dataNode->SetName(name); + dataNode->SetData(segmentation); + + dataStorage->Add(dataNode, parent); +} diff --git a/Plugins/org.mitk.gui.qt.segmentation/src/internal/SegmentationUtilities/ContourModelToImage/QmitkContourModelToImageWidget.h b/Plugins/org.mitk.gui.qt.segmentation/src/internal/SegmentationUtilities/ContourModelToImage/QmitkContourModelToImageWidget.h new file mode 100644 index 0000000000..15b9e8bcbe --- /dev/null +++ b/Plugins/org.mitk.gui.qt.segmentation/src/internal/SegmentationUtilities/ContourModelToImage/QmitkContourModelToImageWidget.h @@ -0,0 +1,86 @@ +/*=================================================================== + +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 QmitkContourModelToImageWidget_h +#define QmitkContourModelToImageWidget_h + +#include "../QmitkSegmentationUtilityWidget.h" +#include + +#include + +namespace mitk { + class Image; + class ContourModelSet; + class ContourModel; +} + +/*! + \brief QmitkContourModelToImageWidget + + Tool masks an image with a binary image or a surface. The Method requires + an image and a binary image mask or a surface. The input image and the binary + image mask must be of the same size. Masking with a surface creates first a + binary image of the surface and then use this for the masking of the input image. +*/ +class QmitkContourModelToImageWidget : public QmitkSegmentationUtilityWidget +{ + Q_OBJECT + +public: + + /** @brief Default constructor, including creation of GUI elements and signals/slots connections. */ + explicit QmitkContourModelToImageWidget(mitk::SliceNavigationController* timeNavigationController, QWidget* parent = NULL); + + /** @brief Defaul destructor. */ + ~QmitkContourModelToImageWidget(); + +private slots: + + /** @brief This slot is called if the selection in the workbench is changed. */ + void OnSelectionChanged(unsigned int index, const mitk::DataNode* selection); + +// /** @brief This slot is called if user activates the radio button for masking an image with a binary image mask. */ +// void OnContourModelToImageToggled(bool); + +// /** @brief This slot is called if user activates the radio button for masking an image with a surface. */ +// void OnSurfaceMaskingToggled(bool); + + /** @brief This slot is called if user activates the button to mask an image. */ + void OnProcessPressed(); + +private: + + /** @brief Check if selections is valid. */ + void SelectionControl( unsigned int index, const mitk::DataNode* selection); + + /** @brief Enable buttons if data selction is valid. */ + void EnableButtons(bool enable = true); + + /** @brief Fills a mitk::ContourModel into a given segmentation image */ + itk::SmartPointer ContourModelToImage(itk::SmartPointer segmenationImage, itk::SmartPointer contour ); + + /** @brief Fills a whole ContourModelSet into a given segmentation image */ + itk::SmartPointer ContourModelSetToImage( itk::SmartPointer segmenationImage, itk::SmartPointer contourSet ); + + /** @brief Adds a new data object to the DataStorage.*/ + void AddToDataStorage(mitk::DataStorage::Pointer dataStorage, itk::SmartPointer segmentation, + const std::string& name, mitk::DataNode::Pointer parent = NULL); + + Ui::QmitkContourModelToImageWidgetControls m_Controls; +}; + +#endif diff --git a/Plugins/org.mitk.gui.qt.segmentation/src/internal/SegmentationUtilities/ContourModelToImage/QmitkContourModelToImageWidgetControls.ui b/Plugins/org.mitk.gui.qt.segmentation/src/internal/SegmentationUtilities/ContourModelToImage/QmitkContourModelToImageWidgetControls.ui new file mode 100644 index 0000000000..d69bca34b7 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.segmentation/src/internal/SegmentationUtilities/ContourModelToImage/QmitkContourModelToImageWidgetControls.ui @@ -0,0 +1,48 @@ + + + QmitkContourModelToImageWidgetControls + + + + 0 + 0 + 180 + 154 + + + + + + + + + + Process + + + + + + + Qt::Vertical + + + + 20 + 273 + + + + + + + + + QmitkDataSelectionWidget + QWidget +
internal/Common/QmitkDataSelectionWidget.h
+
+
+ + +
diff --git a/Plugins/org.mitk.gui.qt.segmentation/src/internal/SegmentationUtilities/QmitkSegmentationUtilitiesView.cpp b/Plugins/org.mitk.gui.qt.segmentation/src/internal/SegmentationUtilities/QmitkSegmentationUtilitiesView.cpp index 0c62bdb2c1..a621958a6b 100644 --- a/Plugins/org.mitk.gui.qt.segmentation/src/internal/SegmentationUtilities/QmitkSegmentationUtilitiesView.cpp +++ b/Plugins/org.mitk.gui.qt.segmentation/src/internal/SegmentationUtilities/QmitkSegmentationUtilitiesView.cpp @@ -1,99 +1,105 @@ /*=================================================================== 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. ===================================================================*/ // #define ENABLE_CTK_WIDGETS_WIDGET #include "QmitkSegmentationUtilitiesView.h" #include "BooleanOperations/QmitkBooleanOperationsWidget.h" +#include "ContourModelToImage/QmitkContourModelToImageWidget.h" #include "ImageMasking/QmitkImageMaskingWidget.h" #include "MorphologicalOperations/QmitkMorphologicalOperationsWidget.h" #include "SurfaceToImage/QmitkSurfaceToImageWidget.h" #include "CTKWidgets/QmitkCTKWidgetsWidget.h" QmitkSegmentationUtilitiesView::QmitkSegmentationUtilitiesView() : m_BooleanOperationsWidget(NULL), + m_ContourModelToImageWidget(NULL), m_ImageMaskingWidget(NULL), m_MorphologicalOperationsWidget(NULL), m_SurfaceToImageWidget(NULL), m_CTKWidgetsWidget(NULL) { } QmitkSegmentationUtilitiesView::~QmitkSegmentationUtilitiesView() { } void QmitkSegmentationUtilitiesView::CreateQtPartControl(QWidget* parent) { m_Controls.setupUi(parent); mitk::IRenderWindowPart* renderWindowPart = this->GetRenderWindowPart(); mitk::SliceNavigationController* timeNavigationController = renderWindowPart != NULL ? renderWindowPart->GetTimeNavigationController() : NULL; m_BooleanOperationsWidget = new QmitkBooleanOperationsWidget(timeNavigationController, parent); + m_ContourModelToImageWidget = new QmitkContourModelToImageWidget(timeNavigationController, parent); m_ImageMaskingWidget = new QmitkImageMaskingWidget(timeNavigationController, parent); m_MorphologicalOperationsWidget = new QmitkMorphologicalOperationsWidget(timeNavigationController, parent); m_SurfaceToImageWidget = new QmitkSurfaceToImageWidget(timeNavigationController, parent); this->AddUtilityWidget(m_BooleanOperationsWidget, QIcon(":/SegmentationUtilities/BooleanOperations_48x48.png"), "Boolean Operations"); + this->AddUtilityWidget(m_ContourModelToImageWidget, QIcon(":/SegmentationUtilities/BooleanOperations_48x48.png"), "Contour Model To Image"); this->AddUtilityWidget(m_ImageMaskingWidget, QIcon(":/SegmentationUtilities/ImageMasking_48x48.png"), "Image Masking"); this->AddUtilityWidget(m_MorphologicalOperationsWidget, QIcon(":/SegmentationUtilities/MorphologicalOperations_48x48.png"), "Morphological Operations"); this->AddUtilityWidget(m_SurfaceToImageWidget, QIcon(":/SegmentationUtilities/SurfaceToImage_48x48.png"), "Surface To Image"); #ifdef ENABLE_CTK_WIDGETS_WIDGET m_CTKWidgetsWidget = new QmitkCTKWidgetsWidget(timeNavigationController, parent); this->AddUtilityWidget(m_CTKWidgetsWidget, QIcon(":/SegmentationUtilities/CTKWidgets_48x48.png"), "CTK Widgets"); #endif } void QmitkSegmentationUtilitiesView::AddUtilityWidget(QWidget* widget, const QIcon& icon, const QString& text) { m_Controls.toolBox->addItem(widget, icon, text); } void QmitkSegmentationUtilitiesView::SetFocus() { m_Controls.toolBox->setFocus(); } void QmitkSegmentationUtilitiesView::RenderWindowPartActivated(mitk::IRenderWindowPart* renderWindowPart) { mitk::SliceNavigationController* timeNavigationController = renderWindowPart->GetTimeNavigationController(); m_BooleanOperationsWidget->SetTimeNavigationController(timeNavigationController); + m_ContourModelToImageWidget->SetTimeNavigationController(timeNavigationController); m_ImageMaskingWidget->SetTimeNavigationController(timeNavigationController); m_MorphologicalOperationsWidget->SetTimeNavigationController(timeNavigationController); m_SurfaceToImageWidget->SetTimeNavigationController(timeNavigationController); #ifdef ENABLE_CTK_WIDGETS_WIDGET m_CTKWidgetsWidget->SetTimeNavigationController(timeNavigationController); #endif } void QmitkSegmentationUtilitiesView::RenderWindowPartDeactivated(mitk::IRenderWindowPart*) { m_BooleanOperationsWidget->SetTimeNavigationController(NULL); + m_ContourModelToImageWidget->SetTimeNavigationController(NULL); m_ImageMaskingWidget->SetTimeNavigationController(NULL); m_MorphologicalOperationsWidget->SetTimeNavigationController(NULL); m_SurfaceToImageWidget->SetTimeNavigationController(NULL); #ifdef ENABLE_CTK_WIDGETS_WIDGET m_CTKWidgetsWidget->SetTimeNavigationController(NULL); #endif } diff --git a/Plugins/org.mitk.gui.qt.segmentation/src/internal/SegmentationUtilities/QmitkSegmentationUtilitiesView.h b/Plugins/org.mitk.gui.qt.segmentation/src/internal/SegmentationUtilities/QmitkSegmentationUtilitiesView.h index ef82651dad..ebd991eabd 100644 --- a/Plugins/org.mitk.gui.qt.segmentation/src/internal/SegmentationUtilities/QmitkSegmentationUtilitiesView.h +++ b/Plugins/org.mitk.gui.qt.segmentation/src/internal/SegmentationUtilities/QmitkSegmentationUtilitiesView.h @@ -1,55 +1,57 @@ /*=================================================================== 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 QmitkSegmentationUtilitiesView_h #define QmitkSegmentationUtilitiesView_h #include #include #include class QmitkBooleanOperationsWidget; +class QmitkContourModelToImageWidget; class QmitkImageMaskingWidget; class QmitkMorphologicalOperationsWidget; class QmitkSurfaceToImageWidget; class QmitkCTKWidgetsWidget; class QmitkSegmentationUtilitiesView : public QmitkAbstractView, public mitk::IRenderWindowPartListener { Q_OBJECT public: QmitkSegmentationUtilitiesView(); ~QmitkSegmentationUtilitiesView(); void CreateQtPartControl(QWidget* parent); void SetFocus(); void RenderWindowPartActivated(mitk::IRenderWindowPart* renderWindowPart); void RenderWindowPartDeactivated(mitk::IRenderWindowPart* renderWindowPart); private: void AddUtilityWidget(QWidget* widget, const QIcon& icon, const QString& text); Ui::QmitkSegmentationUtilitiesViewControls m_Controls; QmitkBooleanOperationsWidget* m_BooleanOperationsWidget; + QmitkContourModelToImageWidget* m_ContourModelToImageWidget; QmitkImageMaskingWidget* m_ImageMaskingWidget; QmitkMorphologicalOperationsWidget* m_MorphologicalOperationsWidget; QmitkSurfaceToImageWidget* m_SurfaceToImageWidget; QmitkCTKWidgetsWidget* m_CTKWidgetsWidget; }; #endif