Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkDataStorageSelection.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 mitkDataStorageSelection_h
14 #define mitkDataStorageSelection_h
15 
17 
18 #include <mitkCommon.h>
19 #include <mitkDataStorage.h>
20 #include <mitkNodePredicateBase.h>
21 
22 #include <set>
23 
24 namespace mitk
25 {
26  class BaseProperty;
27  class PropertyList;
28 
42  class MITKDATATYPESEXT_EXPORT DataStorageSelection : public itk::Object
43  {
44  public:
45  typedef std::vector<mitk::DataNode *> Nodes;
47 
56 
58 
61 
62  protected:
63  DataStorageSelection(mitk::DataStorage *_DataStorage, bool _AutoAddNodes);
64  DataStorageSelection(mitk::DataStorage *_DataStorage, mitk::NodePredicateBase *_Predicate, bool _AutoAddNodes);
65 
66  public:
68 
73  mitk::DataStorage::Pointer GetDataStorage() const;
74 
79  mitk::NodePredicateBase::Pointer GetPredicate() const;
80 
85  unsigned int GetSize() const;
86 
92  mitk::DataNode::Pointer GetNode(unsigned int index) const;
93 
101  mitk::DataNode::Pointer GetNode() const;
102 
107  std::vector<mitk::DataNode *> GetNodes() const;
108 
113  bool DoesAutoAddNodes() const;
114 
115  public:
122 
128  DataStorageSelection &operator=(mitk::DataNode::Pointer node);
129 
134  virtual void SetDataStorage(mitk::DataStorage *_DataStorage);
135 
143  virtual void SetPredicate(mitk::NodePredicateBase *_Predicate);
144 
149  virtual void AddNode(const mitk::DataNode *node);
150 
155  virtual void RemoveNode(const mitk::DataNode *node);
156 
160  virtual void RemoveAllNodes();
161 
167  virtual void ObjectChanged(const itk::Object *caller, const itk::EventObject &event);
168 
169  protected:
173  mitk::DataNode::Pointer FindNode(const mitk::BaseProperty *prop) const;
177  mitk::DataNode::Pointer FindNode(const mitk::PropertyList *propList) const;
181  void Reset();
192 
193  protected:
206  mitk::NodePredicateBase::Pointer m_Predicate;
210  std::vector<mitk::DataNode *> m_Nodes;
214  std::map<mitk::DataNode *, unsigned long> m_NodeModifiedObserverTags;
218  std::map<mitk::PropertyList *, unsigned long> m_PropertyListModifiedObserverTags;
222  std::map<mitk::PropertyList *, unsigned long> m_PropertyListDeletedObserverTags;
226  std::map<mitk::BaseProperty *, unsigned long> m_PropertyModifiedObserverTags;
230  std::map<mitk::BaseProperty *, unsigned long> m_PropertyDeletedObserverTags;
239  };
240 }
241 
242 #endif
#define MITKDATATYPESEXT_EXPORT
Abstract base class for properties.
Central node class of the MITK data tree, associating a data object with properties and mappers.
Definition: mitkDataNode.h:72
Manages a selection of DataNode objects from a DataStorage.
mitk::DataNode::Pointer GetNode() const
Returns the first node in the selection.
bool DoesAutoAddNodes() const
Query whether nodes are automatically added from the DataStorage.
mitk::DataStorage::Pointer GetDataStorage() const
Get the associated DataStorage.
std::map< mitk::PropertyList *, unsigned long > m_PropertyListDeletedObserverTags
Maps a propertylist to a delete observer tag.
virtual void AddNode(const mitk::DataNode *node)
Add a node to the selection if it is not already present.
Message2< const mitk::DataNode *, const mitk::BaseProperty * > PropertyChanged
Event fired when a property on a selected node changes.
DataStorageSelection(mitk::DataStorage *_DataStorage, bool _AutoAddNodes)
mitk::NodePredicateBase::Pointer GetPredicate() const
Get the predicate used for filtering nodes.
virtual void RemoveAllNodes()
Remove all nodes from the selection.
std::map< mitk::PropertyList *, unsigned long > m_PropertyListModifiedObserverTags
Maps a propertylist to a modified observer tag.
virtual void SetDataStorage(mitk::DataStorage *_DataStorage)
Set or change the associated DataStorage.
std::vector< mitk::DataNode * > Nodes
mitk::DataNode::Pointer GetNode(unsigned int index) const
Get a node at a specific index.
DataStorageSelection & operator=(mitk::DataNode *node)
Remove all nodes and set a raw pointer as the sole element.
std::map< mitk::DataNode *, unsigned long > m_NodeModifiedObserverTags
Maps a node to a modified observer tag.
void AddListener(mitk::DataNode *node)
mitk::DataNode::Pointer FindNode(const mitk::PropertyList *propList) const
void RemoveListener(mitk::DataNode *node)
mitkClassMacroItkParent(DataStorageSelection, itk::Object)
virtual void RemoveNode(const mitk::DataNode *node)
Remove a node from the selection.
mitkNewMacro3Param(DataStorageSelection, DataStorage *, NodePredicateBase *, bool)
std::vector< mitk::DataNode * > GetNodes() const
Returns a copy of the internal node vector.
DataNodeEvent NodeChanged
Event fired when a node in the selection is modified.
virtual void SetPredicate(mitk::NodePredicateBase *_Predicate)
Set or change the filter predicate.
std::map< mitk::BaseProperty *, unsigned long > m_PropertyDeletedObserverTags
Maps a property to a delete observer tag.
mitk::DataNode::Pointer FindNode(const mitk::BaseProperty *prop) const
std::vector< mitk::DataNode * > m_Nodes
DataNodeEvent NodeAdded
Event fired when a node is added to the selection.
mitk::NodePredicateBase::Pointer m_Predicate
DataNodeEvent NodeRemoved
Event fired when a node is removed from the selection.
DataStorageSelection & operator=(mitk::DataNode::Pointer node)
Remove all nodes and set a smart pointer as the sole element.
mitkNewMacro2Param(DataStorageSelection, DataStorage *, bool)
std::map< mitk::BaseProperty *, unsigned long > m_PropertyModifiedObserverTags
Maps a property to a modified observer tag.
unsigned int GetSize() const
Returns the number of nodes in this selection.
DataStorageSelection(mitk::DataStorage *_DataStorage, mitk::NodePredicateBase *_Predicate, bool _AutoAddNodes)
Message1< const mitk::DataNode * > DataNodeEvent
virtual void ObjectChanged(const itk::Object *caller, const itk::EventObject &event)
Callback invoked when an observed ITK object is deleted or modified.
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.
Find image slices visible on a given plane.