diff --git a/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkLesionInfoWidget.h b/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkLesionInfoWidget.h index 0a59e84375..01c80c3ba5 100644 --- a/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkLesionInfoWidget.h +++ b/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkLesionInfoWidget.h @@ -1,147 +1,151 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKLESIONINFOWIDGET_H #define QMITKLESIONINFOWIDGET_H // semantic relations UI module #include // semantic relations module #include #include // mitk #include // qt #include /* * @brief The QmitkLesionInfoWidget is a widget that shows and modifies the currently available lesion data of the semantic relations model. * * The widget provides a dialogs to add nodes from the data storage to the semantic relations model. * It provides functionality to create new lesions and link them with segmentation nodes. * * The QmitkLesionInfoWidget provides three QListWidgets, that show the lesion data and the referenced segmentation data, as * well as the connected image data, depending on the selected lesion. * * The QmitkLesionInfoWidget implements the 'ISemanticRelationsObserver', so that it is automatically updated, if the * semantic relations model changes. Updating means freshly getting all lesion data and filling the lesion-ListWidget with the lesion data. */ class QmitkLesionInfoWidget : public QWidget, public mitk::ISemanticRelationsObserver { Q_OBJECT public: static const QBrush DEFAULT_BACKGROUND_COLOR; static const QBrush SELECTED_BACKGROUND_COLOR; static const QBrush CONNECTED_BACKGROUND_COLOR; QmitkLesionInfoWidget::QmitkLesionInfoWidget(mitk::DataStorage* dataStorage, QWidget* parent = nullptr); ~QmitkLesionInfoWidget(); void SetCurrentCaseID(const mitk::SemanticTypes::CaseID& caseID); /* * @brief Updates the 'lesionListWidget' of the GUI with the current lesion-data from the semantic relations model. * * Overridden from 'ISemanticRelationsObserver'. * In order for Update-function to be called, this widget has to be added as a observer of SemanticRelation * (e.g. m_SemanticRelations->AddObserver(m_LesionInfoWidget);) * * @par caseID The current case ID to identify the currently active patient / case. */ virtual void Update(const mitk::SemanticTypes::CaseID& caseID) override; const mitk::SemanticTypes::Lesion& GetSelectedLesion() const { return m_CurrentLesion; } const mitk::DataNode* GetSelectedSegmentation() const { return m_CurrentSegmentation; } const mitk::DataNode* GetSelectedImage() const { return m_CurrentImage; } /* * @brief Resets all items from the lesion list widget. */ void ResetLesionListWidget(); /* * @brief Resets all items from the the segmentation list widget. */ void ResetSegmentationListWidget(); /* * @brief Resets all items from the the segmentation list widget. */ void ResetImageListWidget(); /* * @brief Resets the background color of all items in each list widget. */ void ResetBackgroundColors(); void DarkenBackgroundColors(); Q_SIGNALS: void JumpToPosition(const mitk::Point3D&); void ImageAdded(const mitk::SemanticTypes::CaseID&); void ImageRemoved(const mitk::DataNode*); private Q_SLOTS: /* * @brief Generates a new, empty lesion to add to the semantic relations model for the current case ID. */ void OnAddLesionButtonClicked(); void OnAddSegmentationButtonClicked(); void OnAddImageButtonClicked(); // slots for the mouse click events of the list widgets void OnCurrentLesionItemChanged(QListWidgetItem*, QListWidgetItem*); void OnLesionItemDoubleClicked(QListWidgetItem*); void OnCurrentSegmentationItemChanged(QListWidgetItem*, QListWidgetItem*); void OnSegmentationItemDoubleClicked(QListWidgetItem*); void OnCurrentImageItemChanged(QListWidgetItem*, QListWidgetItem*); void OnImageItemDoubleClicked(QListWidgetItem*); void OnLesionListContextMenuRequested(const QPoint&); void OnSegmentationListContextMenuRequested(const QPoint&); void OnImageListContextMenuRequested(const QPoint&); // slots for the context menu actions of the lesion list widget void OnLinkToSegmentation(const mitk::SemanticTypes::ID&); void OnSetLesionName(const mitk::SemanticTypes::ID&); void OnSetLesionClass(const mitk::SemanticTypes::ID&); void OnRemoveLesion(const mitk::SemanticTypes::ID&); // slots for the context menu actions of the segmentation list widget void OnUnlinkFromLesion(const mitk::DataNode*); - void OnRemoveSegmentation(const mitk::DataNode*); + - // slot for the context menu action of the image list widget +public Q_SLOTS: + + // slots for the context menu action of the image / segmentation list widget + // the slots are also used from the semantic relations view if a node in the data storage is removed + void OnRemoveSegmentation(const mitk::DataNode*); void OnRemoveImage(const mitk::DataNode*); private: void Init(); void SetUpConnections(); Ui::QmitkLesionInfoWidgetControls m_Controls; mitk::DataStorage* m_DataStorage; std::unique_ptr m_SemanticRelations; mitk::SemanticTypes::CaseID m_CaseID; mitk::SemanticTypes::Lesion m_CurrentLesion; mitk::DataNode::Pointer m_CurrentSegmentation; mitk::DataNode::Pointer m_CurrentImage; }; #endif // QMITKLESIONINFOWIDGET_H diff --git a/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkSemanticRelationsView.cpp b/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkSemanticRelationsView.cpp index 735b0f7441..dec945ae84 100644 --- a/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkSemanticRelationsView.cpp +++ b/Plugins/org.mitk.gui.qt.semanticrelations/src/internal/QmitkSemanticRelationsView.cpp @@ -1,105 +1,112 @@ /*=================================================================== 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 "QmitkSemanticRelationsView.h" #include "QmitkSemanticRelationsNodeSelectionDialog.h" // semantic relations module #include #include #include // blueberry #include #include // qt #include const std::string QmitkSemanticRelationsView::VIEW_ID = "org.mitk.views.semanticrelations"; void QmitkSemanticRelationsView::SetFocus() { // nothing here } void QmitkSemanticRelationsView::CreateQtPartControl(QWidget* parent) { // create GUI widgets m_Controls.setupUi(parent); // initialize the semantic relations m_SemanticRelations = std::make_unique(GetDataStorage()); m_LesionInfoWidget = new QmitkLesionInfoWidget(GetDataStorage(), parent); m_Controls.gridLayout->addWidget(m_LesionInfoWidget); connect(m_Controls.caseIDComboBox, static_cast(&QComboBox::currentIndexChanged), this, &QmitkSemanticRelationsView::OnCaseIDSelectionChanged); connect(m_LesionInfoWidget, &QmitkLesionInfoWidget::ImageAdded, this, &QmitkSemanticRelationsView::AddToComboBox); connect(m_LesionInfoWidget, &QmitkLesionInfoWidget::JumpToPosition, this, &QmitkSemanticRelationsView::OnJumpToPosition); connect(m_LesionInfoWidget, &QmitkLesionInfoWidget::ImageRemoved, this, &QmitkSemanticRelationsView::OnImageRemoved); } void QmitkSemanticRelationsView::NodeRemoved(const mitk::DataNode* node) { - OnImageRemoved(node); + if (mitk::NodePredicates::GetImagePredicate()->CheckNode(node)) + { + m_LesionInfoWidget->OnRemoveImage(node); + } + else if (mitk::NodePredicates::GetSegmentationPredicate()->CheckNode(node)) + { + m_LesionInfoWidget->OnRemoveSegmentation(node); + } } void QmitkSemanticRelationsView::OnCaseIDSelectionChanged(const QString& caseID) { m_LesionInfoWidget->SetCurrentCaseID(caseID.toStdString()); } void QmitkSemanticRelationsView::OnJumpToPosition(const mitk::Point3D& position) { mitk::IRenderWindowPart* renderWindowPart = GetRenderWindowPart(); if (nullptr != renderWindowPart) { renderWindowPart->SetSelectedPosition(position); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } } void QmitkSemanticRelationsView::OnImageRemoved(const mitk::DataNode* imageNode) { mitk::SemanticTypes::CaseID caseID = mitk::GetCaseIDFromDataNode(imageNode); RemoveFromComboBox(caseID); } void QmitkSemanticRelationsView::AddToComboBox(const mitk::SemanticTypes::CaseID& caseID) { int foundIndex = m_Controls.caseIDComboBox->findText(QString::fromStdString(caseID)); if (-1 == foundIndex) { // add the caseID to the combo box, as it is not already contained m_Controls.caseIDComboBox->addItem(QString::fromStdString(caseID)); } } void QmitkSemanticRelationsView::RemoveFromComboBox(const mitk::SemanticTypes::CaseID& caseID) { std::vector allControlPoints = m_SemanticRelations->GetAllControlPointsOfCase(caseID); int foundIndex = m_Controls.caseIDComboBox->findText(QString::fromStdString(caseID)); if (allControlPoints.empty() && -1 != foundIndex) { // TODO: find new way to check for empty case id // caseID does not contain any control points and therefore no data // remove the caseID, if it is still contained m_Controls.caseIDComboBox->removeItem(foundIndex); } }