diff --git a/Plugins/org.mitk.gui.qt.application/files.cmake b/Plugins/org.mitk.gui.qt.application/files.cmake index 7c7a097ea2..2cf35e19e8 100644 --- a/Plugins/org.mitk.gui.qt.application/files.cmake +++ b/Plugins/org.mitk.gui.qt.application/files.cmake @@ -1,87 +1,89 @@ set(SRC_CPP_FILES QmitkAbstractDataNodeAction.cpp QmitkCloseProjectAction.cpp QmitkDataNodeColorAction.cpp QmitkDataNodeColorMapAction.cpp QmitkDataNodeComponentAction.cpp QmitkDataNodeContextMenu.cpp QmitkDataNodeGlobalReinitAction.cpp QmitkDataNodeHideAllAction.cpp QmitkDataNodeOpacityAction.cpp + QmitkDataNodeOpenInAction.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/QmitkDataNodeOpenInAction.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/QmitkDataNodeColorMapAction.cpp b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeColorMapAction.cpp index 49cca9ecc8..aeb478286d 100644 --- a/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeColorMapAction.cpp +++ b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeColorMapAction.cpp @@ -1,161 +1,158 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #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/QmitkDataNodeComponentAction.cpp b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeComponentAction.cpp index 0250be552f..8e6a9a4468 100644 --- a/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeComponentAction.cpp +++ b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeComponentAction.cpp @@ -1,111 +1,108 @@ /*=================================================================== 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.semanticrelations/src/internal/QmitkDataNodeOpenInAction.cpp b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeOpenInAction.cpp similarity index 66% rename from Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeOpenInAction.cpp rename to Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeOpenInAction.cpp index 0eb010e44f..d57e2f137c 100644 --- a/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeOpenInAction.cpp +++ b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeOpenInAction.cpp @@ -1,170 +1,129 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ // semantic relations plugin #include "QmitkDataNodeOpenInAction.h" // mitk core #include #include // mitk gui common plugin #include // qt #include -// berry -#include -#include - // qt #include QmitkDataNodeOpenInAction::QmitkDataNodeOpenInAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchPartSite) : QAction(parent) - , m_WorkbenchPartSite(workbenchPartSite) + , QmitkAbstractDataNodeAction(workbenchPartSite) { setText(tr("Open in")); InitializeAction(); } QmitkDataNodeOpenInAction::QmitkDataNodeOpenInAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchPartSite) : QAction(parent) - , m_WorkbenchPartSite(berry::IWorkbenchPartSite::Pointer(workbenchPartSite)) + , QmitkAbstractDataNodeAction(berry::IWorkbenchPartSite::Pointer(workbenchPartSite)) { setText(tr("Open in")); InitializeAction(); } QmitkDataNodeOpenInAction::~QmitkDataNodeOpenInAction() { // nothing here } -void QmitkDataNodeOpenInAction::SetControlledRenderer(RenderWindowLayerUtilities::RendererVector controlledRenderer) +void QmitkDataNodeOpenInAction::SetControlledRenderer(RendererVector controlledRenderer) { if (m_ControlledRenderer != controlledRenderer) { // set the new set of controlled renderer m_ControlledRenderer = controlledRenderer; } } void QmitkDataNodeOpenInAction::InitializeAction() { setCheckable(true); setMenu(new QMenu); connect(menu(), &QMenu::aboutToShow, this, &QmitkDataNodeOpenInAction::OnMenuAboutToShow); SetControlledRenderer(); } -void QmitkDataNodeOpenInAction::SetControlledRenderer() -{ - const mitk::RenderingManager::RenderWindowVector allRegisteredRenderWindows = mitk::RenderingManager::GetInstance()->GetAllRegisteredRenderWindows(); - mitk::BaseRenderer* baseRenderer = nullptr; - m_ControlledRenderer.clear(); - for (const auto &renderWindow : allRegisteredRenderWindows) - { - baseRenderer = mitk::BaseRenderer::GetInstance(renderWindow); - if (nullptr != baseRenderer) - { - m_ControlledRenderer.push_back(baseRenderer); - } - } -} - void QmitkDataNodeOpenInAction::OnMenuAboutToShow() { menu()->clear(); QAction* action; for (const auto& renderer : m_ControlledRenderer) { action = menu()->addAction(QString::fromStdString(renderer->GetName())); connect(action, &QAction::triggered, this, &QmitkDataNodeOpenInAction::OnActionTriggered); } } void QmitkDataNodeOpenInAction::OnActionTriggered(bool checked) { auto dataNode = GetSelectedNode(); if (dataNode.IsNull()) { return; } QAction* senderAction = qobject_cast(QObject::sender()); if (nullptr == senderAction) { return; } std::string selectedRenderer = senderAction->text().toStdString(); mitk::BaseRenderer* renderer = mitk::BaseRenderer::GetByName(selectedRenderer); if (nullptr == renderer) { return; } auto image = dynamic_cast(dataNode->GetData()); if (nullptr == image) { return; } mitk::RenderingManager::GetInstance()->InitializeView(renderer->GetRenderWindow(), image->GetTimeGeometry()); } -QList QmitkDataNodeOpenInAction::GetSelectedNodes() -{ - QList selectedNodes; - if (m_WorkbenchPartSite.Expired()) - { - return selectedNodes; - } - - berry::ISelection::ConstPointer selection = m_WorkbenchPartSite.Lock()->GetWorkbenchWindow()->GetSelectionService()->GetSelection(); - mitk::DataNodeSelection::ConstPointer currentSelection = selection.Cast(); - - if (currentSelection.IsNull() || currentSelection->IsEmpty()) - { - return selectedNodes; - } - - selectedNodes = QList::fromStdList(currentSelection->GetSelectedDataNodes()); - return selectedNodes; -} - -mitk::DataNode::Pointer QmitkDataNodeOpenInAction::GetSelectedNode() +void QmitkDataNodeOpenInAction::SetControlledRenderer() { - 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) + const mitk::RenderingManager::RenderWindowVector allRegisteredRenderWindows = + mitk::RenderingManager::GetInstance()->GetAllRegisteredRenderWindows(); + mitk::BaseRenderer *baseRenderer = nullptr; + m_ControlledRenderer.clear(); + for (const auto &renderWindow : allRegisteredRenderWindows) { - return nullptr; + baseRenderer = mitk::BaseRenderer::GetInstance(renderWindow); + if (nullptr != baseRenderer) + { + m_ControlledRenderer.push_back(baseRenderer); + } } - - return dataNode; } diff --git a/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeOpenInAction.h b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeOpenInAction.h similarity index 63% rename from Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeOpenInAction.h rename to Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeOpenInAction.h index f9a9a2e204..5d18b76ddd 100644 --- a/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeOpenInAction.h +++ b/Plugins/org.mitk.gui.qt.application/src/QmitkDataNodeOpenInAction.h @@ -1,65 +1,60 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKDATANODEOPENINACTION_H #define QMITKDATANODEOPENINACTION_H -// mitk core -#include -#include +#include -// mitk render window manager module -#include +#include "QmitkAbstractDataNodeAction.h" -// berry -#include +// mitk core +#include // qt -#include +#include -class QmitkDataNodeOpenInAction : public QAction +class MITK_QT_APP QmitkDataNodeOpenInAction : public QAction, public QmitkAbstractDataNodeAction { Q_OBJECT public: + typedef std::vector RendererVector; + QmitkDataNodeOpenInAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchPartSite); QmitkDataNodeOpenInAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchPartSite); virtual ~QmitkDataNodeOpenInAction() override; - void SetControlledRenderer(RenderWindowLayerUtilities::RendererVector controlledRenderer); + void SetControlledRenderer(RendererVector controlledRenderer); private Q_SLOTS: void OnMenuAboutToShow(); void OnActionTriggered(bool); protected: - void InitializeAction(); - void SetControlledRenderer(); - - QList GetSelectedNodes(); - mitk::DataNode::Pointer GetSelectedNode(); + virtual void InitializeAction() override; - berry::IWorkbenchPartSite::WeakPtr m_WorkbenchPartSite; + void SetControlledRenderer(); - RenderWindowLayerUtilities::RendererVector m_ControlledRenderer; + RendererVector m_ControlledRenderer; }; #endif // QMITKDATANODEOPENINACTION_H diff --git a/Plugins/org.mitk.gui.qt.semanticrelations/files.cmake b/Plugins/org.mitk.gui.qt.semanticrelations/files.cmake index 32a1308816..dcff75cc03 100644 --- a/Plugins/org.mitk.gui.qt.semanticrelations/files.cmake +++ b/Plugins/org.mitk.gui.qt.semanticrelations/files.cmake @@ -1,44 +1,42 @@ set(INTERNAL_CPP_FILES mitkPluginActivator.cpp QmitkDataNodeAddToSemanticRelationsAction.cpp - QmitkDataNodeInformationTypeAction.cpp QmitkDataNodeRemoveFromSemanticRelationsAction.cpp QmitkDataNodeUnlinkFromLesionAction.cpp - QmitkDataNodeOpenInAction.cpp QmitkDataNodeSetControlPointAction.cpp + QmitkDataNodeSetInformationTypeAction.cpp QmitkLesionInfoWidget.cpp QmitkSemanticRelationsContextMenu.cpp QmitkSemanticRelationsNodeSelectionDialog.cpp QmitkSemanticRelationsView.cpp ) set(UI_FILES src/internal/QmitkLesionInfoWidgetControls.ui src/internal/QmitkSemanticRelationsControls.ui ) set(MOC_H_FILES src/internal/mitkPluginActivator.h src/internal/QmitkDataNodeAddToSemanticRelationsAction.h - src/internal/QmitkDataNodeInformationTypeAction.h src/internal/QmitkDataNodeRemoveFromSemanticRelationsAction.h src/internal/QmitkDataNodeUnlinkFromLesionAction.h - src/internal/QmitkDataNodeOpenInAction.h src/internal/QmitkDataNodeSetControlPointAction.h + src/internal/QmitkDataNodeSetInformationTypeAction.h src/internal/QmitkLesionInfoWidget.h src/internal/QmitkSemanticRelationsContextMenu.h src/internal/QmitkSemanticRelationsNodeSelectionDialog.h src/internal/QmitkSemanticRelationsView.h ) set(CACHED_RESOURCE_FILES resources/SemanticRelations_48.png plugin.xml ) set(QRC_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.semanticrelations/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.semanticrelations/manifest_headers.cmake index d22cc46799..9da36a3fbc 100644 --- a/Plugins/org.mitk.gui.qt.semanticrelations/manifest_headers.cmake +++ b/Plugins/org.mitk.gui.qt.semanticrelations/manifest_headers.cmake @@ -1,5 +1,5 @@ set(Plugin-Name "MITK Semantic relations") set(Plugin-Version "0.1") set(Plugin-Vendor "DKFZ") set(Plugin-ContactAddress "http://www.mitk.org") -set(Require-Plugin org.mitk.gui.qt.common) +set(Require-Plugin org.mitk.gui.qt.common org.mitk.gui.qt.application) diff --git a/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeAddToSemanticRelationsAction.cpp b/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeAddToSemanticRelationsAction.cpp index 4131253d55..99b93f1a1a 100644 --- a/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeAddToSemanticRelationsAction.cpp +++ b/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeAddToSemanticRelationsAction.cpp @@ -1,221 +1,179 @@ /*=================================================================== 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. ===================================================================*/ // semantic relations plugin #include "QmitkDataNodeAddToSemanticRelationsAction.h" // semantic relations module #include #include #include // mitk gui common plugin #include -// berry -#include -#include - // qt #include // namespace that contains the concrete action namespace AddToSemanticRelationsAction { void Run(mitk::SemanticRelations* semanticRelations, const mitk::DataStorage* dataStorage, const mitk::DataNode* dataNode) { if (nullptr == dataNode) { return; } if (mitk::NodePredicates::GetImagePredicate()->CheckNode(dataNode)) { AddImage(semanticRelations, dataNode); } else if (mitk::NodePredicates::GetSegmentationPredicate()->CheckNode(dataNode)) { AddSegmentation(semanticRelations, dataStorage, dataNode); } } void AddImage(mitk::SemanticRelations* semanticRelations, const mitk::DataNode* image) { if (nullptr == image) { return; } try { // add the image to the semantic relations storage semanticRelations->AddImage(image); } catch (const mitk::SemanticRelationException& e) { std::stringstream exceptionMessage; exceptionMessage << e; QMessageBox msgBox; msgBox.setWindowTitle("Could not add the selected image."); msgBox.setText("The program wasn't able to correctly add the selected images.\n" "Reason:\n" + QString::fromStdString(exceptionMessage.str())); msgBox.setIcon(QMessageBox::Warning); msgBox.exec(); return; } } void AddSegmentation(mitk::SemanticRelations* semanticRelations, const mitk::DataStorage* dataStorage, const mitk::DataNode* segmentation) { if (nullptr == segmentation) { return; } mitk::BaseData* baseData = segmentation->GetData(); if (nullptr == baseData) { return; } // continue with valid segmentation data // get parent node of the current segmentation node with the node predicate mitk::DataStorage::SetOfObjects::ConstPointer parentNodes = dataStorage->GetSources(segmentation, mitk::NodePredicates::GetImagePredicate(), false); // check for already existing, identifying base properties mitk::BaseProperty* caseIDProperty = baseData->GetProperty("DICOM.0010.0010"); mitk::BaseProperty* nodeIDProperty = baseData->GetProperty("DICOM.0020.000E"); if (nullptr == caseIDProperty || nullptr == nodeIDProperty) { MITK_INFO << "No DICOM tags for case and node identification found. Transferring DICOM tags from the parent node to the selected segmentation node."; mitk::SemanticTypes::CaseID caseID = mitk::GetCaseIDFromDataNode(parentNodes->front()); mitk::SemanticTypes::ID nodeID = mitk::GetIDFromDataNode(parentNodes->front()); // transfer DICOM tags to the segmentation node mitk::StringProperty::Pointer caseIDTag = mitk::StringProperty::New(caseID); baseData->SetProperty("DICOM.0010.0010", caseIDTag); // DICOM tag is "PatientName" // add UID to distinguish between different segmentations of the same parent node mitk::StringProperty::Pointer nodeIDTag = mitk::StringProperty::New(nodeID + mitk::UIDGeneratorBoost::GenerateUID()); baseData->SetProperty("DICOM.0020.000E", nodeIDTag); // DICOM tag is "SeriesInstanceUID" } try { semanticRelations->AddSegmentation(segmentation, parentNodes->front()); } catch (const mitk::SemanticRelationException& e) { std::stringstream exceptionMessage; exceptionMessage << e; QMessageBox msgBox; msgBox.setWindowTitle("Could not add the selected segmentation."); msgBox.setText("The program wasn't able to correctly add the selected segmentation.\n" "Reason:\n" + QString::fromStdString(exceptionMessage.str())); msgBox.setIcon(QMessageBox::Warning); msgBox.exec(); return; } } } QmitkDataNodeAddToSemanticRelationsAction::QmitkDataNodeAddToSemanticRelationsAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchPartSite) : QAction(parent) - , m_WorkbenchPartSite(workbenchPartSite) + , QmitkAbstractDataNodeAction(workbenchPartSite) { setText(tr("Add to semantic relations")); InitializeAction(); } QmitkDataNodeAddToSemanticRelationsAction::QmitkDataNodeAddToSemanticRelationsAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchPartSite) : QAction(parent) - , m_WorkbenchPartSite(berry::IWorkbenchPartSite::Pointer(workbenchPartSite)) + , QmitkAbstractDataNodeAction(berry::IWorkbenchPartSite::Pointer(workbenchPartSite)) { setText(tr("Add to semantic relations")); InitializeAction(); } QmitkDataNodeAddToSemanticRelationsAction::~QmitkDataNodeAddToSemanticRelationsAction() { // nothing here } void QmitkDataNodeAddToSemanticRelationsAction::SetDataStorage(mitk::DataStorage* dataStorage) { if (m_DataStorage != dataStorage) { // set the new data storage m_DataStorage = dataStorage; m_SemanticRelations = std::make_unique(m_DataStorage.Lock()); } } void QmitkDataNodeAddToSemanticRelationsAction::InitializeAction() { connect(this, &QAction::triggered, this, &QmitkDataNodeAddToSemanticRelationsAction::OnActionTriggered); } void QmitkDataNodeAddToSemanticRelationsAction::OnActionTriggered(bool checked) { if (nullptr == m_SemanticRelations) { return; } if (m_DataStorage.IsExpired()) { return; } auto dataNode = GetSelectedNode(); AddToSemanticRelationsAction::Run(m_SemanticRelations.get(), m_DataStorage.Lock(), dataNode); } - -QList QmitkDataNodeAddToSemanticRelationsAction::GetSelectedNodes() -{ - QList selectedNodes; - if (m_WorkbenchPartSite.Expired()) - { - return selectedNodes; - } - - berry::ISelection::ConstPointer selection = m_WorkbenchPartSite.Lock()->GetWorkbenchWindow()->GetSelectionService()->GetSelection(); - mitk::DataNodeSelection::ConstPointer currentSelection = selection.Cast(); - - if (currentSelection.IsNull() || currentSelection->IsEmpty()) - { - return selectedNodes; - } - - selectedNodes = QList::fromStdList(currentSelection->GetSelectedDataNodes()); - return selectedNodes; -} - -mitk::DataNode::Pointer QmitkDataNodeAddToSemanticRelationsAction::GetSelectedNode() -{ - 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; -} \ No newline at end of file diff --git a/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeAddToSemanticRelationsAction.h b/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeAddToSemanticRelationsAction.h index 34cfaca946..99d8de0865 100644 --- a/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeAddToSemanticRelationsAction.h +++ b/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeAddToSemanticRelationsAction.h @@ -1,73 +1,64 @@ /*=================================================================== 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 QMITKDATANODEADDTOSEMANTICRELATIONSACTION_H #define QMITKDATANODEADDTOSEMANTICRELATIONSACTION_H #include -// mitk core -#include -#include -#include - // semantic relations module #include -// berry -#include +// mitk gui qt application plugin +#include // qt #include namespace AddToSemanticRelationsAction { MITK_GUI_SEMANTICRELATIONS_EXPORT void Run(mitk::SemanticRelations* semanticRelations, const mitk::DataStorage* dataStorage, const mitk::DataNode* image); void AddImage(mitk::SemanticRelations* semanticRelations, const mitk::DataNode* image); void AddSegmentation(mitk::SemanticRelations* semanticRelations, const mitk::DataStorage* dataStorage, const mitk::DataNode* segmentation); } -class MITK_GUI_SEMANTICRELATIONS_EXPORT QmitkDataNodeAddToSemanticRelationsAction : public QAction +class MITK_GUI_SEMANTICRELATIONS_EXPORT QmitkDataNodeAddToSemanticRelationsAction : public QAction, public QmitkAbstractDataNodeAction { Q_OBJECT public: QmitkDataNodeAddToSemanticRelationsAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchPartSite); QmitkDataNodeAddToSemanticRelationsAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchPartSite); virtual ~QmitkDataNodeAddToSemanticRelationsAction() override; void SetDataStorage(mitk::DataStorage* dataStorage); private Q_SLOTS: void OnActionTriggered(bool); protected: - void InitializeAction(); - - QList GetSelectedNodes(); - mitk::DataNode::Pointer GetSelectedNode(); + virtual void InitializeAction() override; - berry::IWorkbenchPartSite::WeakPtr m_WorkbenchPartSite; - mitk::WeakPointer m_DataStorage; std::unique_ptr m_SemanticRelations; + }; #endif // QMITKDATANODEADDTOSEMANTICRELATIONSACTION_H diff --git a/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeInformationTypeAction.cpp b/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeInformationTypeAction.cpp deleted file mode 100644 index 1babe59b68..0000000000 --- a/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeInformationTypeAction.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/*=================================================================== - -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. - -===================================================================*/ - -// semantic relations plugin -#include "QmitkDataNodeInformationTypeAction.h" - -// semantic relations module -#include - -// mitk gui common plugin -#include - -// berry -#include -#include - -// qt -#include - -QmitkDataNodeInformationTypeAction::QmitkDataNodeInformationTypeAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchPartSite) - : QAction(parent) - , m_WorkbenchPartSite(workbenchPartSite) -{ - setText(tr("Set information type")); - m_Parent = parent; - InitializeAction(); -} - -QmitkDataNodeInformationTypeAction::QmitkDataNodeInformationTypeAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchPartSite) - : QAction(parent) - , m_WorkbenchPartSite(berry::IWorkbenchPartSite::Pointer(workbenchPartSite)) -{ - setText(tr("Set information type")); - m_Parent = parent; - InitializeAction(); -} - -QmitkDataNodeInformationTypeAction::~QmitkDataNodeInformationTypeAction() -{ - // nothing here -} - -void QmitkDataNodeInformationTypeAction::SetDataStorage(mitk::DataStorage* dataStorage) -{ - if (m_DataStorage != dataStorage) - { - // set the new data storage - m_DataStorage = dataStorage; - m_SemanticRelations = std::make_unique(m_DataStorage.Lock()); - } -} - -void QmitkDataNodeInformationTypeAction::InitializeAction() -{ - connect(this, &QAction::triggered, this, &QmitkDataNodeInformationTypeAction::OnActionTriggered); -} - -void QmitkDataNodeInformationTypeAction::OnActionTriggered(bool checked) -{ - if (nullptr == m_SemanticRelations) - { - return; - } - - auto dataNode = GetSelectedNode(); - if (dataNode.IsNull()) - { - return; - } - - QInputDialog* inputDialog = new QInputDialog(m_Parent); - inputDialog->setWindowTitle(tr("Set information type of selected node")); - inputDialog->setLabelText(tr("Information type:")); - inputDialog->setTextValue(QString::fromStdString(m_SemanticRelations->GetInformationTypeOfImage(dataNode))); - inputDialog->setMinimumSize(250, 100); - - int dialogReturnValue = inputDialog->exec(); - if (QDialog::Rejected == dialogReturnValue) - { - return; - } - - try - { - m_SemanticRelations->SetInformationType(dataNode, inputDialog->textValue().toStdString()); - } - catch (const mitk::SemanticRelationException&) - { - return; - } -} - -QList QmitkDataNodeInformationTypeAction::GetSelectedNodes() -{ - QList selectedNodes; - if (m_WorkbenchPartSite.Expired()) - { - return selectedNodes; - } - - berry::ISelection::ConstPointer selection = m_WorkbenchPartSite.Lock()->GetWorkbenchWindow()->GetSelectionService()->GetSelection(); - mitk::DataNodeSelection::ConstPointer currentSelection = selection.Cast(); - - if (currentSelection.IsNull() || currentSelection->IsEmpty()) - { - return selectedNodes; - } - - selectedNodes = QList::fromStdList(currentSelection->GetSelectedDataNodes()); - return selectedNodes; -} - -mitk::DataNode::Pointer QmitkDataNodeInformationTypeAction::GetSelectedNode() -{ - 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.semanticrelations/src/internal/QmitkDataNodeInformationTypeAction.h b/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeInformationTypeAction.h deleted file mode 100644 index 5985bf5ee3..0000000000 --- a/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeInformationTypeAction.h +++ /dev/null @@ -1,64 +0,0 @@ -/*=================================================================== - -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 QMITKDATANODEINFORMATIONTYPEACTION_H -#define QMITKDATANODEINFORMATIONTYPEACTION_H - -// mitk core -#include -#include -#include - -// semantic relations module -#include - -// berry -#include - -// qt -#include - -class QmitkDataNodeInformationTypeAction : public QAction -{ - Q_OBJECT - -public: - - QmitkDataNodeInformationTypeAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchPartSite); - QmitkDataNodeInformationTypeAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchPartSite); - - virtual ~QmitkDataNodeInformationTypeAction() override; - - void SetDataStorage(mitk::DataStorage* dataStorage); - -private Q_SLOTS: - - void OnActionTriggered(bool); - -protected: - - void InitializeAction(); - - QList GetSelectedNodes(); - mitk::DataNode::Pointer GetSelectedNode(); - - QWidget* m_Parent; - berry::IWorkbenchPartSite::WeakPtr m_WorkbenchPartSite; - mitk::WeakPointer m_DataStorage; - std::unique_ptr m_SemanticRelations; -}; - -#endif // QMITKDATANODEINFORMATIONTYPEACTION_H diff --git a/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeRemoveFromSemanticRelationsAction.cpp b/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeRemoveFromSemanticRelationsAction.cpp index 5233610e9f..4216e9f854 100644 --- a/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeRemoveFromSemanticRelationsAction.cpp +++ b/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeRemoveFromSemanticRelationsAction.cpp @@ -1,188 +1,146 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ // semantic relations plugin #include "QmitkDataNodeRemoveFromSemanticRelationsAction.h" // semantic relations module #include #include #include // mitk gui common plugin #include -// berry -#include -#include - // qt #include // namespace that contains the concrete action namespace RemoveFromSemanticRelationsAction { void Run(mitk::SemanticRelations* semanticRelations, const mitk::DataNode* dataNode) { if (nullptr == dataNode) { return; } if (mitk::NodePredicates::GetImagePredicate()->CheckNode(dataNode)) { RemoveImage(semanticRelations, dataNode); } else if (mitk::NodePredicates::GetSegmentationPredicate()->CheckNode(dataNode)) { RemoveSegmentation(semanticRelations, dataNode); } } void RemoveImage(mitk::SemanticRelations* semanticRelations, const mitk::DataNode* image) { if (nullptr == image) { return; } try { // remove the image from the semantic relations storage semanticRelations->RemoveImage(image); } catch (const mitk::SemanticRelationException& e) { std::stringstream exceptionMessage; exceptionMessage << e; QMessageBox msgBox; msgBox.setWindowTitle("Could not remove the selected image."); msgBox.setText("The program wasn't able to correctly remove the selected image.\n" "Reason:\n" + QString::fromStdString(exceptionMessage.str())); msgBox.setIcon(QMessageBox::Warning); msgBox.exec(); return; } } void RemoveSegmentation(mitk::SemanticRelations* semanticRelations, const mitk::DataNode* segmentation) { if (nullptr == segmentation) { return; } try { semanticRelations->RemoveSegmentation(segmentation); } catch (const mitk::SemanticRelationException& e) { std::stringstream exceptionMessage; exceptionMessage << e; QMessageBox msgBox; msgBox.setWindowTitle("Could not remove the selected segmentation."); msgBox.setText("The program wasn't able to correctly remove the selected segmentation.\n" "Reason:\n" + QString::fromStdString(exceptionMessage.str())); msgBox.setIcon(QMessageBox::Warning); msgBox.exec(); return; } } } QmitkDataNodeRemoveFromSemanticRelationsAction::QmitkDataNodeRemoveFromSemanticRelationsAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchPartSite) : QAction(parent) - , m_WorkbenchPartSite(workbenchPartSite) + , QmitkAbstractDataNodeAction(workbenchPartSite) { setText(tr("Remove from semantic relations")); InitializeAction(); } QmitkDataNodeRemoveFromSemanticRelationsAction::QmitkDataNodeRemoveFromSemanticRelationsAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchPartSite) : QAction(parent) - , m_WorkbenchPartSite(berry::IWorkbenchPartSite::Pointer(workbenchPartSite)) + , QmitkAbstractDataNodeAction(berry::IWorkbenchPartSite::Pointer(workbenchPartSite)) { setText(tr("Remove from semantic relations")); InitializeAction(); } QmitkDataNodeRemoveFromSemanticRelationsAction::~QmitkDataNodeRemoveFromSemanticRelationsAction() { // nothing here } void QmitkDataNodeRemoveFromSemanticRelationsAction::SetDataStorage(mitk::DataStorage* dataStorage) { if (m_DataStorage != dataStorage) { // set the new data storage m_DataStorage = dataStorage; m_SemanticRelations = std::make_unique(m_DataStorage.Lock()); } } void QmitkDataNodeRemoveFromSemanticRelationsAction::InitializeAction() { connect(this, &QAction::triggered, this, &QmitkDataNodeRemoveFromSemanticRelationsAction::OnActionTriggered); } void QmitkDataNodeRemoveFromSemanticRelationsAction::OnActionTriggered(bool checked) { if (nullptr == m_SemanticRelations) { return; } auto dataNode = GetSelectedNode(); RemoveFromSemanticRelationsAction::Run(m_SemanticRelations.get(), dataNode); } - -QList QmitkDataNodeRemoveFromSemanticRelationsAction::GetSelectedNodes() -{ - QList selectedNodes; - if (m_WorkbenchPartSite.Expired()) - { - return selectedNodes; - } - - berry::ISelection::ConstPointer selection = m_WorkbenchPartSite.Lock()->GetWorkbenchWindow()->GetSelectionService()->GetSelection(); - mitk::DataNodeSelection::ConstPointer currentSelection = selection.Cast(); - - if (currentSelection.IsNull() || currentSelection->IsEmpty()) - { - return selectedNodes; - } - - selectedNodes = QList::fromStdList(currentSelection->GetSelectedDataNodes()); - return selectedNodes; -} - -mitk::DataNode::Pointer QmitkDataNodeRemoveFromSemanticRelationsAction::GetSelectedNode() -{ - 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.semanticrelations/src/internal/QmitkDataNodeRemoveFromSemanticRelationsAction.h b/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeRemoveFromSemanticRelationsAction.h index eaa4bd2977..198e2bb53f 100644 --- a/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeRemoveFromSemanticRelationsAction.h +++ b/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeRemoveFromSemanticRelationsAction.h @@ -1,73 +1,64 @@ /*=================================================================== 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 QMITKDATANODEREMOVEFROMSEMANTICRELATIONSACTION_H #define QMITKDATANODEREMOVEFROMSEMANTICRELATIONSACTION_H #include -// mitk core -#include -#include -#include - // semantic relations module #include -// berry -#include +// mitk gui qt application plugin +#include // qt #include namespace RemoveFromSemanticRelationsAction { MITK_GUI_SEMANTICRELATIONS_EXPORT void Run(mitk::SemanticRelations* semanticRelations, const mitk::DataNode* dataNode); void RemoveImage(mitk::SemanticRelations* semanticRelations, const mitk::DataNode* image); void RemoveSegmentation(mitk::SemanticRelations* semanticRelations, const mitk::DataNode* segmentation); } -class MITK_GUI_SEMANTICRELATIONS_EXPORT QmitkDataNodeRemoveFromSemanticRelationsAction : public QAction +class MITK_GUI_SEMANTICRELATIONS_EXPORT QmitkDataNodeRemoveFromSemanticRelationsAction : public QAction, public QmitkAbstractDataNodeAction { Q_OBJECT public: QmitkDataNodeRemoveFromSemanticRelationsAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchPartSite); QmitkDataNodeRemoveFromSemanticRelationsAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchPartSite); virtual ~QmitkDataNodeRemoveFromSemanticRelationsAction() override; void SetDataStorage(mitk::DataStorage* dataStorage); private Q_SLOTS: void OnActionTriggered(bool); protected: - void InitializeAction(); - - QList GetSelectedNodes(); - mitk::DataNode::Pointer GetSelectedNode(); + virtual void InitializeAction() override; - berry::IWorkbenchPartSite::WeakPtr m_WorkbenchPartSite; - mitk::WeakPointer m_DataStorage; std::unique_ptr m_SemanticRelations; + }; #endif // QMITKDATANODEREMOVEFROMSEMANTICRELATIONSACTION_H diff --git a/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeSetControlPointAction.cpp b/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeSetControlPointAction.cpp index a615cc6048..c9c1a68f59 100644 --- a/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeSetControlPointAction.cpp +++ b/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeSetControlPointAction.cpp @@ -1,153 +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. ===================================================================*/ // semantic relations plugin #include "QmitkDataNodeSetControlPointAction.h" // semantic relations module #include #include #include // semantic relations UI module #include "QmitkControlPointDialog.h" // mitk gui common plugin #include -// berry -#include -#include - // qt #include QmitkDataNodeSetControlPointAction::QmitkDataNodeSetControlPointAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchPartSite) : QAction(parent) - , m_WorkbenchPartSite(workbenchPartSite) + , QmitkAbstractDataNodeAction(workbenchPartSite) { setText(tr("Set control point")); m_Parent = parent; InitializeAction(); } QmitkDataNodeSetControlPointAction::QmitkDataNodeSetControlPointAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchPartSite) : QAction(parent) - , m_WorkbenchPartSite(berry::IWorkbenchPartSite::Pointer(workbenchPartSite)) + , QmitkAbstractDataNodeAction(berry::IWorkbenchPartSite::Pointer(workbenchPartSite)) { setText(tr("Set control point")); m_Parent = parent; InitializeAction(); } QmitkDataNodeSetControlPointAction::~QmitkDataNodeSetControlPointAction() { // nothing here } void QmitkDataNodeSetControlPointAction::SetDataStorage(mitk::DataStorage* dataStorage) { if (m_DataStorage != dataStorage) { // set the new data storage m_DataStorage = dataStorage; m_SemanticRelations = std::make_unique(m_DataStorage.Lock()); } } void QmitkDataNodeSetControlPointAction::InitializeAction() { connect(this, &QAction::triggered, this, &QmitkDataNodeSetControlPointAction::OnActionTriggered); } void QmitkDataNodeSetControlPointAction::OnActionTriggered(bool checked) { if (nullptr == m_SemanticRelations) { return; } auto dataNode = GetSelectedNode(); if (dataNode.IsNull()) { return; } QmitkControlPointDialog* inputDialog = new QmitkControlPointDialog(m_Parent); inputDialog->setWindowTitle("Set control point"); inputDialog->SetCurrentDate(m_SemanticRelations->GetControlPointOfData(dataNode)); int dialogReturnValue = inputDialog->exec(); if (QDialog::Rejected == dialogReturnValue) { return; } const QDate& userSelectedDate = inputDialog->GetCurrentDate(); mitk::SemanticTypes::ControlPoint controlPoint; controlPoint.UID = mitk::UIDGeneratorBoost::GenerateUID(); controlPoint.date = boost::gregorian::date(userSelectedDate.year(), userSelectedDate.month(), userSelectedDate.day()); try { m_SemanticRelations->UnlinkDataFromControlPoint(dataNode); m_SemanticRelations->SetControlPointOfData(dataNode, controlPoint); } catch (const mitk::SemanticRelationException&) { return; } } - -QList QmitkDataNodeSetControlPointAction::GetSelectedNodes() -{ - QList selectedNodes; - if (m_WorkbenchPartSite.Expired()) - { - return selectedNodes; - } - - berry::ISelection::ConstPointer selection = m_WorkbenchPartSite.Lock()->GetWorkbenchWindow()->GetSelectionService()->GetSelection(); - mitk::DataNodeSelection::ConstPointer currentSelection = selection.Cast(); - - if (currentSelection.IsNull() || currentSelection->IsEmpty()) - { - return selectedNodes; - } - - selectedNodes = QList::fromStdList(currentSelection->GetSelectedDataNodes()); - return selectedNodes; -} - -mitk::DataNode::Pointer QmitkDataNodeSetControlPointAction::GetSelectedNode() -{ - 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.semanticrelations/src/internal/QmitkDataNodeSetControlPointAction.h b/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeSetControlPointAction.h index a948081620..a96ae08754 100644 --- a/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeSetControlPointAction.h +++ b/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeSetControlPointAction.h @@ -1,64 +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 QMITKDATANODECONTROLPOINTEACTION_H -#define QMITKDATANODECONTROLPOINTEACTION_H - -// mitk core -#include -#include -#include +#ifndef QMITKDATANODESETCONTROLPOINTEACTION_H +#define QMITKDATANODESETCONTROLPOINTEACTION_H // semantic relations module #include -// berry -#include +// mitk gui qt application plugin +#include // qt #include -class QmitkDataNodeSetControlPointAction : public QAction +class QmitkDataNodeSetControlPointAction : public QAction, public QmitkAbstractDataNodeAction { Q_OBJECT public: QmitkDataNodeSetControlPointAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchPartSite); QmitkDataNodeSetControlPointAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchPartSite); virtual ~QmitkDataNodeSetControlPointAction() override; void SetDataStorage(mitk::DataStorage* dataStorage); private Q_SLOTS: void OnActionTriggered(bool); protected: - void InitializeAction(); - - QList GetSelectedNodes(); - mitk::DataNode::Pointer GetSelectedNode(); + virtual void InitializeAction() override; - QWidget* m_Parent; - berry::IWorkbenchPartSite::WeakPtr m_WorkbenchPartSite; - mitk::WeakPointer m_DataStorage; + QWidget *m_Parent; std::unique_ptr m_SemanticRelations; + }; -#endif // QMITKDATANODECONTROLPOINTEACTION_H +#endif // QMITKDATANODESETCONTROLPOINTEACTION_H diff --git a/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeSetInformationTypeAction.cpp b/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeSetInformationTypeAction.cpp new file mode 100644 index 0000000000..851db448db --- /dev/null +++ b/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeSetInformationTypeAction.cpp @@ -0,0 +1,100 @@ +/*=================================================================== + +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. + +===================================================================*/ + +// semantic relations plugin +#include "QmitkDataNodeSetInformationTypeAction.h" + +// semantic relations module +#include + +// mitk gui common plugin +#include + +// qt +#include + +QmitkDataNodeSetInformationTypeAction::QmitkDataNodeSetInformationTypeAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchPartSite) + : QAction(parent) + , QmitkAbstractDataNodeAction(workbenchPartSite) +{ + setText(tr("Set information type")); + m_Parent = parent; + InitializeAction(); +} + +QmitkDataNodeSetInformationTypeAction::QmitkDataNodeSetInformationTypeAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchPartSite) + : QAction(parent) + , QmitkAbstractDataNodeAction(berry::IWorkbenchPartSite::Pointer(workbenchPartSite)) +{ + setText(tr("Set information type")); + m_Parent = parent; + InitializeAction(); +} + +QmitkDataNodeSetInformationTypeAction::~QmitkDataNodeSetInformationTypeAction() +{ + // nothing here +} + +void QmitkDataNodeSetInformationTypeAction::SetDataStorage(mitk::DataStorage* dataStorage) +{ + if (m_DataStorage != dataStorage) + { + // set the new data storage + m_DataStorage = dataStorage; + m_SemanticRelations = std::make_unique(m_DataStorage.Lock()); + } +} + +void QmitkDataNodeSetInformationTypeAction::InitializeAction() +{ + connect(this, &QAction::triggered, this, &QmitkDataNodeSetInformationTypeAction::OnActionTriggered); +} + +void QmitkDataNodeSetInformationTypeAction::OnActionTriggered(bool checked) +{ + if (nullptr == m_SemanticRelations) + { + return; + } + + auto dataNode = GetSelectedNode(); + if (dataNode.IsNull()) + { + return; + } + + QInputDialog* inputDialog = new QInputDialog(m_Parent); + inputDialog->setWindowTitle(tr("Set information type of selected node")); + inputDialog->setLabelText(tr("Information type:")); + inputDialog->setTextValue(QString::fromStdString(m_SemanticRelations->GetInformationTypeOfImage(dataNode))); + inputDialog->setMinimumSize(250, 100); + + int dialogReturnValue = inputDialog->exec(); + if (QDialog::Rejected == dialogReturnValue) + { + return; + } + + try + { + m_SemanticRelations->SetInformationType(dataNode, inputDialog->textValue().toStdString()); + } + catch (const mitk::SemanticRelationException&) + { + return; + } +} diff --git a/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeSetInformationTypeAction.h b/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeSetInformationTypeAction.h new file mode 100644 index 0000000000..9df500d04c --- /dev/null +++ b/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeSetInformationTypeAction.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 QMITKDATANODESETINFORMATIONTYPEACTION_H +#define QMITKDATANODESETINFORMATIONTYPEACTION_H + +// semantic relations module +#include + +// mitk gui qt application plugin +#include + +// qt +#include + +class QmitkDataNodeSetInformationTypeAction : public QAction, public QmitkAbstractDataNodeAction +{ + Q_OBJECT + +public: + + QmitkDataNodeSetInformationTypeAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchPartSite); + QmitkDataNodeSetInformationTypeAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchPartSite); + + virtual ~QmitkDataNodeSetInformationTypeAction() override; + + void SetDataStorage(mitk::DataStorage* dataStorage); + +private Q_SLOTS: + + void OnActionTriggered(bool); + +protected: + + virtual void InitializeAction() override; + + QWidget* m_Parent; + std::unique_ptr m_SemanticRelations; + +}; + +#endif // QMITKDATANODESETINFORMATIONTYPEACTION_H diff --git a/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeUnlinkFromLesionAction.cpp b/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeUnlinkFromLesionAction.cpp index 0e4078d242..95985d8877 100644 --- a/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeUnlinkFromLesionAction.cpp +++ b/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeUnlinkFromLesionAction.cpp @@ -1,168 +1,126 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ // semantic relations plugin #include "QmitkDataNodeUnlinkFromLesionAction.h" // semantic relations module #include #include #include // mitk gui common plugin #include -// berry -#include -#include - // qt #include // namespace that contains the concrete action namespace UnlinkFromLesionAction { void Run(mitk::SemanticRelations* semanticRelations, const mitk::DataNode* dataNode) { if (nullptr == dataNode) { return; } if (mitk::NodePredicates::GetSegmentationPredicate()->CheckNode(dataNode)) { UnlinkSegmentation(semanticRelations, dataNode); } else { QMessageBox msgBox; msgBox.setWindowTitle("Could not unlink the selected data node."); msgBox.setText("Please chose a valid segmentation to unlink from its represented lesion!"); msgBox.setIcon(QMessageBox::Warning); msgBox.exec(); return; } } void UnlinkSegmentation(mitk::SemanticRelations* semanticRelations, const mitk::DataNode* segmentation) { if (nullptr == segmentation) { return; } try { semanticRelations->UnlinkSegmentationFromLesion(segmentation); } catch (const mitk::SemanticRelationException& e) { std::stringstream exceptionMessage; exceptionMessage << e; QMessageBox msgBox; msgBox.setWindowTitle("Could not unlink the selected segmentation."); msgBox.setText("The program wasn't able to correctly unlink the selected segmentation.\n" "Reason:\n" + QString::fromStdString(exceptionMessage.str())); msgBox.setIcon(QMessageBox::Warning); msgBox.exec(); return; } } } QmitkDataNodeUnlinkFromLesionAction::QmitkDataNodeUnlinkFromLesionAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchPartSite) : QAction(parent) - , m_WorkbenchPartSite(workbenchPartSite) + , QmitkAbstractDataNodeAction(workbenchPartSite) { setText(tr("Unlink from lesion")); InitializeAction(); } QmitkDataNodeUnlinkFromLesionAction::QmitkDataNodeUnlinkFromLesionAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchPartSite) : QAction(parent) - , m_WorkbenchPartSite(berry::IWorkbenchPartSite::Pointer(workbenchPartSite)) + , QmitkAbstractDataNodeAction(berry::IWorkbenchPartSite::Pointer(workbenchPartSite)) { setText(tr("Unlink from lesion")); InitializeAction(); } QmitkDataNodeUnlinkFromLesionAction::~QmitkDataNodeUnlinkFromLesionAction() { // nothing here } void QmitkDataNodeUnlinkFromLesionAction::SetDataStorage(mitk::DataStorage* dataStorage) { if (m_DataStorage != dataStorage) { // set the new data storage m_DataStorage = dataStorage; m_SemanticRelations = std::make_unique(m_DataStorage.Lock()); } } void QmitkDataNodeUnlinkFromLesionAction::InitializeAction() { connect(this, &QAction::triggered, this, &QmitkDataNodeUnlinkFromLesionAction::OnActionTriggered); } void QmitkDataNodeUnlinkFromLesionAction::OnActionTriggered(bool checked) { if (nullptr == m_SemanticRelations) { return; } auto dataNode = GetSelectedNode(); UnlinkFromLesionAction::Run(m_SemanticRelations.get(), dataNode); } - -QList QmitkDataNodeUnlinkFromLesionAction::GetSelectedNodes() -{ - QList selectedNodes; - if (m_WorkbenchPartSite.Expired()) - { - return selectedNodes; - } - - berry::ISelection::ConstPointer selection = m_WorkbenchPartSite.Lock()->GetWorkbenchWindow()->GetSelectionService()->GetSelection(); - mitk::DataNodeSelection::ConstPointer currentSelection = selection.Cast(); - - if (currentSelection.IsNull() || currentSelection->IsEmpty()) - { - return selectedNodes; - } - - selectedNodes = QList::fromStdList(currentSelection->GetSelectedDataNodes()); - return selectedNodes; -} - -mitk::DataNode::Pointer QmitkDataNodeUnlinkFromLesionAction::GetSelectedNode() -{ - 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.semanticrelations/src/internal/QmitkDataNodeUnlinkFromLesionAction.h b/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeUnlinkFromLesionAction.h index 4702248a80..784816ec3b 100644 --- a/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeUnlinkFromLesionAction.h +++ b/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkDataNodeUnlinkFromLesionAction.h @@ -1,72 +1,63 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKDATANODEUNLINKFROMLESIONACTION_H #define QMITKDATANODEUNLINKFROMLESIONACTION_H #include -// mitk core -#include -#include -#include - // semantic relations module #include -// berry -#include +// mitk gui qt application plugin +#include // qt #include namespace UnlinkFromLesionAction { MITK_GUI_SEMANTICRELATIONS_EXPORT void Run(mitk::SemanticRelations* semanticRelations, const mitk::DataStorage* dataStorage, const mitk::DataNode* dataNode); void UnlinkSegmentation(mitk::SemanticRelations* semanticRelations, const mitk::DataNode* segmentation); } -class MITK_GUI_SEMANTICRELATIONS_EXPORT QmitkDataNodeUnlinkFromLesionAction : public QAction +class MITK_GUI_SEMANTICRELATIONS_EXPORT QmitkDataNodeUnlinkFromLesionAction : public QAction, public QmitkAbstractDataNodeAction { Q_OBJECT public: QmitkDataNodeUnlinkFromLesionAction(QWidget* parent, berry::IWorkbenchPartSite::Pointer workbenchPartSite); QmitkDataNodeUnlinkFromLesionAction(QWidget* parent, berry::IWorkbenchPartSite* workbenchPartSite); virtual ~QmitkDataNodeUnlinkFromLesionAction() override; void SetDataStorage(mitk::DataStorage* dataStorage); private Q_SLOTS: void OnActionTriggered(bool); protected: - void InitializeAction(); - - QList GetSelectedNodes(); - mitk::DataNode::Pointer GetSelectedNode(); + virtual void InitializeAction() override; - berry::IWorkbenchPartSite::WeakPtr m_WorkbenchPartSite; - mitk::WeakPointer m_DataStorage; std::unique_ptr m_SemanticRelations; + }; #endif // QMITKDATANODEUNLINKFROMLESIONACTION_H diff --git a/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkSemanticRelationsContextMenu.cpp b/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkSemanticRelationsContextMenu.cpp index c92093ad3b..6e64071913 100644 --- a/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkSemanticRelationsContextMenu.cpp +++ b/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkSemanticRelationsContextMenu.cpp @@ -1,78 +1,77 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ // semantic relations plugin #include "QmitkSemanticRelationsContextMenu.h" QmitkSemanticRelationsContextMenu::QmitkSemanticRelationsContextMenu(berry::IWorkbenchPartSite::Pointer workbenchPartSite, QWidget* parent) : QMenu(parent) + , m_Parent(parent) + , m_WorkbenchPartSite(workbenchPartSite) { - m_WorkbenchPartSite = workbenchPartSite; - m_Parent = parent; - InitDefaultActions(); } QmitkSemanticRelationsContextMenu::~QmitkSemanticRelationsContextMenu() { // nothing here } void QmitkSemanticRelationsContextMenu::SetDataStorage(mitk::DataStorage* dataStorage) { if (m_DataStorage != dataStorage) { // set the new data storage - also for all actions m_DataStorage = dataStorage; m_ControlPointAction->SetDataStorage(m_DataStorage.Lock()); m_InformationTypeAction->SetDataStorage(m_DataStorage.Lock()); m_RemoveFromSemanticRelationsAction->SetDataStorage(m_DataStorage.Lock()); m_UnlinkFromLesionAction->SetDataStorage(m_DataStorage.Lock()); } } void QmitkSemanticRelationsContextMenu::SetControlledRenderer(RenderWindowLayerUtilities::RendererVector controlledRenderer) { if (m_ControlledRenderer != controlledRenderer) { // set the new set of controlled renderer m_ControlledRenderer = controlledRenderer; m_OpenInAction->SetControlledRenderer(m_ControlledRenderer); } } void QmitkSemanticRelationsContextMenu::OnContextMenuRequested(const QPoint& /*pos*/) { popup(QCursor::pos()); } void QmitkSemanticRelationsContextMenu::InitDefaultActions() { m_ControlPointAction = new QmitkDataNodeSetControlPointAction(m_Parent, m_WorkbenchPartSite.Lock()); addAction(m_ControlPointAction); - m_InformationTypeAction = new QmitkDataNodeInformationTypeAction(m_Parent, m_WorkbenchPartSite.Lock()); + m_InformationTypeAction = new QmitkDataNodeSetInformationTypeAction(m_Parent, m_WorkbenchPartSite.Lock()); addAction(m_InformationTypeAction); m_UnlinkFromLesionAction = new QmitkDataNodeUnlinkFromLesionAction(m_Parent, m_WorkbenchPartSite.Lock()); addAction(m_UnlinkFromLesionAction); m_RemoveFromSemanticRelationsAction = new QmitkDataNodeRemoveFromSemanticRelationsAction(m_Parent, m_WorkbenchPartSite.Lock()); addAction(m_RemoveFromSemanticRelationsAction); m_OpenInAction = new QmitkDataNodeOpenInAction(m_Parent, m_WorkbenchPartSite.Lock()); addAction(m_OpenInAction); } diff --git a/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkSemanticRelationsContextMenu.h b/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkSemanticRelationsContextMenu.h index fb94cef562..73daef38ff 100644 --- a/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkSemanticRelationsContextMenu.h +++ b/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkSemanticRelationsContextMenu.h @@ -1,73 +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 QMITKSEMANTICRELATIONSCONTEXTMENU_H #define QMITKSEMANTICRELATIONSCONTEXTMENU_H // semantic relations plugin #include "QmitkDataNodeSetControlPointAction.h" -#include "QmitkDataNodeInformationTypeAction.h" +#include "QmitkDataNodeSetInformationTypeAction.h" #include "QmitkDataNodeUnlinkFromLesionAction.h" #include "QmitkDataNodeRemoveFromSemanticRelationsAction.h" -#include "QmitkDataNodeOpenInAction.h" // mitk core #include #include // mitk render window manager module #include +// mitk gui qt application plugin +#include + // blueberry ui qt plugin #include //qt #include class QmitkSemanticRelationsContextMenu : public QMenu { Q_OBJECT public: QmitkSemanticRelationsContextMenu(berry::IWorkbenchPartSite::Pointer workbenchPartSite, QWidget* parent = nullptr); virtual ~QmitkSemanticRelationsContextMenu() override; void SetDataStorage(mitk::DataStorage* dataStorage); void SetControlledRenderer(RenderWindowLayerUtilities::RendererVector controlledRenderer); public Q_SLOTS: void OnContextMenuRequested(const QPoint&); private: void InitDefaultActions(); QWidget* m_Parent; berry::IWorkbenchPartSite::WeakPtr m_WorkbenchPartSite; mitk::WeakPointer m_DataStorage; RenderWindowLayerUtilities::RendererVector m_ControlledRenderer; QmitkDataNodeSetControlPointAction* m_ControlPointAction; - QmitkDataNodeInformationTypeAction* m_InformationTypeAction; + QmitkDataNodeSetInformationTypeAction* m_InformationTypeAction; QmitkDataNodeUnlinkFromLesionAction* m_UnlinkFromLesionAction; QmitkDataNodeRemoveFromSemanticRelationsAction* m_RemoveFromSemanticRelationsAction; QmitkDataNodeOpenInAction* m_OpenInAction; }; #endif // QMITKSEMANTICRELATIONSCONTEXTMENU_H