13 #ifndef mitkDataStorage_h
14 #define mitkDataStorage_h
16 #include <itkObject.h>
17 #include <itkVectorContainer.h>
27 class NodePredicateBase;
59 typedef itk::VectorContainer<unsigned int, DataNode::Pointer>
SetOfObjects;
172 bool onlyDirectSources =
true)
const = 0;
189 bool onlyDirectDerivations =
true)
const = 0;
197 virtual SetOfObjects::ConstPointer
GetAll()
const = 0;
239 bool onlyDirectDerivations =
true)
const;
251 template <
class DataType>
256 DataNode *n = this->GetNamedNode(name);
260 return dynamic_cast<DataType *
>(n->
GetData());
271 template <
class DataType>
274 return this->GetNamedObject<DataType>(name.c_str());
287 template <
class DataType>
290 bool onlyDirectDerivations =
true)
const
294 DataNode *n = this->GetNamedDerivedNode(name, sourceNode, onlyDirectDerivations);
298 return dynamic_cast<DataType *
>(n->
GetData());
314 std::string
GetUniqueName(
const std::string& name,
const DataNode* sourceNode =
nullptr,
bool onlyDirectDerivations =
true)
const;
395 const char *boolPropertyKey =
nullptr,
397 const char *boolPropertyKey2 =
nullptr)
const;
413 const char *boolPropertyKey =
nullptr,
415 const char *boolPropertyKey2 =
nullptr)
const;
429 const char *boolPropertyKey2 =
nullptr)
const;
441 const char *boolPropertyKey =
nullptr);
453 const char *boolPropertyKey2 =
nullptr);
465 const char *boolPropertyKey =
nullptr)
467 return ComputeBoundingBox(
"visible", renderer, boolPropertyKey);
484 const char *boolPropertyKey2);
497 return ComputeTimeBounds(
"visible", renderer, boolPropertyKey);
566 void PrintSelf(std::ostream &os, itk::Indent indent)
const override;
Organizes the rendering process.
Central node class of the MITK data tree, associating a data object with properties and mappers.
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
std::set< std::string > GroupTagList
Set of group tag name strings (keys of GroupTagProperty entries).
Abstract data management class that organizes DataNode objects in a directed acyclic graph.
TimeGeometry::ConstPointer ComputeBoundingGeometry3D(const char *boolPropertyKey=nullptr, const BaseRenderer *renderer=nullptr, const char *boolPropertyKey2=nullptr) const
Compute the axis-parallel bounding geometry of all nodes in the DataStorage.
DataStorageEvent RemoveNodeEvent
Event emitted directly before a node is removed from the DataStorage.
TimeBounds ComputeTimeBounds(const BaseRenderer *renderer, const char *boolPropertyKey)
Compute the time bounds of all visible nodes.
virtual void Add(DataNode *node, const DataStorage::SetOfObjects *parents=nullptr)=0
Add a DataNode to the storage, optionally with parent (source) nodes.
itk::VectorContainer< unsigned int, DataNode::Pointer > SetOfObjects
Container type used as a result set of query operations such as GetSubset().
void Add(DataNode *node, DataNode *parent)
Convenience method to add a node with a single parent.
const DataNode::GroupTagList GetGroupTags() const
Return all group tags used across all nodes in the DataStorage.
DataType * GetNamedDerivedObject(const char *name, const DataNode *sourceNode, bool onlyDirectDerivations=true) const
Convenience method to get the first data object of a given type with a given name,...
Message1< const DataNode * > DataStorageEvent
Event type used for all DataStorage notifications, carrying a const DataNode pointer.
DataNode * GetNode(const NodePredicateBase *condition=nullptr) const
Convenience method to get the first node that matches the predicate condition.
SetOfObjects::ConstPointer FilterSetOfObjects(const SetOfObjects *set, const NodePredicateBase *condition) const
Filters a SetOfObjects by the condition. If no condition is provided, the original set is returned.
std::string GetUniqueName(const std::string &name, const DataNode *sourceNode=nullptr, bool onlyDirectDerivations=true) const
Generate a unique node name by appending an incrementing number if necessary.
DataNode * GetNamedNode(const char *name) const
Convenience method to get the first node with a given name.
void BlockNodeModifiedEvents(bool block)
Enable or disable suppression of ChangedNodeEvent emission.
void EmitRemoveNodeEvent(const DataNode *node)
EmitRemoveNodeEvent emits the RemoveNodeEvent.
std::mutex m_MutexOne
Mutex for thread-safe operations on the DataStorage.
DataType * GetNamedObject(const std::string &name) const
Convenience method to get the first data object of a given type with a given name (std::string overlo...
BoundingBox::Pointer ComputeBoundingBox(const char *boolPropertyKey=nullptr, const BaseRenderer *renderer=nullptr, const char *boolPropertyKey2=nullptr)
Compute the axis-parallel bounding box of all nodes in the DataStorage.
void Add(DataNode *node, const ConstSetOfObjects *parents)
Convenience overload for callers that hold only const node pointers for the parents.
void OnNodeModifiedOrDeleted(const itk::Object *caller, const itk::EventObject &event)
OnNodeModified listens to modified events of DataNodes.
DataStorageEvent ChangedNodeEvent
Event emitted after a managed node has been modified.
void AddListeners(const DataNode *_Node)
Adds a Modified-Listener to the given Node.
DataStorageEvent AddNodeEvent
Event emitted after a new node has been added to the DataStorage.
bool m_BlockNodeModifiedEvents
If this class changes nodes itself, set this to TRUE in order to suppress NodeChangedEvent to be emit...
DataStorageEvent DeleteNodeEvent
Event emitted directly before a managed node is deleted.
DataStorageEvent InteractorChangedNodeEvent
Event emitted when the DataInteractor of a managed node changes.
TimeGeometry::ConstPointer ComputeVisibleBoundingGeometry3D(const BaseRenderer *renderer=nullptr, const char *boolPropertyKey=nullptr)
Compute the axis-parallel bounding geometry of all visible nodes.
std::map< const DataNode *, unsigned long > m_NodeModifiedObserverTags
Saves Modified-Observer Tags for each node in order to remove the event listeners again.
DataNode * GetNamedDerivedNode(const char *name, const DataNode *sourceNode, bool onlyDirectDerivations=true) const
Convenience method to get the first node with a given name that is derived from a source node.
itk::VectorContainer< unsigned int, DataNode::ConstPointer > ConstSetOfObjects
Container type for const node pointers, used for input parameters where nodes are read-only.
virtual SetOfObjects::ConstPointer GetAll() const =0
Return all nodes managed by this DataStorage.
void OnNodeInteractorChanged(itk::Object *caller, const itk::EventObject &event)
virtual SetOfObjects::ConstPointer GetSources(const DataNode *node, const NodePredicateBase *condition=nullptr, bool onlyDirectSources=true) const =0
Return the source (parent) nodes of a given node.
TimeGeometry::ConstPointer ComputeBoundingGeometry3D(const SetOfObjects *input, const char *boolPropertyKey=nullptr, const BaseRenderer *renderer=nullptr, const char *boolPropertyKey2=nullptr) const
Compute the axis-parallel bounding geometry encompassing the given set of nodes.
void Remove(const DataStorage::SetOfObjects *nodes)
Remove a set of nodes from the DataStorage.
mitkClassMacroItkParent(DataStorage, itk::Object)
std::map< const DataNode *, unsigned long > m_NodeInteractorChangedObserverTags
TimeGeometry::ConstPointer ComputeBoundingGeometry3D(const ConstSetOfObjects *input, const char *boolPropertyKey=nullptr, const BaseRenderer *renderer=nullptr, const char *boolPropertyKey2=nullptr) const
Compute the axis-parallel bounding geometry for a set of const node pointers.
TimeBounds ComputeTimeBounds(const char *boolPropertyKey, const BaseRenderer *renderer, const char *boolPropertyKey2)
Compute the time bounds of all nodes in the DataStorage.
void Remove(const ConstSetOfObjects *nodes)
Remove a set of const-pointer nodes from the DataStorage.
std::map< const DataNode *, unsigned long > m_NodeDeleteObserverTags
Saves Delete-Observer Tags for each node in order to remove the event listeners again.
SetOfObjects::ConstPointer GetSubset(const NodePredicateBase *condition) const
Return all nodes that satisfy the given predicate condition.
virtual void Remove(const DataNode *node)=0
Remove a single node from the DataStorage.
BoundingBox::Pointer ComputeVisibleBoundingBox(const BaseRenderer *renderer=nullptr, const char *boolPropertyKey=nullptr)
Compute the bounding box of all visible nodes.
virtual bool Exists(const DataNode *node) const =0
Check whether a node exists in the DataStorage.
void RemoveListeners(const DataNode *_Node)
Removes a Modified-Listener from the given Node.
virtual SetOfObjects::ConstPointer GetDerivations(const DataNode *node, const NodePredicateBase *condition=nullptr, bool onlyDirectDerivations=true) const =0
Return the derived (child) nodes of a given node.
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Prints the contents of the DataStorage to os. Do not call directly, call ->Print() instead.
DataType * GetNamedObject(const char *name) const
Convenience method to get the first data object of a given type with a given name.
void EmitAddNodeEvent(const DataNode *node)
EmitAddNodeEvent emits the AddNodeEvent.
DataNode * GetNamedNode(const std::string &name) const
Convenience method to get the first node with a given name (std::string overload).
Abstract base class for predicates used to filter DataNode objects in DataStorage queries.
Find image slices visible on a given plane.
itk::FixedArray< ScalarType, 2 > TimeBounds
Fixed-size array holding a pair of time bound values [min, max] in milliseconds.
MITKCORE_EXPORT DataNode::Pointer FindTopmostVisibleNode(const DataStorage::SetOfObjects::ConstPointer nodes, const Point3D worldPosition, const TimePointType timePoint, const BaseRenderer *baseRender)
Find the topmost visible node at a given world position and time point.
mitk::ScalarType TimePointType
Type for time point values in milliseconds (ms).