Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
QmitkDataStorageComboBox.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 
20 #ifndef QmitkDataStorageComboBox_h
21 #define QmitkDataStorageComboBox_h
22 
23 #include <MitkQtWidgetsExports.h>
24 
25 // Own Includes
26 #include <mitkDataNode.h>
27 #include <mitkDataStorage.h>
28 #include <mitkNodePredicateBase.h>
29 #include <mitkWeakPointer.h>
30 
31 // Toolkit Includes
32 #include <QComboBox>
33 #include <map>
34 
45 {
46  Q_OBJECT
47 
48 public:
52  QmitkDataStorageComboBox(QWidget *parent = nullptr, bool autoSelectNewNodes = false);
53 
58  const mitk::NodePredicateBase *predicate,
59  QWidget *parent = nullptr,
60  bool autoSelectNewNodes = false);
61 
66 
70  virtual int Find(const mitk::DataNode *dataNode) const;
71 
72 public:
76  mitk::DataStorage::Pointer GetDataStorage() const;
80  const mitk::NodePredicateBase::ConstPointer GetPredicate() const;
84  virtual mitk::DataNode::Pointer GetNode(int index) const;
88  virtual mitk::DataNode::Pointer GetSelectedNode() const;
92  mitk::DataStorage::SetOfObjects::ConstPointer GetNodes() const;
97  virtual bool GetAutoSelectNewItems();
98 
99 public:
104  void SetDataStorage(mitk::DataStorage *dataStorage);
109  void SetPredicate(const mitk::NodePredicateBase *predicate);
113  virtual void AddNode(const mitk::DataNode *dataNode);
118  virtual void RemoveNode(int index);
122  virtual void RemoveNode(const mitk::DataNode *dataNode);
127  virtual void SetNode(int index, const mitk::DataNode *dataNode);
132  virtual void SetNode(const mitk::DataNode *dataNode, const mitk::DataNode *otherDataNode);
136  virtual void SetAutoSelectNewItems(bool autoSelectNewItems);
140  virtual void OnPropertyListChanged(const itk::Object *caller, const itk::EventObject &event);
141 
142 signals:
147 
148 protected:
152  bool HasIndex(unsigned int index) const;
153 
154 protected slots:
159 
160 public slots:
164  void SetSelectedNode(const mitk::DataNode::Pointer& node);
165 
166 protected:
177  virtual void InsertNode(int index, const mitk::DataNode *dataNode);
178 
182  void Init();
183 
187  virtual void Reset();
188 
192  void RemoveNodeAndPropertyLists(int index);
193 
198 
199 protected:
205 
210  mitk::NodePredicateBase::ConstPointer m_Predicate;
211 
215  std::vector<mitk::DataNode *> m_Nodes;
216 
221 
226 
231 
235 };
236 
237 #endif
#define MITKQTWIDGETS_EXPORT
Displays all or a subset (defined by a predicate) of nodes of the Data Storage.
bool HasIndex(unsigned int index) const
Checks if the given index is within the range of the m_Nodes vector.
void Init()
Init-function this class with the given data storage and predicate. This function is called by all ct...
virtual void RemoveNode(const mitk::DataNode *dataNode)
bool m_AutoSelectNewNodes
If set to "true" new Nodes will be automatically selected.
mitk::DataStorage::SetOfObjects::ConstPointer GetNodes() const
Returns all nodes that are stored in this combobox.
virtual void SetNode(int index, const mitk::DataNode *dataNode)
virtual int Find(const mitk::DataNode *dataNode) const
Searches for a given node and returns a valid index or -1 if the node was not found.
virtual void SetNode(const mitk::DataNode *dataNode, const mitk::DataNode *otherDataNode)
virtual mitk::DataNode::Pointer GetNode(int index) const
Returns the dataNode at Index index or 0 if the index is out of bounds.
virtual bool GetAutoSelectNewItems()
const mitk::NodePredicateBase::ConstPointer GetPredicate() const
Return the predicate (may be nullptr) that is responsible for the dataNode selection of this ComboBox...
mitk::NodePredicateBase::ConstPointer m_Predicate
Holds the predicate that is responsible for the dataNode selection of this ComboBox....
mitk::DataStorage::Pointer GetDataStorage() const
Get the DataStorage this ComboBox listens to.
void SetSelectedNode(const mitk::DataNode::Pointer &node)
Slot for signal when user wants to set a node as current selected node.
~QmitkDataStorageComboBox() override
Standard Dtor. Nothing to do here.
std::vector< long > m_DataNodePropertyListObserverTags
Holds the tags of the data node property observers.
void SetDataStorage(mitk::DataStorage *dataStorage)
Set the DataStorage this ComboBox should listen to.
mitk::WeakPointer< mitk::DataStorage > m_DataStorage
void OnCurrentIndexChanged(int)
Slot for signal when the user selects another item.
virtual void RemoveNode(int index)
virtual void Reset()
Reset function whenever data storage or predicate changes.
void SetPredicate(const mitk::NodePredicateBase *predicate)
Set the predicate for this ComboBox. (QmitkDataStorageComboBox is now owner of the predicate)
std::vector< mitk::DataNode * > m_Nodes
QmitkDataStorageComboBox(QWidget *parent=nullptr, bool autoSelectNewNodes=false)
Ctor for an empty combobox. Use setDataStorage and setPredicate afterwards.
virtual mitk::DataNode::Pointer GetSelectedNode() const
Returns the selected dataNode or 0 if there is none.
void OnSelectionChanged(const mitk::DataNode *)
Throw a signal when the data node selection changed.
virtual void UpdateComboBoxText(const mitk::PropertyList *)
Update the combo box display text when a node's property list changes.
bool m_BlockEvents
Event function guard. Each function which is called by an event mechanism first checks if this is tru...
virtual void InsertNode(int index, const mitk::DataNode *dataNode)
Inserts a new node at the given index. If the index does not exist, the data node is simply appended ...
QmitkDataStorageComboBox(mitk::DataStorage *dataStorage, const mitk::NodePredicateBase *predicate, QWidget *parent=nullptr, bool autoSelectNewNodes=false)
Ctor for constructing QmitkDataStorageComboBox with given DataStorageComboBox and given predicate.
virtual void AddNode(const mitk::DataNode *dataNode)
virtual void OnPropertyListChanged(const itk::Object *caller, const itk::EventObject &event)
Called when the name property of the node was modified.
virtual void SetAutoSelectNewItems(bool autoSelectNewItems)
void RemoveNodeAndPropertyLists(int index)
Remove the node at the given index and unregister its property list observers.
std::vector< long > m_BaseDatapropertyListObserverTags
Holds the tags of the base data property observers.
Central node class of the MITK data tree, associating a data object with properties and mappers.
Definition: mitkDataNode.h:72
Abstract data management class that organizes DataNode objects in a directed acyclic graph.
Abstract base class for predicates used to filter DataNode objects in DataStorage queries.
Key-value list holding instances of BaseProperty.