Medical Imaging Interaction Toolkit  2025.12.02
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);
38 
44  void SetDataStorage(mitk::DataStorage* dataStorage);
45 
52  void SetNodePredicate(const mitk::NodePredicateBase* nodePredicate);
53 
55 
56  QString GetInvalidInfo() const;
57  QString GetEmptyInfo() const;
58  QString GetPopUpTitel() const;
59  QString GetPopUpHint() const;
60 
61  bool GetSelectionIsOptional() const;
62 
64 
65  using NodeList = QList<mitk::DataNode::Pointer>;
67  using ConstNodeStdVector = std::vector<mitk::DataNode::ConstPointer>;
68 
74 
75  void OnSelectionReceived(const std::string& context, const std::vector<mitk::DataNode::Pointer>& selection) override;
76 
77 Q_SIGNALS:
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:
146 
147 protected:
149  virtual void UpdateInfo() = 0;
150 
155  virtual void OnNodePredicateChanged();
156 
160  virtual void OnDataStorageChanged();
161 
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 
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 
223 
225  mitk::NodePredicateBase::ConstPointer m_NodePredicate;
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
#define MITKQTWIDGETS_EXPORT
Abstract base class for the selection of data from a data storage.
virtual void OnNodeAddedToStorage(const mitk::DataNode *node)
void OnSelectionReceived(const std::string &context, const std::vector< mitk::DataNode::Pointer > &selection) override
Callback method for received selections.
virtual void ReviseSelectionChanged(const NodeList &oldInternalSelection, NodeList &newInternalSelection)
void SetInvalidInfo(QString info)
virtual void OnNodeRemovedFromStorage(const mitk::DataNode *node)
virtual void OnNodeModified(const itk::Object *caller, const itk::EventObject &event)
virtual void OnInternalSelectionChanged()
void SetCurrentInternalSelection(NodeList selectedNodes)
virtual ~QmitkAbstractNodeSelectionWidget() override
const mitk::NodePredicateBase * GetNodePredicate() const
void SetPopUpHint(QString info)
QmitkAbstractNodeSelectionWidget(QWidget *parent=nullptr)
const NodeList & GetCurrentInternalSelection() const
void SetEmptyInfo(QString info)
void SetSelectionIsOptional(bool isOptional)
void SetSelectOnlyVisibleNodes(bool selectOnlyVisibleNodes)
Change the selection modus of the item view's selection model.
void EmitSelection(const NodeList &emissionCandidates)
ConstNodeStdVector GetSelectedNodesStdVector() const
mitk::WeakPointer< mitk::DataStorage > m_DataStorage
void RemoveNodeFromInternalSelection(const mitk::DataNode *node)
void HandleChangeOfInternalSelection(NodeList newInternalSelection)
void SetDataStorage(mitk::DataStorage *dataStorage)
Sets the data storage that will be used / monitored by widget.
NodeList CompileEmitSelection() const
void CurrentSelectionChanged(NodeList nodes)
A signal that will be emitted if the selected node has changed.
std::vector< mitk::DataNode::ConstPointer > ConstNodeStdVector
virtual bool AllowEmissionOfSelection(const NodeList &emissionCandidates) const
void SetNodePredicate(const mitk::NodePredicateBase *nodePredicate)
void SetPopUpTitel(QString info)
mitk::NodePredicateBase::ConstPointer m_NodePredicate
const NodeList & GetCurrentExternalSelection() const
void SetCurrentSelection(NodeList selectedNodes)
Transform a list of data nodes (a selection) into a model selection and set this as a new selection o...
QList< mitk::DataNode::Pointer > NodeList
Class for nodes of the DataTree.
Definition: mitkDataNode.h:64
Data management class that handles 'was created by' relations.
Interface for listening to node selections sent via the INodeSelectionService.
Interface for evaluation conditions used in the DataStorage class GetSubset() method.