diff --git a/Plugins/org.mitk.gui.qt.common/files.cmake b/Plugins/org.mitk.gui.qt.common/files.cmake index bb57973a0e..fc46816c35 100755 --- a/Plugins/org.mitk.gui.qt.common/files.cmake +++ b/Plugins/org.mitk.gui.qt.common/files.cmake @@ -1,67 +1,46 @@ set(SRC_CPP_FILES QmitkAbstractMultiWidgetEditor.cpp QmitkAbstractRenderEditor.cpp QmitkAbstractView.cpp QmitkDataNodeSelectionProvider.cpp QmitkDnDFrameWidget.cpp QmitkSelectionServiceConnector.cpp QmitkSliceNavigationListener.cpp - QmitkSingleNodeSelectionWidget.cpp - QmitkNodeSelectionDialog.cpp - QmitkMultiNodeSelectionWidget.cpp QmitkMultiWidgetDecorationManager.cpp - QmitkNodeSelectionPreferenceHelper.cpp - QmitkNodeSelectionButton.cpp ) set(INTERNAL_CPP_FILES QmitkCommonActivator.cpp QmitkDataNodeItemModel.cpp QmitkDataNodeSelection.cpp QmitkViewCoordinator.cpp - QmitkNodeSelectionConstants.cpp QmitkNodeSelectionPreferencePage.cpp - QmitkNodeSelectionListItemWidget.cpp ) set(UI_FILES - src/QmitkSingleNodeSelectionWidget.ui - src/QmitkMultiNodeSelectionWidget.ui - src/QmitkNodeSelectionDialog.ui src/internal/QmitkNodeSelectionPreferencePage.ui - src/internal/QmitkNodeSelectionListItemWidget.ui ) set(MOC_H_FILES src/QmitkAbstractMultiWidgetEditor.h src/QmitkAbstractRenderEditor.h src/QmitkDnDFrameWidget.h src/QmitkSelectionServiceConnector.h src/QmitkSliceNavigationListener.h - src/QmitkSingleNodeSelectionWidget.h - src/QmitkNodeSelectionDialog.h - src/QmitkMultiNodeSelectionWidget.h - src/QmitkNodeSelectionButton.h src/internal/QmitkCommonActivator.h src/internal/QmitkNodeSelectionPreferencePage.h - src/internal/QmitkNodeSelectionListItemWidget.h ) set(CACHED_RESOURCE_FILES plugin.xml - resources/times.svg -) - -set(QRC_FILES - resources/common.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.common/resources/common.qrc b/Plugins/org.mitk.gui.qt.common/resources/common.qrc deleted file mode 100644 index e7959f2329..0000000000 --- a/Plugins/org.mitk.gui.qt.common/resources/common.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - times.svg - - diff --git a/Plugins/org.mitk.gui.qt.common/resources/icon-license.txt b/Plugins/org.mitk.gui.qt.common/resources/icon-license.txt deleted file mode 100644 index 167ecb6def..0000000000 --- a/Plugins/org.mitk.gui.qt.common/resources/icon-license.txt +++ /dev/null @@ -1,2 +0,0 @@ -See [Font Awsome 4] in Licenses/ICONS.md for: -- times.svg \ No newline at end of file diff --git a/Plugins/org.mitk.gui.qt.common/resources/times.svg b/Plugins/org.mitk.gui.qt.common/resources/times.svg deleted file mode 100644 index fdb8c5c03b..0000000000 --- a/Plugins/org.mitk.gui.qt.common/resources/times.svg +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - diff --git a/Plugins/org.mitk.gui.qt.common/src/QmitkMultiNodeSelectionWidget.cpp b/Plugins/org.mitk.gui.qt.common/src/QmitkMultiNodeSelectionWidget.cpp deleted file mode 100644 index ecae1b05e3..0000000000 --- a/Plugins/org.mitk.gui.qt.common/src/QmitkMultiNodeSelectionWidget.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "QmitkMultiNodeSelectionWidget.h" - -#include - -#include "QmitkNodeSelectionDialog.h" -#include "QmitkCustomVariants.h" -#include "internal/QmitkNodeSelectionListItemWidget.h" - -QmitkMultiNodeSelectionWidget::QmitkMultiNodeSelectionWidget(QWidget* parent) - : QmitkAbstractNodeSelectionWidget(parent) -{ - m_Controls.setupUi(this); - m_Overlay = new QmitkSimpleTextOverlayWidget(m_Controls.list); - m_Overlay->setVisible(false); - m_CheckFunction = [](const NodeList &) { return ""; }; - - this->OnInternalSelectionChanged(); - this->UpdateInfo(); - - connect(m_Controls.btnChange, SIGNAL(clicked(bool)), this, SLOT(OnEditSelection())); -} - -void QmitkMultiNodeSelectionWidget::SetSelectionCheckFunction(const SelectionCheckFunctionType &checkFunction) -{ - m_CheckFunction = checkFunction; - - auto newEmission = this->CompileEmitSelection(); - auto newCheckResponse = m_CheckFunction(newEmission); - - if (newCheckResponse.empty() && !m_CheckResponse.empty()) - { - this->EmitSelection(newEmission); - } - m_CheckResponse = newCheckResponse; - this->UpdateInfo(); -} - -void QmitkMultiNodeSelectionWidget::OnEditSelection() -{ - QmitkNodeSelectionDialog* dialog = new QmitkNodeSelectionDialog(this, m_PopUpTitel, m_PopUpHint); - - dialog->SetDataStorage(m_DataStorage.Lock()); - dialog->SetNodePredicate(m_NodePredicate); - dialog->SetCurrentSelection(this->CompileEmitSelection()); - dialog->SetSelectOnlyVisibleNodes(m_SelectOnlyVisibleNodes); - dialog->SetSelectionMode(QAbstractItemView::MultiSelection); - dialog->SetSelectionCheckFunction(m_CheckFunction); - - m_Controls.btnChange->setChecked(true); - if (dialog->exec()) - { - this->HandleChangeOfInternalSelection(dialog->GetSelectedNodes()); - } - m_Controls.btnChange->setChecked(false); - - delete dialog; -} - -void QmitkMultiNodeSelectionWidget::UpdateInfo() -{ - if (!m_Controls.list->count()) - { - if (m_IsOptional) - { - if (this->isEnabled()) - { - m_Overlay->SetOverlayText(QStringLiteral("") + m_EmptyInfo + QStringLiteral("")); - } - else - { - m_Overlay->SetOverlayText(QStringLiteral("") + m_EmptyInfo + QStringLiteral("")); - } - } - else - { - if (this->isEnabled()) - { - m_Overlay->SetOverlayText(QStringLiteral("") + m_InvalidInfo + QStringLiteral("")); - } - else - { - m_Overlay->SetOverlayText(QStringLiteral("") + m_InvalidInfo + QStringLiteral("")); - } - } - } - else - { - if (!m_CheckResponse.empty()) - { - m_Overlay->SetOverlayText(QString::fromStdString(m_CheckResponse)); - } - } - - m_Overlay->setVisible(m_Controls.list->count() == 0 || !m_CheckResponse.empty()); - - for (auto i = 0; i < m_Controls.list->count(); ++i) - { - auto item = m_Controls.list->item(i); - auto widget = qobject_cast(m_Controls.list->itemWidget(item)); - widget->SetClearAllowed(m_IsOptional || m_Controls.list->count() > 1); - } -} - -void QmitkMultiNodeSelectionWidget::OnInternalSelectionChanged() -{ - m_Controls.list->clear(); - auto currentSelection = this->GetCurrentInternalSelection(); - for (auto& node : currentSelection) - { - if (m_NodePredicate.IsNull() || m_NodePredicate->CheckNode(node)) - { - QListWidgetItem *newItem = new QListWidgetItem; - - newItem->setSizeHint(QSize(0, 40)); - QmitkNodeSelectionListItemWidget* widget = new QmitkNodeSelectionListItemWidget; - - widget->SetSelectedNode(node); - widget->SetClearAllowed(m_IsOptional || currentSelection.size() > 1); - - connect(widget, &QmitkNodeSelectionListItemWidget::ClearSelection, this, &QmitkMultiNodeSelectionWidget::OnClearSelection); - newItem->setData(Qt::UserRole, QVariant::fromValue(node)); - - m_Controls.list->addItem(newItem); - m_Controls.list->setItemWidget(newItem, widget); - } - } -} - -void QmitkMultiNodeSelectionWidget::OnClearSelection(const mitk::DataNode* node) -{ - this->RemoveNodeFromSelection(node); -} - -void QmitkMultiNodeSelectionWidget::changeEvent(QEvent *event) -{ - if (event->type() == QEvent::EnabledChange) - { - this->UpdateInfo(); - } - QmitkAbstractNodeSelectionWidget::changeEvent(event); -} - -bool QmitkMultiNodeSelectionWidget::AllowEmissionOfSelection(const NodeList& emissionCandidates) const -{ - m_CheckResponse = m_CheckFunction(emissionCandidates); - return m_CheckResponse.empty(); -} diff --git a/Plugins/org.mitk.gui.qt.common/src/QmitkMultiNodeSelectionWidget.h b/Plugins/org.mitk.gui.qt.common/src/QmitkMultiNodeSelectionWidget.h deleted file mode 100644 index d490574f32..0000000000 --- a/Plugins/org.mitk.gui.qt.common/src/QmitkMultiNodeSelectionWidget.h +++ /dev/null @@ -1,80 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#ifndef QMITK_MULTI_NODE_SELECTION_WIDGET_H -#define QMITK_MULTI_NODE_SELECTION_WIDGET_H - -#include -#include -#include - -#include "QmitkSimpleTextOverlayWidget.h" - -#include "org_mitk_gui_qt_common_Export.h" - -#include "ui_QmitkMultiNodeSelectionWidget.h" - -#include - -class QmitkAbstractDataStorageModel; - -/** -* @class QmitkMultiNodeSelectionWidget -* @brief Widget that allows to perform and represents a multiple node selection. -*/ -class MITK_QT_COMMON QmitkMultiNodeSelectionWidget : public QmitkAbstractNodeSelectionWidget -{ - Q_OBJECT - -public: - explicit QmitkMultiNodeSelectionWidget(QWidget* parent = nullptr); - - using NodeList = QmitkAbstractNodeSelectionWidget::NodeList; - - /** - * @brief Helper function that is used to check the given selection for consistency. - * Returning an empty string assumes that everything is alright and the selection - * is valid. If the string is not empty, the content of the string will be used - * as error message in the overlay to indicate the problem. - */ - using SelectionCheckFunctionType = std::function; - /** - * @brief A selection check function can be set. If set the widget uses this function to - * check the made/set selection. If the selection is valid, everything is fine. - * If selection is indicated as invalid, it will not be communicated by the widget - * (no signal emission). - */ - void SetSelectionCheckFunction(const SelectionCheckFunctionType &checkFunction); - -public Q_SLOTS: - void OnEditSelection(); - -protected Q_SLOTS: - void OnClearSelection(const mitk::DataNode* node); - -protected: - void changeEvent(QEvent *event) override; - - void UpdateInfo() override; - void OnInternalSelectionChanged() override; - - bool AllowEmissionOfSelection(const NodeList& emissionCandidates) const override; - - QmitkSimpleTextOverlayWidget* m_Overlay; - - SelectionCheckFunctionType m_CheckFunction; - mutable std::string m_CheckResponse; - - Ui_QmitkMultiNodeSelectionWidget m_Controls; -}; - -#endif // QMITK_MULTI_NODE_SELECTION_WIDGET_H diff --git a/Plugins/org.mitk.gui.qt.common/src/QmitkMultiNodeSelectionWidget.ui b/Plugins/org.mitk.gui.qt.common/src/QmitkMultiNodeSelectionWidget.ui deleted file mode 100644 index 172db00d55..0000000000 --- a/Plugins/org.mitk.gui.qt.common/src/QmitkMultiNodeSelectionWidget.ui +++ /dev/null @@ -1,85 +0,0 @@ - - - QmitkMultiNodeSelectionWidget - - - - 0 - 0 - 391 - 265 - - - - Form - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - QAbstractItemView::NoEditTriggers - - - false - - - QAbstractItemView::NoDragDrop - - - Qt::MoveAction - - - QAbstractItemView::NoSelection - - - - 1 - - - - - 2 - - - - - 3 - - - - - 4 - - - - - - - - Change selection - - - true - - - - - - - - diff --git a/Plugins/org.mitk.gui.qt.common/src/QmitkNodeSelectionButton.cpp b/Plugins/org.mitk.gui.qt.common/src/QmitkNodeSelectionButton.cpp deleted file mode 100644 index aad227179e..0000000000 --- a/Plugins/org.mitk.gui.qt.common/src/QmitkNodeSelectionButton.cpp +++ /dev/null @@ -1,281 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "QmitkNodeSelectionButton.h" - -// mitk core -#include -#include -#include -#include -#include - -// mitk qt widgets module -#include - -// berry includes -#include -#include - -#include - -#include -#include -#include - -QPixmap GetPixmapFromImageNode(const mitk::DataNode* dataNode, int height) -{ - if (nullptr == dataNode) - { - return QPixmap(); - } - - const mitk::Image* image = dynamic_cast(dataNode->GetData()); - if ((nullptr == image || !image->IsInitialized()) || // -> must be an image - (image->GetPixelType().GetNumberOfComponents() != 1)) // -> for now only single component are allowed - { - auto descManager = QmitkNodeDescriptorManager::GetInstance(); - auto desc = descManager->GetDescriptor(dataNode); - auto icon = desc->GetIcon(dataNode); - auto fallBackMap = icon.pixmap(height, height); - return fallBackMap; - } - - mitk::PlaneGeometry::Pointer planeGeometry = mitk::PlaneGeometry::New(); - int sliceNumber = image->GetDimension(2) / 2; - planeGeometry->InitializeStandardPlane(image->GetGeometry(), mitk::AnatomicalPlane::Axial, sliceNumber); - - mitk::ExtractSliceFilter::Pointer extractSliceFilter = mitk::ExtractSliceFilter::New(); - extractSliceFilter->SetInput(image); - extractSliceFilter->SetInterpolationMode(mitk::ExtractSliceFilter::RESLICE_CUBIC); - extractSliceFilter->SetResliceTransformByGeometry(image->GetGeometry()); - extractSliceFilter->SetWorldGeometry(planeGeometry); - extractSliceFilter->SetOutputDimensionality(2); - extractSliceFilter->SetVtkOutputRequest(true); - extractSliceFilter->Update(); - - vtkImageData* imageData = extractSliceFilter->GetVtkOutput(); - - mitk::LevelWindow levelWindow; - dataNode->GetLevelWindow(levelWindow); - vtkSmartPointer lookupTable = vtkSmartPointer::New(); - lookupTable->SetRange(levelWindow.GetLowerWindowBound(), levelWindow.GetUpperWindowBound()); - lookupTable->SetSaturationRange(0.0, 0.0); - lookupTable->SetValueRange(0.0, 1.0); - lookupTable->SetHueRange(0.0, 0.0); - lookupTable->SetRampToLinear(); - - vtkSmartPointer levelWindowFilter = vtkSmartPointer::New(); - levelWindowFilter->SetLookupTable(lookupTable); - levelWindowFilter->SetInputData(imageData); - levelWindowFilter->SetMinOpacity(0.0); - levelWindowFilter->SetMaxOpacity(1.0); - int dims[3]; - imageData->GetDimensions(dims); - double clippingBounds[] = { 0.0, static_cast(dims[0]), 0.0, static_cast(dims[1]) }; - levelWindowFilter->SetClippingBounds(clippingBounds); - levelWindowFilter->Update(); - imageData = levelWindowFilter->GetOutput(); - - QImage thumbnailImage(reinterpret_cast(imageData->GetScalarPointer()), dims[0], dims[1], QImage::Format_ARGB32); - - if (dims[0] > dims[1]) - { - thumbnailImage = thumbnailImage.scaledToWidth(height, Qt::SmoothTransformation).rgbSwapped(); - } - else - { - thumbnailImage = thumbnailImage.scaledToHeight(height, Qt::SmoothTransformation).rgbSwapped(); - } - - return QPixmap::fromImage(thumbnailImage); -} - -QmitkNodeSelectionButton::QmitkNodeSelectionButton(QWidget *parent) - : QPushButton(parent) - , m_OutDatedThumbNail(true) - , m_DataMTime(0) - , m_IsOptional(true) - , m_NodeModifiedObserverTag(0) - , m_NodeObserved(false) -{ -} - -QmitkNodeSelectionButton::~QmitkNodeSelectionButton() -{ - this->RemoveNodeObserver(); - this->m_SelectedNode = nullptr; -} - -void QmitkNodeSelectionButton::AddNodeObserver() -{ - if (this->m_SelectedNode.IsNotNull()) - { - if (m_NodeObserved) - { - MITK_DEBUG << "Invalid observer state in QmitkNodeSelectionButton. There is already a registered observer. Internal logic is not correct. May be an old observer was not removed."; - } - - auto modifiedCommand = itk::MemberCommand::New(); - modifiedCommand->SetCallbackFunction(this, &QmitkNodeSelectionButton::OnNodeModified); - - // const cast because we need non const nodes and it seems to be the lesser of two evil. - // the changes to the node are only on the observer level. The other option would be to - // make the public interface require non const nodes, this we don't want to introduce. - auto nonconst_node = const_cast(this->m_SelectedNode.GetPointer()); - m_NodeModifiedObserverTag = nonconst_node->AddObserver(itk::ModifiedEvent(), modifiedCommand); - m_NodeObserved = true; - } -} - -void QmitkNodeSelectionButton::RemoveNodeObserver() -{ - if (this->m_SelectedNode.IsNotNull()) - { - // const cast because we need non const nodes and it seems to be the lesser of two evil. - // the changes to the node are only on the observer level. The other option would be to - // make the public interface require non const nodes, this we don't want to introduce. - auto nonconst_node = const_cast(this->m_SelectedNode.GetPointer()); - nonconst_node->RemoveObserver(m_NodeModifiedObserverTag); - } - m_NodeObserved = false; -} - -void QmitkNodeSelectionButton::OnNodeModified(const itk::Object * /*caller*/, const itk::EventObject & event) -{ - if (itk::ModifiedEvent().CheckEvent(&event)) - { - this->update(); - } -} - -const mitk::DataNode* QmitkNodeSelectionButton::GetSelectedNode() const -{ - return m_SelectedNode; -} - -void QmitkNodeSelectionButton::SetSelectedNode(const mitk::DataNode* node) -{ - if (m_SelectedNode != node) - { - this->RemoveNodeObserver(); - this->m_SelectedNode = node; - this->m_OutDatedThumbNail = true; - this->AddNodeObserver(); - } - - this->update(); -} - -void QmitkNodeSelectionButton::SetNodeInfo(QString info) -{ - this->m_Info = info; - this->update(); -} - -void QmitkNodeSelectionButton::paintEvent(QPaintEvent *p) -{ - QString stylesheet; - - ctkPluginContext* context = berry::WorkbenchPlugin::GetDefault()->GetPluginContext(); - ctkServiceReference styleManagerRef = context->getServiceReference(); - if (styleManagerRef) - { - auto styleManager = context->getService(styleManagerRef); - stylesheet = styleManager->GetStylesheet(); - } - - QPushButton::paintEvent(p); - - QPainter painter(this); - QTextDocument td(this); - td.setDefaultStyleSheet(stylesheet); - - auto widgetSize = this->size(); - QPoint origin = QPoint(5, 5); - - if (this->m_SelectedNode) - { - auto iconLength = widgetSize.height() - 10; - auto node = this->m_SelectedNode; - - itk::ModifiedTimeType dataMTime = 0; - if (m_SelectedNode->GetData()) - { - dataMTime = m_SelectedNode->GetData()->GetMTime(); - } - if (dataMTime>m_DataMTime || this->m_OutDatedThumbNail) - { - this->m_ThumbNail = GetPixmapFromImageNode(node, iconLength); - this->m_OutDatedThumbNail = false; - m_DataMTime = dataMTime; - } - - auto thumbNailOrigin = origin; - thumbNailOrigin.setY(thumbNailOrigin.y() + ((iconLength - m_ThumbNail.height()) / 2)); - painter.drawPixmap(thumbNailOrigin, m_ThumbNail); - origin.setX(origin.x() + iconLength + 5); - - if (this->isEnabled()) - { - td.setHtml(QString::fromStdString("" + node->GetName() + "")); - } - else - { - td.setHtml(QString::fromStdString("" + node->GetName() + "")); - } - } - else - { - if (this->isEnabled()) - { - if (this->m_IsOptional) - { - td.setHtml(QString("") + m_Info + QString("")); - } - else - { - td.setHtml(QString("") + m_Info + QString("")); - } - } - else - { - td.setHtml(QString("") + m_Info + QString("")); - } - } - - auto textSize = td.size(); - - origin.setY( (widgetSize.height() - textSize.height()) / 2.); - - painter.translate(origin); - td.drawContents(&painter); -} - -void QmitkNodeSelectionButton::changeEvent(QEvent *event) -{ - if (event->type() == QEvent::EnabledChange) - { - this->update(); - } -} - -bool QmitkNodeSelectionButton::GetSelectionIsOptional() const -{ - return m_IsOptional; -} - -void QmitkNodeSelectionButton::SetSelectionIsOptional(bool isOptional) -{ - m_IsOptional = isOptional; - this->update(); -} diff --git a/Plugins/org.mitk.gui.qt.common/src/QmitkNodeSelectionButton.h b/Plugins/org.mitk.gui.qt.common/src/QmitkNodeSelectionButton.h deleted file mode 100644 index 21d328da1c..0000000000 --- a/Plugins/org.mitk.gui.qt.common/src/QmitkNodeSelectionButton.h +++ /dev/null @@ -1,71 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#ifndef QMITK_NODE_SELECTION_BUTTON_H -#define QMITK_NODE_SELECTION_BUTTON_H - -#include "org_mitk_gui_qt_common_Export.h" - -#include - -#include -#include - -/** -* @class QmitkNodeSelectionButton -* @brief Button class that can be used to display information about a given node. -* If the given node is a nullptr the node info text will be shown. -* The node info can be formated text (e.g. HTML code; like the tooltip text). -*/ -class MITK_QT_COMMON QmitkNodeSelectionButton : public QPushButton -{ - Q_OBJECT - -public: - explicit QmitkNodeSelectionButton(QWidget *parent = nullptr); - ~QmitkNodeSelectionButton() override; - - const mitk::DataNode* GetSelectedNode() const; - bool GetSelectionIsOptional() const; - -public Q_SLOTS: - virtual void SetSelectedNode(const mitk::DataNode* node); - virtual void SetNodeInfo(QString info); - - /** Set the widget into an optional mode. Optional means that the selection of no valid - node does not mean an invalid state. Thus no node is a valid "node" selection too. - The state influences if the info text is handled as an information (optional) or a - warning (optiona==false).*/ - void SetSelectionIsOptional(bool isOptional); - -protected: - void paintEvent(QPaintEvent *p) override; - void changeEvent(QEvent *event) override; - - void AddNodeObserver(); - void RemoveNodeObserver(); - void OnNodeModified(const itk::Object * /*caller*/, const itk::EventObject &); - - mitk::DataNode::ConstPointer m_SelectedNode; - QString m_Info; - bool m_OutDatedThumbNail; - QPixmap m_ThumbNail; - itk::ModifiedTimeType m_DataMTime; - itk::ModifiedTimeType m_SelectionPropMTime; - - bool m_IsOptional; - - unsigned long m_NodeModifiedObserverTag; - bool m_NodeObserved; -}; - -#endif // QMITK_NODE_SELECTION_BUTTON_H diff --git a/Plugins/org.mitk.gui.qt.common/src/QmitkNodeSelectionDialog.cpp b/Plugins/org.mitk.gui.qt.common/src/QmitkNodeSelectionDialog.cpp deleted file mode 100644 index 5c557c42bd..0000000000 --- a/Plugins/org.mitk.gui.qt.common/src/QmitkNodeSelectionDialog.cpp +++ /dev/null @@ -1,293 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "QmitkNodeSelectionDialog.h" - -#include - -#include -#include -#include -#include - -QmitkNodeSelectionDialog::QmitkNodeSelectionDialog(QWidget* parent, QString title, QString hint) - : QDialog(parent) - , m_NodePredicate(nullptr) - , m_SelectOnlyVisibleNodes(false) - , m_SelectedNodes(NodeList()) - , m_SelectionMode(QAbstractItemView::SingleSelection) -{ - m_Controls.setupUi(this); - - m_CheckFunction = [](const NodeList &) { return ""; }; - - auto providers = mitk::DataStorageInspectorGenerator::GetProviders(); - auto visibleProviders = mitk::GetVisibleDataStorageInspectors(); - auto preferredID = mitk::GetPreferredDataStorageInspector(); - - if (visibleProviders.empty()) - { - MITK_DEBUG << "No presets for visible node selection inspectors available. Use fallback (show all available inspectors)"; - unsigned int order = 0; - for (const auto &proIter : providers) - { - visibleProviders.insert(std::make_pair(order, proIter.first)); - ++order; - } - } - - int preferredIndex = 0; - bool preferredFound = false; - for (const auto &proIter : visibleProviders) - { - auto finding = providers.find(proIter.second); - if (finding != providers.end()) - { - if (finding->second->GetInspectorID() != QmitkDataStorageFavoriteNodesInspector::INSPECTOR_ID() && finding->second->GetInspectorID() != QmitkDataStorageSelectionHistoryInspector::INSPECTOR_ID()) - { - auto provider = finding->second; - this->AddPanel(provider, preferredID, preferredFound, preferredIndex); - } - } - else - { - MITK_DEBUG << "No provider registered for inspector that is defined as visible in the preferences. Illegal inspector ID: " << proIter.second; - } - } - - if (mitk::GetShowFavoritesInspector()) - { - auto favoritesPorvider = mitk::DataStorageInspectorGenerator::GetProvider(QmitkDataStorageFavoriteNodesInspector::INSPECTOR_ID()); - if (favoritesPorvider != nullptr) - { - this->AddPanel(favoritesPorvider, preferredID, preferredFound, preferredIndex); - } - } - - if (mitk::GetShowHistoryInspector()) - { - auto historyPorvider = mitk::DataStorageInspectorGenerator::GetProvider(QmitkDataStorageSelectionHistoryInspector::INSPECTOR_ID()); - if (historyPorvider != nullptr) - { - this->AddPanel(historyPorvider, preferredID, preferredFound, preferredIndex); - } - } - - m_Controls.tabWidget->setCurrentIndex(preferredIndex); - this->setWindowTitle(title); - this->setToolTip(hint); - - m_Controls.hint->setText(hint); - m_Controls.hint->setVisible(!hint.isEmpty()); - if(hint.isEmpty()) - { - m_Controls.layoutHint->setContentsMargins(0, 0, 0, 0); - } - else - { - m_Controls.layoutHint->setContentsMargins(6, 6, 6, 6); - } - - this->SetErrorText(""); - - m_Controls.btnAddToFav->setIcon(berry::QtStyleManager::ThemeIcon(QStringLiteral(":/Qmitk/favorite_add.svg"))); - - connect(m_Controls.btnAddToFav, &QPushButton::clicked, this, &QmitkNodeSelectionDialog::OnFavoriteNodesButtonClicked); - connect(m_Controls.buttonBox, &QDialogButtonBox::accepted, this, &QmitkNodeSelectionDialog::OnOK); - connect(m_Controls.buttonBox, &QDialogButtonBox::rejected, this, &QmitkNodeSelectionDialog::OnCancel); -} - -void QmitkNodeSelectionDialog::SetDataStorage(mitk::DataStorage* dataStorage) -{ - if (m_DataStorage != dataStorage) - { - m_DataStorage = dataStorage; - auto lockedDataStorage = m_DataStorage.Lock(); - - if (lockedDataStorage.IsNotNull()) - { - for (auto panel : m_Panels) - { - panel->SetDataStorage(lockedDataStorage); - } - } - } -} - -void QmitkNodeSelectionDialog::SetNodePredicate(const mitk::NodePredicateBase* nodePredicate) -{ - if (m_NodePredicate != nodePredicate) - { - m_NodePredicate = nodePredicate; - - for (auto panel : m_Panels) - { - panel->SetNodePredicate(m_NodePredicate); - } - } -} - -const mitk::NodePredicateBase* QmitkNodeSelectionDialog::GetNodePredicate() const -{ - return m_NodePredicate; -} - -QmitkNodeSelectionDialog::NodeList QmitkNodeSelectionDialog::GetSelectedNodes() const -{ - return m_SelectedNodes; -} - -void QmitkNodeSelectionDialog::SetSelectionCheckFunction(const SelectionCheckFunctionType &checkFunction) -{ - m_CheckFunction = checkFunction; - auto checkResponse = m_CheckFunction(m_SelectedNodes); - - SetErrorText(checkResponse); - - m_Controls.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(checkResponse.empty()); -} - -void QmitkNodeSelectionDialog::SetErrorText(const std::string& checkResponse) -{ - m_Controls.error->setText(QString::fromStdString(checkResponse)); - m_Controls.error->setVisible(!checkResponse.empty()); - if (checkResponse.empty()) - { - m_Controls.layoutError->setContentsMargins(0, 0, 0, 0); - } - else - { - m_Controls.layoutError->setContentsMargins(6, 6, 6, 6); - } -} - -bool QmitkNodeSelectionDialog::GetSelectOnlyVisibleNodes() const -{ - return m_SelectOnlyVisibleNodes; -} - -void QmitkNodeSelectionDialog::SetSelectionMode(SelectionMode mode) -{ - m_SelectionMode = mode; - for (auto panel : m_Panels) - { - panel->SetSelectionMode(mode); - } -} - -QmitkNodeSelectionDialog::SelectionMode QmitkNodeSelectionDialog::GetSelectionMode() const -{ - return m_SelectionMode; -} - -void QmitkNodeSelectionDialog::SetSelectOnlyVisibleNodes(bool selectOnlyVisibleNodes) -{ - if (m_SelectOnlyVisibleNodes != selectOnlyVisibleNodes) - { - m_SelectOnlyVisibleNodes = selectOnlyVisibleNodes; - - for (auto panel : m_Panels) - { - panel->SetSelectOnlyVisibleNodes(m_SelectOnlyVisibleNodes); - } - } -} - -void QmitkNodeSelectionDialog::SetCurrentSelection(NodeList selectedNodes) -{ - m_SelectedNodes = selectedNodes; - auto checkResponse = m_CheckFunction(m_SelectedNodes); - - SetErrorText(checkResponse); - - m_Controls.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(checkResponse.empty()); - - for (auto panel : m_Panels) - { - panel->SetCurrentSelection(selectedNodes); - } -} - -void QmitkNodeSelectionDialog::OnSelectionChanged(NodeList selectedNodes) -{ - SetCurrentSelection(selectedNodes); - emit CurrentSelectionChanged(selectedNodes); -} - -void QmitkNodeSelectionDialog::OnFavoriteNodesButtonClicked() -{ - for (auto node : qAsConst(m_SelectedNodes)) - { - node->SetBoolProperty("org.mitk.selection.favorite", true); - } -} - -void QmitkNodeSelectionDialog::OnOK() -{ - for (const auto &node : qAsConst(m_SelectedNodes)) - { - QmitkDataStorageSelectionHistoryInspector::AddNodeToHistory(node); - } - - this->accept(); -} - -void QmitkNodeSelectionDialog::OnCancel() -{ - this->reject(); -} - -void QmitkNodeSelectionDialog::AddPanel(const mitk::IDataStorageInspectorProvider * provider, const mitk::IDataStorageInspectorProvider::InspectorIDType& preferredID, bool &preferredFound, int &preferredIndex) -{ - auto inspector = provider->CreateInspector(); - QString name = QString::fromStdString(provider->GetInspectorDisplayName()); - QString desc = QString::fromStdString(provider->GetInspectorDescription()); - - inspector->setParent(this); - inspector->SetSelectionMode(m_SelectionMode); - - auto tabPanel = new QWidget(); - tabPanel->setObjectName(QString("tab_") + name); - tabPanel->setToolTip(desc); - - auto verticalLayout = new QVBoxLayout(tabPanel); - verticalLayout->setSpacing(0); - verticalLayout->setContentsMargins(0, 0, 0, 0); - verticalLayout->addWidget(inspector); - - auto panelPos = m_Controls.tabWidget->insertTab(m_Controls.tabWidget->count(), tabPanel, name); - - auto icon = provider->GetInspectorIcon(); - if (!icon.isNull()) - { - m_Controls.tabWidget->setTabIcon(panelPos, icon); - } - - m_Panels.push_back(inspector); - connect(inspector, &QmitkAbstractDataStorageInspector::CurrentSelectionChanged, this, &QmitkNodeSelectionDialog::OnSelectionChanged); - connect(inspector->GetView(), &QAbstractItemView::doubleClicked, this, &QmitkNodeSelectionDialog::OnDoubleClicked); - - preferredFound = preferredFound || provider->GetInspectorID() == preferredID; - if (!preferredFound) - { - ++preferredIndex; - } -} - -void QmitkNodeSelectionDialog::OnDoubleClicked(const QModelIndex& /*index*/) -{ - const auto isOK = m_Controls.buttonBox->button(QDialogButtonBox::Ok)->isEnabled(); - if (!m_SelectedNodes.empty() && isOK) - { - this->OnOK(); - } -} diff --git a/Plugins/org.mitk.gui.qt.common/src/QmitkNodeSelectionDialog.h b/Plugins/org.mitk.gui.qt.common/src/QmitkNodeSelectionDialog.h deleted file mode 100644 index 217e212b6d..0000000000 --- a/Plugins/org.mitk.gui.qt.common/src/QmitkNodeSelectionDialog.h +++ /dev/null @@ -1,146 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#ifndef QMITK_NODE_SELECTION_DIALOG_H -#define QMITK_NODE_SELECTION_DIALOG_H - -#include "org_mitk_gui_qt_common_Export.h" - -#include "ui_QmitkNodeSelectionDialog.h" - -#include -#include -#include -#include "mitkIDataStorageInspectorProvider.h" - -#include - -#include -#include - -/** -* @class QmitkNodeSelectionDialog -* @brief A customized QDialog that displays different data storage inspectors and allows to -* set and get a current selection by selecting data nodes in the data storage inspectors. -*/ -class MITK_QT_COMMON QmitkNodeSelectionDialog : public QDialog -{ - Q_OBJECT - -public: - explicit QmitkNodeSelectionDialog(QWidget* parent = nullptr, QString caption = "", QString hint = ""); - - /** - * @brief Set the data storage that will be used. - * The function iterates over the dialog's panels and sets the data storage of each panel accordingly. - * Each panel is a specific data storage inspector. - * - * @param dataStorage A pointer to the data storage to set. - */ - void SetDataStorage(mitk::DataStorage* dataStorage); - - /** - * @brief Set the node predicate that will be used. - * The function iterates over the dialog's panels and sets the node predicate of each panel accordingly. - * Each panel is a specific data storage inspector. - * - * @param nodePredicate A pointer to node predicate. - */ - virtual void SetNodePredicate(const mitk::NodePredicateBase* nodePredicate); - - const mitk::NodePredicateBase* GetNodePredicate() const; - - using NodeList = QList; - NodeList GetSelectedNodes() const; - - /** - * @brief Helper function that is used to check the given selection for consistency. - * Returning an empty string assumes that everything is alright and the selection is valid. - * If the string is not empty, the content of the string will be used as error message. - */ - using SelectionCheckFunctionType = std::function; - /** - * @brief A selection check function can be set. If set the dialog uses this function to check the made/set selection. - * If the selection is valid, everything is fine. - * If the selection is indicated as invalid, the dialog will display the selection check function error message. - */ - void SetSelectionCheckFunction(const SelectionCheckFunctionType &checkFunction); - - bool GetSelectOnlyVisibleNodes() const; - - using SelectionMode = QAbstractItemView::SelectionMode; - /** - * @brief Set the Qt selection mode (e.g. Single selection, multi selection). - * The function iterates over the dialog's panels and sets the Qt selection mode of each panel accordingly. - * Each panel is a concrete data storage inspector. - * - * @param mode The QAbstractItemView::SelectionMode to define the selection mode. - */ - void SetSelectionMode(SelectionMode mode); - SelectionMode GetSelectionMode() const; - -Q_SIGNALS: - /** - * @brief A signal that will be emitted if the selected node has changed. - * - * @param nodes A list of data nodes that are newly selected. - */ - void CurrentSelectionChanged(NodeList nodes); - - public Q_SLOTS: - /** - * @brief Set the selection modus to (not) include invisible nodes in the selection. - * The function iterates over the dialog's panels and sets the selection modus of each panel accordingly. - * Each panel is a concrete data storage inspector. - * - * @param selectOnlyVisibleNodes The bool value to define the selection modus. - */ - void SetSelectOnlyVisibleNodes(bool selectOnlyVisibleNodes); - /** - * @brief Set the currently selected nodes given a list of data nodes. - * The function iterates over the dialog's panels and sets the current selection of each panel accordingly. - * Each panel is a concrete data storage inspector. - * - * @param selectedNodes A list of data nodes that should be newly selected. - */ - void SetCurrentSelection(NodeList selectedNodes); - -protected Q_SLOTS: - - void OnSelectionChanged(NodeList selectedNodes); - void OnFavoriteNodesButtonClicked(); - void OnOK(); - void OnCancel(); - void OnDoubleClicked(const QModelIndex& index); - -protected: - void SetErrorText(const std::string& checkResponse); - - void AddPanel(const mitk::IDataStorageInspectorProvider* provider, const mitk::IDataStorageInspectorProvider::InspectorIDType &preferredID, bool &preferredFound, int &preferredIndex); - - mitk::WeakPointer m_DataStorage; - mitk::NodePredicateBase::ConstPointer m_NodePredicate; - bool m_SelectOnlyVisibleNodes; - NodeList m_SelectedNodes; - - SelectionCheckFunctionType m_CheckFunction; - - SelectionMode m_SelectionMode; - - using PanelVectorType = std::vector; - PanelVectorType m_Panels; - - QPushButton* m_FavoriteNodesButton; - Ui_QmitkNodeSelectionDialog m_Controls; -}; - -#endif // QMITK_NODE_SELECTION_DIALOG_H diff --git a/Plugins/org.mitk.gui.qt.common/src/QmitkNodeSelectionDialog.ui b/Plugins/org.mitk.gui.qt.common/src/QmitkNodeSelectionDialog.ui deleted file mode 100644 index 26f94b420d..0000000000 --- a/Plugins/org.mitk.gui.qt.common/src/QmitkNodeSelectionDialog.ui +++ /dev/null @@ -1,116 +0,0 @@ - - - QmitkNodeSelectionDialog - - - - 0 - 0 - 800 - 600 - - - - Dialog - - - true - - - true - - - - - - 6 - - - 6 - - - 6 - - - 6 - - - - - QFrame::NoFrame - - - Info text ... - - - Qt::RichText - - - true - - - - - - - - - -1 - - - - 24 - 24 - - - - - - - - 6 - - - 6 - - - 6 - - - 6 - - - - - error text - - - - - - - - - - - Add the current selection to the favorites. - - - Add to favorites - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - - diff --git a/Plugins/org.mitk.gui.qt.common/src/QmitkNodeSelectionPreferenceHelper.cpp b/Plugins/org.mitk.gui.qt.common/src/QmitkNodeSelectionPreferenceHelper.cpp deleted file mode 100644 index df4a7c5920..0000000000 --- a/Plugins/org.mitk.gui.qt.common/src/QmitkNodeSelectionPreferenceHelper.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "QmitkNodeSelectionPreferenceHelper.h" - -#include - -#include -#include -#include - -#include -#include - -#include "mitkExceptionMacro.h" -#include "mitkDataStorageInspectorGenerator.h" - -void mitk::PutVisibleDataStorageInspectors(const VisibleDataStorageInspectorMapType &inspectors) -{ - auto* prefService = mitk::CoreServices::GetPreferencesService(); - auto* prefNode = prefService->GetSystemPreferences()->Node(mitk::NodeSelectionConstants::ROOT_PREFERENCE_NODE_ID); - auto* visNode = prefNode->Node(mitk::NodeSelectionConstants::VISIBLE_INSPECTORS_NODE_ID); - - visNode->Clear(); - - // store map in new node - for (const auto &inspector : inspectors) - { - std::ostringstream sstr; - sstr << inspector.first; - auto* aNode = visNode->Node(sstr.str()); - - aNode->Put(mitk::NodeSelectionConstants::VISIBLE_INSPECTOR_ID, inspector.second); - } - - visNode->Flush(); -} - -mitk::VisibleDataStorageInspectorMapType mitk::GetVisibleDataStorageInspectors() -{ - auto* prefService = mitk::CoreServices::GetPreferencesService(); - - auto* prefNode = prefService->GetSystemPreferences()->Node(mitk::NodeSelectionConstants::ROOT_PREFERENCE_NODE_ID); - auto* visNode = prefNode->Node(mitk::NodeSelectionConstants::VISIBLE_INSPECTORS_NODE_ID); - - using NamesType = std::vector; - NamesType names = visNode->ChildrenNames(); - - VisibleDataStorageInspectorMapType visMap; - - if (!names.empty()) - { - for (const auto& name : names) - { - auto* aNode = visNode->Node(name); - - if (aNode == nullptr) - mitkThrow() << "Error in preference interface. Cannot find preset node under given name. Name: " << name; - - std::istringstream isstr(name); - unsigned int order = 0; - isstr >> order; - - auto id = aNode->Get(mitk::NodeSelectionConstants::VISIBLE_INSPECTOR_ID, ""); - - if (id.empty()) - mitkThrow() << "Error in preference interface. ID of visible inspector is not set. Inspector position: " << order; - - visMap.insert(std::make_pair(order, id)); - } - } - - if (visMap.empty()) - { //no visibility preferences set. Generate default - auto allProviders = mitk::DataStorageInspectorGenerator::GetProviders(); - - //fill inspector list - unsigned int pos = 0; - for (const auto& iter : allProviders) - { - if (iter.first != QmitkDataStorageFavoriteNodesInspector::INSPECTOR_ID() && iter.first != QmitkDataStorageSelectionHistoryInspector::INSPECTOR_ID()) - { - visMap.insert(std::make_pair(pos, iter.first)); - ++pos; - } - } - } - - return visMap; -} - -mitk::DataStorageInspectorIDType mitk::GetPreferredDataStorageInspector() -{ - auto* prefService = mitk::CoreServices::GetPreferencesService(); - auto* prefNode = prefService->GetSystemPreferences()->Node(mitk::NodeSelectionConstants::ROOT_PREFERENCE_NODE_ID); - auto id = prefNode->Get(mitk::NodeSelectionConstants::PREFERRED_INSPECTOR_ID, ""); - - if (id.empty()) - { //nothing set, deduce default preferred inspector - auto visibleInspectors = GetVisibleDataStorageInspectors(); - if (!visibleInspectors.empty()) - id = visibleInspectors.begin()->second; - } - - return id; -} - -void mitk::PutPreferredDataStorageInspector(const DataStorageInspectorIDType &id) -{ - auto* prefService = mitk::CoreServices::GetPreferencesService(); - auto* prefNode = prefService->GetSystemPreferences()->Node(mitk::NodeSelectionConstants::ROOT_PREFERENCE_NODE_ID); - - prefNode->Put(mitk::NodeSelectionConstants::PREFERRED_INSPECTOR_ID, id); - prefNode->Flush(); -} - -void mitk::PutShowFavoritesInspector(bool show) -{ - auto* prefService = mitk::CoreServices::GetPreferencesService(); - auto* prefNode = prefService->GetSystemPreferences()->Node(mitk::NodeSelectionConstants::ROOT_PREFERENCE_NODE_ID); - - prefNode->PutBool(mitk::NodeSelectionConstants::SHOW_FAVORITE_INSPECTOR, show); - prefNode->Flush(); -} - -bool mitk::GetShowFavoritesInspector() -{ - auto* prefService = mitk::CoreServices::GetPreferencesService(); - auto* prefNode = prefService->GetSystemPreferences()->Node(mitk::NodeSelectionConstants::ROOT_PREFERENCE_NODE_ID); - - return prefNode->GetBool(mitk::NodeSelectionConstants::SHOW_FAVORITE_INSPECTOR, true); -} - -void mitk::PutShowHistoryInspector(bool show) -{ - auto* prefService = mitk::CoreServices::GetPreferencesService(); - auto* prefNode = prefService->GetSystemPreferences()->Node(mitk::NodeSelectionConstants::ROOT_PREFERENCE_NODE_ID); - - prefNode->PutBool(mitk::NodeSelectionConstants::SHOW_HISTORY_INSPECTOR, show); - prefNode->Flush(); -} - -bool mitk::GetShowHistoryInspector() -{ - auto* prefService = mitk::CoreServices::GetPreferencesService(); - auto* prefNode = prefService->GetSystemPreferences()->Node(mitk::NodeSelectionConstants::ROOT_PREFERENCE_NODE_ID); - - return prefNode->GetBool(mitk::NodeSelectionConstants::SHOW_HISTORY_INSPECTOR, true); -} diff --git a/Plugins/org.mitk.gui.qt.common/src/QmitkNodeSelectionPreferenceHelper.h b/Plugins/org.mitk.gui.qt.common/src/QmitkNodeSelectionPreferenceHelper.h deleted file mode 100644 index 477493c03e..0000000000 --- a/Plugins/org.mitk.gui.qt.common/src/QmitkNodeSelectionPreferenceHelper.h +++ /dev/null @@ -1,55 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#ifndef __QMITK_NODE_SELECTION_PREFERENCE_HELPER_H -#define __QMITK_NODE_SELECTION_PREFERENCE_HELPER_H - -#include -#include - -namespace mitk -{ - using DataStorageInspectorIDType = std::string; - - /** map containing the IDs of all inspectors that should be visible. The map key is the order of appearance - of the respective inspector.*/ - using VisibleDataStorageInspectorMapType = std::map; - - /** Stores the given ID as favorite inspector.*/ - void PutPreferredDataStorageInspector(const DataStorageInspectorIDType& id); - - /** Gets the ID of the current favorite data storage inspector. - * If empty string is returned, no favorite is set.*/ - DataStorageInspectorIDType GetPreferredDataStorageInspector(); - - /** Stores the given map of visible inspectors.*/ - void PutVisibleDataStorageInspectors(const VisibleDataStorageInspectorMapType& inspectors); - - /** Gets the map of current visible inspectors.*/ - VisibleDataStorageInspectorMapType GetVisibleDataStorageInspectors(); - - - /** Stores the given show state of the favorite inspector.*/ - void PutShowFavoritesInspector(bool show); - - /** Indicates if the favorites inspector should be shown. */ - bool GetShowFavoritesInspector(); - - /** Stores the given show state of the history inspector.*/ - void PutShowHistoryInspector(bool show); - - /** Indicates if the history inspector should be shown. */ - bool GetShowHistoryInspector(); -} - -#endif diff --git a/Plugins/org.mitk.gui.qt.common/src/QmitkSingleNodeSelectionWidget.cpp b/Plugins/org.mitk.gui.qt.common/src/QmitkSingleNodeSelectionWidget.cpp deleted file mode 100644 index 594695ef6f..0000000000 --- a/Plugins/org.mitk.gui.qt.common/src/QmitkSingleNodeSelectionWidget.cpp +++ /dev/null @@ -1,241 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "QmitkSingleNodeSelectionWidget.h" - -#include - -#include "mitkNodePredicateFunction.h" -#include "mitkNodePredicateAnd.h" - -#include - -#include "QmitkNodeSelectionDialog.h" -#include "QmitkNodeDetailsDialog.h" - -QmitkSingleNodeSelectionWidget::QmitkSingleNodeSelectionWidget(QWidget* parent) - : QmitkAbstractNodeSelectionWidget(parent) - , m_AutoSelectNodes(false) -{ - m_Controls.setupUi(this); - - m_Controls.btnSelect->installEventFilter(this); - m_Controls.btnSelect->setVisible(true); - m_Controls.btnClear->setVisible(false); - - m_Controls.btnClear->setIcon(berry::QtStyleManager::ThemeIcon(QStringLiteral(":/org.mitk.gui.qt.common/times.svg"))); - - this->UpdateInfo(); - - connect(m_Controls.btnClear, SIGNAL(clicked(bool)), this, SLOT(OnClearSelection())); -} - -void QmitkSingleNodeSelectionWidget::ReviseSelectionChanged(const NodeList& oldInternalSelection, NodeList& newInternalSelection) -{ - if (newInternalSelection.empty()) - { - if (m_AutoSelectNodes) - { - auto autoSelectedNode = this->DetermineAutoSelectNode(oldInternalSelection); - - if (autoSelectedNode.IsNotNull()) - { - newInternalSelection.append(autoSelectedNode); - } - } - } - else if (newInternalSelection.size()>1) - { - //this widget only allows one internal selected node. - newInternalSelection = { newInternalSelection.front() }; - } -} - -void QmitkSingleNodeSelectionWidget::OnClearSelection() -{ - if (m_IsOptional) - { - this->SetCurrentSelection({}); - } - - this->UpdateInfo(); -} - -mitk::DataNode::Pointer QmitkSingleNodeSelectionWidget::GetSelectedNode() const -{ - mitk::DataNode::Pointer result; - - auto selection = GetCurrentInternalSelection(); - if (!selection.empty()) - { - result = selection.front(); - } - return result; -} - -bool QmitkSingleNodeSelectionWidget::eventFilter(QObject *obj, QEvent *ev) -{ - if (obj == m_Controls.btnSelect) - { - if (ev->type() == QEvent::MouseButtonRelease) - { - auto mouseEv = dynamic_cast(ev); - if (!mouseEv) - { - return false; - } - - if (mouseEv->button() == Qt::LeftButton) - { - if (this->isEnabled()) - { - this->EditSelection(); - return true; - } - } - else - { - auto selection = this->CompileEmitSelection(); - if (!selection.empty()) - { - QmitkNodeDetailsDialog infoDialog(selection, this); - infoDialog.exec(); - return true; - } - } - } - } - - return false; -} - -void QmitkSingleNodeSelectionWidget::EditSelection() -{ - QmitkNodeSelectionDialog* dialog = new QmitkNodeSelectionDialog(this, m_PopUpTitel, m_PopUpHint); - - dialog->SetDataStorage(m_DataStorage.Lock()); - dialog->SetNodePredicate(m_NodePredicate); - dialog->SetCurrentSelection(this->GetCurrentInternalSelection()); - dialog->SetSelectOnlyVisibleNodes(m_SelectOnlyVisibleNodes); - dialog->SetSelectionMode(QAbstractItemView::SingleSelection); - - m_Controls.btnSelect->setChecked(true); - - if (dialog->exec()) - { - this->HandleChangeOfInternalSelection(dialog->GetSelectedNodes()); - } - - m_Controls.btnSelect->setChecked(false); - - delete dialog; -} - -void QmitkSingleNodeSelectionWidget::UpdateInfo() -{ - if (this->GetSelectedNode().IsNull()) - { - if (m_IsOptional) - { - m_Controls.btnSelect->SetNodeInfo(m_EmptyInfo); - } - else - { - m_Controls.btnSelect->SetNodeInfo(m_InvalidInfo); - } - m_Controls.btnSelect->SetSelectionIsOptional(m_IsOptional); - m_Controls.btnClear->setVisible(false); - } - else - { - m_Controls.btnClear->setVisible(m_IsOptional); - } - - m_Controls.btnSelect->SetSelectedNode(this->GetSelectedNode()); -} - -void QmitkSingleNodeSelectionWidget::SetCurrentSelectedNode(mitk::DataNode* selectedNode) -{ - NodeList selection; - if (selectedNode) - { - selection.append(selectedNode); - } - this->SetCurrentSelection(selection); -} - -void QmitkSingleNodeSelectionWidget::OnDataStorageChanged() -{ - this->AutoSelectNodes(); -} - -void QmitkSingleNodeSelectionWidget::OnNodeAddedToStorage(const mitk::DataNode* /*node*/) -{ - this->AutoSelectNodes(); -} - -bool QmitkSingleNodeSelectionWidget::GetAutoSelectNewNodes() const -{ - return m_AutoSelectNodes; -} - -void QmitkSingleNodeSelectionWidget::SetAutoSelectNewNodes(bool autoSelect) -{ - m_AutoSelectNodes = autoSelect; - this->AutoSelectNodes(); -} - -void QmitkSingleNodeSelectionWidget::AutoSelectNodes() -{ - if (this->GetSelectedNode().IsNull() && m_AutoSelectNodes) - { - auto autoNode = this->DetermineAutoSelectNode(); - - if (autoNode.IsNotNull()) - { - this->HandleChangeOfInternalSelection({ autoNode }); - } - } -} - -mitk::DataNode::Pointer QmitkSingleNodeSelectionWidget::DetermineAutoSelectNode(const NodeList& ignoreNodes) -{ - mitk::DataNode::Pointer result; - auto storage = m_DataStorage.Lock(); - if (storage.IsNotNull()) - { - auto ignoreCheck = [ignoreNodes](const mitk::DataNode * node) - { - bool result = true; - for (const auto& ignoreNode : ignoreNodes) - { - if (node == ignoreNode) - { - result = false; - break; - } - } - return result; - }; - - mitk::NodePredicateFunction::Pointer isNotIgnoredNode = mitk::NodePredicateFunction::New(ignoreCheck); - mitk::NodePredicateBase::Pointer predicate = isNotIgnoredNode.GetPointer(); - - if (m_NodePredicate.IsNotNull()) - { - predicate = mitk::NodePredicateAnd::New(m_NodePredicate.GetPointer(), predicate.GetPointer()).GetPointer(); - } - - result = storage->GetNode(predicate); - } - return result; -} diff --git a/Plugins/org.mitk.gui.qt.common/src/QmitkSingleNodeSelectionWidget.h b/Plugins/org.mitk.gui.qt.common/src/QmitkSingleNodeSelectionWidget.h deleted file mode 100644 index 52ab4d7bb6..0000000000 --- a/Plugins/org.mitk.gui.qt.common/src/QmitkSingleNodeSelectionWidget.h +++ /dev/null @@ -1,97 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#ifndef QMITK_SINGLE_NODE_SELECTION_WIDGET_H -#define QMITK_SINGLE_NODE_SELECTION_WIDGET_H - -#include -#include -#include - -#include "org_mitk_gui_qt_common_Export.h" - -#include "ui_QmitkSingleNodeSelectionWidget.h" - -#include -#include - -class QmitkAbstractDataStorageModel; - -/** -* @class QmitkSingleNodeSelectionWidget -* @brief Widget that represents a node selection of (max) one node. It acts like a button. Clicking on it -* allows to change the selection. -* -* @remark This class provides a public function 'SetAutoSelectNewNodes' that can be used to enable -* the auto selection mode (default is false). -* The user of this class calling this function has to make sure that the base-class Q_SIGNAL -* 'CurrentSelectionChanged', which will be emitted by this function, is already -* connected to a receiving slot, if the initial valid auto selection should not get lost. -*/ -class MITK_QT_COMMON QmitkSingleNodeSelectionWidget : public QmitkAbstractNodeSelectionWidget -{ - Q_OBJECT - -public: - explicit QmitkSingleNodeSelectionWidget(QWidget* parent = nullptr); - - mitk::DataNode::Pointer GetSelectedNode() const; - bool GetAutoSelectNewNodes() const; - - using NodeList = QmitkAbstractNodeSelectionWidget::NodeList; - -public Q_SLOTS: - void SetCurrentSelectedNode(mitk::DataNode* selectedNode); - - /** - * Sets the auto selection mode (default is false). - * If auto select is true and the following conditions are fullfilled, the widget will - * select a node automatically from the data storage: - * - a data storage is set - * - data storage contains at least one node that matches the given predicate - * - no selection is set - * - * @remark Enabling the auto selection mode by calling 'SetAutoSelectNewNodes(true)' - * will directly emit a 'QmitkSingleNodeSelectionWidget::CurrentSelectionChanged' Q_SIGNAL - * if a valid auto selection was made. - * If this initial emission should not get lost, auto selection mode needs to be enabled after this - * selection widget has been connected via the 'QmitkSingleNodeSelectionWidget::CurrentSelectionChanged' - * Q_SIGNAL to a receiving function. - */ - void SetAutoSelectNewNodes(bool autoSelect); - -protected Q_SLOTS: - virtual void OnClearSelection(); - -protected: - void ReviseSelectionChanged(const NodeList& oldInternalSelection, NodeList& newInternalSelection) override; - - bool eventFilter(QObject *obj, QEvent *ev) override; - void EditSelection(); - void UpdateInfo() override; - - void OnDataStorageChanged() override; - void OnNodeAddedToStorage(const mitk::DataNode* node) override; - - void AutoSelectNodes(); - - /** Helper function that gets a suitable auto selected node from the datastorage that fits to the predicate settings. - @param ignoreNodes You may pass a list of nodes that must not be choosen as auto selected node. */ - mitk::DataNode::Pointer DetermineAutoSelectNode(const NodeList& ignoreNodes = {}); - - /** See documentation of SetAutoSelectNewNodes for details*/ - bool m_AutoSelectNodes; - - Ui_QmitkSingleNodeSelectionWidget m_Controls; -}; - -#endif // QMITK_SINGLE_NODE_SELECTION_WIDGET_H diff --git a/Plugins/org.mitk.gui.qt.common/src/QmitkSingleNodeSelectionWidget.ui b/Plugins/org.mitk.gui.qt.common/src/QmitkSingleNodeSelectionWidget.ui deleted file mode 100644 index 94f5047e55..0000000000 --- a/Plugins/org.mitk.gui.qt.common/src/QmitkSingleNodeSelectionWidget.ui +++ /dev/null @@ -1,124 +0,0 @@ - - - QmitkSingleNodeSelectionWidget - - - - 0 - 0 - 348 - 25 - - - - - 0 - 0 - - - - - 0 - 25 - - - - - 16777215 - 40 - - - - Form - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 0 - 25 - - - - <html><head/><body><p>Press to change the selection.</p><p>Right click to show details about selected node.</p></body></html> - - - - - - true - - - - - - - - 0 - 0 - - - - - 0 - 25 - - - - - 25 - 16777215 - - - - Press to remove the current selection. - - - - - - - :/org.mitk.gui.qt.common/resources/times.svg:/org.mitk.gui.qt.common/resources/times.svg - - - - 19 - 19 - - - - - - - - - QmitkNodeSelectionButton - QPushButton -
QmitkNodeSelectionButton.h
-
-
- - -
diff --git a/Plugins/org.mitk.gui.qt.common/src/internal/QmitkNodeSelectionConstants.cpp b/Plugins/org.mitk.gui.qt.common/src/internal/QmitkNodeSelectionConstants.cpp deleted file mode 100644 index 4ab85ab5e1..0000000000 --- a/Plugins/org.mitk.gui.qt.common/src/internal/QmitkNodeSelectionConstants.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "QmitkNodeSelectionConstants.h" - -const std::string mitk::NodeSelectionConstants::ROOT_PREFERENCE_NODE_ID = "/NODESELECTION/UI"; -const std::string mitk::NodeSelectionConstants::VISIBLE_INSPECTORS_NODE_ID = "visibleInspectors"; -const std::string mitk::NodeSelectionConstants::PREFERRED_INSPECTOR_ID = "inspectorID"; -const std::string mitk::NodeSelectionConstants::VISIBLE_INSPECTOR_ID = "inspectorID"; -const std::string mitk::NodeSelectionConstants::SHOW_FAVORITE_INSPECTOR = "showFavoriteInspector"; -const std::string mitk::NodeSelectionConstants::SHOW_HISTORY_INSPECTOR = "showHistoryInspector"; diff --git a/Plugins/org.mitk.gui.qt.common/src/internal/QmitkNodeSelectionConstants.h b/Plugins/org.mitk.gui.qt.common/src/internal/QmitkNodeSelectionConstants.h deleted file mode 100644 index 7aa5326fd1..0000000000 --- a/Plugins/org.mitk.gui.qt.common/src/internal/QmitkNodeSelectionConstants.h +++ /dev/null @@ -1,42 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#ifndef _QMITK_NODE_SELECTION_CONSTANTS_H_ -#define _QMITK_NODE_SELECTION_CONSTANTS_H_ - -#include - -#include "org_mitk_gui_qt_common_Export.h" - -namespace mitk -{ -struct MITK_QT_COMMON NodeSelectionConstants -{ - /** ID/Path of main preference node for node selections. */ - static const std::string ROOT_PREFERENCE_NODE_ID; - - /** ID of main preference node where all visible inspectors are stored (e.g. ROOT_PREFERENCE_NODE_ID+"/"+VISIBLE_INSPECTORS_NODE_ID+"/[orderering #]"). - The sub node naming encodes the ordering number of the visible inspector.*/ - static const std::string VISIBLE_INSPECTORS_NODE_ID; - /** ID for the value that stores the preferred inspector ID in the root preference node.*/ - static const std::string PREFERRED_INSPECTOR_ID; - /** ID for the value that stores the inspector ID in the preference node.*/ - static const std::string VISIBLE_INSPECTOR_ID; - /** ID for the value that stores if the favorite inspector should be visible.*/ - static const std::string SHOW_FAVORITE_INSPECTOR; - /** ID for the value that stores if the history inspector should be visible.*/ - static const std::string SHOW_HISTORY_INSPECTOR; -}; - -} - -#endif diff --git a/Plugins/org.mitk.gui.qt.common/src/internal/QmitkNodeSelectionListItemWidget.cpp b/Plugins/org.mitk.gui.qt.common/src/internal/QmitkNodeSelectionListItemWidget.cpp deleted file mode 100644 index a18f4f833a..0000000000 --- a/Plugins/org.mitk.gui.qt.common/src/internal/QmitkNodeSelectionListItemWidget.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#include "QmitkNodeSelectionListItemWidget.h" - -#include - -#include - -#include "QmitkNodeDetailsDialog.h" - -QmitkNodeSelectionListItemWidget::QmitkNodeSelectionListItemWidget(QWidget *parent) - : QWidget(parent) -{ - m_Controls.setupUi(this); - - m_Controls.btnSelect->installEventFilter(this); - m_Controls.btnSelect->setVisible(true); - m_Controls.btnSelect->SetNodeInfo("No valid selection"); - m_Controls.btnClear->setVisible(false); - - m_Controls.btnClear->setIcon(berry::QtStyleManager::ThemeIcon(QStringLiteral(":/org.mitk.gui.qt.common/times.svg"))); - - connect(m_Controls.btnClear, SIGNAL(clicked(bool)), this, SLOT(OnClearSelection())); -} - -QmitkNodeSelectionListItemWidget::~QmitkNodeSelectionListItemWidget() -{ -} - -const mitk::DataNode* QmitkNodeSelectionListItemWidget::GetSelectedNode() const -{ - return m_Controls.btnSelect->GetSelectedNode(); -}; - -void QmitkNodeSelectionListItemWidget::SetSelectedNode(const mitk::DataNode* node) -{ - m_Controls.btnSelect->SetSelectedNode(node); - this->update(); -}; - -void QmitkNodeSelectionListItemWidget::SetClearAllowed(bool allowed) -{ - m_Controls.btnClear->setVisible(allowed); -}; - -void QmitkNodeSelectionListItemWidget::OnClearSelection() -{ - emit ClearSelection(this->GetSelectedNode()); -}; - -bool QmitkNodeSelectionListItemWidget::eventFilter(QObject *obj, QEvent *ev) -{ - if (obj == m_Controls.btnSelect) - { - if (ev->type() == QEvent::MouseButtonRelease) - { - auto mouseEv = dynamic_cast(ev); - if (!mouseEv) - { - return false; - } - - if (mouseEv->button() == Qt::RightButton) - { - auto selection = this->GetSelectedNode(); - - if (selection != nullptr) - { - QList selectionList({ this->GetSelectedNode() }); - QmitkNodeDetailsDialog infoDialog(selectionList, this); - infoDialog.exec(); - return true; - } - } - } - } - - return false; -} diff --git a/Plugins/org.mitk.gui.qt.common/src/internal/QmitkNodeSelectionListItemWidget.h b/Plugins/org.mitk.gui.qt.common/src/internal/QmitkNodeSelectionListItemWidget.h deleted file mode 100644 index 9527823603..0000000000 --- a/Plugins/org.mitk.gui.qt.common/src/internal/QmitkNodeSelectionListItemWidget.h +++ /dev/null @@ -1,52 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#ifndef QMITK_NODE_SELECTION_LIST_ITEM_WIDGET_H -#define QMITK_NODE_SELECTION_LIST_ITEM_WIDGET_H - -#include - -#include - -#include "ui_QmitkNodeSelectionListItemWidget.h" - -#include "org_mitk_gui_qt_common_Export.h" - -class MITK_QT_COMMON QmitkNodeSelectionListItemWidget : public QWidget -{ - Q_OBJECT - -public: - explicit QmitkNodeSelectionListItemWidget(QWidget* parent = nullptr); - ~QmitkNodeSelectionListItemWidget() override; - - const mitk::DataNode* GetSelectedNode() const; - -public Q_SLOTS : - virtual void SetSelectedNode(const mitk::DataNode* node); - virtual void SetClearAllowed(bool allowed); - -signals: - void ClearSelection(const mitk::DataNode* node); - -protected Q_SLOTS: - void OnClearSelection(); - -protected: - bool eventFilter(QObject *obj, QEvent *ev) override; - - Ui_QmitkNodeSelectionListItemWidget m_Controls; -}; - - -#endif // QMITK_NODE_SELECTION_LIST_ITEM_WIDGET_H diff --git a/Plugins/org.mitk.gui.qt.common/src/internal/QmitkNodeSelectionListItemWidget.ui b/Plugins/org.mitk.gui.qt.common/src/internal/QmitkNodeSelectionListItemWidget.ui deleted file mode 100644 index 6f59ef5284..0000000000 --- a/Plugins/org.mitk.gui.qt.common/src/internal/QmitkNodeSelectionListItemWidget.ui +++ /dev/null @@ -1,124 +0,0 @@ - - - QmitkNodeSelectionListItemWidget - - - - 0 - 0 - 348 - 25 - - - - - 0 - 0 - - - - - 0 - 25 - - - - - 16777215 - 40 - - - - Form - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 0 - 25 - - - - Right click to show details about selected node. - - - - - - false - - - - - - - - 0 - 0 - - - - - 0 - 25 - - - - - 25 - 16777215 - - - - Press to remove the current selection. - - - - - - - :/org.mitk.gui.qt.common/resources/times.svg:/org.mitk.gui.qt.common/resources/times.svg - - - - 19 - 19 - - - - - - - - - QmitkNodeSelectionButton - QPushButton -
QmitkNodeSelectionButton.h
-
-
- - -