Medical Imaging Interaction Toolkit  2024.12.99-0da743f6
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>
20 #include <mitkWeakPointer.h>
21 #include <mitkNodePredicateBase.h>
22 
23 #include <QWidget>
24 
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  void OnSelectionReceived(const std::string& context, const std::vector<mitk::DataNode::Pointer>& selection) override;
76 
77 Q_SIGNALS:
83  void CurrentSelectionChanged(NodeList nodes);
84 
85 public Q_SLOTS:
97  void SetSelectOnlyVisibleNodes(bool selectOnlyVisibleNodes);
98 
111  void SetCurrentSelection(NodeList selectedNodes);
112 
117  void SetInvalidInfo(QString info);
118 
123  void SetEmptyInfo(QString info);
124 
128  void SetPopUpTitel(QString info);
129 
133  void SetPopUpHint(QString info);
134 
138  void SetSelectionIsOptional(bool isOptional);
139 
140 protected Q_SLOTS:
145  void RemoveNodeFromSelection(const mitk::DataNode* node);
146 
147 protected:
149  virtual void UpdateInfo() = 0;
150 
155  virtual void OnNodePredicateChanged();
156 
160  virtual void OnDataStorageChanged();
161 
165  virtual void OnInternalSelectionChanged();
166 
170  virtual void OnNodeAddedToStorage(const mitk::DataNode* node);
171 
177  virtual void OnNodeRemovedFromStorage(const mitk::DataNode* node);
178 
186  virtual void OnNodeModified(const itk::Object* caller, const itk::EventObject& event);
187 
194  void HandleChangeOfInternalSelection(NodeList newInternalSelection);
195 
199  NodeList CompileEmitSelection() const;
200 
206  virtual void ReviseSelectionChanged(const NodeList& oldInternalSelection, NodeList& newInternalSelection);
207 
213  virtual bool AllowEmissionOfSelection(const NodeList& emissionCandidates) const;
214 
218  void EmitSelection(const NodeList& emissionCandidates);
219 
220  void SetCurrentInternalSelection(NodeList selectedNodes);
221  const NodeList& GetCurrentInternalSelection() const;
222  const NodeList& GetCurrentExternalSelection() const;
223 
226 
227  QString m_InvalidInfo;
228  QString m_EmptyInfo;
229  QString m_PopUpTitel;
230  QString m_PopUpHint;
231 
236 
237 private:
239  void SetDataStorageDeleted();
240 
243  void NodeAddedToStorage(const mitk::DataNode* node);
244 
249  void NodeRemovedFromStorage(const mitk::DataNode* node);
250 
251  void AddNodeObserver(mitk::DataNode* node);
252  void RemoveNodeObserver(mitk::DataNode* node);
253 
254  unsigned long m_DataStorageDeletedTag;
255 
256  NodeList m_CurrentInternalSelection;
257  NodeList m_CurrentExternalSelection;
258 
259  NodeList m_LastEmission;
260  bool m_LastEmissionAllowance;
261 
262  using NodeObserverTagMapType = std::map<const mitk::DataNode*, unsigned long>;
263  NodeObserverTagMapType m_NodeObserverTags;
264 
266  bool m_RecursionGuard;
267 };
268 
269 #endif
QmitkAbstractNodeSelectionWidget
Abstract base class for the selection of data from a data storage.
Definition: QmitkAbstractNodeSelectionWidget.h:31
mitk::INodeSelectionListener::OnSelectionReceived
virtual void OnSelectionReceived(const std::string &context, const std::vector< mitk::DataNode::Pointer > &selection)=0
Callback method for received selections.
MITKQTWIDGETS_EXPORT
#define MITKQTWIDGETS_EXPORT
Definition: MitkQtWidgetsExports.h:15
mitk::INodeSelectionListener
Interface for listening to node selections sent via the INodeSelectionService.
Definition: mitkINodeSelectionListener.h:26
QmitkAbstractNodeSelectionWidget::m_PopUpTitel
QString m_PopUpTitel
Definition: QmitkAbstractNodeSelectionWidget.h:229
QmitkAbstractNodeSelectionWidget::m_SelectOnlyVisibleNodes
bool m_SelectOnlyVisibleNodes
Definition: QmitkAbstractNodeSelectionWidget.h:235
mitkDataStorage.h
QmitkAbstractNodeSelectionWidget::m_IsOptional
bool m_IsOptional
Definition: QmitkAbstractNodeSelectionWidget.h:233
QmitkAbstractNodeSelectionWidget::m_PopUpHint
QString m_PopUpHint
Definition: QmitkAbstractNodeSelectionWidget.h:230
QmitkAbstractNodeSelectionWidget::ConstNodeStdVector
std::vector< mitk::DataNode::ConstPointer > ConstNodeStdVector
Definition: QmitkAbstractNodeSelectionWidget.h:67
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:224
mitkNodePredicateBase.h
mitkINodeSelectionListener.h
QmitkAbstractNodeSelectionWidget::m_EmptyInfo
QString m_EmptyInfo
Definition: QmitkAbstractNodeSelectionWidget.h:228
QmitkAbstractNodeSelectionWidget::m_NodePredicate
mitk::NodePredicateBase::ConstPointer m_NodePredicate
Definition: QmitkAbstractNodeSelectionWidget.h:225
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:65
mitkWeakPointer.h
QmitkAbstractNodeSelectionWidget::m_InvalidInfo
QString m_InvalidInfo
Definition: QmitkAbstractNodeSelectionWidget.h:227
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