Data management class that handles 'was created by' relations. More...
#include <mitkDataStorage.h>
Public Types | |
typedef DataStorage | Self |
typedef itk::Object | Superclass |
typedef itk::SmartPointer< Self > | Pointer |
typedef itk::SmartPointer < const Self > | ConstPointer |
typedef itk::VectorContainer < unsigned int, mitk::DataNode::Pointer > | SetOfObjects |
A Container of objects that is used as a result set of GetSubset() query operations (Set of SmartPointers to DataNodes). | |
typedef Message1< const mitk::DataNode * > | DataStorageEvent |
Public Member Functions | |
virtual const char * | GetClassName () const |
virtual void | Add (mitk::DataNode *node, const mitk::DataStorage::SetOfObjects *parents=NULL)=0 |
Adds a DataNode containing a data object to its internal storage. | |
void | Add (mitk::DataNode *node, mitk::DataNode *parent) |
Convenience method to add a node that has one parent. | |
virtual void | Remove (const mitk::DataNode *node)=0 |
Removes node from the DataStorage. | |
virtual bool | Exists (const mitk::DataNode *node) const =0 |
Checks if a node exists in the DataStorage. | |
void | Remove (const mitk::DataStorage::SetOfObjects *nodes) |
Removes a set of nodes from the DataStorage. | |
SetOfObjects::ConstPointer | GetSubset (const NodePredicateBase *condition) const |
returns a set of data objects that meet the given condition(s) | |
virtual SetOfObjects::ConstPointer | GetSources (const mitk::DataNode *node, const NodePredicateBase *condition=NULL, bool onlyDirectSources=true) const =0 |
returns a set of source objects for a given node that meet the given condition(s). | |
virtual SetOfObjects::ConstPointer | GetDerivations (const mitk::DataNode *node, const NodePredicateBase *condition=NULL, bool onlyDirectDerivations=true) const =0 |
returns a set of derived objects for a given node. | |
virtual SetOfObjects::ConstPointer | GetAll () const =0 |
returns a set of all data objects that are stored in the data storage | |
mitk::DataNode * | GetNode (const NodePredicateBase *condition=NULL) const |
Convenience method to get the first node that matches the predicate condition. | |
mitk::DataNode * | GetNamedNode (const char *name) const |
Convenience method to get the first node with a given name. | |
mitk::DataNode * | GetNamedNode (const std::string name) const |
Convenience method to get the first node with a given name. | |
mitk::DataNode * | GetNamedDerivedNode (const char *name, const mitk::DataNode *sourceNode, bool onlyDirectDerivations=true) const |
Convenience method to get the first node with a given name that is derived from sourceNode. | |
template<class DataType > | |
DataType * | GetNamedObject (const char *name) const |
Convenience method to get the first data object of a given data type with a given name. | |
template<class DataType > | |
DataType * | GetNamedObject (const std::string name) const |
Convenience method to get the first data object of a given data type with a given name. | |
template<class DataType > | |
DataType * | GetNamedDerivedObject (const char *name, const mitk::DataNode *sourceNode, bool onlyDirectDerivations=true) const |
Convenience method to get the first data object of a given data type with a given name that is derived from a specific node. | |
const DataNode::GroupTagList | GetGroupTags () const |
Returns a list of used grouptags. | |
mitk::TimeSlicedGeometry::Pointer | ComputeBoundingGeometry3D (const SetOfObjects *input, const char *boolPropertyKey=NULL, mitk::BaseRenderer *renderer=NULL, const char *boolPropertyKey2=NULL) |
Compute the axis-parallel bounding geometry of the input objects. | |
mitk::TimeSlicedGeometry::Pointer | ComputeBoundingGeometry3D (const char *boolPropertyKey=NULL, mitk::BaseRenderer *renderer=NULL, const char *boolPropertyKey2=NULL) |
Compute the axis-parallel bounding geometry of the data tree (bounding box, minimal spacing of the considered nodes, live-span) | |
mitk::TimeSlicedGeometry::Pointer | ComputeVisibleBoundingGeometry3D (mitk::BaseRenderer *renderer=NULL, const char *boolPropertyKey=NULL) |
Compute the axis-parallel bounding geometry of all visible parts of the data tree bounding box, minimal spacing of the considered nodes, live-span) | |
mitk::BoundingBox::Pointer | ComputeBoundingBox (const char *boolPropertyKey=NULL, mitk::BaseRenderer *renderer=NULL, const char *boolPropertyKey2=NULL) |
Compute the bounding box of data tree structure it -> an iterator to a data tree structure. | |
mitk::BoundingBox::Pointer | ComputeVisibleBoundingBox (mitk::BaseRenderer *renderer=NULL, const char *boolPropertyKey=NULL) |
Compute the bounding box of all visible parts of the data tree structure, for general rendering or renderer specific visibility property checking. | |
mitk::TimeBounds | ComputeTimeBounds (const char *boolPropertyKey, mitk::BaseRenderer *renderer, const char *boolPropertyKey2) |
Compute the time-bounds of the contents of a data tree structure. | |
mitk::TimeBounds | ComputeTimeBounds (mitk::BaseRenderer *renderer, const char *boolPropertyKey) |
Compute the time-bounds of all visible parts of the data tree structure, for general. | |
Public Attributes | |
itk::SimpleFastMutexLock | m_MutexOne |
DataStorageEvent | AddNodeEvent |
AddEvent is emitted whenever a new node has been added to the DataStorage. | |
DataStorageEvent | RemoveNodeEvent |
RemoveEvent is emitted directly before a node is removed from the DataStorage. | |
DataStorageEvent | ChangedNodeEvent |
ChangedEvent is emitted directly after a node was changed. | |
DataStorageEvent | DeleteNodeEvent |
DeleteNodeEvent is emitted directly before a node is deleted. | |
Protected Member Functions | |
void | EmitAddNodeEvent (const mitk::DataNode *node) |
EmitAddNodeEvent emits the AddNodeEvent. | |
void | EmitRemoveNodeEvent (const mitk::DataNode *node) |
EmitRemoveNodeEvent emits the RemoveNodeEvent. | |
void | OnNodeModifiedOrDeleted (const itk::Object *caller, const itk::EventObject &event) |
OnNodeModified listens to modified events of DataNodes. | |
void | AddListeners (const mitk::DataNode *_Node) |
Adds a Modified-Listener to the given Node. | |
void | RemoveListeners (const mitk::DataNode *_Node) |
Removes a Modified-Listener from the given Node. | |
DataStorage () | |
Standard Constructor for New() instantiation. | |
virtual | ~DataStorage () |
Standard Destructor. | |
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. | |
virtual void | PrintSelf (std::ostream &os, itk::Indent indent) const |
Prints the contents of the DataStorage to os. Do not call directly, call ->Print() instead. | |
Protected Attributes | |
std::map< const mitk::DataNode *, unsigned long > | m_NodeModifiedObserverTags |
Saves Modified-Observer Tags for each node in order to remove the event listeners again. | |
std::map< const mitk::DataNode *, unsigned long > | m_NodeDeleteObserverTags |
Saves Delete-Observer Tags for each node in order to remove the event listeners again. | |
bool | m_BlockNodeModifiedEvents |
If this class changes nodes itself, set this to TRUE in order to suppress NodeChangedEvent to be emitted. |
Data management class that handles 'was created by' relations.
The DataStorage provides data storage and management functionality. It handles a 'was created by' relation by associating each data object with a set of source objects, that this object was created from. Thus, nodes are stored in a noncyclical directed graph data structure. If a new node is added to the DataStorage, AddNodeEvent is emitted. If a node is removed, RemoveNodeEvent is emitted.
Definition at line 49 of file mitkDataStorage.h.
typedef itk::SmartPointer<const Self> mitk::DataStorage::ConstPointer |
Reimplemented in mitk::StandaloneDataStorage, and mitk::TestStandaloneDataStorage.
Definition at line 52 of file mitkDataStorage.h.
typedef Message1<const mitk::DataNode*> mitk::DataStorage::DataStorageEvent |
Definition at line 200 of file mitkDataStorage.h.
typedef itk::SmartPointer<Self> mitk::DataStorage::Pointer |
Reimplemented in mitk::StandaloneDataStorage, and mitk::TestStandaloneDataStorage.
Definition at line 52 of file mitkDataStorage.h.
typedef DataStorage mitk::DataStorage::Self |
Reimplemented in mitk::StandaloneDataStorage, and mitk::TestStandaloneDataStorage.
Definition at line 52 of file mitkDataStorage.h.
typedef itk::VectorContainer<unsigned int, mitk::DataNode::Pointer> mitk::DataStorage::SetOfObjects |
A Container of objects that is used as a result set of GetSubset() query operations (Set of SmartPointers to DataNodes).
Definition at line 52 of file mitkDataStorage.h.
typedef itk::Object mitk::DataStorage::Superclass |
Reimplemented in mitk::StandaloneDataStorage, and mitk::TestStandaloneDataStorage.
Definition at line 52 of file mitkDataStorage.h.
mitk::DataStorage::DataStorage | ( | ) | [protected] |
Standard Constructor for New() instantiation.
Definition at line 30 of file mitkDataStorage.cpp.
: itk::Object() , m_BlockNodeModifiedEvents(false) { }
mitk::DataStorage::~DataStorage | ( | ) | [protected, virtual] |
Standard Destructor.
Definition at line 36 of file mitkDataStorage.cpp.
{ //SetOfObjects::ConstPointer all = this->GetAll(); //for (SetOfObjects::ConstIterator it = all->Begin(); it != all->End(); ++it) // this->RemoveListeners(it->Value()); //m_NodeModifiedObserverTags.clear(); //m_NodeDeleteObserverTags.clear(); }
virtual void mitk::DataStorage::Add | ( | mitk::DataNode * | node, |
const mitk::DataStorage::SetOfObjects * | parents = NULL |
||
) | [pure virtual] |
Adds a DataNode containing a data object to its internal storage.
This Method adds a new data object to the DataStorage. The new object is passed in the first parameter. The second parameter is a set of source objects, that were used to create this object. The new object will have a 'was created from' relation to its source objects. the addition of a new object will fire the notification mechanism. If the node parameter is NULL or if the DataNode has already been added, an exception will be thrown.
Implemented in mitk::StandaloneDataStorage.
Referenced by QmitkBoundingObjectWidget::CreateBoundingObject(), SceneIOTestClass::FillStorage(), QmitkNavigationToolManagementWidget::OnAddToolSave(), QmitkNavigationToolManagementWidget::OnLoadSurface(), QmitkToolPairNavigationView::SetupIGTPipeline(), QmitkIGTRecorderView::SetupIGTPipeline(), and TestDataStorage().
void mitk::DataStorage::Add | ( | mitk::DataNode * | node, |
mitk::DataNode * | parent | ||
) |
Convenience method to add a node that has one parent.
Definition at line 47 of file mitkDataStorage.cpp.
{ mitk::DataStorage::SetOfObjects::Pointer parents = mitk::DataStorage::SetOfObjects::New(); parents->InsertElement(0, parent); this->Add(node, parents); }
void mitk::DataStorage::AddListeners | ( | const mitk::DataNode * | _Node ) | [protected] |
Adds a Modified-Listener to the given Node.
Definition at line 209 of file mitkDataStorage.cpp.
References OnNodeModifiedOrDeleted().
{ itk::MutexLockHolder<itk::SimpleFastMutexLock> locked(m_MutexOne); // node must not be 0 and must not be yet registered mitk::DataNode* NonConstNode = const_cast<mitk::DataNode*>(_Node); if(_Node && m_NodeModifiedObserverTags .find(NonConstNode) == m_NodeModifiedObserverTags.end()) { itk::MemberCommand<mitk::DataStorage>::Pointer nodeModifiedCommand = itk::MemberCommand<mitk::DataStorage>::New(); nodeModifiedCommand->SetCallbackFunction(this , &mitk::DataStorage::OnNodeModifiedOrDeleted); m_NodeModifiedObserverTags[NonConstNode] = NonConstNode->AddObserver(itk::ModifiedEvent(), nodeModifiedCommand); // add itk delete listener on datastorage itk::MemberCommand<mitk::DataStorage>::Pointer deleteCommand = itk::MemberCommand<mitk::DataStorage>::New(); deleteCommand->SetCallbackFunction(this, &mitk::DataStorage::OnNodeModifiedOrDeleted); // add observer m_NodeDeleteObserverTags[NonConstNode] = NonConstNode->AddObserver(itk::DeleteEvent(), deleteCommand); } }
mitk::BoundingBox::Pointer mitk::DataStorage::ComputeBoundingBox | ( | const char * | boolPropertyKey = NULL , |
mitk::BaseRenderer * | renderer = NULL , |
||
const char * | boolPropertyKey2 = NULL |
||
) |
Compute the bounding box of data tree structure it -> an iterator to a data tree structure.
boolPropertyKey | if a BoolProperty with this boolPropertyKey exists for a node (for renderer) |
Definition at line 415 of file mitkDataStorage.cpp.
References mitk::Geometry3D::GetBoundingBox(), and mitk::Geometry3D::GetCornerPoint().
Referenced by mitk::SurfaceInteractor::CanHandleEvent(), mitk::SpaceNavigatorVtkCameraController::OnSpaceNavigatorEvent(), mitk::SpaceNavigatorVtkCameraController::OnSpaceNavigatorKeyDown(), mitk::TDMouseVtkCameraController::OnTDMouseEvent(), mitk::TDMouseVtkCameraController::OnTDMouseKeyDown(), and mitk::CameraController::SetStandardView().
{ BoundingBox::PointsContainer::Pointer pointscontainer=BoundingBox::PointsContainer::New(); BoundingBox::PointIdentifier pointid=0; Point3D point; // Needed for check of zero bounding boxes mitk::ScalarType nullpoint[]={0,0,0,0,0,0}; BoundingBox::BoundsArrayType itkBoundsZero(nullpoint); SetOfObjects::ConstPointer all = this->GetAll(); for (SetOfObjects::ConstIterator it = all->Begin(); it != all->End(); ++it) { DataNode::Pointer node = it->Value(); if((node.IsNotNull()) && (node->GetData() != NULL) && (node->GetData()->IsEmpty()==false) && node->IsOn(boolPropertyKey, renderer) && node->IsOn(boolPropertyKey2, renderer) ) { const Geometry3D* geometry = node->GetData()->GetUpdatedTimeSlicedGeometry(); if (geometry != NULL ) { // bounding box (only if non-zero) BoundingBox::BoundsArrayType itkBounds = geometry->GetBoundingBox()->GetBounds(); if (itkBounds == itkBoundsZero) { continue; } unsigned char i; for(i=0; i<8; ++i) { point = geometry->GetCornerPoint(i); if(point[0]*point[0]+point[1]*point[1]+point[2]*point[2] < large) pointscontainer->InsertElement( pointid++, point); else { itkGenericOutputMacro( << "Unrealistically distant corner point encountered. Ignored. Node: " << node ); } } } } } BoundingBox::Pointer result = BoundingBox::New(); result->SetPoints(pointscontainer); result->ComputeBoundingBox(); return result; }
mitk::TimeSlicedGeometry::Pointer mitk::DataStorage::ComputeBoundingGeometry3D | ( | const SetOfObjects * | input, |
const char * | boolPropertyKey = NULL , |
||
mitk::BaseRenderer * | renderer = NULL , |
||
const char * | boolPropertyKey2 = NULL |
||
) |
Compute the axis-parallel bounding geometry of the input objects.
Throws std::invalid_argument exception if input is NULL
input | set of objects of the DataStorage to be included in the bounding geometry |
boolPropertyKey | if a BoolProperty with this boolPropertyKey exists for a node (for renderer) and is set to false, the node is ignored for the bounding-box calculation. |
renderer | see boolPropertyKey |
boolPropertyKey2 | a second condition that is applied additionally to boolPropertyKey |
Definition at line 254 of file mitkDataStorage.cpp.
References mitk::Geometry3D::GetBoundingBox(), mitk::Geometry3D::GetCornerPoint(), mitk::Geometry3D::GetIndexToWorldTransform(), mitk::Geometry3D::GetTimeBounds(), mitk::TimeSlicedGeometry::GetTimeSteps(), QuadProgPP::max(), MITK_ERROR, mitk::TimeSlicedGeometry::New(), and mitk::Geometry3D::New().
Referenced by TestDataStorage().
{ if (input == NULL) throw std::invalid_argument("DataStorage: input is invalid"); BoundingBox::PointsContainer::Pointer pointscontainer=BoundingBox::PointsContainer::New(); BoundingBox::PointIdentifier pointid=0; Point3D point; Vector3D minSpacing; minSpacing.Fill(ScalarTypeNumericTraits::max()); ScalarType stmin, stmax; stmin= ScalarTypeNumericTraits::NonpositiveMin(); stmax= ScalarTypeNumericTraits::max(); ScalarType minimalIntervallSize = stmax; ScalarType minimalTime = stmax; ScalarType maximalTime = 0; // Needed for check of zero bounding boxes mitk::ScalarType nullpoint[]={0,0,0,0,0,0}; BoundingBox::BoundsArrayType itkBoundsZero(nullpoint); for (SetOfObjects::ConstIterator it = input->Begin(); it != input->End(); ++it) { DataNode::Pointer node = it->Value(); if((node.IsNotNull()) && (node->GetData() != NULL) && (node->GetData()->IsEmpty()==false) && node->IsOn(boolPropertyKey, renderer) && node->IsOn(boolPropertyKey2, renderer) ) { const TimeSlicedGeometry* geometry = node->GetData()->GetUpdatedTimeSlicedGeometry(); if (geometry != NULL ) { // bounding box (only if non-zero) BoundingBox::BoundsArrayType itkBounds = geometry->GetBoundingBox()->GetBounds(); if (itkBounds == itkBoundsZero) { continue; } unsigned char i; for(i=0; i<8; ++i) { point = geometry->GetCornerPoint(i); if(point[0]*point[0]+point[1]*point[1]+point[2]*point[2] < large) pointscontainer->InsertElement( pointid++, point); else { itkGenericOutputMacro( << "Unrealistically distant corner point encountered. Ignored. Node: " << node ); } } // spacing try { AffineTransform3D::Pointer inverseTransform = AffineTransform3D::New(); geometry->GetIndexToWorldTransform()->GetInverse(inverseTransform); vnl_vector< AffineTransform3D::MatrixType::ValueType > unitVector(3); int axis; for(axis = 0; axis < 3; ++axis) { unitVector.fill(0); unitVector[axis] = 1.0; ScalarType mmPerPixel = 1.0/(inverseTransform->GetMatrix()*unitVector).magnitude(); if(minSpacing[axis] > mmPerPixel) { minSpacing[axis] = mmPerPixel; } } // time bounds // iterate over all time steps // Attention: Objects with zero bounding box are not respected in time bound calculation TimeBounds minTB = geometry->GetTimeBounds(); for (unsigned int i=0; i<geometry->GetTimeSteps(); i++) { const TimeBounds & curTimeBounds = node->GetData()->GetGeometry(i)->GetTimeBounds(); // get the minimal time of all objects in the DataStorage if ((curTimeBounds[0]<minimalTime)&&(curTimeBounds[0]>stmin)) { minimalTime=curTimeBounds[0]; } // get the maximal time of all objects in the DataStorage if ((curTimeBounds[1]>maximalTime)&&(curTimeBounds[1]<stmax)) { maximalTime = curTimeBounds[1]; } // get the minimal TimeBound of all time steps of the current DataNode if (curTimeBounds[1]-curTimeBounds[0]<minTB[1]-minTB[0]) { minTB = curTimeBounds; } } // get the minimal interval size of all time steps of all objects of the DataStorage if (minTB[1]-minTB[0]<minimalIntervallSize) { minimalIntervallSize = minTB[1]-minTB[0]; } } catch(itk::ExceptionObject e) { MITK_ERROR << e << std::endl; } } } } BoundingBox::Pointer result = BoundingBox::New(); result->SetPoints(pointscontainer); result->ComputeBoundingBox(); // minimal time bounds of a single time step for all geometries TimeBounds minTimeBounds; minTimeBounds[0] = 0; minTimeBounds[1] = 1; // compute the number of time steps unsigned int numberOfTimeSteps = 1; if (maximalTime!=0) // make sure that there is at least one time sliced geometry in the data storage { minTimeBounds[0] = minimalTime; minTimeBounds[1] = minimalTime + minimalIntervallSize; numberOfTimeSteps = (maximalTime-minimalTime)/minimalIntervallSize; } TimeSlicedGeometry::Pointer timeSlicedGeometry = NULL; if ( result->GetPoints()->Size()>0 ) { // Initialize a geometry of a single time step Geometry3D::Pointer geometry = Geometry3D::New(); geometry->Initialize(); // correct bounding-box (is now in mm, should be in index-coordinates) // according to spacing BoundingBox::BoundsArrayType bounds = result->GetBounds(); int i; for(i = 0; i < 6; ++i) { bounds[i] /= minSpacing[i/2]; } geometry->SetBounds(bounds); geometry->SetSpacing(minSpacing); geometry->SetTimeBounds(minTimeBounds); // Initialize the time sliced geometry timeSlicedGeometry = TimeSlicedGeometry::New(); timeSlicedGeometry->InitializeEvenlyTimed(geometry,numberOfTimeSteps); } return timeSlicedGeometry; }
mitk::TimeSlicedGeometry::Pointer mitk::DataStorage::ComputeBoundingGeometry3D | ( | const char * | boolPropertyKey = NULL , |
mitk::BaseRenderer * | renderer = NULL , |
||
const char * | boolPropertyKey2 = NULL |
||
) |
Compute the axis-parallel bounding geometry of the data tree (bounding box, minimal spacing of the considered nodes, live-span)
it -> an iterator to a data tree structure
boolPropertyKey | if a BoolProperty with this boolPropertyKey exists for a node (for renderer) and is set to false, the node is ignored for the bounding-box calculation. |
renderer | see boolPropertyKey |
boolPropertyKey2 | a second condition that is applied additionally to boolPropertyKey |
Definition at line 404 of file mitkDataStorage.cpp.
{ return this->ComputeBoundingGeometry3D(this->GetAll(), boolPropertyKey, renderer, boolPropertyKey2); }
mitk::TimeBounds mitk::DataStorage::ComputeTimeBounds | ( | const char * | boolPropertyKey, |
mitk::BaseRenderer * | renderer, | ||
const char * | boolPropertyKey2 | ||
) |
Compute the time-bounds of the contents of a data tree structure.
The methods returns only [-infinity, +infinity], if all data-objects have an infinite live-span. Otherwise, all data-objects with infinite live-span are ignored. it -> an iterator to a data tree structure
boolPropertyKey | if a BoolProperty with this boolPropertyKey exists for a node (for renderer) and is set to false, the node is ignored for the time-bounds calculation. |
renderer | see boolPropertyKey |
boolPropertyKey2 | a second condition that is applied additionally to boolPropertyKey |
Definition at line 470 of file mitkDataStorage.cpp.
References mitk::Geometry3D::GetTimeBounds(), and QuadProgPP::max().
{ TimeBounds timeBounds; ScalarType stmin, stmax, cur; stmin= ScalarTypeNumericTraits::NonpositiveMin(); stmax= ScalarTypeNumericTraits::max(); timeBounds[0]=stmax; timeBounds[1]=stmin; SetOfObjects::ConstPointer all = this->GetAll(); for (SetOfObjects::ConstIterator it = all->Begin(); it != all->End(); ++it) { DataNode::Pointer node = it->Value(); if((node.IsNotNull()) && (node->GetData() != NULL) && (node->GetData()->IsEmpty()==false) && node->IsOn(boolPropertyKey, renderer) && node->IsOn(boolPropertyKey2, renderer) ) { const Geometry3D* geometry = node->GetData()->GetUpdatedTimeSlicedGeometry(); if (geometry != NULL ) { const TimeBounds & curTimeBounds = geometry->GetTimeBounds(); cur=curTimeBounds[0]; //is it after -infinity, but before everything else that we found until now? if((cur > stmin) && (cur < timeBounds[0])) timeBounds[0] = cur; cur=curTimeBounds[1]; //is it before infinity, but after everything else that we found until now? if((cur < stmax) && (cur > timeBounds[1])) timeBounds[1] = cur; } } } if(!(timeBounds[0] < stmax)) { timeBounds[0] = stmin; timeBounds[1] = stmax; } return timeBounds; }
mitk::TimeBounds mitk::DataStorage::ComputeTimeBounds | ( | mitk::BaseRenderer * | renderer, |
const char * | boolPropertyKey | ||
) | [inline] |
Compute the time-bounds of all visible parts of the data tree structure, for general.
Definition at line 330 of file mitkDataStorage.h.
{ return ComputeTimeBounds( "visible", renderer, boolPropertyKey); }
mitk::BoundingBox::Pointer mitk::DataStorage::ComputeVisibleBoundingBox | ( | mitk::BaseRenderer * | renderer = NULL , |
const char * | boolPropertyKey = NULL |
||
) | [inline] |
Compute the bounding box of all visible parts of the data tree structure, for general rendering or renderer specific visibility property checking.
Simply calls ComputeBoundingBox(it, "visible", renderer, boolPropertyKey). it -> an iterator of a data tree structure
renderer | the reference to the renderer |
boolPropertyKey | if a BoolProperty with this boolPropertyKey exists for a node (for renderer) and is set to false, the node is ignored for the bounding-box calculation. |
Definition at line 302 of file mitkDataStorage.h.
{ return ComputeBoundingBox( "visible", renderer, boolPropertyKey); }
mitk::TimeSlicedGeometry::Pointer mitk::DataStorage::ComputeVisibleBoundingGeometry3D | ( | mitk::BaseRenderer * | renderer = NULL , |
const char * | boolPropertyKey = NULL |
||
) |
Compute the axis-parallel bounding geometry of all visible parts of the data tree bounding box, minimal spacing of the considered nodes, live-span)
Simply calls ComputeBoundingGeometry3D(it, "visible", renderer, boolPropertyKey). it -> an iterator of a data tree structure
renderer | the reference to the renderer |
boolPropertyKey | if a BoolProperty with this boolPropertyKey exists for a node (for renderer) and is set to false, the node is ignored for the bounding-box calculation. |
Definition at line 409 of file mitkDataStorage.cpp.
{ return ComputeBoundingGeometry3D( "visible", renderer, boolPropertyKey ); }
void mitk::DataStorage::EmitAddNodeEvent | ( | const mitk::DataNode * | node ) | [protected] |
EmitAddNodeEvent emits the AddNodeEvent.
This method should be called by subclasses to emit the AddNodeEvent
Definition at line 181 of file mitkDataStorage.cpp.
{ AddNodeEvent.Send(node); }
void mitk::DataStorage::EmitRemoveNodeEvent | ( | const mitk::DataNode * | node ) | [protected] |
EmitRemoveNodeEvent emits the RemoveNodeEvent.
This method should be called by subclasses to emit the RemoveNodeEvent
Definition at line 187 of file mitkDataStorage.cpp.
{ RemoveNodeEvent.Send(node); }
virtual bool mitk::DataStorage::Exists | ( | const mitk::DataNode * | node ) | const [pure virtual] |
Checks if a node exists in the DataStorage.
Implemented in mitk::StandaloneDataStorage.
mitk::DataStorage::SetOfObjects::ConstPointer mitk::DataStorage::FilterSetOfObjects | ( | const SetOfObjects * | set, |
const NodePredicateBase * | condition | ||
) | const [protected] |
Filters a SetOfObjects by the condition. If no condition is provided, the original set is returned.
Definition at line 148 of file mitkDataStorage.cpp.
References mitk::NodePredicateBase::CheckNode().
{ if (set == NULL) return NULL; mitk::DataStorage::SetOfObjects::Pointer result = mitk::DataStorage::SetOfObjects::New(); for (mitk::DataStorage::SetOfObjects::ConstIterator it = set->Begin(); it != set->End(); it++) if (condition == NULL || condition->CheckNode(it.Value()) == true) //alway copy the set, otherwise the iterator in mitk::DataStorage::Remove() will crash result->InsertElement(result->Size(), it.Value()); return mitk::DataStorage::SetOfObjects::ConstPointer(result); }
virtual SetOfObjects::ConstPointer mitk::DataStorage::GetAll | ( | ) | const [pure virtual] |
returns a set of all data objects that are stored in the data storage
Implemented in mitk::StandaloneDataStorage.
Referenced by QmitkToolWorkingDataSelectionBox::GetAllNodes(), QmitkToolReferenceDataSelectionBox::GetAllPossibleReferenceImages(), QmitkDataStorageListModel::reset(), and TestDataStorage().
virtual const char* mitk::DataStorage::GetClassName | ( | ) | const [virtual] |
Reimplemented in mitk::StandaloneDataStorage, and mitk::TestStandaloneDataStorage.
virtual SetOfObjects::ConstPointer mitk::DataStorage::GetDerivations | ( | const mitk::DataNode * | node, |
const NodePredicateBase * | condition = NULL , |
||
bool | onlyDirectDerivations = true |
||
) | const [pure virtual] |
returns a set of derived objects for a given node.
GetDerivations() returns a set of objects that are derived from the DataNode node. This means, that node was used to create the returned objects. If the parameter onlyDirectDerivations is set to true (default value), only objects that directly have node as one of their source objects will be returned. Otherwise, objects that are derived from derivations of node are returned too. The derived objects can be filtered with a predicate object as described in the GetSubset() method by providing a predicate as the condition parameter.
Implemented in mitk::StandaloneDataStorage.
Referenced by QmitkToolWorkingDataSelectionBox::GetAllNodes(), and TestDataStorage().
const mitk::DataNode::GroupTagList mitk::DataStorage::GetGroupTags | ( | ) | const |
Returns a list of used grouptags.
Definition at line 162 of file mitkDataStorage.cpp.
References mitk::PropertyList::GetMap().
Referenced by TestDataStorage().
{ DataNode::GroupTagList result; SetOfObjects::ConstPointer all = this->GetAll(); if (all.IsNull()) return result; for (mitk::DataStorage::SetOfObjects::ConstIterator nodeIt = all->Begin(); nodeIt != all->End(); nodeIt++) // for each node { mitk::PropertyList* pl = nodeIt.Value()->GetPropertyList(); for (mitk::PropertyList::PropertyMap::const_iterator propIt = pl->GetMap()->begin(); propIt != pl->GetMap()->end(); propIt++) if (dynamic_cast<mitk::GroupTagProperty*>(propIt->second.first.GetPointer()) != NULL) result.insert(propIt->first); } return result; }
mitk::DataNode * mitk::DataStorage::GetNamedDerivedNode | ( | const char * | name, |
const mitk::DataNode * | sourceNode, | ||
bool | onlyDirectDerivations = true |
||
) | const |
Convenience method to get the first node with a given name that is derived from sourceNode.
Definition at line 99 of file mitkDataStorage.cpp.
References mitk::NodePredicateProperty::New(), and mitk::StringProperty::New().
Referenced by TestDataStorage().
{ if (name == NULL) return NULL; mitk::StringProperty::Pointer s(mitk::StringProperty::New(name)); mitk::NodePredicateProperty::Pointer p = mitk::NodePredicateProperty::New("name", s); mitk::DataStorage::SetOfObjects::ConstPointer rs = this->GetDerivations(sourceNode, p, onlyDirectDerivations); if (rs->Size() >= 1) return rs->GetElement(0); else return NULL; }
DataType* mitk::DataStorage::GetNamedDerivedObject | ( | const char * | name, |
const mitk::DataNode * | sourceNode, | ||
bool | onlyDirectDerivations = true |
||
) | const [inline] |
Convenience method to get the first data object of a given data type with a given name that is derived from a specific node.
Definition at line 180 of file mitkDataStorage.h.
References mitk::DataNode::GetData().
{ if (name == NULL) return NULL; mitk::DataNode* n = this->GetNamedDerivedNode(name, sourceNode, onlyDirectDerivations); if (n == NULL) return NULL; else return dynamic_cast<DataType*>(n->GetData()); }
mitk::DataNode * mitk::DataStorage::GetNamedNode | ( | const char * | name ) | const |
Convenience method to get the first node with a given name.
Definition at line 71 of file mitkDataStorage.cpp.
References mitk::NodePredicateProperty::New(), and mitk::StringProperty::New().
Referenced by QmitkRenderWindowMenu::OnCrossHairMenuAboutToShow(), QmitkRenderWindowMenu::SetCrossHairVisibility(), QmitkToolPairNavigationView::SetupIGTPipeline(), TestDataStorage(), and SceneIOTestClass::VerifyStorage().
{ if (name == NULL) return NULL; mitk::StringProperty::Pointer s(mitk::StringProperty::New(name)); mitk::NodePredicateProperty::Pointer p = mitk::NodePredicateProperty::New("name", s); mitk::DataStorage::SetOfObjects::ConstPointer rs = this->GetSubset(p); if (rs->Size() >= 1) return rs->GetElement(0); else return NULL; }
mitk::DataNode* mitk::DataStorage::GetNamedNode | ( | const std::string | name ) | const [inline] |
Convenience method to get the first node with a given name.
Definition at line 143 of file mitkDataStorage.h.
{ return this->GetNamedNode(name.c_str()); }
DataType* mitk::DataStorage::GetNamedObject | ( | const std::string | name ) | const [inline] |
Convenience method to get the first data object of a given data type with a given name.
Definition at line 171 of file mitkDataStorage.h.
{
return this->GetNamedObject<DataType>(name.c_str());
}
DataType* mitk::DataStorage::GetNamedObject | ( | const char * | name ) | const [inline] |
Convenience method to get the first data object of a given data type with a given name.
Definition at line 157 of file mitkDataStorage.h.
References mitk::DataNode::GetData().
Referenced by TestDataStorage().
{ if (name == NULL) return NULL; mitk::DataNode* n = this->GetNamedNode(name); if (n == NULL) return NULL; else return dynamic_cast<DataType*>(n->GetData()); }
mitk::DataNode * mitk::DataStorage::GetNode | ( | const NodePredicateBase * | condition = NULL ) |
const |
Convenience method to get the first node that matches the predicate condition.
Definition at line 87 of file mitkDataStorage.cpp.
Referenced by mitk::PositionTracker::ExecuteAction(), and TestDataStorage().
{ if (condition == NULL) return NULL; mitk::DataStorage::SetOfObjects::ConstPointer rs = this->GetSubset(condition); if (rs->Size() >= 1) return rs->GetElement(0); else return NULL; }
virtual SetOfObjects::ConstPointer mitk::DataStorage::GetSources | ( | const mitk::DataNode * | node, |
const NodePredicateBase * | condition = NULL , |
||
bool | onlyDirectSources = true |
||
) | const [pure virtual] |
returns a set of source objects for a given node that meet the given condition(s).
Implemented in mitk::StandaloneDataStorage.
Referenced by mitk::SceneIO::SaveScene(), TestDataStorage(), and SceneIOTestClass::VerifyStorage().
mitk::DataStorage::SetOfObjects::ConstPointer mitk::DataStorage::GetSubset | ( | const NodePredicateBase * | condition ) | const |
returns a set of data objects that meet the given condition(s)
GetSubset returns a set of objects with a specific data type that meet the condition(s) specified in the condition parameter. Conditions can be
Definition at line 64 of file mitkDataStorage.cpp.
Referenced by QmitkBoundingObjectWidget::GetAllBoundingObjects(), QmitkToolWorkingDataSelectionBox::GetAllNodes(), QmitkToolReferenceDataSelectionBox::GetAllPossibleReferenceImages(), QmitkToolPairNavigationView::RemoveVisualizationObjects(), QmitkDataStorageListModel::reset(), and TestDataStorage().
{ mitk::DataStorage::SetOfObjects::ConstPointer result = this->FilterSetOfObjects(this->GetAll(), condition); return result; }
void mitk::DataStorage::OnNodeModifiedOrDeleted | ( | const itk::Object * | caller, |
const itk::EventObject & | event | ||
) | [protected] |
OnNodeModified listens to modified events of DataNodes.
The node is hidden behind the caller parameter, which has to be casted first. If the cast succeeds the ChangedNodeEvent is emitted with this node.
Definition at line 192 of file mitkDataStorage.cpp.
Referenced by AddListeners().
{ if(m_BlockNodeModifiedEvents) return; const mitk::DataNode* _Node = dynamic_cast<const mitk::DataNode*>(caller); if(_Node) { const itk::ModifiedEvent* modEvent = dynamic_cast<const itk::ModifiedEvent*>(&event); if(modEvent) ChangedNodeEvent.Send(_Node); else DeleteNodeEvent.Send(_Node); } }
void mitk::DataStorage::PrintSelf | ( | std::ostream & | os, |
itk::Indent | indent | ||
) | const [protected, virtual] |
Prints the contents of the DataStorage to os. Do not call directly, call ->Print() instead.
Reimplemented in mitk::StandaloneDataStorage.
Definition at line 114 of file mitkDataStorage.cpp.
{ //Superclass::PrintSelf(os, indent); mitk::DataStorage::SetOfObjects::ConstPointer all = this->GetAll(); os << indent << "DataStorage " << this << " is managing " << all->Size() << " objects. List of objects:" << std::endl; for (mitk::DataStorage::SetOfObjects::ConstIterator allIt = all->Begin(); allIt != all->End(); allIt++) { std::string name; allIt.Value()->GetName(name); std::string datatype; if (allIt.Value()->GetData() != NULL) datatype = allIt.Value()->GetData()->GetNameOfClass(); os << indent << " " << allIt.Value().GetPointer() << "<" << datatype << ">: " << name << std::endl; mitk::DataStorage::SetOfObjects::ConstPointer parents = this->GetSources(allIt.Value()); if (parents->Size() > 0) { os << indent << " Direct sources: "; for (mitk::DataStorage::SetOfObjects::ConstIterator parentIt = parents->Begin(); parentIt != parents->End(); parentIt++) os << parentIt.Value().GetPointer() << ", "; os << std::endl; } mitk::DataStorage::SetOfObjects::ConstPointer derivations = this->GetDerivations(allIt.Value()); if (derivations->Size() > 0) { os << indent << " Direct derivations: "; for (mitk::DataStorage::SetOfObjects::ConstIterator derivationIt = derivations->Begin(); derivationIt != derivations->End(); derivationIt++) os << derivationIt.Value().GetPointer() << ", "; os << std::endl; } } os << std::endl; }
virtual void mitk::DataStorage::Remove | ( | const mitk::DataNode * | node ) | [pure virtual] |
Removes node from the DataStorage.
Implemented in mitk::StandaloneDataStorage.
Referenced by QmitkNavigationToolManagementWidget::OnDeleteTool(), QmitkNavigationToolManagementWidget::OnLoadSingleTool(), QmitkBoundingObjectWidget::RemoveItem(), QmitkToolPairNavigationView::RemoveVisualizationObjects(), and TestDataStorage().
void mitk::DataStorage::Remove | ( | const mitk::DataStorage::SetOfObjects * | nodes ) |
Removes a set of nodes from the DataStorage.
Definition at line 55 of file mitkDataStorage.cpp.
{ if (nodes == NULL) return; for (mitk::DataStorage::SetOfObjects::ConstIterator it = nodes->Begin(); it != nodes->End(); it++) this->Remove(it.Value()); }
void mitk::DataStorage::RemoveListeners | ( | const mitk::DataNode * | _Node ) | [protected] |
Removes a Modified-Listener from the given Node.
Definition at line 235 of file mitkDataStorage.cpp.
{ itk::MutexLockHolder<itk::SimpleFastMutexLock> locked(m_MutexOne) ; // node must not be 0 and must be registered mitk::DataNode* NonConstNode = const_cast<mitk::DataNode*>(_Node); if(_Node && m_NodeModifiedObserverTags .find(NonConstNode) != m_NodeModifiedObserverTags.end()) { // const cast is bad! but sometimes it is necessary. removing an observer does not really // touch the internal state NonConstNode->RemoveObserver(m_NodeModifiedObserverTags .find(NonConstNode)->second); NonConstNode->RemoveObserver(m_NodeDeleteObserverTags .find(NonConstNode)->second); m_NodeModifiedObserverTags.erase(NonConstNode); m_NodeDeleteObserverTags.erase(NonConstNode); } }
AddEvent is emitted whenever a new node has been added to the DataStorage.
Observers should register to this event by calling myDataStorage->AddNodeEvent.AddListener(myObject, MyObject::MyMethod). After registering, myObject->MyMethod() will be called every time a new node has been added to the DataStorage. Observers should unregister by calling myDataStorage->AddNodeEvent.RemoveListener(myObject, MyObject::MyMethod). Note: AddEvents are _not_ emitted if a node is added to DataStorage by adding it to the the underlying DataTree!
Definition at line 211 of file mitkDataStorage.h.
Referenced by QmitkDataStorageListModel::SetDataStorage(), mitk::LevelWindowManager::SetDataStorage(), and TestDataStorage().
ChangedEvent is emitted directly after a node was changed.
Observers should register to this event by calling myDataStorage->ChangedNodeEvent.AddListener(myObject, MyObject::MyMethod). After registering, myObject->MyMethod() will be called every time a new node has been changed. Observers should unregister by calling myDataStorage->ChangedNodeEvent.RemoveListener(myObject, MyObject::MyMethod). Internally the DataStorage listens to itk::ModifiedEvents on the nodes and forwards them to the listeners of this event.
Definition at line 236 of file mitkDataStorage.h.
DeleteNodeEvent is emitted directly before a node is deleted.
Observers should register to this event by calling myDataStorage->DeleteNodeEvent.AddListener(myObject, MyObject::MyMethod). After registering, myObject->MyMethod() will be called when a node is deleted. Observers should unregister by calling myDataStorage->DeleteNodeEvent.RemoveListener(myObject, MyObject::MyMethod). Internally the DataStorage listens to itk::DeleteEvents on the nodes and forwards them to the listeners of this event.
Definition at line 249 of file mitkDataStorage.h.
bool mitk::DataStorage::m_BlockNodeModifiedEvents [protected] |
If this class changes nodes itself, set this to TRUE in order to suppress NodeChangedEvent to be emitted.
Definition at line 376 of file mitkDataStorage.h.
itk::SimpleFastMutexLock mitk::DataStorage::m_MutexOne [mutable] |
Definition at line 197 of file mitkDataStorage.h.
std::map<const mitk::DataNode*, unsigned long> mitk::DataStorage::m_NodeDeleteObserverTags [protected] |
Saves Delete-Observer Tags for each node in order to remove the event listeners again.
Definition at line 371 of file mitkDataStorage.h.
Referenced by mitk::TestStandaloneDataStorage::GetDeletedObserverTags().
std::map<const mitk::DataNode*, unsigned long> mitk::DataStorage::m_NodeModifiedObserverTags [protected] |
Saves Modified-Observer Tags for each node in order to remove the event listeners again.
Definition at line 367 of file mitkDataStorage.h.
Referenced by mitk::TestStandaloneDataStorage::GetModifiedObserverTags().
RemoveEvent is emitted directly before a node is removed from the DataStorage.
Observers should register to this event by calling myDataStorage->RemoveNodeEvent.AddListener(myObject, MyObject::MyMethod). After registering, myObject->MyMethod() will be called every time a new node has been added to the DataStorage. Observers should unregister by calling myDataStorage->RemoveNodeEvent.RemoveListener(myObject, MyObject::MyMethod). Note: RemoveEvents are also emitted if a node was removed from the DataStorage by deleting it from the underlying DataTree
Definition at line 223 of file mitkDataStorage.h.
Referenced by QmitkDataStorageListModel::SetDataStorage(), and TestDataStorage().