Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::DataStorageSelection Class Reference

Manages a selection of DataNode objects from a DataStorage. More...

#include <mitkDataStorageSelection.h>

Inheritance diagram for mitk::DataStorageSelection:
Collaboration diagram for mitk::DataStorageSelection:

Public Types

typedef std::vector< mitk::DataNode * > Nodes
 
typedef Message1< const mitk::DataNode * > DataNodeEvent
 

Public Member Functions

 mitkClassMacroItkParent (DataStorageSelection, itk::Object)
 
 mitkNewMacro2Param (DataStorageSelection, DataStorage *, bool)
 
 mitkNewMacro3Param (DataStorageSelection, DataStorage *, NodePredicateBase *, bool)
 
 ~DataStorageSelection () override
 
mitk::DataStorage::Pointer GetDataStorage () const
 Get the associated DataStorage. More...
 
mitk::NodePredicateBase::Pointer GetPredicate () const
 Get the predicate used for filtering nodes. More...
 
unsigned int GetSize () const
 Returns the number of nodes in this selection. More...
 
mitk::DataNode::Pointer GetNode (unsigned int index) const
 Get a node at a specific index. More...
 
mitk::DataNode::Pointer GetNode () const
 Returns the first node in the selection. More...
 
std::vector< mitk::DataNode * > GetNodes () const
 Returns a copy of the internal node vector. More...
 
bool DoesAutoAddNodes () const
 Query whether nodes are automatically added from the DataStorage. More...
 
DataStorageSelection & operator= (mitk::DataNode *node)
 Remove all nodes and set a raw pointer as the sole element. More...
 
DataStorageSelection & operator= (mitk::DataNode::Pointer node)
 Remove all nodes and set a smart pointer as the sole element. More...
 
virtual void SetDataStorage (mitk::DataStorage *_DataStorage)
 Set or change the associated DataStorage. More...
 
virtual void SetPredicate (mitk::NodePredicateBase *_Predicate)
 Set or change the filter predicate. More...
 
virtual void AddNode (const mitk::DataNode *node)
 Add a node to the selection if it is not already present. More...
 
virtual void RemoveNode (const mitk::DataNode *node)
 Remove a node from the selection. More...
 
virtual void RemoveAllNodes ()
 Remove all nodes from the selection. More...
 
virtual void ObjectChanged (const itk::Object *caller, const itk::EventObject &event)
 Callback invoked when an observed ITK object is deleted or modified. More...
 

Public Attributes

DataNodeEvent NodeChanged
 Event fired when a node in the selection is modified. More...
 
DataNodeEvent NodeAdded
 Event fired when a node is added to the selection. More...
 
DataNodeEvent NodeRemoved
 Event fired when a node is removed from the selection. More...
 
Message2< const mitk::DataNode *, const mitk::BaseProperty * > PropertyChanged
 Event fired when a property on a selected node changes. More...
 

Protected Member Functions

 DataStorageSelection (mitk::DataStorage *_DataStorage, bool _AutoAddNodes)
 
 DataStorageSelection (mitk::DataStorage *_DataStorage, mitk::NodePredicateBase *_Predicate, bool _AutoAddNodes)
 
mitk::DataNode::Pointer FindNode (const mitk::BaseProperty *prop) const
 
mitk::DataNode::Pointer FindNode (const mitk::PropertyList *propList) const
 
void Reset ()
 
void RemoveListener (mitk::DataNode *node)
 
void AddListener (mitk::DataNode *node)
 

Protected Attributes

mitk::DataStorage * m_DataStorage
 
unsigned int m_DataStorageDeletedTag
 
mitk::NodePredicateBase::Pointer m_Predicate
 
std::vector< mitk::DataNode * > m_Nodes
 
std::map< mitk::DataNode *, unsigned long > m_NodeModifiedObserverTags
 Maps a node to a modified observer tag. More...
 
std::map< mitk::PropertyList *, unsigned long > m_PropertyListModifiedObserverTags
 Maps a propertylist to a modified observer tag. More...
 
std::map< mitk::PropertyList *, unsigned long > m_PropertyListDeletedObserverTags
 Maps a propertylist to a delete observer tag. More...
 
std::map< mitk::BaseProperty *, unsigned long > m_PropertyModifiedObserverTags
 Maps a property to a modified observer tag. More...
 
std::map< mitk::BaseProperty *, unsigned long > m_PropertyDeletedObserverTags
 Maps a property to a delete observer tag. More...
 
bool m_SelfCall
 
bool m_AutoAddNodes
 

Detailed Description

Manages a selection of DataNode objects from a DataStorage.

Observes a DataStorage for node additions and removals, optionally filtering by a NodePredicateBase. Fires events (NodeChanged, NodeAdded, NodeRemoved, PropertyChanged) when the selection or its properties change.

Nodes can be automatically added when they appear in the DataStorage (if AutoAddNodes is enabled), or manually added/removed.

See also
DataStorage, NodePredicateBase

Definition at line 42 of file mitkDataStorageSelection.h.

Member Typedef Documentation

◆ DataNodeEvent

◆ Nodes

Definition at line 45 of file mitkDataStorageSelection.h.

Constructor & Destructor Documentation

◆ DataStorageSelection() [1/2]

mitk::DataStorageSelection::DataStorageSelection ( mitk::DataStorage *  _DataStorage,
bool  _AutoAddNodes 
)
protected

◆ DataStorageSelection() [2/2]

mitk::DataStorageSelection::DataStorageSelection ( mitk::DataStorage *  _DataStorage,
mitk::NodePredicateBase *  _Predicate,
bool  _AutoAddNodes 
)
protected

◆ ~DataStorageSelection()

mitk::DataStorageSelection::~DataStorageSelection ( )
override

Member Function Documentation

◆ AddListener()

void mitk::DataStorageSelection::AddListener ( mitk::DataNode *  node)
protected

Adds listeners for modified/delete event, for the propertylists modified/delete and for the modified/delete event of each property and stores listener tags

◆ AddNode()

virtual void mitk::DataStorageSelection::AddNode ( const mitk::DataNode *  node)
virtual

Add a node to the selection if it is not already present.

Parameters
[in]nodeThe node to add.

◆ DoesAutoAddNodes()

bool mitk::DataStorageSelection::DoesAutoAddNodes ( ) const

Query whether nodes are automatically added from the DataStorage.

Returns
true if auto-add is enabled.

◆ FindNode() [1/2]

mitk::DataNode::Pointer mitk::DataStorageSelection::FindNode ( const mitk::BaseProperty *  prop) const
protected

Find a node in the list by the given prop

◆ FindNode() [2/2]

mitk::DataNode::Pointer mitk::DataStorageSelection::FindNode ( const mitk::PropertyList *  propList) const
protected

Find a node in the list by the given proplist

◆ GetDataStorage()

mitk::DataStorage::Pointer mitk::DataStorageSelection::GetDataStorage ( ) const

Get the associated DataStorage.

Returns
Smart pointer to the DataStorage, or nullptr.

◆ GetNode() [1/2]

mitk::DataNode::Pointer mitk::DataStorageSelection::GetNode ( ) const

Returns the first node in the selection.

Equivalent to calling GetNode(0).

Returns
Smart pointer to the first node, or nullptr if empty.

◆ GetNode() [2/2]

mitk::DataNode::Pointer mitk::DataStorageSelection::GetNode ( unsigned int  index) const

Get a node at a specific index.

Parameters
[in]indexThe zero-based index.
Returns
Smart pointer to the node, or nullptr if index is out of range.

◆ GetNodes()

std::vector<mitk::DataNode *> mitk::DataStorageSelection::GetNodes ( ) const

Returns a copy of the internal node vector.

Returns
A vector of raw DataNode pointers.

◆ GetPredicate()

mitk::NodePredicateBase::Pointer mitk::DataStorageSelection::GetPredicate ( ) const

Get the predicate used for filtering nodes.

Returns
Smart pointer to the predicate, or nullptr if none is set.

◆ GetSize()

unsigned int mitk::DataStorageSelection::GetSize ( ) const

Returns the number of nodes in this selection.

Returns
The node count.

◆ mitkClassMacroItkParent()

mitk::DataStorageSelection::mitkClassMacroItkParent ( DataStorageSelection  ,
itk::Object   
)

◆ mitkNewMacro2Param()

mitk::DataStorageSelection::mitkNewMacro2Param ( DataStorageSelection  ,
DataStorage *  ,
bool   
)

◆ mitkNewMacro3Param()

mitk::DataStorageSelection::mitkNewMacro3Param ( DataStorageSelection  ,
DataStorage *  ,
NodePredicateBase *  ,
bool   
)

◆ ObjectChanged()

virtual void mitk::DataStorageSelection::ObjectChanged ( const itk::Object *  caller,
const itk::EventObject &  event 
)
virtual

Callback invoked when an observed ITK object is deleted or modified.

Parameters
[in]callerThe object that triggered the event.
[in]eventThe event descriptor.

◆ operator=() [1/2]

DataStorageSelection& mitk::DataStorageSelection::operator= ( mitk::DataNode *  node)

Remove all nodes and set a raw pointer as the sole element.

Parameters
[in]nodeThe node to set.
Returns
Reference to this selection.

◆ operator=() [2/2]

DataStorageSelection& mitk::DataStorageSelection::operator= ( mitk::DataNode::Pointer  node)

Remove all nodes and set a smart pointer as the sole element.

Parameters
[in]nodeThe node to set.
Returns
Reference to this selection.

◆ RemoveAllNodes()

virtual void mitk::DataStorageSelection::RemoveAllNodes ( )
virtual

Remove all nodes from the selection.

◆ RemoveListener()

void mitk::DataStorageSelection::RemoveListener ( mitk::DataNode *  node)
protected

If a node is already in this list, all listeners will be removed

◆ RemoveNode()

virtual void mitk::DataStorageSelection::RemoveNode ( const mitk::DataNode *  node)
virtual

Remove a node from the selection.

Parameters
[in]nodeThe node to remove.

◆ Reset()

void mitk::DataStorageSelection::Reset ( )
protected

Removes all nodes and fill the vector again

◆ SetDataStorage()

virtual void mitk::DataStorageSelection::SetDataStorage ( mitk::DataStorage *  _DataStorage)
virtual

Set or change the associated DataStorage.

Parameters
[in]_DataStoragePointer to the new DataStorage, or nullptr to detach.

◆ SetPredicate()

virtual void mitk::DataStorageSelection::SetPredicate ( mitk::NodePredicateBase *  _Predicate)
virtual

Set or change the filter predicate.

Ownership of the predicate is taken by this class.

Parameters
[in]_PredicateThe new predicate, or nullptr to accept all nodes.

Member Data Documentation

◆ m_AutoAddNodes

bool mitk::DataStorageSelection::m_AutoAddNodes
protected

Saves if new nodes are automatically added to this selection

Definition at line 238 of file mitkDataStorageSelection.h.

◆ m_DataStorage

mitk::DataStorage* mitk::DataStorageSelection::m_DataStorage
protected

Pointer to the DataStorage from which the nodes are selected

Definition at line 197 of file mitkDataStorageSelection.h.

◆ m_DataStorageDeletedTag

unsigned int mitk::DataStorageSelection::m_DataStorageDeletedTag
protected

DeleteTag for the DataStorage

Definition at line 201 of file mitkDataStorageSelection.h.

◆ m_NodeModifiedObserverTags

std::map<mitk::DataNode *, unsigned long> mitk::DataStorageSelection::m_NodeModifiedObserverTags
protected

Maps a node to a modified observer tag.

Definition at line 214 of file mitkDataStorageSelection.h.

◆ m_Nodes

std::vector<mitk::DataNode *> mitk::DataStorageSelection::m_Nodes
protected

Holds all selected Nodes.

Definition at line 210 of file mitkDataStorageSelection.h.

◆ m_Predicate

mitk::NodePredicateBase::Pointer mitk::DataStorageSelection::m_Predicate
protected

Holds the predicate that defines this SubSet of Nodes. If m_Predicate is nullptr all Nodes will be selected.

Definition at line 206 of file mitkDataStorageSelection.h.

◆ m_PropertyDeletedObserverTags

std::map<mitk::BaseProperty *, unsigned long> mitk::DataStorageSelection::m_PropertyDeletedObserverTags
protected

Maps a property to a delete observer tag.

Definition at line 230 of file mitkDataStorageSelection.h.

◆ m_PropertyListDeletedObserverTags

std::map<mitk::PropertyList *, unsigned long> mitk::DataStorageSelection::m_PropertyListDeletedObserverTags
protected

Maps a propertylist to a delete observer tag.

Definition at line 222 of file mitkDataStorageSelection.h.

◆ m_PropertyListModifiedObserverTags

std::map<mitk::PropertyList *, unsigned long> mitk::DataStorageSelection::m_PropertyListModifiedObserverTags
protected

Maps a propertylist to a modified observer tag.

Definition at line 218 of file mitkDataStorageSelection.h.

◆ m_PropertyModifiedObserverTags

std::map<mitk::BaseProperty *, unsigned long> mitk::DataStorageSelection::m_PropertyModifiedObserverTags
protected

Maps a property to a modified observer tag.

Definition at line 226 of file mitkDataStorageSelection.h.

◆ m_SelfCall

bool mitk::DataStorageSelection::m_SelfCall
protected

If set to true no event processing will be performed

Definition at line 234 of file mitkDataStorageSelection.h.

◆ NodeAdded

DataNodeEvent mitk::DataStorageSelection::NodeAdded

Event fired when a node is added to the selection.

Definition at line 51 of file mitkDataStorageSelection.h.

◆ NodeChanged

DataNodeEvent mitk::DataStorageSelection::NodeChanged

Event fired when a node in the selection is modified.

Definition at line 49 of file mitkDataStorageSelection.h.

◆ NodeRemoved

DataNodeEvent mitk::DataStorageSelection::NodeRemoved

Event fired when a node is removed from the selection.

Definition at line 53 of file mitkDataStorageSelection.h.

◆ PropertyChanged

Message2<const mitk::DataNode *, const mitk::BaseProperty *> mitk::DataStorageSelection::PropertyChanged

Event fired when a property on a selected node changes.

Definition at line 55 of file mitkDataStorageSelection.h.


The documentation for this class was generated from the following file: