Medical Imaging Interaction Toolkit  2024.06.00
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 QmitkAbstractNodeSelectionWidget_h
14 #define QmitkAbstractNodeSelectionWidget_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 
31 {
32  Q_OBJECT
33 
34 public:
35  explicit QmitkAbstractNodeSelectionWidget(QWidget* parent = nullptr);
36  virtual ~QmitkAbstractNodeSelectionWidget() override;
37 
43  void SetDataStorage(mitk::DataStorage* dataStorage);
44 
51  void SetNodePredicate(const mitk::NodePredicateBase* nodePredicate);
52 
53  const mitk::NodePredicateBase* GetNodePredicate() const;
54 
55  QString GetInvalidInfo() const;
56  QString GetEmptyInfo() const;
57  QString GetPopUpTitel() const;
58  QString GetPopUpHint() const;
59 
60  bool GetSelectionIsOptional() const;
61 
62  bool GetSelectOnlyVisibleNodes() const;
63 
64  using NodeList = QList<mitk::DataNode::Pointer>;
66  using ConstNodeStdVector = std::vector<mitk::DataNode::ConstPointer>;
67 
69  NodeList GetSelectedNodes() const;
72  ConstNodeStdVector GetSelectedNodesStdVector() const;
73 
74 Q_SIGNALS:
80  void CurrentSelectionChanged(NodeList nodes);
81 
82 public Q_SLOTS:
94  void SetSelectOnlyVisibleNodes(bool selectOnlyVisibleNodes);
95 
108  void SetCurrentSelection(NodeList selectedNodes);
109 
114  void SetInvalidInfo(QString info);
115 
120  void SetEmptyInfo(QString info);
121 
125  void SetPopUpTitel(QString info);
126 
130  void SetPopUpHint(QString info);
131 
135  void SetSelectionIsOptional(bool isOptional);
136 
137 protected Q_SLOTS:
142  void RemoveNodeFromSelection(const mitk::DataNode* node);
143 
144 protected:
146  virtual void UpdateInfo() = 0;
147 
152  virtual void OnNodePredicateChanged();
153 
157  virtual void OnDataStorageChanged();
158 
162  virtual void OnInternalSelectionChanged();
163 
167  virtual void OnNodeAddedToStorage(const mitk::DataNode* node);
168 
174  virtual void OnNodeRemovedFromStorage(const mitk::DataNode* node);
175 
183  virtual void OnNodeModified(const itk::Object* caller, const itk::EventObject& event);
184 
191  void HandleChangeOfInternalSelection(NodeList newInternalSelection);
192 
196  NodeList CompileEmitSelection() const;
197 
203  virtual void ReviseSelectionChanged(const NodeList& oldInternalSelection, NodeList& newInternalSelection);
204 
210  virtual bool AllowEmissionOfSelection(const NodeList& emissionCandidates) const;
211 
215  void EmitSelection(const NodeList& emissionCandidates);
216 
217  void SetCurrentInternalSelection(NodeList selectedNodes);
218  const NodeList& GetCurrentInternalSelection() const;
219  const NodeList& GetCurrentExternalSelection() const;
220 
223 
224  QString m_InvalidInfo;
225  QString m_EmptyInfo;
226  QString m_PopUpTitel;
227  QString m_PopUpHint;
228 
233 
234 private:
236  void SetDataStorageDeleted();
237 
240  void NodeAddedToStorage(const mitk::DataNode* node);
241 
246  void NodeRemovedFromStorage(const mitk::DataNode* node);
247 
248  void AddNodeObserver(mitk::DataNode* node);
249  void RemoveNodeObserver(mitk::DataNode* node);
250 
251  unsigned long m_DataStorageDeletedTag;
252 
253  NodeList m_CurrentInternalSelection;
254  NodeList m_CurrentExternalSelection;
255 
256  NodeList m_LastEmission;
257  bool m_LastEmissionAllowance;
258 
259  using NodeObserverTagMapType = std::map<const mitk::DataNode*, unsigned long>;
260  NodeObserverTagMapType m_NodeObserverTags;
261 
263  bool m_RecursionGuard;
264 };
265 
266 #endif
QmitkAbstractNodeSelectionWidget
Abstract base class for the selection of data from a data storage.
Definition: QmitkAbstractNodeSelectionWidget.h:30
MITKQTWIDGETS_EXPORT
#define MITKQTWIDGETS_EXPORT
Definition: MitkQtWidgetsExports.h:15
QmitkAbstractNodeSelectionWidget::m_PopUpTitel
QString m_PopUpTitel
Definition: QmitkAbstractNodeSelectionWidget.h:226
QmitkAbstractNodeSelectionWidget::m_SelectOnlyVisibleNodes
bool m_SelectOnlyVisibleNodes
Definition: QmitkAbstractNodeSelectionWidget.h:232
mitkDataStorage.h
QmitkAbstractNodeSelectionWidget::m_IsOptional
bool m_IsOptional
Definition: QmitkAbstractNodeSelectionWidget.h:230
QmitkAbstractNodeSelectionWidget::m_PopUpHint
QString m_PopUpHint
Definition: QmitkAbstractNodeSelectionWidget.h:227
QmitkAbstractNodeSelectionWidget::ConstNodeStdVector
std::vector< mitk::DataNode::ConstPointer > ConstNodeStdVector
Definition: QmitkAbstractNodeSelectionWidget.h:66
itk::SmartPointer< const Self >
mitk::NodePredicateBase
Interface for evaluation conditions used in the DataStorage class GetSubset() method.
Definition: mitkNodePredicateBase.h:35
QmitkAbstractNodeSelectionWidget::m_DataStorage
mitk::WeakPointer< mitk::DataStorage > m_DataStorage
Definition: QmitkAbstractNodeSelectionWidget.h:221
mitkNodePredicateBase.h
QmitkAbstractNodeSelectionWidget::m_EmptyInfo
QString m_EmptyInfo
Definition: QmitkAbstractNodeSelectionWidget.h:225
QmitkAbstractNodeSelectionWidget::m_NodePredicate
mitk::NodePredicateBase::ConstPointer m_NodePredicate
Definition: QmitkAbstractNodeSelectionWidget.h:222
MitkQtWidgetsExports.h
mitk::DataStorage
Data management class that handles 'was created by' relations.
Definition: mitkDataStorage.h:43
QmitkAbstractNodeSelectionWidget::NodeList
QList< mitk::DataNode::Pointer > NodeList
Definition: QmitkAbstractNodeSelectionWidget.h:64
mitkWeakPointer.h
QmitkAbstractNodeSelectionWidget::m_InvalidInfo
QString m_InvalidInfo
Definition: QmitkAbstractNodeSelectionWidget.h:224
mitk::WeakPointer< mitk::DataStorage >
AbstractDataNodeAction::GetSelectedNodes
MITK_QT_APP QList< mitk::DataNode::Pointer > GetSelectedNodes(berry::IWorkbenchPartSite::Pointer workbenchPartSite)
QmitkAbstractDataStorageModel
Definition: QmitkAbstractDataStorageModel.h:40
mitk::DataNode
Class for nodes of the DataTree.
Definition: mitkDataNode.h:63