19 #include "itkCommand.h"
20 #include "itkMutexLockHolder.h"
46 parents->InsertElement(0, parent);
47 this->Add(node, parents);
54 for (mitk::DataStorage::SetOfObjects::ConstIterator it = nodes->Begin(); it != nodes->End(); it++)
55 this->Remove(it.Value());
74 return rs->GetElement(0);
81 if (condition == NULL)
86 return rs->GetElement(0);
93 bool onlyDirectDerivations)
const
102 return rs->GetElement(0);
111 os << indent <<
"DataStorage " <<
this <<
" is managing " << all->Size() <<
" objects. List of objects:" << std::endl;
112 for (mitk::DataStorage::SetOfObjects::ConstIterator allIt = all->Begin(); allIt != all->End(); allIt++)
115 allIt.Value()->GetName(name);
116 std::string datatype;
117 if (allIt.Value()->GetData() != NULL)
118 datatype = allIt.Value()->GetData()->GetNameOfClass();
119 os << indent <<
" " << allIt.Value().GetPointer() <<
"<" << datatype <<
">: " << name << std::endl;
121 if (parents->Size() > 0)
123 os << indent <<
" Direct sources: ";
124 for (mitk::DataStorage::SetOfObjects::ConstIterator parentIt = parents->Begin(); parentIt != parents->End();
126 os << parentIt.Value().GetPointer() <<
", ";
130 if (derivations->Size() > 0)
132 os << indent <<
" Direct derivations: ";
133 for (mitk::DataStorage::SetOfObjects::ConstIterator derivationIt = derivations->Begin();
134 derivationIt != derivations->End();
136 os << derivationIt.Value().GetPointer() <<
", ";
150 for (mitk::DataStorage::SetOfObjects::ConstIterator it = set->Begin(); it != set->End(); it++)
151 if (condition == NULL ||
154 result->InsertElement(result->Size(), it.Value());
166 for (mitk::DataStorage::SetOfObjects::ConstIterator nodeIt = all->Begin(); nodeIt != all->End();
170 for (mitk::PropertyList::PropertyMap::const_iterator propIt = pl->
GetMap()->begin(); propIt != pl->
GetMap()->end();
172 if (dynamic_cast<mitk::GroupTagProperty *>(propIt->second.GetPointer()) != NULL)
173 result.insert(propIt->first);
181 AddNodeEvent.Send(node);
186 RemoveNodeEvent.Send(node);
194 InteractorChangedNodeEvent.Send(_Node);
200 if (m_BlockNodeModifiedEvents)
206 const itk::ModifiedEvent *modEvent =
dynamic_cast<const itk::ModifiedEvent *
>(&event);
208 ChangedNodeEvent.Send(_Node);
210 DeleteNodeEvent.Send(_Node);
219 if (_Node && m_NodeModifiedObserverTags.find(NonConstNode) == m_NodeModifiedObserverTags.end())
223 m_NodeModifiedObserverTags[NonConstNode] = NonConstNode->AddObserver(itk::ModifiedEvent(), nodeModifiedCommand);
228 m_NodeInteractorChangedObserverTags[NonConstNode] =
229 NonConstNode->AddObserver(mitk::DataNode::InteractorChangedEvent(), interactorChangedCommand);
235 m_NodeDeleteObserverTags[NonConstNode] = NonConstNode->AddObserver(itk::DeleteEvent(), deleteCommand);
244 if (_Node && m_NodeModifiedObserverTags.find(NonConstNode) != m_NodeModifiedObserverTags.end())
248 NonConstNode->RemoveObserver(m_NodeModifiedObserverTags.find(NonConstNode)->second);
249 NonConstNode->RemoveObserver(m_NodeDeleteObserverTags.find(NonConstNode)->second);
250 NonConstNode->RemoveObserver(m_NodeInteractorChangedObserverTags.find(NonConstNode)->second);
252 m_NodeModifiedObserverTags.erase(NonConstNode);
253 m_NodeDeleteObserverTags.erase(NonConstNode);
254 m_NodeInteractorChangedObserverTags.erase(NonConstNode);
259 const char *boolPropertyKey,
261 const char *boolPropertyKey2)
const
264 throw std::invalid_argument(
"DataStorage: input is invalid");
268 BoundingBox::PointIdentifier pointid = 0;
275 stmin = itk::NumericTraits<mitk::ScalarType>::NonpositiveMin();
286 for (SetOfObjects::ConstIterator it = input->Begin(); it != input->End(); ++it)
289 if ((node.IsNotNull()) && (node->GetData() != NULL) && (node->GetData()->IsEmpty() ==
false) &&
290 node->IsOn(boolPropertyKey, renderer) && node->IsOn(boolPropertyKey2, renderer))
292 const TimeGeometry *timeGeometry = node->GetData()->GetUpdatedTimeGeometry();
294 if (timeGeometry != NULL)
298 if (itkBounds == itkBoundsZero)
304 for (i = 0; i < 8; ++i)
307 if (point[0] * point[0] + point[1] * point[1] + point[2] * point[2] <
large)
308 pointscontainer->InsertElement(pointid++, point);
311 itkGenericOutputMacro(<<
"Unrealistically distant corner point encountered. Ignored. Node: " << node);
319 for (
TimeStepType i = 0; i < timeGeometry->CountTimeSteps(); i++)
327 node->GetData()->GetGeometry(i)->IndexToWorld(spacing, spacing);
328 for (
int axis = 0; axis < 3; ++ axis)
331 if (space < minSpacing[axis])
333 minSpacing[axis] = space;
337 const TimeBounds &curTimeBounds = node->GetData()->GetTimeGeometry()->GetTimeBounds(i);
339 if ((curTimeBounds[0] < minimalTime) && (curTimeBounds[0] > stmin))
341 minimalTime = curTimeBounds[0];
344 if ((curTimeBounds[1] > maximalTime) && (curTimeBounds[1] < stmax))
346 maximalTime = curTimeBounds[1];
349 if (curTimeBounds[1] - curTimeBounds[0] < minimalIntervallSize)
351 minimalIntervallSize = curTimeBounds[1] - curTimeBounds[0];
355 catch (itk::ExceptionObject &e)
364 result->SetPoints(pointscontainer);
365 result->ComputeBoundingBox();
368 unsigned int numberOfTimeSteps = 1;
369 if (maximalTime == 0)
373 minimalIntervallSize = 1;
375 numberOfTimeSteps =
static_cast<unsigned int>((maximalTime - minimalTime) / minimalIntervallSize);
378 if (result->GetPoints()->Size() > 0)
382 geometry->Initialize();
386 AffineTransform3D::OutputVectorType
offset;
387 for (
int i = 0; i < 3; ++i)
389 offset[i] = bounds[i * 2];
391 bounds[i * 2 + 1] = (bounds[i * 2 + 1] - offset[i]) / minSpacing[i];
393 geometry->GetIndexToWorldTransform()->SetOffset(offset);
394 geometry->SetBounds(bounds);
395 geometry->SetSpacing(minSpacing);
407 const char *boolPropertyKey2)
const
409 return this->ComputeBoundingGeometry3D(this->GetAll(), boolPropertyKey, renderer, boolPropertyKey2);
413 const char *boolPropertyKey)
415 return ComputeBoundingGeometry3D(
"visible", renderer, boolPropertyKey);
420 const char *boolPropertyKey2)
424 BoundingBox::PointIdentifier pointid = 0;
432 for (SetOfObjects::ConstIterator it = all->Begin(); it != all->End(); ++it)
435 if ((node.IsNotNull()) && (node->GetData() != NULL) && (node->GetData()->IsEmpty() ==
false) &&
436 node->IsOn(boolPropertyKey, renderer) && node->IsOn(boolPropertyKey2, renderer))
438 const TimeGeometry *geometry = node->GetData()->GetUpdatedTimeGeometry();
439 if (geometry != NULL)
443 if (itkBounds == itkBoundsZero)
449 for (i = 0; i < 8; ++i)
452 if (point[0] * point[0] + point[1] * point[1] + point[2] * point[2] <
large)
453 pointscontainer->InsertElement(pointid++, point);
456 itkGenericOutputMacro(<<
"Unrealistically distant corner point encountered. Ignored. Node: " << node);
464 result->SetPoints(pointscontainer);
465 result->ComputeBoundingBox();
472 const char *boolPropertyKey2)
478 stmin = itk::NumericTraits<mitk::ScalarType>::NonpositiveMin();
481 timeBounds[0] = stmax;
482 timeBounds[1] = stmin;
485 for (SetOfObjects::ConstIterator it = all->Begin(); it != all->End(); ++it)
488 if ((node.IsNotNull()) && (node->GetData() != NULL) && (node->GetData()->IsEmpty() ==
false) &&
489 node->IsOn(boolPropertyKey, renderer) && node->IsOn(boolPropertyKey2, renderer))
491 const TimeGeometry *geometry = node->GetData()->GetUpdatedTimeGeometry();
492 if (geometry != NULL)
495 cur = curTimeBounds[0];
497 if ((cur > stmin) && (cur < timeBounds[0]))
500 cur = curTimeBounds[1];
502 if ((cur < stmax) && (cur > timeBounds[1]))
507 if (!(timeBounds[0] < stmax))
509 timeBounds[0] = stmin;
510 timeBounds[1] = stmax;
517 m_BlockNodeModifiedEvents = block;
mitk::DataNode * GetNode(const NodePredicateBase *condition=nullptr) const
Convenience method to get the first node that matches the predicate condition.
virtual void Add(mitk::DataNode *node, const mitk::DataStorage::SetOfObjects *parents=nullptr)=0
Adds a DataNode containing a data object to its internal storage.
itk::SmartPointer< Self > Pointer
DataStorage()
Standard Constructor for New() instantiation.
std::set< std::string > GroupTagList
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...
itk::FixedArray< ScalarType, 2 > TimeBounds
Standard typedef for time-bounds.
BoundingBox * GetBoundingBoxInWorld() const
Returns a bounding box that covers all time steps.
Organizes the rendering process.
virtual 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...
void AddListeners(const mitk::DataNode *_Node)
Adds a Modified-Listener to the given Node.
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...
Key-value list holding instances of BaseProperty.
Point3D GetCornerPointInWorld(int id) const
Get the position of the corner number id (in world coordinates)
itk::SmartPointer< const Self > ConstPointer
mitk::TimeGeometry::Pointer ComputeVisibleBoundingGeometry3D(const mitk::BaseRenderer *renderer=nullptr, const char *boolPropertyKey=nullptr)
Compute the axis-parallel bounding geometry of all visible parts of the data tree bounding box...
virtual bool CheckNode(const mitk::DataNode *node) const =0
This method will be used to evaluate the node. Has to be overwritten in subclasses.
const DataNode::GroupTagList GetGroupTags() const
Returns a list of used grouptags.
void BlockNodeModifiedEvents(bool block)
Defines whether or not NodeChangedEvent is invoked .
mitk::TimeBounds ComputeTimeBounds(const char *boolPropertyKey, const mitk::BaseRenderer *renderer, const char *boolPropertyKey2)
Compute the time-bounds of the contents of a data tree structure.
virtual TimeBounds GetTimeBounds() const =0
Get the time bounds (in ms)
SetOfObjects::ConstPointer GetSubset(const NodePredicateBase *condition) const
returns a set of data objects that meet the given condition(s)
void OnNodeInteractorChanged(itk::Object *caller, const itk::EventObject &event)
void EmitAddNodeEvent(const mitk::DataNode *node)
EmitAddNodeEvent emits the AddNodeEvent.
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.
void OnNodeModifiedOrDeleted(const itk::Object *caller, const itk::EventObject &event)
OnNodeModified listens to modified events of DataNodes.
std::vcl_size_t TimeStepType
static Pointer New(const char *_arg)
MITKCORE_EXPORT const double large
void RemoveListeners(const mitk::DataNode *_Node)
Removes a Modified-Listener from the given Node.
mitk::TimeGeometry::Pointer ComputeBoundingGeometry3D(const SetOfObjects *input, const char *boolPropertyKey=nullptr, const mitk::BaseRenderer *renderer=nullptr, const char *boolPropertyKey2=nullptr) const
Compute the axis-parallel bounding geometry of the input objects.
mitk::BoundingBox::Pointer ComputeBoundingBox(const char *boolPropertyKey=nullptr, const mitk::BaseRenderer *renderer=nullptr, const char *boolPropertyKey2=nullptr)
Compute the bounding box of data tree structure it -> an iterator to a data tree structure.
void EmitRemoveNodeEvent(const mitk::DataNode *node)
EmitRemoveNodeEvent emits the RemoveNodeEvent.
Interface for evaluation conditions used in the DataStorage class GetSubset() method.
virtual void Remove(const mitk::DataNode *node)=0
Removes node from the DataStorage.
mitk::DataNode * GetNamedNode(const char *name) const
Convenience method to get the first node with a given name.
virtual ~DataStorage()
Standard Destructor.
Class for nodes of the DataTree.
const PropertyMap * GetMap() const
BoundingBoxType::BoundsArrayType BoundsArrayType
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.