Commit 1a74ba0f authored by haehn's avatar haehn
Browse files

ENH: Annotation module: Fixed memoryleaks and other small things.

git-svn-id: http://svn.slicer.org/Slicer4/trunk@15169 3bd1e089-480b-0410-8dfb-8563597acbee
parent 12ccd778
......@@ -245,21 +245,9 @@ void vtkMRMLAnnotationDisplayableManager::OnMRMLSceneNodeRemovedEvent(vtkMRMLNod
{
return;
}
/*
// Remove the node from the list.
vtkInternal::AnnotationNodeListIt it = std::find(
this->Internal->AnnotationNodeList.begin(),
this->Internal->AnnotationNodeList.end(),
annotationNode);
if (it == this->Internal->AnnotationNodeList.end())
{
return;
}
this->Internal->AnnotationNodeList.erase(it);
*/
// Remove the widget from the list.
this->Helper->RemoveWidget(annotationNode);
// Remove the widget and the MRMLnode from the internal lists.
this->Helper->RemoveWidgetAndNode(annotationNode);
// Refresh observers
this->SetAndObserveNodes();
......@@ -458,7 +446,8 @@ bool vtkMRMLAnnotationDisplayableManager::IsWidgetDisplayable(vtkMRMLSliceNode *
return 0;
}
vtkMatrix4x4* transformMatrix = vtkMatrix4x4::New();
VTK_CREATE(vtkMatrix4x4, transformMatrix);
transformMatrix->Identity();
if (node->GetTransformNodeID())
......@@ -690,7 +679,7 @@ void vtkMRMLAnnotationDisplayableManager::GetWorldToDisplayCoordinates(double r,
// we will get the transformation matrix to convert world coordinates to the display coordinates of the specific sliceNode
vtkMatrix4x4 * xyToRasMatrix = this->GetSliceNode()->GetXYToRAS();
vtkMatrix4x4 * rasToXyMatrix = vtkMatrix4x4::New();
VTK_CREATE(vtkMatrix4x4, rasToXyMatrix);
// we need to invert this matrix
xyToRasMatrix->Invert(xyToRasMatrix,rasToXyMatrix);
......
......@@ -77,8 +77,7 @@ void vtkMRMLAnnotationDisplayableManagerHelper::UpdateLocked(vtkMRMLAnnotationNo
}
//---------------------------------------------------------------------------
void vtkMRMLAnnotationDisplayableManagerHelper::UpdateVisible(
vtkMRMLAnnotationNode* node)
void vtkMRMLAnnotationDisplayableManagerHelper::UpdateVisible(vtkMRMLAnnotationNode* node)
{
// Sanity checks
if (node == 0)
......@@ -144,7 +143,7 @@ vtkAbstractWidget * vtkMRMLAnnotationDisplayableManagerHelper::GetWidget(
}
//---------------------------------------------------------------------------
void vtkMRMLAnnotationDisplayableManagerHelper::RemoveWidget(
void vtkMRMLAnnotationDisplayableManagerHelper::RemoveWidgetAndNode(
vtkMRMLAnnotationNode *node)
{
if (!node)
......@@ -167,7 +166,14 @@ void vtkMRMLAnnotationDisplayableManagerHelper::RemoveWidget(
this->AnnotationNodeList.end(),
node);
// Make sure the map contains the annotationNode
if (it2 == this->AnnotationNodeList.end())
{
return;
}
this->AnnotationNodeList.erase(it2);
}
//---------------------------------------------------------------------------
......@@ -181,12 +187,12 @@ void vtkMRMLAnnotationDisplayableManagerHelper::PlaceSeed(double x, double y, vt
if (!interactor)
{
vtkErrorMacro("PlaceSeed: No render interactor found.")
vtkErrorMacro("PlaceSeed: No renderInteractor found.")
}
if (!renderer)
{
vtkErrorMacro("PlaceSeed: No render renderer found.")
vtkErrorMacro("PlaceSeed: No renderer found.")
}
if (!this->SeedWidget)
......
......@@ -47,7 +47,7 @@ public:
/// Get a vtkAbstractWidget* given a node
vtkAbstractWidget * GetWidget(vtkMRMLAnnotationNode * node);
void RemoveWidget(vtkMRMLAnnotationNode *node);
void RemoveWidgetAndNode(vtkMRMLAnnotationNode *node);
/// List of Nodes managed by the DisplayableManager
std::vector<vtkMRMLAnnotationNode*> AnnotationNodeList;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment