diff --git a/Modules/QtWidgets/include/QmitkNodeDescriptorManager.h b/Modules/QtWidgets/include/QmitkNodeDescriptorManager.h
index 924be1623b..8b8024a523 100644
--- a/Modules/QtWidgets/include/QmitkNodeDescriptorManager.h
+++ b/Modules/QtWidgets/include/QmitkNodeDescriptorManager.h
@@ -1,117 +1,118 @@
/*===================================================================
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 QmitkNodeDescriptorManager_h
#define QmitkNodeDescriptorManager_h
#include
#include "QmitkNodeDescriptor.h"
/**
* \ingroup QmitkModule
* \brief QmitkNodeDescriptorManager manages a set of QmitkNodeDescriptors
*
* \sa QmitkNodeDescriptor
*/
class MITKQTWIDGETS_EXPORT QmitkNodeDescriptorManager : public QObject
{
Q_OBJECT
+
public:
///
/// \return the solely instance of QmitkNodeDescriptorManager
///
- static QmitkNodeDescriptorManager *GetInstance();
+ static QmitkNodeDescriptorManager* GetInstance();
///
/// Initializes the QmitkNodeDescriptorManager.
/// Adds a few standard Descriptors.
/// This Descriptors are added:
/// - A QmitkNodeDescriptor for the class of "Image" DataNodes
/// - A QmitkNodeDescriptor for the class of "Image Mask" DataNodes
/// - A QmitkNodeDescriptor for the class of "Surface" DataNodes
/// - A QmitkNodeDescriptor for the class of "PointSet" DataNodes
///
virtual void Initialize();
///
/// Adds a new descriptor to the manager. The manager takes the ownership.
///
- void AddDescriptor(QmitkNodeDescriptor *_Descriptor);
+ void AddDescriptor(QmitkNodeDescriptor* descriptor);
///
/// Removes and deletes a descriptor from the manager
///
- void RemoveDescriptor(QmitkNodeDescriptor *_Descriptor);
+ void RemoveDescriptor(QmitkNodeDescriptor* descriptor);
///
/// Get the last descriptor in the descriptors list that matches the given node.
/// *Attention*: More specialized Descriptors should therefore be appended at
/// the end of the list, e.g. first add "Image", then add "Image Mask"
///
/// \return a QmitkNodeDescriptor for the given node or a QmitkNodeDescriptor describing unknown nodes (never 0)
/// \sa AddDescriptor()
///
- QmitkNodeDescriptor *GetDescriptor(const mitk::DataNode *_Node) const;
+ QmitkNodeDescriptor* GetDescriptor(const mitk::DataNode* node) const;
///
/// Get the last QmitkNodeDescriptor for the given class name
///
/// \return a QmitkNodeDescriptor for the given class name or 0 if there is no QmitkNodeDescriptor for _ClassName
///
- QmitkNodeDescriptor *GetDescriptor(const QString &_ClassName) const;
+ QmitkNodeDescriptor* GetDescriptor(const QString& className) const;
///
/// \return The UnknownDataNodeDescriptor, which is the default Descriptor for all Nodes.
///
- QmitkNodeDescriptor *GetUnknownDataNodeDescriptor() const;
+ QmitkNodeDescriptor* GetUnknownDataNodeDescriptor() const;
///
/// Returns a list of all actions that are associated with the given node.
/// If there are more than one Descriptors for this node all actions
/// will be merged together.
/// E.g. all actions from the "unknown" DataNodes will be added to
/// this list. Generic Actions like Save, Load, etc. are stored there.
///
- QList GetActions(const mitk::DataNode *_Node) const;
+ QList GetActions(const mitk::DataNode* node) const;
///
/// \return a list of actions associated with the given nodes
///
- QList GetActions(const QList &_Nodes) const;
+ QList GetActions(const QList& nodes) const;
///
/// Deletes all Descriptors in the list
///
~QmitkNodeDescriptorManager() override;
protected:
///
/// Creates the m_UnknownDataNodeDescriptor
/// Calls Initialize
///
QmitkNodeDescriptorManager();
protected:
///
/// This is the standard QmitkNodeDescriptor matching every node
///
- QmitkNodeDescriptor *m_UnknownDataNodeDescriptor;
+ QmitkNodeDescriptor* m_UnknownDataNodeDescriptor;
///
/// Holds all user defined descriptors
///
- QList m_NodeDescriptors;
+ QList m_NodeDescriptors;
};
#endif // QmitkNodeDescriptorManager_h
diff --git a/Modules/QtWidgets/src/QmitkNodeDescriptorManager.cpp b/Modules/QtWidgets/src/QmitkNodeDescriptorManager.cpp
index 1a7b67c88c..c8d380adac 100644
--- a/Modules/QtWidgets/src/QmitkNodeDescriptorManager.cpp
+++ b/Modules/QtWidgets/src/QmitkNodeDescriptorManager.cpp
@@ -1,180 +1,175 @@
/*===================================================================
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 "QmitkNodeDescriptorManager.h"
#include
#include
#include
#include
#include
#include
#include
#include
-QmitkNodeDescriptorManager *QmitkNodeDescriptorManager::GetInstance()
+QmitkNodeDescriptorManager* QmitkNodeDescriptorManager::GetInstance()
{
- static QmitkNodeDescriptorManager _Instance;
- return &_Instance;
+ static QmitkNodeDescriptorManager instance;
+ return &instance;
}
void QmitkNodeDescriptorManager::Initialize()
{
auto isImage = mitk::NodePredicateDataType::New("Image");
- this->AddDescriptor(new QmitkNodeDescriptor(tr("Image"), QString(":/Qmitk/Images_48.png"), isImage, this));
+ AddDescriptor(new QmitkNodeDescriptor(tr("Image"), QString(":/Qmitk/Images_48.png"), isImage, this));
- auto isMultiComponentImage =
- mitk::NodePredicateAnd::New(isImage, mitk::NodePredicateProperty::New("Image.Displayed Component"));
- this->AddDescriptor(new QmitkNodeDescriptor(
- tr("MultiComponentImage"), QString(": / Qmitk / Images_48.png"), isMultiComponentImage, this));
+ auto isMultiComponentImage = mitk::NodePredicateAnd::New(isImage, mitk::NodePredicateProperty::New("Image.Displayed Component"));
+ AddDescriptor(new QmitkNodeDescriptor(tr("MultiComponentImage"), QString(": / Qmitk / Images_48.png"), isMultiComponentImage, this));
auto isBinary = mitk::NodePredicateProperty::New("binary", mitk::BoolProperty::New(true));
auto isBinaryImage = mitk::NodePredicateAnd::New(isBinary, isImage);
- this->AddDescriptor(
- new QmitkNodeDescriptor(tr("ImageMask"), QString(":/Qmitk/Binaerbilder_48.png"), isBinaryImage, this));
+ AddDescriptor(new QmitkNodeDescriptor(tr("ImageMask"), QString(":/Qmitk/Binaerbilder_48.png"), isBinaryImage, this));
auto isLabelSetImage = mitk::NodePredicateDataType::New("LabelSetImage");
- this->AddDescriptor(
- new QmitkNodeDescriptor(tr("LabelSetImage"), QString(":/Qmitk/LabelSetImage_48.png"), isLabelSetImage, this));
+ AddDescriptor(new QmitkNodeDescriptor(tr("LabelSetImage"), QString(":/Qmitk/LabelSetImage_48.png"), isLabelSetImage, this));
auto isPointSet = mitk::NodePredicateDataType::New("PointSet");
- this->AddDescriptor(new QmitkNodeDescriptor(tr("PointSet"), QString(":/Qmitk/PointSet_48.png"), isPointSet, this));
+ AddDescriptor(new QmitkNodeDescriptor(tr("PointSet"), QString(":/Qmitk/PointSet_48.png"), isPointSet, this));
auto isSurface = mitk::NodePredicateDataType::New("Surface");
- this->AddDescriptor(new QmitkNodeDescriptor(tr("Surface"), QString(":/Qmitk/Surface_48.png"), isSurface, this));
+ AddDescriptor(new QmitkNodeDescriptor(tr("Surface"), QString(":/Qmitk/Surface_48.png"), isSurface, this));
auto isNotBinary = mitk::NodePredicateNot::New(isBinary);
auto isNoneBinaryImage = mitk::NodePredicateAnd::New(isImage, isNotBinary);
- this->AddDescriptor(
- new QmitkNodeDescriptor(tr("NoneBinaryImage"), QString(":/Qmitk/Images_48.png"), isNoneBinaryImage, this));
+ AddDescriptor(new QmitkNodeDescriptor(tr("NoneBinaryImage"), QString(":/Qmitk/Images_48.png"), isNoneBinaryImage, this));
}
-void QmitkNodeDescriptorManager::AddDescriptor(QmitkNodeDescriptor *_Descriptor)
+void QmitkNodeDescriptorManager::AddDescriptor(QmitkNodeDescriptor* descriptor)
{
- _Descriptor->setParent(this);
- m_NodeDescriptors.push_back(_Descriptor);
+ descriptor->setParent(this);
+ m_NodeDescriptors.push_back(descriptor);
}
-void QmitkNodeDescriptorManager::RemoveDescriptor(QmitkNodeDescriptor *_Descriptor)
+void QmitkNodeDescriptorManager::RemoveDescriptor(QmitkNodeDescriptor* descriptor)
{
- int index = m_NodeDescriptors.indexOf(_Descriptor);
+ int index = m_NodeDescriptors.indexOf(descriptor);
if (index != -1)
{
m_NodeDescriptors.removeAt(index);
- _Descriptor->setParent(nullptr);
- delete _Descriptor;
+ descriptor->setParent(nullptr);
+ delete descriptor;
}
}
-QmitkNodeDescriptor *QmitkNodeDescriptorManager::GetDescriptor(const mitk::DataNode *_Node) const
+QmitkNodeDescriptor* QmitkNodeDescriptorManager::GetDescriptor(const mitk::DataNode* node) const
{
- QmitkNodeDescriptor *_Descriptor = m_UnknownDataNodeDescriptor;
+ QmitkNodeDescriptor* descriptor = m_UnknownDataNodeDescriptor;
for (QList::const_iterator it = m_NodeDescriptors.begin(); it != m_NodeDescriptors.end(); ++it)
{
- if ((*it)->CheckNode(_Node))
- _Descriptor = *it;
+ if ((*it)->CheckNode(node))
+ descriptor = *it;
}
- return _Descriptor;
+ return descriptor;
}
-QmitkNodeDescriptor *QmitkNodeDescriptorManager::GetDescriptor(const QString &_ClassName) const
+QmitkNodeDescriptor* QmitkNodeDescriptorManager::GetDescriptor(const QString& className) const
{
- QmitkNodeDescriptor *_Descriptor = nullptr;
+ QmitkNodeDescriptor* descriptor = nullptr;
- if (_ClassName == "Unknown")
+ if (className == "Unknown")
{
return m_UnknownDataNodeDescriptor;
}
else
{
- for (QList::const_iterator it = m_NodeDescriptors.begin(); it != m_NodeDescriptors.end();
- ++it)
+ for (QList::const_iterator it = m_NodeDescriptors.begin(); it != m_NodeDescriptors.end(); ++it)
{
- if ((*it)->GetNameOfClass() == _ClassName)
- _Descriptor = *it;
+ if ((*it)->GetNameOfClass() == className)
+ descriptor = *it;
}
}
- return _Descriptor;
+ return descriptor;
}
-QList QmitkNodeDescriptorManager::GetActions(const mitk::DataNode *_Node) const
+
+QList QmitkNodeDescriptorManager::GetActions(const mitk::DataNode* node) const
{
- QList actions = m_UnknownDataNodeDescriptor->GetBatchActions();
+ QList actions = m_UnknownDataNodeDescriptor->GetBatchActions();
actions.append(m_UnknownDataNodeDescriptor->GetActions());
- QmitkNodeDescriptor *lastDescriptor = m_UnknownDataNodeDescriptor;
+ QmitkNodeDescriptor* lastDescriptor = m_UnknownDataNodeDescriptor;
for (QList::const_iterator it = m_NodeDescriptors.begin(); it != m_NodeDescriptors.end(); ++it)
{
- if ((*it)->CheckNode(_Node))
+ if ((*it)->CheckNode(node))
{
actions.append(lastDescriptor->GetSeparator());
lastDescriptor = *it;
actions.append(lastDescriptor->GetBatchActions());
actions.append(lastDescriptor->GetActions());
}
}
return actions;
}
-QList QmitkNodeDescriptorManager::GetActions(const QList &_Nodes) const
+QList QmitkNodeDescriptorManager::GetActions(const QList& nodes) const
{
- QList actions = m_UnknownDataNodeDescriptor->GetBatchActions();
- QSet nodeDescriptors;
- QmitkNodeDescriptor *lastDescriptor;
+ QList actions = m_UnknownDataNodeDescriptor->GetBatchActions();
+ QmitkNodeDescriptor* lastDescriptor = m_UnknownDataNodeDescriptor;
// find all descriptors for the nodes (unique)
- foreach (mitk::DataNode::Pointer node, _Nodes)
+ QSet nodeDescriptors;
+ for (const auto& node : nodes)
{
- for (QList::const_iterator it = m_NodeDescriptors.begin(); it != m_NodeDescriptors.end(); ++it)
+ for (QList::const_iterator it = m_NodeDescriptors.begin(); it != m_NodeDescriptors.end(); ++it)
{
if ((*it)->CheckNode(node))
{
nodeDescriptors.insert(*it);
}
}
}
+
// add all actions for the found descriptors
- lastDescriptor = m_UnknownDataNodeDescriptor;
- foreach (QmitkNodeDescriptor *descr, nodeDescriptors)
+ for (const auto& nodeDescriptor : nodeDescriptors)
{
actions.append(lastDescriptor->GetSeparator());
- lastDescriptor = descr;
+ lastDescriptor = nodeDescriptor;
actions.append(lastDescriptor->GetBatchActions());
}
return actions;
}
QmitkNodeDescriptorManager::QmitkNodeDescriptorManager()
: m_UnknownDataNodeDescriptor(new QmitkNodeDescriptor("Unknown", QString(":/Qmitk/DataTypeUnknown_48.png"), nullptr, this))
{
- this->Initialize();
+ Initialize();
}
QmitkNodeDescriptorManager::~QmitkNodeDescriptorManager()
{
// delete m_UnknownDataNodeDescriptor;
// qDeleteAll(m_NodeDescriptors);
}
QmitkNodeDescriptor *QmitkNodeDescriptorManager::GetUnknownDataNodeDescriptor() const
{
return m_UnknownDataNodeDescriptor;
}
diff --git a/Modules/QtWidgetsExt/include/QmitkHotkeyLineEdit.h b/Modules/QtWidgetsExt/include/QmitkHotkeyLineEdit.h
index fc27f4cfdb..f4818e5798 100644
--- a/Modules/QtWidgetsExt/include/QmitkHotkeyLineEdit.h
+++ b/Modules/QtWidgetsExt/include/QmitkHotkeyLineEdit.h
@@ -1,52 +1,57 @@
/*===================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
-#ifndef QMITKHOTKEYLINEEDIT_H_
-#define QMITKHOTKEYLINEEDIT_H_
+#ifndef QMITKHOTKEYLINEEDIT_H
+#define QMITKHOTKEYLINEEDIT_H
+#include "MitkQtWidgetsExtExports.h"
+
+// qt
#include
#include
-#include "MitkQtWidgetsExtExports.h"
-
class MITKQTWIDGETSEXT_EXPORT QmitkHotkeyLineEdit : public QLineEdit
{
Q_OBJECT
public:
+
static const std::string TOOLTIP;
- QmitkHotkeyLineEdit(QWidget *parent = nullptr);
- QmitkHotkeyLineEdit(const QKeySequence &_QKeySequence, QWidget *parent = nullptr);
- QmitkHotkeyLineEdit(const QString &_QString, QWidget *parent = nullptr);
+ QmitkHotkeyLineEdit(QWidget* parent = nullptr);
+ QmitkHotkeyLineEdit(const QKeySequence& qKeySequence, QWidget* parent = nullptr);
+ QmitkHotkeyLineEdit(const QString& qQString, QWidget* parent = nullptr);
- virtual void SetKeySequence(const QKeySequence &_QKeySequence);
- virtual void SetKeySequence(const QString &_QKeySequenceAsString);
+ virtual void SetKeySequence(const QKeySequence& qKeySequence);
+ virtual void SetKeySequence(const QString& qKeySequenceAsString);
virtual QKeySequence GetKeySequence();
virtual QString GetKeySequenceAsString();
bool Matches(QKeyEvent *event);
-protected slots:
- void LineEditTextChanged(const QString &);
+
+protected Q_SLOTS:
+
+ void LineEditTextChanged(const QString&);
protected:
- void keyPressEvent(QKeyEvent *event) override;
+
+ virtual void keyPressEvent(QKeyEvent* event) override;
void Init();
-protected:
QKeySequence m_KeySequence;
+
};
-#endif
+#endif // QMITKHOTKEYLINEEDIT_H
diff --git a/Modules/QtWidgetsExt/src/QmitkHotkeyLineEdit.cpp b/Modules/QtWidgetsExt/src/QmitkHotkeyLineEdit.cpp
index 541d905d2c..a884b3b50a 100644
--- a/Modules/QtWidgetsExt/src/QmitkHotkeyLineEdit.cpp
+++ b/Modules/QtWidgetsExt/src/QmitkHotkeyLineEdit.cpp
@@ -1,101 +1,101 @@
/*===================================================================
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 "QmitkHotkeyLineEdit.h"
#include
#include
#include
#include
const std::string QmitkHotkeyLineEdit::TOOLTIP = "Press any key (combination)";
-QmitkHotkeyLineEdit::QmitkHotkeyLineEdit(QWidget *parent) : QLineEdit(parent)
+QmitkHotkeyLineEdit::QmitkHotkeyLineEdit(QWidget* parent /*= nullptr*/)
+ : QLineEdit(parent)
{
- this->Init();
+ Init();
}
-QmitkHotkeyLineEdit::QmitkHotkeyLineEdit(const QKeySequence &_QKeySequence, QWidget *parent) : QLineEdit(parent)
+QmitkHotkeyLineEdit::QmitkHotkeyLineEdit(const QKeySequence& qKeySequence, QWidget* parent /*= nullptr*/)
+ : QLineEdit(parent)
{
- this->Init();
- this->SetKeySequence(_QKeySequence);
+ Init();
+ SetKeySequence(qKeySequence);
}
-QmitkHotkeyLineEdit::QmitkHotkeyLineEdit(const QString &_QKeySequenceAsString, QWidget *parent) : QLineEdit(parent)
+QmitkHotkeyLineEdit::QmitkHotkeyLineEdit(const QString& qKeySequenceAsString, QWidget* parent /*= nullptr*/)
+ : QLineEdit(parent)
{
- this->Init();
- this->SetKeySequence(_QKeySequenceAsString);
+ Init();
+ SetKeySequence(qKeySequenceAsString);
}
void QmitkHotkeyLineEdit::Init()
{
- this->setToolTip(QString::fromStdString(QmitkHotkeyLineEdit::TOOLTIP));
- this->setReadOnly(true);
- connect(this, SIGNAL(textChanged(const QString &)), this, SLOT(LineEditTextChanged(const QString &)));
+ setToolTip(QString::fromStdString(QmitkHotkeyLineEdit::TOOLTIP));
+ setReadOnly(true);
+ connect(this, &QLineEdit::textChanged, this, &QmitkHotkeyLineEdit::LineEditTextChanged);
}
-void QmitkHotkeyLineEdit::keyPressEvent(QKeyEvent *event)
+void QmitkHotkeyLineEdit::keyPressEvent(QKeyEvent* event)
{
if (event->key() == Qt::Key_unknown)
+ {
return;
+ }
else if (event->key() == Qt::Key_Escape)
+ {
m_KeySequence = QKeySequence();
-
+ }
else
{
- m_KeySequence = QKeySequence(event->modifiers(), event->key());
- // if no modifier was pressed the sequence is now empty
- if (event->modifiers() == Qt::NoModifier)
- m_KeySequence = QKeySequence(event->key());
+ m_KeySequence = QKeySequence(event->modifiers() + event->key());
}
- this->SetKeySequence(m_KeySequence);
+ SetKeySequence(m_KeySequence);
}
-void QmitkHotkeyLineEdit::SetKeySequence(const QKeySequence &_QKeySequence)
+void QmitkHotkeyLineEdit::SetKeySequence(const QKeySequence& qKeySequence)
{
- this->setText(_QKeySequence.toString());
+ setText(qKeySequence.toString());
}
-void QmitkHotkeyLineEdit::SetKeySequence(const QString &_QKeySequenceAsString)
+void QmitkHotkeyLineEdit::SetKeySequence(const QString& qKeySequenceAsString)
{
- this->SetKeySequence(QKeySequence(_QKeySequenceAsString));
+ SetKeySequence(QKeySequence(qKeySequenceAsString));
}
QKeySequence QmitkHotkeyLineEdit::GetKeySequence()
{
return m_KeySequence;
}
QString QmitkHotkeyLineEdit::GetKeySequenceAsString()
{
return m_KeySequence.toString();
}
-bool QmitkHotkeyLineEdit::Matches(QKeyEvent *event)
+bool QmitkHotkeyLineEdit::Matches(QKeyEvent* event)
{
- QKeySequence _KeySequence = QKeySequence(event->modifiers(), event->key());
- // if no modifier was pressed the sequence is now empty
- if (event->modifiers() == Qt::NoModifier)
- _KeySequence = QKeySequence(event->key());
+ QKeySequence keySequence = QKeySequence(event->modifiers() + event->key());
- return _KeySequence == m_KeySequence;
+ return keySequence == m_KeySequence;
}
-void QmitkHotkeyLineEdit::LineEditTextChanged(const QString &text)
+void QmitkHotkeyLineEdit::LineEditTextChanged(const QString& text)
{
m_KeySequence = QKeySequence(text.toUpper());
}
diff --git a/Plugins/org.mitk.gui.common/src/mitkWorkbenchUtil.cpp b/Plugins/org.mitk.gui.common/src/mitkWorkbenchUtil.cpp
index 3a0fc9455b..7c569071d6 100644
--- a/Plugins/org.mitk.gui.common/src/mitkWorkbenchUtil.cpp
+++ b/Plugins/org.mitk.gui.common/src/mitkWorkbenchUtil.cpp
@@ -1,376 +1,475 @@
/*===================================================================
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 "mitkWorkbenchUtil.h"
#include
#include
#include
#include
#include
#include
#include "mitkIDataStorageService.h"
#include "mitkDataStorageEditorInput.h"
#include "mitkRenderingManager.h"
-#include "mitkIRenderWindowPart.h"
#include "mitkIRenderingManager.h"
#include "mitkProperties.h"
#include "mitkNodePredicateData.h"
#include "mitkNodePredicateNot.h"
#include "mitkNodePredicateProperty.h"
#include "mitkCoreObjectFactory.h"
#include "QmitkIOUtil.h"
#include
#include
#include
#include "internal/org_mitk_gui_common_Activator.h"
namespace mitk {
-struct WorkbenchUtilPrivate {
-
- /**
- * Get the editor descriptor for a given name using the editorDescriptor
- * passed in as a default as a starting point.
- *
- * @param name
- * The name of the element to open.
- * @param editorReg
- * The editor registry to do the lookups from.
- * @param defaultDescriptor
- * IEditorDescriptor or null
- * @return IEditorDescriptor
- * @throws PartInitException
- * if no valid editor can be found
- */
- static berry::IEditorDescriptor::Pointer GetEditorDescriptor(const QString& name,
- berry::IEditorRegistry* editorReg,
- berry::IEditorDescriptor::Pointer defaultDescriptor)
- {
-
- if (defaultDescriptor.IsNotNull())
+ struct WorkbenchUtilPrivate {
+
+ /**
+ * Get the editor descriptor for a given name using the editorDescriptor
+ * passed in as a default as a starting point.
+ *
+ * @param name
+ * The name of the element to open.
+ * @param editorReg
+ * The editor registry to do the lookups from.
+ * @param defaultDescriptor
+ * IEditorDescriptor or null
+ * @return IEditorDescriptor
+ * @throws PartInitException
+ * if no valid editor can be found
+ */
+ static berry::IEditorDescriptor::Pointer GetEditorDescriptor(const QString& name, berry::IEditorRegistry* editorReg, berry::IEditorDescriptor::Pointer defaultDescriptor)
{
- return defaultDescriptor;
- }
+ if (defaultDescriptor.IsNotNull())
+ {
+ return defaultDescriptor;
+ }
- berry::IEditorDescriptor::Pointer editorDesc = defaultDescriptor;
+ berry::IEditorDescriptor::Pointer editorDesc = defaultDescriptor;
- // next check the OS for in-place editor (OLE on Win32)
- if (editorReg->IsSystemInPlaceEditorAvailable(name))
- {
- editorDesc = editorReg->FindEditor(berry::IEditorRegistry::SYSTEM_INPLACE_EDITOR_ID);
- }
+ // next check the OS for in-place editor (OLE on Win32)
+ if (editorReg->IsSystemInPlaceEditorAvailable(name))
+ {
+ editorDesc = editorReg->FindEditor(berry::IEditorRegistry::SYSTEM_INPLACE_EDITOR_ID);
+ }
- // next check with the OS for an external editor
- if (editorDesc.IsNull() && editorReg->IsSystemExternalEditorAvailable(name))
- {
- editorDesc = editorReg->FindEditor(berry::IEditorRegistry::SYSTEM_EXTERNAL_EDITOR_ID);
+ // next check with the OS for an external editor
+ if (editorDesc.IsNull() && editorReg->IsSystemExternalEditorAvailable(name))
+ {
+ editorDesc = editorReg->FindEditor(berry::IEditorRegistry::SYSTEM_EXTERNAL_EDITOR_ID);
+ }
+
+ // if no valid editor found, bail out
+ if (editorDesc.IsNull())
+ {
+ throw berry::PartInitException("No editor found");
+ }
+
+ return editorDesc;
}
- // if no valid editor found, bail out
- if (editorDesc.IsNull())
+ static mitk::IDataStorageReference::Pointer GetDataStorageReference()
{
- throw berry::PartInitException("No editor found");
- }
+ ctkPluginContext* context = mitk::PluginActivator::GetContext();
+ mitk::IDataStorageService* dss = nullptr;
+ ctkServiceReference dsRef = context->getServiceReference();
+ if (dsRef)
+ {
+ dss = context->getService(dsRef);
+ }
- return editorDesc;
- }
-};
-// //! [UtilLoadFiles]
-void WorkbenchUtil::LoadFiles(const QStringList &fileNames, berry::IWorkbenchWindow::Pointer window, bool openEditor)
-// //! [UtilLoadFiles]
-{
- if (fileNames.empty())
- return;
+ if (nullptr == dss)
+ {
+ QString msg = "IDataStorageService service not available. Unable to open files.";
+ MITK_WARN << msg.toStdString();
+ QMessageBox::warning(QApplication::activeWindow(), "Unable to open files", msg);
+ return mitk::IDataStorageReference::Pointer(nullptr);
+ }
- mitk::IDataStorageReference::Pointer dataStorageRef;
+ // Get the active data storage (or the default one, if none is active)
+ mitk::IDataStorageReference::Pointer dataStorageRef = dss->GetDataStorage();
+ context->ungetService(dsRef);
+ return dataStorageRef;
+ }
+
+ }; // end struct WorkbenchUtilPrivate
+
+ void WorkbenchUtil::LoadFiles(const QStringList &fileNames, berry::IWorkbenchWindow::Pointer window, bool openEditor)
{
- ctkPluginContext* context = mitk::PluginActivator::GetContext();
- mitk::IDataStorageService* dss = nullptr;
- ctkServiceReference dsRef = context->getServiceReference();
- if (dsRef)
+ if (fileNames.empty())
{
- dss = context->getService(dsRef);
+ return;
}
- if (!dss)
+ mitk::IDataStorageReference::Pointer dataStorageReference = WorkbenchUtilPrivate::GetDataStorageReference();
+ if (nullptr == dataStorageReference)
{
- QString msg = "IDataStorageService service not available. Unable to open files.";
- MITK_WARN << msg.toStdString();
- QMessageBox::warning(QApplication::activeWindow(), "Unable to open files", msg);
return;
}
+ mitk::DataStorage::Pointer dataStorage = dataStorageReference->GetDataStorage();
- // Get the active data storage (or the default one, if none is active)
- dataStorageRef = dss->GetDataStorage();
- context->ungetService(dsRef);
- }
-
- mitk::DataStorage::Pointer dataStorage = dataStorageRef->GetDataStorage();
-
- // Do the actual work of loading the data into the data storage
-
- // Turn off ASSERT
- #if defined(_MSC_VER) && !defined(NDEBUG) && defined(_DEBUG) && defined(_CRT_ERROR)
- int lastCrtReportType = _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_DEBUG );
- #endif
+ // Turn off ASSERT
+#if defined(_MSC_VER) && !defined(NDEBUG) && defined(_DEBUG) && defined(_CRT_ERROR)
+ int lastCrtReportType = _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG);
+#endif
- DataStorage::SetOfObjects::Pointer data;
- try
- {
- data = QmitkIOUtil::Load(fileNames, *dataStorage);
- }
- catch (const mitk::Exception& e)
- {
- MITK_INFO << e;
- return;
- }
- const bool dsmodified = !data->empty();
+ // Do the actual work of loading the data into the data storage
+ DataStorage::SetOfObjects::Pointer data;
+ try
+ {
+ data = QmitkIOUtil::Load(fileNames, *dataStorage);
+ }
+ catch (const mitk::Exception& e)
+ {
+ MITK_INFO << e;
+ return;
+ }
+ const bool dsmodified = !data->empty();
- // Set ASSERT status back to previous status.
- #if defined(_MSC_VER) && !defined(NDEBUG) && defined(_DEBUG) && defined(_CRT_ERROR)
+ // Set ASSERT status back to previous status.
+#if defined(_MSC_VER) && !defined(NDEBUG) && defined(_DEBUG) && defined(_CRT_ERROR)
if (lastCrtReportType)
- _CrtSetReportMode( _CRT_ASSERT, lastCrtReportType );
- #endif
+ _CrtSetReportMode(_CRT_ASSERT, lastCrtReportType);
+#endif
- // Check if there is an open perspective. If not, open the default perspective.
- if (window->GetActivePage().IsNull())
- {
- QString defaultPerspId = window->GetWorkbench()->GetPerspectiveRegistry()->GetDefaultPerspective();
- window->GetWorkbench()->ShowPerspective(defaultPerspId, window);
- }
+ // Check if there is an open perspective. If not, open the default perspective.
+ if (window->GetActivePage().IsNull())
+ {
+ QString defaultPerspId = window->GetWorkbench()->GetPerspectiveRegistry()->GetDefaultPerspective();
+ window->GetWorkbench()->ShowPerspective(defaultPerspId, window);
+ }
- bool globalReinitOnNodeAdded = true;
- berry::IPreferencesService* prefService = berry::Platform::GetPreferencesService();
- if (prefService != nullptr)
- {
+ bool globalReinitOnNodeAdded = true;
+ berry::IPreferencesService* prefService = berry::Platform::GetPreferencesService();
+ if (prefService != nullptr)
+ {
berry::IPreferences::Pointer prefs
- = prefService->GetSystemPreferences()->Node("org.mitk.views.datamanager");
- if(prefs.IsNotNull())
+ = prefService->GetSystemPreferences()->Node("org.mitk.views.datamanager");
+ if (prefs.IsNotNull())
{
globalReinitOnNodeAdded = prefs->GetBool("Call global reinit if node is added", true);
}
- }
+ }
- if (openEditor && globalReinitOnNodeAdded)
- {
- try
+ if (openEditor && globalReinitOnNodeAdded)
{
- // Activate the editor using the same data storage or open the default editor
- mitk::DataStorageEditorInput::Pointer input(new mitk::DataStorageEditorInput(dataStorageRef));
- berry::IEditorPart::Pointer editor = mitk::WorkbenchUtil::OpenEditor(window->GetActivePage(), input, true);
- mitk::IRenderWindowPart* renderEditor = dynamic_cast(editor.GetPointer());
- mitk::IRenderingManager* renderingManager = renderEditor == nullptr ? nullptr : renderEditor->GetRenderingManager();
-
- if(dsmodified && renderingManager)
+ try
{
- mitk::RenderingManager::GetInstance()->InitializeViewsByBoundingObjects(dataStorage);
+ // Activate the editor using the same data storage or open the default editor
+ mitk::DataStorageEditorInput::Pointer input(new mitk::DataStorageEditorInput(dataStorageReference));
+ berry::IEditorPart::Pointer editor = mitk::WorkbenchUtil::OpenEditor(window->GetActivePage(), input, true);
+ mitk::IRenderWindowPart* renderEditor = dynamic_cast(editor.GetPointer());
+ mitk::IRenderingManager* renderingManager = renderEditor == nullptr ? nullptr : renderEditor->GetRenderingManager();
+
+ if (dsmodified && renderingManager)
+ {
+ mitk::RenderingManager::GetInstance()->InitializeViewsByBoundingObjects(dataStorage);
+ }
+ }
+ catch (const berry::PartInitException& e)
+ {
+ QString msg = "An error occurred when displaying the file(s): %1";
+ QMessageBox::warning(QApplication::activeWindow(), "Error displaying file",
+ msg.arg(e.message()));
}
- }
- catch (const berry::PartInitException& e)
- {
- QString msg = "An error occurred when displaying the file(s): %1";
- QMessageBox::warning(QApplication::activeWindow(), "Error displaying file",
- msg.arg(e.message()));
}
}
-}
-
-berry::IEditorPart::Pointer WorkbenchUtil::OpenEditor(berry::IWorkbenchPage::Pointer page,
- berry::IEditorInput::Pointer input,
- const QString &editorId, bool activate)
-{
- // sanity checks
- if (page.IsNull())
+
+ berry::IEditorPart::Pointer WorkbenchUtil::OpenEditor(berry::IWorkbenchPage::Pointer page, berry::IEditorInput::Pointer input, const QString &editorId, bool activate)
{
- throw std::invalid_argument("page argument must not be nullptr");
+ // sanity checks
+ if (page.IsNull())
+ {
+ throw std::invalid_argument("page argument must not be nullptr");
+ }
+
+ // open the editor on the input
+ return page->OpenEditor(input, editorId, activate);
}
- // open the editor on the input
- return page->OpenEditor(input, editorId, activate);
-}
-
-berry::IEditorPart::Pointer WorkbenchUtil::OpenEditor(berry::IWorkbenchPage::Pointer page,
- mitk::DataStorageEditorInput::Pointer input,
- bool activate,
- bool determineContentType)
-{
- // sanity checks
- if (page.IsNull())
+ berry::IEditorPart::Pointer WorkbenchUtil::OpenEditor(berry::IWorkbenchPage::Pointer page, mitk::DataStorageEditorInput::Pointer input, bool activate, bool determineContentType)
{
- throw std::invalid_argument("page argument must not be nullptr");
+ // sanity checks
+ if (page.IsNull())
+ {
+ throw std::invalid_argument("page argument must not be nullptr");
+ }
+
+ // open the editor on the data storage
+ QString name = input->GetName() + ".mitk";
+ berry::IEditorDescriptor::Pointer editorDesc = WorkbenchUtilPrivate::GetEditorDescriptor(name,
+ berry::PlatformUI::GetWorkbench()->GetEditorRegistry(),
+ GetDefaultEditor(name, determineContentType));
+
+ return page->OpenEditor(input, editorDesc->GetId(), activate);
}
- // open the editor on the data storage
- QString name = input->GetName() + ".mitk";
- berry::IEditorDescriptor::Pointer editorDesc =
- WorkbenchUtilPrivate::GetEditorDescriptor(name,
- berry::PlatformUI::GetWorkbench()->GetEditorRegistry(),
- GetDefaultEditor(name, determineContentType));
- return page->OpenEditor(input, editorDesc->GetId(), activate);
-}
-
-berry::IEditorDescriptor::Pointer WorkbenchUtil::GetEditorDescriptor(
- const QString& name, bool /*inferContentType*/)
-{
- if (name.isEmpty())
+ berry::IEditorDescriptor::Pointer WorkbenchUtil::GetEditorDescriptor(const QString& name, bool /*inferContentType*/)
{
- throw std::invalid_argument("name argument must not be empty");
- }
+ if (name.isEmpty())
+ {
+ throw std::invalid_argument("name argument must not be empty");
+ }
- // no used for now
- //IContentType contentType = inferContentType ? Platform
- // .getContentTypeManager().findContentTypeFor(name) : null;
+ // no used for now
+ //IContentType contentType = inferContentType ? Platform
+ // .getContentTypeManager().findContentTypeFor(name) : null;
- berry::IEditorRegistry* editorReg = berry::PlatformUI::GetWorkbench()->GetEditorRegistry();
+ berry::IEditorRegistry* editorReg = berry::PlatformUI::GetWorkbench()->GetEditorRegistry();
- return WorkbenchUtilPrivate::GetEditorDescriptor(name, editorReg,
- editorReg->GetDefaultEditor(name /*, contentType*/));
-}
+ return WorkbenchUtilPrivate::GetEditorDescriptor(name, editorReg, editorReg->GetDefaultEditor(name /*, contentType*/));
+ }
-berry::IEditorDescriptor::Pointer WorkbenchUtil::GetDefaultEditor(const QString& name,
- bool /*determineContentType*/)
-{
- // Try file specific editor.
- berry::IEditorRegistry* editorReg = berry::PlatformUI::GetWorkbench()->GetEditorRegistry();
- try
+ berry::IEditorDescriptor::Pointer WorkbenchUtil::GetDefaultEditor(const QString& name, bool /*determineContentType*/)
{
- QString editorID; // = file.getPersistentProperty(EDITOR_KEY);
- if (!editorID.isEmpty())
+ // Try file specific editor.
+ berry::IEditorRegistry* editorReg = berry::PlatformUI::GetWorkbench()->GetEditorRegistry();
+ try
{
- berry::IEditorDescriptor::Pointer desc = editorReg->FindEditor(editorID);
- if (desc.IsNotNull())
+ QString editorID; // = file.getPersistentProperty(EDITOR_KEY);
+ if (!editorID.isEmpty())
{
- return desc;
+ berry::IEditorDescriptor::Pointer desc = editorReg->FindEditor(editorID);
+ if (desc.IsNotNull())
+ {
+ return desc;
+ }
}
}
- }
- catch (const berry::CoreException&)
- {
- // do nothing
- }
+ catch (const berry::CoreException&)
+ {
+ // do nothing
+ }
-// IContentType contentType = null;
-// if (determineContentType)
-// {
-// contentType = getContentType(file);
-// }
+ // IContentType contentType = null;
+ // if (determineContentType)
+ // {
+ // contentType = getContentType(file);
+ // }
- // Try lookup with filename
- return editorReg->GetDefaultEditor(name); //, contentType);
-}
+ // Try lookup with filename
+ return editorReg->GetDefaultEditor(name); //, contentType);
+ }
-bool WorkbenchUtil::SetDepartmentLogoPreference(const QString &logoResource, ctkPluginContext *context)
-{
- if (context == nullptr)
+ mitk::IRenderWindowPart* WorkbenchUtil::GetRenderWindowPart(berry::IWorkbenchPage::Pointer page, IRenderWindowPartStrategies strategies)
{
- BERRY_WARN << "Plugin context invalid, unable to set custom logo.";
- return false;
- }
+ // Return the active editor if it implements mitk::IRenderWindowPart
+ mitk::IRenderWindowPart* renderWindowPart = dynamic_cast(page->GetActiveEditor().GetPointer());
+ if (renderWindowPart)
+ {
+ return renderWindowPart;
+ }
- // The logo must be available in the local filesystem. We check if we have not already extracted the
- // logo from the plug-in or if this plug-ins timestamp is newer then the already extracted logo timestamp.
- // If one of the conditions is true, extract it and write it to the plug-in specific storage location.
- const QString logoFileName = logoResource.mid(logoResource.lastIndexOf('/')+1);
+ // No suitable active editor found, check visible editors
+ QList editors = page->GetEditorReferences();
+ for (QList::iterator i = editors.begin(); i != editors.end(); ++i)
+ {
+ berry::IWorkbenchPart::Pointer part = (*i)->GetPart(false);
+ if (page->IsPartVisible(part))
+ {
+ renderWindowPart = dynamic_cast(part.GetPointer());
+ if (renderWindowPart)
+ {
+ return renderWindowPart;
+ }
+ }
+ }
- if (logoFileName.isEmpty())
- {
- BERRY_WARN << "Logo file name empty, unable to set custom logo.";
- return false;
- }
+ // No suitable visible editor found, check visible views
+ QList views = page->GetViewReferences();
+ for (QList::iterator i = views.begin(); i != views.end(); ++i)
+ {
+ berry::IWorkbenchPart::Pointer part = (*i)->GetPart(false);
+ if (page->IsPartVisible(part))
+ {
+ renderWindowPart = dynamic_cast(part.GetPointer());
+ if (renderWindowPart)
+ {
+ return renderWindowPart;
+ }
+ }
+ }
- const QString logoPath = context->getDataFile("").absoluteFilePath();
+ // No strategies given
+ if (strategies == NONE)
+ {
+ return nullptr;
+ }
- bool extractLogo = true;
- QFileInfo logoFileInfo(logoPath + "/" + logoFileName);
+ mitk::IDataStorageReference::Pointer dataStorageReference = WorkbenchUtilPrivate::GetDataStorageReference();
+ if (nullptr == dataStorageReference)
+ {
+ return nullptr;
+ }
- if (logoFileInfo.exists())
- {
- // The logo has been extracted previously. Check if the plugin timestamp is newer, which
- // means it might contain an updated logo.
- QString pluginLocation = QUrl(context->getPlugin()->getLocation()).toLocalFile();
- if (!pluginLocation.isEmpty())
+ mitk::DataStorageEditorInput::Pointer input(new mitk::DataStorageEditorInput(dataStorageReference));
+
+ bool activate = false;
+ if (strategies & ACTIVATE)
+ {
+ activate = true;
+ }
+
+ berry::IEditorPart::Pointer editorPart;
+ if (strategies & OPEN)
{
- QFileInfo pluginFileInfo(pluginLocation);
- if (logoFileInfo.lastModified() > pluginFileInfo.lastModified())
+ // This will create a default editor for the given input. If an editor
+ // with that input is already open, the editor is brought to the front.
+ try
{
- extractLogo = false;
+ editorPart = mitk::WorkbenchUtil::OpenEditor(page, input, activate);
+ }
+ catch (const berry::PartInitException&)
+ {
+ // There is no editor registered which can handle the given input.
+ }
+ }
+ else if (activate || (strategies & BRING_TO_FRONT))
+ {
+ // check if a suitable editor is already opened
+ editorPart = page->FindEditor(input);
+ if (editorPart)
+ {
+ if (activate)
+ {
+ page->Activate(editorPart);
+ }
+ else
+ {
+ page->BringToTop(editorPart);
+ }
}
}
+
+ return dynamic_cast(editorPart.GetPointer());
}
- if (extractLogo)
+ mitk::IRenderWindowPart* WorkbenchUtil::OpenRenderWindowPart(berry::IWorkbenchPage::Pointer page, bool activatedEditor/* = true*/)
{
- // Extract the logo from the shared library and write it to disk.
- QFile logo(logoResource);
+ if (activatedEditor)
+ {
+ return GetRenderWindowPart(page, ACTIVATE | OPEN);
+ }
+ else
+ {
+ return GetRenderWindowPart(page, BRING_TO_FRONT | OPEN);
+ }
+ }
- if (!logo.exists())
+ bool WorkbenchUtil::SetDepartmentLogoPreference(const QString &logoResource, ctkPluginContext *context)
+ {
+ if (context == nullptr)
{
- BERRY_WARN << "Custom logo '" << logoResource << "' does not exist.";
+ BERRY_WARN << "Plugin context invalid, unable to set custom logo.";
return false;
}
- if (logo.open(QIODevice::ReadOnly))
+ // The logo must be available in the local filesystem. We check if we have not already extracted the
+ // logo from the plug-in or if this plug-ins timestamp is newer then the already extracted logo timestamp.
+ // If one of the conditions is true, extract it and write it to the plug-in specific storage location.
+ const QString logoFileName = logoResource.mid(logoResource.lastIndexOf('/') + 1);
+
+ if (logoFileName.isEmpty())
{
- QFile localLogo(logoPath + "/" + logoFileName);
+ BERRY_WARN << "Logo file name empty, unable to set custom logo.";
+ return false;
+ }
- if (localLogo.open(QIODevice::WriteOnly))
+ const QString logoPath = context->getDataFile("").absoluteFilePath();
+
+ bool extractLogo = true;
+ QFileInfo logoFileInfo(logoPath + "/" + logoFileName);
+
+ if (logoFileInfo.exists())
+ {
+ // The logo has been extracted previously. Check if the plugin timestamp is newer, which
+ // means it might contain an updated logo.
+ QString pluginLocation = QUrl(context->getPlugin()->getLocation()).toLocalFile();
+ if (!pluginLocation.isEmpty())
{
- localLogo.write(logo.readAll());
- localLogo.flush();
+ QFileInfo pluginFileInfo(pluginLocation);
+ if (logoFileInfo.lastModified() > pluginFileInfo.lastModified())
+ {
+ extractLogo = false;
+ }
}
}
- }
- logoFileInfo.refresh();
-
- if (logoFileInfo.exists())
- {
- // Get the preferences service
- ctkServiceReference prefServiceRef = context->getServiceReference();
- berry::IPreferencesService* prefService = nullptr;
- if (prefServiceRef)
+ if (extractLogo)
{
- prefService = context->getService(prefServiceRef);
+ // Extract the logo from the shared library and write it to disk.
+ QFile logo(logoResource);
+
+ if (!logo.exists())
+ {
+ BERRY_WARN << "Custom logo '" << logoResource << "' does not exist.";
+ return false;
+ }
+
+ if (logo.open(QIODevice::ReadOnly))
+ {
+ QFile localLogo(logoPath + "/" + logoFileName);
+
+ if (localLogo.open(QIODevice::WriteOnly))
+ {
+ localLogo.write(logo.readAll());
+ localLogo.flush();
+ }
+ }
}
- if (prefService)
+ logoFileInfo.refresh();
+
+ if (logoFileInfo.exists())
{
- prefService->GetSystemPreferences()->Put("DepartmentLogo", qPrintable(logoFileInfo.absoluteFilePath()));
+ // Get the preferences service
+ ctkServiceReference prefServiceRef = context->getServiceReference();
+ berry::IPreferencesService* prefService = nullptr;
+ if (prefServiceRef)
+ {
+ prefService = context->getService(prefServiceRef);
+ }
+
+ if (prefService)
+ {
+ prefService->GetSystemPreferences()->Put("DepartmentLogo", qPrintable(logoFileInfo.absoluteFilePath()));
+ }
+ else
+ {
+ BERRY_WARN << "Preferences service not available, unable to set custom logo.";
+ return false;
+ }
}
else
{
- BERRY_WARN << "Preferences service not available, unable to set custom logo.";
+ BERRY_WARN << "Custom logo at '" << logoFileInfo.absoluteFilePath().toStdString() << "' does not exist.";
return false;
}
- }
- else
- {
- BERRY_WARN << "Custom logo at '" << logoFileInfo.absoluteFilePath().toStdString() << "' does not exist.";
- return false;
- }
- return true;
-}
+ return true;
+ }
} // namespace mitk
diff --git a/Plugins/org.mitk.gui.common/src/mitkWorkbenchUtil.h b/Plugins/org.mitk.gui.common/src/mitkWorkbenchUtil.h
index b3dc8a8e86..238d8fc94d 100644
--- a/Plugins/org.mitk.gui.common/src/mitkWorkbenchUtil.h
+++ b/Plugins/org.mitk.gui.common/src/mitkWorkbenchUtil.h
@@ -1,189 +1,214 @@
/*===================================================================
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 MITKWORKBENCHUTIL_H
#define MITKWORKBENCHUTIL_H
#include
#include "mitkDataStorageEditorInput.h"
+#include "mitkIRenderWindowPart.h"
+
#include
#include
class ctkPluginContext;
namespace mitk {
-
-/**
- * @ingroup org_mitk_gui_common
- *
- * @brief Utility class for loading data, opening editors and other tasks in a MITK Workbench.
- *
- * @note Infering the content type is not yet supported (ignore the comments about it
- * in the method documentation).
- */
-struct MITK_GUI_COMMON_PLUGIN WorkbenchUtil
-{
-
/**
- * Loads the set of given files into the active data storage of the given Workbench window.
- *
- * If the window already has an editor open on the active datastorage then that editor
- * is activated; otherwise the default editor for the "mitk" extension is activated.
+ * @ingroup org_mitk_gui_common
*
- * @param fileNames
- * A list of file names with absolute path.
- * @param wnd
- * The Workbench window in which the data will be loaded.
- * @param openEditor
- * Whether an Editor is to be opened on file loading (for cases there is none).
+ * @brief Utility class for loading data, opening editors and other tasks in a MITK Workbench.
*
- * @see mitk::IOUtil
+ * @note Inferring the content type is not yet supported (ignore the comments about it
+ * in the method documentation).
*/
- static void LoadFiles(const QStringList& fileNames, berry::IWorkbenchWindow::Pointer wnd, bool openEditor = true);
-
- /**
+ struct MITK_GUI_COMMON_PLUGIN WorkbenchUtil
+ {
+ /**
+ * Describes the strategies to be used for getting an mitk::IRenderWindowPart instance.
+ */
+ enum IRenderWindowPartStrategy {
+
+ // Do nothing.
+ NONE = 0x00000000,
+ // Bring the most recently activated mitk::IRenderWindowPart instance to the front.
+ BRING_TO_FRONT = 0x00000001,
+ // Activate an mitk::IRenderWindowPart part (implies bringing it to the front).
+ ACTIVATE = 0x00000002,
+ // Create an mitk::IRenderWindowPart if none is alredy opened.
+ OPEN = 0x00000004
+ };
+
+ Q_DECLARE_FLAGS(IRenderWindowPartStrategies, IRenderWindowPartStrategy)
+
+ /**
+ * Loads the set of given files into the active data storage of the given Workbench window.
+ *
+ * If the window already has an editor open on the active datastorage then that editor
+ * is activated; otherwise the default editor for the "mitk" extension is activated.
+ *
+ * @param fileNames
+ * A list of file names with absolute path.
+ * @param wnd
+ * The Workbench window in which the data will be loaded.
+ * @param openEditor
+ * Whether an Editor is to be opened on file loading (for cases there is none).
+ *
+ * @see mitk::IOUtil
+ */
+ static void LoadFiles(const QStringList& fileNames, berry::IWorkbenchWindow::Pointer wnd, bool openEditor = true);
+ /**
* Opens an editor on the given object.
*
* If the page already has an editor open on the target object then that
* editor is brought to front; otherwise, a new editor is opened. If
* activate == true
the editor will be activated.
*
*
* @param page
* the page in which the editor will be opened
* @param input
* the editor input
* @param editorId
* the id of the editor extension to use
* @param activate
* if true
the editor will be activated
* @return an open editor or null
if an external editor was
* opened
* @exception PartInitException
* if the editor could not be initialized
* @see IWorkbenchPage#OpenEditor(IEditorInput::Pointer, std::string, bool)
*/
- static berry::IEditorPart::Pointer OpenEditor(berry::IWorkbenchPage::Pointer page,
- berry::IEditorInput::Pointer input,
- const QString& editorId, bool activate = false);
-
- /**
+ static berry::IEditorPart::Pointer OpenEditor(berry::IWorkbenchPage::Pointer page, berry::IEditorInput::Pointer input, const QString& editorId, bool activate = false);
+ /**
* Opens an editor on the given file resource. This method will attempt to
* resolve the editor based on content-type bindings as well as traditional
* name/extension bindings if determineContentType
is
* true
.
*
* If the page already has an editor open on the target object then that
* editor is brought to front; otherwise, a new editor is opened. If
* activate == true
the editor will be activated.
*
*
* @param page
* the page in which the editor will be opened
* @param input
* the editor input
* @param activate
* if true
the editor will be activated
* @param determineContentType
* attempt to resolve the content type for this file
* @return an open editor or null
if an external editor was
* opened
* @exception PartInitException
* if the editor could not be initialized
* @see IWorkbenchPage#OpenEditor(IEditorInput::Pointer,std::string,bool)
*/
- static berry::IEditorPart::Pointer OpenEditor(berry::IWorkbenchPage::Pointer page,
- mitk::DataStorageEditorInput::Pointer input,
- bool activate = false,
- bool determineContentType = false);
-
- /**
+ static berry::IEditorPart::Pointer OpenEditor(berry::IWorkbenchPage::Pointer page, DataStorageEditorInput::Pointer input, bool activate = false, bool determineContentType = false);
+ /**
* Returns an editor descriptor appropriate for opening a file resource with
* the given name.
*
* The editor descriptor is determined using a multi-step process. This
* method will attempt to infer the content type of the file if
* inferContentType
is true
.
*
*
* - The file is consulted for a persistent property named
*
IDE.EDITOR_KEY
containing the preferred editor id to be
* used.
* - The workbench editor registry is consulted to determine if an editor
* extension has been registered for the file type. If so, an instance of
* the editor extension is opened on the file. See
*
IEditorRegistry#GetDefaultEditor(std::string)
.
* - The operating system is consulted to determine if an in-place
* component editor is available (e.g. OLE editor on Win32 platforms).
* - The operating system is consulted to determine if an external editor
* is available.
*
*
*
* @param name
* the file name
* @param inferContentType
* attempt to infer the content type from the file name if this
* is true
* @return an editor descriptor, appropriate for opening the file
* @throws PartInitException
* if no editor can be found
*/
- static berry::IEditorDescriptor::Pointer GetEditorDescriptor(
- const QString& name, bool inferContentType = true);
-
- /**
+ static berry::IEditorDescriptor::Pointer GetEditorDescriptor(const QString& name, bool inferContentType = true);
+ /**
* Returns the default editor for a given file. This method will attempt to
* resolve the editor based on content-type bindings as well as traditional
* name/extension bindings if determineContentType
is
* true
.
*
* A default editor id may be registered for a specific file using
* setDefaultEditor
. If the given file has a registered
* default editor id the default editor will derived from it. If not, the
* default editor is determined by taking the file name for the file and
* obtaining the default editor for that name.
*
*
* @param file
* the file
* @param determineContentType
* determine the content type for the given file
* @return the descriptor of the default editor, or null
if
* not found
*/
- static berry::IEditorDescriptor::Pointer GetDefaultEditor(const QString& file,
- bool determineContentType);
- /**
- * Set the "DepartmentLogo" preference using a Qt resource path.
- *
- * This is a convenience method to set the preference for a "deparment" logo which is usually
- * shown in render windows in the MITK workbench.
- *
- * @param logoResource A Qt resource path to the logo, e.g. ":/MyLogo.png".
- * @param context The plugin context of the plug-in containing the logo resource.
- * @return \c true if the preference was set successfully, \c false otherwise.
- */
- static bool SetDepartmentLogoPreference(const QString& logoResource, ctkPluginContext* context);
-
-};
-
+ static berry::IEditorDescriptor::Pointer GetDefaultEditor(const QString& file, bool determineContentType);
+ /**
+ * @brief Returns the currently active mitk::IRenderWindowPart.
+ *
+ * @param page The page in which the editor will be opened.
+ * @param strategies Strategies for returning a mitk::IRenderWindowPart instance if there
+ * is currently no active one.
+ * @return The active mitk::IRenderWindowPart.
+ */
+ static IRenderWindowPart* GetRenderWindowPart(berry::IWorkbenchPage::Pointer page, IRenderWindowPartStrategies strategies);
+ /**
+ * @brief Uses 'GetRenderWindowPart' to open the a render window part with a certain strategy:
+ * Calls 'GetRenderWindowPart' with strategy "ACTIVATE | OPEN" if the bool argument is true.
+ * Calls 'GetRenderWindowPart' with strategy "BRING_TO_FRONT | OPEN" if the bool argument is false.
+ *
+ * @param page The page in which the editor will be opened.
+ * @param activatedEditor Determine if the render window part should be activated or just brought to front.
+ * @return The active and opened mitk::IRenderWindowPart.
+ */
+ static IRenderWindowPart* OpenRenderWindowPart(berry::IWorkbenchPage::Pointer page, bool activatedEditor = true);
+ /**
+ * Set the "DepartmentLogo" preference using a Qt resource path.
+ *
+ * This is a convenience method to set the preference for a "department" logo which is usually
+ * shown in render windows in the MITK workbench.
+ *
+ * @param logoResource A Qt resource path to the logo, e.g. ":/MyLogo.png".
+ * @param context The plugin context of the plug-in containing the logo resource.
+ * @return \c true if the preference was set successfully, \c false otherwise.
+ */
+ static bool SetDepartmentLogoPreference(const QString& logoResource, ctkPluginContext* context);
+ };
}
+Q_DECLARE_OPERATORS_FOR_FLAGS(mitk::WorkbenchUtil::IRenderWindowPartStrategies)
+
#endif // MITKWORKBENCHUTIL_H
diff --git a/Plugins/org.mitk.gui.qt.application/CMakeLists.txt b/Plugins/org.mitk.gui.qt.application/CMakeLists.txt
index 15c4e7f713..04efa26bd0 100644
--- a/Plugins/org.mitk.gui.qt.application/CMakeLists.txt
+++ b/Plugins/org.mitk.gui.qt.application/CMakeLists.txt
@@ -1,9 +1,9 @@
project(org_mitk_gui_qt_application)
mitk_create_plugin(
EXPORT_DIRECTIVE MITK_QT_APP
EXPORTED_INCLUDE_SUFFIXES src
- MODULE_DEPENDS MitkQtWidgets
+ MODULE_DEPENDS MitkQtWidgets MitkQtWidgetsExt
PACKAGE_DEPENDS Qt5|OpenGL+Xml
SUBPROJECTS MITK-CoreUI
)
diff --git a/Plugins/org.mitk.gui.qt.application/files.cmake b/Plugins/org.mitk.gui.qt.application/files.cmake
index bcd9b22a2e..7c7a097ea2 100644
--- a/Plugins/org.mitk.gui.qt.application/files.cmake
+++ b/Plugins/org.mitk.gui.qt.application/files.cmake
@@ -1,55 +1,87 @@
set(SRC_CPP_FILES
+ QmitkAbstractDataNodeAction.cpp
QmitkCloseProjectAction.cpp
+ QmitkDataNodeColorAction.cpp
+ QmitkDataNodeColorMapAction.cpp
+ QmitkDataNodeComponentAction.cpp
+ QmitkDataNodeContextMenu.cpp
+ QmitkDataNodeGlobalReinitAction.cpp
+ QmitkDataNodeHideAllAction.cpp
+ QmitkDataNodeOpacityAction.cpp
+ QmitkDataNodeReinitAction.cpp
+ QmitkDataNodeRemoveAction.cpp
+ QmitkDataNodeShowDetailsAction.cpp
+ QmitkDataNodeShowSelectedNodesAction.cpp
+ QmitkDataNodeSurfaceRepresentationAction.cpp
+ QmitkDataNodeTextureInterpolationAction.cpp
+ QmitkDataNodeToggleVisibilityAction.cpp
QmitkDefaultDropTargetListener.cpp
QmitkFileExitAction.cpp
QmitkFileOpenAction.cpp
QmitkFileSaveAction.cpp
QmitkUndoAction.cpp
QmitkRedoAction.cpp
QmitkPreferencesDialog.cpp
QmitkStatusBar.cpp
)
set(INTERNAL_CPP_FILES
org_mitk_gui_qt_application_Activator.cpp
QmitkEditorsPreferencePage.cpp
QmitkGeneralPreferencePage.cpp
+ QmitkInfoDialog.cpp
QmitkShowPreferencePageHandler.cpp
)
set(MOC_H_FILES
+ src/QmitkAbstractDataNodeAction.h
src/QmitkCloseProjectAction.h
+ src/QmitkDataNodeColorAction.h
+ src/QmitkDataNodeColorMapAction.h
+ src/QmitkDataNodeComponentAction.h
+ src/QmitkDataNodeGlobalReinitAction.h
+ src/QmitkDataNodeContextMenu.h
+ src/QmitkDataNodeHideAllAction.h
+ src/QmitkDataNodeOpacityAction.h
+ src/QmitkDataNodeReinitAction.h
+ src/QmitkDataNodeRemoveAction.h
+ src/QmitkDataNodeShowDetailsAction.h
+ src/QmitkDataNodeShowSelectedNodesAction.h
+ src/QmitkDataNodeSurfaceRepresentationAction.h
+ src/QmitkDataNodeTextureInterpolationAction.h
+ src/QmitkDataNodeToggleVisibilityAction.h
src/QmitkFileExitAction.h
src/QmitkFileOpenAction.h
src/QmitkFileSaveAction.h
src/QmitkUndoAction.h
src/QmitkRedoAction.h
src/QmitkPreferencesDialog.h
src/internal/org_mitk_gui_qt_application_Activator.h
src/internal/QmitkEditorsPreferencePage.h
src/internal/QmitkGeneralPreferencePage.h
+ src/internal/QmitkInfoDialog.h
src/internal/QmitkShowPreferencePageHandler.h
)
set(UI_FILES
src/QmitkPreferencesDialog.ui
)
set(CACHED_RESOURCE_FILES
plugin.xml
)
set(QRC_FILES
resources/resources.qrc
)
set(CPP_FILES )
foreach(file ${SRC_CPP_FILES})
set(CPP_FILES ${CPP_FILES} src/${file})
endforeach(file ${SRC_CPP_FILES})
foreach(file ${INTERNAL_CPP_FILES})
set(CPP_FILES ${CPP_FILES} src/internal/${file})
endforeach(file ${INTERNAL_CPP_FILES})
diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkAbstractDataNodeAction.cpp b/Plugins/org.mitk.gui.qt.application/src/QmitkAbstractDataNodeAction.cpp
new file mode 100644
index 0000000000..47ce1aa415
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.application/src/QmitkAbstractDataNodeAction.cpp
@@ -0,0 +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.
+
+===================================================================*/
+
+#include
+
+#include "mitkIRenderWindowPart.h"
+
+// mitk gui common plugin
+#include
+
+// berry
+#include
+
+QList AbstractDataNodeAction::GetSelectedNodes(berry::IWorkbenchPartSite::Pointer workbenchPartSite)
+{
+ QList selectedNodes;
+ if (nullptr == workbenchPartSite)
+ {
+ return selectedNodes;
+ }
+
+ berry::ISelection::ConstPointer selection = workbenchPartSite->GetWorkbenchWindow()->GetSelectionService()->GetSelection();
+ mitk::DataNodeSelection::ConstPointer currentSelection = selection.Cast();
+
+ if (currentSelection.IsNull() || currentSelection->IsEmpty())
+ {
+ return selectedNodes;
+ }
+
+ selectedNodes = QList::fromStdList(currentSelection->GetSelectedDataNodes());
+ return selectedNodes;
+}
+
+QmitkAbstractDataNodeAction::QmitkAbstractDataNodeAction(berry::IWorkbenchPartSite::Pointer workbenchPartSite)
+{
+ m_WorkbenchPartSite = workbenchPartSite;
+}
+
+QmitkAbstractDataNodeAction::QmitkAbstractDataNodeAction(berry::IWorkbenchPartSite* workbenchPartSite)
+{
+ m_WorkbenchPartSite = berry::IWorkbenchPartSite::Pointer(workbenchPartSite);
+}
+
+QmitkAbstractDataNodeAction::~QmitkAbstractDataNodeAction()
+{
+ // nothing here
+}
+
+void QmitkAbstractDataNodeAction::SetDataStorage(mitk::DataStorage* dataStorage)
+{
+ if (m_DataStorage != dataStorage)
+ {
+ // set the new data storage
+ m_DataStorage = dataStorage;
+ }
+}
+
+QList QmitkAbstractDataNodeAction::GetSelectedNodes() const
+{
+ QList selectedNodes;
+ if (m_WorkbenchPartSite.Expired())
+ {
+ return selectedNodes;
+ }
+
+ return AbstractDataNodeAction::GetSelectedNodes(m_WorkbenchPartSite.Lock());
+}
+
+mitk::DataNode::Pointer QmitkAbstractDataNodeAction::GetSelectedNode() const
+{
+ QList selectedNodes = GetSelectedNodes();
+ if (selectedNodes.empty())
+ {
+ return nullptr;
+ }
+
+ // no batch action; should only be called with a single node
+ mitk::DataNode::Pointer dataNode = selectedNodes.front();
+ if (nullptr == dataNode)
+ {
+ return nullptr;
+ }
+
+ return dataNode;
+}
diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkAbstractDataNodeAction.h b/Plugins/org.mitk.gui.qt.application/src/QmitkAbstractDataNodeAction.h
new file mode 100644
index 0000000000..09866c45d3
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.application/src/QmitkAbstractDataNodeAction.h
@@ -0,0 +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 QMITKABSTRACTDATANODEACTION_H
+#define QMITKABSTRACTDATANODEACTION_H
+
+#include
+
+// mitk core
+#include
+#include
+
+// berry
+#include
+
+// qt
+#include
+
+namespace AbstractDataNodeAction
+{
+ QList GetSelectedNodes(berry::IWorkbenchPartSite::Pointer workbenchPartSite);
+}
+
+class MITK_QT_APP QmitkAbstractDataNodeAction
+{
+
+public:
+
+ QmitkAbstractDataNodeAction(berry::IWorkbenchPartSite::Pointer workbenchPartSite);
+ QmitkAbstractDataNodeAction(berry::IWorkbenchPartSite* workbenchPartSite);
+
+ virtual ~QmitkAbstractDataNodeAction();
+
+ void SetDataStorage(mitk::DataStorage* dataStorage);
+
+ virtual void InitializeWithDataNode(const mitk::DataNode* dataNode) { }
+
+protected:
+
+ virtual void InitializeAction() = 0;
+ mitk::DataNode::Pointer GetSelectedNode() const;
+ QList GetSelectedNodes() const;
+
+ berry::IWorkbenchPartSite::WeakPtr m_WorkbenchPartSite;
+ mitk::WeakPointer m_DataStorage;
+
+};
+
+#endif // QMITKABSTRACTDATANODEACTION_H
diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeColorAction.cpp b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeColorAction.cpp
new file mode 100644
index 0000000000..582c667c63
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeColorAction.cpp
@@ -0,0 +1,130 @@
+/*===================================================================
+
+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
+
+// mitk core
+#include
+
+// qt
+#include
+#include
+#include
+
+QmitkDataNodeColorAction::QmitkDataNodeColorAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchPartSite)
+ : QWidgetAction(parent)
+ , QmitkAbstractDataNodeAction(workbenchPartSite)
+{
+ InitializeAction();
+}
+
+QmitkDataNodeColorAction::QmitkDataNodeColorAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchPartSite)
+ : QWidgetAction(parent)
+ , QmitkAbstractDataNodeAction(berry::IWorkbenchPartSite::Pointer(workbenchPartSite))
+{
+ InitializeAction();
+}
+
+QmitkDataNodeColorAction::~QmitkDataNodeColorAction()
+{
+ // nothing here
+}
+
+void QmitkDataNodeColorAction::InitializeAction()
+{
+ m_ColorButton = new QPushButton;
+ m_ColorButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
+ connect(m_ColorButton, &QPushButton::clicked, this, &QmitkDataNodeColorAction::OnColorChanged);
+
+ QLabel* colorLabel = new QLabel(tr("Color: "));
+ colorLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
+ QHBoxLayout* colorWidgetLayout = new QHBoxLayout;
+ colorWidgetLayout->setContentsMargins(4, 4, 4, 4);
+ colorWidgetLayout->addWidget(colorLabel);
+ colorWidgetLayout->addWidget(m_ColorButton);
+
+ QWidget* colorWidget = new QWidget;
+ colorWidget->setLayout(colorWidgetLayout);
+
+ setDefaultWidget(colorWidget);
+
+ connect(this, &QmitkDataNodeColorAction::changed, this, &QmitkDataNodeColorAction::OnActionChanged);
+}
+
+void QmitkDataNodeColorAction::InitializeWithDataNode(const mitk::DataNode* dataNode)
+{
+ float rgb[3];
+ if (dataNode->GetColor(rgb))
+ {
+ QColor color(rgb[0] * 255, rgb[1] * 255, rgb[2] * 255);
+ QString styleSheet = QString("background-color: ") + color.name(QColor::HexRgb);
+ m_ColorButton->setAutoFillBackground(true);
+ m_ColorButton->setStyleSheet(styleSheet);
+ }
+}
+
+void QmitkDataNodeColorAction::OnColorChanged()
+{
+ bool selectedColor = false;
+ QColor newColor;
+
+ auto selectedNodes = GetSelectedNodes();
+ for (auto& dataNode : selectedNodes)
+ {
+ if (dataNode.IsNull())
+ {
+ continue;
+ }
+
+ float rgb[3];
+ if (dataNode->GetColor(rgb))
+ {
+ if (!selectedColor)
+ {
+ QColor initial(rgb[0] * 255, rgb[1] * 255, rgb[2] * 255);
+ newColor = QColorDialog::getColor(initial, nullptr, QString(tr("Change color")));
+
+ if (newColor.isValid())
+ {
+ selectedColor = true;
+ }
+ else
+ {
+ return;
+ }
+ }
+
+ dataNode->SetProperty("color", mitk::ColorProperty::New(newColor.redF(), newColor.greenF(), newColor.blueF()));
+ if (dataNode->GetProperty("binaryimage.selectedcolor"))
+ {
+ dataNode->SetProperty("binaryimage.selectedcolor", mitk::ColorProperty::New(newColor.redF(), newColor.greenF(), newColor.blueF()));
+ }
+ }
+ }
+
+ mitk::RenderingManager::GetInstance()->RequestUpdateAll();
+}
+
+void QmitkDataNodeColorAction::OnActionChanged()
+{
+ auto dataNode = GetSelectedNode();
+ if (dataNode.IsNull())
+ {
+ return;
+ }
+
+ InitializeWithDataNode(dataNode);
+}
diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeColorAction.h b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeColorAction.h
new file mode 100644
index 0000000000..f1bf1c22b5
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeColorAction.h
@@ -0,0 +1,56 @@
+/*===================================================================
+
+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 QMITKDATANODECOLORACTION_H
+#define QMITKDATANODECOLORACTION_H
+
+#include
+
+#include "QmitkAbstractDataNodeAction.h"
+
+// qt
+#include
+#include
+
+class MITK_QT_APP QmitkDataNodeColorAction : public QWidgetAction, public QmitkAbstractDataNodeAction
+{
+ Q_OBJECT
+
+public:
+
+ QmitkDataNodeColorAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchPartSite);
+ QmitkDataNodeColorAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchPartSite);
+
+ virtual ~QmitkDataNodeColorAction() override;
+
+ virtual void InitializeWithDataNode(const mitk::DataNode* dataNode) override;
+
+private Q_SLOTS:
+
+ void OnColorChanged();
+ void OnActionChanged();
+
+protected:
+
+ virtual void InitializeAction() override;
+
+private:
+
+ QPushButton* m_ColorButton;
+
+};
+
+#endif // QMITKDATANODECOLORACTION_H
diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeColorMapAction.cpp b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeColorMapAction.cpp
new file mode 100644
index 0000000000..49cca9ecc8
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeColorMapAction.cpp
@@ -0,0 +1,161 @@
+/*===================================================================
+
+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
+
+// mitk core
+#include
+#include
+#include
+#include
+#include
+
+// mitk gui common plugin
+#include
+
+// berry
+#include
+
+// qt
+#include
+
+QmitkDataNodeColorMapAction::QmitkDataNodeColorMapAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchpartSite)
+ : QAction(parent)
+ , QmitkAbstractDataNodeAction(workbenchpartSite)
+{
+ setText(tr("Colormap"));
+ InitializeAction();
+}
+
+QmitkDataNodeColorMapAction::QmitkDataNodeColorMapAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchpartSite)
+ : QAction(parent)
+ , QmitkAbstractDataNodeAction(berry::IWorkbenchPartSite::Pointer(workbenchpartSite))
+{
+ setText(tr("Colormap"));
+ InitializeAction();
+}
+
+QmitkDataNodeColorMapAction::~QmitkDataNodeColorMapAction()
+{
+ // nothing here
+}
+
+void QmitkDataNodeColorMapAction::InitializeAction()
+{
+ setCheckable(true);
+
+ setMenu(new QMenu);
+ connect(menu(), &QMenu::aboutToShow, this, &QmitkDataNodeColorMapAction::OnMenuAboutShow);
+}
+
+void QmitkDataNodeColorMapAction::OnMenuAboutShow()
+{
+ auto dataNode = GetSelectedNode();
+ if (dataNode.IsNull())
+ {
+ return;
+ }
+
+ mitk::LookupTableProperty::Pointer lookupTableProperty = dynamic_cast(dataNode->GetProperty("LookupTable"));
+ if (lookupTableProperty.IsNull())
+ {
+ mitk::LookupTable::Pointer mitkLut = mitk::LookupTable::New();
+ lookupTableProperty = mitk::LookupTableProperty::New();
+ lookupTableProperty->SetLookupTable(mitkLut);
+ dataNode->SetProperty("LookupTable", lookupTableProperty);
+ }
+
+ mitk::LookupTable::Pointer lookupTable = lookupTableProperty->GetValue();
+ if (lookupTable.IsNull())
+ {
+ return;
+ }
+
+ menu()->clear();
+ QAction* tmp;
+
+ int i = 0;
+ std::string lutType = lookupTable->typenameList[i];
+
+ while (lutType != "END_OF_ARRAY")
+ {
+ tmp = menu()->addAction(QString::fromStdString(lutType));
+ tmp->setCheckable(true);
+
+ if (lutType == lookupTable->GetActiveTypeAsString())
+ {
+ tmp->setChecked(true);
+ }
+
+ connect(tmp, &QAction::triggered, this, &QmitkDataNodeColorMapAction::OnActionTriggered);
+
+ lutType = lookupTable->typenameList[++i];
+ }
+}
+
+void QmitkDataNodeColorMapAction::OnActionTriggered(bool checked)
+{
+ auto selectedNodes = GetSelectedNodes();
+ for (auto &dataNode : selectedNodes)
+ {
+ if (dataNode.IsNull())
+ {
+ continue;
+ }
+ mitk::LookupTableProperty::Pointer lookupTableProperty = dynamic_cast(dataNode->GetProperty("LookupTable"));
+ if (lookupTableProperty.IsNull())
+ {
+ continue;
+ }
+
+ mitk::LookupTable::Pointer lookupTable = lookupTableProperty->GetValue();
+ if (lookupTable.IsNull())
+ {
+ continue;
+ }
+
+ QAction* senderAction = qobject_cast(QObject::sender());
+ if (nullptr == senderAction)
+ {
+ continue;
+ }
+
+ std::string activatedItem = senderAction->text().toStdString();
+ lookupTable->SetType(activatedItem);
+ lookupTableProperty->SetValue(lookupTable);
+
+ if (mitk::LookupTable::LookupTableType::MULTILABEL == lookupTable->GetActiveType())
+ {
+ // special case: multilabel => set the level window to include the whole pixel range
+ UseWholePixelRange(dataNode);
+ }
+
+ mitk::RenderingModeProperty::Pointer renderingMode = dynamic_cast(dataNode->GetProperty("Image Rendering.Mode"));
+ renderingMode->SetValue(mitk::RenderingModeProperty::LOOKUPTABLE_LEVELWINDOW_COLOR);
+ mitk::RenderingManager::GetInstance()->RequestUpdateAll();
+ }
+}
+
+void QmitkDataNodeColorMapAction::UseWholePixelRange(mitk::DataNode* node)
+{
+ auto image = dynamic_cast(node->GetData());
+ if (nullptr != image)
+ {
+ mitk::LevelWindow levelWindow;
+ levelWindow.SetToImageRange(image);
+ node->SetLevelWindow(levelWindow);
+ }
+}
diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeColorMapAction.h b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeColorMapAction.h
new file mode 100644
index 0000000000..659bd92ef8
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeColorMapAction.h
@@ -0,0 +1,53 @@
+/*===================================================================
+
+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 QMITKDATANODECOLORMAPACTION_H
+#define QMITKDATANODECOLORMAPACTION_H
+
+#include
+
+#include "QmitkAbstractDataNodeAction.h"
+
+// mitk core
+#include
+
+// qt
+#include
+
+class MITK_QT_APP QmitkDataNodeColorMapAction : public QAction, public QmitkAbstractDataNodeAction
+{
+ Q_OBJECT
+
+public:
+
+ QmitkDataNodeColorMapAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchPartSite);
+ QmitkDataNodeColorMapAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchPartSite);
+
+ virtual ~QmitkDataNodeColorMapAction() override;
+
+private Q_SLOTS:
+
+ void OnMenuAboutShow();
+ void OnActionTriggered(bool);
+
+protected:
+
+ virtual void InitializeAction() override;
+
+ void UseWholePixelRange(mitk::DataNode* node);
+};
+
+#endif // QMITKDATANODECOLORMAPACTION_H
diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeComponentAction.cpp b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeComponentAction.cpp
new file mode 100644
index 0000000000..0250be552f
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeComponentAction.cpp
@@ -0,0 +1,111 @@
+/*===================================================================
+
+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
+
+// mitk core
+#include
+#include
+#include
+
+// mitk gui common plugin
+#include
+
+// berry
+#include
+
+// qt
+#include
+#include
+
+QmitkDataNodeComponentAction::QmitkDataNodeComponentAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchpartSite)
+ : QWidgetAction(parent)
+ , QmitkAbstractDataNodeAction(workbenchpartSite)
+{
+ InitializeAction();
+}
+
+QmitkDataNodeComponentAction::QmitkDataNodeComponentAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchpartSite)
+ : QWidgetAction(parent)
+ , QmitkAbstractDataNodeAction(berry::IWorkbenchPartSite::Pointer(workbenchpartSite))
+{
+ InitializeAction();
+}
+
+QmitkDataNodeComponentAction::~QmitkDataNodeComponentAction()
+{
+ // nothing here
+}
+
+void QmitkDataNodeComponentAction::InitializeAction()
+{
+ setCheckable(true);
+
+ m_ComponentSlider = new QmitkNumberPropertySlider;
+ m_ComponentSlider->setOrientation(Qt::Horizontal);
+
+ QLabel* componentLabel = new QLabel(tr("Component: "));
+ QHBoxLayout* componentWidgetLayout = new QHBoxLayout;
+ componentWidgetLayout->setContentsMargins(4, 4, 4, 4);
+ componentWidgetLayout->addWidget(componentLabel);
+ componentWidgetLayout->addWidget(m_ComponentSlider);
+ QLabel* componentValueLabel = new QLabel();
+ componentWidgetLayout->addWidget(componentValueLabel);
+ connect(m_ComponentSlider, &QmitkNumberPropertySlider::valueChanged, componentValueLabel, static_cast(&QLabel::setNum));
+
+ QWidget* componentWidget = new QWidget;
+ componentWidget->setLayout(componentWidgetLayout);
+
+ setDefaultWidget(componentWidget);
+
+ connect(this, &QmitkDataNodeComponentAction::changed, this, &QmitkDataNodeComponentAction::OnActionChanged);
+}
+
+void QmitkDataNodeComponentAction::InitializeWithDataNode(const mitk::DataNode* dataNode)
+{
+ if (nullptr == dataNode)
+ {
+ m_ComponentSlider->SetProperty(static_cast(nullptr));
+ return;
+ }
+
+ mitk::Image* img = dynamic_cast(dataNode->GetData());
+ if (nullptr == img)
+ {
+ m_ComponentSlider->SetProperty(static_cast(nullptr));
+ return;
+ }
+
+ int numComponents = 0;
+ numComponents = img->GetPixelType().GetNumberOfComponents();
+ mitk::IntProperty* componentProperty = dynamic_cast(dataNode->GetProperty("Image.Displayed Component"));
+ if (numComponents <= 1 || nullptr == componentProperty)
+ {
+ m_ComponentSlider->SetProperty(static_cast(nullptr));
+ return;
+ }
+
+ m_ComponentSlider->SetProperty(componentProperty);
+ m_ComponentSlider->setMinValue(0);
+ m_ComponentSlider->setMaxValue(numComponents - 1);
+}
+
+void QmitkDataNodeComponentAction::OnActionChanged()
+{
+ auto dataNode = GetSelectedNode();
+
+ InitializeWithDataNode(dataNode);
+}
diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeComponentAction.h b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeComponentAction.h
new file mode 100644
index 0000000000..3da6b93db6
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeComponentAction.h
@@ -0,0 +1,57 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+
+#ifndef QMITKDATANODECOMPONENTACTION_H
+#define QMITKDATANODECOMPONENTACTION_H
+
+#include
+
+// qt widgets ext module
+#include
+
+#include "QmitkAbstractDataNodeAction.h"
+
+// qt
+#include
+
+class MITK_QT_APP QmitkDataNodeComponentAction : public QWidgetAction, public QmitkAbstractDataNodeAction
+{
+ Q_OBJECT
+
+public:
+
+ QmitkDataNodeComponentAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchPartSite);
+ QmitkDataNodeComponentAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchPartSite);
+
+ virtual ~QmitkDataNodeComponentAction() override;
+
+ virtual void InitializeWithDataNode(const mitk::DataNode* dataNode) override;
+
+private Q_SLOTS:
+
+ void OnActionChanged();
+
+protected:
+
+ virtual void InitializeAction() override;
+
+private:
+
+ QmitkNumberPropertySlider* m_ComponentSlider;
+
+};
+
+#endif // QMITKDATANODECOMPONENTACTION_H
diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeContextMenu.cpp b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeContextMenu.cpp
new file mode 100644
index 0000000000..58ac548085
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeContextMenu.cpp
@@ -0,0 +1,538 @@
+/*===================================================================
+
+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 "QmitkDataNodeContextMenu.h"
+
+// mitk gui qt application plugin
+#include "mitkIContextMenuAction.h"
+#include "QmitkFileSaveAction.h"
+
+// mitk gui common plugin
+#include
+
+// qt widgets module
+#include
+#include
+
+// berry
+#include
+#include
+#include
+#include
+#include
+
+QmitkDataNodeContextMenu::QmitkDataNodeContextMenu(berry::IWorkbenchPartSite::Pointer workbenchPartSite, QWidget* parent)
+ : QMenu(parent)
+{
+ m_Parent = parent;
+ m_WorkbenchPartSite = workbenchPartSite;
+
+ InitNodeDescriptors();
+ InitDefaultActions();
+ InitExtensionPointActions();
+}
+
+QmitkDataNodeContextMenu::~QmitkDataNodeContextMenu()
+{
+ // remove the registered actions from each descriptor
+ for (DescriptorActionListType::const_iterator it = m_DescriptorActionList.begin(); it != m_DescriptorActionList.end(); ++it)
+ {
+ (it->first)->RemoveAction(it->second);
+ }
+}
+
+void QmitkDataNodeContextMenu::SetDataStorage(mitk::DataStorage* dataStorage)
+{
+ if (m_DataStorage != dataStorage)
+ {
+ // set the new data storage - also for all actions
+ m_DataStorage = dataStorage;
+ for (DescriptorActionListType::const_iterator it = m_DescriptorActionList.begin(); it != m_DescriptorActionList.end(); ++it)
+ {
+ QmitkAbstractDataNodeAction* abstractDataNodeAction = dynamic_cast(it->second);
+ if(nullptr != abstractDataNodeAction)
+ {
+ abstractDataNodeAction->SetDataStorage(m_DataStorage.Lock());
+ }
+ }
+ }
+}
+
+void QmitkDataNodeContextMenu::SetSurfaceDecimation(bool surfaceDecimation)
+{
+ m_SurfaceDecimation = surfaceDecimation;
+}
+
+void QmitkDataNodeContextMenu::InitNodeDescriptors()
+{
+ m_UnknownDataNodeDescriptor = QmitkNodeDescriptorManager::GetInstance()->GetUnknownDataNodeDescriptor();
+ m_ImageDataNodeDescriptor = QmitkNodeDescriptorManager::GetInstance()->GetDescriptor("Image");
+ m_MultiComponentImageDataNodeDescriptor = QmitkNodeDescriptorManager::GetInstance()->GetDescriptor("MultiComponentImage");
+ m_DiffusionImageDataNodeDescriptor = QmitkNodeDescriptorManager::GetInstance()->GetDescriptor("DiffusionImage");
+ m_FiberBundleDataNodeDescriptor = QmitkNodeDescriptorManager::GetInstance()->GetDescriptor("FiberBundle");
+ m_PeakImageDataNodeDescriptor = QmitkNodeDescriptorManager::GetInstance()->GetDescriptor("PeakImage");
+ m_SegmentDataNodeDescriptor = QmitkNodeDescriptorManager::GetInstance()->GetDescriptor("Segment");
+ m_SurfaceDataNodeDescriptor = QmitkNodeDescriptorManager::GetInstance()->GetDescriptor("Surface");
+ m_PointSetNodeDescriptor = QmitkNodeDescriptorManager::GetInstance()->GetDescriptor("PointSet");
+ m_PlanarLineNodeDescriptor = QmitkNodeDescriptorManager::GetInstance()->GetDescriptor("PlanarLine");
+ m_PlanarCircleNodeDescriptor = QmitkNodeDescriptorManager::GetInstance()->GetDescriptor("PlanarCircle");
+ m_PlanarEllipseNodeDescriptor = QmitkNodeDescriptorManager::GetInstance()->GetDescriptor("PlanarEllipse");
+ m_PlanarAngleNodeDescriptor = QmitkNodeDescriptorManager::GetInstance()->GetDescriptor("PlanarAngle");
+ m_PlanarFourPointAngleNodeDescriptor = QmitkNodeDescriptorManager::GetInstance()->GetDescriptor("PlanarFourPointAngle");
+ m_PlanarRectangleNodeDescriptor = QmitkNodeDescriptorManager::GetInstance()->GetDescriptor("PlanarRectangle");
+ m_PlanarPolygonNodeDescriptor = QmitkNodeDescriptorManager::GetInstance()->GetDescriptor("PlanarPolygon");
+ m_PlanarPathNodeDescriptor = QmitkNodeDescriptorManager::GetInstance()->GetDescriptor("PlanarPath");
+ m_PlanarDoubleEllipseNodeDescriptor = QmitkNodeDescriptorManager::GetInstance()->GetDescriptor("PlanarDoubleEllipse");
+ m_PlanarBezierCurveNodeDescriptor = QmitkNodeDescriptorManager::GetInstance()->GetDescriptor("PlanarBezierCurve");
+ m_PlanarSubdivisionPolygonNodeDescriptor = QmitkNodeDescriptorManager::GetInstance()->GetDescriptor("PlanarSubdivisionPolygon");
+}
+
+void QmitkDataNodeContextMenu::InitDefaultActions()
+{
+ m_GlobalReinitAction = new QmitkDataNodeGlobalReinitAction(m_Parent, m_WorkbenchPartSite.Lock());
+ m_GlobalReinitAction->setIcon(QIcon(":/org.mitk.gui.qt.datamanager/Refresh_48.png"));
+ m_UnknownDataNodeDescriptor->AddAction(m_GlobalReinitAction, true);
+ m_DescriptorActionList.push_back(std::make_pair(m_UnknownDataNodeDescriptor, m_GlobalReinitAction));
+
+ m_ReinitAction = new QmitkDataNodeReinitAction(m_Parent, m_WorkbenchPartSite.Lock());
+ m_ReinitAction->setIcon(QIcon(":/org.mitk.gui.qt.datamanager/Refresh_48.png"));
+ m_UnknownDataNodeDescriptor->AddAction(m_ReinitAction, true);
+ m_DescriptorActionList.push_back(std::make_pair(m_UnknownDataNodeDescriptor, m_ReinitAction));
+
+ QAction* saveAction = new QmitkFileSaveAction(QIcon(":/org.mitk.gui.qt.datamanager/Save_48.png"), m_WorkbenchPartSite.Lock()->GetWorkbenchWindow());
+ m_UnknownDataNodeDescriptor->AddAction(saveAction, true);
+ m_DescriptorActionList.push_back(std::make_pair(m_UnknownDataNodeDescriptor, saveAction));
+
+ m_RemoveAction = new QmitkDataNodeRemoveAction(m_Parent, m_WorkbenchPartSite.Lock());
+ m_RemoveAction->setIcon(QIcon(":/org.mitk.gui.qt.datamanager/Remove_48.png"));
+ m_UnknownDataNodeDescriptor->AddAction(m_RemoveAction, true);
+ m_DescriptorActionList.push_back(std::make_pair(m_UnknownDataNodeDescriptor, m_RemoveAction));
+
+ m_ShowSelectedNodesAction = new QmitkDataNodeShowSelectedNodesAction(m_Parent, m_WorkbenchPartSite.Lock());
+ m_RemoveAction->setIcon(QIcon(":/org.mitk.gui.qt.datamanager/ShowSelectedNode_48.png"));
+ m_UnknownDataNodeDescriptor->AddAction(m_ShowSelectedNodesAction, true);
+ m_DescriptorActionList.push_back(std::make_pair(m_UnknownDataNodeDescriptor, m_ShowSelectedNodesAction));
+
+ m_ToggleVisibilityAction = new QmitkDataNodeToggleVisibilityAction(m_Parent, m_WorkbenchPartSite.Lock());
+ m_ToggleVisibilityAction->setIcon(QIcon(":/org.mitk.gui.qt.datamanager/InvertShowSelectedNode_48.png"));
+ m_UnknownDataNodeDescriptor->AddAction(m_ToggleVisibilityAction, true);
+ m_DescriptorActionList.push_back(std::make_pair(m_UnknownDataNodeDescriptor, m_ToggleVisibilityAction));
+
+ m_ShowDetailsAction = new QmitkDataNodeShowDetailsAction(m_Parent, m_WorkbenchPartSite.Lock());
+ m_ShowDetailsAction->setIcon(QIcon(":/org.mitk.gui.qt.datamanager/ShowDataInfo_48.png"));
+ m_UnknownDataNodeDescriptor->AddAction(m_ShowDetailsAction, true);
+ m_DescriptorActionList.push_back(std::make_pair(m_UnknownDataNodeDescriptor, m_ShowDetailsAction));
+
+ // default widget actions
+ m_OpacityAction = new QmitkDataNodeOpacityAction(m_Parent, m_WorkbenchPartSite.Lock());
+ // not used for batch actions (no multi-selection action)
+ m_UnknownDataNodeDescriptor->AddAction(m_OpacityAction, false);
+ m_DescriptorActionList.push_back(std::make_pair(m_UnknownDataNodeDescriptor, m_OpacityAction));
+
+ m_ColorAction = new QmitkDataNodeColorAction(m_Parent, m_WorkbenchPartSite.Lock());
+ AddColorAction(m_ColorAction);
+
+ m_ColormapAction = new QmitkDataNodeColorMapAction(m_Parent, m_WorkbenchPartSite.Lock());
+ // used for batch actions
+ m_ImageDataNodeDescriptor->AddAction(m_ColormapAction);
+ m_DescriptorActionList.push_back(std::make_pair(m_ImageDataNodeDescriptor, m_ColormapAction));
+
+ if (m_DiffusionImageDataNodeDescriptor != nullptr)
+ {
+ // not used for batch actions (no multi-selection action)
+ m_DiffusionImageDataNodeDescriptor->AddAction(m_ColormapAction, false);
+ m_DescriptorActionList.push_back(std::make_pair(m_DiffusionImageDataNodeDescriptor, m_ColormapAction));
+ }
+
+ m_ComponentAction = new QmitkDataNodeComponentAction(m_Parent, m_WorkbenchPartSite.Lock());
+ // not used for batch actions (no multi-selection action)
+ m_MultiComponentImageDataNodeDescriptor->AddAction(m_ComponentAction, false);
+ m_DescriptorActionList.push_back(std::make_pair(m_MultiComponentImageDataNodeDescriptor, m_ComponentAction));
+
+ if (m_DiffusionImageDataNodeDescriptor != nullptr)
+ {
+ // not used for batch actions (no multi-selection action)
+ m_DiffusionImageDataNodeDescriptor->AddAction(m_ComponentAction, false);
+ m_DescriptorActionList.push_back(std::make_pair(m_DiffusionImageDataNodeDescriptor, m_ComponentAction));
+ }
+
+ m_TextureInterpolationAction = new QmitkDataNodeTextureInterpolationAction(m_Parent, m_WorkbenchPartSite.Lock());
+ // not used for batch actions (no multi-selection action)
+ m_ImageDataNodeDescriptor->AddAction(m_TextureInterpolationAction, false);
+ m_DescriptorActionList.push_back(std::make_pair(m_ImageDataNodeDescriptor, m_TextureInterpolationAction));
+
+ if (m_DiffusionImageDataNodeDescriptor != nullptr)
+ {
+ // not used for batch actions (no multi-selection action)
+ m_DiffusionImageDataNodeDescriptor->AddAction(m_TextureInterpolationAction, false);
+ m_DescriptorActionList.push_back(std::make_pair(m_DiffusionImageDataNodeDescriptor, m_TextureInterpolationAction));
+ }
+
+ if (m_SegmentDataNodeDescriptor != nullptr)
+ {
+ // not used for batch actions (no multi-selection action)
+ m_SegmentDataNodeDescriptor->AddAction(m_TextureInterpolationAction, false);
+ m_DescriptorActionList.push_back(std::make_pair(m_SegmentDataNodeDescriptor, m_TextureInterpolationAction));
+ }
+
+ m_SurfaceRepresentationAction = new QmitkDataNodeSurfaceRepresentationAction(m_Parent, m_WorkbenchPartSite.Lock());
+ // not used for batch actions (no multi-selection action)
+ m_SurfaceDataNodeDescriptor->AddAction(m_SurfaceRepresentationAction, false);
+ m_DescriptorActionList.push_back(std::make_pair(m_SurfaceDataNodeDescriptor, m_SurfaceRepresentationAction));
+}
+
+void QmitkDataNodeContextMenu::InitExtensionPointActions()
+{
+ // find contextMenuAction extension points and add them to the node descriptor
+ berry::IExtensionRegistry* extensionPointService = berry::Platform::GetExtensionRegistry();
+ QList customMenuConfigs = extensionPointService->GetConfigurationElementsFor("org.mitk.gui.qt.datamanager.contextMenuActions");
+
+ // prepare all custom QActions
+ m_ConfigElements.clear();
+ DescriptorActionListType descriptorActionList;
+ for (const auto& customMenuConfig : customMenuConfigs)
+ {
+ QString actionNodeDescriptorName = customMenuConfig->GetAttribute("nodeDescriptorName");
+ QString actionLabel = customMenuConfig->GetAttribute("label");
+ QString actionClass = customMenuConfig->GetAttribute("class");
+
+ if (actionNodeDescriptorName.isEmpty() || actionLabel.isEmpty() || actionClass.isEmpty())
+ {
+ // no properties found for the current extension point
+ continue;
+ }
+
+ // find matching descriptor
+ auto nodeDescriptor = QmitkNodeDescriptorManager::GetInstance()->GetDescriptor(actionNodeDescriptorName);
+ if (nullptr == nodeDescriptor)
+ {
+ MITK_WARN << "Cannot add action \"" << actionLabel << "\" because descriptor " << actionNodeDescriptorName << " does not exist.";
+ continue;
+ }
+
+ // create action with or without icon
+ QAction* contextMenuAction;
+ QString actionIconName = customMenuConfig->GetAttribute("icon");
+ if (!actionIconName.isEmpty())
+ {
+ QIcon actionIcon;
+ if (QFile::exists(actionIconName))
+ {
+ actionIcon = QIcon(actionIconName);
+ }
+ else
+ {
+ actionIcon = berry::AbstractUICTKPlugin::ImageDescriptorFromPlugin(customMenuConfig->GetContributor()->GetName(), actionIconName);
+ }
+ contextMenuAction = new QAction(actionIcon, actionLabel, m_Parent);
+ }
+ else
+ {
+ contextMenuAction = new QAction(actionLabel, m_Parent);
+ }
+
+ // connect action trigger
+ connect(contextMenuAction, static_cast(&QAction::triggered), this, &QmitkDataNodeContextMenu::OnExtensionPointActionTriggered);
+
+ // mark configuration element into lookup list for context menu handler
+ m_ConfigElements[contextMenuAction] = customMenuConfig;
+ // mark new action in sortable list for addition to descriptor
+ descriptorActionList.emplace_back(nodeDescriptor, contextMenuAction);
+ }
+
+ AddDescriptorActionList(descriptorActionList);
+}
+
+void QmitkDataNodeContextMenu::InitServiceActions()
+{
+
+}
+
+void QmitkDataNodeContextMenu::OnContextMenuRequested(const QPoint& pos)
+{
+ if (m_WorkbenchPartSite.Expired())
+ {
+ return;
+ }
+
+ berry::ISelection::ConstPointer selection = m_WorkbenchPartSite.Lock()->GetWorkbenchWindow()->GetSelectionService()->GetSelection();
+ mitk::DataNodeSelection::ConstPointer currentSelection = selection.Cast();
+
+ if (currentSelection.IsNull() || currentSelection->IsEmpty())
+ {
+ return;
+ }
+
+ m_SelectedNodes = QList::fromStdList(currentSelection->GetSelectedDataNodes());
+ if (!m_SelectedNodes.isEmpty())
+ {
+ clear();
+ QList actions;
+ if (m_SelectedNodes.size() == 1)
+ {
+ // no batch action; should only contain a single node
+ actions = GetActions(m_SelectedNodes.front());
+ }
+ else
+ {
+ // batch action
+ actions = GetActions(m_SelectedNodes);
+ }
+
+ // initialize abstract data node actions
+ for (auto& action : actions)
+ {
+ QmitkAbstractDataNodeAction* abstractDataNodeAction = dynamic_cast(action);
+ if (nullptr != abstractDataNodeAction)
+ {
+ // use the first selected node to initialize the data node actions
+ abstractDataNodeAction->InitializeWithDataNode(m_SelectedNodes.front());
+ }
+ }
+
+ /*
+ if (!m_ShowInActions.isEmpty())
+ {
+ QMenu* showInMenu = m_NodeMenu->addMenu(tr("Show In"));
+ showInMenu->addActions(m_ShowInActions);
+ }
+ */
+
+ addActions(actions);
+ popup(QCursor::pos());
+ }
+}
+
+void QmitkDataNodeContextMenu::OnExtensionPointActionTriggered(bool)
+{
+ QAction* action = qobject_cast(sender());
+ ConfigurationElementsType::const_iterator it = m_ConfigElements.find(action);
+ if (it == m_ConfigElements.end())
+ {
+ MITK_WARN << "Associated configuration element for action " << action->text().toStdString() << " not found.";
+ return;
+ }
+
+ berry::IConfigurationElement::Pointer confElem = it->second;
+ mitk::IContextMenuAction* contextMenuAction = confElem->CreateExecutableExtension("class");
+
+ QString className = confElem->GetAttribute("class");
+ QString smoothed = confElem->GetAttribute("smoothed");
+
+ if (!m_DataStorage.IsExpired())
+ {
+ auto dataStorage = m_DataStorage.Lock();
+ contextMenuAction->SetDataStorage(dataStorage);
+ }
+
+ if (className == "QmitkCreatePolygonModelAction")
+ {
+ if (smoothed == "false")
+ {
+ contextMenuAction->SetSmoothed(false);
+ }
+ else
+ {
+ contextMenuAction->SetSmoothed(true);
+ }
+ contextMenuAction->SetDecimated(m_SurfaceDecimation);
+ }
+
+ contextMenuAction->Run(m_SelectedNodes);
+}
+
+void QmitkDataNodeContextMenu::AddColorAction(QWidgetAction* colorAction)
+{
+ bool colorActionCanBatch = true;
+ if (nullptr != m_ImageDataNodeDescriptor)
+ {
+ m_ImageDataNodeDescriptor->AddAction(colorAction, colorActionCanBatch);
+ m_DescriptorActionList.push_back(std::make_pair(m_ImageDataNodeDescriptor, colorAction));
+ }
+
+ if (nullptr != m_MultiComponentImageDataNodeDescriptor)
+ {
+ m_MultiComponentImageDataNodeDescriptor->AddAction(colorAction, colorActionCanBatch);
+ m_DescriptorActionList.push_back(std::make_pair(m_MultiComponentImageDataNodeDescriptor, colorAction));
+ }
+
+ if (nullptr != m_DiffusionImageDataNodeDescriptor)
+ {
+ m_DiffusionImageDataNodeDescriptor->AddAction(colorAction, colorActionCanBatch);
+ m_DescriptorActionList.push_back(std::make_pair(m_DiffusionImageDataNodeDescriptor, colorAction));
+ }
+
+ if (nullptr != m_FiberBundleDataNodeDescriptor)
+ {
+ m_FiberBundleDataNodeDescriptor->AddAction(colorAction, false);
+ m_DescriptorActionList.push_back(std::make_pair(m_FiberBundleDataNodeDescriptor, colorAction));
+ }
+
+ if (nullptr != m_PeakImageDataNodeDescriptor)
+ {
+ m_PeakImageDataNodeDescriptor->AddAction(colorAction, false);
+ m_DescriptorActionList.push_back(std::make_pair(m_PeakImageDataNodeDescriptor, colorAction));
+ }
+
+ if (nullptr != m_SegmentDataNodeDescriptor)
+ {
+ m_SegmentDataNodeDescriptor->AddAction(colorAction, false);
+ m_DescriptorActionList.push_back(std::make_pair(m_SegmentDataNodeDescriptor, colorAction));
+ }
+
+ if (nullptr != m_SurfaceDataNodeDescriptor)
+ {
+ m_SurfaceDataNodeDescriptor->AddAction(colorAction, colorActionCanBatch);
+ m_DescriptorActionList.push_back(std::make_pair(m_SurfaceDataNodeDescriptor, colorAction));
+ }
+
+ if (nullptr != m_PointSetNodeDescriptor)
+ {
+ m_PointSetNodeDescriptor->AddAction(colorAction, colorActionCanBatch);
+ m_DescriptorActionList.push_back(std::make_pair(m_PointSetNodeDescriptor, colorAction));
+ }
+
+ if (nullptr != m_PlanarLineNodeDescriptor)
+ {
+ m_PlanarLineNodeDescriptor->AddAction(colorAction, colorActionCanBatch);
+ m_DescriptorActionList.push_back(std::make_pair(m_PlanarLineNodeDescriptor, colorAction));
+ }
+
+ if (nullptr != m_PlanarCircleNodeDescriptor)
+ {
+ m_PlanarCircleNodeDescriptor->AddAction(colorAction, colorActionCanBatch);
+ m_DescriptorActionList.push_back(std::make_pair(m_PlanarCircleNodeDescriptor, colorAction));
+ }
+
+ if (nullptr != m_PlanarEllipseNodeDescriptor)
+ {
+ m_PlanarEllipseNodeDescriptor->AddAction(colorAction, colorActionCanBatch);
+ m_DescriptorActionList.push_back(std::make_pair(m_PlanarEllipseNodeDescriptor, colorAction));
+ }
+
+ if (nullptr != m_PlanarAngleNodeDescriptor)
+ {
+ m_PlanarAngleNodeDescriptor->AddAction(colorAction, colorActionCanBatch);
+ m_DescriptorActionList.push_back(std::make_pair(m_PlanarAngleNodeDescriptor, colorAction));
+ }
+
+ if (nullptr != m_PlanarFourPointAngleNodeDescriptor)
+ {
+ m_PlanarFourPointAngleNodeDescriptor->AddAction(colorAction, colorActionCanBatch);
+ m_DescriptorActionList.push_back(std::make_pair(m_PlanarFourPointAngleNodeDescriptor, colorAction));
+ }
+
+ if (nullptr != m_PlanarRectangleNodeDescriptor)
+ {
+ m_PlanarRectangleNodeDescriptor->AddAction(colorAction, colorActionCanBatch);
+ m_DescriptorActionList.push_back(std::make_pair(m_PlanarRectangleNodeDescriptor, colorAction));
+ }
+
+ if (nullptr != m_PlanarPolygonNodeDescriptor)
+ {
+ m_PlanarPolygonNodeDescriptor->AddAction(colorAction, colorActionCanBatch);
+ m_DescriptorActionList.push_back(std::make_pair(m_PlanarPolygonNodeDescriptor, colorAction));
+ }
+
+ if (nullptr != m_PlanarPathNodeDescriptor)
+ {
+ m_PlanarPathNodeDescriptor->AddAction(colorAction, colorActionCanBatch);
+ m_DescriptorActionList.push_back(std::make_pair(m_PlanarPathNodeDescriptor, colorAction));
+ }
+
+ if (nullptr != m_PlanarDoubleEllipseNodeDescriptor)
+ {
+ m_PlanarDoubleEllipseNodeDescriptor->AddAction(colorAction, colorActionCanBatch);
+ m_DescriptorActionList.push_back(std::make_pair(m_PlanarDoubleEllipseNodeDescriptor, colorAction));
+ }
+
+ if (nullptr != m_PlanarBezierCurveNodeDescriptor)
+ {
+ m_PlanarBezierCurveNodeDescriptor->AddAction(colorAction, colorActionCanBatch);
+ m_DescriptorActionList.push_back(std::make_pair(m_PlanarBezierCurveNodeDescriptor, colorAction));
+ }
+
+ if (nullptr != m_PlanarSubdivisionPolygonNodeDescriptor)
+ {
+ m_PlanarSubdivisionPolygonNodeDescriptor->AddAction(colorAction, colorActionCanBatch);
+ m_DescriptorActionList.push_back(std::make_pair(m_PlanarSubdivisionPolygonNodeDescriptor, colorAction));
+ }
+}
+
+void QmitkDataNodeContextMenu::AddDescriptorActionList(DescriptorActionListType& descriptorActionList)
+{
+ // sort all custom QActions by their texts
+ using ListEntryType = std::pair;
+ std::sort(descriptorActionList.begin(), descriptorActionList.end(),
+ [](const ListEntryType& left, const ListEntryType& right) -> bool
+ {
+ assert(left.second != nullptr && right.second != nullptr); // unless we messed up above
+ return left.second->text() < right.second->text();
+ });
+
+ // add custom QActions in sorted order
+ for (auto& descriptorActionPair : descriptorActionList)
+ {
+ auto& nodeDescriptor = descriptorActionPair.first;
+ auto& contextMenuAction = descriptorActionPair.second;
+
+ // add action to the descriptor
+ nodeDescriptor->AddAction(contextMenuAction);
+
+ // mark new action into list of descriptors to remove in destructor
+ m_DescriptorActionList.push_back(descriptorActionPair);
+ }
+}
+
+QList QmitkDataNodeContextMenu::GetActions(const mitk::DataNode* node)
+{
+ QList actions;
+ for (DescriptorActionListType::const_iterator it = m_DescriptorActionList.begin(); it != m_DescriptorActionList.end(); ++it)
+ {
+ if ((it->first)->CheckNode(node) ||
+ it->first->GetNameOfClass() == "Unknown")
+ {
+ actions.append(it->second);
+ }
+ }
+
+ return actions;
+}
+
+QList QmitkDataNodeContextMenu::GetActions(const QList& nodes)
+{
+ QList actions;
+
+ for (DescriptorActionListType::const_iterator it = m_DescriptorActionList.begin(); it != m_DescriptorActionList.end(); ++it)
+ {
+ for (const auto& node : nodes)
+ {
+ if ((it->first)->CheckNode(node) ||
+ it->first->GetNameOfClass() == "Unknown")
+ {
+ const auto& batchActions = (it->first)->GetBatchActions();
+ if (std::find(batchActions.begin(), batchActions.end(), it->second) != batchActions.end())
+ {
+ // current descriptor action is a batch action
+ actions.append(it->second);
+ }
+ break; // only add action once; goto next descriptor action
+ }
+ }
+ }
+
+ return actions;
+}
diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeContextMenu.h b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeContextMenu.h
new file mode 100644
index 0000000000..d5f3055074
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeContextMenu.h
@@ -0,0 +1,134 @@
+/*===================================================================
+
+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 QMITKDATANODECONTEXTMENU_H
+#define QMITKDATANODECONTEXTMENU_H
+
+#include
+
+// qt widgets module
+#include "QmitkDataNodeGlobalReinitAction.h"
+#include "QmitkDataNodeReinitAction.h"
+#include "QmitkDataNodeRemoveAction.h"
+#include "QmitkDataNodeShowSelectedNodesAction.h"
+#include "QmitkDataNodeToggleVisibilityAction.h"
+#include "QmitkDataNodeShowDetailsAction.h"
+#include "QmitkDataNodeOpacityAction.h"
+#include "QmitkDataNodeColorAction.h"
+#include "QmitkDataNodeColorMapAction.h"
+#include "QmitkDataNodeComponentAction.h"
+#include "QmitkDataNodeTextureInterpolationAction.h"
+#include "QmitkDataNodeSurfaceRepresentationAction.h"
+#include "QmitkNodeDescriptor.h"
+
+// mitk core
+#include
+#include
+
+// blueberry ui qt plugin
+#include
+#include
+
+// qt
+#include
+
+class MITK_QT_APP QmitkDataNodeContextMenu : public QMenu
+{
+ Q_OBJECT
+
+public:
+
+ QmitkDataNodeContextMenu(berry::IWorkbenchPartSite::Pointer workbenchPartSite, QWidget* parent = nullptr);
+
+ virtual ~QmitkDataNodeContextMenu() override;
+
+ void SetDataStorage(mitk::DataStorage* dataStorage);
+ void SetSurfaceDecimation(bool surfaceDecimation);
+
+public Q_SLOTS:
+
+ void OnContextMenuRequested(const QPoint& pos);
+ void OnExtensionPointActionTriggered(bool);
+
+private:
+
+ using DescriptorActionListType = std::vector>;
+ using ConfigurationElementsType = std::map;
+
+ void InitNodeDescriptors();
+ void InitDefaultActions();
+ void InitExtensionPointActions();
+ void InitServiceActions();
+
+ void AddColorAction(QWidgetAction* colorAction);
+ void AddDescriptorActionList(DescriptorActionListType& descriptorActionList);
+
+ QList GetActions(const mitk::DataNode* node);
+ QList GetActions(const QList& nodes);
+
+ QWidget* m_Parent;
+ berry::IWorkbenchPartSite::WeakPtr m_WorkbenchPartSite;
+
+ mitk::WeakPointer m_DataStorage;
+ QList m_SelectedNodes;
+
+ // store a list of all actions to remove them on menu destruction
+ DescriptorActionListType m_DescriptorActionList;
+
+ // stores the configuration elements for the context menu actions from extension points
+ ConfigurationElementsType m_ConfigElements;
+
+ QmitkNodeDescriptor* m_UnknownDataNodeDescriptor;
+ QmitkNodeDescriptor* m_ImageDataNodeDescriptor;
+ QmitkNodeDescriptor* m_MultiComponentImageDataNodeDescriptor;
+ QmitkNodeDescriptor* m_DiffusionImageDataNodeDescriptor;
+ QmitkNodeDescriptor* m_FiberBundleDataNodeDescriptor;
+ QmitkNodeDescriptor* m_PeakImageDataNodeDescriptor;
+ QmitkNodeDescriptor* m_SegmentDataNodeDescriptor;
+ QmitkNodeDescriptor* m_SurfaceDataNodeDescriptor;
+ QmitkNodeDescriptor* m_PointSetNodeDescriptor;
+ QmitkNodeDescriptor* m_PlanarLineNodeDescriptor;
+ QmitkNodeDescriptor* m_PlanarCircleNodeDescriptor;
+ QmitkNodeDescriptor* m_PlanarEllipseNodeDescriptor;
+ QmitkNodeDescriptor* m_PlanarAngleNodeDescriptor;
+ QmitkNodeDescriptor* m_PlanarFourPointAngleNodeDescriptor;
+ QmitkNodeDescriptor* m_PlanarRectangleNodeDescriptor;
+ QmitkNodeDescriptor* m_PlanarPolygonNodeDescriptor;
+ QmitkNodeDescriptor* m_PlanarPathNodeDescriptor;
+ QmitkNodeDescriptor* m_PlanarDoubleEllipseNodeDescriptor;
+ QmitkNodeDescriptor* m_PlanarBezierCurveNodeDescriptor;
+ QmitkNodeDescriptor* m_PlanarSubdivisionPolygonNodeDescriptor;
+
+ //////////////////////////////////////////////////////////////////////////
+ // default actions
+ //////////////////////////////////////////////////////////////////////////
+ QmitkDataNodeGlobalReinitAction* m_GlobalReinitAction;
+ QmitkDataNodeReinitAction* m_ReinitAction;
+ QmitkDataNodeRemoveAction* m_RemoveAction;
+ QmitkDataNodeShowSelectedNodesAction* m_ShowSelectedNodesAction;
+ QmitkDataNodeToggleVisibilityAction* m_ToggleVisibilityAction;
+ QmitkDataNodeShowDetailsAction* m_ShowDetailsAction;
+ QmitkDataNodeOpacityAction* m_OpacityAction;
+ QmitkDataNodeColorAction* m_ColorAction;
+ QmitkDataNodeColorMapAction* m_ColormapAction;
+ QmitkDataNodeComponentAction* m_ComponentAction;
+ QmitkDataNodeTextureInterpolationAction* m_TextureInterpolationAction;
+ QmitkDataNodeSurfaceRepresentationAction* m_SurfaceRepresentationAction;
+
+ bool m_SurfaceDecimation;
+};
+
+#endif // QMITKDATANODECONTEXTMENU_H
diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeGlobalReinitAction.cpp b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeGlobalReinitAction.cpp
new file mode 100644
index 0000000000..0ee3c9249b
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeGlobalReinitAction.cpp
@@ -0,0 +1,86 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+
+#include
+
+// mitk core
+#include
+
+// mitk gui common plugin
+#include
+
+const QString QmitkDataNodeGlobalReinitAction::ACTION_ID = "org.mitk.gui.qt.application.globalreinitaction";
+
+// namespace that contains the concrete action
+namespace GlobalReinitAction
+{
+ void Run(berry::IWorkbenchPartSite::Pointer workbenchPartSite, mitk::DataStorage::Pointer dataStorage)
+ {
+ auto renderWindow = mitk::WorkbenchUtil::GetRenderWindowPart(workbenchPartSite->GetPage(), mitk::WorkbenchUtil::NONE);
+ if (nullptr == renderWindow)
+ {
+ renderWindow = mitk::WorkbenchUtil::OpenRenderWindowPart(workbenchPartSite->GetPage(), false);
+ if (nullptr == renderWindow)
+ {
+ // no render window available
+ return;
+ }
+ }
+
+ mitk::RenderingManager::GetInstance()->InitializeViewsByBoundingObjects(dataStorage);
+ }
+}
+
+QmitkDataNodeGlobalReinitAction::QmitkDataNodeGlobalReinitAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchPartSite)
+ : QAction(parent)
+ , QmitkAbstractDataNodeAction(workbenchPartSite)
+{
+ setText(tr("Global Reinit"));
+ InitializeAction();
+}
+
+QmitkDataNodeGlobalReinitAction::QmitkDataNodeGlobalReinitAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchPartSite)
+ : QAction(parent)
+ , QmitkAbstractDataNodeAction(berry::IWorkbenchPartSite::Pointer(workbenchPartSite))
+{
+ setText(tr("Global Reinit"));
+ InitializeAction();
+}
+
+QmitkDataNodeGlobalReinitAction::~QmitkDataNodeGlobalReinitAction()
+{
+ // nothing here
+}
+
+void QmitkDataNodeGlobalReinitAction::InitializeAction()
+{
+ connect(this, &QmitkDataNodeGlobalReinitAction::triggered, this, &QmitkDataNodeGlobalReinitAction::OnActionTriggered);
+}
+
+void QmitkDataNodeGlobalReinitAction::OnActionTriggered(bool checked)
+{
+ if (m_WorkbenchPartSite.Expired())
+ {
+ return;
+ }
+
+ if (m_DataStorage.IsExpired())
+ {
+ return;
+ }
+
+ GlobalReinitAction::Run(m_WorkbenchPartSite.Lock(), m_DataStorage.Lock());
+}
diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeGlobalReinitAction.h b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeGlobalReinitAction.h
new file mode 100644
index 0000000000..5202843495
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeGlobalReinitAction.h
@@ -0,0 +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 QMITKDATANODEGLOBALREINITACTION_H
+#define QMITKDATANODEGLOBALREINITACTION_H
+
+#include
+
+#include "QmitkAbstractDataNodeAction.h"
+
+// qt
+#include
+
+namespace GlobalReinitAction
+{
+ MITK_QT_APP void Run(berry::IWorkbenchPartSite::Pointer workbenchPartSite, mitk::DataStorage::Pointer dataStorage);
+}
+
+class MITK_QT_APP QmitkDataNodeGlobalReinitAction : public QAction, public QmitkAbstractDataNodeAction
+{
+ Q_OBJECT
+
+public:
+
+ static const QString ACTION_ID; // = "org.mitk.gui.qt.application.globalreinitaction";
+
+ QmitkDataNodeGlobalReinitAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchPartSite);
+ QmitkDataNodeGlobalReinitAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchPartSite);
+
+ virtual ~QmitkDataNodeGlobalReinitAction() override;
+
+private Q_SLOTS:
+
+ void OnActionTriggered(bool);
+
+private:
+
+ virtual void InitializeAction() override;
+
+};
+
+#endif // QMITKDATANODEGLOBALREINITACTION_H
diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeHideAllAction.cpp b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeHideAllAction.cpp
new file mode 100644
index 0000000000..3d6f1fb987
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeHideAllAction.cpp
@@ -0,0 +1,73 @@
+/*===================================================================
+
+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
+
+// mitk core
+#include
+
+namespace HideAllAction
+{
+ void Run(mitk::DataStorage::Pointer dataStorage)
+ {
+ auto nodeset = dataStorage->GetAll();
+ for (auto& node : *nodeset)
+ {
+ if (node.IsNotNull())
+ {
+ node->SetVisibility(false);
+ }
+ }
+
+ mitk::RenderingManager::GetInstance()->RequestUpdateAll();
+ }
+}
+
+QmitkDataNodeHideAllAction::QmitkDataNodeHideAllAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchpartSite)
+ : QAction(parent)
+ , QmitkAbstractDataNodeAction(workbenchpartSite)
+{
+ setText(tr("Hide all nodes"));
+ InitializeAction();
+}
+
+QmitkDataNodeHideAllAction::QmitkDataNodeHideAllAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchpartSite)
+ : QAction(parent)
+ , QmitkAbstractDataNodeAction(berry::IWorkbenchPartSite::Pointer(workbenchpartSite))
+{
+ setText(tr("Hide all nodes"));
+ InitializeAction();
+}
+
+QmitkDataNodeHideAllAction::~QmitkDataNodeHideAllAction()
+{
+ // nothing here
+}
+
+void QmitkDataNodeHideAllAction::InitializeAction()
+{
+ connect(this, &QmitkDataNodeHideAllAction::triggered, this, &QmitkDataNodeHideAllAction::OnActionTriggered);
+}
+
+void QmitkDataNodeHideAllAction::OnActionTriggered(bool checked)
+{
+ if (m_DataStorage.IsExpired())
+ {
+ return;
+ }
+
+ HideAllAction::Run(m_DataStorage.Lock());
+}
diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeHideAllAction.h b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeHideAllAction.h
new file mode 100644
index 0000000000..c4dc15e2a7
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeHideAllAction.h
@@ -0,0 +1,53 @@
+/*===================================================================
+
+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 QMITKDATANODEHIDEALLACTION_H
+#define QMITKDATANODEHIDEALLACTION_H
+
+#include
+
+#include "QmitkAbstractDataNodeAction.h"
+
+// qt
+#include
+
+namespace HideAllAction
+{
+ MITK_QT_APP void Run(mitk::DataStorage::Pointer dataStorage);
+}
+
+class MITK_QT_APP QmitkDataNodeHideAllAction : public QAction, public QmitkAbstractDataNodeAction
+{
+ Q_OBJECT
+
+public:
+
+ QmitkDataNodeHideAllAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchPartSite);
+ QmitkDataNodeHideAllAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchPartSite);
+
+ virtual ~QmitkDataNodeHideAllAction() override;
+
+private Q_SLOTS:
+
+ void OnActionTriggered(bool);
+
+protected:
+
+ virtual void InitializeAction() override;
+
+};
+
+#endif // QMITKDATANODEHIDEALLACTION_H
diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeOpacityAction.cpp b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeOpacityAction.cpp
new file mode 100644
index 0000000000..58c58830bc
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeOpacityAction.cpp
@@ -0,0 +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.
+
+===================================================================*/
+
+#include
+
+// mitk core
+#include
+
+// qt
+#include
+#include
+
+QmitkDataNodeOpacityAction::QmitkDataNodeOpacityAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchPartSite)
+ : QWidgetAction(parent)
+ , QmitkAbstractDataNodeAction(workbenchPartSite)
+{
+ InitializeAction();
+}
+
+QmitkDataNodeOpacityAction::QmitkDataNodeOpacityAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchPartSite)
+ : QWidgetAction(parent)
+ , QmitkAbstractDataNodeAction(berry::IWorkbenchPartSite::Pointer(workbenchPartSite))
+{
+ InitializeAction();
+}
+
+QmitkDataNodeOpacityAction::~QmitkDataNodeOpacityAction()
+{
+ // nothing here
+}
+
+void QmitkDataNodeOpacityAction::InitializeAction()
+{
+ m_OpacitySlider = new QSlider;
+ m_OpacitySlider->setMinimum(0);
+ m_OpacitySlider->setMaximum(100);
+ m_OpacitySlider->setOrientation(Qt::Horizontal);
+ connect(m_OpacitySlider, &QSlider::valueChanged, this, &QmitkDataNodeOpacityAction::OnOpacityChanged);
+
+ QLabel* opacityLabel = new QLabel(tr("Opacity: "));
+ QHBoxLayout* opacityWidgetLayout = new QHBoxLayout;
+ opacityWidgetLayout->setContentsMargins(4, 4, 4, 4);
+ opacityWidgetLayout->addWidget(opacityLabel);
+ opacityWidgetLayout->addWidget(m_OpacitySlider);
+
+ QWidget* opacityWidget = new QWidget;
+ opacityWidget->setLayout(opacityWidgetLayout);
+
+ setDefaultWidget(opacityWidget);
+
+ connect(this, &QAction::changed, this, &QmitkDataNodeOpacityAction::OnActionChanged);
+}
+
+void QmitkDataNodeOpacityAction::InitializeWithDataNode(const mitk::DataNode* dataNode)
+{
+ float opacity = 0.0;
+ if (dataNode->GetFloatProperty("opacity", opacity))
+ {
+ m_OpacitySlider->setValue(static_cast(opacity * 100));
+ }
+}
+
+void QmitkDataNodeOpacityAction::OnOpacityChanged(int value)
+{
+ auto dataNode = GetSelectedNode();
+ if (dataNode.IsNull())
+ {
+ return;
+ }
+
+ float opacity = static_cast(value) / 100.0f;
+ dataNode->SetFloatProperty("opacity", opacity);
+
+ mitk::RenderingManager::GetInstance()->RequestUpdateAll();
+}
+
+void QmitkDataNodeOpacityAction::OnActionChanged()
+{
+ auto dataNode = GetSelectedNode();
+ if (dataNode.IsNull())
+ {
+ return;
+ }
+
+ InitializeWithDataNode(dataNode);
+}
diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeOpacityAction.h b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeOpacityAction.h
new file mode 100644
index 0000000000..637732249a
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeOpacityAction.h
@@ -0,0 +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 QMITKDATANODEOPACITYACTION_H
+#define QMITKDATANODEOPACITYACTION_H
+
+#include
+
+#include "QmitkAbstractDataNodeAction.h"
+
+// qt
+#include
+#include
+
+class MITK_QT_APP QmitkDataNodeOpacityAction : public QWidgetAction, public QmitkAbstractDataNodeAction
+{
+ Q_OBJECT
+
+public:
+
+ QmitkDataNodeOpacityAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchPartSite);
+ QmitkDataNodeOpacityAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchPartSite);
+
+ virtual ~QmitkDataNodeOpacityAction() override;
+
+ virtual void InitializeWithDataNode(const mitk::DataNode* dataNode) override;
+
+private Q_SLOTS:
+
+ void OnOpacityChanged(int);
+ void OnActionChanged();
+
+protected:
+
+ virtual void InitializeAction() override;
+
+ QSlider* m_OpacitySlider;
+
+};
+
+#endif // QMITKDATANODEOPACITYACTION_H
diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeReinitAction.cpp b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeReinitAction.cpp
new file mode 100644
index 0000000000..b7925ad9d3
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeReinitAction.cpp
@@ -0,0 +1,123 @@
+/*===================================================================
+
+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
+
+// mitk core
+#include
+#include
+#include
+#include
+#include
+
+// mitk gui common plugin
+#include
+
+// namespace that contains the concrete action
+namespace ReinitAction
+{
+ void Run(berry::IWorkbenchPartSite::Pointer workbenchPartSite, mitk::DataStorage::Pointer dataStorage)
+ {
+ auto renderWindow =
+ mitk::WorkbenchUtil::GetRenderWindowPart(workbenchPartSite->GetPage(), mitk::WorkbenchUtil::NONE);
+ if (nullptr == renderWindow)
+ {
+ renderWindow = mitk::WorkbenchUtil::OpenRenderWindowPart(workbenchPartSite->GetPage(), false);
+ if (nullptr == renderWindow)
+ {
+ // no render window available
+ return;
+ }
+ }
+
+ auto dataNodes = AbstractDataNodeAction::GetSelectedNodes(workbenchPartSite);
+ if (dataNodes.isEmpty())
+ {
+ return;
+ }
+
+ auto boundingBoxPredicate = mitk::NodePredicateNot::New(mitk::NodePredicateProperty::New("includeInBoundingBox", mitk::BoolProperty::New(false)));
+
+ mitk::DataStorage::SetOfObjects::Pointer nodes = mitk::DataStorage::SetOfObjects::New();
+ for (const auto &dataNode : dataNodes)
+ {
+ if (boundingBoxPredicate->CheckNode(dataNode))
+ {
+ nodes->InsertElement(nodes->Size(), dataNode);
+ }
+ }
+
+ if (nodes->empty())
+ {
+ return;
+ }
+
+ if (1 == nodes->Size()) // Special case: If exactly one ...
+ {
+ auto image = dynamic_cast(nodes->ElementAt(0)->GetData());
+
+ if (nullptr != image) // ... image is selected, reinit is expected to rectify askew images.
+ {
+ mitk::RenderingManager::GetInstance()->InitializeViews(image->GetTimeGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true);
+ return;
+ }
+ }
+
+ auto boundingGeometry = dataStorage->ComputeBoundingGeometry3D(nodes, "visible");
+ mitk::RenderingManager::GetInstance()->InitializeViews(boundingGeometry);
+ }
+}
+
+QmitkDataNodeReinitAction::QmitkDataNodeReinitAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchpartSite)
+ : QAction(parent)
+ , QmitkAbstractDataNodeAction(workbenchpartSite)
+{
+ setText(tr("Reinit"));
+ InitializeAction();
+}
+
+QmitkDataNodeReinitAction::QmitkDataNodeReinitAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchpartSite)
+ : QAction(parent)
+ , QmitkAbstractDataNodeAction(berry::IWorkbenchPartSite::Pointer(workbenchpartSite))
+{
+ setText(tr("Reinit"));
+ InitializeAction();
+}
+
+QmitkDataNodeReinitAction::~QmitkDataNodeReinitAction()
+{
+ // nothing here
+}
+
+void QmitkDataNodeReinitAction::InitializeAction()
+{
+ connect(this, &QmitkDataNodeReinitAction::triggered, this, &QmitkDataNodeReinitAction::OnActionTriggered);
+}
+
+void QmitkDataNodeReinitAction::OnActionTriggered(bool checked)
+{
+ if (m_WorkbenchPartSite.Expired())
+ {
+ return;
+ }
+
+ if (m_DataStorage.IsExpired())
+ {
+ return;
+ }
+
+ ReinitAction::Run(m_WorkbenchPartSite.Lock(), m_DataStorage.Lock());
+}
diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeReinitAction.h b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeReinitAction.h
new file mode 100644
index 0000000000..0e605f361b
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeReinitAction.h
@@ -0,0 +1,53 @@
+/*===================================================================
+
+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 QMITKDATANODEREINITACTION_H
+#define QMITKDATANODEREINITACTION_H
+
+#include
+
+#include "QmitkAbstractDataNodeAction.h"
+
+// qt
+#include
+
+namespace ReinitAction
+{
+ MITK_QT_APP void Run(berry::IWorkbenchPartSite::Pointer workbenchPartSite, mitk::DataStorage::Pointer dataStorage);
+}
+
+class MITK_QT_APP QmitkDataNodeReinitAction : public QAction, public QmitkAbstractDataNodeAction
+{
+ Q_OBJECT
+
+public:
+
+ QmitkDataNodeReinitAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchPartSite);
+ QmitkDataNodeReinitAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchPartSite);
+
+ virtual ~QmitkDataNodeReinitAction() override;
+
+private Q_SLOTS:
+
+ void OnActionTriggered(bool);
+
+protected:
+
+ virtual void InitializeAction() override;
+
+};
+
+#endif // QMITKDATANODEREINITACTION_H
diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeRemoveAction.cpp b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeRemoveAction.cpp
new file mode 100644
index 0000000000..e0ba7e83f3
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeRemoveAction.cpp
@@ -0,0 +1,118 @@
+/*===================================================================
+
+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
+#include
+
+// qt
+#include
+
+// berry
+#include
+#include
+#include
+
+namespace RemoveAction
+{
+ void Run(berry::IWorkbenchPartSite::Pointer workbenchPartSite, mitk::DataStorage::Pointer dataStorage, QWidget* parent /* = nullptr*/)
+ {
+ QString question("Do you really want to remove ");
+ auto selectedNodes = AbstractDataNodeAction::GetSelectedNodes(workbenchPartSite);
+ for (auto& dataNode : selectedNodes)
+ {
+ if (nullptr == dataNode)
+ {
+ continue;
+ }
+
+ question.append(QString::fromStdString(dataNode->GetName()));
+ question.append(", ");
+ }
+
+ // remove the last two characters = ", "
+ question = question.remove(question.size() - 2, 2);
+ question.append(" from data storage?");
+
+ QMessageBox::StandardButton answerButton =
+ QMessageBox::question(parent, "DataManager", question, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
+
+ if (answerButton == QMessageBox::Yes)
+ {
+ for (auto& dataNode : selectedNodes)
+ {
+ if (nullptr == dataNode)
+ {
+ continue;
+ }
+
+ dataStorage->Remove(dataNode);
+ }
+
+ berry::IPreferencesService* prefService = berry::Platform::GetPreferencesService();
+ berry::IPreferences::Pointer preferencesNode =
+ prefService->GetSystemPreferences()->Node(QmitkDataNodeGlobalReinitAction::ACTION_ID);
+
+ bool globalReinit = preferencesNode->GetBool("Call global reinit if node is deleted", true);
+ if (globalReinit)
+ {
+ GlobalReinitAction::Run(workbenchPartSite, dataStorage);
+ }
+ }
+ }
+}
+
+QmitkDataNodeRemoveAction::QmitkDataNodeRemoveAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchpartSite)
+ : QAction(parent)
+ , QmitkAbstractDataNodeAction(workbenchpartSite)
+{
+ setText(tr("Remove"));
+ m_Parent = parent;
+ InitializeAction();
+}
+
+QmitkDataNodeRemoveAction::QmitkDataNodeRemoveAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchpartSite)
+ : QAction(parent)
+ , QmitkAbstractDataNodeAction(berry::IWorkbenchPartSite::Pointer(workbenchpartSite))
+{
+ setText(tr("Remove"));
+ m_Parent = parent;
+ InitializeAction();
+}
+
+QmitkDataNodeRemoveAction::~QmitkDataNodeRemoveAction()
+{
+ // nothing here
+}
+
+void QmitkDataNodeRemoveAction::InitializeAction()
+{
+ connect(this, &QmitkDataNodeRemoveAction::triggered, this, &QmitkDataNodeRemoveAction::OnActionTriggered);
+}
+
+void QmitkDataNodeRemoveAction::OnActionTriggered(bool checked)
+{
+ if (m_WorkbenchPartSite.Expired())
+ {
+ return;
+ }
+
+ if (m_DataStorage.IsExpired())
+ {
+ return;
+ }
+
+ RemoveAction::Run(m_WorkbenchPartSite.Lock(), m_DataStorage.Lock(), m_Parent);
+}
diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeRemoveAction.h b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeRemoveAction.h
new file mode 100644
index 0000000000..7af412e6a6
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeRemoveAction.h
@@ -0,0 +1,57 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+
+#ifndef QMITKDATANODEREMOVEACTION_H
+#define QMITKDATANODEREMOVEACTION_H
+
+#include
+
+#include "QmitkAbstractDataNodeAction.h"
+
+// qt
+#include
+
+namespace RemoveAction
+{
+ MITK_QT_APP void Run(berry::IWorkbenchPartSite::Pointer workbenchPartSite, mitk::DataStorage::Pointer dataStorage, QWidget* parent = nullptr);
+}
+
+class MITK_QT_APP QmitkDataNodeRemoveAction : public QAction, public QmitkAbstractDataNodeAction
+{
+ Q_OBJECT
+
+public:
+
+ QmitkDataNodeRemoveAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchPartSite);
+ QmitkDataNodeRemoveAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchPartSite);
+
+ virtual ~QmitkDataNodeRemoveAction() override;
+
+private Q_SLOTS:
+
+ void OnActionTriggered(bool);
+
+protected:
+
+ virtual void InitializeAction() override;
+
+private:
+
+ QWidget* m_Parent;
+
+};
+
+#endif // QMITKDATANODEREMOVEACTION_H
diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeShowDetailsAction.cpp b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeShowDetailsAction.cpp
new file mode 100644
index 0000000000..0b3d03db81
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeShowDetailsAction.cpp
@@ -0,0 +1,69 @@
+/*===================================================================
+
+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
+
+// mitk gui qt application
+#include "src/internal/QmitkInfoDialog.h"
+
+namespace ShowDetailsAction
+{
+ void Run(berry::IWorkbenchPartSite::Pointer workbenchPartSite, QWidget* parent /* = nullptr*/)
+ {
+ auto selectedNodes = AbstractDataNodeAction::GetSelectedNodes(workbenchPartSite);
+
+ QmitkInfoDialog infoDialog(selectedNodes, parent);
+ infoDialog.exec();
+ }
+}
+
+QmitkDataNodeShowDetailsAction::QmitkDataNodeShowDetailsAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchpartSite)
+ : QAction(parent)
+ , QmitkAbstractDataNodeAction(workbenchpartSite)
+{
+ setText(tr("Show details"));
+ m_Parent = parent;
+ InitializeAction();
+}
+
+QmitkDataNodeShowDetailsAction::QmitkDataNodeShowDetailsAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchpartSite)
+ : QAction(parent)
+ , QmitkAbstractDataNodeAction(berry::IWorkbenchPartSite::Pointer(workbenchpartSite))
+{
+ setText(tr("Show details"));
+ m_Parent = parent;
+ InitializeAction();
+}
+
+QmitkDataNodeShowDetailsAction::~QmitkDataNodeShowDetailsAction()
+{
+ // nothing here
+}
+
+void QmitkDataNodeShowDetailsAction::InitializeAction()
+{
+ connect(this, &QmitkDataNodeShowDetailsAction::triggered, this, &QmitkDataNodeShowDetailsAction::OnActionTriggered);
+}
+
+void QmitkDataNodeShowDetailsAction::OnActionTriggered(bool checked)
+{
+ if (m_WorkbenchPartSite.Expired())
+ {
+ return;
+ }
+
+ ShowDetailsAction::Run(m_WorkbenchPartSite.Lock(), m_Parent);
+}
diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeShowDetailsAction.h b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeShowDetailsAction.h
new file mode 100644
index 0000000000..e0a1b74e84
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeShowDetailsAction.h
@@ -0,0 +1,57 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+
+#ifndef QMITKDATANODESHOWDETAILSACTION_H
+#define QMITKDATANODESHOWDETAILSACTION_H
+
+#include
+
+#include "QmitkAbstractDataNodeAction.h"
+
+// qt
+#include
+
+namespace ShowDetailsAction
+{
+ MITK_QT_APP void Run(berry::IWorkbenchPartSite::Pointer workbenchPartSite, QWidget* parent = nullptr);
+}
+
+class MITK_QT_APP QmitkDataNodeShowDetailsAction : public QAction, public QmitkAbstractDataNodeAction
+{
+ Q_OBJECT
+
+public:
+
+ QmitkDataNodeShowDetailsAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchPartSite);
+ QmitkDataNodeShowDetailsAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchPartSite);
+
+ virtual ~QmitkDataNodeShowDetailsAction() override;
+
+private Q_SLOTS:
+
+ void OnActionTriggered(bool);
+
+protected:
+
+ virtual void InitializeAction() override;
+
+private:
+
+ QWidget* m_Parent;
+
+};
+
+#endif // QMITKDATANODESHOWDETAILSACTION_H
diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeShowSelectedNodesAction.cpp b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeShowSelectedNodesAction.cpp
new file mode 100644
index 0000000000..43a802af99
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeShowSelectedNodesAction.cpp
@@ -0,0 +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.
+
+===================================================================*/
+
+#include
+
+// mitk core
+#include
+
+QmitkDataNodeShowSelectedNodesAction::QmitkDataNodeShowSelectedNodesAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchpartSite)
+ : QAction(parent)
+ , QmitkAbstractDataNodeAction(workbenchpartSite)
+{
+ setText(tr("Show only selected nodes"));
+ InitializeAction();
+}
+
+QmitkDataNodeShowSelectedNodesAction::QmitkDataNodeShowSelectedNodesAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchpartSite)
+ : QAction(parent)
+ , QmitkAbstractDataNodeAction(berry::IWorkbenchPartSite::Pointer(workbenchpartSite))
+{
+ setText(tr("Show only selected nodes"));
+ InitializeAction();
+}
+
+QmitkDataNodeShowSelectedNodesAction::~QmitkDataNodeShowSelectedNodesAction()
+{
+ // nothing here
+}
+
+void QmitkDataNodeShowSelectedNodesAction::InitializeAction()
+{
+ connect(this, &QmitkDataNodeShowSelectedNodesAction::triggered, this, &QmitkDataNodeShowSelectedNodesAction::OnActionTriggered);
+}
+
+void QmitkDataNodeShowSelectedNodesAction::OnActionTriggered(bool checked)
+{
+ if (m_DataStorage.IsExpired())
+ {
+ return;
+ }
+
+ auto dataStorage = m_DataStorage.Lock();
+
+ auto selectedNodes = GetSelectedNodes();
+ auto nodeset = dataStorage->GetAll();
+ for (auto& node : *nodeset)
+ {
+ if (node.IsNotNull())
+ {
+ node->SetVisibility(selectedNodes.contains(node));
+ }
+ }
+
+ mitk::RenderingManager::GetInstance()->RequestUpdateAll();
+}
diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeShowSelectedNodesAction.h b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeShowSelectedNodesAction.h
new file mode 100644
index 0000000000..1847481291
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeShowSelectedNodesAction.h
@@ -0,0 +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 QMITKDATANODESHOWSELECTEDNODESACTION_H
+#define QMITKDATANODESHOWSELECTEDNODESACTION_H
+
+#include
+
+#include "QmitkAbstractDataNodeAction.h"
+
+// qt
+#include
+
+class MITK_QT_APP QmitkDataNodeShowSelectedNodesAction : public QAction, public QmitkAbstractDataNodeAction
+{
+ Q_OBJECT
+
+public:
+
+ QmitkDataNodeShowSelectedNodesAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchPartSite);
+ QmitkDataNodeShowSelectedNodesAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchPartSite);
+
+ virtual ~QmitkDataNodeShowSelectedNodesAction() override;
+
+private Q_SLOTS:
+
+ void OnActionTriggered(bool);
+
+protected:
+
+ virtual void InitializeAction() override;
+
+};
+
+#endif // QMITKDATANODESHOWSELECTEDNODESACTION_H
diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeSurfaceRepresentationAction.cpp b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeSurfaceRepresentationAction.cpp
new file mode 100644
index 0000000000..9e71bd0de8
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeSurfaceRepresentationAction.cpp
@@ -0,0 +1,118 @@
+/*===================================================================
+
+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
+
+// mitk core
+#include
+#include
+
+// qt
+#include
+
+QmitkDataNodeSurfaceRepresentationAction::QmitkDataNodeSurfaceRepresentationAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchpartSite)
+ : QAction(parent)
+ , QmitkAbstractDataNodeAction(workbenchpartSite)
+{
+ setText(tr("Surface Representation"));
+ InitializeAction();
+}
+
+QmitkDataNodeSurfaceRepresentationAction::QmitkDataNodeSurfaceRepresentationAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchpartSite)
+ : QAction(parent)
+ , QmitkAbstractDataNodeAction(berry::IWorkbenchPartSite::Pointer(workbenchpartSite))
+{
+ setText(tr("Surface Representation"));
+ InitializeAction();
+}
+
+QmitkDataNodeSurfaceRepresentationAction::~QmitkDataNodeSurfaceRepresentationAction()
+{
+ // nothing here
+}
+
+void QmitkDataNodeSurfaceRepresentationAction::InitializeAction()
+{
+ setCheckable(true);
+
+ setMenu(new QMenu);
+ connect(menu(), &QMenu::aboutToShow, this, &QmitkDataNodeSurfaceRepresentationAction::OnMenuAboutShow);
+}
+
+void QmitkDataNodeSurfaceRepresentationAction::OnMenuAboutShow()
+{
+ mitk::DataNode::Pointer dataNode = GetSelectedNode();
+ if (nullptr == dataNode)
+ {
+ return;
+ }
+
+ mitk::EnumerationProperty* representationProp = dynamic_cast(dataNode->GetProperty("material.representation"));
+ if (nullptr == representationProp)
+ {
+ return;
+ }
+
+ menu()->clear();
+ QAction* tmp;
+
+ for (mitk::EnumerationProperty::EnumConstIterator it = representationProp->Begin(); it != representationProp->End(); ++it)
+ {
+ tmp = menu()->addAction(QString::fromStdString(it->second));
+ tmp->setCheckable(true);
+
+ if (it->second == representationProp->GetValueAsString())
+ {
+ tmp->setChecked(true);
+ }
+
+ connect(tmp, &QAction::triggered, this, &QmitkDataNodeSurfaceRepresentationAction::OnActionTriggered);
+ }
+}
+
+void QmitkDataNodeSurfaceRepresentationAction::OnActionTriggered(bool checked)
+{
+ auto dataNode = GetSelectedNode();
+ if (dataNode.IsNull())
+ {
+ return;
+ }
+
+ mitk::EnumerationProperty* representationProp = dynamic_cast(dataNode->GetProperty("material.representation"));
+ if (nullptr == representationProp)
+ {
+ return;
+ }
+
+ QAction* senderAction = qobject_cast(QObject::sender());
+ if (nullptr == senderAction)
+ {
+ return;
+ }
+
+ std::string activatedItem = senderAction->text().toStdString();
+ if (activatedItem != representationProp->GetValueAsString())
+ {
+ if (representationProp->IsValidEnumerationValue(activatedItem))
+ {
+ representationProp->SetValue(activatedItem);
+ representationProp->InvokeEvent(itk::ModifiedEvent());
+ representationProp->Modified();
+
+ mitk::RenderingManager::GetInstance()->RequestUpdateAll();
+ }
+ }
+}
diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeSurfaceRepresentationAction.h b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeSurfaceRepresentationAction.h
new file mode 100644
index 0000000000..57abbf8e87
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeSurfaceRepresentationAction.h
@@ -0,0 +1,49 @@
+/*===================================================================
+
+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 QMITKDATANODESURFACEREPRESENTATIONACTION_H
+#define QMITKDATANODESURFACEREPRESENTATIONACTION_H
+
+#include
+
+#include "QmitkAbstractDataNodeAction.h"
+
+// qt
+#include
+
+class MITK_QT_APP QmitkDataNodeSurfaceRepresentationAction : public QAction, public QmitkAbstractDataNodeAction
+{
+ Q_OBJECT
+
+public:
+
+ QmitkDataNodeSurfaceRepresentationAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchPartSite);
+ QmitkDataNodeSurfaceRepresentationAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchPartSite);
+
+ virtual ~QmitkDataNodeSurfaceRepresentationAction() override;
+
+private Q_SLOTS:
+
+ void OnMenuAboutShow();
+ void OnActionTriggered(bool);
+
+protected:
+
+ virtual void InitializeAction() override;
+
+};
+
+#endif // QMITKDATANODESURFACEREPRESENTATIONACTION_H
diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeTextureInterpolationAction.cpp b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeTextureInterpolationAction.cpp
new file mode 100644
index 0000000000..7dfac8d873
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeTextureInterpolationAction.cpp
@@ -0,0 +1,79 @@
+/*===================================================================
+
+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
+
+// mitk core
+#include
+
+QmitkDataNodeTextureInterpolationAction::QmitkDataNodeTextureInterpolationAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchpartSite)
+ : QAction(parent)
+ , QmitkAbstractDataNodeAction(workbenchpartSite)
+{
+ setText(tr("Texture Interpolation"));
+ InitializeAction();
+}
+
+QmitkDataNodeTextureInterpolationAction::QmitkDataNodeTextureInterpolationAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchpartSite)
+ : QAction(parent)
+ , QmitkAbstractDataNodeAction(berry::IWorkbenchPartSite::Pointer(workbenchpartSite))
+{
+ setText(tr("Texture Interpolation"));
+ InitializeAction();
+}
+
+QmitkDataNodeTextureInterpolationAction::~QmitkDataNodeTextureInterpolationAction()
+{
+ // nothing here
+}
+
+void QmitkDataNodeTextureInterpolationAction::InitializeAction()
+{
+ setCheckable(true);
+
+ connect(this, &QmitkDataNodeTextureInterpolationAction::toggled, this, &QmitkDataNodeTextureInterpolationAction::OnActionToggled);
+ connect(this, &QmitkDataNodeTextureInterpolationAction::changed, this, &QmitkDataNodeTextureInterpolationAction::OnActionChanged);
+}
+
+void QmitkDataNodeTextureInterpolationAction::InitializeWithDataNode(const mitk::DataNode* dataNode)
+{
+ bool textureInterpolation = false;
+ dataNode->GetBoolProperty("texture interpolation", textureInterpolation);
+ setChecked(textureInterpolation);
+}
+
+void QmitkDataNodeTextureInterpolationAction::OnActionToggled(bool checked)
+{
+ auto dataNode = GetSelectedNode();
+ if (dataNode.IsNull())
+ {
+ return;
+ }
+
+ dataNode->SetBoolProperty("texture interpolation", checked);
+ mitk::RenderingManager::GetInstance()->RequestUpdateAll();
+}
+
+void QmitkDataNodeTextureInterpolationAction::OnActionChanged()
+{
+ auto dataNode = GetSelectedNode();
+ if (dataNode.IsNull())
+ {
+ return;
+ }
+
+ InitializeWithDataNode(dataNode);
+}
diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeTextureInterpolationAction.h b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeTextureInterpolationAction.h
new file mode 100644
index 0000000000..589c2b2f95
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeTextureInterpolationAction.h
@@ -0,0 +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 QMITKDATANODETEXTUREINTERPOLATIONACTION_H
+#define QMITKDATANODETEXTUREINTERPOLATIONACTION_H
+
+#include
+
+#include "QmitkAbstractDataNodeAction.h"
+
+// qt
+#include
+
+class MITK_QT_APP QmitkDataNodeTextureInterpolationAction : public QAction, public QmitkAbstractDataNodeAction
+{
+ Q_OBJECT
+
+public:
+
+ QmitkDataNodeTextureInterpolationAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchPartSite);
+ QmitkDataNodeTextureInterpolationAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchPartSite);
+
+ virtual ~QmitkDataNodeTextureInterpolationAction() override;
+
+ virtual void InitializeWithDataNode(const mitk::DataNode* dataNode) override;
+
+private Q_SLOTS:
+
+ void OnActionChanged();
+ void OnActionToggled(bool);
+
+protected:
+
+ virtual void InitializeAction() override;
+
+};
+
+#endif // QMITKDATANODETEXTUREINTERPOLATIONACTION_H
diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeToggleVisibilityAction.cpp b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeToggleVisibilityAction.cpp
new file mode 100644
index 0000000000..71043897d4
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeToggleVisibilityAction.cpp
@@ -0,0 +1,103 @@
+/*===================================================================
+
+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
+#include
+
+// mitk core
+#include
+
+// berry
+#include
+#include
+#include
+
+// namespace that contains the concrete action
+namespace ToggleVisibilityAction
+{
+ void Run(berry::IWorkbenchPartSite::Pointer workbenchPartSite, mitk::DataStorage::Pointer dataStorage, QList selectedNodes /* = QList()*/)
+ {
+ if (selectedNodes.empty())
+ {
+ selectedNodes = AbstractDataNodeAction::GetSelectedNodes(workbenchPartSite);
+ }
+
+ bool isVisible;
+ for (auto& node : selectedNodes)
+ {
+ if (node.IsNotNull())
+ {
+ isVisible = false;
+ node->GetBoolProperty("visible", isVisible);
+ node->SetVisibility(!isVisible);
+ }
+ }
+
+ berry::IPreferencesService* prefService = berry::Platform::GetPreferencesService();
+ berry::IPreferences::Pointer preferencesNode = prefService->GetSystemPreferences()->Node(QmitkDataNodeGlobalReinitAction::ACTION_ID);
+
+ bool globalReinit = preferencesNode->GetBool("Call global reinit if node visibility is changed", false);
+ if (globalReinit)
+ {
+ GlobalReinitAction::Run(workbenchPartSite, dataStorage);
+ }
+ else
+ {
+ mitk::RenderingManager::GetInstance()->RequestUpdateAll();
+ }
+ }
+}
+
+QmitkDataNodeToggleVisibilityAction::QmitkDataNodeToggleVisibilityAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchpartSite)
+ : QAction(parent)
+ , QmitkAbstractDataNodeAction(workbenchpartSite)
+{
+ setText(tr("Toggle visibility"));
+ InitializeAction();
+}
+
+QmitkDataNodeToggleVisibilityAction::QmitkDataNodeToggleVisibilityAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchpartSite)
+ : QAction(parent)
+ , QmitkAbstractDataNodeAction(berry::IWorkbenchPartSite::Pointer(workbenchpartSite))
+{
+ setText(tr("Toggle visibility"));
+ InitializeAction();
+}
+
+QmitkDataNodeToggleVisibilityAction::~QmitkDataNodeToggleVisibilityAction()
+{
+ // nothing here
+}
+
+void QmitkDataNodeToggleVisibilityAction::InitializeAction()
+{
+ connect(this, &QmitkDataNodeToggleVisibilityAction::triggered, this, &QmitkDataNodeToggleVisibilityAction::OnActionTriggered);
+}
+
+void QmitkDataNodeToggleVisibilityAction::OnActionTriggered(bool checked)
+{
+ if (m_WorkbenchPartSite.Expired())
+ {
+ return;
+ }
+
+ if (m_DataStorage.IsExpired())
+ {
+ return;
+ }
+
+ ToggleVisibilityAction::Run(m_WorkbenchPartSite.Lock(), m_DataStorage.Lock());
+}
diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeToggleVisibilityAction.h b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeToggleVisibilityAction.h
new file mode 100644
index 0000000000..acd9138b91
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeToggleVisibilityAction.h
@@ -0,0 +1,53 @@
+/*===================================================================
+
+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 QMITKDATANODETOGGLEVISIBILITYACTION_H
+#define QMITKDATANODETOGGLEVISIBILITYACTION_H
+
+#include
+
+#include "QmitkAbstractDataNodeAction.h"
+
+// qt
+#include
+
+namespace ToggleVisibilityAction
+{
+ MITK_QT_APP void Run(berry::IWorkbenchPartSite::Pointer workbenchPartSite, mitk::DataStorage::Pointer dataStorage, QList selectedNodes = QList());
+}
+
+class MITK_QT_APP QmitkDataNodeToggleVisibilityAction : public QAction, public QmitkAbstractDataNodeAction
+{
+ Q_OBJECT
+
+public:
+
+ QmitkDataNodeToggleVisibilityAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchPartSite);
+ QmitkDataNodeToggleVisibilityAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchPartSite);
+
+ virtual ~QmitkDataNodeToggleVisibilityAction() override;
+
+private Q_SLOTS:
+
+ void OnActionTriggered(bool);
+
+protected:
+
+ virtual void InitializeAction() override;
+
+};
+
+#endif // QMITKDATANODETOGGLEVISIBILITYACTION_H
diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkFileOpenAction.cpp b/Plugins/org.mitk.gui.qt.application/src/QmitkFileOpenAction.cpp
index f8cbab6c8a..8e37af88e6 100644
--- a/Plugins/org.mitk.gui.qt.application/src/QmitkFileOpenAction.cpp
+++ b/Plugins/org.mitk.gui.qt.application/src/QmitkFileOpenAction.cpp
@@ -1,123 +1,125 @@
/*===================================================================
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 "QmitkFileOpenAction.h"
#include "internal/org_mitk_gui_qt_application_Activator.h"
#include
#include
#include
#include
class QmitkFileOpenActionPrivate
{
public:
- void init ( berry::IWorkbenchWindow* window, QmitkFileOpenAction* action )
+ void Init(berry::IWorkbenchWindow* window, QmitkFileOpenAction* action)
{
m_Window = window;
action->setText("&Open File...");
action->setToolTip("Open data files (images, surfaces,...)");
QObject::connect(action, SIGNAL(triggered(bool)), action, SLOT(Run()));
}
berry::IPreferences::Pointer GetPreferences() const
{
berry::IPreferencesService* prefService = mitk::PluginActivator::GetInstance()->GetPreferencesService();
- if (prefService)
+ if (prefService != nullptr)
{
return prefService->GetSystemPreferences()->Node("/General");
}
return berry::IPreferences::Pointer(nullptr);
}
- QString getLastFileOpenPath() const
+ QString GetLastFileOpenPath() const
{
berry::IPreferences::Pointer prefs = GetPreferences();
- if(prefs.IsNotNull())
+ if (prefs.IsNotNull())
{
return prefs->Get("LastFileOpenPath", "");
}
return QString();
}
- void setLastFileOpenPath(const QString& path) const
+ void SetLastFileOpenPath(const QString& path) const
{
berry::IPreferences::Pointer prefs = GetPreferences();
- if(prefs.IsNotNull())
+ if (prefs.IsNotNull())
{
prefs->Put("LastFileOpenPath", path);
prefs->Flush();
}
}
bool GetOpenEditor() const
{
berry::IPreferences::Pointer prefs = GetPreferences();
- if(prefs.IsNotNull())
+ if (prefs.IsNotNull())
{
return prefs->GetBool("OpenEditor", true);
}
return true;
}
berry::IWorkbenchWindow* m_Window;
};
QmitkFileOpenAction::QmitkFileOpenAction(berry::IWorkbenchWindow::Pointer window)
- : QAction(nullptr), d(new QmitkFileOpenActionPrivate)
+ : QAction(nullptr)
+ , d(new QmitkFileOpenActionPrivate)
{
- d->init(window.GetPointer(), this);
+ d->Init(window.GetPointer(), this);
}
-QmitkFileOpenAction::QmitkFileOpenAction(const QIcon & icon, berry::IWorkbenchWindow::Pointer window)
- : QAction(nullptr), d(new QmitkFileOpenActionPrivate)
+QmitkFileOpenAction::QmitkFileOpenAction(const QIcon& icon, berry::IWorkbenchWindow::Pointer window)
+ : QAction(nullptr)
+ , d(new QmitkFileOpenActionPrivate)
{
- d->init(window.GetPointer(), this);
- this->setIcon(icon);
+ d->Init(window.GetPointer(), this);
+ setIcon(icon);
}
QmitkFileOpenAction::QmitkFileOpenAction(const QIcon& icon, berry::IWorkbenchWindow* window)
: QAction(nullptr), d(new QmitkFileOpenActionPrivate)
{
- d->init(window, this);
- this->setIcon(icon);
+ d->Init(window, this);
+ setIcon(icon);
}
QmitkFileOpenAction::~QmitkFileOpenAction()
{
}
void QmitkFileOpenAction::Run()
{
-
- // Ask the user for a list of files to open
+ // ask the user for a list of files to open
QStringList fileNames = QFileDialog::getOpenFileNames(nullptr, "Open",
- d->getLastFileOpenPath(),
+ d->GetLastFileOpenPath(),
QmitkIOUtil::GetFileOpenFilterString());
if (fileNames.empty())
+ {
return;
+ }
- d->setLastFileOpenPath(fileNames.front());
- mitk::WorkbenchUtil::LoadFiles(fileNames, berry::IWorkbenchWindow::Pointer(d->m_Window),
- d->GetOpenEditor());
+ d->SetLastFileOpenPath(fileNames.front());
+ mitk::WorkbenchUtil::LoadFiles(fileNames, berry::IWorkbenchWindow::Pointer(d->m_Window), d->GetOpenEditor());
}
diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkFileOpenAction.h b/Plugins/org.mitk.gui.qt.application/src/QmitkFileOpenAction.h
index 79675eb528..5f032d9d6a 100644
--- a/Plugins/org.mitk.gui.qt.application/src/QmitkFileOpenAction.h
+++ b/Plugins/org.mitk.gui.qt.application/src/QmitkFileOpenAction.h
@@ -1,56 +1,53 @@
/*===================================================================
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 QMITKFILEOPENACTION_H_
#define QMITKFILEOPENACTION_H_
-#include
-#include
+#include
#include
-#include
-
-#include
+// qt
+#include
+#include
class QmitkFileOpenActionPrivate;
-/**
- * \ingroup org_mitk_gui_qt_application
- */
class MITK_QT_APP QmitkFileOpenAction : public QAction
{
Q_OBJECT
public:
+
QmitkFileOpenAction(berry::IWorkbenchWindow::Pointer window);
- QmitkFileOpenAction(const QIcon & icon, berry::IWorkbenchWindow::Pointer window);
- QmitkFileOpenAction(const QIcon & icon, berry::IWorkbenchWindow* window);
+ QmitkFileOpenAction(const QIcon& icon, berry::IWorkbenchWindow::Pointer window);
+ QmitkFileOpenAction(const QIcon& icon, berry::IWorkbenchWindow* window);
- ~QmitkFileOpenAction() override;
+ virtual ~QmitkFileOpenAction() override;
protected slots:
virtual void Run();
private:
const QScopedPointer d;
};
#endif /*QMITKFILEOPENACTION_H_*/
diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkFileSaveAction.cpp b/Plugins/org.mitk.gui.qt.application/src/QmitkFileSaveAction.cpp
index d755511a5f..8efe3f43eb 100644
--- a/Plugins/org.mitk.gui.qt.application/src/QmitkFileSaveAction.cpp
+++ b/Plugins/org.mitk.gui.qt.application/src/QmitkFileSaveAction.cpp
@@ -1,196 +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 "QmitkFileSaveAction.h"
#include "internal/org_mitk_gui_qt_application_Activator.h"
#include
#include
#include
#include
#include
#include
-#include
-#include
-
class QmitkFileSaveActionPrivate
{
private:
void HandleSelectionChanged(const berry::IWorkbenchPart::Pointer& /*part*/,
const berry::ISelection::ConstPointer& selection)
{
- this->setEnabled(selection);
+ this->SetEnabled(selection);
}
QScopedPointer m_SelectionListener;
public:
QmitkFileSaveActionPrivate()
: m_SelectionListener(new berry::NullSelectionChangedAdapter(
this, &QmitkFileSaveActionPrivate::HandleSelectionChanged))
{
}
~QmitkFileSaveActionPrivate()
{
if (!m_Window.Expired())
{
m_Window.Lock()->GetSelectionService()->RemoveSelectionListener(m_SelectionListener.data());
}
}
- void init ( berry::IWorkbenchWindow* window, QmitkFileSaveAction* action )
+ void Init(berry::IWorkbenchWindow* window, QAction* action)
{
m_Window = berry::IWorkbenchWindow::Pointer(window);
m_Action = action;
- action->setText("&Save...");
- action->setToolTip("Save data objects (images, surfaces,...)");
+ m_Action->setText("&Save...");
+ m_Action->setToolTip("Save data objects (images, surfaces,...)");
berry::ISelectionService* selectionService = m_Window.Lock()->GetSelectionService();
- setEnabled(selectionService->GetSelection());
+ SetEnabled(selectionService->GetSelection());
selectionService->AddSelectionListener(m_SelectionListener.data());
- QObject::connect(action, SIGNAL(triggered(bool)), action, SLOT(Run()));
+ QObject::connect(m_Action, SIGNAL(triggered(bool)), m_Action, SLOT(Run()));
}
berry::IPreferences::Pointer GetPreferences() const
{
berry::IPreferencesService* prefService = mitk::PluginActivator::GetInstance()->GetPreferencesService();
if (prefService != nullptr)
{
return prefService->GetSystemPreferences()->Node("/General");
}
return berry::IPreferences::Pointer(nullptr);
}
- QString getLastFileSavePath() const
+ QString GetLastFileSavePath() const
{
berry::IPreferences::Pointer prefs = GetPreferences();
- if(prefs.IsNotNull())
+ if (prefs.IsNotNull())
{
return prefs->Get("LastFileSavePath", "");
}
return QString();
}
- void setLastFileSavePath(const QString& path) const
+ void SetLastFileSavePath(const QString& path) const
{
berry::IPreferences::Pointer prefs = GetPreferences();
- if(prefs.IsNotNull())
+ if (prefs.IsNotNull())
{
prefs->Put("LastFileSavePath", path);
prefs->Flush();
}
}
- void setEnabled(berry::ISelection::ConstPointer selection)
+ void SetEnabled(berry::ISelection::ConstPointer selection)
{
mitk::DataNodeSelection::ConstPointer nodeSelection = selection.Cast();
if (nodeSelection.IsNotNull() && !selection->IsEmpty())
{
bool enable = false;
std::list dataNodes = nodeSelection->GetSelectedDataNodes();
- for (std::list::const_iterator nodeIter = dataNodes.begin(),
- nodeIterEnd = dataNodes.end(); nodeIter != nodeIterEnd; ++nodeIter)
+ for (std::list::const_iterator nodeIter = dataNodes.begin(), nodeIterEnd = dataNodes.end(); nodeIter != nodeIterEnd; ++nodeIter)
{
if ((*nodeIter)->GetData() != nullptr)
{
enable = true;
break;
}
}
m_Action->setEnabled(enable);
}
else
{
m_Action->setEnabled(false);
}
}
berry::IWorkbenchWindow::WeakPtr m_Window;
QAction* m_Action;
};
QmitkFileSaveAction::QmitkFileSaveAction(berry::IWorkbenchWindow::Pointer window)
- : QAction(nullptr), d(new QmitkFileSaveActionPrivate)
+ : QAction(tr("Save..."))
+ , d(new QmitkFileSaveActionPrivate)
{
- d->init(window.GetPointer(), this);
+ d->Init(window.GetPointer(), this);
}
-QmitkFileSaveAction::QmitkFileSaveAction(const QIcon & icon, berry::IWorkbenchWindow::Pointer window)
- : QAction(nullptr), d(new QmitkFileSaveActionPrivate)
+QmitkFileSaveAction::QmitkFileSaveAction(const QIcon& icon, berry::IWorkbenchWindow::Pointer window)
+ : QAction(tr("Save..."))
+ , d(new QmitkFileSaveActionPrivate)
{
- d->init(window.GetPointer(), this);
- this->setIcon(icon);
+ d->Init(window.GetPointer(), this);
+ setIcon(icon);
}
QmitkFileSaveAction::QmitkFileSaveAction(const QIcon& icon, berry::IWorkbenchWindow* window)
- : QAction(nullptr), d(new QmitkFileSaveActionPrivate)
+ : QAction(tr("Save..."))
+ , d(new QmitkFileSaveActionPrivate)
{
- d->init(window, this);
- this->setIcon(icon);
+ d->Init(window, this);
+ setIcon(icon);
}
QmitkFileSaveAction::~QmitkFileSaveAction()
{
}
void QmitkFileSaveAction::Run()
{
- // Get the list of selected base data objects
+ // get the list of selected base data objects
mitk::DataNodeSelection::ConstPointer selection = d->m_Window.Lock()->GetSelectionService()->GetSelection().Cast();
if (selection.IsNull() || selection->IsEmpty())
{
MITK_ERROR << "Assertion failed: data node selection is nullptr or empty";
return;
}
std::list dataNodes = selection->GetSelectedDataNodes();
std::vector data;
QStringList names;
- for (std::list::const_iterator nodeIter = dataNodes.begin(),
- nodeIterEnd = dataNodes.end(); nodeIter != nodeIterEnd; ++nodeIter)
+ for (std::list::const_iterator nodeIter = dataNodes.begin(), nodeIterEnd = dataNodes.end(); nodeIter != nodeIterEnd; ++nodeIter)
{
data.push_back((*nodeIter)->GetData());
std::string name;
(*nodeIter)->GetStringProperty("name", name);
names.push_back(QString::fromStdString(name));
}
try
{
- QStringList fileNames = QmitkIOUtil::Save(data, names, d->getLastFileSavePath(),
- d->m_Action->parentWidget());
+ QStringList fileNames = QmitkIOUtil::Save(data, names, d->GetLastFileSavePath(), d->m_Action->parentWidget());
if (!fileNames.empty())
{
- d->setLastFileSavePath(QFileInfo(fileNames.back()).absolutePath());
+ d->SetLastFileSavePath(QFileInfo(fileNames.back()).absolutePath());
}
}
catch (const mitk::Exception& e)
{
MITK_INFO << e;
return;
}
}
diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkFileSaveAction.h b/Plugins/org.mitk.gui.qt.application/src/QmitkFileSaveAction.h
index e6c5e0deb4..069afbdc42 100644
--- a/Plugins/org.mitk.gui.qt.application/src/QmitkFileSaveAction.h
+++ b/Plugins/org.mitk.gui.qt.application/src/QmitkFileSaveAction.h
@@ -1,56 +1,53 @@
/*===================================================================
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 QMITKFILESAVEACTION_H_
#define QMITKFILESAVEACTION_H_
-#include
-#include
+#include
#include
-#include
-
-#include
+// qt
+#include
+#include
class QmitkFileSaveActionPrivate;
-/**
- * \ingroup org_mitk_gui_qt_application
- */
class MITK_QT_APP QmitkFileSaveAction : public QAction
{
Q_OBJECT
public:
+
QmitkFileSaveAction(berry::IWorkbenchWindow::Pointer window);
- QmitkFileSaveAction(const QIcon & icon, berry::IWorkbenchWindow::Pointer window);
- QmitkFileSaveAction(const QIcon & icon, berry::IWorkbenchWindow* window);
+ QmitkFileSaveAction(const QIcon& icon, berry::IWorkbenchWindow::Pointer window);
+ QmitkFileSaveAction(const QIcon& icon, berry::IWorkbenchWindow* window);
- ~QmitkFileSaveAction() override;
+ virtual ~QmitkFileSaveAction() override;
protected slots:
virtual void Run();
private:
const QScopedPointer d;
};
#endif /*QMITKFILESAVEACTION_H_*/
diff --git a/Plugins/org.mitk.gui.qt.application/src/internal/QmitkGeneralPreferencePage.cpp b/Plugins/org.mitk.gui.qt.application/src/internal/QmitkGeneralPreferencePage.cpp
index 0e6057f917..02afc531fd 100644
--- a/Plugins/org.mitk.gui.qt.application/src/internal/QmitkGeneralPreferencePage.cpp
+++ b/Plugins/org.mitk.gui.qt.application/src/internal/QmitkGeneralPreferencePage.cpp
@@ -1,66 +1,78 @@
/*===================================================================
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 "QmitkGeneralPreferencePage.h"
-#include
+#include "QmitkDataNodeGlobalReinitAction.h"
-#include
-#include
#include
-#include
-#include
+#include
+
+#include
+#include
QmitkGeneralPreferencePage::QmitkGeneralPreferencePage()
-: m_MainControl(nullptr)
+ : m_MainControl(nullptr)
{
-
+ // nothing here
}
-void QmitkGeneralPreferencePage::Init(berry::IWorkbench::Pointer )
+void QmitkGeneralPreferencePage::Init(berry::IWorkbench::Pointer)
{
+ // nothing here
}
void QmitkGeneralPreferencePage::CreateQtControl(QWidget* parent)
{
- //empty page
+ berry::IPreferencesService* prefService = berry::Platform::GetPreferencesService();
+ m_GeneralPreferencesNode = prefService->GetSystemPreferences()->Node(QmitkDataNodeGlobalReinitAction::ACTION_ID);
+
m_MainControl = new QWidget(parent);
- auto layout = new QVBoxLayout;
- layout->addStretch();
- m_MainControl->setLayout(layout);
+ m_GlobalReinitOnNodeDelete = new QCheckBox;
+ m_GlobalReinitOnNodeVisibilityChanged = new QCheckBox;
+
+ auto formLayout = new QFormLayout;
+ formLayout->addRow("&Call global reinit if node is deleted", m_GlobalReinitOnNodeDelete);
+ formLayout->addRow("&Call global reinit if node visibility is changed", m_GlobalReinitOnNodeVisibilityChanged);
- this->Update();
+ m_MainControl->setLayout(formLayout);
+ Update();
}
QWidget* QmitkGeneralPreferencePage::GetQtControl() const
{
return m_MainControl;
}
bool QmitkGeneralPreferencePage::PerformOk()
{
+ m_GeneralPreferencesNode->PutBool("Call global reinit if node is deleted", m_GlobalReinitOnNodeDelete->isChecked());
+ m_GeneralPreferencesNode->PutBool("Call global reinit if node visibility is changed", m_GlobalReinitOnNodeVisibilityChanged->isChecked());
+
return true;
}
void QmitkGeneralPreferencePage::PerformCancel()
{
-
+ // nothing here
}
void QmitkGeneralPreferencePage::Update()
{
+ m_GlobalReinitOnNodeDelete->setChecked(m_GeneralPreferencesNode->GetBool("Call global reinit if node is deleted", true));
+ m_GlobalReinitOnNodeVisibilityChanged->setChecked(m_GeneralPreferencesNode->GetBool("Call global reinit if node visibility is changed", false));
}
diff --git a/Plugins/org.mitk.gui.qt.application/src/internal/QmitkGeneralPreferencePage.h b/Plugins/org.mitk.gui.qt.application/src/internal/QmitkGeneralPreferencePage.h
index 8f3c289dcc..31882e5f01 100644
--- a/Plugins/org.mitk.gui.qt.application/src/internal/QmitkGeneralPreferencePage.h
+++ b/Plugins/org.mitk.gui.qt.application/src/internal/QmitkGeneralPreferencePage.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 QMITKGENERALPREFERENCEPAGE_H_
-#define QMITKGENERALPREFERENCEPAGE_H_
+#ifndef QMITKGENERALPREFERENCEPAGE_H
+#define QMITKGENERALPREFERENCEPAGE_H
#include "berryIQtPreferencePage.h"
#include
class QWidget;
class QCheckBox;
class QmitkGeneralPreferencePage : public QObject, public berry::IQtPreferencePage
{
Q_OBJECT
Q_INTERFACES(berry::IPreferencePage)
public:
- /**
- * Default constructor
- */
QmitkGeneralPreferencePage();
/**
* @see berry::IPreferencePage::Init(berry::IWorkbench::Pointer workbench)
*/
void Init(berry::IWorkbench::Pointer workbench) override;
/**
* @see berry::IPreferencePage::CreateQtControl(void* parent)
*/
void CreateQtControl(QWidget* widget) override;
/**
* @see berry::IPreferencePage::CreateQtControl()
*/
QWidget* GetQtControl() const override;
/**
* @see berry::IPreferencePage::PerformOk()
*/
bool PerformOk() override;
/**
* @see berry::IPreferencePage::PerformCancel()
*/
void PerformCancel() override;
/**
* @see berry::IPreferencePage::Update()
*/
void Update() override;
protected:
QWidget* m_MainControl;
+ QCheckBox* m_GlobalReinitOnNodeDelete;
+ QCheckBox* m_GlobalReinitOnNodeVisibilityChanged;
+
+ berry::IPreferences::Pointer m_GeneralPreferencesNode;
};
-#endif /* QMITKGENERALPREFERENCEPAGE_H_ */
+#endif // QMITKGENERALPREFERENCEPAGE_H
diff --git a/Plugins/org.mitk.gui.qt.application/src/internal/QmitkInfoDialog.cpp b/Plugins/org.mitk.gui.qt.application/src/internal/QmitkInfoDialog.cpp
new file mode 100644
index 0000000000..11a8efc17d
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.application/src/internal/QmitkInfoDialog.cpp
@@ -0,0 +1,127 @@
+/*===================================================================
+
+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 "QmitkInfoDialog.h"
+
+#include "QmitkDataStorageComboBox.h"
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+QmitkInfoDialog::QmitkInfoDialog(const QList& nodes, QWidget* parent /*= nullptr*/, Qt::WindowFlags flags /*= nullptr */)
+ : QDialog(parent, flags)
+{
+ auto parentLayout = new QGridLayout;
+ auto dataStorageComboBox = new QmitkDataStorageComboBox(this, true);
+ m_KeyWord = new QLineEdit;
+ m_KeyWord->installEventFilter(this);
+ m_SearchButton = new QPushButton("Search (F3)", this);
+ m_SearchButton->installEventFilter(this);
+ m_TextBrowser = new QTextBrowser(this);
+ QPushButton* cancelButton = new QPushButton("Cancel", this);
+
+ setMinimumSize(512, 512);
+ setLayout(parentLayout);
+ setSizeGripEnabled(true);
+ setModal(true);
+
+ parentLayout->addWidget(dataStorageComboBox, 0, 0, 1, 2);
+ parentLayout->addWidget(m_KeyWord, 1, 0);
+ parentLayout->addWidget(m_SearchButton, 1, 1);
+ parentLayout->addWidget(m_TextBrowser, 2, 0, 1, 2);
+ parentLayout->addWidget(cancelButton, 3, 0, 1, 2);
+
+ connect(dataStorageComboBox, &QmitkDataStorageComboBox::OnSelectionChanged, this, &QmitkInfoDialog::OnSelectionChanged);
+
+ for(auto& node : nodes)
+ {
+ dataStorageComboBox->AddNode(node);
+ }
+
+ connect(m_KeyWord, &QLineEdit::textChanged, this, &QmitkInfoDialog::KeyWordTextChanged);
+ connect(m_SearchButton, &QPushButton::clicked, this, &QmitkInfoDialog::OnSearchButtonClicked);
+ connect(cancelButton, &QPushButton::clicked, this, &QmitkInfoDialog::OnCancelButtonClicked);
+
+ cancelButton->setDefault(true);
+}
+
+void QmitkInfoDialog::OnSelectionChanged(const mitk::DataNode* node)
+{
+ if (nullptr == node)
+ {
+ return;
+ }
+
+ std::ostringstream s;
+ itk::Indent i(2);
+ mitk::BaseData* baseData = node->GetData();
+ if (nullptr != baseData)
+ {
+ baseData->Print(s, i);
+ }
+
+ m_TextBrowser->setPlainText(QString::fromStdString(s.str()));
+}
+
+void QmitkInfoDialog::OnSearchButtonClicked(bool /*checked*/ /*= false */)
+{
+ QString keyWord = m_KeyWord->text();
+ QString text = m_TextBrowser->toPlainText();
+
+ if (keyWord.isEmpty() || text.isEmpty())
+ {
+ return;
+ }
+
+ m_TextBrowser->find(keyWord);
+ m_SearchButton->setText("Search Next(F3)");
+}
+
+void QmitkInfoDialog::OnCancelButtonClicked(bool /*checked*/ /*= false */)
+{
+ done(0);
+}
+
+bool QmitkInfoDialog::eventFilter(QObject* obj, QEvent* event)
+{
+ if (event->type() == QEvent::KeyPress)
+ {
+ QKeyEvent *keyEvent = static_cast(event);
+ if (keyEvent->key() == Qt::Key_F3 || keyEvent->key() == Qt::Key_Return)
+ {
+ // trigger deletion of selected node(s)
+ OnSearchButtonClicked(true);
+ // return true: this means the delete key event is not send to the table
+ return true;
+ }
+ }
+ // standard event processing
+ return QObject::eventFilter(obj, event);
+}
+
+void QmitkInfoDialog::KeyWordTextChanged(const QString& /*text*/)
+{
+ QTextCursor textCursor = m_TextBrowser->textCursor();
+ textCursor.setPosition(0);
+ m_TextBrowser->setTextCursor(textCursor);
+ m_SearchButton->setText("Search (F3)");
+}
diff --git a/Plugins/org.mitk.gui.qt.application/src/internal/QmitkInfoDialog.h b/Plugins/org.mitk.gui.qt.application/src/internal/QmitkInfoDialog.h
new file mode 100644
index 0000000000..f5cdd17572
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.application/src/internal/QmitkInfoDialog.h
@@ -0,0 +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 QMITKINFODIALOG_H
+#define QMITKINFODIALOG_H
+
+#include
+
+#include
+
+class QLineEdit;
+class QTextBrowser;
+
+class QmitkInfoDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+
+ QmitkInfoDialog(const QList& nodes, QWidget* parent = nullptr, Qt::WindowFlags flags = nullptr);
+
+public Q_SLOTS:
+
+ void OnSelectionChanged(const mitk::DataNode*);
+ void OnSearchButtonClicked(bool checked = false);
+ void OnCancelButtonClicked(bool checked = false);
+ void KeyWordTextChanged(const QString& text);
+
+protected:
+
+ bool eventFilter(QObject* obj, QEvent* event) override;
+
+protected:
+
+ QLineEdit* m_KeyWord;
+ QPushButton* m_SearchButton;
+ QTextBrowser* m_TextBrowser;
+
+};
+
+#endif // QMITKINFODIALOG_H
diff --git a/Plugins/org.mitk.gui.qt.datamanager/src/mitkIContextMenuAction.h b/Plugins/org.mitk.gui.qt.application/src/mitkIContextMenuAction.h
similarity index 89%
rename from Plugins/org.mitk.gui.qt.datamanager/src/mitkIContextMenuAction.h
rename to Plugins/org.mitk.gui.qt.application/src/mitkIContextMenuAction.h
index fa3dabbc5c..18133dcdd5 100644
--- a/Plugins/org.mitk.gui.qt.datamanager/src/mitkIContextMenuAction.h
+++ b/Plugins/org.mitk.gui.qt.application/src/mitkIContextMenuAction.h
@@ -1,53 +1,53 @@
/*===================================================================
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 mitkIContextMenuAction_H_
#define mitkIContextMenuAction_H_
#include
#include
#include
#include
#include "mitkDataStorage.h"
namespace mitk
{
/**
* A context menu action, which is linked to the context menu
* through an extension point. For an example check the
* plugin.xml
and the connected classes of
* the the segmentation bundle and also the QmitkDataManagerView.cpp
* in this bundle.
*/
struct IContextMenuAction
{
- /**
- * @brief Executes the action, that linked to the context menu entry.
- */
- virtual void Run( const QList& selectedNodes ) = 0;
+ /**
+ * @brief Executes the action, that linked to the context menu entry.
+ */
+ virtual void Run(const QList& selectedNodes) = 0;
// Setters
virtual void SetDataStorage(mitk::DataStorage* dataStorage) = 0;
virtual void SetSmoothed(bool smoothed) = 0;
virtual void SetDecimated(bool decimated) = 0;
virtual void SetFunctionality(berry::QtViewPart* functionality) = 0;
};
}
Q_DECLARE_INTERFACE(mitk::IContextMenuAction, "org.mitk.datamanager.IContextMenuAction")
#endif // mitkIContextMenuAction_H_
diff --git a/Plugins/org.mitk.gui.qt.common/src/QmitkAbstractView.cpp b/Plugins/org.mitk.gui.qt.common/src/QmitkAbstractView.cpp
index 33c8bf4dd2..fc92092b26 100644
--- a/Plugins/org.mitk.gui.qt.common/src/QmitkAbstractView.cpp
+++ b/Plugins/org.mitk.gui.qt.common/src/QmitkAbstractView.cpp
@@ -1,602 +1,526 @@
/*===================================================================
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 "QmitkAbstractView.h"
#include "QmitkDataNodeSelectionProvider.h"
#include "internal/QmitkCommonActivator.h"
#include "internal/QmitkDataNodeItemModel.h"
// mitk Includes
#include
#include
#include
-#include
#include
#include
// berry Includes
#include
#include
#include
#include
#include
// CTK Includes
#include
// Qt Includes
#include
#include
#include
#include
#include
class QmitkAbstractViewPrivate
{
public:
QmitkAbstractViewPrivate(QmitkAbstractView* qq)
: q(qq)
, m_PrefServiceTracker(QmitkCommonActivator::GetContext())
, m_DataStorageServiceTracker(QmitkCommonActivator::GetContext())
, m_Parent(nullptr)
, m_DataNodeItemModel(new QmitkDataNodeItemModel)
, m_DataNodeSelectionModel(new QItemSelectionModel(m_DataNodeItemModel))
, m_InDataStorageChanged(false)
{
m_PrefServiceTracker.open();
m_DataStorageServiceTracker.open();
}
~QmitkAbstractViewPrivate()
{
delete m_DataNodeSelectionModel;
delete m_DataNodeItemModel;
m_PrefServiceTracker.close();
m_DataStorageServiceTracker.close();
}
/**
* Called when a DataStorage Add Event was thrown. Sets
* m_InDataStorageChanged to true and calls NodeAdded afterwards.
* \see m_InDataStorageChanged
*/
void NodeAddedProxy(const mitk::DataNode* node)
{
// garantuee no recursions when a new node event is thrown in NodeAdded()
if(!m_InDataStorageChanged)
{
m_InDataStorageChanged = true;
q->NodeAdded(node);
q->DataStorageModified();
m_InDataStorageChanged = false;
}
}
/**
* Called when a DataStorage remove event was thrown. Sets
* m_InDataStorageChanged to true and calls NodeRemoved afterwards.
* \see m_InDataStorageChanged
*/
void NodeRemovedProxy(const mitk::DataNode* node)
{
// garantuee no recursions when a new node event is thrown in NodeAdded()
if(!m_InDataStorageChanged)
{
m_InDataStorageChanged = true;
q->NodeRemoved(node);
q->DataStorageModified();
m_InDataStorageChanged = false;
}
}
/**
* Called when a DataStorage changed event was thrown. Sets
* m_InDataStorageChanged to true and calls NodeChanged afterwards.
* \see m_InDataStorageChanged
*/
void NodeChangedProxy(const mitk::DataNode* node)
{
// garantuee no recursions when a new node event is thrown in NodeAdded()
if(!m_InDataStorageChanged)
{
m_InDataStorageChanged = true;
q->NodeChanged(node);
q->DataStorageModified();
m_InDataStorageChanged = false;
}
}
/**
* reactions to selection events from views
*/
void BlueBerrySelectionChanged(const berry::IWorkbenchPart::Pointer& sourcepart,
const berry::ISelection::ConstPointer& selection)
{
if(sourcepart.IsNull() || sourcepart.GetPointer() == static_cast(q))
return;
if(selection.IsNull())
{
q->OnNullSelection(sourcepart);
return;
}
mitk::DataNodeSelection::ConstPointer _DataNodeSelection
= selection.Cast();
q->OnSelectionChanged(sourcepart, this->DataNodeSelectionToQList(_DataNodeSelection));
}
/**
* Converts a mitk::DataNodeSelection to a QList (possibly empty)
*/
QList