Medical Imaging Interaction Toolkit  2022.04.99-01b95b17
Medical Imaging Interaction Toolkit
QmitkAbstractNodeSelectionWidget.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_ABSTRACT_NODE_SELECTION_WIDGET_H
14 #define QMITK_ABSTRACT_NODE_SELECTION_WIDGET_H
15 
16 #include <MitkQtWidgetsExports.h>
17 
18 #include <mitkDataStorage.h>
19 #include <mitkWeakPointer.h>
20 #include <mitkNodePredicateBase.h>
21 
22 #include <QWidget>
23 
25 class QAbstractItemVew;
26 
32 {
33  Q_OBJECT
34 
35 public:
36  explicit QmitkAbstractNodeSelectionWidget(QWidget* parent = nullptr);
37  virtual ~QmitkAbstractNodeSelectionWidget() override;
38 
44  void SetDataStorage(mitk::DataStorage* dataStorage);
45 
52  void SetNodePredicate(const mitk::NodePredicateBase* nodePredicate);
53 
54  const mitk::NodePredicateBase* GetNodePredicate() const;
55 
56  QString GetInvalidInfo() const;
57  QString GetEmptyInfo() const;
58  QString GetPopUpTitel() const;
59  QString GetPopUpHint() const;
60 
61  bool GetSelectionIsOptional() const;
62 
63  bool GetSelectOnlyVisibleNodes() const;
64 
65  using NodeList = QList<mitk::DataNode::Pointer>;
67  using ConstNodeStdVector = std::vector<mitk::DataNode::ConstPointer>;
68 
70  NodeList GetSelectedNodes() const;
73  ConstNodeStdVector GetSelectedNodesStdVector() const;
74 
75 Q_SIGNALS:
81  void CurrentSelectionChanged(NodeList nodes);
82 
83 public Q_SLOTS:
95  void SetSelectOnlyVisibleNodes(bool selectOnlyVisibleNodes);
96 
109  void SetCurrentSelection(NodeList selectedNodes);
110 
115  void SetInvalidInfo(QString info);
116 
121  void SetEmptyInfo(QString info);
122 
126  void SetPopUpTitel(QString info);
127 
131  void SetPopUpHint(QString info);
132 
136  void SetSelectionIsOptional(bool isOptional);
137 
138 protected Q_SLOTS:
143  void RemoveNodeFromSelection(const mitk::DataNode* node);
144 
145 protected:
147  virtual void UpdateInfo() = 0;
148 
153  virtual void OnNodePredicateChanged();
154 
158  virtual void OnDataStorageChanged();
159 
163  virtual void OnInternalSelectionChanged();
164 
168  virtual void OnNodeAddedToStorage(const mitk::DataNode* node);
169 
174  virtual void OnNodeRemovedFromStorage(const mitk::DataNode* node);
175 
182  void HandleChangeOfInternalSelection(NodeList newInternalSelection);
183 
187  NodeList CompileEmitSelection() const;
188 
194  virtual void ReviseSelectionChanged(const NodeList& oldInternalSelection, NodeList& newInternalSelection);
195 
201  virtual bool AllowEmissionOfSelection(const NodeList& emissionCandidates) const;
202 
206  void EmitSelection(const NodeList& emissionCandidates);
207 
208  void SetCurrentInternalSelection(NodeList selectedNodes);
209  const NodeList& GetCurrentInternalSelection() const;
210  const NodeList& GetCurrentExternalSelection() const;
211 
214 
215  QString m_InvalidInfo;
216  QString m_EmptyInfo;
217  QString m_PopUpTitel;
218  QString m_PopUpHint;
219 
224 
225 private:
227  void SetDataStorageDeleted();
228 
231  void NodeAddedToStorage(const mitk::DataNode* node);
232 
237  void NodeRemovedFromStorage(const mitk::DataNode* node);
238 
239  void OnNodeModified(const itk::Object * /*caller*/, const itk::EventObject &);
240 
241  void AddNodeObserver(mitk::DataNode* node);
242  void RemoveNodeObserver(mitk::DataNode* node);
243 
244  unsigned long m_DataStorageDeletedTag;
245 
246  NodeList m_CurrentInternalSelection;
247  NodeList m_CurrentExternalSelection;
248 
249  NodeList m_LastEmission;
250  bool m_LastEmissionAllowance;
251 
252  using NodeObserverTagMapType = std::map<const mitk::DataNode*, unsigned long>;
253  NodeObserverTagMapType m_NodeObserverTags;
254 
256  bool m_RecursionGuard;
257 };
258 
259 #endif // QMITK_ABSTRACT_NODE_SELECTION_WIDGET_H
Data management class that handles &#39;was created by&#39; relations.
QList< mitk::DataNode::Pointer > NodeList
#define MITKQTWIDGETS_EXPORT
mitk::WeakPointer< mitk::DataStorage > m_DataStorage
std::vector< mitk::DataNode::ConstPointer > ConstNodeStdVector
mitk::NodePredicateBase::ConstPointer m_NodePredicate
Interface for evaluation conditions used in the DataStorage class GetSubset() method.
Abstract base class for the selection of data from a data storage.
MITK_QT_APP QList< mitk::DataNode::Pointer > GetSelectedNodes(berry::IWorkbenchPartSite::Pointer workbenchPartSite)
Class for nodes of the DataTree.
Definition: mitkDataNode.h:63