Page MenuHomePhabricator

3281_ExtensionPointsForContextMenu.patch

Authored By
iud
Sep 29 2010, 7:14 PM
Size
33 KB
Referenced Files
None
Subscribers
None

3281_ExtensionPointsForContextMenu.patch

Index: mitk/Modules/Bundles/org.mitk.gui.qt.datamanager/plugin.xml
===================================================================
--- mitk/Modules/Bundles/org.mitk.gui.qt.datamanager/plugin.xml (revision 25364)
+++ mitk/Modules/Bundles/org.mitk.gui.qt.datamanager/plugin.xml (working copy)
@@ -34,5 +34,7 @@
<keyword id="org.mitk.gui.qt.application.DataManagerPreferencePageKeywords" label="data manager"></keyword>
<keyword id="org.mitk.gui.qt.application.DataManagerHotkeysPrefPageKeywords" label="data manager hotkeys"></keyword>
</extension>
-
+
+ <extension-point id="contextMenuActions" name="Context menu actions"/>
+
</plugin>
Index: mitk/Modules/Bundles/org.mitk.gui.qt.datamanager/src/mitkIContextMenuAction.h
===================================================================
--- mitk/Modules/Bundles/org.mitk.gui.qt.datamanager/src/mitkIContextMenuAction.h (revision 0)
+++ mitk/Modules/Bundles/org.mitk.gui.qt.datamanager/src/mitkIContextMenuAction.h (revision 0)
@@ -0,0 +1,36 @@
+#ifndef mitkIContextMenuAction_H_
+#define mitkIContextMenuAction_H_
+
+#include <vector>
+#include <mitkDataNode.h>
+#include <berryMacros.h>
+
+#include "mitkDataStorage.h"
+#include "berryQtViewPart.h"
+
+namespace mitk
+{
+ /**
+ * A context menu action, which is linked to the context menu <br>
+ * through an extension point. For an example check the <br>
+ * <code> plugin.xml </code> and the connected classes of <br>
+ * the the segmentation bundle and also the <code> QmitkDataManagerView.cpp </code> <br>
+ * in this bundle.
+ */
+ struct IContextMenuAction
+ {
+ berryInterfaceMacro(IContextMenuAction, mitk)
+
+ /**
+ * @brief Executes the action, that linked to the context menu entry.
+ */
+ virtual void Run( const std::vector<mitk::DataNode*>& selectedNodes ) = 0;
+
+ // Setters
+ virtual void SetDataStorage(mitk::DataStorage* dataStorage) = 0;
+ virtual void SetSmoothed(bool smoothed) = 0;
+ virtual void SetFunctionality(berry::QtViewPart* functionality) = 0;
+ };
+}
+
+#endif // mitkIContextMenuAction_H_
\ No newline at end of file
Index: mitk/Modules/Bundles/org.mitk.gui.qt.datamanager/src/QmitkDataManagerView.cpp
===================================================================
--- mitk/Modules/Bundles/org.mitk.gui.qt.datamanager/src/QmitkDataManagerView.cpp (revision 25364)
+++ mitk/Modules/Bundles/org.mitk.gui.qt.datamanager/src/QmitkDataManagerView.cpp (working copy)
@@ -81,7 +81,10 @@
#include <QColor>
#include <QColorDialog>
#include <QSizePolicy>
+
#include "mitkDataNodeObject.h"
+#include "mitkIContextMenuAction.h"
+#include "berryIExtensionPointService.h"
const std::string QmitkDataManagerView::VIEW_ID = "org.mitk.views.datamanager";
@@ -187,6 +190,51 @@
, this, SLOT( ReinitSelectedNodes(bool) ) );
unknownDataNodeDescriptor->AddAction(m_ReinitAction);
+ // find contextMenuAction extension points and add them to the node descriptor
+ berry::IExtensionPointService::Pointer extensionPointService = berry::Platform::GetExtensionPointService();
+ berry::IConfigurationElement::vector cmActions(
+ extensionPointService->GetConfigurationElementsFor("org.mitk.gui.qt.datamanager.contextMenuActions") );
+ berry::IConfigurationElement::vector::iterator cmActionsIt;
+
+ std::string cmNodeDescriptorName;
+ std::string cmLabel;
+ std::string cmIcon;
+ std::string cmClass;
+
+ QmitkNodeDescriptor* tmpDescriptor;
+ QAction* contextMenuAction;
+ QVariant cmActionDataIt;
+ m_ConfElements.clear();
+
+ int i=1;
+ for (cmActionsIt = cmActions.begin()
+ ; cmActionsIt != cmActions.end()
+ ; ++cmActionsIt)
+ {
+ cmIcon.erase();
+ if((*cmActionsIt)->GetAttribute("nodeDescriptorName", cmNodeDescriptorName)
+ && (*cmActionsIt)->GetAttribute("label", cmLabel)
+ && (*cmActionsIt)->GetAttribute("class", cmClass))
+ {
+ (*cmActionsIt)->GetAttribute("icon", cmIcon);
+ // create context menu entry here
+ tmpDescriptor = QmitkNodeDescriptorManager::GetInstance()->GetDescriptor(QString::fromStdString(cmNodeDescriptorName));
+ if(!tmpDescriptor)
+ {
+ MITK_WARN << "cannot add action \"" << cmLabel << "\" because descriptor " << cmNodeDescriptorName << " does not exist";
+ continue;
+ }
+ contextMenuAction = new QAction( QString::fromStdString(cmLabel), parent);
+ tmpDescriptor->AddAction(contextMenuAction);
+ m_ConfElements[contextMenuAction] = *cmActionsIt;
+
+ cmActionDataIt.setValue<int>(i);
+ contextMenuAction->setData( cmActionDataIt );
+ connect( contextMenuAction, SIGNAL( triggered(bool) ) , this, SLOT( ContextMenuActionTriggered(bool) ) );
+ ++i;
+ }
+ }
+
m_OpacitySlider = new QSlider;
m_OpacitySlider->setMinimum(0);
m_OpacitySlider->setMaximum(100);
@@ -296,6 +344,47 @@
{
}
+void QmitkDataManagerView::ContextMenuActionTriggered( bool )
+{
+ QAction* action = qobject_cast<QAction*> ( sender() );
+
+ std::map<QAction*, berry::IConfigurationElement::Pointer>::iterator it
+ = m_ConfElements.find( action );
+ if( it == m_ConfElements.end() )
+ {
+ MITK_WARN << "associated conf element for action " << action->text().toStdString() << " not found";
+ return;
+ }
+ berry::IConfigurationElement::Pointer confElem = it->second;
+ mitk::IContextMenuAction* contextMenuAction = dynamic_cast<mitk::IContextMenuAction*>
+ (confElem->CreateExecutableExtension<mitk::IContextMenuAction>("class") );
+ std::string className;
+ std::string smoothed;
+ confElem->GetAttribute("class", className);
+ confElem->GetAttribute("smoothed", smoothed);
+ if(className == "QmitkThresholdAction")
+ {
+ contextMenuAction->SetDataStorage(this->GetDataStorage());
+ }
+ if(className == "QmitkCreatePolygonModelAction")
+ {
+ contextMenuAction->SetDataStorage(this->GetDataStorage());
+ if(smoothed == "false")
+ {
+ contextMenuAction->SetSmoothed(false);
+ }
+ else
+ {
+ contextMenuAction->SetSmoothed(true);
+ }
+ }
+ if(className == "QmitkStatisticsAction")
+ {
+ contextMenuAction->SetFunctionality(this);
+ }
+ contextMenuAction->Run( this->GetSelectedNodes() ); // run the action
+}
+
mitk::DataStorage::Pointer QmitkDataManagerView::GetDataStorage() const
{
mitk::IDataStorageService::Pointer service =
Index: mitk/Modules/Bundles/org.mitk.gui.qt.datamanager/src/QmitkDataManagerView.h
===================================================================
--- mitk/Modules/Bundles/org.mitk.gui.qt.datamanager/src/QmitkDataManagerView.h (revision 25364)
+++ mitk/Modules/Bundles/org.mitk.gui.qt.datamanager/src/QmitkDataManagerView.h (working copy)
@@ -156,6 +156,12 @@
/// Invoked when the preferences were changed
///
void OnPreferencesChanged(const berry::IBerryPreferences*);
+ ///
+ /// \brief will be toggled when a extension point context menu action is toggled
+ /// this is a proxy method which will load the corresponding extension class
+ /// and run IContextMenuAction
+ ///
+ void ContextMenuActionTriggered( bool );
///
/// Invoked when the DataManager selection changed
@@ -200,6 +206,10 @@
///
berry::IBerryPreferences::Pointer m_DataManagerPreferencesNode;
///
+ /// saves the configuration elements for the context menu actions from extension points
+ ///
+ std::map<QAction*, berry::IConfigurationElement::Pointer> m_ConfElements;
+ ///
/// \brief The Table view to show the selected nodes.
///
QTreeView* m_NodeTreeView;
Index: mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/files.cmake
===================================================================
--- mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/files.cmake (revision 25364)
+++ mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/files.cmake (working copy)
@@ -5,6 +5,10 @@
SET(INTERNAL_CPP_FILES
QmitkSegmentationView.cpp
QmitkSegmentationPostProcessing.cpp
+ QmitkThresholdAction.cpp
+ QmitkCreatePolygonModelAction.cpp
+ QmitkStatisticsAction.cpp
+ QmitkAutocropAction.cpp
)
SET(UI_FILES
@@ -15,6 +19,10 @@
src/QmitkSegmentationPreferencePage.h
src/internal/QmitkSegmentationView.h
src/internal/QmitkSegmentationPostProcessing.h
+ src/internal/QmitkThresholdAction.h
+ src/internal/QmitkCreatePolygonModelAction.h
+ src/internal/QmitkStatisticsAction.h
+ src/internal/QmitkAutocropAction.h
)
SET(RESOURCE_FILES
Index: mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/manifest.cpp
===================================================================
--- mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/manifest.cpp (revision 25364)
+++ mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/manifest.cpp (working copy)
@@ -17,9 +17,15 @@
#include <Poco/ClassLibrary.h>
+#include <mitkIContextMenuAction.h>
#include <berryIViewPart.h>
+
#include "src/internal/QmitkSegmentationView.h"
#include "src/QmitkSegmentationPreferencePage.h"
+#include "src/internal/QmitkThresholdAction.h"
+#include "src/internal/QmitkCreatePolygonModelAction.h"
+#include "src/internal/QmitkStatisticsAction.h"
+#include "src/internal/QmitkAutocropAction.h"
POCO_BEGIN_NAMED_MANIFEST(berryIViewPart, berry::IViewPart)
@@ -30,3 +36,9 @@
POCO_EXPORT_CLASS(QmitkSegmentationPreferencePage)
POCO_END_MANIFEST
+POCO_BEGIN_NAMED_MANIFEST(mitkIContextMenuAction, mitk::IContextMenuAction)
+ POCO_EXPORT_CLASS(QmitkThresholdAction)
+ POCO_EXPORT_CLASS(QmitkCreatePolygonModelAction)
+ POCO_EXPORT_CLASS(QmitkStatisticsAction)
+ POCO_EXPORT_CLASS(QmitkAutocropAction)
+POCO_END_MANIFEST
Index: mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/META-INF/MANIFEST.MF
===================================================================
--- mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/META-INF/MANIFEST.MF (revision 25364)
+++ mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/META-INF/MANIFEST.MF (working copy)
@@ -3,4 +3,4 @@
Bundle-SymbolicName: org.mitk.gui.qt.segmentation
Bundle-Version: 1.0.0
Bundle-Vendor: DKFZ, Medical and Biological Informatics
-Require-Bundle: org.mitk.gui.qt.common
+Require-Bundle: org.mitk.gui.qt.common, org.mitk.gui.qt.datamanager
Index: mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/plugin.xml
===================================================================
--- mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/plugin.xml (revision 25364)
+++ mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/plugin.xml (working copy)
@@ -23,5 +23,13 @@
<extension point="org.blueberry.ui.keywords">
<keyword id="org.mitk.gui.qt.application.SegmentationPreferencePageKeywords" label="data manager"></keyword>
</extension>
+
+ <extension point="org.mitk.gui.qt.datamanager.contextMenuActions">
+ <contextMenuAction nodeDescriptorName="Image" label="Threshold..." icon="" class="QmitkThresholdAction" />
+ <contextMenuAction nodeDescriptorName="ImageMask" label="Create polygon model" icon="" smoothed="false" class="QmitkCreatePolygonModelAction" />
+ <contextMenuAction nodeDescriptorName="ImageMask" label="Create smoothed polygon model" icon="" smoothed = "true" class="QmitkCreatePolygonModelAction" />
+ <contextMenuAction nodeDescriptorName="ImageMask" label="Statistics" icon="" class="QmitkStatisticsAction" />
+ <contextMenuAction nodeDescriptorName="ImageMask" label="Autocrop" icon="" class="QmitkAutocropAction" />
+ </extension>
</plugin>
Index: mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkAutocropAction.cpp
===================================================================
--- mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkAutocropAction.cpp (revision 0)
+++ mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkAutocropAction.cpp (revision 0)
@@ -0,0 +1,135 @@
+#include "QmitkAutocropAction.h"
+
+#include "mitkAutoCropImageFilter.h"
+#include "mitkImageCast.h"
+
+#include "mitkProgressBar.h"
+
+#include <itkConstantPadImageFilter.h>
+
+//needed for qApp
+#include <qcoreapplication.h>
+
+QmitkAutocropAction::QmitkAutocropAction()
+{
+}
+
+QmitkAutocropAction::~QmitkAutocropAction()
+{
+}
+
+void QmitkAutocropAction::Run( const std::vector<mitk::DataNode*>& selectedNodes )
+{
+ NodeList selection = selectedNodes;
+
+ for ( NodeList::iterator iter = selection.begin(); iter != selection.end(); ++iter )
+ {
+ mitk::DataNode* node = *iter;
+
+ if (node)
+ {
+ mitk::Image::Pointer image = dynamic_cast<mitk::Image*>( node->GetData() );
+ if (image.IsNull()) return;
+
+ mitk::ProgressBar::GetInstance()->AddStepsToDo(10);
+ mitk::ProgressBar::GetInstance()->Progress(2);
+
+ qApp->processEvents();
+
+ mitk::AutoCropImageFilter::Pointer cropFilter = mitk::AutoCropImageFilter::New();
+ cropFilter->SetInput( image );
+ cropFilter->SetBackgroundValue( 0 );
+ try
+ {
+ cropFilter->Update();
+
+ image = cropFilter->GetOutput();
+
+ if (image.IsNotNull())
+ {
+ node->SetData( this->IncreaseCroppedImageSize(image) ); // bug fix 3145
+ }
+ }
+ catch(...)
+ {
+ MITK_ERROR << "Cropping image failed...";
+ }
+ mitk::ProgressBar::GetInstance()->Progress(8);
+ }
+ else
+ {
+ MITK_INFO << " a NULL node selected";
+ }
+ }
+}
+
+mitk::Image::Pointer QmitkAutocropAction::IncreaseCroppedImageSize( mitk::Image::Pointer image )
+{
+ typedef itk::Image< short, 3 > ImageType;
+ typedef itk::Image< unsigned char, 3 > PADOutputImageType;
+ ImageType::Pointer itkTransformImage = ImageType::New();
+ mitk::CastToItkImage( image, itkTransformImage );
+
+ typedef itk::ConstantPadImageFilter< ImageType, PADOutputImageType > PadFilterType;
+ PadFilterType::Pointer padFilter = PadFilterType::New();
+
+ unsigned long upperPad[3];
+ unsigned long lowerPad[3];
+ int borderLiner = 6;
+
+ mitk::Point3D mitkOriginPoint;
+ double origin[3];
+ origin[0]=0;
+ origin[1]=0;
+ origin[2]=0;
+ itkTransformImage->SetOrigin(origin);
+
+ lowerPad[0]=borderLiner/2;
+ lowerPad[1]=borderLiner/2;
+ lowerPad[2]=borderLiner/2;
+
+ upperPad[0]=borderLiner/2;
+ upperPad[1]=borderLiner/2;
+ upperPad[2]=borderLiner/2;
+
+ padFilter->SetInput(itkTransformImage);
+ padFilter->SetConstant(0);
+ padFilter->SetPadUpperBound(upperPad);
+ padFilter->SetPadLowerBound(lowerPad);
+ padFilter->UpdateLargestPossibleRegion();
+
+
+ mitk::Image::Pointer paddedImage = mitk::Image::New();
+ mitk::CastToMitkImage(padFilter->GetOutput(), paddedImage);
+
+ paddedImage->SetGeometry(image->GetGeometry());
+
+ //calculate translation vector according to padding to get the new origin
+ mitk::Vector3D transVector = image->GetGeometry()->GetSpacing();
+ transVector[0] = -(borderLiner/2);
+ transVector[1] = -(borderLiner/2);
+ transVector[2] = -(borderLiner/2);
+
+ mitk::Vector3D newTransVectorInmm = image->GetGeometry()->GetSpacing();
+
+ image->GetGeometry()->IndexToWorld(mitkOriginPoint, transVector, newTransVectorInmm);
+ paddedImage->GetGeometry()->Translate(newTransVectorInmm);
+ //paddedImage->SetRequestedRegionToLargestPossibleRegion();
+
+ return paddedImage;
+}
+
+void QmitkAutocropAction::SetSmoothed(bool smoothed)
+{
+ //not needed
+}
+
+void QmitkAutocropAction::SetDataStorage(mitk::DataStorage* dataStorage)
+{
+ //not needed
+}
+
+void QmitkAutocropAction::SetFunctionality(berry::QtViewPart *functionality)
+{
+ //not needed
+}
Property changes on: mitk\Modules\Bundles\org.mitk.gui.qt.segmentation\src\internal\QmitkAutocropAction.cpp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Index: mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkAutocropAction.h
===================================================================
--- mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkAutocropAction.h (revision 0)
+++ mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkAutocropAction.h (revision 0)
@@ -0,0 +1,35 @@
+#ifndef QMITK_AUTOCROPACTION_H
+#define QMITK_AUTOCROPACTION_H
+
+#include "mitkIContextMenuAction.h"
+
+#include "mitkQtSegmentationDll.h"
+
+#include "vector"
+#include "mitkDataNode.h"
+#include "mitkImage.h"
+
+class MITK_QT_SEGMENTATION QmitkAutocropAction : public mitk::IContextMenuAction
+{
+public:
+
+ QmitkAutocropAction();
+ virtual ~QmitkAutocropAction();
+
+ //interface methods
+ void Run( const std::vector<mitk::DataNode*>& selectedNodes );
+ void SetDataStorage(mitk::DataStorage* dataStorage);
+ void SetSmoothed(bool smoothed);
+ void SetFunctionality(berry::QtViewPart* functionality);
+
+protected:
+
+ mitk::Image::Pointer IncreaseCroppedImageSize( mitk::Image::Pointer image );
+
+private:
+
+ typedef std::vector<mitk::DataNode*> NodeList;
+
+};
+
+#endif // QMITK_AUTOCROPACTION_H
\ No newline at end of file
Property changes on: mitk\Modules\Bundles\org.mitk.gui.qt.segmentation\src\internal\QmitkAutocropAction.h
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Index: mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkCreatePolygonModelAction.cpp
===================================================================
--- mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkCreatePolygonModelAction.cpp (revision 0)
+++ mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkCreatePolygonModelAction.cpp (revision 0)
@@ -0,0 +1,102 @@
+#include "QmitkCreatePolygonModelAction.h"
+
+#include "mitkShowSegmentationAsSurface.h"
+#include "mitkProgressBar.h"
+#include "mitkStatusBar.h"
+
+QmitkCreatePolygonModelAction::QmitkCreatePolygonModelAction()
+{
+}
+
+QmitkCreatePolygonModelAction::~QmitkCreatePolygonModelAction()
+{
+}
+
+void QmitkCreatePolygonModelAction::Run(const std::vector<mitk::DataNode*>& selectedNodes)
+{
+ NodeList selection = selectedNodes;
+
+ for ( NodeList::iterator iter = selection.begin(); iter != selection.end(); ++iter )
+ {
+ mitk::DataNode* node = *iter;
+
+ if (node)
+ {
+ mitk::Image::Pointer image = dynamic_cast<mitk::Image*>( node->GetData() );
+ if (image.IsNull()) return;
+
+ try
+ {
+ mitk::ShowSegmentationAsSurface::Pointer surfaceFilter = mitk::ShowSegmentationAsSurface::New();
+
+ // attach observer to get notified about result
+ itk::SimpleMemberCommand<QmitkCreatePolygonModelAction>::Pointer goodCommand = itk::SimpleMemberCommand<QmitkCreatePolygonModelAction>::New();
+ goodCommand->SetCallbackFunction(this, &QmitkCreatePolygonModelAction::OnSurfaceCalculationDone);
+ surfaceFilter->AddObserver(mitk::ResultAvailable(), goodCommand);
+ itk::SimpleMemberCommand<QmitkCreatePolygonModelAction>::Pointer badCommand = itk::SimpleMemberCommand<QmitkCreatePolygonModelAction>::New();
+ badCommand->SetCallbackFunction(this, &QmitkCreatePolygonModelAction::OnSurfaceCalculationDone);
+ surfaceFilter->AddObserver(mitk::ProcessingError(), badCommand);
+
+ mitk::DataNode::Pointer nodepointer = node;
+ surfaceFilter->SetPointerParameter("Input", image);
+ surfaceFilter->SetPointerParameter("Group node", nodepointer);
+ surfaceFilter->SetParameter("Show result", true );
+ surfaceFilter->SetParameter("Sync visibility", false );
+ surfaceFilter->SetDataStorage( *m_DataStorage );
+
+ if (this->m_IsSmoothed)
+ {
+ surfaceFilter->SetParameter("Smooth", true );
+ //surfaceFilter->SetParameter("Apply median", true );
+ surfaceFilter->SetParameter("Apply median", false ); // median makes the resulting surfaces look like lego models
+ surfaceFilter->SetParameter("Median kernel size", 3u );
+ surfaceFilter->SetParameter("Gaussian SD", 2.5f );
+ surfaceFilter->SetParameter("Decimate mesh", true );
+ surfaceFilter->SetParameter("Decimation rate", 0.80f );
+ }
+ else
+ {
+ surfaceFilter->SetParameter("Smooth", false );
+ surfaceFilter->SetParameter("Apply median", false );
+ surfaceFilter->SetParameter("Median kernel size", 3u );
+ surfaceFilter->SetParameter("Gaussian SD", 1.5f );
+ surfaceFilter->SetParameter("Decimate mesh", true );
+ surfaceFilter->SetParameter("Decimation rate", 0.8f );
+ }
+
+ mitk::ProgressBar::GetInstance()->AddStepsToDo(10);
+ mitk::ProgressBar::GetInstance()->Progress(2);
+ mitk::StatusBar::GetInstance()->DisplayText("Surface creation started in background...");
+ surfaceFilter->StartAlgorithm();
+ }
+ catch(...)
+ {
+ MITK_ERROR << "surface creation filter had an error";
+ }
+ }
+ else
+ {
+ MITK_INFO << " a NULL node selected";
+ }
+ }
+}
+
+void QmitkCreatePolygonModelAction::OnSurfaceCalculationDone()
+{
+ mitk::ProgressBar::GetInstance()->Progress(8);
+}
+
+void QmitkCreatePolygonModelAction::SetSmoothed(bool smoothed)
+{
+ this->m_IsSmoothed = smoothed;
+}
+
+void QmitkCreatePolygonModelAction::SetDataStorage(mitk::DataStorage* dataStorage)
+{
+ this->m_DataStorage = dataStorage;
+}
+
+void QmitkCreatePolygonModelAction::SetFunctionality(berry::QtViewPart *functionality)
+{
+ //not needed
+}
Property changes on: mitk\Modules\Bundles\org.mitk.gui.qt.segmentation\src\internal\QmitkCreatePolygonModelAction.cpp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Index: mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkCreatePolygonModelAction.h
===================================================================
--- mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkCreatePolygonModelAction.h (revision 0)
+++ mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkCreatePolygonModelAction.h (revision 0)
@@ -0,0 +1,36 @@
+#ifndef QMITK_CREATEPOLYGONMODELACTION_H
+#define QMITK_CREATEPOLYGONMODELACTION_H
+
+#include "mitkQtSegmentationDll.h"
+
+#include "mitkIContextMenuAction.h"
+
+#include "mitkDataNode.h"
+#include "berryQtViewPart.h"
+
+class MITK_QT_SEGMENTATION QmitkCreatePolygonModelAction: public mitk::IContextMenuAction
+{
+
+public:
+ QmitkCreatePolygonModelAction();
+ virtual ~QmitkCreatePolygonModelAction();
+
+ //interface methods
+ void Run( const std::vector<mitk::DataNode*>& selectedNodes );
+ void SetDataStorage(mitk::DataStorage* dataStorage);
+ void SetSmoothed(bool smoothed);
+ void SetFunctionality(berry::QtViewPart* functionality);
+
+ // for receiving messages
+ void OnSurfaceCalculationDone();
+
+protected:
+
+ typedef std::vector<mitk::DataNode*> NodeList;
+
+ mitk::DataStorage::Pointer m_DataStorage;
+
+ bool m_IsSmoothed;
+
+};
+#endif // QMITK_CREATEPOLYGONMODELACTION_H
\ No newline at end of file
Property changes on: mitk\Modules\Bundles\org.mitk.gui.qt.segmentation\src\internal\QmitkCreatePolygonModelAction.h
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Index: mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkSegmentationView.cpp
===================================================================
--- mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkSegmentationView.cpp (revision 25364)
+++ mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkSegmentationView.cpp (working copy)
@@ -40,14 +40,14 @@
:m_Parent(NULL)
,m_Controls(NULL)
,m_MultiWidget(NULL)
-,m_PostProcessing(NULL)
+//,m_PostProcessing(NULL)
,m_RenderingManagerObserverTag(0)
{
}
QmitkSegmentationView::~QmitkSegmentationView()
{
- delete m_PostProcessing;
+ /*delete m_PostProcessing;*/
delete m_Controls;
}
@@ -700,8 +700,8 @@
m_Controls->MaskSurfaces->SetDataStorage(this->GetDefaultDataStorage());
m_Controls->MaskSurfaces->SetPredicate(mitk::NodePredicateDataType::New("Surface"));
- // create helper class to provide context menus for segmentations in data manager
- m_PostProcessing = new QmitkSegmentationPostProcessing(this->GetDefaultDataStorage(), this, NULL);
+ //// create helper class to provide context menus for segmentations in data manager
+ //m_PostProcessing = new QmitkSegmentationPostProcessing(this->GetDefaultDataStorage(), this, NULL);
}
Index: mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkSegmentationView.h
===================================================================
--- mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkSegmentationView.h (revision 25364)
+++ mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkSegmentationView.h (working copy)
@@ -131,7 +131,7 @@
// THE currently existing QmitkStdMultiWidget
QmitkStdMultiWidget * m_MultiWidget;
- QmitkSegmentationPostProcessing* m_PostProcessing;
+ /* QmitkSegmentationPostProcessing* m_PostProcessing;*/
unsigned long m_RenderingManagerObserverTag;
unsigned long m_SlicesRotationObserverTag1;
Index: mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkStatisticsAction.cpp
===================================================================
--- mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkStatisticsAction.cpp (revision 0)
+++ mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkStatisticsAction.cpp (revision 0)
@@ -0,0 +1,38 @@
+#include "QmitkStatisticsAction.h"
+
+#include <berryIWorkbenchPage.h>
+
+QmitkStatisticsAction::QmitkStatisticsAction(): m_BlueBerryView(NULL)
+{
+}
+
+QmitkStatisticsAction::~QmitkStatisticsAction()
+{
+}
+
+void QmitkStatisticsAction::Run(const std::vector<mitk::DataNode*>& selectedNodes)
+{
+ berry::IBundle::Pointer imageStatisticsBundle = berry::Platform::GetBundle("org.mitk.gui.qt.imagestatistics");
+
+ if (m_BlueBerryView && imageStatisticsBundle.IsNotNull())
+ {
+ m_BlueBerryView->GetSite()->GetWorkbenchWindow()->GetActivePage()->ShowView("org.mitk.views.imagestatistics");
+ }
+}
+
+void QmitkStatisticsAction::SetFunctionality(berry::QtViewPart* functionality)
+{
+ this->m_BlueBerryView = functionality;
+}
+
+void QmitkStatisticsAction::SetDataStorage(mitk::DataStorage* dataStorage)
+{
+ //not needed
+}
+
+void QmitkStatisticsAction::SetSmoothed(bool smoothed)
+{
+ //not needed
+}
+
+
Property changes on: mitk\Modules\Bundles\org.mitk.gui.qt.segmentation\src\internal\QmitkStatisticsAction.cpp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Index: mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkStatisticsAction.h
===================================================================
--- mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkStatisticsAction.h (revision 0)
+++ mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkStatisticsAction.h (revision 0)
@@ -0,0 +1,28 @@
+#ifndef QMITK_STATISTICSACTION_H
+#define QMITK_STATISTICSACTION_H
+
+#include "mitkIContextMenuAction.h"
+
+#include "mitkQtSegmentationDll.h"
+
+#include "berryQtViewPart.h"
+
+class MITK_QT_SEGMENTATION QmitkStatisticsAction: public mitk::IContextMenuAction
+{
+public:
+
+ QmitkStatisticsAction();
+ virtual ~QmitkStatisticsAction();
+
+ //interface methods
+ void Run( const std::vector<mitk::DataNode*>& selectedNodes );
+ void SetDataStorage(mitk::DataStorage* dataStorage);
+ void SetSmoothed(bool smoothed);
+ void SetFunctionality(berry::QtViewPart* functionality);
+
+protected:
+
+ //needs to be set over the IContextMenuAction (with this - QmitkDataManagerView - as parameter)
+ berry::QtViewPart* m_BlueBerryView;
+};
+#endif // QMITK_STATISTICSACTION_H
\ No newline at end of file
Property changes on: mitk\Modules\Bundles\org.mitk.gui.qt.segmentation\src\internal\QmitkStatisticsAction.h
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Index: mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkThresholdAction.cpp
===================================================================
--- mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkThresholdAction.cpp (revision 0)
+++ mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkThresholdAction.cpp (revision 0)
@@ -0,0 +1,100 @@
+#include "QmitkThresholdAction.h"
+
+#include "QmitkToolGUI.h"
+
+#include "mitkBinaryThresholdTool.h"
+#include "mitkRenderingManager.h"
+
+#include <QtGui>
+
+
+QmitkThresholdAction::QmitkThresholdAction()
+{
+}
+
+QmitkThresholdAction::~QmitkThresholdAction()
+{
+}
+
+void QmitkThresholdAction::Run(const std::vector<mitk::DataNode*> &selectedNodes)
+{
+ m_ThresholdingToolManager = mitk::ToolManager::New( m_DataStorage );
+ m_ThresholdingToolManager->RegisterClient();
+ m_ThresholdingToolManager->ActiveToolChanged +=
+ mitk::MessageDelegate<QmitkThresholdAction>( this, &QmitkThresholdAction::OnThresholdingToolManagerToolModified );
+
+ m_ThresholdingDialog = new QDialog(NULL);
+ connect( m_ThresholdingDialog, SIGNAL(finished(int)), this, SLOT(ThresholdingDone(int)) );
+
+ QVBoxLayout* layout = new QVBoxLayout;
+ layout->setContentsMargins(0, 0, 0, 0);
+
+ mitk::Tool* tool = m_ThresholdingToolManager->GetToolById( m_ThresholdingToolManager->GetToolIdByToolType<mitk::BinaryThresholdTool>() );
+ if (tool)
+ {
+ itk::Object::Pointer possibleGUI = tool->GetGUI("Qmitk", "GUI");
+ QmitkToolGUI* gui = dynamic_cast<QmitkToolGUI*>( possibleGUI.GetPointer() );
+ if (gui)
+ {
+ gui->SetTool(tool);
+ gui->setParent(m_ThresholdingDialog);
+ layout->addWidget(gui);
+ m_ThresholdingDialog->setLayout(layout);
+ layout->activate();
+ m_ThresholdingDialog->setFixedSize(300,50);
+ m_ThresholdingDialog->open();
+ }
+ }
+
+ for ( NodeList::const_iterator iter = selectedNodes.begin(); iter != selectedNodes.end(); ++iter )
+ {
+ mitk::DataNode* node = *iter;
+
+ if (node)
+ {
+ m_ThresholdingToolManager->SetReferenceData( node );
+ m_ThresholdingToolManager->ActivateTool( m_ThresholdingToolManager->GetToolIdByToolType<mitk::BinaryThresholdTool>() );
+ }
+ }
+}
+
+void QmitkThresholdAction::ThresholdingDone(int result)
+{
+ if (result == QDialog::Rejected)
+ m_ThresholdingToolManager->ActivateTool(-1);
+ MITK_INFO << "Thresholding done, cleaning up";
+ m_ThresholdingDialog->deleteLater();
+ m_ThresholdingDialog = NULL;
+ m_ThresholdingToolManager->SetReferenceData( NULL );
+ m_ThresholdingToolManager->SetWorkingData( NULL );
+
+ mitk::RenderingManager::GetInstance()->RequestUpdateAll();
+}
+
+void QmitkThresholdAction::OnThresholdingToolManagerToolModified()
+{
+ if ( m_ThresholdingToolManager.IsNull() ) return;
+
+ //MITK_INFO << "Now got tool " << m_ThresholdingToolManager->GetActiveToolID();
+
+ if ( m_ThresholdingToolManager->GetActiveToolID() < 0)
+ {
+ if (m_ThresholdingDialog)
+ m_ThresholdingDialog->accept();
+ }
+}
+
+void QmitkThresholdAction::SetDataStorage(mitk::DataStorage* dataStorage)
+{
+ this->m_DataStorage = dataStorage;
+}
+
+void QmitkThresholdAction::SetSmoothed(bool smoothed)
+{
+ //not needed
+}
+
+void QmitkThresholdAction::SetFunctionality(berry::QtViewPart* functionality)
+{
+ //not needed
+}
\ No newline at end of file
Property changes on: mitk\Modules\Bundles\org.mitk.gui.qt.segmentation\src\internal\QmitkThresholdAction.cpp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Index: mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkThresholdAction.h
===================================================================
--- mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkThresholdAction.h (revision 0)
+++ mitk/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkThresholdAction.h (revision 0)
@@ -0,0 +1,51 @@
+#ifndef QMITK_THRESHOLDACTION_H
+#define QMITK_THRESHOLDACTION_H
+
+#include "mitkIContextMenuAction.h"
+
+#include <QObject>
+
+#include "mitkQtSegmentationDll.h"
+
+#include "mitkDataStorage.h"
+#include "mitkToolManager.h"
+#include "berryQtViewPart.h"
+
+#include <berryISelectionListener.h>
+
+#include <QDialog>
+
+class MITK_QT_SEGMENTATION QmitkThresholdAction: public QObject, public mitk::IContextMenuAction
+{
+ Q_OBJECT
+
+ public:
+
+ QmitkThresholdAction();
+ virtual ~QmitkThresholdAction();
+
+ //interface methods
+ void Run( const std::vector<mitk::DataNode*>& selectedNodes );
+ void SetDataStorage(mitk::DataStorage* dataStorage);
+ void SetSmoothed(bool smoothed);
+ void SetFunctionality(berry::QtViewPart* functionality);
+
+ // for receiving messages
+ void OnThresholdingToolManagerToolModified();
+
+ protected:
+
+ typedef std::vector<mitk::DataNode*> NodeList;
+
+ mitk::DataStorage::Pointer m_DataStorage;
+ mitk::ToolManager::Pointer m_ThresholdingToolManager;
+
+ QDialog* m_ThresholdingDialog;
+
+ protected slots:
+
+ // class internal slot
+ void ThresholdingDone(int);
+};
+
+#endif // QMITK_THRESHOLDACTION_H
\ No newline at end of file
Property changes on: mitk\Modules\Bundles\org.mitk.gui.qt.segmentation\src\internal\QmitkThresholdAction.h
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native

File Metadata

Mime Type
text/plain
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
431
Default Alt Text
3281_ExtensionPointsForContextMenu.patch (33 KB)

Event Timeline

context menu implemented with extension points