Commit e6fe8c03 authored by haehn's avatar haehn
Browse files

ENH: Annotation module: Move annotation up works now. Also, MRML save/load...

ENH: Annotation module: Move annotation up works now. Also, MRML save/load with Annotations works - still some issues so.

git-svn-id: http://svn.slicer.org/Slicer4/trunk@15647 3bd1e089-480b-0410-8dfb-8563597acbee
parent 4919d278
......@@ -1324,6 +1324,12 @@ void vtkSlicerAnnotationModuleLogic::MoveAnnotationUp(const char* id)
return;
}
if (!bufferNode->GetParentNode())
{
// this is the toplevel hierarchy node, therefore, we cannot move up
return;
}
if (!bufferNode->GetHideFromEditors())
{
// this is a manually created hierarchy, we don't want to move towards this one
......@@ -1333,34 +1339,81 @@ void vtkSlicerAnnotationModuleLogic::MoveAnnotationUp(const char* id)
// now we copy the hierarchy node
vtkMRMLAnnotationHierarchyNode* copyHNode = vtkMRMLAnnotationHierarchyNode::New();
VTK_CREATE(vtkMRMLAnnotationHierarchyNode, copyHNode);
copyHNode->CopyWithoutModifiedEvent(hNode);
copyHNode->HideFromEditorsOn();
// now we copy the corresponding annotation node
//if (annotationNode->IsA("vtkMRMLAnnotationRulerNode"))
vtkMRMLAnnotationRulerNode* copyANode = vtkMRMLAnnotationRulerNode::New();
vtkMRMLAnnotationRulerNode* rNode = vtkMRMLAnnotationRulerNode::SafeDownCast(annotationNode);
copyANode->CopyWithoutModifiedEvent(rNode);
std::cout << "copyANode: " << copyANode->GetPosition1()[0] << ", " << copyANode->GetPosition1()[1] << ", " << copyANode->GetPosition1()[2] << std::endl;
std::cout << "annotationNode: " << rNode->GetPosition1()[0] << ", " << rNode->GetPosition1()[1] << ", " << rNode->GetPosition1()[2] << std::endl;
//vtkMRMLAnnotationNode* copyANode = vtkMRMLAnnotationNode::New();
// ..and delete the annotation
this->GetMRMLScene()->RemoveNode(annotationNode);
// ..and the hierarchy
this->GetMRMLScene()->RemoveNode(hNode);
// ..and now insert the copy of the annotation before the buffer
this->GetMRMLScene()->InsertBeforeNode(bufferNode,copyANode);
if (annotationNode->IsA("vtkMRMLAnnotationRulerNode"))
{
VTK_CREATE(vtkMRMLAnnotationRulerNode, copyANode);
vtkMRMLAnnotationRulerNode* rNode = vtkMRMLAnnotationRulerNode::SafeDownCast(annotationNode);
copyANode->CopyWithoutModifiedEvent(rNode);
// ..and now insert the copy of the hierarchyNode before our annotation
this->GetMRMLScene()->InsertBeforeNode(copyANode,copyHNode);
// ..and delete the annotation
this->GetMRMLScene()->RemoveNode(annotationNode);
// ..and delete the hierarchy
this->GetMRMLScene()->RemoveNode(hNode);
copyHNode->SetDisplayableNodeID(copyANode->GetID());
copyANode->Modified();
// ..and now insert the copy of the annotation before the buffer
this->GetMRMLScene()->InsertBeforeNode(bufferNode,copyANode);
}
else if (annotationNode->IsA("vtkMRMLAnnotationBidimensionalNode"))
{
VTK_CREATE(vtkMRMLAnnotationBidimensionalNode, copyANode);
vtkMRMLAnnotationBidimensionalNode* bNode = vtkMRMLAnnotationBidimensionalNode::SafeDownCast(annotationNode);
copyANode->CopyWithoutModifiedEvent(bNode);
// ..and delete the annotation
this->GetMRMLScene()->RemoveNode(annotationNode);
// ..and delete the hierarchy
this->GetMRMLScene()->RemoveNode(hNode);
// ..and now insert the copy of the annotation before the buffer
this->GetMRMLScene()->InsertBeforeNode(bufferNode,copyANode);
}
else if (annotationNode->IsA("vtkMRMLAnnotationFiducialNode"))
{
VTK_CREATE(vtkMRMLAnnotationFiducialNode, copyANode);
vtkMRMLAnnotationFiducialNode* fNode = vtkMRMLAnnotationFiducialNode::SafeDownCast(annotationNode);
copyANode->CopyWithoutModifiedEvent(fNode);
// ..and delete the annotation
this->GetMRMLScene()->RemoveNode(annotationNode);
// ..and delete the hierarchy
this->GetMRMLScene()->RemoveNode(hNode);
// ..and now insert the copy of the annotation before the buffer
this->GetMRMLScene()->InsertBeforeNode(bufferNode,copyANode);
}
else if (annotationNode->IsA("vtkMRMLAnnotationTextNode"))
{
VTK_CREATE(vtkMRMLAnnotationTextNode, copyANode);
vtkMRMLAnnotationTextNode* tNode = vtkMRMLAnnotationTextNode::SafeDownCast(annotationNode);
copyANode->CopyWithoutModifiedEvent(tNode);
// ..and delete the annotation
this->GetMRMLScene()->RemoveNode(annotationNode);
// ..and delete the hierarchy
this->GetMRMLScene()->RemoveNode(hNode);
// ..and now insert the copy of the annotation before the buffer
this->GetMRMLScene()->InsertBeforeNode(bufferNode,copyANode);
}
// ..and now insert the copy of the hierarchyNode before our annotation
//this->GetMRMLScene()->InsertBeforeNode(copyANode,copyHNode);
}
//---------------------------------------------------------------------------
......
......@@ -158,6 +158,9 @@ void vtkMRMLAnnotationBidimensionalNode::ReadXMLAttributes(const char** atts)
void vtkMRMLAnnotationBidimensionalNode::Copy(vtkMRMLNode *anode)
{
Superclass::Copy(anode);
vtkMRMLAnnotationBidimensionalNode *node = (vtkMRMLAnnotationBidimensionalNode *) anode;
this->SetBidimensionalMeasurement(node->GetBidimensionalMeasurement()[0],node->GetBidimensionalMeasurement()[1]);
}
//-----------------------------------------------------------
......
......@@ -193,11 +193,11 @@ void vtkMRMLAnnotationRulerNode::Copy(vtkMRMLNode *anode)
{
Superclass::Copy(anode);
//vtkMRMLAnnotationRulerNode *node = (vtkMRMLAnnotationRulerNode *) anode;
vtkMRMLAnnotationRulerNode *node = (vtkMRMLAnnotationRulerNode *) anode;
//this->SetPosition1(node->GetPosition1());
//this->SetPosition2(node->GetPosition2());
//this->SetDistanceMeasurement(node->GetDistanceMeasurement());
this->SetDistanceMeasurement(node->GetDistanceMeasurement());
//this->SetResolution(node->GetResolution());
//this->SetDistanceAnnotationFormat(node->GetDistanceAnnotationFormat());
//this->SetModelID1(node->GetModelID1());
......
......@@ -190,7 +190,7 @@ void vtkMRMLAnnotationDisplayableManager::OnMRMLSceneNodeAddedEvent(vtkMRMLNode*
vtkDebugMacro("OnMRMLSceneNodeAddedEvent");
if (!this->IsCorrectDisplayableManager())
if (!node->IsA(this->m_Focus))
{
// jump out
vtkDebugMacro("OnMRMLSceneNodeAddedEvent: Not the correct displayableManager, jumping out!")
......
......@@ -203,6 +203,9 @@ void vtkMRMLAnnotationRulerDisplayableManager::OnWidgetCreated(vtkAbstractWidget
return;
}
//rulerWidget->SetWidgetStateToManipulate();
VTK_CREATE(vtkInteractorEventRecorder, recorder);
recorder->SetInteractor(this->GetInteractor());
recorder->ReadFromInputStringOn();
......
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