diff --git a/Modules/CMakeLists.txt b/Modules/CMakeLists.txt index dc1781f1a1..d102bf4a11 100644 --- a/Modules/CMakeLists.txt +++ b/Modules/CMakeLists.txt @@ -1,60 +1,61 @@ set(LIBPOSTFIX "Ext") # Modules must be listed according to their dependencies set(module_dirs SceneSerializationBase PlanarFigure ImageExtraction ImageStatistics LegacyAdaptors IpPicSupport MitkExt SceneSerialization GraphAlgorithms Segmentation Qmitk QmitkExt + SegmentationUI Properties DiffusionImaging GPGPU IGT CameraCalibration IGTUI RigidRegistration RigidRegistrationUI DeformableRegistration DeformableRegistrationUI OpenCL OpenCVVideoSupport Overlays InputDevices ToFHardware ToFProcessing ToFUI US ClippingTools USUI DicomUI Simulation Python ) set(MITK_DEFAULT_SUBPROJECTS MITK-Modules) foreach(module_dir ${module_dirs}) add_subdirectory(${module_dir}) endforeach() if(MITK_PRIVATE_MODULES) file(GLOB all_subdirs RELATIVE ${MITK_PRIVATE_MODULES} ${MITK_PRIVATE_MODULES}/*) foreach(subdir ${all_subdirs}) string(FIND ${subdir} "." _result) if(_result EQUAL -1) if(EXISTS ${MITK_PRIVATE_MODULES}/${subdir}/CMakeLists.txt) message(STATUS "Found private module ${subdir}") add_subdirectory(${MITK_PRIVATE_MODULES}/${subdir} private_modules/${subdir}) endif() endif() endforeach() endif(MITK_PRIVATE_MODULES) diff --git a/Modules/MitkExt/Interactions/mitkTool.cpp b/Modules/MitkExt/Interactions/mitkTool.cpp index 8db3fb311d..19e67a1a60 100644 --- a/Modules/MitkExt/Interactions/mitkTool.cpp +++ b/Modules/MitkExt/Interactions/mitkTool.cpp @@ -1,180 +1,193 @@ /*=================================================================== 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 "mitkTool.h" #include "mitkDataNodeFactory.h" #include "mitkProperties.h" #include "mitkLevelWindowProperty.h" #include "mitkVtkResliceInterpolationProperty.h" +// us +#include "mitkModule.h" +#include "mitkModuleResource.h" +#include +#include + #include mitk::Tool::Tool(const char* type) : StateMachine(type), m_SupportRoi(false), // for reference images m_PredicateImages(NodePredicateDataType::New("Image")), m_PredicateDim3(NodePredicateDimension::New(3, 1)), m_PredicateDim4(NodePredicateDimension::New(4, 1)), m_PredicateDimension( mitk::NodePredicateOr::New(m_PredicateDim3, m_PredicateDim4) ), m_PredicateImage3D( NodePredicateAnd::New(m_PredicateImages, m_PredicateDimension) ), m_PredicateBinary(NodePredicateProperty::New("binary", BoolProperty::New(true))), m_PredicateNotBinary( NodePredicateNot::New(m_PredicateBinary) ), m_PredicateSegmentation(NodePredicateProperty::New("segmentation", BoolProperty::New(true))), m_PredicateNotSegmentation( NodePredicateNot::New(m_PredicateSegmentation) ), m_PredicateHelper(NodePredicateProperty::New("helper object", BoolProperty::New(true))), m_PredicateNotHelper( NodePredicateNot::New(m_PredicateHelper) ), m_PredicateImageColorful( NodePredicateAnd::New(m_PredicateNotBinary, m_PredicateNotSegmentation) ), m_PredicateImageColorfulNotHelper( NodePredicateAnd::New(m_PredicateImageColorful, m_PredicateNotHelper) ), m_PredicateReference( NodePredicateAnd::New(m_PredicateImage3D, m_PredicateImageColorfulNotHelper) ), // for working image m_IsSegmentationPredicate(NodePredicateAnd::New(NodePredicateOr::New(m_PredicateBinary, m_PredicateSegmentation), m_PredicateNotHelper)) { } mitk::Tool::~Tool() { } const char* mitk::Tool::GetGroup() const { return "default"; } void mitk::Tool::SetToolManager(ToolManager* manager) { m_ToolManager = manager; } void mitk::Tool::Activated() { } void mitk::Tool::Deactivated() { StateMachine::ResetStatemachineToStartState(); // forget about the past } itk::Object::Pointer mitk::Tool::GetGUI(const std::string& toolkitPrefix, const std::string& toolkitPostfix) { itk::Object::Pointer object; std::string classname = this->GetNameOfClass(); std::string guiClassname = toolkitPrefix + classname + toolkitPostfix; std::list allGUIs = itk::ObjectFactoryBase::CreateAllInstance(guiClassname.c_str()); for( std::list::iterator iter = allGUIs.begin(); iter != allGUIs.end(); ++iter ) { if (object.IsNull()) { object = dynamic_cast( iter->GetPointer() ); } else { MITK_ERROR << "There is more than one GUI for " << classname << " (several factories claim ability to produce a " << guiClassname << " ) " << std::endl; return NULL; // people should see and fix this error } } return object; } mitk::NodePredicateBase::ConstPointer mitk::Tool::GetReferenceDataPreference() const { return m_PredicateReference.GetPointer(); } mitk::NodePredicateBase::ConstPointer mitk::Tool::GetWorkingDataPreference() const { return m_IsSegmentationPredicate.GetPointer(); } mitk::DataNode::Pointer mitk::Tool::CreateEmptySegmentationNode( Image* original, const std::string& organName, const mitk::Color& color ) { // we NEED a reference image for size etc. if (!original) return NULL; // actually create a new empty segmentation PixelType pixelType(mitk::MakeScalarPixelType() ); Image::Pointer segmentation = Image::New(); if (original->GetDimension() == 2) { const unsigned int dimensions[] = { original->GetDimension(0), original->GetDimension(1), 1 }; segmentation->Initialize(pixelType, 3, dimensions); } else { segmentation->Initialize(pixelType, original->GetDimension(), original->GetDimensions()); } unsigned int byteSize = sizeof(DefaultSegmentationDataType); for (unsigned int dim = 0; dim < segmentation->GetDimension(); ++dim) { byteSize *= segmentation->GetDimension(dim); } memset( segmentation->GetData(), 0, byteSize ); if (original->GetTimeSlicedGeometry() ) { TimeSlicedGeometry::Pointer originalGeometry = original->GetTimeSlicedGeometry()->Clone(); segmentation->SetGeometry( originalGeometry ); } else { Tool::ErrorMessage("Original image does not have a 'Time sliced geometry'! Cannot create a segmentation."); return NULL; } return CreateSegmentationNode( segmentation, organName, color ); } mitk::DataNode::Pointer mitk::Tool::CreateSegmentationNode( Image* image, const std::string& organName, const mitk::Color& color ) { if (!image) return NULL; // decorate the datatreenode with some properties DataNode::Pointer segmentationNode = DataNode::New(); segmentationNode->SetData( image ); // name segmentationNode->SetProperty( "name", StringProperty::New( organName ) ); // visualization properties segmentationNode->SetProperty( "binary", BoolProperty::New(true) ); segmentationNode->SetProperty( "color", ColorProperty::New(color) ); segmentationNode->SetProperty( "texture interpolation", BoolProperty::New(false) ); segmentationNode->SetProperty( "layer", IntProperty::New(10) ); segmentationNode->SetProperty( "levelwindow", LevelWindowProperty::New( LevelWindow(0.5, 1) ) ); segmentationNode->SetProperty( "opacity", FloatProperty::New(0.3) ); segmentationNode->SetProperty( "segmentation", BoolProperty::New(true) ); segmentationNode->SetProperty( "reslice interpolation", VtkResliceInterpolationProperty::New() ); // otherwise -> segmentation appears in 2 slices sometimes (only visual effect, not different data) // For MITK-3M3 release, the volume of all segmentations should be shown segmentationNode->SetProperty( "showVolume", BoolProperty::New( true ) ); return segmentationNode; } +mitk::ModuleResource mitk::Tool::GetIconResource() const +{ + Module* module = GetModuleContext()->GetModule(); + // Each specific tool should load its own resource. This one will be invalid + ModuleResource resource = module->GetResource("dummy.resource"); + return resource; +} diff --git a/Modules/MitkExt/Interactions/mitkTool.h b/Modules/MitkExt/Interactions/mitkTool.h index 702cda28de..b2cbe68469 100644 --- a/Modules/MitkExt/Interactions/mitkTool.h +++ b/Modules/MitkExt/Interactions/mitkTool.h @@ -1,233 +1,241 @@ /*=================================================================== 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 mitkTool_h_Included #define mitkTool_h_Included #include "mitkCommon.h" #include "MitkExtExports.h" #include "mitkStateMachine.h" #include "mitkToolEvents.h" #include "itkObjectFactoryBase.h" #include "itkVersion.h" #include "mitkToolFactoryMacro.h" #include "mitkMessage.h" #include "mitkDataNode.h" #include "mitkNodePredicateProperty.h" #include "mitkNodePredicateDataType.h" #include "mitkNodePredicateDimension.h" #include "mitkNodePredicateAnd.h" #include "mitkNodePredicateOr.h" #include "mitkNodePredicateNot.h" #include #include #include namespace mitk { + class ModuleResource; class ToolManager; /** \brief Base class of all tools used by mitk::ToolManager. \sa ToolManager \sa SegTool2D \ingroup Interaction \ingroup ToolManagerEtAl There is a separate page describing the \ref QmitkInteractiveSegmentationTechnicalPage. Every tool is a mitk::StateMachine, which can follow any transition pattern that it likes. One important thing to know is, that every derived tool should always call SuperClass::Deactivated() in its own implementation of Deactivated, because mitk::Tool resets the StateMachine in this method. Only if you are very sure that you covered all possible things that might happen to your own tool, you should consider not to reset the StateMachine from time to time. To learn about the MITK implementation of state machines in general, have a look at \ref InteractionPage. To derive a non-abstract tool, you inherit from mitk::Tool (or some other base class further down the inheritance tree), and in your own parameterless constructor (that is called from the itkNewMacro that you use) you pass a StateMachine pattern name to the superclass. Names for valid patterns can be found in StateMachine.xml (which might be enhanced by you). You have to implement at least GetXPM() and GetName() to provide some identification. Each Tool knows its ToolManager, which can provide the data that the tool should work on. \warning Only to be instantiated by mitk::ToolManager (because SetToolManager has to be called). All other uses are unsupported. $Author$ */ class MitkExt_EXPORT Tool : public StateMachine { public: typedef unsigned char DefaultSegmentationDataType; /** * \brief To let GUI process new events (e.g. qApp->processEvents() ) */ Message<> GUIProcessEventsMessage; /** * \brief To send error messages (to be shown by some GUI) */ Message1 ErrorMessage; /** * \brief To send whether the tool is busy (to be shown by some GUI) */ Message1 CurrentlyBusy; /** * \brief To send general messages (to be shown by some GUI) */ Message1 GeneralMessage; mitkClassMacro(Tool, StateMachine); // no New(), there should only be subclasses /** \brief Returns an icon in the XPM format. This icon has to fit into some kind of button in most applications, so make it smaller than 25x25 pixels. XPM is e.g. supported by The Gimp. But if you open any XPM file in your text editor, you will see that you could also "draw" it with an editor. */ virtual const char** GetXPM() const = 0; /** * \brief Returns the path of an icon. * * This icon is preferred to the XPM icon. */ virtual std::string GetIconPath() const { return ""; } /** * \brief Returns the path of a cursor icon. * */ virtual std::string GetCursorIconPath() const { return ""; } + /** + * @brief Returns the tool button icon of the tool wrapped by a usModuleResource + * @return a valid ModuleResource or an invalid if this function + * is not reimplemented + */ + virtual ModuleResource GetIconResource() const; + /** \brief Returns the name of this tool. Make it short! This name has to fit into some kind of button in most applications, so take some time to think of a good name! */ virtual const char* GetName() const = 0; /** \brief Name of a group. You can group several tools by assigning a group name. Graphical tool selectors might use this information to group tools. (What other reason could there be?) */ virtual const char* GetGroup() const; /** * \brief Interface for GUI creation. * * This is the basic interface for creation of a GUI object belonging to one tool. * * Tools that support a GUI (e.g. for display/editing of parameters) should follow some rules: * * - A Tool and its GUI are two separate classes * - There may be several instances of a GUI at the same time. * - mitk::Tool is toolkit (Qt, wxWidgets, etc.) independent, the GUI part is of course dependent * - The GUI part inherits both from itk::Object and some GUI toolkit class * - The GUI class name HAS to be constructed like "toolkitPrefix" tool->GetClassName() + "toolkitPostfix", e.g. MyTool -> wxMyToolGUI * - For each supported toolkit there is a base class for tool GUIs, which contains some convenience methods * - Tools notify the GUI about changes using ITK events. The GUI must observe interesting events. * - The GUI base class may convert all ITK events to the GUI toolkit's favoured messaging system (Qt -> signals) * - Calling methods of a tool by its GUI is done directly. * In some cases GUIs don't want to be notified by the tool when they cause a change in a tool. * There is a macro CALL_WITHOUT_NOTICE(method()), which will temporarily disable all notifications during a method call. */ virtual itk::Object::Pointer GetGUI(const std::string& toolkitPrefix, const std::string& toolkitPostfix); virtual NodePredicateBase::ConstPointer GetReferenceDataPreference() const; virtual NodePredicateBase::ConstPointer GetWorkingDataPreference() const; DataNode::Pointer CreateEmptySegmentationNode( Image* original, const std::string& organName, const mitk::Color& color ); DataNode::Pointer CreateSegmentationNode( Image* image, const std::string& organName, const mitk::Color& color ); itkGetMacro(SupportRoi, bool); itkSetMacro(SupportRoi, bool); itkBooleanMacro(SupportRoi); protected: friend class ToolManager; virtual void SetToolManager(ToolManager*); /** \brief Called when the tool gets activated (registered to mitk::GlobalInteraction). Derived tools should call their parents implementation. */ virtual void Activated(); /** \brief Called when the tool gets deactivated (unregistered from mitk::GlobalInteraction). Derived tools should call their parents implementation. */ virtual void Deactivated(); Tool(); // purposely hidden Tool( const char*); // purposely hidden virtual ~Tool(); ToolManager* m_ToolManager; bool m_SupportRoi; private: // for reference data NodePredicateDataType::Pointer m_PredicateImages; NodePredicateDimension::Pointer m_PredicateDim3; NodePredicateDimension::Pointer m_PredicateDim4; NodePredicateOr::Pointer m_PredicateDimension; NodePredicateAnd::Pointer m_PredicateImage3D; NodePredicateProperty::Pointer m_PredicateBinary; NodePredicateNot::Pointer m_PredicateNotBinary; NodePredicateProperty::Pointer m_PredicateSegmentation; NodePredicateNot::Pointer m_PredicateNotSegmentation; NodePredicateProperty::Pointer m_PredicateHelper; NodePredicateNot::Pointer m_PredicateNotHelper; NodePredicateAnd::Pointer m_PredicateImageColorful; NodePredicateAnd::Pointer m_PredicateImageColorfulNotHelper; NodePredicateAnd::Pointer m_PredicateReference; // for working data NodePredicateAnd::Pointer m_IsSegmentationPredicate; }; } // namespace #endif diff --git a/Modules/QmitkExt/CMakeLists.txt b/Modules/QmitkExt/CMakeLists.txt index fe6dab3cfa..c89ded677e 100644 --- a/Modules/QmitkExt/CMakeLists.txt +++ b/Modules/QmitkExt/CMakeLists.txt @@ -1,9 +1,8 @@ include_directories(${CTK_INCLUDE_DIRS}) MITK_CREATE_MODULE( QmitkExt INCLUDE_DIRS QmitkApplicationBase QmitkPropertyObservers QmitkFunctionalityComponents - DEPENDS MitkExt IpPicSupport Qmitk qwt qxt PlanarFigure SceneSerialization Segmentation - PACKAGE_DEPENDS CTK + DEPENDS MitkExt IpPicSupport Qmitk qwt qxt PlanarFigure SceneSerialization QT_MODULE ) diff --git a/Modules/QmitkExt/QmitkExtRegisterClasses.cpp b/Modules/QmitkExt/QmitkExtRegisterClasses.cpp index de61807866..804375bd20 100644 --- a/Modules/QmitkExt/QmitkExtRegisterClasses.cpp +++ b/Modules/QmitkExt/QmitkExtRegisterClasses.cpp @@ -1,48 +1,48 @@ /*=================================================================== 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 "QmitkExtRegisterClasses.h" #include "QmitkRenderingManagerFactory.h" #include "QmitkCallbackFromGUIThread.h" #include "QmitkNodeDescriptorManager.h" -#include "QmitkDrawPaintbrushToolGUI.h" +//#include "QmitkDrawPaintbrushToolGUI.h" #include "mitkNodePredicateDataType.h" #include "mitkNodePredicateProperty.h" #include "mitkNodePredicateAnd.h" #include "mitkProperties.h" #include #include void QmitkExtRegisterClasses() { static bool alreadyDone = false; if (!alreadyDone) { MITK_DEBUG << "QmitkExtRegisterClasses()"; static QmitkCallbackFromGUIThread globalQmitkCallbackFromGUIThread; alreadyDone = true; } } diff --git a/Modules/QmitkExt/files.cmake b/Modules/QmitkExt/files.cmake index b3e5052008..95ba54d22c 100644 --- a/Modules/QmitkExt/files.cmake +++ b/Modules/QmitkExt/files.cmake @@ -1,272 +1,224 @@ set(CPP_FILES QmitkApplicationBase/QmitkCommonFunctionality.cpp QmitkApplicationBase/QmitkIOUtil.cpp #QmitkModels/QmitkDataStorageListModel.cpp #QmitkModels/QmitkPropertiesTableModel.cpp #QmitkModels/QmitkDataStorageTreeModel.cpp #QmitkModels/QmitkDataStorageTableModel.cpp #QmitkModels/QmitkPropertyDelegate.cpp #QmitkModels/QmitkPointListModel.cpp #QmitkAlgorithmFunctionalityComponent.cpp #QmitkBaseAlgorithmComponent.cpp QmitkAboutDialog/QmitkAboutDialog.cpp #QmitkFunctionalityComponents/QmitkSurfaceCreatorComponent.cpp #QmitkFunctionalityComponents/QmitkPixelGreyValueManipulatorComponent.cpp #QmitkFunctionalityComponents/QmitkConnectivityFilterComponent.cpp #QmitkFunctionalityComponents/QmitkImageCropperComponent.cpp #QmitkFunctionalityComponents/QmitkSeedPointSetComponent.cpp #QmitkFunctionalityComponents/QmitkSurfaceTransformerComponent.cpp QmitkPropertyObservers/QmitkBasePropertyView.cpp QmitkPropertyObservers/QmitkBoolPropertyWidget.cpp QmitkPropertyObservers/QmitkColorPropertyEditor.cpp QmitkPropertyObservers/QmitkColorPropertyView.cpp QmitkPropertyObservers/QmitkEnumerationPropertyWidget.cpp QmitkPropertyObservers/QmitkNumberPropertyEditor.cpp QmitkPropertyObservers/QmitkNumberPropertyView.cpp QmitkPropertyObservers/QmitkPropertyViewFactory.cpp QmitkPropertyObservers/QmitkStringPropertyEditor.cpp QmitkPropertyObservers/QmitkStringPropertyOnDemandEdit.cpp QmitkPropertyObservers/QmitkStringPropertyView.cpp QmitkPropertyObservers/QmitkNumberPropertySlider.cpp QmitkPropertyObservers/QmitkUGCombinedRepresentationPropertyWidget.cpp qclickablelabel.cpp #QmitkAbortEventFilter.cpp # QmitkApplicationCursor.cpp QmitkCallbackFromGUIThread.cpp QmitkEditPointDialog.cpp QmitkExtRegisterClasses.cpp QmitkFileChooser.cpp # QmitkRenderingManager.cpp # QmitkRenderingManagerFactory.cpp # QmitkRenderWindow.cpp # QmitkEventAdapter.cpp QmitkFloatingPointSpanSlider.cpp QmitkColorTransferFunctionCanvas.cpp - QmitkSlicesInterpolator.cpp QmitkStandardViews.cpp QmitkStepperAdapter.cpp # QmitkLineEditLevelWindowWidget.cpp # mitkSliderLevelWindowWidget.cpp # QmitkLevelWindowWidget.cpp # QmitkPointListWidget.cpp # QmitkPointListView.cpp QmitkPiecewiseFunctionCanvas.cpp QmitkSliderNavigatorWidget.cpp QmitkTransferFunctionCanvas.cpp QmitkCrossWidget.cpp #QmitkLevelWindowRangeChangeDialog.cpp #QmitkLevelWindowPresetDefinitionDialog.cpp # QmitkLevelWindowWidgetContextMenu.cpp QmitkSliceWidget.cpp # QmitkStdMultiWidget.cpp QmitkTransferFunctionWidget.cpp QmitkTransferFunctionGeneratorWidget.cpp QmitkSelectableGLWidget.cpp - QmitkToolReferenceDataSelectionBox.cpp - QmitkToolWorkingDataSelectionBox.cpp - QmitkToolGUIArea.cpp - QmitkToolSelectionBox.cpp # QmitkPropertyListPopup.cpp - QmitkToolGUI.cpp - QmitkNewSegmentationDialog.cpp - QmitkPaintbrushToolGUI.cpp - QmitkDrawPaintbrushToolGUI.cpp - QmitkErasePaintbrushToolGUI.cpp - QmitkBinaryThresholdToolGUI.cpp - QmitkWatershedToolGUI.cpp - QmitkCalculateGrayValueStatisticsToolGUI.cpp - QmitkCopyToClipBoardDialog.cpp # QmitkMaterialEditor.cpp # QmitkMaterialShowcase.cpp # QmitkPropertiesTableEditor.cpp QmitkPrimitiveMovieNavigatorWidget.cpp # QmitkDataStorageComboBox.cpp - QmitkOtsuTool3DGUI.cpp QmitkHistogram.cpp QmitkHistogramWidget.cpp QmitkPlotWidget.cpp QmitkPlotDialog.cpp QmitkPointListModel.cpp QmitkPointListView.cpp QmitkPointListWidget.cpp QmitkPointListViewWidget.cpp QmitkCorrespondingPointSetsView.cpp QmitkCorrespondingPointSetsModel.cpp QmitkCorrespondingPointSetsWidget.cpp QmitkVideoBackground.cpp QmitkHotkeyLineEdit.cpp - QmitkBinaryThresholdULToolGUI.cpp - QmitkPixelManipulationToolGUI.cpp - QmitkRegionGrow3DToolGUI.cpp - QmitkToolRoiDataSelectionBox.cpp QmitkBoundingObjectWidget.cpp - QmitkFastMarchingTool3DGUI.cpp - QmitkLiveWireTool2DGUI.cpp - QmitkFastMarchingToolGUI.cpp - - QmitkAdaptiveRegionGrowingToolGUI.cpp QmitkModuleTableModel.cpp QmitkModulesDialog.cpp QmitkHistogramJSWidget.cpp QmitkLineEdit.cpp ) if( NOT ${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}.${VTK_BUILD_VERSION} VERSION_LESS 5.4.0 ) set(CPP_FILES ${CPP_FILES} QmitkVtkHistogramWidget.cpp QmitkVtkLineProfileWidget.cpp ) endif() if(NOT APPLE) set(CPP_FILES ${CPP_FILES} QmitkBaseComponent.cpp QmitkBaseFunctionalityComponent.cpp QmitkFunctionalityComponentContainer.cpp QmitkFunctionalityComponents/QmitkThresholdComponent.cpp ) endif() QT4_ADD_RESOURCES(CPP_FILES resources/QmitkResources.qrc) set(MOC_H_FILES QmitkPropertyObservers/QmitkBasePropertyView.h QmitkPropertyObservers/QmitkBoolPropertyWidget.h QmitkPropertyObservers/QmitkColorPropertyEditor.h QmitkPropertyObservers/QmitkColorPropertyView.h QmitkPropertyObservers/QmitkEnumerationPropertyWidget.h QmitkPropertyObservers/QmitkNumberPropertyEditor.h QmitkPropertyObservers/QmitkNumberPropertyView.h QmitkPropertyObservers/QmitkStringPropertyEditor.h QmitkPropertyObservers/QmitkStringPropertyOnDemandEdit.h QmitkPropertyObservers/QmitkStringPropertyView.h QmitkPropertyObservers/QmitkNumberPropertySlider.h QmitkPropertyObservers/QmitkUGCombinedRepresentationPropertyWidget.h # QmitkFunctionalityComponents/QmitkSurfaceCreatorComponent.h #QmitkFunctionalityComponents/QmitkPixelGreyValueManipulatorComponent.h # QmitkFunctionalityComponents/QmitkConnectivityFilterComponent.h # QmitkFunctionalityComponents/QmitkImageCropperComponent.h # QmitkFunctionalityComponents/QmitkSeedPointSetComponent.h # QmitkFunctionalityComponents/QmitkSurfaceTransformerComponent.h qclickablelabel.h QmitkCallbackFromGUIThread.h QmitkEditPointDialog.h #QmitkAlgorithmFunctionalityComponent.h #QmitkBaseAlgorithmComponent.h QmitkStandardViews.h QmitkStepperAdapter.h QmitkSliderNavigatorWidget.h QmitkSliceWidget.h - QmitkSlicesInterpolator.h QmitkColorTransferFunctionCanvas.h QmitkPiecewiseFunctionCanvas.h QmitkTransferFunctionCanvas.h QmitkFloatingPointSpanSlider.h QmitkCrossWidget.h QmitkTransferFunctionWidget.h QmitkTransferFunctionGeneratorWidget.h - QmitkToolGUIArea.h - QmitkToolGUI.h - QmitkToolReferenceDataSelectionBox.h - QmitkToolWorkingDataSelectionBox.h - QmitkToolSelectionBox.h # QmitkPropertyListPopup.h #QmitkSelectableGLWidget.h - QmitkNewSegmentationDialog.h - QmitkPaintbrushToolGUI.h - QmitkDrawPaintbrushToolGUI.h - QmitkErasePaintbrushToolGUI.h - QmitkBinaryThresholdToolGUI.h - QmitkWatershedToolGUI.h - QmitkCalculateGrayValueStatisticsToolGUI.h - QmitkCopyToClipBoardDialog.h QmitkPrimitiveMovieNavigatorWidget.h QmitkPlotWidget.h QmitkPointListModel.h QmitkPointListView.h QmitkPointListWidget.h QmitkPointListViewWidget.h QmitkCorrespondingPointSetsView.h QmitkCorrespondingPointSetsModel.h QmitkCorrespondingPointSetsWidget.h QmitkHistogramWidget.h QmitkVideoBackground.h QmitkFileChooser.h QmitkHotkeyLineEdit.h QmitkAboutDialog/QmitkAboutDialog.h - QmitkBinaryThresholdULToolGUI.h - QmitkPixelManipulationToolGUI.h - QmitkRegionGrow3DToolGUI.h - QmitkToolRoiDataSelectionBox.h QmitkBoundingObjectWidget.h QmitkPlotWidget.h - QmitkAdaptiveRegionGrowingToolGUI.h - QmitkFastMarchingTool3DGUI.h - QmitkLiveWireTool2DGUI.h - QmitkFastMarchingToolGUI.h - QmitkOtsuTool3DGUI.h QmitkHistogramJSWidget.h QmitkLineEdit.h ) if( NOT ${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}.${VTK_BUILD_VERSION} VERSION_LESS 5.4.0 ) set(MOC_H_FILES ${MOC_H_FILES} QmitkVtkHistogramWidget.h QmitkVtkLineProfileWidget.h ) endif() if(NOT APPLE) set(MOC_H_FILES ${MOC_H_FILES} QmitkBaseComponent.h QmitkBaseFunctionalityComponent.h QmitkFunctionalityComponentContainer.h QmitkFunctionalityComponents/QmitkThresholdComponent.h ) endif() set(UI_FILES QmitkSliderNavigator.ui # QmitkLevelWindowRangeChange.ui # QmitkLevelWindowPresetDefinition.ui # QmitkLevelWindowWidget.ui QmitkSliceWidget.ui QmitkTransferFunctionWidget.ui QmitkTransferFunctionGeneratorWidget.ui QmitkSelectableGLWidget.ui QmitkOtsuToolWidgetControls.ui QmitkPrimitiveMovieNavigatorWidget.ui QmitkFunctionalityComponentContainerControls.ui QmitkFunctionalityComponents/QmitkThresholdComponentControls.ui QmitkAboutDialog/QmitkAboutDialogGUI.ui - QmitkAdaptiveRegionGrowingToolGUIControls.ui ) set(QRC_FILES QmitkExt.qrc ) diff --git a/Modules/Segmentation/CMakeLists.txt b/Modules/Segmentation/CMakeLists.txt index a5046ae2fb..4c85edcba1 100644 --- a/Modules/Segmentation/CMakeLists.txt +++ b/Modules/Segmentation/CMakeLists.txt @@ -1,12 +1,10 @@ # configure_file(${PROJECT_SOURCE_DIR}/CMake/ToolExtensionITKFactory.cpp.in $#{PROJECT_BINARY_DIR}/ToolExtensionITKFactory.cpp.in COPYONLY) # configure_file(${PROJECT_SOURCE_DIR}/CMake/ToolExtensionITKFactoryLoader.cpp.in $#{PROJECT_BINARY_DIR}/ToolExtensionITKFactoryLoader.cpp.in COPYONLY) # configure_file(${PROJECT_SOURCE_DIR}/CMake/ToolGUIExtensionITKFactory.cpp.in $#{PROJECT_BINARY_DIR}/ToolGUIExtensionITKFactory.cpp.in COPYONLY) MITK_CREATE_MODULE(Segmentation INCLUDE_DIRS Algorithms Controllers DataManagement Interactions IO Rendering SegmentationUtilities/BooleanOperations SegmentationUtilities/MorphologicalOperations DEPENDS Mitk ipSegmentation mitkIpFunc MitkExt MitkGraphAlgorithms - PACKAGE_DEPENDS QT - QT_MODULE ) add_subdirectory(Testing) diff --git a/Modules/Segmentation/Interactions/mitkAdaptiveRegionGrowingTool.cpp b/Modules/Segmentation/Interactions/mitkAdaptiveRegionGrowingTool.cpp index 9ccabe0a31..fc858b6d94 100644 --- a/Modules/Segmentation/Interactions/mitkAdaptiveRegionGrowingTool.cpp +++ b/Modules/Segmentation/Interactions/mitkAdaptiveRegionGrowingTool.cpp @@ -1,69 +1,77 @@ /*=================================================================== 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 "mitkAdaptiveRegionGrowingTool.h" #include "mitkToolManager.h" +// us +#include "mitkModule.h" +#include "mitkModuleResource.h" +#include +#include + namespace mitk { MITK_TOOL_MACRO(Segmentation_EXPORT, AdaptiveRegionGrowingTool, "AdaptiveRegionGrowingTool"); } mitk::AdaptiveRegionGrowingTool::AdaptiveRegionGrowingTool() { } mitk::AdaptiveRegionGrowingTool::~AdaptiveRegionGrowingTool() { } const char** mitk::AdaptiveRegionGrowingTool::GetXPM() const { return NULL; } const char* mitk::AdaptiveRegionGrowingTool::GetName() const { return "RegionGrowing"; } -std::string mitk::AdaptiveRegionGrowingTool::GetIconPath() const +mitk::ModuleResource mitk::AdaptiveRegionGrowingTool::GetIconResource() const { - return ":/Segmentation/RegionGrowing_48x48.png"; + Module* module = GetModuleContext()->GetModule(); + ModuleResource resource = module->GetResource("RegionGrowing_48x48.png"); + return resource; } void mitk::AdaptiveRegionGrowingTool::Activated() { } void mitk::AdaptiveRegionGrowingTool::Deactivated() { } mitk::DataNode* mitk::AdaptiveRegionGrowingTool::GetReferenceData(){ return this->m_ToolManager->GetReferenceData(0); } mitk::DataStorage* mitk::AdaptiveRegionGrowingTool::GetDataStorage(){ return this->m_ToolManager->GetDataStorage(); } mitk::DataNode* mitk::AdaptiveRegionGrowingTool::GetWorkingData(){ return this->m_ToolManager->GetWorkingData(0); } diff --git a/Modules/Segmentation/Interactions/mitkAdaptiveRegionGrowingTool.h b/Modules/Segmentation/Interactions/mitkAdaptiveRegionGrowingTool.h index 20e3c2eb99..a945368614 100644 --- a/Modules/Segmentation/Interactions/mitkAdaptiveRegionGrowingTool.h +++ b/Modules/Segmentation/Interactions/mitkAdaptiveRegionGrowingTool.h @@ -1,65 +1,68 @@ /*=================================================================== 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 mitkAdaptiveRegionGrowingTool_h_Included #define mitkAdaptiveRegionGrowingTool_h_Included #include "mitkCommon.h" #include "SegmentationExports.h" #include "mitkAutoSegmentationTool.h" #include "mitkDataStorage.h" +class ModuleResource; + namespace mitk { /** \brief Dummy Tool for AdaptiveRegionGrowingToolGUI to get Tool functionality for AdaptiveRegionGrowing. The actual logic is implemented in QmitkAdaptiveRegionGrowingToolGUI. \ingroup ToolManagerEtAl \sa mitk::Tool \sa QmitkInteractiveSegmentation */ class Segmentation_EXPORT AdaptiveRegionGrowingTool : public AutoSegmentationTool { public: mitkClassMacro(AdaptiveRegionGrowingTool, AutoSegmentationTool); itkNewMacro(AdaptiveRegionGrowingTool); virtual const char** GetXPM() const; virtual const char* GetName() const; - virtual std::string GetIconPath() const; + ModuleResource GetIconResource() const; + virtual void Activated(); virtual void Deactivated(); mitk::DataNode* GetReferenceData(); mitk::DataNode* GetWorkingData(); mitk::DataStorage* GetDataStorage(); protected: AdaptiveRegionGrowingTool(); // purposely hidden virtual ~AdaptiveRegionGrowingTool(); }; } // namespace #endif diff --git a/Modules/Segmentation/Interactions/mitkAddContourTool.cpp b/Modules/Segmentation/Interactions/mitkAddContourTool.cpp index 7006e4f6de..7cf1096204 100644 --- a/Modules/Segmentation/Interactions/mitkAddContourTool.cpp +++ b/Modules/Segmentation/Interactions/mitkAddContourTool.cpp @@ -1,53 +1,60 @@ /*=================================================================== 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 "mitkAddContourTool.h" #include "mitkAddContourTool.xpm" +// us +#include "mitkModule.h" +#include "mitkModuleResource.h" +#include + namespace mitk { MITK_TOOL_MACRO(Segmentation_EXPORT, AddContourTool, "Add tool"); } mitk::AddContourTool::AddContourTool() :ContourTool(1) { } mitk::AddContourTool::~AddContourTool() { } const char** mitk::AddContourTool::GetXPM() const { return mitkAddContourTool_xpm; } -std::string mitk::AddContourTool::GetIconPath() const +mitk::ModuleResource mitk::AddContourTool::GetIconResource() const { - return ":/Segmentation/Add_48x48.png"; + Module* module = GetModuleContext()->GetModule(); + ModuleResource resource = module->GetResource("Add_48x48.png"); + return resource; } std::string mitk::AddContourTool::GetCursorIconPath() const { return ":/Segmentation/Add_Cursor_48x48.png"; } const char* mitk::AddContourTool::GetName() const { return "Add"; } diff --git a/Modules/Segmentation/Interactions/mitkAddContourTool.h b/Modules/Segmentation/Interactions/mitkAddContourTool.h index ebc77f7da0..2ff7cbe4d6 100644 --- a/Modules/Segmentation/Interactions/mitkAddContourTool.h +++ b/Modules/Segmentation/Interactions/mitkAddContourTool.h @@ -1,68 +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 mitkAddContourTool_h_Included #define mitkAddContourTool_h_Included #include "mitkContourTool.h" #include "SegmentationExports.h" +class ModuleResource; + namespace mitk { /** \brief Fill the inside of a contour with 1 \sa ContourTool \ingroup Interaction \ingroup ToolManagerEtAl Fills a visible contour (from FeedbackContourTool) during mouse dragging. When the mouse button is released, AddContourTool tries to extract a slice from the working image and fill in the (filled) contour as a binary image. All inside pixels are set to 1. While holding the CTRL key, the contour changes color and the pixels on the inside would be filled with 0. \warning Only to be instantiated by mitk::ToolManager. $Author$ */ class Segmentation_EXPORT AddContourTool : public ContourTool { public: mitkClassMacro(AddContourTool, ContourTool); itkNewMacro(AddContourTool); virtual const char** GetXPM() const; - virtual std::string GetIconPath() const; virtual std::string GetCursorIconPath() const; + ModuleResource GetIconResource() const; + virtual const char* GetName() const; protected: AddContourTool(); // purposely hidden virtual ~AddContourTool(); }; } // namespace #endif diff --git a/Modules/Segmentation/Interactions/mitkBinaryThresholdTool.cpp b/Modules/Segmentation/Interactions/mitkBinaryThresholdTool.cpp index 9658e9d7f3..b66dabdf97 100644 --- a/Modules/Segmentation/Interactions/mitkBinaryThresholdTool.cpp +++ b/Modules/Segmentation/Interactions/mitkBinaryThresholdTool.cpp @@ -1,323 +1,330 @@ /*=================================================================== 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 "mitkBinaryThresholdTool.h" #include "mitkBinaryThresholdTool.xpm" #include "mitkToolManager.h" #include "mitkBoundingObjectToSegmentationFilter.h" #include #include "mitkLevelWindowProperty.h" #include "mitkColorProperty.h" #include "mitkProperties.h" #include "mitkOrganTypeProperty.h" #include "mitkVtkResliceInterpolationProperty.h" #include "mitkDataStorage.h" #include "mitkRenderingManager.h" #include "mitkImageCast.h" #include "mitkImageAccessByItk.h" #include "mitkImageTimeSelector.h" #include #include #include "mitkPadImageFilter.h" #include "mitkMaskAndCutRoiImageFilter.h" +// us +#include "mitkModule.h" +#include "mitkModuleResource.h" +#include "mitkGetModuleContext.h" + namespace mitk { MITK_TOOL_MACRO(Segmentation_EXPORT, BinaryThresholdTool, "Thresholding tool"); } mitk::BinaryThresholdTool::BinaryThresholdTool() :m_SensibleMinimumThresholdValue(-100), m_SensibleMaximumThresholdValue(+100), m_CurrentThresholdValue(0.0), m_IsFloatImage(false) { this->SupportRoiOn(); m_ThresholdFeedbackNode = DataNode::New(); mitk::CoreObjectFactory::GetInstance()->SetDefaultProperties( m_ThresholdFeedbackNode ); m_ThresholdFeedbackNode->SetProperty( "color", ColorProperty::New(1.0, 0.0, 0.0) ); m_ThresholdFeedbackNode->SetProperty( "texture interpolation", BoolProperty::New(false) ); m_ThresholdFeedbackNode->SetProperty( "layer", IntProperty::New( 100 ) ); m_ThresholdFeedbackNode->SetProperty( "levelwindow", LevelWindowProperty::New( LevelWindow(100, 1) ) ); m_ThresholdFeedbackNode->SetProperty( "name", StringProperty::New("Thresholding feedback") ); m_ThresholdFeedbackNode->SetProperty( "opacity", FloatProperty::New(0.3) ); m_ThresholdFeedbackNode->SetProperty( "helper object", BoolProperty::New(true) ); } mitk::BinaryThresholdTool::~BinaryThresholdTool() { } const char** mitk::BinaryThresholdTool::GetXPM() const { return NULL; } -std::string mitk::BinaryThresholdTool::GetIconPath() const +mitk::ModuleResource mitk::BinaryThresholdTool::GetIconResource() const { - return ":/Segmentation/Threshold_48x48.png"; + Module* module = GetModuleContext()->GetModule(); + ModuleResource resource = module->GetResource("Threshold_48x48.png"); + return resource; } const char* mitk::BinaryThresholdTool::GetName() const { return "Threshold"; } void mitk::BinaryThresholdTool::Activated() { m_ToolManager->RoiDataChanged += mitk::MessageDelegate(this, &mitk::BinaryThresholdTool::OnRoiDataChanged); m_OriginalImageNode = m_ToolManager->GetReferenceData(0); m_NodeForThresholding = m_OriginalImageNode; if ( m_NodeForThresholding.IsNotNull() ) { SetupPreviewNodeFor( m_NodeForThresholding ); } else { m_ToolManager->ActivateTool(-1); } } void mitk::BinaryThresholdTool::Deactivated() { m_ToolManager->RoiDataChanged -= mitk::MessageDelegate(this, &mitk::BinaryThresholdTool::OnRoiDataChanged); m_NodeForThresholding = NULL; m_OriginalImageNode = NULL; try { if (DataStorage* storage = m_ToolManager->GetDataStorage()) { storage->Remove( m_ThresholdFeedbackNode ); RenderingManager::GetInstance()->RequestUpdateAll(); } } catch(...) { // don't care } m_ThresholdFeedbackNode->SetData(NULL); } void mitk::BinaryThresholdTool::SetThresholdValue(double value) { if (m_ThresholdFeedbackNode.IsNotNull()) { m_CurrentThresholdValue = value; m_ThresholdFeedbackNode->SetProperty( "levelwindow", LevelWindowProperty::New( LevelWindow(m_CurrentThresholdValue, 0.001) ) ); RenderingManager::GetInstance()->RequestUpdateAll(); } } void mitk::BinaryThresholdTool::AcceptCurrentThresholdValue() { CreateNewSegmentationFromThreshold(m_NodeForThresholding); RenderingManager::GetInstance()->RequestUpdateAll(); m_ToolManager->ActivateTool(-1); } void mitk::BinaryThresholdTool::CancelThresholding() { m_ToolManager->ActivateTool(-1); } void mitk::BinaryThresholdTool::SetupPreviewNodeFor( DataNode* nodeForThresholding ) { if (nodeForThresholding) { Image::Pointer image = dynamic_cast( nodeForThresholding->GetData() ); Image::Pointer originalImage = dynamic_cast (m_OriginalImageNode->GetData()); if (image.IsNotNull()) { // initialize and a new node with the same image as our reference image // use the level window property of this image copy to display the result of a thresholding operation m_ThresholdFeedbackNode->SetData( image ); int layer(50); nodeForThresholding->GetIntProperty("layer", layer); m_ThresholdFeedbackNode->SetIntProperty("layer", layer+1); if (DataStorage* storage = m_ToolManager->GetDataStorage()) { if (storage->Exists(m_ThresholdFeedbackNode)) storage->Remove(m_ThresholdFeedbackNode); storage->Add( m_ThresholdFeedbackNode, m_OriginalImageNode ); } if (image.GetPointer() == originalImage.GetPointer()) { if ((originalImage->GetPixelType().GetPixelType() == itk::ImageIOBase::SCALAR) &&(originalImage->GetPixelType().GetComponentType() == itk::ImageIOBase::FLOAT)) m_IsFloatImage = true; else m_IsFloatImage = false; m_SensibleMinimumThresholdValue = static_cast( originalImage->GetScalarValueMin() ); m_SensibleMaximumThresholdValue = static_cast( originalImage->GetScalarValueMax() ); } LevelWindowProperty::Pointer lwp = dynamic_cast( m_ThresholdFeedbackNode->GetProperty( "levelwindow" )); if (lwp && !m_IsFloatImage ) { m_CurrentThresholdValue = static_cast( lwp->GetLevelWindow().GetLevel() ); } else { m_CurrentThresholdValue = (m_SensibleMaximumThresholdValue + m_SensibleMinimumThresholdValue)/2; } IntervalBordersChanged.Send(m_SensibleMinimumThresholdValue, m_SensibleMaximumThresholdValue, m_IsFloatImage); ThresholdingValueChanged.Send(m_CurrentThresholdValue); } } } void mitk::BinaryThresholdTool::CreateNewSegmentationFromThreshold(DataNode* node) { if (node) { Image::Pointer image = dynamic_cast( m_NodeForThresholding->GetData() ); if (image.IsNotNull()) { DataNode::Pointer emptySegmentation = m_ToolManager->GetWorkingData(0); if (emptySegmentation) { // actually perform a thresholding and ask for an organ type for (unsigned int timeStep = 0; timeStep < image->GetTimeSteps(); ++timeStep) { try { ImageTimeSelector::Pointer timeSelector = ImageTimeSelector::New(); timeSelector->SetInput( image ); timeSelector->SetTimeNr( timeStep ); timeSelector->UpdateLargestPossibleRegion(); Image::Pointer image3D = timeSelector->GetOutput(); if (image3D->GetDimension() == 2) { AccessFixedDimensionByItk_2( image3D, ITKThresholding, 2, dynamic_cast(emptySegmentation->GetData()), timeStep ); } else { AccessFixedDimensionByItk_2( image3D, ITKThresholding, 3, dynamic_cast(emptySegmentation->GetData()), timeStep ); } } catch(...) { Tool::ErrorMessage("Error accessing single time steps of the original image. Cannot create segmentation."); } } if (m_OriginalImageNode.GetPointer() != m_NodeForThresholding.GetPointer()) { mitk::PadImageFilter::Pointer padFilter = mitk::PadImageFilter::New(); padFilter->SetInput(0, dynamic_cast (emptySegmentation->GetData())); padFilter->SetInput(1, dynamic_cast (m_OriginalImageNode->GetData())); padFilter->SetBinaryFilter(true); padFilter->SetUpperThreshold(1); padFilter->SetLowerThreshold(1); padFilter->Update(); emptySegmentation->SetData(padFilter->GetOutput()); } m_ToolManager->SetWorkingData( emptySegmentation ); } } } } template void mitk::BinaryThresholdTool::ITKThresholding( itk::Image* originalImage, Image* segmentation, unsigned int timeStep ) { ImageTimeSelector::Pointer timeSelector = ImageTimeSelector::New(); timeSelector->SetInput( segmentation ); timeSelector->SetTimeNr( timeStep ); timeSelector->UpdateLargestPossibleRegion(); Image::Pointer segmentation3D = timeSelector->GetOutput(); typedef itk::Image< Tool::DefaultSegmentationDataType, 3> SegmentationType; // this is sure for new segmentations SegmentationType::Pointer itkSegmentation; CastToItkImage( segmentation3D, itkSegmentation ); // iterate over original and segmentation typedef itk::ImageRegionConstIterator< itk::Image > InputIteratorType; typedef itk::ImageRegionIterator< SegmentationType > SegmentationIteratorType; InputIteratorType inputIterator( originalImage, originalImage->GetLargestPossibleRegion() ); SegmentationIteratorType outputIterator( itkSegmentation, itkSegmentation->GetLargestPossibleRegion() ); inputIterator.GoToBegin(); outputIterator.GoToBegin(); while (!outputIterator.IsAtEnd()) { if ( inputIterator.Get() >= m_CurrentThresholdValue ) outputIterator.Set( 1 ); else outputIterator.Set( 0 ); ++inputIterator; ++outputIterator; } } void mitk::BinaryThresholdTool::OnRoiDataChanged() { mitk::DataNode::Pointer node = m_ToolManager->GetRoiData(0); if (node.IsNotNull()) { mitk::Image::Pointer image = dynamic_cast (m_NodeForThresholding->GetData()); if (image.IsNull()) return; mitk::MaskAndCutRoiImageFilter::Pointer roiFilter = mitk::MaskAndCutRoiImageFilter::New(); roiFilter->SetInput(image); roiFilter->SetRegionOfInterest(node->GetData()); roiFilter->Update(); mitk::DataNode::Pointer tmpNode = mitk::DataNode::New(); mitk::Image::Pointer tmpImage = roiFilter->GetOutput(); tmpNode->SetData(tmpImage); m_SensibleMaximumThresholdValue = static_cast (roiFilter->GetMaxValue()); m_SensibleMinimumThresholdValue = static_cast (roiFilter->GetMinValue()); SetupPreviewNodeFor( tmpNode ); m_NodeForThresholding = tmpNode; return; } else { this->SetupPreviewNodeFor(m_OriginalImageNode); m_NodeForThresholding = m_OriginalImageNode; return; } } diff --git a/Modules/Segmentation/Interactions/mitkBinaryThresholdTool.h b/Modules/Segmentation/Interactions/mitkBinaryThresholdTool.h index cf6c9484bb..0041c3c2bf 100644 --- a/Modules/Segmentation/Interactions/mitkBinaryThresholdTool.h +++ b/Modules/Segmentation/Interactions/mitkBinaryThresholdTool.h @@ -1,89 +1,91 @@ /*=================================================================== 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 mitkBinaryThresholdTool_h_Included #define mitkBinaryThresholdTool_h_Included #include "mitkCommon.h" #include "SegmentationExports.h" #include "mitkAutoSegmentationTool.h" #include "mitkDataNode.h" #include +class ModuleResource; + namespace mitk { /** \brief Calculates the segmented volumes for binary images. \ingroup ToolManagerEtAl \sa mitk::Tool \sa QmitkInteractiveSegmentation Last contributor: $Author$ */ class Segmentation_EXPORT BinaryThresholdTool : public AutoSegmentationTool { public: Message3 IntervalBordersChanged; Message1 ThresholdingValueChanged; mitkClassMacro(BinaryThresholdTool, AutoSegmentationTool); itkNewMacro(BinaryThresholdTool); virtual const char** GetXPM() const; - virtual std::string GetIconPath() const; + ModuleResource GetIconResource() const; virtual const char* GetName() const; virtual void Activated(); virtual void Deactivated(); virtual void SetThresholdValue(double value); virtual void AcceptCurrentThresholdValue(); virtual void CancelThresholding(); protected: BinaryThresholdTool(); // purposely hidden virtual ~BinaryThresholdTool(); void SetupPreviewNodeFor( DataNode* nodeForThresholding ); void CreateNewSegmentationFromThreshold(DataNode* node); void OnRoiDataChanged(); template void ITKThresholding( itk::Image* originalImage, mitk::Image* segmentation, unsigned int timeStep ); DataNode::Pointer m_ThresholdFeedbackNode; DataNode::Pointer m_OriginalImageNode; DataNode::Pointer m_NodeForThresholding; double m_SensibleMinimumThresholdValue; double m_SensibleMaximumThresholdValue; double m_CurrentThresholdValue; bool m_IsFloatImage; }; } // namespace #endif diff --git a/Modules/Segmentation/Interactions/mitkBinaryThresholdULTool.cpp b/Modules/Segmentation/Interactions/mitkBinaryThresholdULTool.cpp index 6fe6a294c8..4d22a1a8eb 100644 --- a/Modules/Segmentation/Interactions/mitkBinaryThresholdULTool.cpp +++ b/Modules/Segmentation/Interactions/mitkBinaryThresholdULTool.cpp @@ -1,319 +1,327 @@ /*=================================================================== 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 "mitkBinaryThresholdULTool.h" #include "mitkBinaryThresholdULTool.xpm" #include "mitkToolManager.h" #include "mitkLevelWindowProperty.h" #include "mitkColorProperty.h" #include "mitkProperties.h" #include "mitkDataStorage.h" #include "mitkRenderingManager.h" #include "mitkImageCast.h" #include "mitkImageAccessByItk.h" #include "mitkImageTimeSelector.h" #include #include #include "mitkMaskAndCutRoiImageFilter.h" #include "mitkPadImageFilter.h" +// us +#include "mitkModule.h" +#include "mitkModuleResource.h" +#include "mitkGetModuleContext.h" +#include "mitkModuleContext.h" + namespace mitk { MITK_TOOL_MACRO(Segmentation_EXPORT, BinaryThresholdULTool, "ThresholdingUL tool"); } mitk::BinaryThresholdULTool::BinaryThresholdULTool() :m_SensibleMinimumThresholdValue(-100), m_SensibleMaximumThresholdValue(+100), m_CurrentLowerThresholdValue(1), m_CurrentUpperThresholdValue(1) { this->SupportRoiOn(); m_ThresholdFeedbackNode = DataNode::New(); m_ThresholdFeedbackNode->SetProperty( "color", ColorProperty::New(1.0, 0.0, 0.0) ); m_ThresholdFeedbackNode->SetProperty( "name", StringProperty::New("Thresholding feedback") ); m_ThresholdFeedbackNode->SetProperty( "opacity", FloatProperty::New(0.3) ); m_ThresholdFeedbackNode->SetProperty("binary", BoolProperty::New(true)); m_ThresholdFeedbackNode->SetProperty( "helper object", BoolProperty::New(true) ); } mitk::BinaryThresholdULTool::~BinaryThresholdULTool() { } const char** mitk::BinaryThresholdULTool::GetXPM() const { return NULL; } -std::string mitk::BinaryThresholdULTool::GetIconPath() const +mitk::ModuleResource mitk::BinaryThresholdULTool::GetIconResource() const { - return ":/Segmentation/TwoThresholds_48x48.png"; + Module* module = GetModuleContext()->GetModule(); + ModuleResource resource = module->GetResource("TwoThresholds_48x48.png"); + return resource; } const char* mitk::BinaryThresholdULTool::GetName() const { return "Two Thresholds"; } void mitk::BinaryThresholdULTool::Activated() { m_ToolManager->RoiDataChanged += mitk::MessageDelegate(this, &mitk::BinaryThresholdULTool::OnRoiDataChanged); m_OriginalImageNode = m_ToolManager->GetReferenceData(0); m_NodeForThresholding = m_OriginalImageNode; if ( m_NodeForThresholding.IsNotNull() ) { SetupPreviewNode(); } else { m_ToolManager->ActivateTool(-1); } } void mitk::BinaryThresholdULTool::Deactivated() { m_ToolManager->RoiDataChanged -= mitk::MessageDelegate(this, &mitk::BinaryThresholdULTool::OnRoiDataChanged); m_NodeForThresholding = NULL; m_OriginalImageNode = NULL; try { if (DataStorage* storage = m_ToolManager->GetDataStorage()) { storage->Remove( m_ThresholdFeedbackNode ); RenderingManager::GetInstance()->RequestUpdateAll(); } } catch(...) { // don't care } m_ThresholdFeedbackNode->SetData(NULL); } void mitk::BinaryThresholdULTool::SetThresholdValues(int lower, int upper) { if (m_ThresholdFeedbackNode.IsNotNull()) { m_CurrentLowerThresholdValue = lower; m_CurrentUpperThresholdValue = upper; UpdatePreview(); } } void mitk::BinaryThresholdULTool::AcceptCurrentThresholdValue() { CreateNewSegmentationFromThreshold(m_NodeForThresholding); RenderingManager::GetInstance()->RequestUpdateAll(); m_ToolManager->ActivateTool(-1); } void mitk::BinaryThresholdULTool::CancelThresholding() { m_ToolManager->ActivateTool(-1); } void mitk::BinaryThresholdULTool::SetupPreviewNode() { if (m_NodeForThresholding.IsNotNull()) { Image::Pointer image = dynamic_cast( m_NodeForThresholding->GetData() ); Image::Pointer originalImage = dynamic_cast (m_OriginalImageNode->GetData()); if (image.IsNotNull()) { // initialize and a new node with the same image as our reference image // use the level window property of this image copy to display the result of a thresholding operation m_ThresholdFeedbackNode->SetData( image ); int layer(50); m_NodeForThresholding->GetIntProperty("layer", layer); m_ThresholdFeedbackNode->SetIntProperty("layer", layer+1); if (DataStorage* ds = m_ToolManager->GetDataStorage()) { if (!ds->Exists(m_ThresholdFeedbackNode)) ds->Add( m_ThresholdFeedbackNode, m_OriginalImageNode ); } if (image.GetPointer() == originalImage.GetPointer()) { m_SensibleMinimumThresholdValue = static_cast( originalImage->GetScalarValueMin() ); m_SensibleMaximumThresholdValue = static_cast( originalImage->GetScalarValueMax() ); } m_CurrentLowerThresholdValue = (m_SensibleMaximumThresholdValue + m_SensibleMinimumThresholdValue) / 3; m_CurrentUpperThresholdValue = 2*m_CurrentLowerThresholdValue; IntervalBordersChanged.Send(m_SensibleMinimumThresholdValue, m_SensibleMaximumThresholdValue); ThresholdingValuesChanged.Send(m_CurrentLowerThresholdValue, m_CurrentUpperThresholdValue); } } } void mitk::BinaryThresholdULTool::CreateNewSegmentationFromThreshold(DataNode* node) { if (node) { Image::Pointer image = dynamic_cast( m_NodeForThresholding->GetData() ); if (image.IsNotNull()) { // create a new image of the same dimensions and smallest possible pixel type DataNode::Pointer emptySegmentation = m_ToolManager->GetWorkingData(0); if (emptySegmentation) { // actually perform a thresholding and ask for an organ type for (unsigned int timeStep = 0; timeStep < image->GetTimeSteps(); ++timeStep) { try { ImageTimeSelector::Pointer timeSelector = ImageTimeSelector::New(); timeSelector->SetInput( image ); timeSelector->SetTimeNr( timeStep ); timeSelector->UpdateLargestPossibleRegion(); Image::Pointer image3D = timeSelector->GetOutput(); AccessFixedDimensionByItk_2( image3D, ITKThresholding, 3, dynamic_cast(emptySegmentation->GetData()), timeStep ); } catch(...) { Tool::ErrorMessage("Error accessing single time steps of the original image. Cannot create segmentation."); } } //since we are maybe working on a smaller image, pad it to the size of the original image if (m_OriginalImageNode.GetPointer() != m_NodeForThresholding.GetPointer()) { mitk::PadImageFilter::Pointer padFilter = mitk::PadImageFilter::New(); padFilter->SetInput(0, dynamic_cast (emptySegmentation->GetData())); padFilter->SetInput(1, dynamic_cast (m_OriginalImageNode->GetData())); padFilter->SetBinaryFilter(true); padFilter->SetUpperThreshold(1); padFilter->SetLowerThreshold(1); padFilter->Update(); emptySegmentation->SetData(padFilter->GetOutput()); } m_ToolManager->SetWorkingData( emptySegmentation ); } } } } template void mitk::BinaryThresholdULTool::ITKThresholding( itk::Image* originalImage, Image* segmentation, unsigned int timeStep ) { ImageTimeSelector::Pointer timeSelector = ImageTimeSelector::New(); timeSelector->SetInput( segmentation ); timeSelector->SetTimeNr( timeStep ); timeSelector->UpdateLargestPossibleRegion(); Image::Pointer segmentation3D = timeSelector->GetOutput(); typedef itk::Image< Tool::DefaultSegmentationDataType, 3> SegmentationType; // this is sure for new segmentations SegmentationType::Pointer itkSegmentation; CastToItkImage( segmentation3D, itkSegmentation ); // iterate over original and segmentation typedef itk::ImageRegionConstIterator< itk::Image > InputIteratorType; typedef itk::ImageRegionIterator< SegmentationType > SegmentationIteratorType; InputIteratorType inputIterator( originalImage, originalImage->GetLargestPossibleRegion() ); SegmentationIteratorType outputIterator( itkSegmentation, itkSegmentation->GetLargestPossibleRegion() ); inputIterator.GoToBegin(); outputIterator.GoToBegin(); while (!outputIterator.IsAtEnd()) { if ( (signed)inputIterator.Get() >= m_CurrentLowerThresholdValue && (signed)inputIterator.Get() <= m_CurrentUpperThresholdValue ) { outputIterator.Set( 1 ); } else { outputIterator.Set( 0 ); } ++inputIterator; ++outputIterator; } } void mitk::BinaryThresholdULTool::OnRoiDataChanged() { mitk::DataNode::Pointer node = m_ToolManager->GetRoiData(0); if (node.IsNotNull()) { mitk::MaskAndCutRoiImageFilter::Pointer roiFilter = mitk::MaskAndCutRoiImageFilter::New(); mitk::Image::Pointer image = dynamic_cast (m_NodeForThresholding->GetData()); if (image.IsNull()) return; roiFilter->SetInput(image); roiFilter->SetRegionOfInterest(node->GetData()); roiFilter->Update(); mitk::DataNode::Pointer tmpNode = mitk::DataNode::New(); tmpNode->SetData(roiFilter->GetOutput()); m_SensibleMinimumThresholdValue = static_cast( roiFilter->GetMinValue()); m_SensibleMaximumThresholdValue = static_cast( roiFilter->GetMaxValue()); m_NodeForThresholding = tmpNode; } else m_NodeForThresholding = m_OriginalImageNode; this->SetupPreviewNode(); this->UpdatePreview(); } void mitk::BinaryThresholdULTool::UpdatePreview() { typedef itk::Image ImageType; typedef itk::Image SegmentationType; typedef itk::BinaryThresholdImageFilter ThresholdFilterType; mitk::Image::Pointer thresholdimage = dynamic_cast (m_NodeForThresholding->GetData()); if(thresholdimage) { ImageType::Pointer itkImage = ImageType::New(); CastToItkImage(thresholdimage, itkImage); ThresholdFilterType::Pointer filter = ThresholdFilterType::New(); filter->SetInput(itkImage); filter->SetLowerThreshold(m_CurrentLowerThresholdValue); filter->SetUpperThreshold(m_CurrentUpperThresholdValue); filter->SetInsideValue(1); filter->SetOutsideValue(0); filter->Update(); mitk::Image::Pointer new_image = mitk::Image::New(); CastToMitkImage(filter->GetOutput(), new_image); m_ThresholdFeedbackNode->SetData(new_image); } RenderingManager::GetInstance()->RequestUpdateAll(); } diff --git a/Modules/Segmentation/Interactions/mitkBinaryThresholdULTool.h b/Modules/Segmentation/Interactions/mitkBinaryThresholdULTool.h index 33376a7da4..ccb598d342 100644 --- a/Modules/Segmentation/Interactions/mitkBinaryThresholdULTool.h +++ b/Modules/Segmentation/Interactions/mitkBinaryThresholdULTool.h @@ -1,96 +1,98 @@ /*=================================================================== 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 mitkBinaryThresholdULTool_h_Included #define mitkBinaryThresholdULTool_h_Included #include "mitkCommon.h" #include "SegmentationExports.h" #include "mitkAutoSegmentationTool.h" #include "mitkDataNode.h" #include #include +class ModuleResource; + namespace mitk { /** \brief Calculates the segmented volumes for binary images. \ingroup ToolManagerEtAl \sa mitk::Tool \sa QmitkInteractiveSegmentation Last contributor: $Author$ */ class Segmentation_EXPORT BinaryThresholdULTool : public AutoSegmentationTool { public: Message2 IntervalBordersChanged; Message2 ThresholdingValuesChanged; mitkClassMacro(BinaryThresholdULTool, AutoSegmentationTool); itkNewMacro(BinaryThresholdULTool); virtual const char** GetXPM() const; - virtual std::string GetIconPath() const; + ModuleResource GetIconResource() const; virtual const char* GetName() const; virtual void Activated(); virtual void Deactivated(); virtual void SetThresholdValues(int lower, int upper); virtual void AcceptCurrentThresholdValue(); virtual void CancelThresholding(); protected: BinaryThresholdULTool(); // purposely hidden virtual ~BinaryThresholdULTool(); void SetupPreviewNode(); void CreateNewSegmentationFromThreshold(DataNode* node); void OnRoiDataChanged(); void UpdatePreview(); template void ITKThresholding( itk::Image* originalImage, mitk::Image* segmentation, unsigned int timeStep ); DataNode::Pointer m_ThresholdFeedbackNode; DataNode::Pointer m_OriginalImageNode; DataNode::Pointer m_NodeForThresholding; int m_SensibleMinimumThresholdValue; int m_SensibleMaximumThresholdValue; int m_CurrentLowerThresholdValue; int m_CurrentUpperThresholdValue; typedef itk::Image ImageType; typedef itk::Image< Tool::DefaultSegmentationDataType, 3> SegmentationType; // this is sure for new segmentations typedef itk::BinaryThresholdImageFilter ThresholdFilterType; ThresholdFilterType::Pointer m_ThresholdFilter; }; } // namespace #endif diff --git a/Modules/Segmentation/Interactions/mitkCorrectorTool2D.cpp b/Modules/Segmentation/Interactions/mitkCorrectorTool2D.cpp index dca52f7b77..e7a7cfa782 100644 --- a/Modules/Segmentation/Interactions/mitkCorrectorTool2D.cpp +++ b/Modules/Segmentation/Interactions/mitkCorrectorTool2D.cpp @@ -1,163 +1,167 @@ /*=================================================================== 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 "mitkCorrectorTool2D.h" #include "mitkCorrectorAlgorithm.h" #include "mitkToolManager.h" -#include "mitkOverwriteSliceImageFilter.h" #include "mitkBaseRenderer.h" #include "mitkRenderingManager.h" #include "mitkCorrectorTool2D.xpm" -#include "mitkOverwriteDirectedPlaneImageFilter.h" +// us +#include "mitkModule.h" +#include "mitkModuleResource.h" +#include namespace mitk { MITK_TOOL_MACRO(Segmentation_EXPORT, CorrectorTool2D, "Correction tool"); } mitk::CorrectorTool2D::CorrectorTool2D(int paintingPixelValue) :FeedbackContourTool("PressMoveRelease"), m_PaintingPixelValue(paintingPixelValue) { // great magic numbers CONNECT_ACTION( 80, OnMousePressed ); CONNECT_ACTION( 90, OnMouseMoved ); CONNECT_ACTION( 42, OnMouseReleased ); GetFeedbackContour()->SetClosed( false ); // don't close the contour to a polygon } mitk::CorrectorTool2D::~CorrectorTool2D() { } const char** mitk::CorrectorTool2D::GetXPM() const { return mitkCorrectorTool2D_xpm; } -std::string mitk::CorrectorTool2D::GetIconPath() const +mitk::ModuleResource mitk::CorrectorTool2D::GetIconResource() const { - return ":/Segmentation/Correction_48x48.png"; + Module* module = GetModuleContext()->GetModule(); + ModuleResource resource = module->GetResource("Correction_48x48.png"); + return resource; } std::string mitk::CorrectorTool2D::GetCursorIconPath() const { return ":/Segmentation/Correction_Cursor_48x48.png"; } const char* mitk::CorrectorTool2D::GetName() const { return "Correction"; } void mitk::CorrectorTool2D::Activated() { Superclass::Activated(); } void mitk::CorrectorTool2D::Deactivated() { Superclass::Deactivated(); } bool mitk::CorrectorTool2D::OnMousePressed (Action* action, const StateEvent* stateEvent) { const PositionEvent* positionEvent = dynamic_cast(stateEvent->GetEvent()); if (!positionEvent) return false; m_LastEventSender = positionEvent->GetSender(); m_LastEventSlice = m_LastEventSender->GetSlice(); if ( FeedbackContourTool::CanHandleEvent(stateEvent) < 1.0 ) return false; Contour* contour = FeedbackContourTool::GetFeedbackContour(); contour->Initialize(); contour->AddVertex( positionEvent->GetWorldPosition() ); FeedbackContourTool::SetFeedbackContourVisible(true); return true; } bool mitk::CorrectorTool2D::OnMouseMoved (Action* action, const StateEvent* stateEvent) { if ( FeedbackContourTool::CanHandleEvent(stateEvent) < 1.0 ) return false; const PositionEvent* positionEvent = dynamic_cast(stateEvent->GetEvent()); if (!positionEvent) return false; Contour* contour = FeedbackContourTool::GetFeedbackContour(); contour->AddVertex( positionEvent->GetWorldPosition() ); assert( positionEvent->GetSender()->GetRenderWindow() ); mitk::RenderingManager::GetInstance()->RequestUpdate( positionEvent->GetSender()->GetRenderWindow() ); return true; } bool mitk::CorrectorTool2D::OnMouseReleased(Action* action, const StateEvent* stateEvent) { // 1. Hide the feedback contour, find out which slice the user clicked, find out which slice of the toolmanager's working image corresponds to that FeedbackContourTool::SetFeedbackContourVisible(false); const PositionEvent* positionEvent = dynamic_cast(stateEvent->GetEvent()); if (!positionEvent) return false; assert( positionEvent->GetSender()->GetRenderWindow() ); mitk::RenderingManager::GetInstance()->RequestUpdate( positionEvent->GetSender()->GetRenderWindow() ); if ( FeedbackContourTool::CanHandleEvent(stateEvent) < 1.0 ) return false; DataNode* workingNode( m_ToolManager->GetWorkingData(0) ); if (!workingNode) return false; Image* image = dynamic_cast(workingNode->GetData()); const PlaneGeometry* planeGeometry( dynamic_cast (positionEvent->GetSender()->GetCurrentWorldGeometry2D() ) ); if ( !image || !planeGeometry ) return false; // 2. Slice is known, now we try to get it as a 2D image and project the contour into index coordinates of this slice m_WorkingSlice = FeedbackContourTool::GetAffectedImageSliceAs2DImage( positionEvent, image ); if ( m_WorkingSlice.IsNull() ) { MITK_ERROR << "Unable to extract slice." << std::endl; return false; } CorrectorAlgorithm::Pointer algorithm = CorrectorAlgorithm::New(); algorithm->SetInput( m_WorkingSlice ); algorithm->SetContour( FeedbackContourTool::GetFeedbackContour() ); try { algorithm->UpdateLargestPossibleRegion(); } catch ( std::exception& e ) { MITK_ERROR << "Caught exception '" << e.what() << "'" << std::endl; } mitk::Image::Pointer resultSlice = mitk::Image::New(); resultSlice->Initialize(algorithm->GetOutput()); resultSlice->SetVolume(algorithm->GetOutput()->GetData()); this->WriteBackSegmentationResult(positionEvent, resultSlice); return true; } diff --git a/Modules/Segmentation/Interactions/mitkCorrectorTool2D.h b/Modules/Segmentation/Interactions/mitkCorrectorTool2D.h index 27ec4a5a06..84ccb5c427 100644 --- a/Modules/Segmentation/Interactions/mitkCorrectorTool2D.h +++ b/Modules/Segmentation/Interactions/mitkCorrectorTool2D.h @@ -1,82 +1,85 @@ /*=================================================================== 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 mitkCorrectorTool2D_h_Included #define mitkCorrectorTool2D_h_Included #include "mitkCommon.h" #include "SegmentationExports.h" #include "mitkFeedbackContourTool.h" +class ModuleResource; + namespace mitk { class Image; /** \brief Corrector tool for 2D binary segmentations \sa FeedbackContourTool \sa ExtractImageFilter \sa OverwriteSliceImageFilter \ingroup Interaction \ingroup ToolManagerEtAl Lets the user draw a (multi-point) line and intelligently decides what to do. The underlying algorithm tests if the line begins and ends inside or outside a segmentation and either adds or subtracts a piece of segmentation. Algorithm is implemented in CorrectorAlgorithm (so that it could be reimplemented in a more modern fashion some time). \warning Only to be instantiated by mitk::ToolManager. $Author$ */ class Segmentation_EXPORT CorrectorTool2D : public FeedbackContourTool { public: mitkClassMacro(CorrectorTool2D, FeedbackContourTool); itkNewMacro(CorrectorTool2D); virtual const char** GetXPM() const; - virtual std::string GetIconPath() const; virtual std::string GetCursorIconPath() const; + ModuleResource GetIconResource() const; + virtual const char* GetName() const; protected: CorrectorTool2D(int paintingPixelValue = 1); // purposely hidden virtual ~CorrectorTool2D(); virtual void Activated(); virtual void Deactivated(); virtual bool OnMousePressed (Action*, const StateEvent*); virtual bool OnMouseMoved (Action*, const StateEvent*); virtual bool OnMouseReleased(Action*, const StateEvent*); int m_PaintingPixelValue; Image::Pointer m_WorkingSlice; }; } // namespace #endif diff --git a/Modules/Segmentation/Interactions/mitkDrawPaintbrushTool.cpp b/Modules/Segmentation/Interactions/mitkDrawPaintbrushTool.cpp index 3aad396478..d9eac46deb 100644 --- a/Modules/Segmentation/Interactions/mitkDrawPaintbrushTool.cpp +++ b/Modules/Segmentation/Interactions/mitkDrawPaintbrushTool.cpp @@ -1,53 +1,60 @@ /*=================================================================== 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 "mitkDrawPaintbrushTool.h" #include "mitkDrawPaintbrushTool.xpm" +// us +#include "mitkModule.h" +#include "mitkModuleResource.h" +#include + namespace mitk { MITK_TOOL_MACRO(Segmentation_EXPORT, DrawPaintbrushTool, "Paintbrush drawing tool"); } mitk::DrawPaintbrushTool::DrawPaintbrushTool() :PaintbrushTool(1) { } mitk::DrawPaintbrushTool::~DrawPaintbrushTool() { } const char** mitk::DrawPaintbrushTool::GetXPM() const { return mitkDrawPaintbrushTool_xpm; } -std::string mitk::DrawPaintbrushTool::GetIconPath() const +mitk::ModuleResource mitk::DrawPaintbrushTool::GetIconResource() const { - return ":/Segmentation/Paint_48x48.png"; + Module* module = GetModuleContext()->GetModule(); + ModuleResource resource = module->GetResource("Paint_48x48.png"); + return resource; } std::string mitk::DrawPaintbrushTool::GetCursorIconPath() const { return ":/Segmentation/Paint_Cursor_48x48.png"; } const char* mitk::DrawPaintbrushTool::GetName() const { return "Paint"; } diff --git a/Modules/Segmentation/Interactions/mitkDrawPaintbrushTool.h b/Modules/Segmentation/Interactions/mitkDrawPaintbrushTool.h index 845b362438..c0e7b35f85 100644 --- a/Modules/Segmentation/Interactions/mitkDrawPaintbrushTool.h +++ b/Modules/Segmentation/Interactions/mitkDrawPaintbrushTool.h @@ -1,65 +1,68 @@ /*=================================================================== 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 mitkPaintContourTool_h_Included #define mitkPaintContourTool_h_Included #include "mitkPaintbrushTool.h" #include "SegmentationExports.h" +class ModuleResource; + namespace mitk { /** \brief Paintbrush tool for InteractiveSegmentation \sa FeedbackContourTool \sa ExtractImageFilter \sa OverwriteSliceImageFilter \ingroup Interaction \ingroup ToolManagerEtAl Simple paintbrush drawing tool. Right now there are only circular pens of varying size. This class specified only the drawing "color" for the super class PaintbrushTool. \warning Only to be instantiated by mitk::ToolManager. $Author: maleike $ */ class Segmentation_EXPORT DrawPaintbrushTool : public PaintbrushTool { public: mitkClassMacro(DrawPaintbrushTool, PaintbrushTool); itkNewMacro(DrawPaintbrushTool); virtual const char** GetXPM() const; - virtual std::string GetIconPath() const; virtual std::string GetCursorIconPath() const; + ModuleResource GetIconResource() const; + virtual const char* GetName() const; protected: DrawPaintbrushTool(); // purposely hidden virtual ~DrawPaintbrushTool(); }; } // namespace #endif diff --git a/Modules/Segmentation/Interactions/mitkErasePaintbrushTool.cpp b/Modules/Segmentation/Interactions/mitkErasePaintbrushTool.cpp index cc1d96b97b..52093f3a89 100644 --- a/Modules/Segmentation/Interactions/mitkErasePaintbrushTool.cpp +++ b/Modules/Segmentation/Interactions/mitkErasePaintbrushTool.cpp @@ -1,54 +1,61 @@ /*=================================================================== 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 "mitkErasePaintbrushTool.h" #include "mitkErasePaintbrushTool.xpm" +// us +#include "mitkModule.h" +#include "mitkModuleResource.h" +#include + namespace mitk { MITK_TOOL_MACRO(Segmentation_EXPORT, ErasePaintbrushTool, "Paintbrush erasing tool"); } mitk::ErasePaintbrushTool::ErasePaintbrushTool() :PaintbrushTool(0) { FeedbackContourTool::SetFeedbackContourColor( 1.0, 0.0, 0.0 ); } mitk::ErasePaintbrushTool::~ErasePaintbrushTool() { } const char** mitk::ErasePaintbrushTool::GetXPM() const { return mitkErasePaintbrushTool_xpm; } -std::string mitk::ErasePaintbrushTool::GetIconPath() const +mitk::ModuleResource mitk::ErasePaintbrushTool::GetIconResource() const { - return ":/Segmentation/Wipe_48x48.png"; + Module* module = GetModuleContext()->GetModule(); + ModuleResource resource = module->GetResource("Wipe_48x48.png"); + return resource; } std::string mitk::ErasePaintbrushTool::GetCursorIconPath() const { return ":/Segmentation/Wipe_Cursor_48x48.png"; } const char* mitk::ErasePaintbrushTool::GetName() const { return "Wipe"; } diff --git a/Modules/Segmentation/Interactions/mitkErasePaintbrushTool.h b/Modules/Segmentation/Interactions/mitkErasePaintbrushTool.h index 7dddafe518..23c40f826c 100644 --- a/Modules/Segmentation/Interactions/mitkErasePaintbrushTool.h +++ b/Modules/Segmentation/Interactions/mitkErasePaintbrushTool.h @@ -1,65 +1,68 @@ /*=================================================================== 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 mitkErasePaintbrushTool_h_Included #define mitkErasePaintbrushTool_h_Included #include "mitkPaintbrushTool.h" #include "SegmentationExports.h" +class ModuleResource; + namespace mitk { /** \brief Paintbrush tool for InteractiveSegmentation \sa FeedbackContourTool \sa ExtractImageFilter \sa OverwriteSliceImageFilter \ingroup Interaction \ingroup ToolManagerEtAl Simple paintbrush drawing tool. Right now there are only circular pens of varying size. This class specified only the drawing "color" for the super class PaintbrushTool. \warning Only to be instantiated by mitk::ToolManager. $Author: maleike $ */ class Segmentation_EXPORT ErasePaintbrushTool : public PaintbrushTool { public: mitkClassMacro(ErasePaintbrushTool, PaintbrushTool); itkNewMacro(ErasePaintbrushTool); virtual const char** GetXPM() const; - virtual std::string GetIconPath() const; virtual std::string GetCursorIconPath() const; + ModuleResource GetIconResource() const; + virtual const char* GetName() const; protected: ErasePaintbrushTool(); // purposely hidden virtual ~ErasePaintbrushTool(); }; } // namespace #endif diff --git a/Modules/Segmentation/Interactions/mitkEraseRegionTool.cpp b/Modules/Segmentation/Interactions/mitkEraseRegionTool.cpp index 4dbefcb9fe..6d9c1d54fc 100644 --- a/Modules/Segmentation/Interactions/mitkEraseRegionTool.cpp +++ b/Modules/Segmentation/Interactions/mitkEraseRegionTool.cpp @@ -1,54 +1,61 @@ /*=================================================================== 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 "mitkEraseRegionTool.h" #include "mitkEraseRegionTool.xpm" +// us +#include "mitkModule.h" +#include "mitkModuleResource.h" +#include + namespace mitk { MITK_TOOL_MACRO(Segmentation_EXPORT, EraseRegionTool, "Erase tool"); } mitk::EraseRegionTool::EraseRegionTool() :SetRegionTool(0) { FeedbackContourTool::SetFeedbackContourColor( 1.0, 0.0, 0.0 ); } mitk::EraseRegionTool::~EraseRegionTool() { } const char** mitk::EraseRegionTool::GetXPM() const { return mitkEraseRegionTool_xpm; } -std::string mitk::EraseRegionTool::GetIconPath() const +mitk::ModuleResource mitk::EraseRegionTool::GetIconResource() const { - return ":/Segmentation/Erase_48x48.png"; + Module* module = GetModuleContext()->GetModule(); + ModuleResource resource = module->GetResource("Erase_48x48.png"); + return resource; } std::string mitk::EraseRegionTool::GetCursorIconPath() const { return ":/Segmentation/Erase_Cursor_48x48.png"; } const char* mitk::EraseRegionTool::GetName() const { return "Erase"; } diff --git a/Modules/Segmentation/Interactions/mitkEraseRegionTool.h b/Modules/Segmentation/Interactions/mitkEraseRegionTool.h index 5e640165e7..99feed3429 100644 --- a/Modules/Segmentation/Interactions/mitkEraseRegionTool.h +++ b/Modules/Segmentation/Interactions/mitkEraseRegionTool.h @@ -1,64 +1,67 @@ /*=================================================================== 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 mitkEraseRegionTool_h_Included #define mitkEraseRegionTool_h_Included #include "mitkSetRegionTool.h" #include "SegmentationExports.h" +class ModuleResource; + namespace mitk { /** \brief Fill the inside of a contour with 1 \sa SetRegionTool \ingroup Interaction \ingroup ToolManagerEtAl Finds the outer contour of a shape in 2D (possibly including holes) and sets all the inside pixels to 0 (erasing a segmentation). \warning Only to be instantiated by mitk::ToolManager. $Author$ */ class Segmentation_EXPORT EraseRegionTool : public SetRegionTool { public: mitkClassMacro(EraseRegionTool, SetRegionTool); itkNewMacro(EraseRegionTool); virtual const char** GetXPM() const; - virtual std::string GetIconPath() const; virtual std::string GetCursorIconPath() const; + ModuleResource GetIconResource() const; + virtual const char* GetName() const; protected: EraseRegionTool(); // purposely hidden virtual ~EraseRegionTool(); }; } // namespace #endif diff --git a/Modules/Segmentation/Interactions/mitkFastMarchingTool.cpp b/Modules/Segmentation/Interactions/mitkFastMarchingTool.cpp index 050293c497..6954240f79 100644 --- a/Modules/Segmentation/Interactions/mitkFastMarchingTool.cpp +++ b/Modules/Segmentation/Interactions/mitkFastMarchingTool.cpp @@ -1,418 +1,424 @@ /*=================================================================== 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 "mitkFastMarchingTool.h" #include "mitkToolManager.h" #include "mitkBaseRenderer.h" #include "mitkRenderingManager.h" #include "mitkApplicationCursor.h" #include "mitkFastMarchingTool.xpm" #include "mitkInteractionConst.h" #include "itkOrImageFilter.h" +// us +#include "mitkModule.h" +#include "mitkModuleResource.h" +#include namespace mitk { MITK_TOOL_MACRO(Segmentation_EXPORT, FastMarchingTool, "FastMarching tool"); } mitk::FastMarchingTool::FastMarchingTool() :FeedbackContourTool("PressMoveReleaseAndPointSetting"), m_IsLivePreviewEnabled(false), m_LowerThreshold(0.0), m_UpperThreshold(200.0), m_StoppingValue(100), sigma(1.0), alpha(-0.5), beta(3.0) { /* Connect UI events */ CONNECT_ACTION( AcADDPOINTRMB, OnAddPoint ); CONNECT_ACTION( AcADDPOINT, OnAddPoint ); CONNECT_ACTION( AcREMOVEPOINT, OnDelete ); /*setup ITK filters */ m_SliceInITK = InternalImageType::New(); thresholder = ThresholdingFilterType::New(); thresholder->SetLowerThreshold( m_LowerThreshold ); thresholder->SetUpperThreshold( m_UpperThreshold ); thresholder->SetOutsideValue( 0 ); thresholder->SetInsideValue( 1.0 ); smoothing = SmoothingFilterType::New(); smoothing->SetTimeStep( 0.125 ); smoothing->SetNumberOfIterations( 5 ); smoothing->SetConductanceParameter( 9.0 ); gradientMagnitude = GradientFilterType::New(); gradientMagnitude->SetSigma( sigma ); sigmoid = SigmoidFilterType::New(); sigmoid->SetAlpha( alpha ); sigmoid->SetBeta( beta ); sigmoid->SetOutputMinimum( 0.0 ); sigmoid->SetOutputMaximum( 1.0 ); fastMarching = FastMarchingFilterType::New(); fastMarching->SetStoppingValue( m_StoppingValue ); seeds = NodeContainer::New(); seeds->Initialize(); fastMarching->SetTrialPoints( seeds ); //set up pipeline smoothing->SetInput( m_SliceInITK ); gradientMagnitude->SetInput( smoothing->GetOutput() ); sigmoid->SetInput( gradientMagnitude->GetOutput() ); fastMarching->SetInput( sigmoid->GetOutput() ); thresholder->SetInput( fastMarching->GetOutput() ); } mitk::FastMarchingTool::~FastMarchingTool() { m_ReferenceSlice = NULL; m_WorkingSlice = NULL; m_PositionEvent = NULL; } float mitk::FastMarchingTool::CanHandleEvent( StateEvent const *stateEvent) const { float returnValue = Superclass::CanHandleEvent(stateEvent); //we can handle delete if(stateEvent->GetId() == 12 ) { returnValue = 1.0; } return returnValue; } const char** mitk::FastMarchingTool::GetXPM() const { return NULL;// mitkFastMarchingTool_xpm; } -std::string mitk::FastMarchingTool::GetIconPath() const +mitk::ModuleResource mitk::FastMarchingTool::GetIconResource() const { - return ":/Segmentation/FastMarching_48x48.png"; + Module* module = GetModuleContext()->GetModule(); + ModuleResource resource = module->GetResource("FastMarching_48x48.png"); + return resource; } std::string mitk::FastMarchingTool::GetCursorIconPath() const { return ":/Segmentation/FastMarching_Cursor_48x48.png"; } const char* mitk::FastMarchingTool::GetName() const { return "Fast Marching"; } void mitk::FastMarchingTool::SetUpperThreshold(float value) { m_UpperThreshold = value; thresholder->SetUpperThreshold( m_UpperThreshold ); if(m_IsLivePreviewEnabled) this->UpdatePreviewImage(); } void mitk::FastMarchingTool::SetLowerThreshold(float value) { m_LowerThreshold = value; thresholder->SetLowerThreshold( m_LowerThreshold ); if(m_IsLivePreviewEnabled) this->UpdatePreviewImage(); } void mitk::FastMarchingTool::SetMu(float value) { beta = value; sigmoid->SetBeta( beta ); if(m_IsLivePreviewEnabled) this->UpdatePreviewImage(); } void mitk::FastMarchingTool::SetStandardDeviation(float value) { alpha = value; sigmoid->SetAlpha( alpha ); if(m_IsLivePreviewEnabled) this->UpdatePreviewImage(); } void mitk::FastMarchingTool::SetStoppingValue(float value) { m_StoppingValue = value; fastMarching->SetStoppingValue( m_StoppingValue ); if(m_IsLivePreviewEnabled) this->UpdatePreviewImage(); } void mitk::FastMarchingTool::SetLivePreviewEnabled(bool enabled) { m_IsLivePreviewEnabled = enabled; if(enabled)//an update may be needed this->UpdatePreviewImage(); } void mitk::FastMarchingTool::Activated() { Superclass::Activated(); m_ResultImageNode = mitk::DataNode::New(); m_ResultImageNode->SetName("FastMarching_Preview"); m_ResultImageNode->SetBoolProperty("helper object", true); m_ResultImageNode->SetColor(0.0, 1.0, 0.0); m_ResultImageNode->SetVisibility(true); m_ToolManager->GetDataStorage()->Add( this->m_ResultImageNode); m_SeedsAsPointSet = mitk::PointSet::New(); m_SeedsAsPointSetNode = mitk::DataNode::New(); m_SeedsAsPointSetNode->SetData(m_SeedsAsPointSet); m_SeedsAsPointSetNode->SetName("Seeds_Preview"); m_SeedsAsPointSetNode->SetBoolProperty("helper object", true); m_SeedsAsPointSetNode->SetColor(0.0, 1.0, 0.0); m_SeedsAsPointSetNode->SetVisibility(true); m_ToolManager->GetDataStorage()->Add( this->m_SeedsAsPointSetNode); } void mitk::FastMarchingTool::Deactivated() { Superclass::Deactivated(); m_ToolManager->GetDataStorage()->Remove( this->m_ResultImageNode ); m_ToolManager->GetDataStorage()->Remove( this->m_SeedsAsPointSetNode ); m_ResultImageNode = NULL; } void mitk::FastMarchingTool::ConfirmSegmentation() { /*+++++++combine preview image with already performed segmentation++++++*/ if (m_PositionEvent) { // remember parameters for next time if (dynamic_cast(m_ResultImageNode->GetData())) { //logical or combination of preview and segmentation slice OutputImageType::Pointer segmentationSlice = OutputImageType::New(); mitk::Image::Pointer workingSlice = GetAffectedWorkingSlice( m_PositionEvent ); CastToItkImage( workingSlice, segmentationSlice ); typedef itk::OrImageFilter OrImageFilterType; OrImageFilterType::Pointer orFilter = OrImageFilterType::New(); orFilter->SetInput(0, thresholder->GetOutput()); orFilter->SetInput(1, segmentationSlice); orFilter->Update(); mitk::Image::Pointer segmentationResult = mitk::Image::New(); mitk::CastToMitkImage(orFilter->GetOutput(), segmentationResult); segmentationResult->GetGeometry()->SetOrigin(workingSlice->GetGeometry()->GetOrigin()); segmentationResult->GetGeometry()->SetIndexToWorldTransform(workingSlice->GetGeometry()->GetIndexToWorldTransform()); //write to segmentation volume and hide preview image this->WriteBackSegmentationResult(m_PositionEvent, segmentationResult ); this->m_ResultImageNode->SetVisibility(false); this->ClearSeeds(); } mitk::RenderingManager::GetInstance()->RequestUpdate( m_PositionEvent->GetSender()->GetRenderWindow() ); } } bool mitk::FastMarchingTool::OnAddPoint(Action* action, const StateEvent* stateEvent) { /*++++++++++++Add a new seed point for FastMarching algorithm+++++++++++*/ const mitk::PositionEvent* p = dynamic_cast(stateEvent->GetEvent()); if (!p) return false; m_PositionEvent = new PositionEvent(p->GetSender(), p->GetType(), p->GetButton(), p->GetButtonState(), p->GetKey(), p->GetDisplayPosition(), p->GetWorldPosition()); //if click happpened in another renderwindow or slice then reset pipeline and preview if( (m_LastEventSender != m_PositionEvent->GetSender()) || (m_LastEventSlice != m_PositionEvent->GetSender()->GetSlice()) ) { this->ResetFastMarching(m_PositionEvent); } m_LastEventSender = m_PositionEvent->GetSender(); m_LastEventSlice = m_LastEventSender->GetSlice(); mitk::Point3D clickInIndex; m_ReferenceSlice->GetGeometry()->WorldToIndex(m_PositionEvent->GetWorldPosition(), clickInIndex); itk::Index<2> seedPosition; seedPosition[0] = clickInIndex[0]; seedPosition[1] = clickInIndex[1]; NodeType node; const double seedValue = 0.0; node.SetValue( seedValue ); node.SetIndex( seedPosition ); this->seeds->InsertElement(this->seeds->Size(), node); fastMarching->Modified(); m_SeedsAsPointSet->InsertPoint(m_SeedsAsPointSet->GetSize(), m_PositionEvent->GetWorldPosition()); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); //preview result by updating the pipeline - this is not done automatically for changing seeds if(m_IsLivePreviewEnabled) this->UpdatePreviewImage(); return true; } bool mitk::FastMarchingTool::OnDelete(Action* action, const StateEvent* stateEvent) { /*++++++++++delete last seed point++++++++*/ if(!(this->seeds->empty())) { //delete last element of seeds container this->seeds->pop_back(); fastMarching->Modified(); //delete last point in pointset - somehow ugly m_SeedsAsPointSet->GetPointSet()->GetPoints()->DeleteIndex(m_SeedsAsPointSet->GetSize() - 1); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); //preview result by updating the pipeline - this is not done automatically for changing seeds if(m_IsLivePreviewEnabled) this->UpdatePreviewImage(); } return true; } void mitk::FastMarchingTool::UpdatePreviewImage() { /*++++++++update FastMarching pipeline and show result++++++++*/ if(m_ReferenceSlice.IsNotNull()) { try{ thresholder->UpdateLargestPossibleRegion(); } catch( itk::ExceptionObject & excep ) { std::cerr << "Exception caught !" << std::endl; std::cerr << excep << std::endl; std::cerr << "Reseting step." << std::endl; this->ResetToInitialState(); return; } //make output visible mitk::Image::Pointer result = mitk::Image::New(); CastToMitkImage( thresholder->GetOutput(), result); result->GetGeometry()->SetOrigin(m_ReferenceSlice->GetGeometry()->GetOrigin() ); result->GetGeometry()->SetIndexToWorldTransform(m_ReferenceSlice->GetGeometry()->GetIndexToWorldTransform() ); m_ResultImageNode->SetData(result); m_ResultImageNode->SetVisibility(true); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } } void mitk::FastMarchingTool::ClearSeeds() { /*++++++++clear seeds for FastMarching as well as the PointSet for visualization++++++++*/ this->seeds->clear(); fastMarching->Modified(); m_SeedsAsPointSet->Clear(); m_ResultImageNode->SetVisibility(false); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } void mitk::FastMarchingTool::ResetFastMarching(const PositionEvent* positionEvent) { /*++++++++reset all relevant inputs for FastMarching++++++++*/ //reset reference slice according to the plane where the click happened m_ReferenceSlice = FeedbackContourTool::GetAffectedReferenceSlice( positionEvent ); //reset input of FastMarching pipeline CastToItkImage(m_ReferenceSlice, m_SliceInITK); smoothing->SetInput( m_SliceInITK ); //clear all seeds and preview empty result this->ClearSeeds(); this->UpdatePreviewImage(); } void mitk::FastMarchingTool::ResetToInitialState() { m_SeedsAsPointSet->Clear(); m_ResultImageNode->SetVisibility(false); m_SliceInITK = InternalImageType::New(); thresholder = ThresholdingFilterType::New(); thresholder->SetLowerThreshold( m_LowerThreshold ); thresholder->SetUpperThreshold( m_UpperThreshold ); thresholder->SetOutsideValue( 0 ); thresholder->SetInsideValue( 1.0 ); smoothing = SmoothingFilterType::New(); smoothing->SetTimeStep( 0.125 ); smoothing->SetNumberOfIterations( 5 ); smoothing->SetConductanceParameter( 9.0 ); gradientMagnitude = GradientFilterType::New(); gradientMagnitude->SetSigma( sigma ); sigmoid = SigmoidFilterType::New(); sigmoid->SetAlpha( alpha ); sigmoid->SetBeta( beta ); sigmoid->SetOutputMinimum( 0.0 ); sigmoid->SetOutputMaximum( 1.0 ); fastMarching = FastMarchingFilterType::New(); fastMarching->SetStoppingValue( m_StoppingValue ); seeds = NodeContainer::New(); seeds->Initialize(); fastMarching->SetTrialPoints( seeds ); //set up pipeline smoothing->SetInput( m_SliceInITK ); gradientMagnitude->SetInput( smoothing->GetOutput() ); sigmoid->SetInput( gradientMagnitude->GetOutput() ); fastMarching->SetInput( sigmoid->GetOutput() ); thresholder->SetInput( fastMarching->GetOutput() ); } diff --git a/Modules/Segmentation/Interactions/mitkFastMarchingTool.h b/Modules/Segmentation/Interactions/mitkFastMarchingTool.h index 06f9528b0d..7e4933caf2 100644 --- a/Modules/Segmentation/Interactions/mitkFastMarchingTool.h +++ b/Modules/Segmentation/Interactions/mitkFastMarchingTool.h @@ -1,155 +1,158 @@ /*=================================================================== 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 mitkFastMarchingTool_h_Included #define mitkFastMarchingTool_h_Included #include "mitkFeedbackContourTool.h" #include "mitkLegacyAdaptors.h" #include "SegmentationExports.h" #include "mitkDataNode.h" #include "mitkPointSet.h" #include "mitkPositionEvent.h" #include "itkImage.h" //itk filter #include "itkFastMarchingImageFilter.h" #include "itkBinaryThresholdImageFilter.h" #include "itkGradientMagnitudeRecursiveGaussianImageFilter.h" #include "itkSigmoidImageFilter.h" #include "itkCurvatureAnisotropicDiffusionImageFilter.h" +class ModuleResource; + namespace mitk { /** \brief FastMarching semgentation tool. The segmentation is done by setting one or more seed point within the image and adapting time range plus threshold. The pipeline is: Smoothing->GradientMagnitude->SigmoidFunction->FastMarching->Threshold The resulting binary image is seen as a segmentation of an object. For detailed documentation see ITK Software Guide section 9.3.1 Fast Marching Segmentation. */ class Segmentation_EXPORT FastMarchingTool : public FeedbackContourTool { public: mitkClassMacro(FastMarchingTool, FeedbackContourTool); itkNewMacro(FastMarchingTool); /* typedefs for itk pipeline */ typedef float InternalPixelType; typedef itk::Image< InternalPixelType, 2 > InternalImageType; typedef unsigned char OutputPixelType; typedef itk::Image< OutputPixelType, 2 > OutputImageType; typedef itk::BinaryThresholdImageFilter< InternalImageType, OutputImageType > ThresholdingFilterType; typedef itk::CurvatureAnisotropicDiffusionImageFilter< InternalImageType, InternalImageType > SmoothingFilterType; typedef itk::GradientMagnitudeRecursiveGaussianImageFilter< InternalImageType, InternalImageType > GradientFilterType; typedef itk::SigmoidImageFilter< InternalImageType, InternalImageType > SigmoidFilterType; typedef itk::FastMarchingImageFilter< InternalImageType, InternalImageType > FastMarchingFilterType; typedef FastMarchingFilterType::NodeContainer NodeContainer; typedef FastMarchingFilterType::NodeType NodeType; /* icon stuff */ virtual const char** GetXPM() const; virtual const char* GetName() const; - virtual std::string GetIconPath() const; + virtual std::string GetCursorIconPath() const; + ModuleResource GetIconResource() const; /* parameters of itk filters */ void SetUpperThreshold(float value); void SetLowerThreshold(float value); void SetMu(float value); void SetStoppingValue(float value); void SetStandardDeviation(float value); /// \brief Fill preview in segmentation image. virtual void ConfirmSegmentation(); /// \brief Select update preview image. virtual void SetLivePreviewEnabled(bool enabled); /// \brief Clear all seed point. void ClearSeeds(); protected: FastMarchingTool(); virtual ~FastMarchingTool(); virtual float CanHandleEvent( StateEvent const *stateEvent) const; virtual void Activated(); virtual void Deactivated(); /*Actions of StateMachine pattern*/ virtual bool OnAddPoint (Action*, const StateEvent*); virtual bool OnDelete (Action*, const StateEvent*); /// \brief Updates the itk pipeline and shows the result of FastMarching. void UpdatePreviewImage(); /// \brief Reset all relevant inputs of the itk pipeline. void ResetFastMarching(const PositionEvent* positionEvent); /// \brief Reinit filters. void ResetToInitialState(); mitk::BaseRenderer* m_LastEventSender; unsigned int m_LastEventSlice; mitk::PositionEvent* m_PositionEvent; Image::Pointer m_ReferenceSlice; Image::Pointer m_WorkingSlice; ScalarType m_LowerThreshold; ScalarType m_UpperThreshold; ScalarType m_StoppingValue; bool m_IsLivePreviewEnabled;//update preview image or not float sigma;//used for GradientFilter float alpha;//used for SigmoidFilter float beta;//used for SigmoidFilter NodeContainer::Pointer seeds;//seed point for FastMarching InternalImageType::Pointer m_SliceInITK;//the reference slice as itk::Image mitk::DataNode::Pointer m_ResultImageNode;//holds the result as a preview image mitk::DataNode::Pointer m_SeedsAsPointSetNode;//used to visualize the seed points mitk::PointSet::Pointer m_SeedsAsPointSet;//seed points as PointSet /* ITK filters */ ThresholdingFilterType::Pointer thresholder; SmoothingFilterType::Pointer smoothing; GradientFilterType::Pointer gradientMagnitude; SigmoidFilterType::Pointer sigmoid; FastMarchingFilterType::Pointer fastMarching; }; } // namespace #endif diff --git a/Modules/Segmentation/Interactions/mitkFastMarchingTool3D.cpp b/Modules/Segmentation/Interactions/mitkFastMarchingTool3D.cpp index 6447832a89..67f585116c 100644 --- a/Modules/Segmentation/Interactions/mitkFastMarchingTool3D.cpp +++ b/Modules/Segmentation/Interactions/mitkFastMarchingTool3D.cpp @@ -1,399 +1,404 @@ /*=================================================================== 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 "mitkFastMarchingTool3D.h" #include "mitkToolManager.h" #include "mitkBaseRenderer.h" #include "mitkRenderingManager.h" #include "mitkApplicationCursor.h" //#include "mitkFastMarchingTool3D.xpm" #include "mitkInteractionConst.h" #include "itkOrImageFilter.h" #include "mitkImageTimeSelector.h" - +// us +#include "mitkModule.h" +#include "mitkModuleResource.h" +#include namespace mitk { MITK_TOOL_MACRO(Segmentation_EXPORT, FastMarchingTool3D, "FastMarching tool"); } mitk::FastMarchingTool3D::FastMarchingTool3D() :FeedbackContourTool("PressMoveReleaseAndPointSetting"), m_NeedUpdate(true), m_CurrentTimeStep(0), m_LowerThreshold(0), m_UpperThreshold(200), m_StoppingValue(100), m_Sigma(1.0), m_Alpha(-0.5), m_Beta(3.0) { CONNECT_ACTION( AcADDPOINTRMB, OnAddPoint ); CONNECT_ACTION( AcADDPOINT, OnAddPoint ); CONNECT_ACTION( AcREMOVEPOINT, OnDelete ); m_ReferenceImageAsITK = InternalImageType::New(); m_ProgressCommand = mitk::ToolCommand::New(); m_ThresholdFilter = ThresholdingFilterType::New(); m_ThresholdFilter->SetLowerThreshold( m_LowerThreshold ); m_ThresholdFilter->SetUpperThreshold( m_UpperThreshold ); m_ThresholdFilter->SetOutsideValue( 0 ); m_ThresholdFilter->SetInsideValue( 1.0 ); m_SmoothFilter = SmoothingFilterType::New(); m_SmoothFilter->AddObserver( itk::ProgressEvent(), m_ProgressCommand); m_SmoothFilter->SetTimeStep( 0.05 ); m_SmoothFilter->SetNumberOfIterations( 2 ); m_SmoothFilter->SetConductanceParameter( 9.0 ); m_GradientMagnitudeFilter = GradientFilterType::New(); m_GradientMagnitudeFilter->AddObserver( itk::ProgressEvent(), m_ProgressCommand); m_GradientMagnitudeFilter->SetSigma( m_Sigma ); m_SigmoidFilter = SigmoidFilterType::New(); m_SigmoidFilter->AddObserver( itk::ProgressEvent(), m_ProgressCommand); m_SigmoidFilter->SetAlpha( m_Alpha ); m_SigmoidFilter->SetBeta( m_Beta ); m_SigmoidFilter->SetOutputMinimum( 0.0 ); m_SigmoidFilter->SetOutputMaximum( 1.0 ); m_FastMarchingFilter = FastMarchingFilterType::New(); m_FastMarchingFilter->AddObserver( itk::ProgressEvent(), m_ProgressCommand); m_FastMarchingFilter->SetStoppingValue( m_StoppingValue ); m_SeedContainer = NodeContainer::New(); m_SeedContainer->Initialize(); m_FastMarchingFilter->SetTrialPoints( m_SeedContainer ); //set up pipeline m_SmoothFilter->SetInput( m_ReferenceImageAsITK ); m_GradientMagnitudeFilter->SetInput( m_SmoothFilter->GetOutput() ); m_SigmoidFilter->SetInput( m_GradientMagnitudeFilter->GetOutput() ); m_FastMarchingFilter->SetInput( m_SigmoidFilter->GetOutput() ); m_ThresholdFilter->SetInput( m_FastMarchingFilter->GetOutput() ); } mitk::FastMarchingTool3D::~FastMarchingTool3D() { } float mitk::FastMarchingTool3D::CanHandleEvent( StateEvent const *stateEvent) const { float returnValue = Superclass::CanHandleEvent(stateEvent); //we can handle delete if(stateEvent->GetId() == 12 ) { returnValue = 1.0; } return returnValue; } const char** mitk::FastMarchingTool3D::GetXPM() const { return NULL;//mitkFastMarchingTool3D_xpm; } -std::string mitk::FastMarchingTool3D::GetIconPath() const +mitk::ModuleResource mitk::FastMarchingTool3D::GetIconResource() const { - return ":/Segmentation/FastMarching_48x48.png"; + Module* module = GetModuleContext()->GetModule(); + ModuleResource resource = module->GetResource("FastMarching_48x48.png"); + return resource; } const char* mitk::FastMarchingTool3D::GetName() const { return "FastMarching3D"; } void mitk::FastMarchingTool3D::SetUpperThreshold(double value) { m_UpperThreshold = value / 10.0; m_ThresholdFilter->SetUpperThreshold( m_UpperThreshold ); m_NeedUpdate = true; } void mitk::FastMarchingTool3D::SetLowerThreshold(double value) { m_LowerThreshold = value / 10.0; m_ThresholdFilter->SetLowerThreshold( m_LowerThreshold ); m_NeedUpdate = true; } void mitk::FastMarchingTool3D::SetBeta(double value) { if (m_Beta != value) { m_Beta = value; m_SigmoidFilter->SetBeta( m_Beta ); m_NeedUpdate = true; } } void mitk::FastMarchingTool3D::SetSigma(double value) { if (m_Sigma != value) { m_Sigma = value; m_GradientMagnitudeFilter->SetSigma( m_Sigma ); m_NeedUpdate = true; } } void mitk::FastMarchingTool3D::SetAlpha(double value) { if (m_Alpha != value) { m_Alpha = value; m_SigmoidFilter->SetAlpha( m_Alpha ); m_NeedUpdate = true; } } void mitk::FastMarchingTool3D::SetStoppingValue(double value) { if (m_StoppingValue != value) { m_StoppingValue = value; m_FastMarchingFilter->SetStoppingValue( m_StoppingValue ); m_NeedUpdate = true; } } void mitk::FastMarchingTool3D::Activated() { Superclass::Activated(); m_ResultImageNode = mitk::DataNode::New(); m_ResultImageNode->SetName("FastMarching_Preview"); m_ResultImageNode->SetBoolProperty("helper object", true); m_ResultImageNode->SetColor(0.0, 1.0, 0.0); m_ResultImageNode->SetVisibility(true); m_ToolManager->GetDataStorage()->Add( this->m_ResultImageNode, m_ToolManager->GetReferenceData(0)); m_SeedsAsPointSet = mitk::PointSet::New(); m_SeedsAsPointSetNode = mitk::DataNode::New(); m_SeedsAsPointSetNode->SetData(m_SeedsAsPointSet); m_SeedsAsPointSetNode->SetName("Seeds_Preview"); m_SeedsAsPointSetNode->SetBoolProperty("helper object", true); m_SeedsAsPointSetNode->SetColor(0.0, 1.0, 0.0); m_SeedsAsPointSetNode->SetVisibility(true); m_ToolManager->GetDataStorage()->Add( this->m_SeedsAsPointSetNode, m_ToolManager->GetReferenceData(0)); this->Initialize(); } void mitk::FastMarchingTool3D::Deactivated() { Superclass::Deactivated(); m_ToolManager->GetDataStorage()->Remove( this->m_ResultImageNode ); m_ToolManager->GetDataStorage()->Remove( this->m_SeedsAsPointSetNode ); this->ClearSeeds(); this->m_SmoothFilter->RemoveAllObservers(); this->m_SigmoidFilter->RemoveAllObservers(); this->m_GradientMagnitudeFilter->RemoveAllObservers(); this->m_FastMarchingFilter->RemoveAllObservers(); m_ResultImageNode = NULL; } void mitk::FastMarchingTool3D::Initialize() { m_ReferenceImage = dynamic_cast(m_ToolManager->GetReferenceData(0)->GetData()); if(m_ReferenceImage->GetTimeSlicedGeometry()->GetTimeSteps() > 1) { mitk::ImageTimeSelector::Pointer timeSelector = ImageTimeSelector::New(); timeSelector->SetInput( m_ReferenceImage ); timeSelector->SetTimeNr( m_CurrentTimeStep ); timeSelector->UpdateLargestPossibleRegion(); m_ReferenceImage = timeSelector->GetOutput(); } CastToItkImage(m_ReferenceImage, m_ReferenceImageAsITK); m_SmoothFilter->SetInput( m_ReferenceImageAsITK ); m_NeedUpdate = true; } void mitk::FastMarchingTool3D::ConfirmSegmentation() { // combine preview image with current working segmentation if (dynamic_cast(m_ResultImageNode->GetData())) { //logical or combination of preview and segmentation slice OutputImageType::Pointer segmentationImageInITK = OutputImageType::New(); mitk::Image::Pointer workingImage = dynamic_cast(this->m_ToolManager->GetWorkingData(0)->GetData()); if(workingImage->GetTimeSlicedGeometry()->GetTimeSteps() > 1) { mitk::ImageTimeSelector::Pointer timeSelector = mitk::ImageTimeSelector::New(); timeSelector->SetInput( workingImage ); timeSelector->SetTimeNr( m_CurrentTimeStep ); timeSelector->UpdateLargestPossibleRegion(); CastToItkImage( timeSelector->GetOutput(), segmentationImageInITK ); } else { CastToItkImage( workingImage, segmentationImageInITK ); } typedef itk::OrImageFilter OrImageFilterType; OrImageFilterType::Pointer orFilter = OrImageFilterType::New(); orFilter->SetInput(0, m_ThresholdFilter->GetOutput()); orFilter->SetInput(1, segmentationImageInITK); orFilter->Update(); //set image volume in current time step from itk image workingImage->SetVolume( (void*)(orFilter->GetOutput()->GetPixelContainer()->GetBufferPointer()), m_CurrentTimeStep); this->m_ResultImageNode->SetVisibility(false); this->ClearSeeds(); workingImage->Modified(); } mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } bool mitk::FastMarchingTool3D::OnAddPoint(Action* action, const StateEvent* stateEvent) { // Add a new seed point for FastMarching algorithm const PositionEvent* positionEvent = dynamic_cast(stateEvent->GetEvent()); if (!positionEvent) return false; mitk::Point3D clickInIndex; m_ReferenceImage->GetGeometry()->WorldToIndex(positionEvent->GetWorldPosition(), clickInIndex); itk::Index<3> seedPosition; seedPosition[0] = clickInIndex[0]; seedPosition[1] = clickInIndex[1]; seedPosition[2] = clickInIndex[2]; NodeType node; const double seedValue = 0.0; node.SetValue( seedValue ); node.SetIndex( seedPosition ); this->m_SeedContainer->InsertElement(this->m_SeedContainer->Size(), node); m_FastMarchingFilter->Modified(); m_SeedsAsPointSet->InsertPoint(m_SeedsAsPointSet->GetSize(), positionEvent->GetWorldPosition()); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); m_NeedUpdate = true; this->Update(); return true; } bool mitk::FastMarchingTool3D::OnDelete(Action* action, const StateEvent* stateEvent) { // delete last seed point if(!(this->m_SeedContainer->empty())) { //delete last element of seeds container this->m_SeedContainer->pop_back(); m_FastMarchingFilter->Modified(); //delete last point in pointset - somehow ugly m_SeedsAsPointSet->GetPointSet()->GetPoints()->DeleteIndex(m_SeedsAsPointSet->GetSize() - 1); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); m_NeedUpdate = true; this->Update(); } return true; } void mitk::FastMarchingTool3D::Update() { // update FastMarching pipeline and show result if (m_NeedUpdate) { m_ProgressCommand->AddStepsToDo(20); CurrentlyBusy.Send(true); try { m_ThresholdFilter->Update(); } catch( itk::ExceptionObject & excep ) { MITK_ERROR << "Exception caught: " << excep.GetDescription(); m_ProgressCommand->SetRemainingProgress(100); CurrentlyBusy.Send(false); std::string msg = excep.GetDescription(); ErrorMessage.Send(msg); return; } m_ProgressCommand->SetRemainingProgress(100); CurrentlyBusy.Send(false); //make output visible mitk::Image::Pointer result = mitk::Image::New(); CastToMitkImage( m_ThresholdFilter->GetOutput(), result); result->GetGeometry()->SetOrigin(m_ReferenceImage->GetGeometry()->GetOrigin() ); result->GetGeometry()->SetIndexToWorldTransform(m_ReferenceImage->GetGeometry()->GetIndexToWorldTransform() ); m_ResultImageNode->SetData(result); m_ResultImageNode->SetVisibility(true); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } } void mitk::FastMarchingTool3D::ClearSeeds() { // clear seeds for FastMarching as well as the PointSet for visualization this->m_SeedContainer->Initialize(); this->m_SeedsAsPointSet->Clear(); m_FastMarchingFilter->Modified(); this->m_NeedUpdate = true; } void mitk::FastMarchingTool3D::Reset() { //clear all seeds and preview empty result this->ClearSeeds(); m_ResultImageNode->SetVisibility(false); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } void mitk::FastMarchingTool3D::SetCurrentTimeStep(int t) { if( m_CurrentTimeStep != t ) { m_CurrentTimeStep = t; this->Initialize(); } } diff --git a/Modules/Segmentation/Interactions/mitkFastMarchingTool3D.h b/Modules/Segmentation/Interactions/mitkFastMarchingTool3D.h index 41e71fda0c..d3804ebca0 100644 --- a/Modules/Segmentation/Interactions/mitkFastMarchingTool3D.h +++ b/Modules/Segmentation/Interactions/mitkFastMarchingTool3D.h @@ -1,161 +1,163 @@ /*=================================================================== 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 mitkFastMarchingTool3D_h_Included #define mitkFastMarchingTool3D_h_Included #include "mitkFeedbackContourTool.h" #include "mitkLegacyAdaptors.h" #include "SegmentationExports.h" #include "mitkDataNode.h" #include "mitkPointSet.h" #include "mitkToolCommand.h" #include "itkImage.h" //itk filter #include "itkFastMarchingImageFilter.h" #include "itkBinaryThresholdImageFilter.h" #include "itkGradientMagnitudeRecursiveGaussianImageFilter.h" #include "itkSigmoidImageFilter.h" #include "itkCurvatureAnisotropicDiffusionImageFilter.h" +class ModuleResource; + namespace mitk { /** \brief FastMarching semgentation tool. The segmentation is done by setting one or more seed points on the image and adapting the time range and threshold. The pipeline is: Smoothing->GradientMagnitude->SigmoidFunction->FastMarching->Threshold The resulting binary image is seen as a segmentation of an object. For detailed documentation see ITK Software Guide section 9.3.1 Fast Marching Segmentation. */ class Segmentation_EXPORT FastMarchingTool3D : public FeedbackContourTool { public: mitkClassMacro(FastMarchingTool3D, FeedbackContourTool); itkNewMacro(FastMarchingTool3D); /* typedefs for itk pipeline */ typedef float InternalPixelType; typedef itk::Image< InternalPixelType, 3 > InternalImageType; typedef unsigned char OutputPixelType; typedef itk::Image< OutputPixelType, 3 > OutputImageType; typedef itk::BinaryThresholdImageFilter< InternalImageType, OutputImageType > ThresholdingFilterType; typedef itk::CurvatureAnisotropicDiffusionImageFilter< InternalImageType, InternalImageType > SmoothingFilterType; typedef itk::GradientMagnitudeRecursiveGaussianImageFilter< InternalImageType, InternalImageType > GradientFilterType; typedef itk::SigmoidImageFilter< InternalImageType, InternalImageType > SigmoidFilterType; typedef itk::FastMarchingImageFilter< InternalImageType, InternalImageType > FastMarchingFilterType; typedef FastMarchingFilterType::NodeContainer NodeContainer; typedef FastMarchingFilterType::NodeType NodeType; /* icon stuff */ virtual const char** GetXPM() const; virtual const char* GetName() const; - virtual std::string GetIconPath() const; + ModuleResource GetIconResource() const; /// \brief Set parameter used in Threshold filter. void SetUpperThreshold(double); /// \brief Set parameter used in Threshold filter. void SetLowerThreshold(double); /// \brief Set parameter used in Fast Marching filter. void SetStoppingValue(double); /// \brief Set parameter used in Gradient Magnitude filter. void SetSigma(double); /// \brief Set parameter used in Fast Marching filter. void SetAlpha(double); /// \brief Set parameter used in Fast Marching filter. void SetBeta(double); /// \brief Adds the feedback image to the current working image. virtual void ConfirmSegmentation(); /// \brief Set the working time step. virtual void SetCurrentTimeStep(int t); /// \brief Clear all seed points. void ClearSeeds(); /// \brief Updates the itk pipeline and shows the result of FastMarching. void Update(); protected: FastMarchingTool3D(); virtual ~FastMarchingTool3D(); virtual float CanHandleEvent( StateEvent const *stateEvent) const; virtual void Activated(); virtual void Deactivated(); virtual void Initialize(); /// \brief Add point action of StateMachine pattern virtual bool OnAddPoint (Action*, const StateEvent*); /// \brief Delete action of StateMachine pattern virtual bool OnDelete (Action*, const StateEvent*); /// \brief Reset all relevant inputs of the itk pipeline. void Reset(); mitk::ToolCommand::Pointer m_ProgressCommand; Image::Pointer m_ReferenceImage; bool m_NeedUpdate; int m_CurrentTimeStep; float m_LowerThreshold; //used in Threshold filter float m_UpperThreshold; //used in Threshold filter float m_StoppingValue; //used in Fast Marching filter float m_Sigma; //used in GradientMagnitude filter float m_Alpha; //used in Sigmoid filter float m_Beta; //used in Sigmoid filter NodeContainer::Pointer m_SeedContainer; //seed points for FastMarching InternalImageType::Pointer m_ReferenceImageAsITK; //the reference image as itk::Image mitk::DataNode::Pointer m_ResultImageNode;//holds the result as a preview image mitk::DataNode::Pointer m_SeedsAsPointSetNode;//used to visualize the seed points mitk::PointSet::Pointer m_SeedsAsPointSet; ThresholdingFilterType::Pointer m_ThresholdFilter; SmoothingFilterType::Pointer m_SmoothFilter; GradientFilterType::Pointer m_GradientMagnitudeFilter; SigmoidFilterType::Pointer m_SigmoidFilter; FastMarchingFilterType::Pointer m_FastMarchingFilter; }; } // namespace #endif diff --git a/Modules/Segmentation/Interactions/mitkFillRegionTool.cpp b/Modules/Segmentation/Interactions/mitkFillRegionTool.cpp index 078a367686..9aabf2c3ba 100644 --- a/Modules/Segmentation/Interactions/mitkFillRegionTool.cpp +++ b/Modules/Segmentation/Interactions/mitkFillRegionTool.cpp @@ -1,53 +1,60 @@ /*=================================================================== 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 "mitkFillRegionTool.h" #include "mitkFillRegionTool.xpm" +// us +#include "mitkModule.h" +#include "mitkModuleResource.h" +#include + namespace mitk { MITK_TOOL_MACRO(Segmentation_EXPORT, FillRegionTool, "Fill tool"); } mitk::FillRegionTool::FillRegionTool() :SetRegionTool(1) { } mitk::FillRegionTool::~FillRegionTool() { } const char** mitk::FillRegionTool::GetXPM() const { return mitkFillRegionTool_xpm; } -std::string mitk::FillRegionTool::GetIconPath() const +mitk::ModuleResource mitk::FillRegionTool::GetIconResource() const { - return ":/Segmentation/Fill_48x48.png"; + Module* module = GetModuleContext()->GetModule(); + ModuleResource resource = module->GetResource("Fill_48x48.png"); + return resource; } std::string mitk::FillRegionTool::GetCursorIconPath() const { return ":/Segmentation/Fill_Cursor_48x48.png"; } const char* mitk::FillRegionTool::GetName() const { return "Fill"; } diff --git a/Modules/Segmentation/Interactions/mitkFillRegionTool.h b/Modules/Segmentation/Interactions/mitkFillRegionTool.h index 9119c629f2..2f560a3df6 100644 --- a/Modules/Segmentation/Interactions/mitkFillRegionTool.h +++ b/Modules/Segmentation/Interactions/mitkFillRegionTool.h @@ -1,63 +1,66 @@ /*=================================================================== 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 mitkFillRegionTool_h_Included #define mitkFillRegionTool_h_Included #include "mitkSetRegionTool.h" #include "SegmentationExports.h" +class ModuleResource; + namespace mitk { /** \brief Fill the inside of a contour with 1 \sa SetRegionTool \ingroup Interaction \ingroup ToolManagerEtAl Finds the outer contour of a shape in 2D (possibly including holes) and sets all the inside pixels to 1, filling holes in a segmentation. \warning Only to be instantiated by mitk::ToolManager. $Author$ */ class Segmentation_EXPORT FillRegionTool : public SetRegionTool { public: mitkClassMacro(FillRegionTool, SetRegionTool); itkNewMacro(FillRegionTool); virtual const char** GetXPM() const; - virtual std::string GetIconPath() const; virtual std::string GetCursorIconPath() const; + ModuleResource GetIconResource() const; + virtual const char* GetName() const; protected: FillRegionTool(); // purposely hidden virtual ~FillRegionTool(); }; } // namespace #endif diff --git a/Modules/Segmentation/Interactions/mitkLiveWireTool2D.cpp b/Modules/Segmentation/Interactions/mitkLiveWireTool2D.cpp index 660b583560..af82b7a441 100644 --- a/Modules/Segmentation/Interactions/mitkLiveWireTool2D.cpp +++ b/Modules/Segmentation/Interactions/mitkLiveWireTool2D.cpp @@ -1,668 +1,661 @@ /*=================================================================== 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 "mitkLiveWireTool2D.h" #include "mitkToolManager.h" #include "mitkBaseRenderer.h" #include "mitkRenderingManager.h" #include "mitkLiveWireTool2D.xpm" #include #include #include #include "mitkContourUtils.h" #include "mitkContour.h" #include +// us +#include "mitkModule.h" +#include "mitkModuleResource.h" +#include namespace mitk { MITK_TOOL_MACRO(Segmentation_EXPORT, LiveWireTool2D, "LiveWire tool"); } mitk::LiveWireTool2D::LiveWireTool2D() :SegTool2D("LiveWireTool") { m_Contour = mitk::ContourModel::New(); m_ContourModelNode = mitk::DataNode::New(); m_ContourModelNode->SetData( m_Contour ); m_ContourModelNode->SetProperty("name", StringProperty::New("working contour node")); m_ContourModelNode->SetProperty("visible", BoolProperty::New(true)); m_ContourModelNode->AddProperty( "contour.color", ColorProperty::New(0.9, 1.0, 0.1), NULL, true ); m_ContourModelNode->AddProperty( "selectedcolor", ColorProperty::New(1.0, 0.0, 0.1), NULL, true ); m_LiveWireContour = mitk::ContourModel::New(); m_LiveWireContourNode = mitk::DataNode::New(); //m_LiveWireContourNode->SetData( m_LiveWireContour ); m_LiveWireContourNode->SetProperty("name", StringProperty::New("active livewire node")); m_LiveWireContourNode->SetProperty("visible", BoolProperty::New(true)); m_LiveWireContourNode->AddProperty( "contour.color", ColorProperty::New(0.1, 1.0, 0.1), NULL, true ); m_LiveWireContourNode->AddProperty( "selectedcolor", ColorProperty::New(0.5, 0.5, 0.1), NULL, true ); m_LiveWireFilter = mitk::ImageLiveWireContourModelFilter::New(); // great magic numbers CONNECT_ACTION( AcINITNEWOBJECT, OnInitLiveWire ); CONNECT_ACTION( AcADDPOINT, OnAddPoint ); CONNECT_ACTION( AcMOVE, OnMouseMoveNoDynamicCosts ); CONNECT_ACTION( AcCHECKPOINT, OnCheckPoint ); CONNECT_ACTION( AcFINISH, OnFinish ); CONNECT_ACTION( AcDELETEPOINT, OnLastSegmentDelete ); CONNECT_ACTION( AcADDLINE, OnMouseMoved ); } mitk::LiveWireTool2D::~LiveWireTool2D() { m_Contours.clear(); } float mitk::LiveWireTool2D::CanHandleEvent( StateEvent const *stateEvent) const { mitk::PositionEvent const *positionEvent = dynamic_cast (stateEvent->GetEvent()); //Key event handling: if (positionEvent == NULL) { //check for delete and escape event if(stateEvent->GetId() == 12 || stateEvent->GetId() == 14) { return 1.0; } //check, if the current state has a transition waiting for that key event. else if (this->GetCurrentState()->GetTransition(stateEvent->GetId())!=NULL) { return 0.5; } else { return 0.0; } } else { if ( positionEvent->GetSender()->GetMapperID() != BaseRenderer::Standard2D ) return 0.0; // we don't want anything but 2D return 1.0; } } - - - const char** mitk::LiveWireTool2D::GetXPM() const { return mitkLiveWireTool2D_xpm; } - - - -std::string mitk::LiveWireTool2D::GetIconPath() const +mitk::ModuleResource mitk::LiveWireTool2D::GetIconResource() const { - return ":/Segmentation/LiveWire_48x48.png"; + Module* module = GetModuleContext()->GetModule(); + ModuleResource resource = module->GetResource("LiveWire_48x48.png"); + return resource; } std::string mitk::LiveWireTool2D::GetCursorIconPath() const { return ":/Segmentation/LiveWire_Cursor_48x48.png"; } - const char* mitk::LiveWireTool2D::GetName() const { return "Live Wire"; } - - - void mitk::LiveWireTool2D::Activated() { Superclass::Activated(); } - - - void mitk::LiveWireTool2D::Deactivated() { this->FinishTool(); Superclass::Deactivated(); } void mitk::LiveWireTool2D::ConfirmSegmentation() { DataNode* workingNode( m_ToolManager->GetWorkingData(0) ); if ( !workingNode ) return; Image* workingImage = dynamic_cast(workingNode->GetData()); if ( !workingImage ) return; ContourUtils::Pointer contourUtils = mitk::ContourUtils::New(); /*+++++++++++++++++++++++ for all contours in list (currently created by tool) ++++++++++++++++++++++++++++++++++++*/ std::vector< std::pair >::iterator it = m_Contours.begin(); while(it != m_Contours.end() ) { //++++++++++if node contains data if( it->first->GetData() ) { //+++++++++++++++if this is a contourModel mitk::ContourModel* contourModel = dynamic_cast(it->first->GetData()); if( contourModel ) { //++++++++++++++++++++++ for each timestep of this contourModel for( int currentTimestep = 0; currentTimestep < contourModel->GetTimeSlicedGeometry()->GetTimeSteps(); currentTimestep++) { //get the segmentation image slice at current timestep mitk::Image::Pointer workingSlice = this->GetAffectedImageSliceAs2DImage(it->second, workingImage, currentTimestep); /*++++++++++++++++++++++ transfer to plain old contour to use contour util functionality +++++++++++++++++++++++*/ mitk::Contour::Pointer plainOldContour = mitk::Contour::New(); mitk::ContourModel::VertexIterator iter = contourModel->IteratorBegin(currentTimestep); while(iter != contourModel->IteratorEnd(currentTimestep) ) { plainOldContour->AddVertex( (*iter)->Coordinates ); iter++; } /*-------------------------------------------------------------------------------*/ mitk::Contour::Pointer projectedContour = contourUtils->ProjectContourTo2DSlice(workingSlice, plainOldContour, true, false); contourUtils->FillContourInSlice(projectedContour, workingSlice, 1.0); //write back to image volume this->WriteBackSegmentationResult(it->second, workingSlice, currentTimestep); } //remove contour node from datastorage m_ToolManager->GetDataStorage()->Remove( it->first ); } } ++it; } m_Contours.clear(); } bool mitk::LiveWireTool2D::OnInitLiveWire (Action* action, const StateEvent* stateEvent) { const PositionEvent* positionEvent = dynamic_cast(stateEvent->GetEvent()); if (!positionEvent) return false; m_LastEventSender = positionEvent->GetSender(); m_LastEventSlice = m_LastEventSender->GetSlice(); if ( Superclass::CanHandleEvent(stateEvent) < 1.0 ) return false; int timestep = positionEvent->GetSender()->GetTimeStep(); m_Contour->Expand(timestep+1); m_ToolManager->GetDataStorage()->Add( m_ContourModelNode ); m_ToolManager->GetDataStorage()->Add( m_LiveWireContourNode ); //set current slice as input for ImageToLiveWireContourFilter m_WorkingSlice = this->GetAffectedReferenceSlice(positionEvent); m_LiveWireFilter->SetInput(m_WorkingSlice); //map click to pixel coordinates mitk::Point3D click = const_cast(positionEvent->GetWorldPosition()); itk::Index<3> idx; m_WorkingSlice->GetGeometry()->WorldToIndex(click, idx); /*+++++++++++++++++++++++ get the pixel the gradient in region of 5x5 ++++++++++++++++++++++++++*/ itk::Index<3> indexWithHighestGradient; AccessFixedDimensionByItk_2(m_WorkingSlice, FindHighestGradientMagnitudeByITK, 2, idx, indexWithHighestGradient); /*----------------------------------------------------------------------------------------------------------------*/ //itk::Index to mitk::Point3D click[0] = indexWithHighestGradient[0]; click[1] = indexWithHighestGradient[1]; click[2] = indexWithHighestGradient[2]; m_WorkingSlice->GetGeometry()->IndexToWorld(click, click); //set initial start point m_Contour->AddVertex( click, true, timestep ); m_LiveWireFilter->SetStartPoint(click); m_CreateAndUseDynamicCosts = true; //render assert( positionEvent->GetSender()->GetRenderWindow() ); mitk::RenderingManager::GetInstance()->RequestUpdate( positionEvent->GetSender()->GetRenderWindow() ); return true; } bool mitk::LiveWireTool2D::OnAddPoint (Action* action, const StateEvent* stateEvent) { //complete LiveWire interaction for last segment //add current LiveWire contour to the finished contour and reset //to start new segment and computation /* check if event can be handled */ const PositionEvent* positionEvent = dynamic_cast(stateEvent->GetEvent()); if (!positionEvent) return false; if ( Superclass::CanHandleEvent(stateEvent) < 1.0 ) return false; /* END check if event can be handled */ int timestep = positionEvent->GetSender()->GetTimeStep(); //remove duplicate first vertex, it's already contained in m_Contour m_LiveWireContour->RemoveVertexAt(0, timestep); /* TODO fix this hack*/ //set last to active added point if( m_LiveWireContour->GetNumberOfVertices(timestep) > 0) { const_cast( m_LiveWireContour->GetVertexAt(m_LiveWireContour->GetNumberOfVertices(timestep)-1, timestep) )->IsControlPoint = true; } //merge contours m_Contour->Concatenate(m_LiveWireContour, timestep); //clear the livewire contour and reset the corresponding datanode m_LiveWireContour->Clear(timestep); //set new start point m_LiveWireFilter->SetStartPoint(const_cast(positionEvent->GetWorldPosition())); if( m_CreateAndUseDynamicCosts ) { //use dynamic cost map for next update m_LiveWireFilter->CreateDynamicCostMap(m_Contour); m_LiveWireFilter->SetUseDynamicCostMap(true); //m_CreateAndUseDynamicCosts = false; } //render assert( positionEvent->GetSender()->GetRenderWindow() ); mitk::RenderingManager::GetInstance()->RequestUpdate( positionEvent->GetSender()->GetRenderWindow() ); return true; } bool mitk::LiveWireTool2D::OnMouseMoved( Action* action, const StateEvent* stateEvent) { //compute LiveWire segment from last control point to current mouse position /* check if event can be handled */ if ( Superclass::CanHandleEvent(stateEvent) < 1.0 ) return false; const PositionEvent* positionEvent = dynamic_cast(stateEvent->GetEvent()); if (!positionEvent) return false; /* END check if event can be handled */ /* actual LiveWire computation */ int timestep = positionEvent->GetSender()->GetTimeStep(); m_LiveWireFilter->SetEndPoint(const_cast(positionEvent->GetWorldPosition())); m_LiveWireFilter->SetTimestep(timestep); m_LiveWireFilter->Update(); //ContourModel::VertexType* currentVertex = const_cast(m_LiveWireContour->GetVertexAt(0)); this->m_LiveWireContour = this->m_LiveWireFilter->GetOutput(); this->m_LiveWireContourNode->SetData(this->m_LiveWireFilter->GetOutput()); /* END actual LiveWire computation */ //render assert( positionEvent->GetSender()->GetRenderWindow() ); mitk::RenderingManager::GetInstance()->RequestUpdate( positionEvent->GetSender()->GetRenderWindow() ); return true; } bool mitk::LiveWireTool2D::OnMouseMoveNoDynamicCosts(Action* action, const StateEvent* stateEvent) { //do not use dynamic cost map m_LiveWireFilter->SetUseDynamicCostMap(false); OnMouseMoved(action, stateEvent); m_LiveWireFilter->SetUseDynamicCostMap(true); return true; } bool mitk::LiveWireTool2D::OnCheckPoint( Action* action, const StateEvent* stateEvent) { //check double click on first control point to finish the LiveWire tool // //Check distance to first point. //Transition YES if click close to first control point // mitk::StateEvent* newStateEvent = NULL; const PositionEvent* positionEvent = dynamic_cast(stateEvent->GetEvent()); if (!positionEvent) { //stay in current state newStateEvent = new mitk::StateEvent(EIDNO, stateEvent->GetEvent()); } else { int timestep = positionEvent->GetSender()->GetTimeStep(); mitk::Point3D click = positionEvent->GetWorldPosition(); mitk::Point3D first = this->m_Contour->GetVertexAt(0, timestep)->Coordinates; if (first.EuclideanDistanceTo(click) < 1.5) { //finish newStateEvent = new mitk::StateEvent(EIDYES, stateEvent->GetEvent()); }else { //stay active newStateEvent = new mitk::StateEvent(EIDNO, stateEvent->GetEvent()); } } this->HandleEvent( newStateEvent ); return true; } bool mitk::LiveWireTool2D::OnFinish( Action* action, const StateEvent* stateEvent) { // finish livewire tool interaction /* check if event can be handled */ if ( Superclass::CanHandleEvent(stateEvent) < 1.0 ) return false; const PositionEvent* positionEvent = dynamic_cast(stateEvent->GetEvent()); if (!positionEvent) return false; /* END check if event can be handled */ //actual timestep int timestep = positionEvent->GetSender()->GetTimeStep(); //remove last control point being added by double click m_Contour->RemoveVertexAt(m_Contour->GetNumberOfVertices(timestep) - 1, timestep); //save contour and corresponding plane geometry to list std::pair contourPair(m_ContourModelNode.GetPointer(), dynamic_cast(positionEvent->GetSender()->GetCurrentWorldGeometry2D()->Clone().GetPointer()) ); m_Contours.push_back(contourPair); m_LiveWireFilter->SetUseDynamicCostMap(false); this->FinishTool(); return true; } void mitk::LiveWireTool2D::FinishTool() { unsigned int numberOfTimesteps = m_Contour->GetTimeSlicedGeometry()->GetTimeSteps(); //close contour in each timestep for( int i = 0; i <= numberOfTimesteps; i++) { m_Contour->Close(i); } //clear LiveWire node m_ToolManager->GetDataStorage()->Remove( m_LiveWireContourNode ); m_LiveWireContourNode = NULL; m_LiveWireContour = NULL; //TODO visual feedback for completing livewire tool m_ContourModelNode->AddProperty( "contour.color", ColorProperty::New(1.0, 1.0, 0.1), NULL, true ); m_ContourModelNode->SetProperty("name", StringProperty::New("contour node")); //set the livewire interactor to edit control points mitk::ContourModelLiveWireInteractor::Pointer interactor = mitk::ContourModelLiveWireInteractor::New(m_ContourModelNode); interactor->SetWorkingImage(this->m_WorkingSlice); m_ContourModelNode->SetInteractor(interactor); //add interactor to globalInteraction instance mitk::GlobalInteraction::GetInstance()->AddInteractor(interactor); /* END complete livewire tool interaction */ /* reset contours and datanodes */ m_Contour = mitk::ContourModel::New(); m_ContourModelNode = mitk::DataNode::New(); m_ContourModelNode->SetData( m_Contour ); m_ContourModelNode->SetProperty("name", StringProperty::New("working contour node")); m_ContourModelNode->SetProperty("visible", BoolProperty::New(true)); m_ContourModelNode->AddProperty( "contour.color", ColorProperty::New(0.9, 1.0, 0.1), NULL, true ); m_ContourModelNode->AddProperty( "points.color", ColorProperty::New(1.0, 0.0, 0.1), NULL, true ); m_LiveWireContour = mitk::ContourModel::New(); m_LiveWireContourNode = mitk::DataNode::New(); //m_LiveWireContourNode->SetData( m_LiveWireContour ); m_LiveWireContourNode->SetProperty("name", StringProperty::New("active livewire node")); m_LiveWireContourNode->SetProperty("visible", BoolProperty::New(true)); m_LiveWireContourNode->AddProperty( "contour.color", ColorProperty::New(0.1, 1.0, 0.1), NULL, true ); m_LiveWireContourNode->AddProperty( "points.color", ColorProperty::New(0.5, 0.5, 0.1), NULL, true ); /* END reset contours and datanodes */ } bool mitk::LiveWireTool2D::OnLastSegmentDelete( Action* action, const StateEvent* stateEvent) { int timestep = stateEvent->GetEvent()->GetSender()->GetTimeStep(); //if last point of current contour will be removed go to start state and remove nodes if( m_Contour->GetNumberOfVertices(timestep) <= 1 ) { m_ToolManager->GetDataStorage()->Remove( m_LiveWireContourNode ); m_ToolManager->GetDataStorage()->Remove( m_ContourModelNode ); m_LiveWireContour = mitk::ContourModel::New(); m_Contour = mitk::ContourModel::New(); m_ContourModelNode->SetData( m_Contour ); m_LiveWireContourNode->SetData( m_LiveWireContour ); Superclass::Deactivated(); //go to start state } else //remove last segment from contour and reset livewire contour { m_LiveWireContour = mitk::ContourModel::New(); m_LiveWireContourNode->SetData(m_LiveWireContour); mitk::ContourModel::Pointer newContour = mitk::ContourModel::New(); newContour->Expand(m_Contour->GetTimeSteps()); mitk::ContourModel::VertexIterator begin = m_Contour->IteratorBegin(); //iterate from last point to next active point mitk::ContourModel::VertexIterator newLast = m_Contour->IteratorBegin() + (m_Contour->GetNumberOfVertices() - 1); //go at least one down if(newLast != begin) { newLast--; } //search next active control point while(newLast != begin && !((*newLast)->IsControlPoint) ) { newLast--; } //set position of start point for livewire filter to coordinates of the new last point m_LiveWireFilter->SetStartPoint((*newLast)->Coordinates); mitk::ContourModel::VertexIterator it = m_Contour->IteratorBegin(); //fill new Contour while(it <= newLast) { newContour->AddVertex((*it)->Coordinates, (*it)->IsControlPoint, timestep); it++; } newContour->SetIsClosed(m_Contour->IsClosed()); //set new contour visible m_ContourModelNode->SetData(newContour); m_Contour = newContour; assert( stateEvent->GetEvent()->GetSender()->GetRenderWindow() ); mitk::RenderingManager::GetInstance()->RequestUpdate( stateEvent->GetEvent()->GetSender()->GetRenderWindow() ); } return true; } template void mitk::LiveWireTool2D::FindHighestGradientMagnitudeByITK(itk::Image* inputImage, itk::Index<3> &index, itk::Index<3> &returnIndex) { typedef itk::Image InputImageType; typedef typename InputImageType::IndexType IndexType; unsigned long xMAX = inputImage->GetLargestPossibleRegion().GetSize()[0]; unsigned long yMAX = inputImage->GetLargestPossibleRegion().GetSize()[1]; returnIndex[0] = index[0]; returnIndex[1] = index[1]; returnIndex[2] = 0.0; double gradientMagnitude = 0.0; double maxGradientMagnitude = 0.0; /* the size and thus the region of 7x7 is only used to calculate the gradient magnitude in that region not for searching the maximum value */ //maximum value in each direction for size typename InputImageType::SizeType size; size[0] = 7; size[1] = 7; //minimum value in each direction for startRegion IndexType startRegion; startRegion[0] = index[0] - 3; startRegion[1] = index[1] - 3; if(startRegion[0] < 0) startRegion[0] = 0; if(startRegion[1] < 0) startRegion[1] = 0; if(xMAX - index[0] < 7) startRegion[0] = xMAX - 7; if(yMAX - index[1] < 7) startRegion[1] = yMAX - 7; index[0] = startRegion[0] + 3; index[1] = startRegion[1] + 3; typename InputImageType::RegionType region; region.SetSize( size ); region.SetIndex( startRegion ); typedef typename itk::GradientMagnitudeImageFilter< InputImageType, InputImageType> GradientMagnitudeFilterType; typename GradientMagnitudeFilterType::Pointer gradientFilter = GradientMagnitudeFilterType::New(); gradientFilter->SetInput(inputImage); gradientFilter->GetOutput()->SetRequestedRegion(region); gradientFilter->Update(); typename InputImageType::Pointer gradientMagnImage; gradientMagnImage = gradientFilter->GetOutput(); IndexType currentIndex; currentIndex[0] = 0; currentIndex[1] = 0; // search max (approximate) gradient magnitude for( int x = -1; x <= 1; ++x) { currentIndex[0] = index[0] + x; for( int y = -1; y <= 1; ++y) { currentIndex[1] = index[1] + y; gradientMagnitude = gradientMagnImage->GetPixel(currentIndex); //check for new max if(maxGradientMagnitude < gradientMagnitude) { maxGradientMagnitude = gradientMagnitude; returnIndex[0] = currentIndex[0]; returnIndex[1] = currentIndex[1]; returnIndex[2] = 0.0; }//end if }//end for y currentIndex[1] = index[1]; }//end for x } diff --git a/Modules/Segmentation/Interactions/mitkLiveWireTool2D.h b/Modules/Segmentation/Interactions/mitkLiveWireTool2D.h index 433dbbbd2a..a2109b1fd9 100644 --- a/Modules/Segmentation/Interactions/mitkLiveWireTool2D.h +++ b/Modules/Segmentation/Interactions/mitkLiveWireTool2D.h @@ -1,126 +1,129 @@ /*=================================================================== 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 mitkCorrectorTool2D_h_Included #define mitkCorrectorTool2D_h_Included #include "mitkCommon.h" #include "SegmentationExports.h" #include "mitkSegTool2D.h" #include #include #include +class ModuleResource; + namespace mitk { /** \brief A 2D segmentation tool based on LiveWire approach. The contour between the last user added point and the current mouse position is computed by searching the shortest path according to specific features of the image. The contour thus snappest to the boundary of objects. \sa SegTool2D \sa ImageLiveWireContourModelFilter \ingroup Interaction \ingroup ToolManagerEtAl \warning Only to be instantiated by mitk::ToolManager. */ class Segmentation_EXPORT LiveWireTool2D : public SegTool2D { public: mitkClassMacro(LiveWireTool2D, SegTool2D); itkNewMacro(LiveWireTool2D); virtual const char** GetXPM() const; - virtual std::string GetIconPath() const; virtual std::string GetCursorIconPath() const; + ModuleResource GetIconResource() const; + virtual const char* GetName() const; /// \brief Convert all current contour objects to binary segmentation image. void ConfirmSegmentation(); protected: LiveWireTool2D(); virtual ~LiveWireTool2D(); /** * \brief Calculates how good the data, this statemachine handles, is hit by the event. * */ virtual float CanHandleEvent( StateEvent const *stateEvent) const; virtual void Activated(); virtual void Deactivated(); /// \brief Initialize tool virtual bool OnInitLiveWire (Action*, const StateEvent*); /// \brief Add a control point and finish current segment virtual bool OnAddPoint (Action*, const StateEvent*); /// \breif Actual LiveWire computation virtual bool OnMouseMoved(Action*, const StateEvent*); /// \brief Check double click on first control point to finish the LiveWire tool virtual bool OnCheckPoint(Action*, const StateEvent*); /// \brief Finish LiveWire tool virtual bool OnFinish(Action*, const StateEvent*); /// \brief Close the contour virtual bool OnLastSegmentDelete(Action*, const StateEvent*); /// \brief Don't use dynamic cost map for LiveWire calculation virtual bool OnMouseMoveNoDynamicCosts(Action*, const StateEvent*); /// \brief Finish contour interaction. void FinishTool(); //the contour already set by the user mitk::ContourModel::Pointer m_Contour; //the corresponding datanode mitk::DataNode::Pointer m_ContourModelNode; //the current LiveWire computed contour mitk::ContourModel::Pointer m_LiveWireContour; //the corresponding datanode mitk::DataNode::Pointer m_LiveWireContourNode; //the current reference image mitk::Image::Pointer m_WorkingSlice; mitk::ImageLiveWireContourModelFilter::Pointer m_LiveWireFilter; bool m_CreateAndUseDynamicCosts; std::vector< std::pair > m_Contours; template void FindHighestGradientMagnitudeByITK(itk::Image* inputImage, itk::Index<3> &index, itk::Index<3> &returnIndex); }; } // namespace #endif diff --git a/Modules/Segmentation/Interactions/mitkOtsuTool3D.cpp b/Modules/Segmentation/Interactions/mitkOtsuTool3D.cpp index f205c191fb..20d863b4d6 100644 --- a/Modules/Segmentation/Interactions/mitkOtsuTool3D.cpp +++ b/Modules/Segmentation/Interactions/mitkOtsuTool3D.cpp @@ -1,216 +1,210 @@ /*=================================================================== 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. ===================================================================*/ // MITK #include "mitkOtsuTool3D.h" #include "mitkToolManager.h" #include "mitkRenderingManager.h" #include #include #include #include #include #include "mitkOtsuSegmentationFilter.h" // ITK #include #include -// Qt -#include - #include "mitkRegionGrow3DTool.xpm" +// us +#include "mitkModule.h" +#include "mitkModuleResource.h" +#include +#include + namespace mitk { MITK_TOOL_MACRO(Segmentation_EXPORT, OtsuTool3D, "Otsu Segmentation"); } mitk::OtsuTool3D::OtsuTool3D() { } mitk::OtsuTool3D::~OtsuTool3D() { } void mitk::OtsuTool3D::Activated() { if (m_ToolManager) { m_OriginalImage = dynamic_cast(m_ToolManager->GetReferenceData(0)->GetData()); m_BinaryPreviewNode = mitk::DataNode::New(); m_BinaryPreviewNode->SetName("Binary_Preview"); //m_BinaryPreviewNode->SetBoolProperty("helper object", true); //m_BinaryPreviewNode->SetProperty("binary", mitk::BoolProperty::New(true)); m_ToolManager->GetDataStorage()->Add( this->m_BinaryPreviewNode ); m_MultiLabelResultNode = mitk::DataNode::New(); m_MultiLabelResultNode->SetName("Otsu_Preview"); //m_MultiLabelResultNode->SetBoolProperty("helper object", true); m_MultiLabelResultNode->SetVisibility(true); m_MaskedImagePreviewNode = mitk::DataNode::New(); m_MaskedImagePreviewNode->SetName("Volume_Preview"); //m_MultiLabelResultNode->SetBoolProperty("helper object", true); m_MaskedImagePreviewNode->SetVisibility(false); m_ToolManager->GetDataStorage()->Add( this->m_MultiLabelResultNode ); } } void mitk::OtsuTool3D::Deactivated() { m_ToolManager->GetDataStorage()->Remove( this->m_MultiLabelResultNode ); m_MultiLabelResultNode = NULL; m_ToolManager->GetDataStorage()->Remove( this->m_BinaryPreviewNode ); m_BinaryPreviewNode = NULL; m_ToolManager->ActivateTool(-1); } const char** mitk::OtsuTool3D::GetXPM() const { return NULL; } -std::string mitk::OtsuTool3D::GetIconPath() const +mitk::ModuleResource mitk::OtsuTool3D::GetIconResource() const { - return ":/Segmentation/Otsu_48x48.png"; + Module* module = GetModuleContext()->GetModule(); + ModuleResource resource = module->GetResource("Otsu_48x48.png"); + return resource; } void mitk::OtsuTool3D::RunSegmentation(int regions) { //this->m_OtsuSegmentationDialog->setCursor(Qt::WaitCursor); int numberOfThresholds = regions - 1; - int proceed; - - QMessageBox* messageBox = new QMessageBox(QMessageBox::Question, NULL, "The otsu segmentation computation may take several minutes depending on the number of Regions you selected. Proceed anyway?", QMessageBox::Ok | QMessageBox::Cancel); - if (numberOfThresholds >= 5) - { - proceed = messageBox->exec(); - if (proceed != QMessageBox::Ok) return; - } mitk::OtsuSegmentationFilter::Pointer otsuFilter = mitk::OtsuSegmentationFilter::New(); otsuFilter->SetNumberOfThresholds( numberOfThresholds ); otsuFilter->SetInput( m_OriginalImage ); try { otsuFilter->Update(); } catch( ... ) { - QMessageBox* messageBox = new QMessageBox(QMessageBox::Critical, NULL, "itkOtsuFilter error: image dimension must be in {2, 3} and no RGB images can be handled."); - messageBox->exec(); - delete messageBox; mitkThrow() << "itkOtsuFilter error (image dimension must be in {2, 3} and image must not be RGB)"; } m_ToolManager->GetDataStorage()->Remove( this->m_MultiLabelResultNode ); m_MultiLabelResultNode = NULL; m_MultiLabelResultNode = mitk::DataNode::New(); m_MultiLabelResultNode->SetName("Otsu_Preview"); m_MultiLabelResultNode->SetVisibility(true); m_ToolManager->GetDataStorage()->Add( this->m_MultiLabelResultNode ); m_MultiLabelResultNode->SetOpacity(1.0); this->m_MultiLabelResultNode->SetData( otsuFilter->GetOutput() ); m_MultiLabelResultNode->SetProperty("binary", mitk::BoolProperty::New(false)); mitk::RenderingModeProperty::Pointer renderingMode = mitk::RenderingModeProperty::New(); renderingMode->SetValue( mitk::RenderingModeProperty::LOOKUPTABLE_LEVELWINDOW_COLOR ); m_MultiLabelResultNode->SetProperty("Image Rendering.Mode", renderingMode); mitk::LookupTable::Pointer lut = mitk::LookupTable::New(); mitk::LookupTableProperty::Pointer prop = mitk::LookupTableProperty::New(lut); vtkLookupTable *lookupTable = vtkLookupTable::New(); lookupTable->SetHueRange(1.0, 0.0); lookupTable->SetSaturationRange(1.0, 1.0); lookupTable->SetValueRange(1.0, 1.0); lookupTable->SetTableRange(-1.0, 1.0); lookupTable->Build(); lut->SetVtkLookupTable(lookupTable); prop->SetLookupTable(lut); m_MultiLabelResultNode->SetProperty("LookupTable",prop); mitk::LevelWindowProperty::Pointer levWinProp = mitk::LevelWindowProperty::New(); mitk::LevelWindow levelwindow; levelwindow.SetRangeMinMax(0, numberOfThresholds + 1); levWinProp->SetLevelWindow( levelwindow ); m_MultiLabelResultNode->SetProperty( "levelwindow", levWinProp ); //m_BinaryPreviewNode->SetVisibility(false); // m_MultiLabelResultNode->SetVisibility(true); //this->m_OtsuSegmentationDialog->setCursor(Qt::ArrowCursor); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } void mitk::OtsuTool3D::ConfirmSegmentation() { this->m_ToolManager->GetWorkingData(0)->SetData(dynamic_cast(m_BinaryPreviewNode->GetData())); } void mitk::OtsuTool3D::UpdateBinaryPreview(int regionID) { m_MultiLabelResultNode->SetVisibility(false); //pixel with regionID -> binary image const unsigned short dim = 3; typedef unsigned char PixelType; typedef itk::Image< PixelType, dim > InputImageType; typedef itk::Image< PixelType, dim > OutputImageType; typedef itk::BinaryThresholdImageFilter< InputImageType, OutputImageType > FilterType; FilterType::Pointer filter = FilterType::New(); InputImageType::Pointer itkImage; mitk::Image::Pointer multiLabelSegmentation = dynamic_cast(m_MultiLabelResultNode->GetData()); mitk::CastToItkImage(multiLabelSegmentation, itkImage); filter->SetInput(itkImage); filter->SetLowerThreshold(regionID); filter->SetUpperThreshold(regionID); filter->Update(); mitk::Image::Pointer binarySegmentation; mitk::CastToMitkImage( filter->GetOutput(), binarySegmentation); m_BinaryPreviewNode->SetData(binarySegmentation); m_BinaryPreviewNode->SetVisibility(true); m_BinaryPreviewNode->SetProperty("outline binary", mitk::BoolProperty::New(false)); m_BinaryPreviewNode->SetOpacity(1.0); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } const char* mitk::OtsuTool3D::GetName() const { return "Otsu"; } void mitk::OtsuTool3D::UpdateVolumePreview(bool volumeRendering) { if (volumeRendering) { m_MaskedImagePreviewNode->SetBoolProperty("volumerendering", true); m_MaskedImagePreviewNode->SetBoolProperty("volumerendering.uselod", true); } else { m_MaskedImagePreviewNode->SetBoolProperty("volumerendering", false); } mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } diff --git a/Modules/Segmentation/Interactions/mitkOtsuTool3D.h b/Modules/Segmentation/Interactions/mitkOtsuTool3D.h index 92fee16b7c..4c0d5a9f04 100644 --- a/Modules/Segmentation/Interactions/mitkOtsuTool3D.h +++ b/Modules/Segmentation/Interactions/mitkOtsuTool3D.h @@ -1,56 +1,58 @@ /*=================================================================== 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 MITKOTSUTOOL3D_H #define MITKOTSUTOOL3D_H #include "SegmentationExports.h" #include "mitkAutoSegmentationTool.h" +class ModuleResource; + namespace mitk{ class Segmentation_EXPORT OtsuTool3D : public AutoSegmentationTool { public: mitkClassMacro(OtsuTool3D, AutoSegmentationTool); itkNewMacro(OtsuTool3D); virtual const char* GetName() const; virtual const char** GetXPM() const; - virtual std::string GetIconPath() const; + ModuleResource GetIconResource() const; virtual void Activated(); virtual void Deactivated(); void RunSegmentation( int regions); void ConfirmSegmentation(); void UpdateBinaryPreview(int regionID); void UpdateVolumePreview(bool volumeRendering); protected: OtsuTool3D(); virtual ~OtsuTool3D(); mitk::Image::Pointer m_OriginalImage; //holds the user selected binary segmentation mitk::DataNode::Pointer m_BinaryPreviewNode; //holds the multilabel result as a preview image mitk::DataNode::Pointer m_MultiLabelResultNode; //holds the user selected binary segmentation masked original image mitk::DataNode::Pointer m_MaskedImagePreviewNode; };//class }//namespace #endif diff --git a/Modules/Segmentation/Interactions/mitkRegionGrowingTool.cpp b/Modules/Segmentation/Interactions/mitkRegionGrowingTool.cpp index 795d6e0cd6..4a21e703c9 100644 --- a/Modules/Segmentation/Interactions/mitkRegionGrowingTool.cpp +++ b/Modules/Segmentation/Interactions/mitkRegionGrowingTool.cpp @@ -1,680 +1,687 @@ /*=================================================================== 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 "mitkRegionGrowingTool.h" #include "mitkToolManager.h" #include "mitkOverwriteSliceImageFilter.h" #include "mitkImageDataItem.h" #include "mitkBaseRenderer.h" #include "mitkRenderingManager.h" #include "mitkApplicationCursor.h" #include "ipSegmentation.h" #include "mitkRegionGrowingTool.xpm" #include "mitkOverwriteDirectedPlaneImageFilter.h" #include "mitkExtractDirectedPlaneImageFilterNew.h" +// us +#include "mitkModule.h" +#include "mitkModuleResource.h" +#include + namespace mitk { MITK_TOOL_MACRO(Segmentation_EXPORT, RegionGrowingTool, "Region growing tool"); } #define ROUND(a) ((a)>0 ? (int)((a)+0.5) : -(int)(0.5-(a))) mitk::RegionGrowingTool::RegionGrowingTool() :FeedbackContourTool("PressMoveRelease"), m_LowerThreshold(200), m_UpperThreshold(200), m_InitialLowerThreshold(200), m_InitialUpperThreshold(200), m_ScreenYDifference(0), m_OriginalPicSlice(NULL), m_SeedPointMemoryOffset(0), m_VisibleWindow(0), m_DefaultWindow(0), m_MouseDistanceScaleFactor(0.5), m_LastWorkingSeed(-1), m_FillFeedbackContour(true) { // great magic numbers CONNECT_ACTION( 80, OnMousePressed ); CONNECT_ACTION( 90, OnMouseMoved ); CONNECT_ACTION( 42, OnMouseReleased ); } mitk::RegionGrowingTool::~RegionGrowingTool() { } const char** mitk::RegionGrowingTool::GetXPM() const { return mitkRegionGrowingTool_xpm; } -std::string mitk::RegionGrowingTool::GetIconPath() const +mitk::ModuleResource mitk::RegionGrowingTool::GetIconResource() const { - return ":/Segmentation/RegionGrowing_48x48.png"; + Module* module = GetModuleContext()->GetModule(); + ModuleResource resource = module->GetResource("RegionGrowing_48x48.png"); + return resource; } std::string mitk::RegionGrowingTool::GetCursorIconPath() const { return ":/Segmentation/RegionGrowing_Cursor_48x48.png"; } const char* mitk::RegionGrowingTool::GetName() const { return "Region Growing"; } void mitk::RegionGrowingTool::Activated() { Superclass::Activated(); } void mitk::RegionGrowingTool::Deactivated() { Superclass::Deactivated(); } /** 1 Determine which slice is clicked into 2 Determine if the user clicked inside or outside of the segmentation 3 Depending on the pixel value under the mouse click position, two different things happen: (separated out into OnMousePressedInside and OnMousePressedOutside) 3.1 Create a skeletonization of the segmentation and try to find a nice cut 3.1.1 Call a ipSegmentation algorithm to create a nice cut 3.1.2 Set the result of this algorithm as the feedback contour 3.2 Initialize region growing 3.2.1 Determine memory offset inside the original image 3.2.2 Determine initial region growing parameters from the level window settings of the image 3.2.3 Perform a region growing (which generates a new feedback contour) */ bool mitk::RegionGrowingTool::OnMousePressed (Action* action, const StateEvent* stateEvent) { const PositionEvent* positionEvent = dynamic_cast(stateEvent->GetEvent()); if (!positionEvent) return false; m_LastEventSender = positionEvent->GetSender(); m_LastEventSlice = m_LastEventSender->GetSlice(); //ToolLogger::SetVerboseness(3); MITK_DEBUG << "OnMousePressed" << std::endl; if ( FeedbackContourTool::CanHandleEvent(stateEvent) > 0.0 ) { MITK_DEBUG << "OnMousePressed: FeedbackContourTool says ok" << std::endl; // 1. Find out which slice the user clicked, find out which slice of the toolmanager's reference and working image corresponds to that if (positionEvent) { MITK_DEBUG << "OnMousePressed: got positionEvent" << std::endl; m_ReferenceSlice = FeedbackContourTool::GetAffectedReferenceSlice( positionEvent ); m_WorkingSlice = FeedbackContourTool::GetAffectedWorkingSlice( positionEvent ); if ( m_WorkingSlice.IsNotNull() ) // can't do anything without the segmentation { MITK_DEBUG << "OnMousePressed: got working slice" << std::endl; // 2. Determine if the user clicked inside or outside of the segmentation const Geometry3D* workingSliceGeometry = m_WorkingSlice->GetGeometry(); Point3D mprojectedPointIn2D; workingSliceGeometry->WorldToIndex( positionEvent->GetWorldPosition(), mprojectedPointIn2D); itk::Index<2> projectedPointInWorkingSlice2D; projectedPointInWorkingSlice2D[0] = static_cast( mprojectedPointIn2D[0] - 0.5 ); projectedPointInWorkingSlice2D[1] = static_cast( mprojectedPointIn2D[1] - 0.5 ); if ( workingSliceGeometry->IsIndexInside( projectedPointInWorkingSlice2D ) ) { MITK_DEBUG << "OnMousePressed: point " << positionEvent->GetWorldPosition() << " (index coordinates " << projectedPointInWorkingSlice2D << ") IS in working slice" << std::endl; // Convert to ipMITKSegmentationTYPE (because getting pixels relys on that data type) itk::Image< ipMITKSegmentationTYPE, 2 >::Pointer correctPixelTypeImage; CastToItkImage( m_WorkingSlice, correctPixelTypeImage ); assert (correctPixelTypeImage.IsNotNull() ); // possible bug in CastToItkImage ? // direction maxtrix is wrong/broken/not working after CastToItkImage, leading to a failed assertion in // mitk/Core/DataStructures/mitkSlicedGeometry3D.cpp, 479: // virtual void mitk::SlicedGeometry3D::SetSpacing(const mitk::Vector3D&): Assertion `aSpacing[0]>0 && aSpacing[1]>0 && aSpacing[2]>0' failed // solution here: we overwrite it with an unity matrix itk::Image< ipMITKSegmentationTYPE, 2 >::DirectionType imageDirection; imageDirection.SetIdentity(); correctPixelTypeImage->SetDirection(imageDirection); Image::Pointer temporarySlice = Image::New(); // temporarySlice = ImportItkImage( correctPixelTypeImage ); CastToMitkImage( correctPixelTypeImage, temporarySlice ); mitkIpPicDescriptor* workingPicSlice = mitkIpPicNew(); CastToIpPicDescriptor(temporarySlice, workingPicSlice); int initialWorkingOffset = projectedPointInWorkingSlice2D[1] * workingPicSlice->n[0] + projectedPointInWorkingSlice2D[0]; if ( initialWorkingOffset < static_cast( workingPicSlice->n[0] * workingPicSlice->n[1] ) && initialWorkingOffset >= 0 ) { // 3. determine the pixel value under the last click bool inside = static_cast(workingPicSlice->data)[initialWorkingOffset] != 0; m_PaintingPixelValue = inside ? 0 : 1; // if inside, we want to remove a part, otherwise we want to add something if ( m_LastWorkingSeed >= static_cast( workingPicSlice->n[0] * workingPicSlice->n[1] ) || m_LastWorkingSeed < 0 ) { inside = false; } if ( m_ReferenceSlice.IsNotNull() ) { MITK_DEBUG << "OnMousePressed: got reference slice" << std::endl; m_OriginalPicSlice = mitkIpPicNew(); CastToIpPicDescriptor(m_ReferenceSlice, m_OriginalPicSlice); // 3.1. Switch depending on the pixel value if (inside) { OnMousePressedInside(action, stateEvent, workingPicSlice, initialWorkingOffset); } else { OnMousePressedOutside(action, stateEvent); } } } } } } } MITK_DEBUG << "end OnMousePressed" << std::endl; return true; } /** 3.1 Create a skeletonization of the segmentation and try to find a nice cut 3.1.1 Call a ipSegmentation algorithm to create a nice cut 3.1.2 Set the result of this algorithm as the feedback contour */ bool mitk::RegionGrowingTool::OnMousePressedInside(Action* itkNotUsed( action ), const StateEvent* stateEvent, mitkIpPicDescriptor* workingPicSlice, int initialWorkingOffset) { const PositionEvent* positionEvent = dynamic_cast(stateEvent->GetEvent()); // checked in OnMousePressed // 3.1.1. Create a skeletonization of the segmentation and try to find a nice cut // apply the skeletonization-and-cut algorithm // generate contour to remove // set m_ReferenceSlice = NULL so nothing will happen during mouse move // remember to fill the contour with 0 in mouserelease mitkIpPicDescriptor* segmentationHistory = ipMITKSegmentationCreateGrowerHistory( workingPicSlice, m_LastWorkingSeed, NULL ); // free again if (segmentationHistory) { tCutResult cutContour = ipMITKSegmentationGetCutPoints( workingPicSlice, segmentationHistory, initialWorkingOffset ); // tCutResult is a ipSegmentation type mitkIpPicFree( segmentationHistory ); if (cutContour.cutIt) { // 3.1.2 copy point from float* to mitk::Contour Contour::Pointer contourInImageIndexCoordinates = Contour::New(); contourInImageIndexCoordinates->Initialize(); Point3D newPoint; for (int index = 0; index < cutContour.deleteSize; ++index) { newPoint[0] = cutContour.deleteCurve[ 2 * index + 0 ]; newPoint[1] = cutContour.deleteCurve[ 2 * index + 1 ]; newPoint[2] = 0.0; contourInImageIndexCoordinates->AddVertex( newPoint - mitk::Point3D::VectorType(0.5) ); } free(cutContour.traceline); free(cutContour.deleteCurve); // perhaps visualize this for fun? free(cutContour.onGradient); Contour::Pointer contourInWorldCoordinates = FeedbackContourTool::BackProjectContourFrom2DSlice( m_WorkingSlice->GetGeometry(), contourInImageIndexCoordinates, true ); // true: sub 0.5 for ipSegmentation correction FeedbackContourTool::SetFeedbackContour( *contourInWorldCoordinates ); FeedbackContourTool::SetFeedbackContourVisible(true); mitk::RenderingManager::GetInstance()->RequestUpdate( positionEvent->GetSender()->GetRenderWindow() ); m_FillFeedbackContour = true; } else { m_FillFeedbackContour = false; } } else { m_FillFeedbackContour = false; } m_ReferenceSlice = NULL; return true; } /** 3.2 Initialize region growing 3.2.1 Determine memory offset inside the original image 3.2.2 Determine initial region growing parameters from the level window settings of the image 3.2.3 Perform a region growing (which generates a new feedback contour) */ bool mitk::RegionGrowingTool::OnMousePressedOutside(Action* itkNotUsed( action ), const StateEvent* stateEvent) { const PositionEvent* positionEvent = dynamic_cast(stateEvent->GetEvent()); // checked in OnMousePressed // 3.2 If we have a reference image, then perform an initial region growing, considering the reference image's level window // if click was outside the image, don't continue const Geometry3D* sliceGeometry = m_ReferenceSlice->GetGeometry(); Point3D mprojectedPointIn2D; sliceGeometry->WorldToIndex( positionEvent->GetWorldPosition(), mprojectedPointIn2D ); itk::Index<2> projectedPointIn2D; projectedPointIn2D[0] = static_cast( mprojectedPointIn2D[0] - 0.5 ); projectedPointIn2D[1] = static_cast( mprojectedPointIn2D[1] - 0.5 ); if ( sliceGeometry->IsIndexInside( mprojectedPointIn2D ) ) { MITK_DEBUG << "OnMousePressed: point " << positionEvent->GetWorldPosition() << " (index coordinates " << mprojectedPointIn2D << ") IS in reference slice" << std::endl; // 3.2.1 Remember Y cursor position and initial seed point //m_ScreenYPositionAtStart = static_cast(positionEvent->GetDisplayPosition()[1]); m_LastScreenPosition = ApplicationCursor::GetInstance()->GetCursorPosition(); m_ScreenYDifference = 0; m_SeedPointMemoryOffset = projectedPointIn2D[1] * m_OriginalPicSlice->n[0] + projectedPointIn2D[0]; m_LastWorkingSeed = m_SeedPointMemoryOffset; // remember for skeletonization if ( m_SeedPointMemoryOffset < static_cast( m_OriginalPicSlice->n[0] * m_OriginalPicSlice->n[1] ) && m_SeedPointMemoryOffset >= 0 ) { // 3.2.2 Get level window from reference DataNode // Use some logic to determine initial gray value bounds LevelWindow lw(0, 500); m_ToolManager->GetReferenceData(0)->GetLevelWindow(lw); // will fill lw if levelwindow property is present, otherwise won't touch it. ScalarType currentVisibleWindow = lw.GetWindow(); if (!mitk::Equal(currentVisibleWindow, m_VisibleWindow)) { m_InitialLowerThreshold = currentVisibleWindow / 20.0; m_InitialUpperThreshold = currentVisibleWindow / 20.0; m_LowerThreshold = m_InitialLowerThreshold; m_UpperThreshold = m_InitialUpperThreshold; // 3.2.3. Actually perform region growing mitkIpPicDescriptor* result = PerformRegionGrowingAndUpdateContour(); ipMITKSegmentationFree( result); // display the contour FeedbackContourTool::SetFeedbackContourVisible(true); mitk::RenderingManager::GetInstance()->RequestUpdate(positionEvent->GetSender()->GetRenderWindow()); m_FillFeedbackContour = true; } } return true; } return false; } /** If in region growing mode (m_ReferenceSlice != NULL), then 1. Calculate the new thresholds from mouse position (relative to first position) 2. Perform a new region growing and update the feedback contour */ bool mitk::RegionGrowingTool::OnMouseMoved(Action* action, const StateEvent* stateEvent) { if ( FeedbackContourTool::CanHandleEvent(stateEvent) > 0.0 ) { if ( m_ReferenceSlice.IsNotNull() && m_OriginalPicSlice ) { const PositionEvent* positionEvent = dynamic_cast(stateEvent->GetEvent()); if (positionEvent) { ApplicationCursor* cursor = ApplicationCursor::GetInstance(); if (!cursor) return false; m_ScreenYDifference += cursor->GetCursorPosition()[1] - m_LastScreenPosition[1]; cursor->SetCursorPosition( m_LastScreenPosition ); m_LowerThreshold = std::max(0.0, m_InitialLowerThreshold - m_ScreenYDifference * m_MouseDistanceScaleFactor); m_UpperThreshold = std::max(0.0, m_InitialUpperThreshold - m_ScreenYDifference * m_MouseDistanceScaleFactor); // 2. Perform region growing again and show the result mitkIpPicDescriptor* result = PerformRegionGrowingAndUpdateContour(); ipMITKSegmentationFree( result ); // 3. Update the contour mitk::RenderingManager::GetInstance()->ForceImmediateUpdate(positionEvent->GetSender()->GetRenderWindow()); } } } return true; } /** If the feedback contour should be filled, then it is done here. (Contour is NOT filled, when skeletonization is done but no nice cut was found) */ bool mitk::RegionGrowingTool::OnMouseReleased(Action* action, const StateEvent* stateEvent) { if ( FeedbackContourTool::CanHandleEvent(stateEvent) > 0.0 ) { // 1. If we have a working slice, use the contour to fill a new piece on segmentation on it (or erase a piece that was selected by ipMITKSegmentationGetCutPoints) if ( m_WorkingSlice.IsNotNull() && m_OriginalPicSlice ) { const PositionEvent* positionEvent = dynamic_cast(stateEvent->GetEvent()); if (positionEvent) { // remember parameters for next time m_InitialLowerThreshold = m_LowerThreshold; m_InitialUpperThreshold = m_UpperThreshold; if (m_FillFeedbackContour) { // 3. use contour to fill a region in our working slice Contour* feedbackContour( FeedbackContourTool::GetFeedbackContour() ); if (feedbackContour) { Contour::Pointer projectedContour = FeedbackContourTool::ProjectContourTo2DSlice( m_WorkingSlice, feedbackContour, false, false ); // false: don't add any 0.5 // false: don't constrain the contour to the image's inside if (projectedContour.IsNotNull()) { FeedbackContourTool::FillContourInSlice( projectedContour, m_WorkingSlice, m_PaintingPixelValue ); const PlaneGeometry* planeGeometry( dynamic_cast (positionEvent->GetSender()->GetCurrentWorldGeometry2D() ) ); //MITK_DEBUG << "OnMouseReleased: writing back to dimension " << affectedDimension << ", slice " << affectedSlice << " in working image" << std::endl; // 4. write working slice back into image volume this->WriteBackSegmentationResult(positionEvent, m_WorkingSlice); } } } FeedbackContourTool::SetFeedbackContourVisible(false); mitk::RenderingManager::GetInstance()->RequestUpdate( positionEvent->GetSender()->GetRenderWindow() ); } } } m_ReferenceSlice = NULL; // don't leak m_WorkingSlice = NULL; m_OriginalPicSlice = NULL; return true; } /** Uses ipSegmentation algorithms to do the actual region growing. The result (binary image) is first smoothed by a 5x5 circle mask, then its contour is extracted and converted to MITK coordinates. */ mitkIpPicDescriptor* mitk::RegionGrowingTool::PerformRegionGrowingAndUpdateContour() { // 1. m_OriginalPicSlice and m_SeedPointMemoryOffset are set to sensitive values, as well as m_LowerThreshold and m_UpperThreshold assert (m_OriginalPicSlice); if (m_OriginalPicSlice->n[0] != 256 || m_OriginalPicSlice->n[1] != 256) // ??? assert( (m_SeedPointMemoryOffset < static_cast( m_OriginalPicSlice->n[0] * m_OriginalPicSlice->n[1] )) && (m_SeedPointMemoryOffset >= 0) ); // inside the image // 2. ipSegmentation is used to perform region growing float ignored; int oneContourOffset( 0 ); mitkIpPicDescriptor* regionGrowerResult = ipMITKSegmentationGrowRegion4N( m_OriginalPicSlice, m_SeedPointMemoryOffset, // seed point true, // grayvalue interval relative to seed point gray value? m_LowerThreshold, m_UpperThreshold, 0, // continue until done (maxIterations == 0) NULL, // allocate new memory (only this time, on mouse move we'll reuse the old buffer) oneContourOffset, // a pixel that is near the resulting contour ignored // ignored by us ); if (!regionGrowerResult || oneContourOffset == -1) { Contour::Pointer dummyContour = Contour::New(); dummyContour->Initialize(); FeedbackContourTool::SetFeedbackContour( *dummyContour ); if (regionGrowerResult) ipMITKSegmentationFree(regionGrowerResult); return NULL; } // 3. We smooth the result a little to reduce contour complexity bool smoothResult( true ); // currently fixed, perhaps remove else block mitkIpPicDescriptor* smoothedRegionGrowerResult; if (smoothResult) { // Smooth the result (otherwise very detailed contour) smoothedRegionGrowerResult = SmoothIPPicBinaryImage( regionGrowerResult, oneContourOffset ); ipMITKSegmentationFree( regionGrowerResult ); } else { smoothedRegionGrowerResult = regionGrowerResult; } // 4. convert the result of region growing into a mitk::Contour // At this point oneContourOffset could be useless, if smoothing destroyed a thin bridge. In these // cases, we have two or more unconnected segmentation regions, and we don't know, which one is touched by oneContourOffset. // In the bad case, the contour is not the one around our seedpoint, so the result looks very strange to the user. // -> we remove the point where the contour started so far. Then we look from the bottom of the image for the first segmentation pixel // and start another contour extraction from there. This is done, until the seedpoint is inside the contour int numberOfContourPoints( 0 ); int newBufferSize( 0 ); float* contourPoints = ipMITKSegmentationGetContour8N( smoothedRegionGrowerResult, oneContourOffset, numberOfContourPoints, newBufferSize ); // memory allocated with malloc if (contourPoints) { while ( !ipMITKSegmentationIsInsideContour( contourPoints, // contour numberOfContourPoints, // points in contour m_SeedPointMemoryOffset % smoothedRegionGrowerResult->n[0], // test point x m_SeedPointMemoryOffset / smoothedRegionGrowerResult->n[0] // test point y ) ) { // we decide that this cannot be part of the segmentation because the seedpoint is not contained in the contour (fill the 4-neighborhood with 0) ipMITKSegmentationReplaceRegion4N( smoothedRegionGrowerResult, oneContourOffset, 0 ); // move the contour offset to the last row (x position of the seed point) int rowLength = smoothedRegionGrowerResult->n[0]; // number of pixels in a row oneContourOffset = m_SeedPointMemoryOffset % smoothedRegionGrowerResult->n[0] // x of seed point + rowLength*(smoothedRegionGrowerResult->n[1]-1); // y of last row while ( oneContourOffset >=0 && (*(static_cast(smoothedRegionGrowerResult->data) + oneContourOffset) == 0) ) { oneContourOffset -= rowLength; // if pixel at data+oneContourOffset is 0, then move up one row } if ( oneContourOffset < 0 ) { break; // just use the last contour we found } free(contourPoints); // release contour memory contourPoints = ipMITKSegmentationGetContour8N( smoothedRegionGrowerResult, oneContourOffset, numberOfContourPoints, newBufferSize ); // memory allocated with malloc } // copy point from float* to mitk::Contour Contour::Pointer contourInImageIndexCoordinates = Contour::New(); contourInImageIndexCoordinates->Initialize(); Point3D newPoint; for (int index = 0; index < numberOfContourPoints; ++index) { newPoint[0] = contourPoints[ 2 * index + 0 ]; newPoint[1] = contourPoints[ 2 * index + 1 ]; newPoint[2] = 0; contourInImageIndexCoordinates->AddVertex( newPoint - mitk::Point3D::VectorType(0.5)); } free(contourPoints); Contour::Pointer contourInWorldCoordinates = FeedbackContourTool::BackProjectContourFrom2DSlice( m_ReferenceSlice->GetGeometry(), contourInImageIndexCoordinates, true ); // true: sub 0.5 for ipSegmentation correctio FeedbackContourTool::SetFeedbackContour( *contourInWorldCoordinates ); } // 5. Result HAS TO BE freed by caller, contains the binary region growing result return smoothedRegionGrowerResult; } /** Helper method for SmoothIPPicBinaryImage. Smoothes a given part of and image. \param sourceImage The original binary image. \param dest The smoothed image (will be written without bounds checking). \param contourOfs One offset of the contour. Is updated if a pixel is changed (which might change the contour). \param maskOffsets Memory offsets that describe the smoothing mask. \param maskSize Entries of the mask. \param startOffset First pixel that should be smoothed using this mask. \param endOffset Last pixel that should be smoothed using this mask. */ void mitk::RegionGrowingTool::SmoothIPPicBinaryImageHelperForRows( mitkIpPicDescriptor* sourceImage, mitkIpPicDescriptor* dest, int &contourOfs, int* maskOffsets, int maskSize, int startOffset, int endOffset ) { // work on the very first row ipMITKSegmentationTYPE* current; ipMITKSegmentationTYPE* source = ((ipMITKSegmentationTYPE*)sourceImage->data) + startOffset; // + 1! don't read at start-1 ipMITKSegmentationTYPE* end = ((ipMITKSegmentationTYPE*)dest->data) + endOffset; int ofs = startOffset; int minority = (maskSize - 1) / 2; for (current = ((ipMITKSegmentationTYPE*)dest->data) + startOffset; current minority) { *current = 1; contourOfs = ofs; } else { *current = 0; } ++source; ++ofs; } } /** Smoothes a binary ipPic image with a 5x5 mask. The image borders (some first and last rows) are treated differently. */ mitkIpPicDescriptor* mitk::RegionGrowingTool::SmoothIPPicBinaryImage( mitkIpPicDescriptor* image, int &contourOfs, mitkIpPicDescriptor* dest ) { if (!image) return NULL; // Original code from /trunk/mbi-qm/Qmitk/Qmitk2DSegTools/RegionGrowerTool.cpp (first version by T. Boettger?). Reformatted and documented and restructured. #define MSK_SIZE5x5 21 #define MSK_SIZE3x3 5 #define MSK_SIZE3x1 3 // mask is an array of coordinates that form a rastered circle like this // // OOO // OOOOO // OOOOO // OOOOO // OOO // // int mask5x5[MSK_SIZE5x5][2] = { /******/ {-1,-2}, {0,-2}, {1,-2}, /*****/ {-2,-1}, {-1,-1}, {0,-1}, {1,-1}, {2,-1}, {-2, 0}, {-1, 0}, {0, 0}, {1, 0}, {2, 0}, {-2, 1}, {-1, 1}, {0, 1}, {1, 1}, {2, 1}, /******/ {-1, 2}, {0, 2}, {1, 2} /*****/ }; int mask3x3[MSK_SIZE3x3][2] = { /******/ {0,-1}, /*****/ {-1, 0}, {0, 0}, {1, 0}, /******/ {0, 1} /*****/ }; int mask3x1[MSK_SIZE3x1][2] = { {-1, 0}, {0, 0}, {1, 0} }; // The following lines iterate over all the pixels of a (sliced) image (except the first and last three rows). // For each pixel, all the coordinates around it (according to mask) are evaluated (this means 21 pixels). // If more than 10 of the evaluated pixels are non-zero, then the central pixel is set to 1, else to 0. // This is determining a majority. If there is no clear majority, then the central pixel itself "decides". int maskOffset5x5[MSK_SIZE5x5]; int line = image->n[0]; for (int i=0; in[0]; int spareOut1Rows = 1*image->n[0]; if ( image->n[1] > 0 ) SmoothIPPicBinaryImageHelperForRows( image, dest, contourOfs, maskOffset3x1, MSK_SIZE3x1, 1, dest->n[0] ); if ( image->n[1] > 3 ) SmoothIPPicBinaryImageHelperForRows( image, dest, contourOfs, maskOffset3x3, MSK_SIZE3x3, spareOut1Rows, dest->n[0]*3 ); if ( image->n[1] > 6 ) SmoothIPPicBinaryImageHelperForRows( image, dest, contourOfs, maskOffset5x5, MSK_SIZE5x5, spareOut3Rows, dest->n[0]*dest->n[1] - spareOut3Rows ); if ( image->n[1] > 8 ) SmoothIPPicBinaryImageHelperForRows( image, dest, contourOfs, maskOffset3x3, MSK_SIZE3x3, dest->n[0]*dest->n[1] -spareOut3Rows, dest->n[0]*dest->n[1] - spareOut1Rows ); if ( image->n[1] > 10) SmoothIPPicBinaryImageHelperForRows( image, dest, contourOfs, maskOffset3x1, MSK_SIZE3x1, dest->n[0]*dest->n[1] -spareOut1Rows, dest->n[0]*dest->n[1] - 1 ); // correction for first pixel (sorry for the ugliness) if ( *((ipMITKSegmentationTYPE*)(dest->data)+1) == 1 ) { *((ipMITKSegmentationTYPE*)(dest->data)+0) = 1; } if (dest->n[0] * dest->n[1] > 2) { // correction for last pixel if ( *((ipMITKSegmentationTYPE*)(dest->data)+dest->n[0]*dest->n[1]-2) == 1 ) { *((ipMITKSegmentationTYPE*)(dest->data)+dest->n[0]*dest->n[1]-1) = 1; } } return dest; } diff --git a/Modules/Segmentation/Interactions/mitkRegionGrowingTool.h b/Modules/Segmentation/Interactions/mitkRegionGrowingTool.h index 957af7a81d..582fb29e0f 100644 --- a/Modules/Segmentation/Interactions/mitkRegionGrowingTool.h +++ b/Modules/Segmentation/Interactions/mitkRegionGrowingTool.h @@ -1,116 +1,119 @@ /*=================================================================== 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 mitkRegionGrowingTool_h_Included #define mitkRegionGrowingTool_h_Included #include "mitkFeedbackContourTool.h" #include "mitkLegacyAdaptors.h" #include "SegmentationExports.h" struct mitkIpPicDescriptor; +class ModuleResource; + namespace mitk { /** \brief A slice based region growing tool. \sa FeedbackContourTool \ingroup Interaction \ingroup ToolManagerEtAl When the user presses the mouse button, RegionGrowingTool will use the gray values at that position to initialize a region growing algorithm (in the affected 2D slice). By moving the mouse up and down while the button is still pressed, the user can change the parameters of the region growing algorithm (selecting more or less of an object). The current result of region growing will always be shown as a contour to the user. After releasing the button, the current result of the region growing algorithm will be written to the working image of this tool's ToolManager. If the first click is inside a segmentation that was generated by region growing (recently), the tool will try to cut off a part of the segmentation. For this reason a skeletonization of the segmentation is generated and the optimal cut point is determined. \warning Only to be instantiated by mitk::ToolManager. $Author$ */ class Segmentation_EXPORT RegionGrowingTool : public FeedbackContourTool { public: mitkClassMacro(RegionGrowingTool, FeedbackContourTool); itkNewMacro(RegionGrowingTool); virtual const char** GetXPM() const; - virtual std::string GetIconPath() const; virtual std::string GetCursorIconPath() const; + ModuleResource GetIconResource() const; + virtual const char* GetName() const; protected: RegionGrowingTool(); // purposely hidden virtual ~RegionGrowingTool(); virtual void Activated(); virtual void Deactivated(); virtual bool OnMousePressed (Action*, const StateEvent*); virtual bool OnMousePressedInside (Action*, const StateEvent*, mitkIpPicDescriptor* workingPicSlice, int initialWorkingOffset); virtual bool OnMousePressedOutside (Action*, const StateEvent*); virtual bool OnMouseMoved (Action*, const StateEvent*); virtual bool OnMouseReleased(Action*, const StateEvent*); mitkIpPicDescriptor* PerformRegionGrowingAndUpdateContour(); Image::Pointer m_ReferenceSlice; Image::Pointer m_WorkingSlice; ScalarType m_LowerThreshold; ScalarType m_UpperThreshold; ScalarType m_InitialLowerThreshold; ScalarType m_InitialUpperThreshold; Point2I m_LastScreenPosition; int m_ScreenYDifference; private: mitkIpPicDescriptor* SmoothIPPicBinaryImage( mitkIpPicDescriptor* image, int &contourOfs, mitkIpPicDescriptor* dest = NULL ); void SmoothIPPicBinaryImageHelperForRows( mitkIpPicDescriptor* source, mitkIpPicDescriptor* dest, int &contourOfs, int* maskOffsets, int maskSize, int startOffset, int endOffset ); mitkIpPicDescriptor* m_OriginalPicSlice; int m_SeedPointMemoryOffset; ScalarType m_VisibleWindow; ScalarType m_DefaultWindow; ScalarType m_MouseDistanceScaleFactor; int m_PaintingPixelValue; int m_LastWorkingSeed; bool m_FillFeedbackContour; }; } // namespace #endif diff --git a/Modules/Segmentation/Interactions/mitkSubtractContourTool.cpp b/Modules/Segmentation/Interactions/mitkSubtractContourTool.cpp index b1cdeb5282..7436158de3 100644 --- a/Modules/Segmentation/Interactions/mitkSubtractContourTool.cpp +++ b/Modules/Segmentation/Interactions/mitkSubtractContourTool.cpp @@ -1,54 +1,61 @@ /*=================================================================== 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 "mitkSubtractContourTool.h" #include "mitkSubtractContourTool.xpm" +// us +#include "mitkModule.h" +#include "mitkModuleResource.h" +#include + namespace mitk { MITK_TOOL_MACRO(Segmentation_EXPORT, SubtractContourTool, "Subtract tool"); } mitk::SubtractContourTool::SubtractContourTool() :ContourTool(0) { FeedbackContourTool::SetFeedbackContourColor( 1.0, 0.0, 0.0 ); } mitk::SubtractContourTool::~SubtractContourTool() { } const char** mitk::SubtractContourTool::GetXPM() const { return mitkSubtractContourTool_xpm; } -std::string mitk::SubtractContourTool::GetIconPath() const +mitk::ModuleResource mitk::SubtractContourTool::GetIconResource() const { - return ":/Segmentation/Subtract_48x48.png"; + Module* module = GetModuleContext()->GetModule(); + ModuleResource resource = module->GetResource("Subtract_48x48.png"); + return resource; } std::string mitk::SubtractContourTool::GetCursorIconPath() const { return ":/Segmentation/Subtract_Cursor_48x48.png"; } const char* mitk::SubtractContourTool::GetName() const { return "Subtract"; } diff --git a/Modules/Segmentation/Interactions/mitkSubtractContourTool.h b/Modules/Segmentation/Interactions/mitkSubtractContourTool.h index 7dfd1570e5..fc6c08dcd7 100644 --- a/Modules/Segmentation/Interactions/mitkSubtractContourTool.h +++ b/Modules/Segmentation/Interactions/mitkSubtractContourTool.h @@ -1,69 +1,72 @@ /*=================================================================== 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 mitkSubtractContourTool_h_Included #define mitkSubtractContourTool_h_Included #include "mitkContourTool.h" #include "SegmentationExports.h" +class ModuleResource; + namespace mitk { /** \brief Fill the inside of a contour with 1 \sa ContourTool \ingroup Interaction \ingroup ToolManagerEtAl Fills a visible contour (from FeedbackContourTool) during mouse dragging. When the mouse button is released, SubtractContourTool tries to extract a slice from the working image and fill in the (filled) contour as a binary image. All inside pixels are set to 0. While holding the CTRL key, the contour changes color and the pixels on the inside would be filled with 1. \warning Only to be instantiated by mitk::ToolManager. $Author$ */ class Segmentation_EXPORT SubtractContourTool : public ContourTool { public: mitkClassMacro(SubtractContourTool, ContourTool); itkNewMacro(SubtractContourTool); virtual const char** GetXPM() const; - virtual std::string GetIconPath() const; virtual std::string GetCursorIconPath() const; + ModuleResource GetIconResource() const; + virtual const char* GetName() const; protected: SubtractContourTool(); // purposely hidden virtual ~SubtractContourTool(); }; } // namespace #endif diff --git a/Modules/Segmentation/Interactions/mitkWatershedTool.cpp b/Modules/Segmentation/Interactions/mitkWatershedTool.cpp index 290030fa1e..277359ecf8 100644 --- a/Modules/Segmentation/Interactions/mitkWatershedTool.cpp +++ b/Modules/Segmentation/Interactions/mitkWatershedTool.cpp @@ -1,161 +1,159 @@ /*=================================================================== 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 "mitkWatershedTool.h" #include "mitkBinaryThresholdTool.xpm" #include "mitkToolManager.h" #include "mitkImageAccessByItk.h" #include "mitkImageCast.h" #include "mitkITKImageImport.h" #include "mitkRenderingManager.h" #include "mitkRenderingModeProperty.h" #include "mitkLookupTable.h" #include "mitkLookupTableProperty.h" #include "mitkIOUtil.h" #include "mitkLevelWindowManager.h" #include "mitkImageStatisticsHolder.h" #include #include #include #include -#include - namespace mitk { MITK_TOOL_MACRO(Segmentation_EXPORT, WatershedTool, "Watershed tool"); } mitk::WatershedTool::WatershedTool() : m_Level(0.), m_Threshold(0.) { } mitk::WatershedTool::~WatershedTool() { } void mitk::WatershedTool::Activated() { Superclass::Activated(); } void mitk::WatershedTool::Deactivated() { Superclass::Deactivated(); } const char** mitk::WatershedTool::GetXPM() const { return mitkBinaryThresholdTool_xpm; } const char* mitk::WatershedTool::GetName() const { return "Watershedding"; } void mitk::WatershedTool::DoIt() { // get image from tool manager mitk::Image::Pointer input = dynamic_cast(m_ToolManager->GetReferenceData(0)->GetData()); mitk::Image::Pointer output; try { // create and run itk filter pipeline AccessFixedDimensionByItk_1(input.GetPointer(),ITKWatershed,3,output); // create a new datanode for output mitk::DataNode::Pointer dataNode = mitk::DataNode::New(); dataNode->SetData(output); // set properties of datanode dataNode->SetProperty("binary", mitk::BoolProperty::New(false)); dataNode->SetProperty("name", mitk::StringProperty::New("Watershed Result")); mitk::RenderingModeProperty::Pointer renderingMode = mitk::RenderingModeProperty::New(); renderingMode->SetValue( mitk::RenderingModeProperty::LOOKUPTABLE_LEVELWINDOW_COLOR ); dataNode->SetProperty("Image Rendering.Mode", renderingMode); // since we create a multi label image, define a vtk lookup table mitk::LookupTable::Pointer lut = mitk::LookupTable::New(); mitk::LookupTableProperty::Pointer prop = mitk::LookupTableProperty::New(lut); vtkLookupTable *lookupTable = vtkLookupTable::New(); lookupTable->SetHueRange(1.0, 0.0); lookupTable->SetSaturationRange(1.0, 1.0); lookupTable->SetValueRange(1.0, 1.0); lookupTable->SetTableRange(-1.0, 1.0); lookupTable->Build(); lookupTable->SetTableValue(1,0,0,0); lut->SetVtkLookupTable(lookupTable); prop->SetLookupTable(lut); dataNode->SetProperty("LookupTable",prop); // make the levelwindow fit to right values mitk::LevelWindowProperty::Pointer levWinProp = mitk::LevelWindowProperty::New(); mitk::LevelWindow levelwindow; levelwindow.SetRangeMinMax(0, output->GetStatistics()->GetScalarValueMax()); levWinProp->SetLevelWindow( levelwindow ); dataNode->SetProperty( "levelwindow", levWinProp ); dataNode->SetProperty( "opacity", mitk::FloatProperty::New(0.5)); // add output to the data storage m_ToolManager->GetDataStorage()->Add(dataNode); } catch(itk::ExceptionObject& e) { - QMessageBox::warning(NULL,QString::fromAscii("Watershed Filter Error"), QString::fromAscii(e.GetDescription())); + MITK_ERROR<<"Watershed Filter Error"; } RenderingManager::GetInstance()->RequestUpdateAll(); } template void mitk::WatershedTool::ITKWatershed( itk::Image* originalImage, mitk::Image::Pointer& segmentation ) { typedef itk::WatershedImageFilter< itk::Image > WatershedFilter; typedef itk::GradientMagnitudeRecursiveGaussianImageFilter< itk::Image, itk::Image > MagnitudeFilter; // at first add a gradient magnitude filter typename MagnitudeFilter::Pointer magnitude = MagnitudeFilter::New(); magnitude->SetInput(originalImage); magnitude->SetSigma(1.0); // then add the watershed filter to the pipeline typename WatershedFilter::Pointer watershed = WatershedFilter::New(); watershed->SetInput(magnitude->GetOutput()); watershed->SetThreshold(m_Threshold); watershed->SetLevel(m_Level); // then make sure, that the output has the desired pixel type typedef itk::CastImageFilter > CastFilter; typename CastFilter::Pointer cast = CastFilter::New(); cast->SetInput(watershed->GetOutput()); // start the whole pipeline cast->Update(); // since we obtain a new image from our pipeline, we have to make sure, that our mitk::Image::Pointer // is responsible for the memory management of the output image segmentation = mitk::GrabItkImageMemory(cast->GetOutput()); } diff --git a/Modules/Segmentation/Interactions/mitkWatershedTool.h b/Modules/Segmentation/Interactions/mitkWatershedTool.h index ff9beff4cc..06dbe7ee2c 100644 --- a/Modules/Segmentation/Interactions/mitkWatershedTool.h +++ b/Modules/Segmentation/Interactions/mitkWatershedTool.h @@ -1,89 +1,93 @@ /*=================================================================== 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 mitkWatershedTool_h_Included #define mitkWatershedTool_h_Included #include "mitkCommon.h" #include "SegmentationExports.h" #include "mitkAutoSegmentationTool.h" +//TODO use usResourceSystem instead of xpm. See other tool icons +//class ModuleResource; + namespace mitk { class Image; /** \brief Simple watershed segmentation tool. \ingroup Interaction \ingroup ToolManagerEtAl Wraps ITK Watershed Filter into tool concept of MITK. For more information look into ITK documentation. \warning Only to be instantiated by mitk::ToolManager. $Darth Vader$ */ class Segmentation_EXPORT WatershedTool : public AutoSegmentationTool { public: mitkClassMacro(WatershedTool, AutoSegmentationTool); itkNewMacro(WatershedTool); void SetThreshold(double t) { m_Threshold = t; } void SetLevel(double l) { m_Level = l; } /** \brief Grabs the tool reference data and creates an ITK pipeline consisting of a GradientMagnitude * image filter followed by a Watershed image filter. The output of the filter pipeline is then added * to the data storage. */ void DoIt(); /** \brief Creates and runs an ITK filter pipeline consisting of the filters: GradientMagnitude-, Watershed- and CastImageFilter. * * \param originalImage The input image, which is delivered by the AccessByItk macro. * \param segmentation A pointer to the output image, which will point to the pipeline output after execution. */ template void ITKWatershed( itk::Image* originalImage, mitk::Image::Pointer& segmentation ); virtual const char** GetXPM() const; virtual const char* GetName() const; +// ModuleResource GetIconResource() const; protected: WatershedTool(); // purposely hidden virtual ~WatershedTool(); virtual void Activated(); virtual void Deactivated(); /** \brief Threshold parameter of the ITK Watershed Image Filter. See ITK Documentation for more information. */ double m_Threshold; /** \brief Threshold parameter of the ITK Watershed Image Filter. See ITK Documentation for more information. */ double m_Level; }; } // namespace #endif diff --git a/Modules/Segmentation/files.cmake b/Modules/Segmentation/files.cmake index 035bde7374..e94d4583c3 100644 --- a/Modules/Segmentation/files.cmake +++ b/Modules/Segmentation/files.cmake @@ -1,87 +1,110 @@ set(CPP_FILES Algorithms/mitkCalculateSegmentationVolume.cpp Algorithms/mitkComputeContourSetNormalsFilter.cpp Algorithms/mitkContourSetToPointSetFilter.cpp Algorithms/mitkContourUtils.cpp Algorithms/mitkCorrectorAlgorithm.cpp Algorithms/mitkCreateDistanceImageFromSurfaceFilter.cpp Algorithms/mitkDiffImageApplier.cpp Algorithms/mitkImageToContourFilter.cpp Algorithms/mitkManualSegmentationToSurfaceFilter.cpp Algorithms/mitkOverwriteDirectedPlaneImageFilter.cpp Algorithms/mitkOverwriteSliceImageFilter.cpp Algorithms/mitkReduceContourSetFilter.cpp Algorithms/mitkSegmentationObjectFactory.cpp Algorithms/mitkSegmentationSink.cpp Algorithms/mitkShapeBasedInterpolationAlgorithm.cpp Algorithms/mitkShowSegmentationAsSmoothedSurface.cpp Algorithms/mitkShowSegmentationAsSurface.cpp Algorithms/mitkVtkImageOverwrite.cpp Algorithms/mitkDiffSliceOperation.cpp Algorithms/mitkDiffSliceOperationApplier.cpp Algorithms/mitkContourModelSource.cpp Algorithms/mitkContourModelToPointSetFilter.cpp Algorithms/mitkContourModelToSurfaceFilter.cpp Algorithms/mitkContourModelSubDivisionFilter.cpp Algorithms/mitkImageToContourModelFilter.cpp Algorithms/mitkImageToLiveWireContourFilter.cpp Algorithms/mitkImageLiveWireContourModelFilter.cpp Algorithms/mitkOtsuSegmentationFilter.cpp Controllers/mitkSegmentationInterpolationController.cpp Controllers/mitkSurfaceInterpolationController.cpp # DataManagement/mitkApplyDiffImageOperation.cpp DataManagement/mitkContour.cpp DataManagement/mitkContourSet.cpp DataManagement/mitkExtrudedContour.cpp DataManagement/mitkContourModel.cpp DataManagement/mitkContourElement.cpp Interactions/mitkAddContourTool.cpp Interactions/mitkAutoCropTool.cpp Interactions/mitkAutoSegmentationTool.cpp Interactions/mitkBinaryThresholdTool.cpp Interactions/mitkBinaryThresholdULTool.cpp Interactions/mitkCalculateGrayValueStatisticsTool.cpp Interactions/mitkCalculateVolumetryTool.cpp Interactions/mitkContourInteractor.cpp Interactions/mitkContourTool.cpp Interactions/mitkCorrectorTool2D.cpp Interactions/mitkCreateSurfaceTool.cpp Interactions/mitkDrawPaintbrushTool.cpp Interactions/mitkErasePaintbrushTool.cpp Interactions/mitkEraseRegionTool.cpp Interactions/mitkExtrudedContourInteractor.cpp Interactions/mitkFeedbackContourTool.cpp Interactions/mitkFillRegionTool.cpp Interactions/mitkOtsuTool3D.cpp Interactions/mitkPaintbrushTool.cpp Interactions/mitkRegionGrow3DTool.cpp Interactions/mitkRegionGrowingTool.cpp Interactions/mitkSegmentationsProcessingTool.cpp Interactions/mitkSetRegionTool.cpp Interactions/mitkSegTool2D.cpp Interactions/mitkSubtractContourTool.cpp Interactions/mitkWatershedTool.cpp Interactions/mitkContourModelInteractor.cpp Interactions/mitkContourModelLiveWireInteractor.cpp Interactions/mitkLiveWireTool2D.cpp Interactions/mitkFastMarchingTool.cpp Interactions/mitkFastMarchingTool3D.cpp Interactions/mitkAdaptiveRegionGrowingTool.cpp IO/mitkContourModelIOFactory.cpp IO/mitkContourModelReader.cpp IO/mitkContourModelWriter.cpp IO/mitkContourModelWriterFactory.cpp Rendering/mitkContourMapper2D.cpp Rendering/mitkContourSetMapper2D.cpp Rendering/mitkContourSetVtkMapper3D.cpp Rendering/mitkContourVtkMapper3D.cpp Rendering/mitkContourModelMapper2D.cpp Rendering/mitkContourModelMapper3D.cpp Rendering/mitkContourModelGLMapper2D.cpp SegmentationUtilities/BooleanOperations/mitkBooleanOperation.cpp SegmentationUtilities/MorphologicalOperations/mitkMorphologicalOperations.cpp ) -set(QRC_FILES - resources/Segmentation.qrc +set(RESOURCE_FILES +Add_48x48.png +Erase_48x48.png +Fill_48x48.png +LiveWire_48x48.png +Paint_48x48.png +Threshold_48x48.png +Wipe_48x48.png +Correction_48x48.png +FastMarching_48x48.png +#Icons.svg +Otsu_48x48.png +RegionGrowing_48x48.png +Subtract_48x48.png +TwoThresholds_48x48.png +Add_Cursor_48x48.png +Correction_Cursor_48x48.png +Erase_Cursor_48x48.png +FastMarching_Cursor_48x48.png +Fill_Cursor_48x48.png +LiveWire_Cursor_48x48.png +Paint_Cursor_48x48.png +RegionGrowing_Cursor_48x48.png +Subtract_Cursor_48x48.png +Wipe_Cursor_48x48.png ) diff --git a/Modules/Segmentation/resources/Segmentation.qrc b/Modules/Segmentation/resources/Segmentation.qrc deleted file mode 100644 index 3862b434f6..0000000000 --- a/Modules/Segmentation/resources/Segmentation.qrc +++ /dev/null @@ -1,28 +0,0 @@ - - - - Add_48x48.png - Add_Cursor_48x48.png - Subtract_48x48.png - Subtract_Cursor_48x48.png - Paint_48x48.png - Paint_Cursor_48x48.png - Wipe_48x48.png - Wipe_Cursor_48x48.png - RegionGrowing_48x48.png - RegionGrowing_Cursor_48x48.png - Correction_48x48.png - Correction_Cursor_48x48.png - Fill_48x48.png - Fill_Cursor_48x48.png - Erase_48x48.png - Erase_Cursor_48x48.png - LiveWire_48x48.png - LiveWire_Cursor_48x48.png - FastMarching_48x48.png - FastMarching_Cursor_48x48.png - Threshold_48x48.png - TwoThresholds_48x48.png - Otsu_48x48.png - - diff --git a/Modules/SegmentationUI/CMakeLists.txt b/Modules/SegmentationUI/CMakeLists.txt new file mode 100644 index 0000000000..640fabfdcf --- /dev/null +++ b/Modules/SegmentationUI/CMakeLists.txt @@ -0,0 +1,6 @@ +MITK_CREATE_MODULE ( SegmentationUI +INCLUDE_DIRS Qmitk +DEPENDS Qmitk Segmentation qxt QmitkExt +PACKAGE_DEPENDS QT +QT_MODULE +) diff --git a/Modules/QmitkExt/QmitkAdaptiveRegionGrowingToolGUI.cpp b/Modules/SegmentationUI/Qmitk/QmitkAdaptiveRegionGrowingToolGUI.cpp similarity index 100% rename from Modules/QmitkExt/QmitkAdaptiveRegionGrowingToolGUI.cpp rename to Modules/SegmentationUI/Qmitk/QmitkAdaptiveRegionGrowingToolGUI.cpp diff --git a/Modules/QmitkExt/QmitkAdaptiveRegionGrowingToolGUI.h b/Modules/SegmentationUI/Qmitk/QmitkAdaptiveRegionGrowingToolGUI.h similarity index 97% rename from Modules/QmitkExt/QmitkAdaptiveRegionGrowingToolGUI.h rename to Modules/SegmentationUI/Qmitk/QmitkAdaptiveRegionGrowingToolGUI.h index b55841c7b2..dcd01d3dce 100644 --- a/Modules/QmitkExt/QmitkAdaptiveRegionGrowingToolGUI.h +++ b/Modules/SegmentationUI/Qmitk/QmitkAdaptiveRegionGrowingToolGUI.h @@ -1,168 +1,168 @@ /*=================================================================== 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 QMITK_QmitkAdaptiveRegionGrowingToolGUI_H #define QMITK_QmitkAdaptiveRegionGrowingToolGUI_H #include "mitkDataStorage.h" #include "itkImage.h" #include "mitkGeometry3D.h" #include "mitkPointSet.h" #include "qwidget.h" #include "ui_QmitkAdaptiveRegionGrowingToolGUIControls.h" -#include "QmitkExtExports.h" +#include "SegmentationUIExports.h" #include "QmitkToolGUI.h" #include "mitkAdaptiveRegionGrowingTool.h" class QmitkStdMultiWidget; class DataNode; class QmitkAdaptiveRegionGrowingToolGUIControls; /*! * * \brief QmitkAdaptiveRegionGrowingToolGUI * * Adaptive Region Growing View class of the segmentation. * */ -class QmitkExt_EXPORT QmitkAdaptiveRegionGrowingToolGUI : public QmitkToolGUI +class SegmentationUI_EXPORT QmitkAdaptiveRegionGrowingToolGUI : public QmitkToolGUI { Q_OBJECT public: mitkClassMacro(QmitkAdaptiveRegionGrowingToolGUI, QmitkToolGUI); itkNewMacro(QmitkAdaptiveRegionGrowingToolGUI); QmitkAdaptiveRegionGrowingToolGUI(QWidget* parent=0); /** \brief Method to create the connections for the component. This Method is obligatory even if no connections is needed*/ virtual void CreateConnections(); ///** \brief Method to set the default data storage.*/ virtual void SetDataStorage(mitk::DataStorage* dataStorage); void SetMultiWidget(QmitkStdMultiWidget* multiWidget); void SetDataNodeNames(std::string labledSegmentation, std::string binaryImage, /*std::string vesselTree,*/ std::string surface, std::string seedPoint); void EnableControls(bool enable); void SetInputImageNode(mitk::DataNode* node); void Deactivated(); void Activated(); /** * @brief The created GUI from the .ui-File. This Attribute is obligatory */ Ui::QmitkAdaptiveRegionGrowingToolGUIControls m_Controls; protected slots: void SetSeedPointToggled(bool toggled); void RunSegmentation(); void ChangeLevelWindow(int newValue);//called, when the Level Window is changed via the slider in the ControlWidget //****called, when the slider-position is modified via the +/- buttons void IncreaseSlider(); void DecreaseSlider(); //*** void ConfirmSegmentation(); void UseVolumeRendering(bool on); void OnDefineThresholdBoundaries(bool); void SetLowerThresholdValue(double lowerThreshold); void SetUpperThresholdValue(double upperThreshold); void OnNewToolAssociated(mitk::Tool*); protected: mitk::AdaptiveRegionGrowingTool::Pointer m_RegionGrow3DTool; /** \brief Destructor. */ virtual ~QmitkAdaptiveRegionGrowingToolGUI(); //Pointer to the main widget to be able to reach the renderer QmitkStdMultiWidget* m_MultiWidget; mitk::DataStorage* m_DataStorage; mitk::DataNode::Pointer m_InputImageNode; void DeactivateSeedPointMode(); void ActivateSeedPointMode(); void OnPointAdded(); private: std::string m_NAMEFORORGIMAGE; std::string m_NAMEFORSEEDPOINT; std::string m_NAMEFORLABLEDSEGMENTATIONIMAGE; std::string m_NAMEFORBINARYIMAGE; std::string m_NAMEFORSURFACE; mitk::ScalarType m_LOWERTHRESHOLD; //Hounsfield value mitk::ScalarType m_UPPERTHRESHOLD; //Hounsfield value mitk::ScalarType m_SeedPointValueMean; void RemoveHelperNodes(); int m_DetectedLeakagePoint; bool m_CurrentRGDirectionIsUpwards; // defines fixed threshold (true = LOWERTHRESHOLD fixed, false = UPPERTHRESHOLD fixed) int m_SeedpointValue; bool m_SliderInitialized; bool m_UseVolumeRendering; bool m_UpdateSuggestedThreshold; float m_SuggestedThValue; long m_PointSetAddObserverTag; template < typename TPixel, unsigned int VImageDimension > void StartRegionGrowing( itk::Image< TPixel, VImageDimension >* itkImage, mitk::Geometry3D* imageGeometry, mitk::PointSet::PointType seedPoint ); template < typename TPixel, unsigned int VImageDimension > void ITKThresholding( itk::Image< TPixel, VImageDimension >* inputImage ); void InitializeLevelWindow(); void EnableVolumeRendering(bool enable); void UpdateVolumeRenderingThreshold(int thValue); }; #endif diff --git a/Modules/QmitkExt/QmitkAdaptiveRegionGrowingToolGUIControls.ui b/Modules/SegmentationUI/Qmitk/QmitkAdaptiveRegionGrowingToolGUIControls.ui similarity index 100% rename from Modules/QmitkExt/QmitkAdaptiveRegionGrowingToolGUIControls.ui rename to Modules/SegmentationUI/Qmitk/QmitkAdaptiveRegionGrowingToolGUIControls.ui diff --git a/Modules/QmitkExt/QmitkBinaryThresholdToolGUI.cpp b/Modules/SegmentationUI/Qmitk/QmitkBinaryThresholdToolGUI.cpp similarity index 98% rename from Modules/QmitkExt/QmitkBinaryThresholdToolGUI.cpp rename to Modules/SegmentationUI/Qmitk/QmitkBinaryThresholdToolGUI.cpp index a2caa10b5a..24161fe62a 100644 --- a/Modules/QmitkExt/QmitkBinaryThresholdToolGUI.cpp +++ b/Modules/SegmentationUI/Qmitk/QmitkBinaryThresholdToolGUI.cpp @@ -1,195 +1,195 @@ /*=================================================================== 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 "QmitkBinaryThresholdToolGUI.h" #include "QmitkNewSegmentationDialog.h" #include #include #include #include -MITK_TOOL_GUI_MACRO(QmitkExt_EXPORT, QmitkBinaryThresholdToolGUI, "") +MITK_TOOL_GUI_MACRO(SegmentationUI_EXPORT, QmitkBinaryThresholdToolGUI, "") QmitkBinaryThresholdToolGUI::QmitkBinaryThresholdToolGUI() :QmitkToolGUI(), m_Slider(NULL), m_Spinner(NULL), m_isFloat(false), m_RangeMin(0), m_RangeMax(0), m_ChangingSlider(false), m_ChangingSpinner(false) { // create the visible widgets QBoxLayout* mainLayout = new QVBoxLayout(this); QLabel* label = new QLabel( "Threshold :", this ); QFont f = label->font(); f.setBold(false); label->setFont( f ); mainLayout->addWidget(label); QBoxLayout* layout = new QHBoxLayout(); m_Spinner = new QDoubleSpinBox(); m_Spinner->setMaximum(20); m_Spinner->setMinimum(5); m_Spinner->setValue(1); connect(m_Spinner, SIGNAL(valueChanged(double)), this, SLOT(OnSpinnerValueChanged()) ); layout->addWidget(m_Spinner); //m_Slider = new QSlider( 5, 20, 1, 1, Qt::Horizontal, this ); m_Slider = new QSlider( Qt::Horizontal, this ); m_Slider->setMinimum(5); m_Slider->setMaximum(20); m_Slider->setPageStep(1); m_Slider->setValue(1); connect( m_Slider, SIGNAL(valueChanged(int)), this, SLOT(OnSliderValueChanged(int))); layout->addWidget( m_Slider ); QPushButton* okButton = new QPushButton("Confirm Segmentation", this); connect( okButton, SIGNAL(clicked()), this, SLOT(OnAcceptThresholdPreview())); okButton->setFont( f ); layout->addWidget( okButton ); mainLayout->addLayout(layout); connect( this, SIGNAL(NewToolAssociated(mitk::Tool*)), this, SLOT(OnNewToolAssociated(mitk::Tool*)) ); } QmitkBinaryThresholdToolGUI::~QmitkBinaryThresholdToolGUI() { // !!! if (m_BinaryThresholdTool.IsNotNull()) { m_BinaryThresholdTool->IntervalBordersChanged -= mitk::MessageDelegate3( this, &QmitkBinaryThresholdToolGUI::OnThresholdingIntervalBordersChanged ); m_BinaryThresholdTool->ThresholdingValueChanged -= mitk::MessageDelegate1( this, &QmitkBinaryThresholdToolGUI::OnThresholdingValueChanged ); } } void QmitkBinaryThresholdToolGUI::OnNewToolAssociated(mitk::Tool* tool) { if (m_BinaryThresholdTool.IsNotNull()) { m_BinaryThresholdTool->IntervalBordersChanged -= mitk::MessageDelegate3( this, &QmitkBinaryThresholdToolGUI::OnThresholdingIntervalBordersChanged ); m_BinaryThresholdTool->ThresholdingValueChanged -= mitk::MessageDelegate1( this, &QmitkBinaryThresholdToolGUI::OnThresholdingValueChanged ); } m_BinaryThresholdTool = dynamic_cast( tool ); if (m_BinaryThresholdTool.IsNotNull()) { m_BinaryThresholdTool->IntervalBordersChanged += mitk::MessageDelegate3( this, &QmitkBinaryThresholdToolGUI::OnThresholdingIntervalBordersChanged ); m_BinaryThresholdTool->ThresholdingValueChanged += mitk::MessageDelegate1( this, &QmitkBinaryThresholdToolGUI::OnThresholdingValueChanged ); } } void QmitkBinaryThresholdToolGUI::OnSpinnerValueChanged() { if (m_BinaryThresholdTool.IsNotNull()) { m_ChangingSpinner = true; double doubleVal = m_Spinner->value(); int intVal = this->DoubleToSliderInt(doubleVal); m_BinaryThresholdTool->SetThresholdValue( doubleVal ); if (m_ChangingSlider == false) m_Slider->setValue( intVal ); m_ChangingSpinner = false; } } void QmitkBinaryThresholdToolGUI::OnSliderValueChanged(int value) { if (m_BinaryThresholdTool.IsNotNull()) { m_ChangingSlider = true; double doubleVal = SliderIntToDouble(value); if (m_ChangingSpinner == false) m_Spinner->setValue(doubleVal); m_ChangingSlider = false; } } void QmitkBinaryThresholdToolGUI::OnAcceptThresholdPreview() { if (m_BinaryThresholdTool.IsNotNull()) { this->thresholdAccepted(); m_BinaryThresholdTool->AcceptCurrentThresholdValue(); } } void QmitkBinaryThresholdToolGUI::OnThresholdingIntervalBordersChanged(double lower, double upper, bool isFloat) { m_isFloat = isFloat; m_RangeMin = lower; m_RangeMax = upper; m_Spinner->setRange(lower, upper); if (!m_isFloat) { m_Slider->setRange(int(lower), int(upper)); m_Spinner->setDecimals(0); m_Spinner->setSingleStep(1); } else { m_Slider->setRange(0, 99); m_Spinner->setDecimals(2); m_Range = upper-lower; m_Spinner->setSingleStep(m_Range/100); } } void QmitkBinaryThresholdToolGUI::OnThresholdingValueChanged(double current) { m_Slider->setValue(DoubleToSliderInt(current)); m_Spinner->setValue(current); } double QmitkBinaryThresholdToolGUI::SliderIntToDouble(int val) { if (!m_isFloat) { return double(val); } else { return double(val*(m_Range)/100 + m_RangeMin); } } int QmitkBinaryThresholdToolGUI::DoubleToSliderInt(double val) { if (!m_isFloat) { return int(val); } else { int intVal = int( ((val-m_RangeMin) / m_Range)*100); return intVal; } } diff --git a/Modules/QmitkExt/QmitkBinaryThresholdToolGUI.h b/Modules/SegmentationUI/Qmitk/QmitkBinaryThresholdToolGUI.h similarity index 96% rename from Modules/QmitkExt/QmitkBinaryThresholdToolGUI.h rename to Modules/SegmentationUI/Qmitk/QmitkBinaryThresholdToolGUI.h index e102d69e6a..03170abd1d 100644 --- a/Modules/QmitkExt/QmitkBinaryThresholdToolGUI.h +++ b/Modules/SegmentationUI/Qmitk/QmitkBinaryThresholdToolGUI.h @@ -1,99 +1,99 @@ /*=================================================================== 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 QmitkBinaryThresholdToolGUI_h_Included #define QmitkBinaryThresholdToolGUI_h_Included #include "QmitkToolGUI.h" -#include "QmitkExtExports.h" +#include "SegmentationUIExports.h" #include "mitkBinaryThresholdTool.h" #include class QSlider; /** \ingroup org_mitk_gui_qt_interactivesegmentation_internal \brief GUI for mitk::BinaryThresholdTool. This GUI shows a slider to change the tool's threshold and an OK button to accept a preview for actual thresholding. There is only a slider for INT values in QT. So, if the working image has a float/double pixeltype, we need to convert the original float intensity into a respective int value for the slider. The slider range is then between 0 and 99. If the pixeltype is INT, then we do not need any conversion. Last contributor: $Author$ */ -class QmitkExt_EXPORT QmitkBinaryThresholdToolGUI : public QmitkToolGUI +class SegmentationUI_EXPORT QmitkBinaryThresholdToolGUI : public QmitkToolGUI { Q_OBJECT public: mitkClassMacro(QmitkBinaryThresholdToolGUI, QmitkToolGUI); itkNewMacro(QmitkBinaryThresholdToolGUI); void OnThresholdingIntervalBordersChanged(double lower, double upper, bool isFloat); void OnThresholdingValueChanged(double current); signals: /// \brief Emitted when threshold Accepted void thresholdAccepted(); /// \brief Emitted when threshold Canceled void thresholdCanceled(); public slots: protected slots: void OnNewToolAssociated(mitk::Tool*); void OnAcceptThresholdPreview(); /// \brief Called when Spinner value has changed. Consider: Spinner contains DOUBLE values void OnSpinnerValueChanged(); /// \brief Called when Slider value has changed. Consider: Slider contains INT values void OnSliderValueChanged(int value); protected: QmitkBinaryThresholdToolGUI(); virtual ~QmitkBinaryThresholdToolGUI(); /// \brief When Slider (int value) has changed, we need to convert it to a respective double value for the spinner double SliderIntToDouble(int val); /// \brief When Spinner (double value) has changed, we need to convert it to a respective int value for the slider int DoubleToSliderInt(double val); QSlider* m_Slider; QDoubleSpinBox* m_Spinner; /// \brief is image float or int? bool m_isFloat; double m_RangeMin; double m_RangeMax; double m_Range; /// \brief helper bool values to find out, which of the GUI elements has been touched by the user. bool m_ChangingSlider, m_ChangingSpinner; mitk::BinaryThresholdTool::Pointer m_BinaryThresholdTool; }; #endif diff --git a/Modules/QmitkExt/QmitkBinaryThresholdULToolGUI.cpp b/Modules/SegmentationUI/Qmitk/QmitkBinaryThresholdULToolGUI.cpp similarity index 98% rename from Modules/QmitkExt/QmitkBinaryThresholdULToolGUI.cpp rename to Modules/SegmentationUI/Qmitk/QmitkBinaryThresholdULToolGUI.cpp index 0bb1556c7a..8e7ba6cd38 100644 --- a/Modules/QmitkExt/QmitkBinaryThresholdULToolGUI.cpp +++ b/Modules/SegmentationUI/Qmitk/QmitkBinaryThresholdULToolGUI.cpp @@ -1,151 +1,151 @@ /*=================================================================== 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 "QmitkBinaryThresholdULToolGUI.h" #include "QmitkNewSegmentationDialog.h" #include #include #include #include -MITK_TOOL_GUI_MACRO(QmitkExt_EXPORT, QmitkBinaryThresholdULToolGUI, "") +MITK_TOOL_GUI_MACRO(SegmentationUI_EXPORT, QmitkBinaryThresholdULToolGUI, "") QmitkBinaryThresholdULToolGUI::QmitkBinaryThresholdULToolGUI() :QmitkToolGUI(), m_RangeSlider(NULL) { // create the visible widgets QBoxLayout* mainLayout = new QVBoxLayout(this); QLabel* label = new QLabel( "Threshold :", this ); QFont f = label->font(); f.setBold(false); label->setFont( f ); mainLayout->addWidget(label); QBoxLayout* layout = new QHBoxLayout(); m_LowerSpinner = new QSpinBox(); m_LowerSpinner->setMinimum(-2048); m_LowerSpinner->setMaximum(0); m_LowerSpinner->setValue(-2048); connect(m_LowerSpinner, SIGNAL(editingFinished()), this, SLOT(OnOneSpinnerChanged()) ); m_RangeSlider = new QxtSpanSlider(Qt::Horizontal, this ); m_RangeSlider->setMaximum(2048); m_RangeSlider->setMinimum(-2048); m_RangeSlider->setHandleMovementMode(QxtSpanSlider::NoOverlapping); m_UpperSpinner = new QSpinBox(); m_UpperSpinner->setMinimum(0); m_UpperSpinner->setMaximum(2048); m_UpperSpinner->setValue(2048); connect(m_UpperSpinner, SIGNAL(editingFinished()), this, SLOT(OnOneSpinnerChanged()) ); connect(m_RangeSlider, SIGNAL(spanChanged(int, int) ),this, SLOT( OnSpanChanged(int , int ) )); layout->addWidget(m_LowerSpinner); layout->addWidget(m_RangeSlider); layout->addWidget(m_UpperSpinner); mainLayout->addLayout(layout); QPushButton* okButton = new QPushButton("Ok", this); connect( okButton, SIGNAL(clicked()), this, SLOT(OnAcceptThresholdPreview())); okButton->setFont( f ); mainLayout->addWidget( okButton ); connect( this, SIGNAL(NewToolAssociated(mitk::Tool*)), this, SLOT(OnNewToolAssociated(mitk::Tool*)) ); } QmitkBinaryThresholdULToolGUI::~QmitkBinaryThresholdULToolGUI() { // !!! if (m_BinaryThresholdULTool.IsNotNull()) { m_BinaryThresholdULTool->IntervalBordersChanged -= mitk::MessageDelegate2( this, &QmitkBinaryThresholdULToolGUI::OnThresholdingIntervalBordersChanged ); m_BinaryThresholdULTool->ThresholdingValuesChanged -= mitk::MessageDelegate2( this, &QmitkBinaryThresholdULToolGUI::OnThresholdingValuesChanged ); } } void QmitkBinaryThresholdULToolGUI::OnNewToolAssociated(mitk::Tool* tool) { if (m_BinaryThresholdULTool.IsNotNull()) { m_BinaryThresholdULTool->IntervalBordersChanged -= mitk::MessageDelegate2( this, &QmitkBinaryThresholdULToolGUI::OnThresholdingIntervalBordersChanged ); m_BinaryThresholdULTool->ThresholdingValuesChanged -= mitk::MessageDelegate2( this, &QmitkBinaryThresholdULToolGUI::OnThresholdingValuesChanged ); } m_BinaryThresholdULTool = dynamic_cast( tool ); if (m_BinaryThresholdULTool.IsNotNull()) { m_BinaryThresholdULTool->IntervalBordersChanged += mitk::MessageDelegate2( this, &QmitkBinaryThresholdULToolGUI::OnThresholdingIntervalBordersChanged ); m_BinaryThresholdULTool->ThresholdingValuesChanged += mitk::MessageDelegate2( this, &QmitkBinaryThresholdULToolGUI::OnThresholdingValuesChanged ); } } void QmitkBinaryThresholdULToolGUI::OnAcceptThresholdPreview() { if (m_BinaryThresholdULTool.IsNotNull()) { m_BinaryThresholdULTool->AcceptCurrentThresholdValue(); } } void QmitkBinaryThresholdULToolGUI::OnThresholdingIntervalBordersChanged(int lower, int upper) { m_RangeSlider->setMaximum(upper); m_RangeSlider->setMinimum(lower); m_LowerSpinner->setMaximum(upper); m_LowerSpinner->setMinimum(lower); m_UpperSpinner->setMaximum(upper); m_UpperSpinner->setMinimum(lower); } void QmitkBinaryThresholdULToolGUI::OnThresholdingValuesChanged(int lower, int upper) { m_RangeSlider->setSpan(lower, upper); m_LowerSpinner->setValue(lower); m_UpperSpinner->setValue(upper); } void QmitkBinaryThresholdULToolGUI::OnSpanChanged(int lower, int upper) { if (upper < lower) { int tmp = upper; upper = lower; lower = tmp; } if (m_BinaryThresholdULTool.IsNotNull()) { m_BinaryThresholdULTool->SetThresholdValues(lower, upper); } if (m_LowerSpinner->value() != lower) m_LowerSpinner->setValue(lower); if (m_UpperSpinner->value() != upper) m_UpperSpinner->setValue(upper); } void QmitkBinaryThresholdULToolGUI::OnOneSpinnerChanged() { m_RangeSlider->setLowerValue(m_LowerSpinner->value()); m_RangeSlider->setUpperValue(m_UpperSpinner->value()); } diff --git a/Modules/QmitkExt/QmitkBinaryThresholdULToolGUI.h b/Modules/SegmentationUI/Qmitk/QmitkBinaryThresholdULToolGUI.h similarity index 93% rename from Modules/QmitkExt/QmitkBinaryThresholdULToolGUI.h rename to Modules/SegmentationUI/Qmitk/QmitkBinaryThresholdULToolGUI.h index f6fe4b7700..883db22603 100644 --- a/Modules/QmitkExt/QmitkBinaryThresholdULToolGUI.h +++ b/Modules/SegmentationUI/Qmitk/QmitkBinaryThresholdULToolGUI.h @@ -1,71 +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 QmitkBinaryThresholdULToolGUI_h_Included #define QmitkBinaryThresholdULToolGUI_h_Included #include "QmitkToolGUI.h" -#include "QmitkExtExports.h" +#include "SegmentationUIExports.h" #include "mitkBinaryThresholdULTool.h" #include #include /** \ingroup org_mitk_gui_qt_interactivesegmentation_internal \brief GUI for mitk::BinaryThresholdTool. This GUI shows a slider to change the tool's threshold and an OK button to accept a preview for actual thresholding. Last contributor: $Author$ */ -class QmitkExt_EXPORT QmitkBinaryThresholdULToolGUI : public QmitkToolGUI +class SegmentationUI_EXPORT QmitkBinaryThresholdULToolGUI : public QmitkToolGUI { Q_OBJECT public: mitkClassMacro(QmitkBinaryThresholdULToolGUI, QmitkToolGUI); itkNewMacro(QmitkBinaryThresholdULToolGUI); void OnThresholdingIntervalBordersChanged(int lower, int upper); void OnThresholdingValuesChanged(int lower, int upper); signals: public slots: protected slots: void OnNewToolAssociated(mitk::Tool*); void OnSpanChanged(int lower, int upper); void OnAcceptThresholdPreview(); void OnOneSpinnerChanged(); protected: QmitkBinaryThresholdULToolGUI(); virtual ~QmitkBinaryThresholdULToolGUI(); QxtSpanSlider *m_RangeSlider; QSpinBox* m_LowerSpinner; QSpinBox* m_UpperSpinner; mitk::BinaryThresholdULTool::Pointer m_BinaryThresholdULTool; }; #endif diff --git a/Modules/QmitkExt/QmitkCalculateGrayValueStatisticsToolGUI.cpp b/Modules/SegmentationUI/Qmitk/QmitkCalculateGrayValueStatisticsToolGUI.cpp similarity index 96% rename from Modules/QmitkExt/QmitkCalculateGrayValueStatisticsToolGUI.cpp rename to Modules/SegmentationUI/Qmitk/QmitkCalculateGrayValueStatisticsToolGUI.cpp index 97ac666bba..9c3ffe7208 100644 --- a/Modules/QmitkExt/QmitkCalculateGrayValueStatisticsToolGUI.cpp +++ b/Modules/SegmentationUI/Qmitk/QmitkCalculateGrayValueStatisticsToolGUI.cpp @@ -1,66 +1,66 @@ /*=================================================================== 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 "QmitkCalculateGrayValueStatisticsToolGUI.h" #include "QmitkCopyToClipBoardDialog.h" -MITK_TOOL_GUI_MACRO(QmitkExt_EXPORT, QmitkCalculateGrayValueStatisticsToolGUI, "") +MITK_TOOL_GUI_MACRO(SegmentationUI_EXPORT, QmitkCalculateGrayValueStatisticsToolGUI, "") QmitkCalculateGrayValueStatisticsToolGUI::QmitkCalculateGrayValueStatisticsToolGUI() :QmitkToolGUI() { connect( this, SIGNAL(NewToolAssociated(mitk::Tool*)), this, SLOT(OnNewToolAssociated(mitk::Tool*)) ); } QmitkCalculateGrayValueStatisticsToolGUI::~QmitkCalculateGrayValueStatisticsToolGUI() { if (m_CalculateGrayValueStatisticsTool.IsNotNull()) { m_CalculateGrayValueStatisticsTool->StatisticsCompleted -= mitk::MessageDelegate( this, &QmitkCalculateGrayValueStatisticsToolGUI::OnCalculationsDone ); } } void QmitkCalculateGrayValueStatisticsToolGUI::OnNewToolAssociated(mitk::Tool* tool) { if (m_CalculateGrayValueStatisticsTool.IsNotNull()) { m_CalculateGrayValueStatisticsTool->StatisticsCompleted -= mitk::MessageDelegate( this, &QmitkCalculateGrayValueStatisticsToolGUI::OnCalculationsDone ); } m_CalculateGrayValueStatisticsTool = dynamic_cast( tool ); if (m_CalculateGrayValueStatisticsTool.IsNotNull()) { m_CalculateGrayValueStatisticsTool->StatisticsCompleted += mitk::MessageDelegate( this, &QmitkCalculateGrayValueStatisticsToolGUI::OnCalculationsDone ); } } void QmitkCalculateGrayValueStatisticsToolGUI::OnCalculationsDone() { if (m_CalculateGrayValueStatisticsTool.IsNotNull()) { std::string report = m_CalculateGrayValueStatisticsTool->GetReport(); // one for linux users std::cout << report << std::endl; // one for window users QmitkCopyToClipBoardDialog* dialog = new QmitkCopyToClipBoardDialog( report.c_str(), NULL); dialog->show(); } } diff --git a/Modules/QmitkExt/QmitkCalculateGrayValueStatisticsToolGUI.h b/Modules/SegmentationUI/Qmitk/QmitkCalculateGrayValueStatisticsToolGUI.h similarity index 92% rename from Modules/QmitkExt/QmitkCalculateGrayValueStatisticsToolGUI.h rename to Modules/SegmentationUI/Qmitk/QmitkCalculateGrayValueStatisticsToolGUI.h index 4593cc6ee6..35630bfbbf 100644 --- a/Modules/QmitkExt/QmitkCalculateGrayValueStatisticsToolGUI.h +++ b/Modules/SegmentationUI/Qmitk/QmitkCalculateGrayValueStatisticsToolGUI.h @@ -1,63 +1,63 @@ /*=================================================================== 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 QmitkCalculateGrayValueStatisticsToolGUI_h_Included #define QmitkCalculateGrayValueStatisticsToolGUI_h_Included #include "QmitkToolGUI.h" -#include "QmitkExtExports.h" +#include "SegmentationUIExports.h" #include "mitkCalculateGrayValueStatisticsTool.h" /** \ingroup org_mitk_gui_qt_interactivesegmentation_internal \brief GUI for mitk::CalculateGrayValueStatisticsTool. Shows nothing. Only when the corresponding tool send a message that statistics are ready, this class pops up a window showing the results. Last contributor: $Author$ */ -class QmitkExt_EXPORT QmitkCalculateGrayValueStatisticsToolGUI : public QmitkToolGUI +class SegmentationUI_EXPORT QmitkCalculateGrayValueStatisticsToolGUI : public QmitkToolGUI { Q_OBJECT public: mitkClassMacro(QmitkCalculateGrayValueStatisticsToolGUI, QmitkToolGUI); itkNewMacro(QmitkCalculateGrayValueStatisticsToolGUI); /// Reacts to signals from mitk::CalculateGrayValueStatisticsTool void OnCalculationsDone(); signals: public slots: protected slots: /// Connected to signal from QmitkToolGUI. We remember the current tool here void OnNewToolAssociated(mitk::Tool*); protected: QmitkCalculateGrayValueStatisticsToolGUI(); virtual ~QmitkCalculateGrayValueStatisticsToolGUI(); mitk::CalculateGrayValueStatisticsTool::Pointer m_CalculateGrayValueStatisticsTool; }; #endif diff --git a/Modules/QmitkExt/QmitkCopyToClipBoardDialog.cpp b/Modules/SegmentationUI/Qmitk/QmitkCopyToClipBoardDialog.cpp similarity index 100% rename from Modules/QmitkExt/QmitkCopyToClipBoardDialog.cpp rename to Modules/SegmentationUI/Qmitk/QmitkCopyToClipBoardDialog.cpp diff --git a/Modules/QmitkExt/QmitkCopyToClipBoardDialog.h b/Modules/SegmentationUI/Qmitk/QmitkCopyToClipBoardDialog.h similarity index 90% rename from Modules/QmitkExt/QmitkCopyToClipBoardDialog.h rename to Modules/SegmentationUI/Qmitk/QmitkCopyToClipBoardDialog.h index 128a4346b1..892e75019d 100644 --- a/Modules/QmitkExt/QmitkCopyToClipBoardDialog.h +++ b/Modules/SegmentationUI/Qmitk/QmitkCopyToClipBoardDialog.h @@ -1,48 +1,48 @@ /*=================================================================== 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 QmitkCopyToClipBoardDialog_h_Included #define QmitkCopyToClipBoardDialog_h_Included #include -#include "QmitkExtExports.h" +#include "SegmentationUIExports.h" #include /** \brief Displays read-only QTextEdit. For output of any kind of information that might be copied into other applications. */ -class QmitkExt_EXPORT QmitkCopyToClipBoardDialog : public QDialog +class SegmentationUI_EXPORT QmitkCopyToClipBoardDialog : public QDialog { Q_OBJECT public: QmitkCopyToClipBoardDialog(const QString& text, QWidget* parent = 0, const char* name = 0); virtual ~QmitkCopyToClipBoardDialog(); signals: public slots: protected slots: protected: }; #endif diff --git a/Modules/QmitkExt/QmitkDrawPaintbrushToolGUI.cpp b/Modules/SegmentationUI/Qmitk/QmitkDrawPaintbrushToolGUI.cpp similarity index 89% rename from Modules/QmitkExt/QmitkDrawPaintbrushToolGUI.cpp rename to Modules/SegmentationUI/Qmitk/QmitkDrawPaintbrushToolGUI.cpp index ff1cf8d83c..8f30f5fc17 100644 --- a/Modules/QmitkExt/QmitkDrawPaintbrushToolGUI.cpp +++ b/Modules/SegmentationUI/Qmitk/QmitkDrawPaintbrushToolGUI.cpp @@ -1,28 +1,28 @@ /*=================================================================== 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 "QmitkDrawPaintbrushToolGUI.h" -MITK_TOOL_GUI_MACRO(QmitkExt_EXPORT, QmitkDrawPaintbrushToolGUI, "") +MITK_TOOL_GUI_MACRO(SegmentationUI_EXPORT, QmitkDrawPaintbrushToolGUI, "") QmitkDrawPaintbrushToolGUI::QmitkDrawPaintbrushToolGUI() { } QmitkDrawPaintbrushToolGUI::~QmitkDrawPaintbrushToolGUI() { } diff --git a/Modules/QmitkExt/QmitkDrawPaintbrushToolGUI.h b/Modules/SegmentationUI/Qmitk/QmitkDrawPaintbrushToolGUI.h similarity index 90% rename from Modules/QmitkExt/QmitkDrawPaintbrushToolGUI.h rename to Modules/SegmentationUI/Qmitk/QmitkDrawPaintbrushToolGUI.h index f751c0eff3..b2612cad5c 100644 --- a/Modules/QmitkExt/QmitkDrawPaintbrushToolGUI.h +++ b/Modules/SegmentationUI/Qmitk/QmitkDrawPaintbrushToolGUI.h @@ -1,55 +1,55 @@ /*=================================================================== 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 QmitkDrawPaintbrushToolGUI_h_Included #define QmitkDrawPaintbrushToolGUI_h_Included #include "QmitkPaintbrushToolGUI.h" -#include "QmitkExtExports.h" +#include "SegmentationUIExports.h" /** \ingroup org_mitk_gui_qt_interactivesegmentation_internal \brief GUI for mitk::PaintbrushTool. This GUI shows a slider to change the tool's threshold and an OK button to accept a preview for actual thresholding. Last contributor: $Author$ */ -class QmitkExt_EXPORT QmitkDrawPaintbrushToolGUI : public QmitkPaintbrushToolGUI +class SegmentationUI_EXPORT QmitkDrawPaintbrushToolGUI : public QmitkPaintbrushToolGUI { Q_OBJECT public: mitkClassMacro(QmitkDrawPaintbrushToolGUI, QmitkPaintbrushToolGUI); itkNewMacro(QmitkDrawPaintbrushToolGUI); virtual ~QmitkDrawPaintbrushToolGUI(); signals: public slots: protected slots: protected: QmitkDrawPaintbrushToolGUI(); }; #endif diff --git a/Modules/QmitkExt/QmitkErasePaintbrushToolGUI.cpp b/Modules/SegmentationUI/Qmitk/QmitkErasePaintbrushToolGUI.cpp similarity index 89% rename from Modules/QmitkExt/QmitkErasePaintbrushToolGUI.cpp rename to Modules/SegmentationUI/Qmitk/QmitkErasePaintbrushToolGUI.cpp index 583476391c..0fa887a2af 100644 --- a/Modules/QmitkExt/QmitkErasePaintbrushToolGUI.cpp +++ b/Modules/SegmentationUI/Qmitk/QmitkErasePaintbrushToolGUI.cpp @@ -1,28 +1,28 @@ /*=================================================================== 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 "QmitkErasePaintbrushToolGUI.h" -MITK_TOOL_GUI_MACRO(QmitkExt_EXPORT, QmitkErasePaintbrushToolGUI, "") +MITK_TOOL_GUI_MACRO(SegmentationUI_EXPORT, QmitkErasePaintbrushToolGUI, "") QmitkErasePaintbrushToolGUI::QmitkErasePaintbrushToolGUI() { } QmitkErasePaintbrushToolGUI::~QmitkErasePaintbrushToolGUI() { } diff --git a/Modules/QmitkExt/QmitkErasePaintbrushToolGUI.h b/Modules/SegmentationUI/Qmitk/QmitkErasePaintbrushToolGUI.h similarity index 90% rename from Modules/QmitkExt/QmitkErasePaintbrushToolGUI.h rename to Modules/SegmentationUI/Qmitk/QmitkErasePaintbrushToolGUI.h index f040dea4cf..795f209435 100644 --- a/Modules/QmitkExt/QmitkErasePaintbrushToolGUI.h +++ b/Modules/SegmentationUI/Qmitk/QmitkErasePaintbrushToolGUI.h @@ -1,54 +1,54 @@ /*=================================================================== 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 QmitkErasePaintbrushToolGUI_h_Included #define QmitkErasePaintbrushToolGUI_h_Included #include "QmitkPaintbrushToolGUI.h" -#include "QmitkExtExports.h" +#include "SegmentationUIExports.h" /** \ingroup org_mitk_gui_qt_interactivesegmentation_internal \brief GUI for mitk::PaintbrushTool. This GUI shows a slider to change the tool's threshold and an OK button to accept a preview for actual thresholding. Last contributor: $Author$ */ -class QmitkExt_EXPORT QmitkErasePaintbrushToolGUI : public QmitkPaintbrushToolGUI +class SegmentationUI_EXPORT QmitkErasePaintbrushToolGUI : public QmitkPaintbrushToolGUI { Q_OBJECT public: mitkClassMacro(QmitkErasePaintbrushToolGUI, QmitkPaintbrushToolGUI); itkNewMacro(QmitkErasePaintbrushToolGUI); signals: public slots: protected slots: protected: QmitkErasePaintbrushToolGUI(); virtual ~QmitkErasePaintbrushToolGUI(); }; #endif diff --git a/Modules/QmitkExt/QmitkFastMarchingTool3DGUI.cpp b/Modules/SegmentationUI/Qmitk/QmitkFastMarchingTool3DGUI.cpp similarity index 99% rename from Modules/QmitkExt/QmitkFastMarchingTool3DGUI.cpp rename to Modules/SegmentationUI/Qmitk/QmitkFastMarchingTool3DGUI.cpp index 6cf48ca2fc..ee09a3d292 100644 --- a/Modules/QmitkExt/QmitkFastMarchingTool3DGUI.cpp +++ b/Modules/SegmentationUI/Qmitk/QmitkFastMarchingTool3DGUI.cpp @@ -1,330 +1,330 @@ /*=================================================================== 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 "QmitkFastMarchingTool3DGUI.h" #include "QmitkNewSegmentationDialog.h" #include #include #include #include #include #include #include #include #include "mitkStepper.h" #include "mitkBaseRenderer.h" -MITK_TOOL_GUI_MACRO(QmitkExt_EXPORT, QmitkFastMarchingTool3DGUI, "") +MITK_TOOL_GUI_MACRO(SegmentationUI_EXPORT, QmitkFastMarchingTool3DGUI, "") QmitkFastMarchingTool3DGUI::QmitkFastMarchingTool3DGUI() :QmitkToolGUI(), m_TimeIsConnected(false) { this->setContentsMargins( 0, 0, 0, 0 ); // create the visible widgets QVBoxLayout *widgetLayout = new QVBoxLayout(this); widgetLayout->setContentsMargins(0, 0, 0, 0); QFont fntHelp; fntHelp.setBold(true); QLabel *lblHelp = new QLabel(this); lblHelp->setText("Press shift-click to add seeds repeatedly."); lblHelp->setFont(fntHelp); widgetLayout->addWidget(lblHelp); QGroupBox *gbControls = new QGroupBox(this); gbControls->setCheckable(false); gbControls->setTitle(" Tool Controls "); // create the visible widgets QVBoxLayout *vlayout = new QVBoxLayout(gbControls); vlayout->setContentsMargins(5, 5, 5, 5); // Sigma controls { QHBoxLayout *hlayout = new QHBoxLayout(); hlayout->setSpacing(2); QLabel *lbl = new QLabel(gbControls); lbl->setText("Sigma: "); hlayout->addWidget(lbl); QSpacerItem* sp2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); hlayout->addItem(sp2); vlayout->addItem(hlayout); } m_slSigma = new ctkSliderWidget(gbControls); m_slSigma->setMinimum(0.1); m_slSigma->setMaximum(5.0); m_slSigma->setPageStep(0.1); m_slSigma->setSingleStep(0.01); m_slSigma->setValue(1.0); m_slSigma->setDecimals(2); m_slSigma->setTracking(false); m_slSigma->setToolTip("The \"sigma\" parameter in the Gradient Magnitude filter."); connect( m_slSigma, SIGNAL(valueChanged(double)), this, SLOT(OnSigmaChanged(double))); vlayout->addWidget( m_slSigma ); // Alpha controls { QHBoxLayout *hlayout = new QHBoxLayout(); hlayout->setSpacing(2); QLabel *lbl = new QLabel(gbControls); lbl->setText("Alpha: "); hlayout->addWidget(lbl); QSpacerItem* sp2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); hlayout->addItem(sp2); vlayout->addItem(hlayout); } m_slAlpha = new ctkSliderWidget(gbControls); m_slAlpha->setMinimum(-10); m_slAlpha->setMaximum(0); m_slAlpha->setPageStep(0.1); m_slAlpha->setSingleStep(0.01); m_slAlpha->setValue(-2.5); m_slAlpha->setDecimals(2); m_slAlpha->setTracking(false); m_slAlpha->setToolTip("The \"alpha\" parameter in the Sigmoid mapping filter."); connect( m_slAlpha, SIGNAL(valueChanged(double)), this, SLOT(OnAlphaChanged(double))); vlayout->addWidget( m_slAlpha ); // Beta controls { QHBoxLayout *hlayout = new QHBoxLayout(); hlayout->setSpacing(2); QLabel *lbl = new QLabel(gbControls); lbl->setText("Beta: "); hlayout->addWidget(lbl); QSpacerItem* sp2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); hlayout->addItem(sp2); vlayout->addLayout(hlayout); } m_slBeta = new ctkSliderWidget(gbControls); m_slBeta->setMinimum(0); m_slBeta->setMaximum(100); m_slBeta->setPageStep(0.1); m_slBeta->setSingleStep(0.01); m_slBeta->setValue(3.5); m_slBeta->setDecimals(2); m_slBeta->setTracking(false); m_slBeta->setToolTip("The \"beta\" parameter in the Sigmoid mapping filter."); connect( m_slBeta, SIGNAL(valueChanged(double)), this, SLOT(OnBetaChanged(double))); vlayout->addWidget( m_slBeta ); // stopping value controls { QHBoxLayout *hlayout = new QHBoxLayout(); hlayout->setSpacing(2); QLabel *lbl = new QLabel(gbControls); lbl->setText("Stopping value: "); hlayout->addWidget(lbl); QSpacerItem* sp2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); hlayout->addItem(sp2); vlayout->addLayout(hlayout); } m_slStoppingValue = new ctkSliderWidget(gbControls); m_slStoppingValue->setMinimum(0); m_slStoppingValue->setMaximum(10000); m_slStoppingValue->setPageStep(10); m_slStoppingValue->setSingleStep(1); m_slStoppingValue->setValue(2000); m_slStoppingValue->setDecimals(0); m_slStoppingValue->setTracking(false); m_slStoppingValue->setToolTip("The \"stopping value\" parameter in the fast marching 3D algorithm"); connect( m_slStoppingValue, SIGNAL(valueChanged(double)), this, SLOT(OnStoppingValueChanged(double))); vlayout->addWidget( m_slStoppingValue ); // threshold controls { QHBoxLayout *hlayout = new QHBoxLayout(); hlayout->setSpacing(2); QLabel *lbl = new QLabel(gbControls); lbl->setText("Threshold: "); hlayout->addWidget(lbl); QSpacerItem* sp2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); hlayout->addItem(sp2); vlayout->addLayout(hlayout); } m_slwThreshold = new ctkRangeWidget(gbControls); m_slwThreshold->setMinimum(-100); m_slwThreshold->setMaximum(5000); m_slwThreshold->setMinimumValue(-100); m_slwThreshold->setMaximumValue(2000); m_slwThreshold->setDecimals(0); m_slwThreshold->setTracking(false); m_slwThreshold->setToolTip("The lower and upper thresholds for the final thresholding"); connect( m_slwThreshold, SIGNAL(valuesChanged(double, double)), this, SLOT(OnThresholdChanged(double, double))); vlayout->addWidget( m_slwThreshold ); widgetLayout->addWidget(gbControls); m_btClearSeeds = new QPushButton("Clear"); m_btClearSeeds->setToolTip("Clear current result and start over again"); widgetLayout->addWidget(m_btClearSeeds); connect( m_btClearSeeds, SIGNAL(clicked()), this, SLOT(OnClearSeeds()) ); m_btConfirm = new QPushButton("Accept"); m_btConfirm->setToolTip("Incorporate current result in your working session."); widgetLayout->addWidget(m_btConfirm); connect( m_btConfirm, SIGNAL(clicked()), this, SLOT(OnConfirmSegmentation()) ); connect( this, SIGNAL(NewToolAssociated(mitk::Tool*)), this, SLOT(OnNewToolAssociated(mitk::Tool*)) ); } QmitkFastMarchingTool3DGUI::~QmitkFastMarchingTool3DGUI() { if (m_FastMarchingTool.IsNotNull()) { m_FastMarchingTool->CurrentlyBusy -= mitk::MessageDelegate1( this, &QmitkFastMarchingTool3DGUI::BusyStateChanged ); } } void QmitkFastMarchingTool3DGUI::OnNewToolAssociated(mitk::Tool* tool) { if (m_FastMarchingTool.IsNotNull()) { m_FastMarchingTool->CurrentlyBusy -= mitk::MessageDelegate1( this, &QmitkFastMarchingTool3DGUI::BusyStateChanged ); } m_FastMarchingTool = dynamic_cast( tool ); if (m_FastMarchingTool.IsNotNull()) { m_FastMarchingTool->CurrentlyBusy += mitk::MessageDelegate1( this, &QmitkFastMarchingTool3DGUI::BusyStateChanged ); // set tool´s default values m_FastMarchingTool->SetLowerThreshold( this->m_slwThreshold->minimumValue()); m_FastMarchingTool->SetUpperThreshold( this->m_slwThreshold->maximumValue()); m_FastMarchingTool->SetStoppingValue( this->m_slStoppingValue->value()); m_FastMarchingTool->SetSigma( this->m_slSigma->value()); m_FastMarchingTool->SetAlpha( this->m_slAlpha->value()); m_FastMarchingTool->SetBeta( this->m_slBeta->value()); //listen to timestep change events mitk::BaseRenderer::Pointer renderer; renderer = mitk::BaseRenderer::GetInstance( mitk::BaseRenderer::GetRenderWindowByName("stdmulti.widget1") ); if (renderer.IsNotNull() && !m_TimeIsConnected) { new QmitkStepperAdapter(this, renderer->GetSliceNavigationController()->GetTime(), "stepper"); // connect(m_TimeStepper, SIGNAL(Refetch()), this, SLOT(Refetch())); m_TimeIsConnected = true; } } } void QmitkFastMarchingTool3DGUI::OnThresholdChanged(double lower, double upper) { if (m_FastMarchingTool.IsNotNull()) { m_FastMarchingTool->SetLowerThreshold( lower ); m_FastMarchingTool->SetUpperThreshold( upper ); m_FastMarchingTool->Update(); } } void QmitkFastMarchingTool3DGUI::OnBetaChanged(double value) { if (m_FastMarchingTool.IsNotNull()) { m_FastMarchingTool->SetBeta( value ); m_FastMarchingTool->Update(); } } void QmitkFastMarchingTool3DGUI::OnSigmaChanged(double value) { if (m_FastMarchingTool.IsNotNull()) { m_FastMarchingTool->SetSigma( value ); m_FastMarchingTool->Update(); } } void QmitkFastMarchingTool3DGUI::OnAlphaChanged(double value) { if (m_FastMarchingTool.IsNotNull()) { m_FastMarchingTool->SetAlpha( value ); m_FastMarchingTool->Update(); } } void QmitkFastMarchingTool3DGUI::OnStoppingValueChanged(double value) { if (m_FastMarchingTool.IsNotNull()) { m_FastMarchingTool->SetStoppingValue( value ); m_FastMarchingTool->Update(); } } void QmitkFastMarchingTool3DGUI::OnConfirmSegmentation() { if (m_FastMarchingTool.IsNotNull()) { m_FastMarchingTool->ConfirmSegmentation(); } } void QmitkFastMarchingTool3DGUI::SetStepper(mitk::Stepper *stepper) { this->m_TimeStepper = stepper; } void QmitkFastMarchingTool3DGUI::Refetch() { //event from image navigator recieved - timestep has changed m_FastMarchingTool->SetCurrentTimeStep(m_TimeStepper->GetPos()); } void QmitkFastMarchingTool3DGUI::OnClearSeeds() { //event from image navigator recieved - timestep has changed m_FastMarchingTool->ClearSeeds(); m_FastMarchingTool->Update(); } void QmitkFastMarchingTool3DGUI::BusyStateChanged(bool value) { if (value) QApplication::setOverrideCursor( QCursor(Qt::BusyCursor) ); else QApplication::restoreOverrideCursor(); } diff --git a/Modules/QmitkExt/QmitkFastMarchingTool3DGUI.h b/Modules/SegmentationUI/Qmitk/QmitkFastMarchingTool3DGUI.h similarity index 94% rename from Modules/QmitkExt/QmitkFastMarchingTool3DGUI.h rename to Modules/SegmentationUI/Qmitk/QmitkFastMarchingTool3DGUI.h index 5a6378ac7c..2369ec0963 100644 --- a/Modules/QmitkExt/QmitkFastMarchingTool3DGUI.h +++ b/Modules/SegmentationUI/Qmitk/QmitkFastMarchingTool3DGUI.h @@ -1,82 +1,82 @@ /*=================================================================== 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 QmitkFastMarchingTool3DGUI_h_Included #define QmitkFastMarchingTool3DGUI_h_Included #include "QmitkToolGUI.h" -#include "QmitkExtExports.h" +#include "SegmentationUIExports.h" #include "mitkFastMarchingTool3D.h" class ctkSliderWidget; class ctkRangeWidget; class QPushButton; #include "QmitkStepperAdapter.h" /** \ingroup org_mitk_gui_qt_interactivesegmentation_internal \brief GUI for mitk::FastMarchingTool. \sa mitk::FastMarchingTool */ -class QmitkExt_EXPORT QmitkFastMarchingTool3DGUI : public QmitkToolGUI +class SegmentationUI_EXPORT QmitkFastMarchingTool3DGUI : public QmitkToolGUI { Q_OBJECT public: mitkClassMacro(QmitkFastMarchingTool3DGUI, QmitkToolGUI); itkNewMacro(QmitkFastMarchingTool3DGUI); void OnThresholdChanged(int current); protected slots: void OnNewToolAssociated(mitk::Tool*); void OnThresholdChanged(double, double); void OnAlphaChanged(double); void OnBetaChanged(double); void OnSigmaChanged(double); void OnStoppingValueChanged(double); void OnConfirmSegmentation(); void Refetch(); void SetStepper(mitk::Stepper *); void OnClearSeeds(); protected: QmitkFastMarchingTool3DGUI(); virtual ~QmitkFastMarchingTool3DGUI(); void BusyStateChanged(bool); ctkRangeWidget* m_slwThreshold; ctkSliderWidget* m_slStoppingValue; ctkSliderWidget* m_slSigma; ctkSliderWidget* m_slAlpha; ctkSliderWidget* m_slBeta; QPushButton* m_btConfirm; QPushButton* m_btClearSeeds; mitk::FastMarchingTool3D::Pointer m_FastMarchingTool; bool m_TimeIsConnected; mitk::Stepper::Pointer m_TimeStepper; }; #endif diff --git a/Modules/QmitkExt/QmitkFastMarchingToolGUI.cpp b/Modules/SegmentationUI/Qmitk/QmitkFastMarchingToolGUI.cpp similarity index 98% rename from Modules/QmitkExt/QmitkFastMarchingToolGUI.cpp rename to Modules/SegmentationUI/Qmitk/QmitkFastMarchingToolGUI.cpp index 38659a057b..301ddeca20 100644 --- a/Modules/QmitkExt/QmitkFastMarchingToolGUI.cpp +++ b/Modules/SegmentationUI/Qmitk/QmitkFastMarchingToolGUI.cpp @@ -1,228 +1,228 @@ /*=================================================================== 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 "QmitkFastMarchingToolGUI.h" #include "QmitkNewSegmentationDialog.h" #include #include #include #include #include -MITK_TOOL_GUI_MACRO(QmitkExt_EXPORT, QmitkFastMarchingToolGUI, "") +MITK_TOOL_GUI_MACRO(SegmentationUI_EXPORT, QmitkFastMarchingToolGUI, "") QmitkFastMarchingToolGUI::QmitkFastMarchingToolGUI() :QmitkToolGUI() { this->setContentsMargins( 0, 0, 0, 0 ); // create the visible widgets QGridLayout *layout = new QGridLayout(this); /*StandardDeviation*/ QLabel* labelStandardDeviation = new QLabel("Alpha: "); layout->addWidget(labelStandardDeviation,0,0); m_StandardDeviationLabel = new QLabel("-1.0"); layout->addWidget(m_StandardDeviationLabel,0,2); m_StandardDeviationSlider = new QSlider( Qt::Horizontal); m_StandardDeviationSlider->setMinimum(-100); m_StandardDeviationSlider->setMaximum(0); m_StandardDeviationSlider->setPageStep(1); m_StandardDeviationSlider->setValue(-10); m_StandardDeviationSlider->setMaximumWidth(200); connect( m_StandardDeviationSlider, SIGNAL(valueChanged(int)), this, SLOT(OnStandardDeviationChanged(int))); layout->addWidget( m_StandardDeviationSlider,0,1); /*END StandardDeviation*/ /*Mu*/ QLabel* labelMu = new QLabel("Beta: "); layout->addWidget(labelMu,1,0); m_MuLabel = new QLabel("5.0"); layout->addWidget(m_MuLabel,1,2); m_MuSlider = new QSlider( Qt::Horizontal); m_MuSlider->setMinimum(0); m_MuSlider->setMaximum(1000); m_MuSlider->setPageStep(1); m_MuSlider->setValue(50); m_MuSlider->setMaximumWidth(200); connect( m_MuSlider, SIGNAL(valueChanged(int)), this, SLOT(OnMuChanged(int))); layout->addWidget( m_MuSlider,1,1); /*END Mu*/ /*StoppingValue*/ QLabel* labelStoppingValue = new QLabel("Stopping value: "); layout->addWidget(labelStoppingValue,2,0); m_StoppingValueLabel = new QLabel("50.0"); layout->addWidget(m_StoppingValueLabel,2,2); m_StoppingValueSlider = new QSlider( Qt::Horizontal); m_StoppingValueSlider->setMinimum(0); m_StoppingValueSlider->setMaximum(10000); m_StoppingValueSlider->setPageStep(1); m_StoppingValueSlider->setValue(500); m_StoppingValueSlider->setMaximumWidth(200); connect( m_StoppingValueSlider, SIGNAL(valueChanged(int)), this, SLOT(OnStoppingValueChanged(int))); layout->addWidget( m_StoppingValueSlider,2,1); /*END StoppingValue*/ /*Upperthreshold*/ QLabel* labelUpper = new QLabel("Upper Threshold: "); layout->addWidget(labelUpper,3,0); m_UpperThresholdLabel = new QLabel("100.0"); layout->addWidget(m_UpperThresholdLabel,3,2); m_UpperThresholdSlider = new QSlider( Qt::Horizontal); m_UpperThresholdSlider->setMinimum(0); m_UpperThresholdSlider->setMaximum(10000); m_UpperThresholdSlider->setPageStep(1); m_UpperThresholdSlider->setValue(1000); m_UpperThresholdSlider->setMaximumWidth(200); connect( m_UpperThresholdSlider, SIGNAL(valueChanged(int)), this, SLOT(OnUpperThresholdChanged(int))); layout->addWidget( m_UpperThresholdSlider,3,1); /*END Upperthreshold*/ /*LowerThreshold*/ QLabel* labelLower = new QLabel("Lower Threshold: "); layout->addWidget(labelLower,4,0); m_LowerThresholdLabel = new QLabel("0.0"); layout->addWidget(m_LowerThresholdLabel,4,2); m_LowerThresholdSlider = new QSlider( Qt::Horizontal); m_LowerThresholdSlider->setMinimum(-100); m_LowerThresholdSlider->setMaximum(100); m_LowerThresholdSlider->setPageStep(1); m_LowerThresholdSlider->setValue(0); m_LowerThresholdSlider->setMaximumWidth(200); connect( m_LowerThresholdSlider, SIGNAL(valueChanged(int)), this, SLOT(OnLowerThresholdChanged(int))); layout->addWidget( m_LowerThresholdSlider,4,1); /*END LowerThreshold*/ m_ConfirmButton = new QPushButton("Confirm Segmentation"); layout->addWidget(m_ConfirmButton, 6,0); connect( m_ConfirmButton, SIGNAL(clicked()), this, SLOT(OnConfirmSegmentation()) ); m_LivePreviewCheckBox = new QCheckBox("Live preview"); m_LivePreviewCheckBox->setChecked(false); m_LivePreviewCheckBox->setTristate(false); layout->addWidget(m_LivePreviewCheckBox, 5,0); connect( m_LivePreviewCheckBox, SIGNAL(stateChanged(int)), this, SLOT(OnLivePreviewCheckBoxChanged(int)) ); m_ClearSeedsButton = new QPushButton("Clear seeds"); layout->addWidget(m_ClearSeedsButton, 5,1); connect( m_ClearSeedsButton, SIGNAL(clicked()), this, SLOT(OnClearSeeds()) ); connect( this, SIGNAL(NewToolAssociated(mitk::Tool*)), this, SLOT(OnNewToolAssociated(mitk::Tool*)) ); } QmitkFastMarchingToolGUI::~QmitkFastMarchingToolGUI() { } void QmitkFastMarchingToolGUI::OnNewToolAssociated(mitk::Tool* tool) { m_FastMarchingTool = dynamic_cast( tool ); } void QmitkFastMarchingToolGUI::OnUpperThresholdChanged(int value) { if (m_FastMarchingTool.IsNotNull()) { m_FastMarchingTool->SetUpperThreshold( (float)value / 10.0 ); //visualize slider value m_UpperThresholdLabel->setText(QString("%1 ").arg(float(value)/10.0)); } } void QmitkFastMarchingToolGUI::OnLowerThresholdChanged(int value) { if (m_FastMarchingTool.IsNotNull()) { m_FastMarchingTool->SetLowerThreshold( (float)value / 10.0 ); //visualize slider value m_LowerThresholdLabel->setText(QString("%1 ").arg(float(value)/10.0)); } } void QmitkFastMarchingToolGUI::OnMuChanged(int value) { if (m_FastMarchingTool.IsNotNull()) { m_FastMarchingTool->SetMu( (float)value / 10.0 ); //visualize slider value m_MuLabel->setText(QString("%1 ").arg(float(value)/10.0)); } } void QmitkFastMarchingToolGUI::OnStandardDeviationChanged(int value) { if (m_FastMarchingTool.IsNotNull()) { m_FastMarchingTool->SetStandardDeviation( (float)value / 10.0 ); //visualize slider value m_StandardDeviationLabel->setText(QString("%1 ").arg(float(value)/10.0)); } } void QmitkFastMarchingToolGUI::OnStoppingValueChanged(int value) { if (m_FastMarchingTool.IsNotNull()) { m_FastMarchingTool->SetStoppingValue( (float)value / 10.0 ); //visualize slider value m_StoppingValueLabel->setText(QString("%1 ").arg(float(value)/10.0)); } } void QmitkFastMarchingToolGUI::OnConfirmSegmentation() { if (m_FastMarchingTool.IsNotNull()) { m_FastMarchingTool->ConfirmSegmentation(); } } void QmitkFastMarchingToolGUI::OnLivePreviewCheckBoxChanged(int value) { bool b(value); if (m_FastMarchingTool.IsNotNull()) { m_FastMarchingTool->SetLivePreviewEnabled(b); } } void QmitkFastMarchingToolGUI::OnClearSeeds() { m_FastMarchingTool->ClearSeeds(); } diff --git a/Modules/QmitkExt/QmitkFastMarchingToolGUI.h b/Modules/SegmentationUI/Qmitk/QmitkFastMarchingToolGUI.h similarity index 94% rename from Modules/QmitkExt/QmitkFastMarchingToolGUI.h rename to Modules/SegmentationUI/Qmitk/QmitkFastMarchingToolGUI.h index 8a241d99e1..3e293d972b 100644 --- a/Modules/QmitkExt/QmitkFastMarchingToolGUI.h +++ b/Modules/SegmentationUI/Qmitk/QmitkFastMarchingToolGUI.h @@ -1,89 +1,89 @@ /*=================================================================== 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 QmitkFastMarchingToolGUI_h_Included #define QmitkFastMarchingToolGUI_h_Included #include "QmitkToolGUI.h" -#include "QmitkExtExports.h" +#include "SegmentationUIExports.h" #include "mitkFastMarchingTool.h" class QSlider; class QLabel; class QFrame; class QPushButton; #include ; /** \ingroup org_mitk_gui_qt_interactivesegmentation_internal \brief GUI for mitk::FastMarchingTool. \sa mitk::FastMarchingTool */ -class QmitkExt_EXPORT QmitkFastMarchingToolGUI : public QmitkToolGUI +class SegmentationUI_EXPORT QmitkFastMarchingToolGUI : public QmitkToolGUI { Q_OBJECT public: mitkClassMacro(QmitkFastMarchingToolGUI, QmitkToolGUI); itkNewMacro(QmitkFastMarchingToolGUI); void OnThresholdChanged(int current); protected slots: void OnNewToolAssociated(mitk::Tool*); void OnUpperThresholdChanged(int value); void OnLowerThresholdChanged(int value); void OnMuChanged(int value); void OnStoppingValueChanged(int value); void OnStandardDeviationChanged(int value); void OnConfirmSegmentation(); void OnLivePreviewCheckBoxChanged(int value); void OnClearSeeds(); protected: QmitkFastMarchingToolGUI(); virtual ~QmitkFastMarchingToolGUI(); QSlider* m_UpperThresholdSlider; QLabel* m_UpperThresholdLabel; QSlider* m_LowerThresholdSlider; QLabel* m_LowerThresholdLabel; QSlider* m_StoppingValueSlider; QLabel* m_StoppingValueLabel; QSlider* m_MuSlider; QLabel* m_MuLabel; QSlider* m_StandardDeviationSlider; QLabel* m_StandardDeviationLabel; QPushButton* m_ConfirmButton; QPushButton* m_ClearSeedsButton; QCheckBox* m_LivePreviewCheckBox; mitk::FastMarchingTool::Pointer m_FastMarchingTool; }; #endif diff --git a/Modules/QmitkExt/QmitkLiveWireTool2DGUI.cpp b/Modules/SegmentationUI/Qmitk/QmitkLiveWireTool2DGUI.cpp similarity index 95% rename from Modules/QmitkExt/QmitkLiveWireTool2DGUI.cpp rename to Modules/SegmentationUI/Qmitk/QmitkLiveWireTool2DGUI.cpp index 727a82fca5..6b0f07cc9e 100644 --- a/Modules/QmitkExt/QmitkLiveWireTool2DGUI.cpp +++ b/Modules/SegmentationUI/Qmitk/QmitkLiveWireTool2DGUI.cpp @@ -1,63 +1,63 @@ /*=================================================================== 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 "QmitkLiveWireTool2DGUI.h" #include "QmitkNewSegmentationDialog.h" #include #include #include #include #include #include "mitkStepper.h" #include "mitkBaseRenderer.h" -MITK_TOOL_GUI_MACRO(QmitkExt_EXPORT, QmitkLiveWireTool2DGUI, "") +MITK_TOOL_GUI_MACRO(SegmentationUI_EXPORT, QmitkLiveWireTool2DGUI, "") QmitkLiveWireTool2DGUI::QmitkLiveWireTool2DGUI() :QmitkToolGUI() { this->setContentsMargins( 0, 0, 0, 0 ); // create the visible widgets QGridLayout *layout = new QGridLayout(this); m_ConfirmButton = new QPushButton("Confirm Segmentation"); layout->addWidget(m_ConfirmButton, 0,0); connect( m_ConfirmButton, SIGNAL(clicked()), this, SLOT(OnConfirmSegmentation()) ); connect( this, SIGNAL(NewToolAssociated(mitk::Tool*)), this, SLOT(OnNewToolAssociated(mitk::Tool*)) ); } QmitkLiveWireTool2DGUI::~QmitkLiveWireTool2DGUI() { } void QmitkLiveWireTool2DGUI::OnNewToolAssociated(mitk::Tool* tool) { m_LiveWireTool = dynamic_cast( tool ); } void QmitkLiveWireTool2DGUI::OnConfirmSegmentation() { if (m_LiveWireTool.IsNotNull()) { m_LiveWireTool->ConfirmSegmentation(); } } diff --git a/Modules/QmitkExt/QmitkLiveWireTool2DGUI.h b/Modules/SegmentationUI/Qmitk/QmitkLiveWireTool2DGUI.h similarity index 92% rename from Modules/QmitkExt/QmitkLiveWireTool2DGUI.h rename to Modules/SegmentationUI/Qmitk/QmitkLiveWireTool2DGUI.h index 0fc76d4c20..6ae78602cc 100644 --- a/Modules/QmitkExt/QmitkLiveWireTool2DGUI.h +++ b/Modules/SegmentationUI/Qmitk/QmitkLiveWireTool2DGUI.h @@ -1,62 +1,62 @@ /*=================================================================== 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 QmitkLiveWireTool2DGUI_h_Included #define QmitkLiveWireTool2DGUI_h_Included #include "QmitkToolGUI.h" -#include "QmitkExtExports.h" +#include "SegmentationUIExports.h" #include "mitkLiveWireTool2D.h" class QSlider; class QLabel; class QFrame; class QPushButton; #include #include "QmitkStepperAdapter.h" /** \ingroup org_mitk_gui_qt_interactivesegmentation_internal \brief GUI for mitk::LiveWireTool. \sa mitk::LiveWireTool2D */ -class QmitkExt_EXPORT QmitkLiveWireTool2DGUI : public QmitkToolGUI +class SegmentationUI_EXPORT QmitkLiveWireTool2DGUI : public QmitkToolGUI { Q_OBJECT public: mitkClassMacro(QmitkLiveWireTool2DGUI, QmitkToolGUI); itkNewMacro(QmitkLiveWireTool2DGUI); protected slots: void OnNewToolAssociated(mitk::Tool*); void OnConfirmSegmentation(); protected: QmitkLiveWireTool2DGUI(); virtual ~QmitkLiveWireTool2DGUI(); QPushButton* m_ConfirmButton; mitk::LiveWireTool2D::Pointer m_LiveWireTool; }; #endif diff --git a/Modules/QmitkExt/QmitkNewSegmentationDialog.cpp b/Modules/SegmentationUI/Qmitk/QmitkNewSegmentationDialog.cpp similarity index 100% rename from Modules/QmitkExt/QmitkNewSegmentationDialog.cpp rename to Modules/SegmentationUI/Qmitk/QmitkNewSegmentationDialog.cpp diff --git a/Modules/QmitkExt/QmitkNewSegmentationDialog.h b/Modules/SegmentationUI/Qmitk/QmitkNewSegmentationDialog.h similarity index 95% rename from Modules/QmitkExt/QmitkNewSegmentationDialog.h rename to Modules/SegmentationUI/Qmitk/QmitkNewSegmentationDialog.h index df7fd0dde8..e460009e04 100644 --- a/Modules/QmitkExt/QmitkNewSegmentationDialog.h +++ b/Modules/SegmentationUI/Qmitk/QmitkNewSegmentationDialog.h @@ -1,102 +1,102 @@ /*=================================================================== 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 QmitkNewSegmentationDialog_h_Included #define QmitkNewSegmentationDialog_h_Included #include "mitkColorProperty.h" -#include "QmitkExtExports.h" +#include "SegmentationUIExports.h" #include #include class QLabel; class QLineEdit; class Q3ListBox; class QPushButton; #include /** \brief Dialog for QmitkInteractiveSegmentation. \ingroup ToolManagerEtAl \ingroup Widgets This dialog is used to ask a user about the type of a newly created segmentation and a name for it. \warning Will not create a new organ type in the OrganTypeProperty. Client has to do that. Last contribution by $Author: maleike $. */ -class QmitkExt_EXPORT QmitkNewSegmentationDialog : public QDialog +class SegmentationUI_EXPORT QmitkNewSegmentationDialog : public QDialog { Q_OBJECT public: QmitkNewSegmentationDialog(QWidget* parent = 0); virtual ~QmitkNewSegmentationDialog(); const QString GetSegmentationName(); const char* GetOrganType(); mitk::Color GetColor(); void SetSuggestionList(QStringList organColorList); signals: public slots: void setPrompt( const QString& prompt ); void setSegmentationName( const QString& name ); protected slots: void onAcceptClicked(); void onNewOrganNameChanged(const QString&); void onColorBtnClicked(); void onColorChange(const QString& completedWord); protected: QLabel* lblPrompt; Q3ListBox* lstOrgans; QLineEdit* edtName; QPushButton* btnColor; QPushButton* btnOk; QLineEdit* edtNewOrgan; QString selectedOrgan; bool newOrganEntry; QColor m_Color; QCompleter* completer; QString m_SegmentationName; QStringList organList; QList colorList; }; #endif diff --git a/Modules/QmitkExt/QmitkOtsuTool3DGUI.cpp b/Modules/SegmentationUI/Qmitk/QmitkOtsuTool3DGUI.cpp similarity index 79% rename from Modules/QmitkExt/QmitkOtsuTool3DGUI.cpp rename to Modules/SegmentationUI/Qmitk/QmitkOtsuTool3DGUI.cpp index 6237a572c4..bff14dadd7 100644 --- a/Modules/QmitkExt/QmitkOtsuTool3DGUI.cpp +++ b/Modules/SegmentationUI/Qmitk/QmitkOtsuTool3DGUI.cpp @@ -1,113 +1,126 @@ /*=================================================================== 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 "QmitkOtsuTool3DGUI.h" #include "QmitkNewSegmentationDialog.h" #include #include #include #include #include +#include -MITK_TOOL_GUI_MACRO(QmitkExt_EXPORT, QmitkOtsuTool3DGUI, "") +MITK_TOOL_GUI_MACRO(SegmentationUI_EXPORT, QmitkOtsuTool3DGUI, "") QmitkOtsuTool3DGUI::QmitkOtsuTool3DGUI() :QmitkToolGUI(), m_NumberOfRegions(0) { m_Controls.setupUi(this); connect( m_Controls.previewButton, SIGNAL(clicked()), this, SLOT(OnSpinboxValueAccept())); connect( m_Controls.m_selectionListWidget, SIGNAL(itemSelectionChanged()), this, SLOT(OnItemSelectionChanged())); connect( m_Controls.m_ConfSegButton, SIGNAL(clicked()), this, SLOT(OnSegmentationRegionAccept())); connect( this, SIGNAL(NewToolAssociated(mitk::Tool*)), this, SLOT(OnNewToolAssociated(mitk::Tool*)) ); } QmitkOtsuTool3DGUI::~QmitkOtsuTool3DGUI() { } void QmitkOtsuTool3DGUI::OnItemSelectionChanged() { if (m_OtsuTool3DTool.IsNotNull()) { // TODO update preview of region m_OtsuTool3DTool->UpdateBinaryPreview(m_Controls.m_selectionListWidget->currentItem()->text().toInt()); if ( !m_Controls.m_selectionListWidget->selectedItems().empty() ) { m_Controls.m_ConfSegButton->setEnabled( true ); } else { m_Controls.m_ConfSegButton->setEnabled( false ); } } } void QmitkOtsuTool3DGUI::OnNewToolAssociated(mitk::Tool* tool) { m_OtsuTool3DTool = dynamic_cast( tool ); } void QmitkOtsuTool3DGUI::OnSegmentationRegionAccept() { if (m_OtsuTool3DTool.IsNotNull() && m_Controls.m_selectionListWidget->currentItem() != NULL) { m_OtsuTool3DTool->ConfirmSegmentation(); m_OtsuTool3DTool->Deactivated(); } } void QmitkOtsuTool3DGUI::OnSpinboxValueAccept() { if( m_NumberOfRegions == m_Controls.m_Spinbox->value() ) return; if (m_OtsuTool3DTool.IsNotNull()) { try { this->setCursor(Qt::WaitCursor); m_NumberOfRegions = m_Controls.m_Spinbox->value(); m_OtsuTool3DTool->RunSegmentation( m_NumberOfRegions ); this->setCursor(Qt::ArrowCursor); + int proceed; + + QMessageBox* messageBox = new QMessageBox(QMessageBox::Question, NULL, "The otsu segmentation computation may take several minutes depending on the number of Regions you selected. Proceed anyway?", QMessageBox::Ok | QMessageBox::Cancel); + if (m_Spinbox->value() >= 5) + { + proceed = messageBox->exec(); + if (proceed != QMessageBox::Ok) return; + } + m_OtsuTool3DTool->RunSegmentation( m_Spinbox->value() ); } catch( ... ) { this->setCursor(Qt::ArrowCursor); + QMessageBox* messageBox = new QMessageBox(QMessageBox::Critical, NULL, "itkOtsuFilter error: image dimension must be in {2, 3} and no RGB images can be handled."); + messageBox->exec(); + delete messageBox; return; } //insert regions into widget QString itemName; QListWidgetItem* item; m_Controls.m_selectionListWidget->clear(); for(int i=0; ivalue(); ++i) { itemName = QString::number(i); item = new QListWidgetItem(itemName); m_Controls.m_selectionListWidget->addItem(item); } } } void QmitkOtsuTool3DGUI::OnVolumePreviewChecked(int state) { if (state == 1) { } } diff --git a/Modules/QmitkExt/QmitkOtsuTool3DGUI.h b/Modules/SegmentationUI/Qmitk/QmitkOtsuTool3DGUI.h similarity index 93% rename from Modules/QmitkExt/QmitkOtsuTool3DGUI.h rename to Modules/SegmentationUI/Qmitk/QmitkOtsuTool3DGUI.h index 190d8f093c..4ca52696ac 100644 --- a/Modules/QmitkExt/QmitkOtsuTool3DGUI.h +++ b/Modules/SegmentationUI/Qmitk/QmitkOtsuTool3DGUI.h @@ -1,75 +1,75 @@ /*=================================================================== 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 QmitkOtsuTool3DGUI_h_Included #define QmitkOtsuTool3DGUI_h_Included #include "QmitkToolGUI.h" -#include "QmitkExtExports.h" +#include "SegmentationUIExports.h" #include "mitkOtsuTool3D.h" #include #include #include "ui_QmitkOtsuToolWidgetControls.h" class QSpinBox; class QLabel; /** \ingroup org_mitk_gui_qt_interactivesegmentation_internal \brief GUI for mitk::. \sa mitk:: This GUI shows ... Last contributor: $Author$ */ -class QmitkExt_EXPORT QmitkOtsuTool3DGUI : public QmitkToolGUI +class SegmentationUI_EXPORT QmitkOtsuTool3DGUI : public QmitkToolGUI { Q_OBJECT public: mitkClassMacro(QmitkOtsuTool3DGUI, QmitkToolGUI); itkNewMacro(QmitkOtsuTool3DGUI); signals: public slots: protected slots: void OnNewToolAssociated(mitk::Tool*); void OnSpinboxValueAccept(); void OnSegmentationRegionAccept(); void OnItemSelectionChanged(); void OnVolumePreviewChecked(int); protected: QmitkOtsuTool3DGUI(); virtual ~QmitkOtsuTool3DGUI(); mitk::OtsuTool3D::Pointer m_OtsuTool3DTool; Ui_QmitkOtsuToolWidgetControls m_Controls; int m_NumberOfRegions; }; #endif diff --git a/Modules/QmitkExt/QmitkPaintbrushToolGUI.cpp b/Modules/SegmentationUI/Qmitk/QmitkPaintbrushToolGUI.cpp similarity index 100% rename from Modules/QmitkExt/QmitkPaintbrushToolGUI.cpp rename to Modules/SegmentationUI/Qmitk/QmitkPaintbrushToolGUI.cpp diff --git a/Modules/QmitkExt/QmitkPaintbrushToolGUI.h b/Modules/SegmentationUI/Qmitk/QmitkPaintbrushToolGUI.h similarity index 92% rename from Modules/QmitkExt/QmitkPaintbrushToolGUI.h rename to Modules/SegmentationUI/Qmitk/QmitkPaintbrushToolGUI.h index 66af0a7536..134156c243 100644 --- a/Modules/QmitkExt/QmitkPaintbrushToolGUI.h +++ b/Modules/SegmentationUI/Qmitk/QmitkPaintbrushToolGUI.h @@ -1,71 +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 QmitkPaintbrushToolGUI_h_Included #define QmitkPaintbrushToolGUI_h_Included #include "QmitkToolGUI.h" -#include "QmitkExtExports.h" +#include "SegmentationUIExports.h" #include "mitkPaintbrushTool.h" class QSlider; class QLabel; class QFrame; /** \ingroup org_mitk_gui_qt_interactivesegmentation_internal \brief GUI for mitk::PaintbrushTool. \sa mitk::PaintbrushTool This GUI shows a slider to change the pen's size. Last contributor: $Author$ */ -class QmitkExt_EXPORT QmitkPaintbrushToolGUI : public QmitkToolGUI +class SegmentationUI_EXPORT QmitkPaintbrushToolGUI : public QmitkToolGUI { Q_OBJECT public: mitkClassMacro(QmitkPaintbrushToolGUI, QmitkToolGUI); void OnSizeChanged(int current); signals: public slots: protected slots: void OnNewToolAssociated(mitk::Tool*); void OnSliderValueChanged(int value); void VisualizePaintbrushSize(int size); protected: QmitkPaintbrushToolGUI(); virtual ~QmitkPaintbrushToolGUI(); QSlider* m_Slider; QLabel* m_SizeLabel; QFrame* m_Frame; mitk::PaintbrushTool::Pointer m_PaintbrushTool; }; #endif diff --git a/Modules/QmitkExt/QmitkPixelManipulationToolGUI.cpp b/Modules/SegmentationUI/Qmitk/QmitkPixelManipulationToolGUI.cpp similarity index 100% rename from Modules/QmitkExt/QmitkPixelManipulationToolGUI.cpp rename to Modules/SegmentationUI/Qmitk/QmitkPixelManipulationToolGUI.cpp diff --git a/Modules/QmitkExt/QmitkPixelManipulationToolGUI.h b/Modules/SegmentationUI/Qmitk/QmitkPixelManipulationToolGUI.h similarity index 100% rename from Modules/QmitkExt/QmitkPixelManipulationToolGUI.h rename to Modules/SegmentationUI/Qmitk/QmitkPixelManipulationToolGUI.h diff --git a/Modules/QmitkExt/QmitkRegionGrow3DToolGUI.cpp b/Modules/SegmentationUI/Qmitk/QmitkRegionGrow3DToolGUI.cpp similarity index 100% rename from Modules/QmitkExt/QmitkRegionGrow3DToolGUI.cpp rename to Modules/SegmentationUI/Qmitk/QmitkRegionGrow3DToolGUI.cpp diff --git a/Modules/QmitkExt/QmitkRegionGrow3DToolGUI.h b/Modules/SegmentationUI/Qmitk/QmitkRegionGrow3DToolGUI.h similarity index 100% rename from Modules/QmitkExt/QmitkRegionGrow3DToolGUI.h rename to Modules/SegmentationUI/Qmitk/QmitkRegionGrow3DToolGUI.h diff --git a/Modules/QmitkExt/QmitkSlicesInterpolator.cpp b/Modules/SegmentationUI/Qmitk/QmitkSlicesInterpolator.cpp similarity index 100% rename from Modules/QmitkExt/QmitkSlicesInterpolator.cpp rename to Modules/SegmentationUI/Qmitk/QmitkSlicesInterpolator.cpp diff --git a/Modules/QmitkExt/QmitkSlicesInterpolator.h b/Modules/SegmentationUI/Qmitk/QmitkSlicesInterpolator.h similarity index 98% rename from Modules/QmitkExt/QmitkSlicesInterpolator.h rename to Modules/SegmentationUI/Qmitk/QmitkSlicesInterpolator.h index a7c86cc9db..f475d0a4e4 100644 --- a/Modules/QmitkExt/QmitkSlicesInterpolator.h +++ b/Modules/SegmentationUI/Qmitk/QmitkSlicesInterpolator.h @@ -1,317 +1,317 @@ /*=================================================================== 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 QmitkSlicesInterpolator_h_Included #define QmitkSlicesInterpolator_h_Included #include "mitkSliceNavigationController.h" -#include "QmitkExtExports.h" +#include "SegmentationUIExports.h" #include "mitkSegmentationInterpolationController.h" #include "mitkDataNode.h" #include "mitkDataStorage.h" #include "mitkWeakPointer.h" #include "mitkSurfaceInterpolationController.h" #include #include #include #include #include #include #include #include "mitkVtkRepresentationProperty.h" #include "vtkProperty.h" //For running 3D interpolation in background #include #include #include #include namespace mitk { class ToolManager; class PlaneGeometry; } class QmitkStdMultiWidget; class QPushButton; //Enhancement for 3D Interpolation //class QRadioButton; //class QGroupBox; //class QCheckBox; /** \brief GUI for slices interpolation. \ingroup ToolManagerEtAl \ingroup Widgets \sa QmitkInteractiveSegmentation \sa mitk::SegmentationInterpolation There is a separate page describing the general design of QmitkInteractiveSegmentation: \ref QmitkInteractiveSegmentationTechnicalPage While mitk::SegmentationInterpolation does the bookkeeping of interpolation (keeping track of which slices contain how much segmentation) and the algorithmic work, QmitkSlicesInterpolator is responsible to watch the GUI, to notice, which slice is currently visible. It triggers generation of interpolation suggestions and also triggers acception of suggestions. \todo show/hide feedback on demand Last contributor: $Author: maleike $ */ -class QmitkExt_EXPORT QmitkSlicesInterpolator : public QWidget +class SegmentationUI_EXPORT QmitkSlicesInterpolator : public QWidget { Q_OBJECT public: QmitkSlicesInterpolator(QWidget* parent = 0, const char* name = 0); /** To be called once before real use. */ void Initialize(mitk::ToolManager* toolManager, QmitkStdMultiWidget* multiWidget); virtual ~QmitkSlicesInterpolator(); void SetDataStorage( mitk::DataStorage& storage ); mitk::DataStorage* GetDataStorage(); /** Just public because it is called by itk::Commands. You should not need to call this. */ void OnToolManagerWorkingDataModified(); /** Just public because it is called by itk::Commands. You should not need to call this. */ void OnToolManagerReferenceDataModified(); /** Just public because it is called by itk::Commands. You should not need to call this. */ void OnAxialTimeChanged(itk::Object* sender, const itk::EventObject&); /** Just public because it is called by itk::Commands. You should not need to call this. */ DEPRECATED(void OnTransversalTimeChanged(itk::Object* sender, const itk::EventObject&)); /** Just public because it is called by itk::Commands. You should not need to call this. */ void OnSagittalTimeChanged(itk::Object* sender, const itk::EventObject&); /** Just public because it is called by itk::Commands. You should not need to call this. */ void OnFrontalTimeChanged(itk::Object* sender, const itk::EventObject&); /** Just public because it is called by itk::Commands. You should not need to call this. */ void OnAxialSliceChanged(const itk::EventObject&); /** Just public because it is called by itk::Commands. You should not need to call this. */ DEPRECATED(void OnTransversalSliceChanged(const itk::EventObject&)); /** Just public because it is called by itk::Commands. You should not need to call this. */ void OnSagittalSliceChanged(const itk::EventObject&); /** Just public because it is called by itk::Commands. You should not need to call this. */ void OnFrontalSliceChanged(const itk::EventObject&); /** Just public because it is called by itk::Commands. You should not need to call this. */ void OnInterpolationInfoChanged(const itk::EventObject&); /** Just public because it is called by itk::Commands. You should not need to call this. */ void OnSurfaceInterpolationInfoChanged(const itk::EventObject&); signals: void SignalRememberContourPositions(bool); void SignalShowMarkerNodes(bool); public slots: /** Call this from the outside to enable/disable interpolation */ void EnableInterpolation(bool); void Enable3DInterpolation(bool); /** Call this from the outside to accept all interpolations */ void FinishInterpolation(int windowID = -1); protected slots: /** Reaction to button clicks. */ void OnAcceptInterpolationClicked(); /* Opens popup to ask about which orientation should be interpolated */ void OnAcceptAllInterpolationsClicked(); /* Reaction to button clicks */ void OnAccept3DInterpolationClicked(); /* * Will trigger interpolation for all slices in given orientation (called from popup menu of OnAcceptAllInterpolationsClicked) */ void OnAcceptAllPopupActivated(QAction* action); /** Called on activation/deactivation */ void OnInterpolationActivated(bool); void On3DInterpolationActivated(bool); void OnInterpolationMethodChanged(int index); void OnMultiWidgetDeleted(QObject*); //Enhancement for 3D interpolation void On2DInterpolationEnabled(bool); void On3DInterpolationEnabled(bool); void OnInterpolationDisabled(bool); void OnShowMarkers(bool); void Run3DInterpolation(); void OnSurfaceInterpolationFinished(); void StartUpdateInterpolationTimer(); void StopUpdateInterpolationTimer(); void ChangeSurfaceColor(); protected: const std::map createActionToSliceDimension(); const std::map ACTION_TO_SLICEDIMENSION; void AcceptAllInterpolations(unsigned int windowID); /** Retrieves the currently selected PlaneGeometry from a SlicedGeometry3D that is generated by a SliceNavigationController and calls Interpolate to further process this PlaneGeometry into an interpolation. \param e is a actually a mitk::SliceNavigationController::GeometrySliceEvent, sent by a SliceNavigationController \param windowID is 2 for axial, 1 for frontal, 0 for sagittal (similar to sliceDimension in other methods) */ bool TranslateAndInterpolateChangedSlice(const itk::EventObject& e, unsigned int windowID); /** Given a PlaneGeometry, this method figures out which slice of the first working image (of the associated ToolManager) should be interpolated. The actual work is then done by our SegmentationInterpolation object. */ void Interpolate( mitk::PlaneGeometry* plane, unsigned int timeStep ); //void InterpolateSurface(); /** Called internally to update the interpolation suggestion. Finds out about the focused render window and requests an interpolation. */ void UpdateVisibleSuggestion(); /** * Tries to figure out the slice position and orientation for a given render window. * \param windowID is 2 for axial, 1 for frontal, 0 for sagittal (similar to sliceDimension in other methods) * \return false if orientation could not be determined */ bool GetSliceForWindowsID(unsigned windowID, int& sliceDimension, int& sliceIndex); void SetCurrentContourListID(); void Show3DInterpolationResult(bool); void HideAllInterpolationControls(); void Show2DInterpolationControls(bool show); void Show3DInterpolationControls(bool show); mitk::SegmentationInterpolationController::Pointer m_Interpolator; mitk::SurfaceInterpolationController::Pointer m_SurfaceInterpolator; QmitkStdMultiWidget* m_MultiWidget; mitk::ToolManager* m_ToolManager; bool m_Initialized; unsigned int TSliceObserverTag; unsigned int SSliceObserverTag; unsigned int FSliceObserverTag; unsigned int TTimeObserverTag; unsigned int STimeObserverTag; unsigned int FTimeObserverTag; unsigned int InterpolationInfoChangedObserverTag; unsigned int SurfaceInterpolationInfoChangedObserverTag; QGroupBox* m_GroupBoxEnableExclusiveInterpolationMode; QComboBox* m_CmbInterpolation; QPushButton* m_BtnApply2D; QPushButton* m_BtnApplyForAllSlices2D; QPushButton* m_BtnApply3D; QCheckBox* m_ChkShowPositionNodes; mitk::DataNode::Pointer m_FeedbackNode; mitk::DataNode::Pointer m_InterpolatedSurfaceNode; mitk::DataNode::Pointer m_3DContourNode; mitk::Image* m_Segmentation; unsigned int m_LastSliceDimension; unsigned int m_LastSliceIndex; std::vector m_TimeStep; // current time step of the render windows bool m_2DInterpolationEnabled; bool m_3DInterpolationEnabled; //unsigned int m_CurrentListID; mitk::WeakPointer m_DataStorage; QFuture m_Future; QFutureWatcher m_Watcher; QTimer* m_Timer; }; #endif diff --git a/Modules/QmitkExt/QmitkToolGUI.cpp b/Modules/SegmentationUI/Qmitk/QmitkToolGUI.cpp similarity index 100% rename from Modules/QmitkExt/QmitkToolGUI.cpp rename to Modules/SegmentationUI/Qmitk/QmitkToolGUI.cpp diff --git a/Modules/QmitkExt/QmitkToolGUI.h b/Modules/SegmentationUI/Qmitk/QmitkToolGUI.h similarity index 92% rename from Modules/QmitkExt/QmitkToolGUI.h rename to Modules/SegmentationUI/Qmitk/QmitkToolGUI.h index b6d32e1f7f..85be4d8407 100644 --- a/Modules/QmitkExt/QmitkToolGUI.h +++ b/Modules/SegmentationUI/Qmitk/QmitkToolGUI.h @@ -1,68 +1,68 @@ /*=================================================================== 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 QmitkToolGUI_h_Included #define QmitkToolGUI_h_Included #include -#include "QmitkExtExports.h" +#include "SegmentationUIExports.h" #include "mitkCommon.h" #include "mitkTool.h" /** \brief Base class for GUIs belonging to mitk::Tool classes. \ingroup org_mitk_gui_qt_interactivesegmentation Created through ITK object factory. TODO May be changed to a toolkit specific way later? Last contributor: $Author$ */ -class QmitkExt_EXPORT QmitkToolGUI : public QWidget, public itk::Object +class SegmentationUI_EXPORT QmitkToolGUI : public QWidget, public itk::Object { Q_OBJECT public: mitkClassMacro(QmitkToolGUI, itk::Object); void SetTool( mitk::Tool* tool ); // just make sure ITK won't take care of anything (especially not destruction) virtual void Register() const; virtual void UnRegister() const; virtual void SetReferenceCount(int); virtual ~QmitkToolGUI(); signals: void NewToolAssociated( mitk::Tool* ); public slots: protected slots: protected: mitk::Tool::Pointer m_Tool; virtual void BusyStateChanged(bool) {}; }; #endif diff --git a/Modules/QmitkExt/QmitkToolGUIArea.cpp b/Modules/SegmentationUI/Qmitk/QmitkToolGUIArea.cpp similarity index 100% rename from Modules/QmitkExt/QmitkToolGUIArea.cpp rename to Modules/SegmentationUI/Qmitk/QmitkToolGUIArea.cpp diff --git a/Modules/QmitkExt/QmitkToolGUIArea.h b/Modules/SegmentationUI/Qmitk/QmitkToolGUIArea.h similarity index 91% rename from Modules/QmitkExt/QmitkToolGUIArea.h rename to Modules/SegmentationUI/Qmitk/QmitkToolGUIArea.h index 565bbeb7b4..b436986a1a 100644 --- a/Modules/QmitkExt/QmitkToolGUIArea.h +++ b/Modules/SegmentationUI/Qmitk/QmitkToolGUIArea.h @@ -1,51 +1,51 @@ /*=================================================================== 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 QmitkToolGUIArea_h_Included #define QmitkToolGUIArea_h_Included #include "mitkCommon.h" -#include "QmitkExtExports.h" +#include "SegmentationUIExports.h" #include /** \brief Dummy class for putting into a GUI (mainly using Qt Designer). This class is nothing more than a QWidget. It is good for use with QmitkToolSelectionBox as a place to display GUIs for active tools. Last contributor: $Author$ */ -class QmitkExt_EXPORT QmitkToolGUIArea : public QWidget +class SegmentationUI_EXPORT QmitkToolGUIArea : public QWidget { Q_OBJECT public: QmitkToolGUIArea( QWidget* parent = 0, Qt::WFlags f = 0 ); virtual ~QmitkToolGUIArea(); signals: public slots: protected slots: protected: }; #endif diff --git a/Modules/QmitkExt/QmitkToolReferenceDataSelectionBox.cpp b/Modules/SegmentationUI/Qmitk/QmitkToolReferenceDataSelectionBox.cpp similarity index 100% rename from Modules/QmitkExt/QmitkToolReferenceDataSelectionBox.cpp rename to Modules/SegmentationUI/Qmitk/QmitkToolReferenceDataSelectionBox.cpp diff --git a/Modules/QmitkExt/QmitkToolReferenceDataSelectionBox.h b/Modules/SegmentationUI/Qmitk/QmitkToolReferenceDataSelectionBox.h similarity index 96% rename from Modules/QmitkExt/QmitkToolReferenceDataSelectionBox.h rename to Modules/SegmentationUI/Qmitk/QmitkToolReferenceDataSelectionBox.h index 5cca9399f2..1b88ca4aac 100644 --- a/Modules/QmitkExt/QmitkToolReferenceDataSelectionBox.h +++ b/Modules/SegmentationUI/Qmitk/QmitkToolReferenceDataSelectionBox.h @@ -1,128 +1,128 @@ /*=================================================================== 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 QmitkToolReferenceDataSelectionBox_h_Included #define QmitkToolReferenceDataSelectionBox_h_Included #include "mitkToolManager.h" -#include "QmitkExtExports.h" +#include "SegmentationUIExports.h" #include "mitkDataStorage.h" #include #include class QmitkDataStorageComboBox; /** \brief Display the data selection of a ToolManager. \sa mitk::ToolManager \sa mitk::DataStorage \ingroup ToolManagerEtAl \ingroup Widgets There is a separate page describing the general design of QmitkInteractiveSegmentation: \ref QmitkInteractiveSegmentationTechnicalPage Shows the reference data of a ToolManager in a segmentation setting. The reference image can be selected from a combobox, where all images of the scene are listed. $Author: maleike $ */ -class QmitkExt_EXPORT QmitkToolReferenceDataSelectionBox : public QWidget +class SegmentationUI_EXPORT QmitkToolReferenceDataSelectionBox : public QWidget { Q_OBJECT public: /** * \brief What kind of items should be displayed. * * Every mitk::Tool holds a NodePredicateBase object, telling the kind of data that this * tool will successfully work with. There are two ways that this list box deals with * these predicates. * * DEFAULT is: list data if ANY one of the displayed tools' predicate matches. * Other option: list data if ALL one of the displayed tools' predicate matches */ enum DisplayMode { ListDataIfAllToolsMatch, ListDataIfAnyToolMatches}; QmitkToolReferenceDataSelectionBox(QWidget* parent = 0, mitk::DataStorage* storage = 0); virtual ~QmitkToolReferenceDataSelectionBox(); mitk::DataStorage* GetDataStorage(); void SetDataStorage(mitk::DataStorage& storage); /// initialization with a data storage object void Initialize(mitk::DataStorage*); void UpdateDataDisplay(); mitk::ToolManager* GetToolManager(); void SetToolManager(mitk::ToolManager&); // no NULL pointer allowed here, a manager is required void OnToolManagerReferenceDataModified(); /** * \brief No brief description. * * Should be called to restrict the number of tools that are * evaluated to build up the list. Default is to ask all tools for their predicate, by * setting the 'groups' string this can be restricted to certain groups of tools * or single tools. */ void SetToolGroupsForFiltering(const std::string& groups); /** * \brief How the list contents is determined. * * See also documentation of DisplayMode. * * \sa DisplayMode */ void SetDisplayMode( DisplayMode mode ); signals: void ReferenceNodeSelected(const mitk::DataNode*); protected slots: void OnReferenceDataSelected(const mitk::DataNode* node); void EnsureOnlyReferenceImageIsVisibile(); protected: mitk::DataStorage::SetOfObjects::ConstPointer GetAllPossibleReferenceImages(); mitk::NodePredicateBase::ConstPointer GetAllPossibleReferenceImagesPredicate(); mitk::ToolManager::Pointer m_ToolManager; QmitkDataStorageComboBox* m_ReferenceDataSelectionBox; bool m_SelfCall; DisplayMode m_DisplayMode; std::string m_ToolGroupsForFiltering; QVBoxLayout* m_Layout; }; #endif diff --git a/Modules/QmitkExt/QmitkToolRoiDataSelectionBox.cpp b/Modules/SegmentationUI/Qmitk/QmitkToolRoiDataSelectionBox.cpp similarity index 100% rename from Modules/QmitkExt/QmitkToolRoiDataSelectionBox.cpp rename to Modules/SegmentationUI/Qmitk/QmitkToolRoiDataSelectionBox.cpp diff --git a/Modules/QmitkExt/QmitkToolRoiDataSelectionBox.h b/Modules/SegmentationUI/Qmitk/QmitkToolRoiDataSelectionBox.h similarity index 94% rename from Modules/QmitkExt/QmitkToolRoiDataSelectionBox.h rename to Modules/SegmentationUI/Qmitk/QmitkToolRoiDataSelectionBox.h index e5fc367b2c..74f91cdb3a 100644 --- a/Modules/QmitkExt/QmitkToolRoiDataSelectionBox.h +++ b/Modules/SegmentationUI/Qmitk/QmitkToolRoiDataSelectionBox.h @@ -1,80 +1,80 @@ /*=================================================================== 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 QMITK_TOOLROIDATASELECTIONBOX_H #define QMITK_TOOLROIDATASELECTIONBOX_H -#include "QmitkExtExports.h" +#include "SegmentationUIExports.h" #include "mitkToolManager.h" #include "QmitkBoundingObjectWidget.h" #include /** \brief Widget for defining a ROI inside the Interactive Segmentation Framwork \ingroup ToolManagerEtAl \ingroup Widgets Allows to define a Region of interest (ROI) either by existing segmentations or by bounding objects. Selection is possible via a combobox, listing all available segmentations. Item "bounding objects" activates the \ref QmitkBoundingObjectWidget. */ -class QmitkExt_EXPORT QmitkToolRoiDataSelectionBox : public QWidget +class SegmentationUI_EXPORT QmitkToolRoiDataSelectionBox : public QWidget { Q_OBJECT public: QmitkToolRoiDataSelectionBox(QWidget* parent = 0, mitk::DataStorage* storage = 0); virtual ~QmitkToolRoiDataSelectionBox(); mitk::DataStorage* GetDataStorage(); void SetDataStorage(mitk::DataStorage& storage); mitk::ToolManager* GetToolManager(); void SetToolManager(mitk::ToolManager& manager); void OnToolManagerRoiDataModified(); void DataStorageChanged(const mitk::DataNode* node ); mitk::ToolManager::DataVectorType GetSelection(); void UpdateComboBoxData(); void setEnabled(bool); signals: void RoiDataSelected(const mitk::DataNode* node); protected slots: void OnRoiDataSelectionChanged(const QString& name); void OnRoiDataSelectionChanged(); protected: QmitkBoundingObjectWidget* m_boundingObjectWidget; QComboBox* m_segmentationComboBox; mitk::ToolManager::Pointer m_ToolManager; bool m_SelfCall; mitk::DataNode::Pointer m_lastSelection; QString m_lastSelectedName; }; #endif diff --git a/Modules/QmitkExt/QmitkToolSelectionBox.cpp b/Modules/SegmentationUI/Qmitk/QmitkToolSelectionBox.cpp similarity index 97% rename from Modules/QmitkExt/QmitkToolSelectionBox.cpp rename to Modules/SegmentationUI/Qmitk/QmitkToolSelectionBox.cpp index 094690d650..25bb909d65 100755 --- a/Modules/QmitkExt/QmitkToolSelectionBox.cpp +++ b/Modules/SegmentationUI/Qmitk/QmitkToolSelectionBox.cpp @@ -1,683 +1,698 @@ /*=================================================================== 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 MBILOG_ENABLE_DEBUG 1 #include "QmitkToolSelectionBox.h" #include "QmitkToolGUI.h" #include "mitkBaseRenderer.h" #include #include #include #include #include #include #include #include +#include "mitkModuleResource.h" +#include "mitkModuleResourceStream.h" + QmitkToolSelectionBox::QmitkToolSelectionBox(QWidget* parent, mitk::DataStorage* storage) :QWidget(parent), m_SelfCall(false), m_DisplayedGroups("default"), m_LayoutColumns(2), m_ShowNames(true), m_AutoShowNamesWidth(0), m_GenerateAccelerators(false), m_ToolGUIWidget(NULL), m_LastToolGUI(NULL), m_ToolButtonGroup(NULL), m_ButtonLayout(NULL), m_EnabledMode(EnabledWithReferenceAndWorkingDataVisible) { QFont currentFont = QWidget::font(); currentFont.setBold(true); QWidget::setFont( currentFont ); m_ToolManager = mitk::ToolManager::New( storage ); // muellerm // QButtonGroup m_ToolButtonGroup = new QButtonGroup(this); // some features of QButtonGroup m_ToolButtonGroup->setExclusive( false ); // mutually exclusive toggle buttons RecreateButtons(); QWidget::setContentsMargins(0, 0, 0, 0); if ( layout() != NULL ) { layout()->setContentsMargins(0, 0, 0, 0); } // reactions to signals connect( m_ToolButtonGroup, SIGNAL(buttonClicked(int)), this, SLOT(toolButtonClicked(int)) ); // reactions to ToolManager events m_ToolManager->ActiveToolChanged += mitk::MessageDelegate( this, &QmitkToolSelectionBox::OnToolManagerToolModified ); m_ToolManager->ReferenceDataChanged += mitk::MessageDelegate( this, &QmitkToolSelectionBox::OnToolManagerReferenceDataModified ); m_ToolManager->WorkingDataChanged += mitk::MessageDelegate( this, &QmitkToolSelectionBox::OnToolManagerWorkingDataModified ); // show active tool SetOrUnsetButtonForActiveTool(); QWidget::setEnabled( false ); } QmitkToolSelectionBox::~QmitkToolSelectionBox() { m_ToolManager->ActiveToolChanged -= mitk::MessageDelegate( this, &QmitkToolSelectionBox::OnToolManagerToolModified ); m_ToolManager->ReferenceDataChanged -= mitk::MessageDelegate( this, &QmitkToolSelectionBox::OnToolManagerReferenceDataModified ); m_ToolManager->WorkingDataChanged -= mitk::MessageDelegate( this, &QmitkToolSelectionBox::OnToolManagerWorkingDataModified ); } void QmitkToolSelectionBox::SetEnabledMode(EnabledMode mode) { m_EnabledMode = mode; SetGUIEnabledAccordingToToolManagerState(); } mitk::ToolManager* QmitkToolSelectionBox::GetToolManager() { return m_ToolManager; } void QmitkToolSelectionBox::SetToolManager(mitk::ToolManager& newManager) // no NULL pointer allowed here, a manager is required { // say bye to the old manager m_ToolManager->ActiveToolChanged -= mitk::MessageDelegate( this, &QmitkToolSelectionBox::OnToolManagerToolModified ); m_ToolManager->ReferenceDataChanged -= mitk::MessageDelegate( this, &QmitkToolSelectionBox::OnToolManagerReferenceDataModified ); m_ToolManager->WorkingDataChanged -= mitk::MessageDelegate( this, &QmitkToolSelectionBox::OnToolManagerWorkingDataModified ); if ( QWidget::isEnabled() ) { m_ToolManager->UnregisterClient(); } m_ToolManager = &newManager; RecreateButtons(); // greet the new one m_ToolManager->ActiveToolChanged += mitk::MessageDelegate( this, &QmitkToolSelectionBox::OnToolManagerToolModified ); m_ToolManager->ReferenceDataChanged += mitk::MessageDelegate( this, &QmitkToolSelectionBox::OnToolManagerReferenceDataModified ); m_ToolManager->WorkingDataChanged += mitk::MessageDelegate( this, &QmitkToolSelectionBox::OnToolManagerWorkingDataModified ); if ( QWidget::isEnabled() ) { m_ToolManager->RegisterClient(); } // ask the new one what the situation is like SetOrUnsetButtonForActiveTool(); } void QmitkToolSelectionBox::toolButtonClicked(int id) { if ( !QWidget::isEnabled() ) return; // this method could be triggered from the constructor, when we are still disabled MITK_DEBUG << "toolButtonClicked(" << id << "): id translates to tool ID " << m_ToolIDForButtonID[id]; //QToolButton* toolButton = dynamic_cast( Q3ButtonGroup::find(id) ); QToolButton* toolButton = dynamic_cast( m_ToolButtonGroup->buttons().at(id) ); if (toolButton) { if ( (m_ButtonIDForToolID.find( m_ToolManager->GetActiveToolID() ) != m_ButtonIDForToolID.end()) // if we have this tool in our box && (m_ButtonIDForToolID[ m_ToolManager->GetActiveToolID() ] == id) ) // the tool corresponding to this button is already active { // disable this button, disable all tools // mmueller toolButton->setChecked(false); m_ToolManager->ActivateTool(-1); // disable everything } else { // enable the corresponding tool m_SelfCall = true; m_ToolManager->ActivateTool( m_ToolIDForButtonID[id] ); m_SelfCall = false; } } } void QmitkToolSelectionBox::OnToolManagerToolModified() { SetOrUnsetButtonForActiveTool(); } void QmitkToolSelectionBox::SetOrUnsetButtonForActiveTool() { // we want to emit a signal in any case, whether we selected ourselves or somebody else changes "our" tool manager. --> emit before check on m_SelfCall int id = m_ToolManager->GetActiveToolID(); // don't emit signal for shape model tools bool emitSignal = true; mitk::Tool* tool = m_ToolManager->GetActiveTool(); if(tool && std::string(tool->GetGroup()) == "organ_segmentation") emitSignal = false; if(emitSignal) emit ToolSelected(id); // delete old GUI (if any) if ( m_LastToolGUI && m_ToolGUIWidget ) { if (m_ToolGUIWidget->layout()) { m_ToolGUIWidget->layout()->removeWidget(m_LastToolGUI); } //m_LastToolGUI->reparent(NULL, QPoint(0,0)); // TODO: reparent <-> setParent, Daniel fragen m_LastToolGUI->setParent(0); delete m_LastToolGUI; // will hopefully notify parent and layouts m_LastToolGUI = NULL; QLayout* layout = m_ToolGUIWidget->layout(); if (layout) { layout->activate(); } } QToolButton* toolButton(NULL); //mitk::Tool* tool = m_ToolManager->GetActiveTool(); if (m_ButtonIDForToolID.find(id) != m_ButtonIDForToolID.end()) // if this tool is in our box { //toolButton = dynamic_cast( Q3ButtonGroup::find( m_ButtonIDForToolID[id] ) ); toolButton = dynamic_cast( m_ToolButtonGroup->buttons().at( m_ButtonIDForToolID[id] ) ); } if ( toolButton ) { // mmueller // uncheck all other buttons QAbstractButton* tmpBtn = 0; QList::iterator it; for(int i=0; i < m_ToolButtonGroup->buttons().size(); ++i) { tmpBtn = m_ToolButtonGroup->buttons().at(i); if(tmpBtn != toolButton) dynamic_cast( tmpBtn )->setChecked(false); } toolButton->setChecked(true); if (m_ToolGUIWidget && tool) { // create and reparent new GUI (if any) itk::Object::Pointer possibleGUI = tool->GetGUI("Qmitk", "GUI").GetPointer(); // prefix and postfix QmitkToolGUI* gui = dynamic_cast( possibleGUI.GetPointer() ); //! m_LastToolGUI = gui; if (gui) { gui->SetTool( tool ); // mmueller //gui->reparent(m_ToolGUIWidget, gui->geometry().topLeft(), true ); gui->setParent(m_ToolGUIWidget); gui->move(gui->geometry().topLeft()); gui->show(); QLayout* layout = m_ToolGUIWidget->layout(); if (!layout) { layout = new QVBoxLayout( m_ToolGUIWidget ); } if (layout) { // mmueller layout->addWidget( gui ); //layout->add( gui ); layout->activate(); } } } } else { // disable all buttons QToolButton* selectedToolButton = dynamic_cast( m_ToolButtonGroup->checkedButton() ); //QToolButton* selectedToolButton = dynamic_cast( Q3ButtonGroup::find( Q3ButtonGroup::selectedId() ) ); if (selectedToolButton) { // mmueller selectedToolButton->setChecked(false); //selectedToolButton->setOn(false); } } } void QmitkToolSelectionBox::OnToolManagerReferenceDataModified() { if (m_SelfCall) return; MITK_DEBUG << "OnToolManagerReferenceDataModified()"; SetGUIEnabledAccordingToToolManagerState(); } void QmitkToolSelectionBox::OnToolManagerWorkingDataModified() { if (m_SelfCall) return; MITK_DEBUG << "OnToolManagerWorkingDataModified()"; SetGUIEnabledAccordingToToolManagerState(); } /** Implementes the logic, which decides, when tools are activated/deactivated. */ void QmitkToolSelectionBox::SetGUIEnabledAccordingToToolManagerState() { mitk::DataNode* referenceNode = m_ToolManager->GetReferenceData(0); mitk::DataNode* workingNode = m_ToolManager->GetWorkingData(0); //MITK_DEBUG << this->name() << ": SetGUIEnabledAccordingToToolManagerState: referenceNode " << (void*)referenceNode << " workingNode " << (void*)workingNode << " isVisible() " << isVisible(); bool enabled = true; switch ( m_EnabledMode ) { default: case EnabledWithReferenceAndWorkingDataVisible: enabled = referenceNode && workingNode && referenceNode->IsVisible(mitk::BaseRenderer::GetInstance( mitk::BaseRenderer::GetRenderWindowByName("stdmulti.widget1"))) && workingNode->IsVisible(mitk::BaseRenderer::GetInstance( mitk::BaseRenderer::GetRenderWindowByName("stdmulti.widget1"))) && isVisible(); break; case EnabledWithReferenceData: enabled = referenceNode && isVisible(); break; case EnabledWithWorkingData: enabled = workingNode && isVisible(); break; case AlwaysEnabled: enabled = isVisible(); break; } if ( QWidget::isEnabled() == enabled ) return; // nothing to change QWidget::setEnabled( enabled ); if (enabled) { m_ToolManager->RegisterClient(); int id = m_ToolManager->GetActiveToolID(); emit ToolSelected(id); } else { m_ToolManager->ActivateTool(-1); m_ToolManager->UnregisterClient(); emit ToolSelected(-1); } } /** External enableization... */ void QmitkToolSelectionBox::setEnabled( bool enable ) { QWidget::setEnabled(enable); SetGUIEnabledAccordingToToolManagerState(); } void QmitkToolSelectionBox::RecreateButtons() { if (m_ToolManager.IsNull()) return; /* // remove all buttons that are there QObjectList *l = Q3ButtonGroup::queryList( "QButton" ); QObjectListIt it( *l ); // iterate over all buttons QObject *obj; while ( (obj = it.current()) != 0 ) { ++it; QButton* button = dynamic_cast(obj); if (button) { Q3ButtonGroup::remove(button); delete button; } } delete l; // delete the list, not the objects */ // mmueller Qt4 impl QList l = m_ToolButtonGroup->buttons(); // remove all buttons that are there QList::iterator it; QAbstractButton * btn; for(it=l.begin(); it!=l.end();++it) { btn = *it; m_ToolButtonGroup->removeButton(btn); //this->removeChild(btn); delete btn; } // end mmueller Qt4 impl mitk::ToolManager::ToolVectorTypeConst allPossibleTools = m_ToolManager->GetTools(); mitk::ToolManager::ToolVectorTypeConst allTools; typedef std::pair< std::string::size_type, const mitk::Tool* > SortPairType; typedef std::priority_queue< SortPairType > SortedToolQueueType; SortedToolQueueType toolPositions; // clear and sort all tools // step one: find name/group of all tools in m_DisplayedGroups string. remember these positions for all tools. for ( mitk::ToolManager::ToolVectorTypeConst::const_iterator iter = allPossibleTools.begin(); iter != allPossibleTools.end(); ++iter) { const mitk::Tool* tool = *iter; std::string::size_type namePos = m_DisplayedGroups.find( std::string("'") + tool->GetName() + "'" ); std::string::size_type groupPos = m_DisplayedGroups.find( std::string("'") + tool->GetGroup() + "'" ); if ( !m_DisplayedGroups.empty() && namePos == std::string::npos && groupPos == std::string::npos ) continue; // skip if ( m_DisplayedGroups.empty() && std::string(tool->GetName()).length() > 0 ) { namePos = static_cast (tool->GetName()[0]); } SortPairType thisPair = std::make_pair( namePos < groupPos ? namePos : groupPos, *iter ); toolPositions.push( thisPair ); } // step two: sort tools according to previously found positions in m_DisplayedGroups MITK_DEBUG << "Sorting order of tools (lower number --> earlier in button group)"; while ( !toolPositions.empty() ) { SortPairType thisPair = toolPositions.top(); MITK_DEBUG << "Position " << thisPair.first << " : " << thisPair.second->GetName(); allTools.push_back( thisPair.second ); toolPositions.pop(); } std::reverse( allTools.begin(), allTools.end() ); MITK_DEBUG << "Sorted tools:"; for ( mitk::ToolManager::ToolVectorTypeConst::const_iterator iter = allTools.begin(); iter != allTools.end(); ++iter) { MITK_DEBUG << (*iter)->GetName(); } // try to change layout... bad? //Q3GroupBox::setColumnLayout ( m_LayoutColumns, Qt::Horizontal ); // mmueller using gridlayout instead of Q3GroupBox //this->setLayout(0); if(m_ButtonLayout == NULL) m_ButtonLayout = new QGridLayout; /*else delete m_ButtonLayout;*/ int row(0); int column(-1); int currentButtonID(0); m_ButtonIDForToolID.clear(); m_ToolIDForButtonID.clear(); QToolButton* button = 0; MITK_DEBUG << "Creating buttons for tools"; // fill group box with buttons for ( mitk::ToolManager::ToolVectorTypeConst::const_iterator iter = allTools.begin(); iter != allTools.end(); ++iter) { const mitk::Tool* tool = *iter; int currentToolID( m_ToolManager->GetToolID( tool ) ); ++column; // new line if we are at the maximum columns if(column == m_LayoutColumns) { ++row; column = 0; } button = new QToolButton; button->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred)); // add new button to the group MITK_DEBUG << "Adding button with ID " << currentToolID; m_ToolButtonGroup->addButton(button, currentButtonID); // ... and to the layout MITK_DEBUG << "Adding button in row/column " << row << "/" << column; m_ButtonLayout->addWidget(button, row, column); if (m_LayoutColumns == 1) { //button->setTextPosition( QToolButton::BesideIcon ); // mmueller button->setToolButtonStyle( Qt::ToolButtonTextBesideIcon ); } else { //button->setTextPosition( QToolButton::BelowIcon ); // mmueller button->setToolButtonStyle( Qt::ToolButtonTextUnderIcon ); } //button->setToggleButton( true ); // mmueller button->setCheckable ( true ); if(currentToolID == m_ToolManager->GetActiveToolID()) button->setChecked(true); QString label; if (m_GenerateAccelerators) { label += "&"; } label += tool->GetName(); QString tooltip = tool->GetName(); MITK_DEBUG << tool->GetName() << ", " << label.toLocal8Bit().constData() << ", '" << tooltip.toLocal8Bit().constData(); if ( m_ShowNames ) { /* button->setUsesTextLabel(true); button->setTextLabel( label ); // a label QToolTip::add( button, tooltip ); */ // mmueller Qt4 button->setText( label ); // a label button->setToolTip( tooltip ); // mmueller QFont currentFont = button->font(); currentFont.setBold(false); button->setFont( currentFont ); } - std::string iconPath = tool->GetIconPath(); + mitk::ModuleResource iconResource = tool->GetIconResource(); - if (iconPath.empty()) + if (!iconResource.IsValid()) { button->setIcon(QIcon(QPixmap(tool->GetXPM()))); } else { - button->setIcon(QIcon(iconPath.c_str())); + mitk::ModuleResourceStream resourceStream(iconResource); + resourceStream.seekg(0, std::ios::end); + std::ios::pos_type length = resourceStream.tellg(); + resourceStream.seekg(0, std::ios::beg); + + char* data = new char[length]; + resourceStream.read(data, length); + QPixmap pixmap; + pixmap.loadFromData(QByteArray::fromRawData(data, length)); + QIcon* icon = new QIcon(pixmap); + delete[] data; + + button->setIcon(*icon); if (m_ShowNames) { if (m_LayoutColumns == 1) button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); else button->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); button->setIconSize(QSize(24, 24)); } else { button->setToolButtonStyle(Qt::ToolButtonIconOnly); button->setIconSize(QSize(32, 32)); button->setStyleSheet("padding: 4px"); button->setToolTip(tooltip); } } if (m_GenerateAccelerators) { QString firstLetter = QString( tool->GetName() ); firstLetter.truncate( 1 ); button->setShortcut( firstLetter ); // a keyboard shortcut (just the first letter of the given name w/o any CTRL or something) } m_ButtonIDForToolID[currentToolID] = currentButtonID; m_ToolIDForButtonID[currentButtonID] = currentToolID; MITK_DEBUG << "m_ButtonIDForToolID[" << currentToolID << "] == " << currentButtonID; MITK_DEBUG << "m_ToolIDForButtonID[" << currentButtonID << "] == " << currentToolID; tool->GUIProcessEventsMessage += mitk::MessageDelegate( this, &QmitkToolSelectionBox::OnToolGUIProcessEventsMessage ); // will never add a listener twice, so we don't have to check here tool->ErrorMessage += mitk::MessageDelegate1( this, &QmitkToolSelectionBox::OnToolErrorMessage ); // will never add a listener twice, so we don't have to check here tool->GeneralMessage += mitk::MessageDelegate1( this, &QmitkToolSelectionBox::OnGeneralToolMessage ); ++currentButtonID; } // setting grid layout for this groupbox this->setLayout(m_ButtonLayout); //this->update(); } void QmitkToolSelectionBox::OnToolGUIProcessEventsMessage() { qApp->processEvents(); } void QmitkToolSelectionBox::OnToolErrorMessage(std::string s) { QMessageBox::critical(this, "MITK", QString( s.c_str() ), QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton); } void QmitkToolSelectionBox::OnGeneralToolMessage(std::string s) { QMessageBox::information(this, "MITK", QString( s.c_str() ), QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton); } void QmitkToolSelectionBox::SetDisplayedToolGroups(const std::string& toolGroups) { if (m_DisplayedGroups != toolGroups) { QString q_DisplayedGroups = toolGroups.c_str(); // quote all unquoted single words q_DisplayedGroups = q_DisplayedGroups.replace( QRegExp("\\b(\\w+)\\b|'([^']+)'"), "'\\1\\2'" ); MITK_DEBUG << "m_DisplayedGroups was \"" << toolGroups << "\""; m_DisplayedGroups = q_DisplayedGroups.toLocal8Bit().constData(); MITK_DEBUG << "m_DisplayedGroups is \"" << m_DisplayedGroups << "\""; RecreateButtons(); SetOrUnsetButtonForActiveTool(); } } void QmitkToolSelectionBox::SetLayoutColumns(int columns) { if (columns > 0 && columns != m_LayoutColumns) { m_LayoutColumns = columns; RecreateButtons(); } } void QmitkToolSelectionBox::SetShowNames(bool show) { if (show != m_ShowNames) { m_ShowNames = show; RecreateButtons(); } } void QmitkToolSelectionBox::SetAutoShowNamesWidth(int width) { width = std::max(0, width); if (m_AutoShowNamesWidth != width) { m_AutoShowNamesWidth = width; if (width != 0) this->SetShowNames(this->width() >= m_AutoShowNamesWidth); else this->SetShowNames(true); } } void QmitkToolSelectionBox::SetGenerateAccelerators(bool accel) { if (accel != m_GenerateAccelerators) { m_GenerateAccelerators = accel; RecreateButtons(); } } void QmitkToolSelectionBox::SetToolGUIArea( QWidget* parentWidget ) { m_ToolGUIWidget = parentWidget; } void QmitkToolSelectionBox::setTitle( const QString& /*title*/ ) { } void QmitkToolSelectionBox::showEvent( QShowEvent* e ) { QWidget::showEvent(e); SetGUIEnabledAccordingToToolManagerState(); } void QmitkToolSelectionBox::hideEvent( QHideEvent* e ) { QWidget::hideEvent(e); SetGUIEnabledAccordingToToolManagerState(); } void QmitkToolSelectionBox::resizeEvent( QResizeEvent* e ) { QWidget::resizeEvent(e); if (m_AutoShowNamesWidth != 0) this->SetShowNames(e->size().width() >= m_AutoShowNamesWidth); } diff --git a/Modules/QmitkExt/QmitkToolSelectionBox.h b/Modules/SegmentationUI/Qmitk/QmitkToolSelectionBox.h similarity index 97% rename from Modules/QmitkExt/QmitkToolSelectionBox.h rename to Modules/SegmentationUI/Qmitk/QmitkToolSelectionBox.h index 5d0acb1c70..8aa26d16a6 100755 --- a/Modules/QmitkExt/QmitkToolSelectionBox.h +++ b/Modules/SegmentationUI/Qmitk/QmitkToolSelectionBox.h @@ -1,148 +1,148 @@ /*=================================================================== 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 QmitkToolSelectionBox_h_Included #define QmitkToolSelectionBox_h_Included #include "QmitkToolGUIArea.h" -#include "QmitkExtExports.h" +#include "SegmentationUIExports.h" #include "mitkToolManager.h" #include #include #include #include class QmitkToolGUI; /** \brief Display the tool selection state of a mitk::ToolManager \sa mitk::ToolManager \ingroup org_mitk_gui_qt_interactivesegmentation \ingroup ToolManagerEtAl There is a separate page describing the general design of QmitkInteractiveSegmentation: \ref QmitkInteractiveSegmentationTechnicalPage This widget graphically displays the active tool of a mitk::ToolManager as a set of toggle buttons. Each button show the identification of a Tool (icon and name). When a button's toggle state is "down", the tool is activated. When a different button is clicked, the active tool is switched. When you click an already active button, the associated tool is deactivated with no replacement, which means that no tool is active then. When this widget is enabled/disabled it (normally) also enables/disables the tools. There could be cases where two QmitkToolSelectionBox widgets are associated to the same ToolManager, but if this happens, please look deeply into the code. Last contributor: $Author: maleike $ */ -class QmitkExt_EXPORT QmitkToolSelectionBox : public QWidget +class SegmentationUI_EXPORT QmitkToolSelectionBox : public QWidget //! { Q_OBJECT public: enum EnabledMode { EnabledWithReferenceAndWorkingDataVisible, EnabledWithReferenceData, EnabledWithWorkingData, AlwaysEnabled }; QmitkToolSelectionBox(QWidget* parent = 0, mitk::DataStorage* storage = 0); virtual ~QmitkToolSelectionBox(); mitk::ToolManager* GetToolManager(); void SetToolManager(mitk::ToolManager&); // no NULL pointer allowed here, a manager is required void setTitle( const QString& title ); /** You may specify a list of tool "groups" that should be displayed in this widget. Every Tool can report its group as a string. This method will try to find the tool's group inside the supplied string \param toolGroups. If there is a match, the tool is displayed. Effectively, you can provide a human readable list like "default, lymphnodevolumetry, oldERISstuff". */ void SetDisplayedToolGroups(const std::string& toolGroups = 0); void OnToolManagerToolModified(); void OnToolManagerReferenceDataModified(); void OnToolManagerWorkingDataModified(); void OnToolGUIProcessEventsMessage(); void OnToolErrorMessage(std::string s); void OnGeneralToolMessage(std::string s); signals: /// Whenever a tool is activated. id is the index of the active tool. Counting starts at 0, -1 indicates "no tool selected" /// This signal is also emitted, when the whole QmitkToolSelectionBox get disabled. Then it will claim ToolSelected(-1) /// When it is enabled again, there will be another ToolSelected event with the tool that is currently selected void ToolSelected(int id); public slots: virtual void setEnabled( bool ); virtual void SetEnabledMode(EnabledMode mode); virtual void SetLayoutColumns(int); virtual void SetShowNames(bool); virtual void SetAutoShowNamesWidth(int width); virtual void SetGenerateAccelerators(bool); virtual void SetToolGUIArea( QWidget* parentWidget ); protected slots: void toolButtonClicked(int id); void SetGUIEnabledAccordingToToolManagerState(); protected: void showEvent( QShowEvent* ); void hideEvent( QHideEvent* ); void resizeEvent( QResizeEvent* ); void RecreateButtons(); void SetOrUnsetButtonForActiveTool(); mitk::ToolManager::Pointer m_ToolManager; bool m_SelfCall; std::string m_DisplayedGroups; /// stores relationship between button IDs of the Qt widget and tool IDs of ToolManager std::map m_ButtonIDForToolID; /// stores relationship between button IDs of the Qt widget and tool IDs of ToolManager std::map m_ToolIDForButtonID; int m_LayoutColumns; bool m_ShowNames; int m_AutoShowNamesWidth; bool m_GenerateAccelerators; QWidget* m_ToolGUIWidget; QmitkToolGUI* m_LastToolGUI; // store buttons in this group QButtonGroup* m_ToolButtonGroup; QGridLayout* m_ButtonLayout; EnabledMode m_EnabledMode; }; #endif diff --git a/Modules/QmitkExt/QmitkToolWorkingDataSelectionBox.cpp b/Modules/SegmentationUI/Qmitk/QmitkToolWorkingDataSelectionBox.cpp similarity index 100% rename from Modules/QmitkExt/QmitkToolWorkingDataSelectionBox.cpp rename to Modules/SegmentationUI/Qmitk/QmitkToolWorkingDataSelectionBox.cpp diff --git a/Modules/QmitkExt/QmitkToolWorkingDataSelectionBox.h b/Modules/SegmentationUI/Qmitk/QmitkToolWorkingDataSelectionBox.h similarity index 97% rename from Modules/QmitkExt/QmitkToolWorkingDataSelectionBox.h rename to Modules/SegmentationUI/Qmitk/QmitkToolWorkingDataSelectionBox.h index 338ef53feb..94c4bcb584 100644 --- a/Modules/QmitkExt/QmitkToolWorkingDataSelectionBox.h +++ b/Modules/SegmentationUI/Qmitk/QmitkToolWorkingDataSelectionBox.h @@ -1,142 +1,142 @@ /*=================================================================== 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 QmitkToolWorkingDataSelectionListBox_h_Included #define QmitkToolWorkingDataSelectionListBox_h_Included // mmueller #include -#include "QmitkExtExports.h" +#include "SegmentationUIExports.h" #include "mitkToolManager.h" #include "mitkProperties.h" /** \brief Display the data selection of a ToolManager. \sa mitk::ToolManager \sa mitk::DataStorage \ingroup Widgets There is a separate page describing the general design of QmitkInteractiveSegmentation: \ref QmitkInteractiveSegmentationTechnicalPage Shows the working data of a ToolManager in a segmentation setting. By default only the segmentation name is shown. The working images (segmentations) are listed in a QListView, each row telling the color and name of a single segmentation. One or several segmentations can be selected to be the "active" segmentations. $Author: maleike $ */ -class QmitkExt_EXPORT QmitkToolWorkingDataSelectionBox : public QListWidget +class SegmentationUI_EXPORT QmitkToolWorkingDataSelectionBox : public QListWidget { Q_OBJECT public: /** * \brief What kind of items should be displayed. * * Every mitk::Tool holds a NodePredicateBase object, telling the kind of data that this * tool will successfully work with. There are two ways that this list box deals with * these predicates. * * DEFAULT is: list data if ANY one of the displayed tools' predicate matches. * Other option: list data if ALL one of the displayed tools' predicate matches */ enum DisplayMode { ListDataIfAllToolsMatch, ListDataIfAnyToolMatches}; QmitkToolWorkingDataSelectionBox(QWidget* parent = 0, mitk::DataStorage* storage = 0); virtual ~QmitkToolWorkingDataSelectionBox(); mitk::DataStorage* GetDataStorage(); void SetDataStorage(mitk::DataStorage& storage); /** \brief Can be called to trigger an update of the list contents. */ void UpdateDataDisplay(); /** \brief Returns the associated mitk::ToolManager. */ mitk::ToolManager* GetToolManager(); /** \brief Tell this object to listen to another ToolManager. */ void SetToolManager(mitk::ToolManager&); // no NULL pointer allowed here, a manager is required /** * \brief A list of all displayed DataNode objects. * This method might be convenient for program modules that want to display * additional information about these nodes, like a total volume of all segmentations, etc. */ mitk::ToolManager::DataVectorType GetAllNodes( bool onlyDerivedFromOriginal = true ); /** * \brief A list of all selected DataNode objects. * This method might be convenient for program modules that want to display * additional information about these nodes, like a total volume of all segmentations, etc. */ mitk::ToolManager::DataVectorType GetSelectedNodes(); /** * \brief Like GetSelectedNodes(), but will only return one object. * Will only return what QListView gives as selected object (documentation says nothing is returned if list is in Single selection mode). */ mitk::DataNode* GetSelectedNode(); /** * \brief Callback function, no need to call it. * This is used to observe and react to changes in the mitk::ToolManager object. */ void OnToolManagerWorkingDataModified(); /** * \brief Callback function, no need to call it. * This is used to observe and react to changes in the mitk::ToolManager object. */ void OnToolManagerReferenceDataModified(); signals: void WorkingNodeSelected(const mitk::DataNode*); protected slots: void OnWorkingDataSelectionChanged(); protected: typedef std::map< QListWidgetItem*, mitk::DataNode* > ItemNodeMapType; mitk::ToolManager::Pointer m_ToolManager; ItemNodeMapType m_Node; bool m_SelfCall; mitk::DataNode* m_LastSelectedReferenceData; std::string m_ToolGroupsForFiltering; bool m_DisplayOnlyDerivedNodes; }; #endif diff --git a/Modules/QmitkExt/QmitkWatershedToolGUI.cpp b/Modules/SegmentationUI/Qmitk/QmitkWatershedToolGUI.cpp similarity index 98% rename from Modules/QmitkExt/QmitkWatershedToolGUI.cpp rename to Modules/SegmentationUI/Qmitk/QmitkWatershedToolGUI.cpp index 49f44921bc..f01f69fbd7 100644 --- a/Modules/QmitkExt/QmitkWatershedToolGUI.cpp +++ b/Modules/SegmentationUI/Qmitk/QmitkWatershedToolGUI.cpp @@ -1,146 +1,146 @@ /*=================================================================== 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 "QmitkWatershedToolGUI.h" #include "QmitkNewSegmentationDialog.h" #include #include #include #include #include #include -MITK_TOOL_GUI_MACRO(QmitkExt_EXPORT, QmitkWatershedToolGUI, "") +MITK_TOOL_GUI_MACRO(SegmentationUI_EXPORT, QmitkWatershedToolGUI, "") QmitkWatershedToolGUI::QmitkWatershedToolGUI() :QmitkToolGUI(), m_SliderThreshold(NULL), m_SliderLevel(NULL) { // create the visible widgets QGridLayout* layout = new QGridLayout( this ); this->setContentsMargins( 0, 0, 0, 0 ); QLabel* label = new QLabel( "Threshold ", this ); QFont f = label->font(); f.setBold(false); label->setFont( f ); layout->addWidget(label,0,0); QLabel* label2 = new QLabel( "Level ", this ); f = label2->font(); f.setBold(false); label2->setFont( f ); layout->addWidget(label2,2,0); m_ThresholdLabel = new QLabel( " 0.5", this ); f = m_ThresholdLabel->font(); f.setBold(false); m_ThresholdLabel->setFont( f ); layout->addWidget(m_ThresholdLabel,0,1); m_SliderThreshold = new QSlider( Qt::Horizontal, this ); m_SliderThreshold->setMinimum(0); m_SliderThreshold->setMaximum(100); m_SliderThreshold->setPageStep(1); m_SliderThreshold->setValue(50); connect( m_SliderThreshold, SIGNAL(valueChanged(int)), this, SLOT(OnSliderValueThresholdChanged(int))); layout->addWidget( m_SliderThreshold, 1, 0, 1, 2 ); m_LevelLabel = new QLabel( " 0.5", this ); f = m_LevelLabel->font(); f.setBold(false); m_LevelLabel->setFont( f ); layout->addWidget(m_LevelLabel,2,1); m_SliderLevel = new QSlider( Qt::Horizontal, this ); m_SliderLevel->setMinimum(0); m_SliderLevel->setMaximum(100); m_SliderLevel->setPageStep(1); m_SliderLevel->setValue(50); connect( m_SliderLevel, SIGNAL(valueChanged(int)), this, SLOT(OnSliderValueLevelChanged(int))); layout->addWidget( m_SliderLevel, 3, 0, 1, 2 ); QPushButton* okButton = new QPushButton("Create Segmentation", this); connect( okButton, SIGNAL(clicked()), this, SLOT(OnCreateSegmentation())); okButton->setFont( f ); layout->addWidget( okButton, 4, 0, 1, 2 ); m_InformationLabel = new QLabel("", this); f = m_InformationLabel->font(); f.setBold(false); m_InformationLabel->setFont( f ); layout->addWidget( m_InformationLabel, 5,0,1,2); connect( this, SIGNAL(NewToolAssociated(mitk::Tool*)), this, SLOT(OnNewToolAssociated(mitk::Tool*)) ); } QmitkWatershedToolGUI::~QmitkWatershedToolGUI() { if (m_WatershedTool.IsNotNull()) { //m_WatershedTool->SizeChanged -= mitk::MessageDelegate1( this, &QmitkWatershedToolGUI::OnSizeChanged ); } } void QmitkWatershedToolGUI::OnNewToolAssociated(mitk::Tool* tool) { if (m_WatershedTool.IsNotNull()) { //m_WatershedTool->SizeChanged -= mitk::MessageDelegate1( this, &QmitkWatershedToolGUI::OnSizeChanged ); } m_WatershedTool = dynamic_cast( tool ); if (m_WatershedTool.IsNotNull()) { // m_WatershedTool->SizeChanged += mitk::MessageDelegate1( this, &QmitkWatershedToolGUI::OnSizeChanged ); } } void QmitkWatershedToolGUI::OnSliderValueThresholdChanged(int value) { if (m_WatershedTool.IsNotNull()) { double realValue = value / 100.; m_WatershedTool->SetThreshold( realValue ); m_ThresholdLabel->setText(QString::number(realValue)); } } void QmitkWatershedToolGUI::OnSliderValueLevelChanged(int value) { if (m_WatershedTool.IsNotNull()) { double realValue = value / 100.; m_WatershedTool->SetLevel( realValue ); m_LevelLabel->setText(QString::number(realValue)); } } void QmitkWatershedToolGUI::OnCreateSegmentation() { m_InformationLabel->setText(QString("Please wait some time for computation...")); m_InformationLabel->repaint(); QApplication::processEvents(); m_WatershedTool->DoIt(); m_InformationLabel->setText(QString("")); } diff --git a/Modules/QmitkExt/QmitkWatershedToolGUI.h b/Modules/SegmentationUI/Qmitk/QmitkWatershedToolGUI.h similarity index 94% rename from Modules/QmitkExt/QmitkWatershedToolGUI.h rename to Modules/SegmentationUI/Qmitk/QmitkWatershedToolGUI.h index 0c0b449b88..2cae183ac2 100644 --- a/Modules/QmitkExt/QmitkWatershedToolGUI.h +++ b/Modules/SegmentationUI/Qmitk/QmitkWatershedToolGUI.h @@ -1,75 +1,75 @@ /*=================================================================== 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 QmitkWatershedToolGUI_h_Included #define QmitkWatershedToolGUI_h_Included #include "QmitkToolGUI.h" -#include "QmitkExtExports.h" +#include "SegmentationUIExports.h" #include "mitkWatershedTool.h" class QSlider; class QLabel; class QFrame; /** \ingroup org_mitk_gui_qt_interactivesegmentation_internal \brief GUI for mitk::WatershedTool. \sa mitk::WatershedTool This GUI shows two sliders to change the watershed parameters. It executes the watershed algorithm by clicking on the button. */ -class QmitkExt_EXPORT QmitkWatershedToolGUI : public QmitkToolGUI +class SegmentationUI_EXPORT QmitkWatershedToolGUI : public QmitkToolGUI { Q_OBJECT public: mitkClassMacro(QmitkWatershedToolGUI, QmitkToolGUI); itkNewMacro(QmitkWatershedToolGUI); protected slots: void OnNewToolAssociated(mitk::Tool*); /** \brief Passes the chosen threshold value directly to the watershed tool */ void OnSliderValueThresholdChanged(int value); /** \brief Passes the chosen level value directly to the watershed tool */ void OnSliderValueLevelChanged(int value); /** \brief Starts segmentation algorithm in the watershed tool */ void OnCreateSegmentation(); protected: QmitkWatershedToolGUI(); virtual ~QmitkWatershedToolGUI(); QSlider* m_SliderThreshold; QSlider* m_SliderLevel; /** \brief Label showing the current threshold value. */ QLabel* m_ThresholdLabel; /** \brief Label showing the current level value. */ QLabel* m_LevelLabel; /** \brief Label showing additional informations. */ QLabel* m_InformationLabel; QFrame* m_Frame; mitk::WatershedTool::Pointer m_WatershedTool; }; #endif diff --git a/Modules/SegmentationUI/files.cmake b/Modules/SegmentationUI/files.cmake new file mode 100644 index 0000000000..4117de8a86 --- /dev/null +++ b/Modules/SegmentationUI/files.cmake @@ -0,0 +1,55 @@ +set( CPP_FILES +Qmitk/QmitkAdaptiveRegionGrowingToolGUI.cpp +Qmitk/QmitkBinaryThresholdToolGUI.cpp +Qmitk/QmitkBinaryThresholdULToolGUI.cpp +Qmitk/QmitkCalculateGrayValueStatisticsToolGUI.cpp +Qmitk/QmitkCopyToClipBoardDialog.cpp +Qmitk/QmitkDrawPaintbrushToolGUI.cpp +Qmitk/QmitkErasePaintbrushToolGUI.cpp +Qmitk/QmitkFastMarchingTool3DGUI.cpp +Qmitk/QmitkFastMarchingToolGUI.cpp +Qmitk/QmitkLiveWireTool2DGUI.cpp +Qmitk/QmitkNewSegmentationDialog.cpp +Qmitk/QmitkOtsuTool3DGUI.cpp +Qmitk/QmitkPaintbrushToolGUI.cpp +Qmitk/QmitkPixelManipulationToolGUI.cpp +Qmitk/QmitkRegionGrow3DToolGUI.cpp +Qmitk/QmitkSlicesInterpolator.cpp +Qmitk/QmitkToolGUI.cpp +Qmitk/QmitkToolGUIArea.cpp +Qmitk/QmitkToolReferenceDataSelectionBox.cpp +Qmitk/QmitkToolRoiDataSelectionBox.cpp +Qmitk/QmitkToolSelectionBox.cpp +Qmitk/QmitkToolWorkingDataSelectionBox.cpp +Qmitk/QmitkWatershedToolGUI.cpp +) + +set(MOC_H_FILES +Qmitk/QmitkAdaptiveRegionGrowingToolGUI.h +Qmitk/QmitkBinaryThresholdToolGUI.h +Qmitk/QmitkBinaryThresholdULToolGUI.h +Qmitk/QmitkCalculateGrayValueStatisticsToolGUI.h +Qmitk/QmitkCopyToClipBoardDialog.h +Qmitk/QmitkDrawPaintbrushToolGUI.h +Qmitk/QmitkErasePaintbrushToolGUI.h +Qmitk/QmitkFastMarchingTool3DGUI.h +Qmitk/QmitkFastMarchingToolGUI.h +Qmitk/QmitkLiveWireTool2DGUI.h +Qmitk/QmitkNewSegmentationDialog.h +Qmitk/QmitkOtsuTool3DGUI.h +Qmitk/QmitkPaintbrushToolGUI.h +Qmitk/QmitkPixelManipulationToolGUI.h +Qmitk/QmitkRegionGrow3DToolGUI.h +Qmitk/QmitkSlicesInterpolator.h +Qmitk/QmitkToolGUI.h +Qmitk/QmitkToolGUIArea.h +Qmitk/QmitkToolReferenceDataSelectionBox.h +Qmitk/QmitkToolRoiDataSelectionBox.h +Qmitk/QmitkToolSelectionBox.h +Qmitk/QmitkToolWorkingDataSelectionBox.h +Qmitk/QmitkWatershedToolGUI.h +) + +set(UI_FILES +Qmitk/QmitkAdaptiveRegionGrowingToolGUIControls.ui +) diff --git a/Plugins/org.mitk.gui.qt.examples/CMakeLists.txt b/Plugins/org.mitk.gui.qt.examples/CMakeLists.txt index 4bc67387dc..c4ecaf406e 100644 --- a/Plugins/org.mitk.gui.qt.examples/CMakeLists.txt +++ b/Plugins/org.mitk.gui.qt.examples/CMakeLists.txt @@ -1,7 +1,7 @@ project(org_mitk_gui_qt_examples) MACRO_CREATE_MITK_CTK_PLUGIN( EXPORT_DIRECTIVE EXAMPLES_EXPORT EXPORTED_INCLUDE_SUFFIXES src - MODULE_DEPENDENCIES QmitkExt -) \ No newline at end of file + MODULE_DEPENDENCIES QmitkExt Segmentation +) diff --git a/Plugins/org.mitk.gui.qt.segmentation/CMakeLists.txt b/Plugins/org.mitk.gui.qt.segmentation/CMakeLists.txt index 71d8b2a2e0..a93da2b458 100644 --- a/Plugins/org.mitk.gui.qt.segmentation/CMakeLists.txt +++ b/Plugins/org.mitk.gui.qt.segmentation/CMakeLists.txt @@ -1,9 +1,9 @@ project(org_mitk_gui_qt_segmentation) include_directories(${CTK_INCLUDE_DIRS}) MACRO_CREATE_MITK_CTK_PLUGIN( EXPORT_DIRECTIVE MITK_QT_SEGMENTATION EXPORTED_INCLUDE_SUFFIXES src - MODULE_DEPENDENCIES QmitkExt ClippingTools Segmentation + MODULE_DEPENDENCIES QmitkExt ClippingTools Segmentation SegmentationUI )