Medical Imaging Interaction Toolkit  2025.12.02
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 
13 #ifndef QmitkDataStorageComboBox_h
14 #define QmitkDataStorageComboBox_h
15 
16 #include <MitkQtWidgetsExports.h>
17 
18 // Own Includes
19 #include "mitkDataNode.h"
20 #include "mitkDataStorage.h"
21 #include "mitkNodePredicateBase.h"
22 #include "mitkWeakPointer.h"
23 
24 // Toolkit Includes
25 #include <QComboBox>
26 #include <map>
27 
39 {
40  Q_OBJECT
41 
42 public:
46  QmitkDataStorageComboBox(QWidget *parent = nullptr, bool autoSelectNewNodes = false);
47 
52  const mitk::NodePredicateBase *predicate,
53  QWidget *parent = nullptr,
54  bool autoSelectNewNodes = false);
55 
60 
64  virtual int Find(const mitk::DataNode *dataNode) const;
65 
66 public:
70  mitk::DataStorage::Pointer GetDataStorage() const;
74  const mitk::NodePredicateBase::ConstPointer GetPredicate() const;
78  virtual mitk::DataNode::Pointer GetNode(int index) const;
82  virtual mitk::DataNode::Pointer GetSelectedNode() const;
86  mitk::DataStorage::SetOfObjects::ConstPointer GetNodes() const;
91  virtual bool GetAutoSelectNewItems();
92 
93 public:
98  void SetDataStorage(mitk::DataStorage *dataStorage);
103  void SetPredicate(const mitk::NodePredicateBase *predicate);
107  virtual void AddNode(const mitk::DataNode *dataNode);
112  virtual void RemoveNode(int index);
116  virtual void RemoveNode(const mitk::DataNode *dataNode);
121  virtual void SetNode(int index, const mitk::DataNode *dataNode);
126  virtual void SetNode(const mitk::DataNode *dataNode, const mitk::DataNode *otherDataNode);
130  virtual void SetAutoSelectNewItems(bool autoSelectNewItems);
134  virtual void OnPropertyListChanged(const itk::Object *caller, const itk::EventObject &event);
135 
136 signals:
141 
142 protected:
146  bool HasIndex(unsigned int index) const;
147 
148 protected slots:
153 
154 public slots:
158  void SetSelectedNode(const mitk::DataNode::Pointer& node);
159 
160 protected:
171  virtual void InsertNode(int index, const mitk::DataNode *dataNode);
172 
176  void Init();
177 
181  virtual void Reset();
182 
183  void RemoveNodeAndPropertyLists(int index);
184 
186 
187 protected:
193 
198  mitk::NodePredicateBase::ConstPointer m_Predicate;
199 
203  std::vector<mitk::DataNode *> m_Nodes;
204 
209 
214 
219 
223 };
224 
225 #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 *)
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)
std::vector< long > m_BaseDatapropertyListObserverTags
Holds the tags of the base data property observers.
Class for nodes of the DataTree.
Definition: mitkDataNode.h:64
Data management class that handles 'was created by' relations.
Interface for evaluation conditions used in the DataStorage class GetSubset() method.
Key-value list holding instances of BaseProperty.