Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
QmitkNodeSelectionDialog.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef QMITK_NODE_SELECTION_DIALOG_H
14 #define QMITK_NODE_SELECTION_DIALOG_H
15 
16 #include <mitkDataStorage.h>
17 #include <mitkWeakPointer.h>
18 #include <mitkNodePredicateBase.h>
20 
22 
24 
25 #include "ui_QmitkNodeSelectionDialog.h"
26 
27 #include <QDialog>
28 #include <QPushButton>
29 
35 {
36  Q_OBJECT
37 
38 public:
39  explicit QmitkNodeSelectionDialog(QWidget* parent = nullptr, QString caption = "", QString hint = "");
40 
46  void SetDataStorage(mitk::DataStorage* dataStorage);
47 
53  virtual void SetNodePredicate(const mitk::NodePredicateBase* nodePredicate);
54 
55  const mitk::NodePredicateBase* GetNodePredicate() const;
56 
57  using NodeList = QList<mitk::DataNode::Pointer>;
58  NodeList GetSelectedNodes() const;
59 
65  using SelectionCheckFunctionType = std::function<std::string(const NodeList &)>;
71  void SetSelectionCheckFunction(const SelectionCheckFunctionType &checkFunction);
72 
73  bool GetSelectOnlyVisibleNodes() const;
74 
75  using SelectionMode = QAbstractItemView::SelectionMode;
76  void SetSelectionMode(SelectionMode mode);
77  SelectionMode GetSelectionMode() const;
78 
79 Q_SIGNALS:
80  /*
81  * @brief A signal that will be emitted if the selected node has changed.
82  *
83  * @param nodes A list of data nodes that are newly selected.
84  */
85  void CurrentSelectionChanged(NodeList nodes);
86 
87  public Q_SLOTS:
88  /*
89  * @brief Change the selection modus of the item view's selection model.
90  *
91  * If true, an incoming selection will be filtered (reduced) to only those nodes that are visible by the current view.
92  * An outgoing selection can then at most contain the filtered nodes.
93  * If false, the incoming non-visible selection will be stored and later added to the outgoing selection,
94  * to include the original selection that could not be modified.
95  * The part of the original selection, that is non-visible are the nodes that are not
96  *
97  * @param selectOnlyVisibleNodes The bool value to define the selection modus.
98  */
99  void SetSelectOnlyVisibleNodes(bool selectOnlyVisibleNodes);
100 
101  /*
102  * @brief Transform a list of data nodes into a model selection and set this as a new selection of the
103  * selection model of the private member item view.
104  *
105  * The function filters the given list of nodes according to the 'm_SelectOnlyVisibleNodes' member variable. If
106  * necessary, the non-visible nodes are stored. This is done if 'm_SelectOnlyVisibleNodes' is false: In this case
107  * the selection may be filtered and only a subset of the selected nodes may be visible and therefore (de-)selectable
108  * in the data storage viewer. By storing the non-visible nodes it is possible to send the new, modified selection
109  * but also include the selected nodes from the original selection that could not be modified (see 'SetSelectOnlyVisibleNodes').
110  *
111  * @param nodes A list of data nodes that should be newly selected.
112  */
113  void SetCurrentSelection(NodeList selectedNodes);
114 
115 protected Q_SLOTS:
116 
117  void OnSelectionChanged(NodeList selectedNodes);
118  void OnFavoriteNodesButtonClicked();
119  void OnOK();
120  void OnCancel();
121 
122 protected:
123  void SetErrorText(const std::string& checkResponse);
124 
125  void AddPanel(const mitk::IDataStorageInspectorProvider* provider, const mitk::IDataStorageInspectorProvider::InspectorIDType &preferredID, bool &preferredFound, int &preferredIndex);
126 
131 
133 
135 
136  using PanelVectorType = std::vector<QmitkAbstractDataStorageInspector*>;
138 
139  QPushButton* m_FavoriteNodesButton;
140  Ui_QmitkNodeSelectionDialog m_Controls;
141 };
142 #endif // QMITK_NODE_SELECTION_DIALOG_H
QList< mitk::DataNode::Pointer > NodeList
Data management class that handles &#39;was created by&#39; relations.
mitk::NodePredicateBase::ConstPointer m_NodePredicate
QAbstractItemView::SelectionMode SelectionMode
MITK_QT_APP QList< mitk::DataNode::Pointer > GetSelectedNodes(berry::IWorkbenchPartSite::Pointer workbenchPartSite)
mitk::WeakPointer< mitk::DataStorage > m_DataStorage
The common interface for all DataStorage inspector providers.
std::vector< QmitkAbstractDataStorageInspector * > PanelVectorType
Widget that allows to show and edit the content of an mitk::IsoDoseLevel instance.
SelectionCheckFunctionType m_CheckFunction
Ui_QmitkNodeSelectionDialog m_Controls
Interface for evaluation conditions used in the DataStorage class GetSubset() method.
#define MITK_QT_COMMON
std::function< std::string(const NodeList &)> SelectionCheckFunctionType
Helper function that is used to check the given selection for consistency. Returning an empty string ...