Skip to content
/ Slicer Public
forked from Slicer/Slicer

Commit

Permalink
BUG: mantis issue Slicer#2473 unify the visibility setting on the ann…
Browse files Browse the repository at this point in the history
…otation nodes. Needed to have the data module displayable tree show the correct visibility flag and for calculating widget visibility in the displayable managers

svn-url: http://viewvc.slicer.org/viewvc.cgi/Slicer4?view=revision&revision=21159
git-svn-id: http://svn.slicer.org/Slicer4/trunk@21159 3bd1e089-480b-0410-8dfb-8563597acbee
  • Loading branch information
Nicole Aucoin committed Oct 11, 2012
1 parent 481e652 commit f9f9308
Show file tree
Hide file tree
Showing 25 changed files with 30 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ char *vtkSlicerAnnotationModuleLogic::LoadFiducialList(const char *filename)
double coord[3] = {(double)xyz[0], (double)xyz[1], (double)xyz[2]};
fnode->AddControlPoint(coord, sel, vis);
fnode->SetSelected(sel);
fnode->SetVisible(vis);
fnode->SetLocked(locked);

this->GetMRMLScene()->AddNode(fnode);
Expand All @@ -185,7 +184,7 @@ char *vtkSlicerAnnotationModuleLogic::LoadFiducialList(const char *filename)
fnode->GetAnnotationPointDisplayNode()->SetSelectedColor(selColor);
fnode->GetAnnotationTextDisplayNode()->SetColor(color);
fnode->GetAnnotationTextDisplayNode()->SetSelectedColor(selColor);

fnode->SetDisplayVisibility(vis);
fnode->Delete();
}
// clean up
Expand Down Expand Up @@ -2192,7 +2191,7 @@ int vtkSlicerAnnotationModuleLogic::GetAnnotationVisibility(const char * id)

if (annotationNode)
{
return annotationNode->GetVisible();
return annotationNode->GetDisplayVisibility();
}

// is it a heirarchy node?
Expand Down Expand Up @@ -2234,7 +2233,7 @@ void vtkSlicerAnnotationModuleLogic::SetAnnotationVisibility(const char * id)
if (annotationNode)
{
// show/hide this annotation
annotationNode->SetVisible(!annotationNode->GetVisible());
annotationNode->SetDisplayVisibility(!annotationNode->GetDisplayVisibility());
return;
}

Expand Down Expand Up @@ -3320,7 +3319,7 @@ void vtkSlicerAnnotationModuleLogic::SetHierarchyAnnotationsVisibleFlag(vtkMRMLA
{
// this is a valid annotation child node
//
childNode->SetVisible((flag ? 1 : 0));
childNode->SetDisplayVisibility((flag ? 1 : 0));
}
} // for loop
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ int vtkMRMLAnnotationAngleNode::SetAngle(vtkIdType line1Id, vtkIdType line2Id, i
//this->SetPositionCenterByID();

this->SetSelected(sel);
this->SetVisible(vis);
this->SetDisplayVisibility(vis);

return 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,6 @@ class VTK_SLICER_ANNOTATIONS_MODULE_MRML_EXPORT vtkMRMLAnnotationAngleNode : pu
vtkGetStringMacro(ModelIDCenter);
vtkSetStringMacro(ModelIDCenter);

// Just here for historic reasons to comply with vtkMRMLMeasurementsAngleNode
int GetVisibility() {return this->GetVisible();}
void SetVisibility(int flag) {this->SetVisible(flag);}

void SetAngleMeasurement(double val);
double GetAngleMeasurement();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ int vtkMRMLAnnotationAngleStorageNode::WriteAnnotationAngleData(fstream& of, vtk
return 0;
}
int sel = refNode->GetSelected();
int vis = refNode->GetVisible();
int vis = refNode->GetDisplayVisibility();
of << this->GetAnnotationStorageType() << "|" << 0 << "|" << 1 << "|" << sel << "|" << vis << endl;

return 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ class VTK_SLICER_ANNOTATIONS_MODULE_MRML_EXPORT vtkMRMLAnnotationBidimensionalN
// transform utility functions
void Initialize(vtkMRMLScene* mrmlScene);

int GetVisibility() {return this->GetVisible();}
void SetVisibility(int flag) {this->SetVisible(flag);}

std::vector<double> GetBidimensionalMeasurement();
void SetBidimensionalMeasurement(double val1, double val2);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ vtkMRMLNodeNewMacro(vtkMRMLAnnotationDisplayNode);
//----------------------------------------------------------------------------
vtkMRMLAnnotationDisplayNode::vtkMRMLAnnotationDisplayNode()
{
this->SetVisibility(0);
this->SetVisibility(1);
this->SetVectorVisibility(0);
this->SetScalarVisibility(0);
this->SetTensorVisibility(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,6 @@ int vtkMRMLAnnotationFiducialNode::SetFiducial(double newControl[3],int selected
{
return 0;
}

// this is wrong, it's over riding the Text when read a fiducial from a file
/*
if (label)
{
this->SetFiducialLabel(label);
}
else
{
this->SetTextFromID();
}
*/

/* and this is wrong because it's setting the flags on the node rather than
on the control point
this->SetSelected(selectedFlag);
this->SetVisible(visibleFlag);
*/

return 1;
}
Expand Down
23 changes: 0 additions & 23 deletions Modules/Loadable/Annotations/MRML/vtkMRMLAnnotationNode.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ vtkMRMLAnnotationNode::vtkMRMLAnnotationNode()
{
this->TextList = vtkStringArray::New();
this->ReferenceNodeID = NULL;
this->Visible=1;
this->Locked = 0;
this->m_Backup = 0;

Expand Down Expand Up @@ -64,7 +63,6 @@ void vtkMRMLAnnotationNode::WriteXML(ostream& of, int nIndent)
vtkIndent indent(nIndent);

of << indent << " referenceNodeID=\"" << (this->ReferenceNodeID ? this->GetReferenceNodeID() : "None") << "\"";
of << indent << " visible=\"" << this->Visible << "\"";
of << indent << " locked=\"" << this->Locked << "\"";

int textLength = this->TextList->GetNumberOfValues();
Expand Down Expand Up @@ -130,25 +128,6 @@ void vtkMRMLAnnotationNode::ReadXMLAttributes(const char** atts)
{
this->SetReferenceNodeID(attValue.c_str());
}
else if (!strcmp(attName, "visible"))
{
this->SetVisible(atof(attValue.c_str()));
}
// for backwards compatibility
else if (!strcmp(attName, "visibility"))
{
if (!strcmp(attValue.c_str(),"true"))
{
// visiblity = true
this->SetVisible(1);
}
else
{
// visibility = false
this->SetVisible(0);
}
}
// end of backwards compatibility
else if (!strcmp(attName, "locked"))
{
this->SetLocked(atof(attValue.c_str()));
Expand Down Expand Up @@ -191,7 +170,6 @@ void vtkMRMLAnnotationNode::Copy(vtkMRMLNode *anode)
}

this->SetReferenceNodeID(node->GetReferenceNodeID());
this->SetVisible(node->GetVisible());
this->SetLocked(node->GetLocked());
this->TextList->DeepCopy(node->TextList);

Expand Down Expand Up @@ -262,7 +240,6 @@ void vtkMRMLAnnotationNode::PrintAnnotationInfo(ostream& os, vtkIndent indent, i

os << indent << "ReferenceNodeID: " << ( (this->ReferenceNodeID) ? this->ReferenceNodeID : "None" ) << "\n";
os << indent << "Selected: " << this->Selected << "\n";
os << indent << "Visible: " << this->Visible << "\n";
os << indent << "Locked: " << this->Locked << "\n";
os << indent << "textList: ";
if (!this->TextList || !this->GetNumberOfTexts())
Expand Down
9 changes: 0 additions & 9 deletions Modules/Loadable/Annotations/MRML/vtkMRMLAnnotationNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,6 @@ class VTK_SLICER_ANNOTATIONS_MODULE_MRML_EXPORT vtkMRMLAnnotationNode : public
vtkGetStringMacro (ReferenceNodeID);
vtkSetStringMacro (ReferenceNodeID);

// Description:
// Select all elements defining an annotation
// overwrites *_SELECTED and *_VISIBLE when set to 0
// do not have to define for Selected as already defined by Superclass
vtkGetMacro(Visible, int);
vtkSetMacro(Visible, int);
vtkBooleanMacro(Visible, int);

/// If set to 1 then parameters should not be changed.
/// Fires vtkMRMLAnnotationNode::LockModifiedEvent if changed except if
/// GetDisableModifiedEvent() is true.
Expand Down Expand Up @@ -170,7 +162,6 @@ class VTK_SLICER_ANNOTATIONS_MODULE_MRML_EXPORT vtkMRMLAnnotationNode : public
vtkStringArray *TextList;
char *ReferenceNodeID;

int Visible;
int Locked;

vtkMRMLAnnotationNode * m_Backup;
Expand Down
10 changes: 0 additions & 10 deletions Modules/Loadable/Annotations/MRML/vtkMRMLAnnotationROINode.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,6 @@ class VTK_SLICER_ANNOTATIONS_MODULE_MRML_EXPORT vtkMRMLAnnotationROINode : publ

void Initialize(vtkMRMLScene* mrmlScene);

int GetVisibility()
{
return this->GetVisible();
}

void SetVisibility(int flag)
{
this->SetVisible(flag);
}

///
/// Get/Set for ROI Position in RAS cooridnates
/// Note: The ROI Postion is the center of the ROI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ int vtkMRMLAnnotationRulerNode::SetRuler(vtkIdType line1Id, int sel, int vis)
return -1;
}
this->SetSelected(sel);
this->SetVisible(vis);
this->SetDisplayVisibility(vis);

return 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,6 @@ class VTK_SLICER_ANNOTATIONS_MODULE_MRML_EXPORT vtkMRMLAnnotationRulerNode : pu

// void Initialize(vtkMRMLScene* mrmlScene);

int GetVisibility() {return this->GetVisible();}
void SetVisibility(int flag) {this->SetVisible(flag);}

double GetDistanceMeasurement();
void SetDistanceMeasurement(double val);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ int vtkMRMLAnnotationRulerStorageNode::WriteAnnotationRulerData(fstream& of, vtk
return 0;
}
int sel = refNode->GetSelected();
int vis = refNode->GetVisible();
int vis = refNode->GetDisplayVisibility();
of << this->GetAnnotationStorageType() << "|" << 0 << "|" << sel << "|" << vis << endl;

return 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ int vtkMRMLAnnotationSplineNode::SetRuler(vtkIdType line1Id, int sel, int vis)
return -1;
}
this->SetSelected(sel);
this->SetVisible(vis);
this->SetDisplayVisibility(vis);

return 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ class VTK_SLICER_ANNOTATIONS_MODULE_MRML_EXPORT vtkMRMLAnnotationSplineNode : p

void Initialize(vtkMRMLScene* mrmlScene);

int GetVisibility() {return this->GetVisible();}
void SetVisibility(int flag) {this->SetVisible(flag);}

double GetSplineMeasurement();
void SetSplineMeasurement(double val);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ void vtkMRMLAnnotationDisplayableManager::OnMRMLSliceNodeModifiedEvent(vtkMRMLSl
// check if the annotation is displayable according to the current selected Slice
bool visibleOnSlice = this->IsWidgetDisplayable(sliceNode, annotationNode);
// check if the annotation is visible according to the current mrml state
bool visibleOnNode = (annotationNode->GetVisible() == 1 ? true : false);
bool visibleOnNode = (annotationNode->GetDisplayVisibility() != 0 ? true : false);
// check if the widget is visible according to the widget state
bool visibleOnWidget = (widget->GetEnabled() == 1 ? true : false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ void vtkMRMLAnnotationDisplayableManagerHelper::UpdateVisible(vtkMRMLAnnotationN
return;
}

bool isVisibleOnNode = (node->GetVisible() != 0 ? true : false);
bool isVisibleOnNode = (node->GetDisplayVisibility() != 0 ? true : false);
bool isVisibleOnWidget = (widget->GetEnabled() != 0 ? true : false);

vtkDebugMacro("UpdateVisible: isVisibleOnNode = " << isVisibleOnNode << ", isVisibleOnWidget = " << isVisibleOnWidget << ", displayableInViewer = " << displayableInViewer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ void vtkMRMLAnnotationROIDisplayableManager::PropagateMRMLToWidget(vtkMRMLAnnota

this->SetParentTransformToWidget(roiNode, roiWidget);

if (roiNode->GetVisibility())
if (roiNode->GetDisplayVisibility())
{
widget->EnabledOn();
}
Expand Down Expand Up @@ -536,7 +536,7 @@ void vtkMRMLAnnotationROIDisplayableManager::PropagateMRMLToWidget2D(vtkMRMLAnno
plane->SetNormal(normal);
plane->SetOrigin(origin);

rep->SetHandlesVisibility(roiNode->GetLocked()==0 && roiNode->GetVisibility() ? 1:0);
rep->SetHandlesVisibility(roiNode->GetLocked()==0 && roiNode->GetDisplayVisibility() ? 1:0);

rep->PlaceWidget(b);

Expand All @@ -546,7 +546,7 @@ void vtkMRMLAnnotationROIDisplayableManager::PropagateMRMLToWidget2D(vtkMRMLAnno
rep->GetActors2D(actors.GetPointer());
for (int i=0; i<actors->GetNumberOfItems(); i++)
{
vtkProp::SafeDownCast(actors->GetItemAsObject(i))->SetVisibility(roiNode->GetVisibility());
vtkProp::SafeDownCast(actors->GetItemAsObject(i))->SetVisibility(roiNode->GetDisplayVisibility());
}

// re-render the widget
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ int vtkMRMLAnnotationFiducialNodeTest1(int , char * [] )
return EXIT_FAILURE;
}
node2->SetSelected(1);
node2->SetVisible(0);
node2->SetDisplayVisibility(0);

double *_ctp = node2->GetFiducialCoordinates();

Expand All @@ -83,7 +83,7 @@ int vtkMRMLAnnotationFiducialNodeTest1(int , char * [] )
return EXIT_FAILURE;
}

if (!node2->GetSelected() || node2->GetVisible())
if (!node2->GetSelected() || node2->GetDisplayVisibility())
{
std::cerr << "Error in SetFiducial: attributes are not set correct " << std::endl;
return EXIT_FAILURE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ int vtkMRMLAnnotationFiducialsStorageNodeTest1(int argc, char * argv[] )
std::cerr << "Error: Could not define Fiducial " << std::endl;
return EXIT_FAILURE;
}
std::cout << "Set annNode visible to 0, GetVisible = " << annNode->GetVisible() << std::endl;
// changing to use the display node visibilty, update this to show the
// control point visibility
std::cout << "Set annNode visible to 0, GetDisplayVisibility = " << annNode->GetDisplayVisibility() << std::endl;

vtkSmartPointer<vtkMRMLScene> mrmlScene = vtkSmartPointer<vtkMRMLScene>::New();
mrmlScene->AddNode(annNode);
Expand Down Expand Up @@ -89,7 +91,7 @@ int vtkMRMLAnnotationFiducialsStorageNodeTest1(int argc, char * argv[] )
}
node2->SetFileName(fileName.c_str());
node2->WriteData(annNode);
std::cout << "After Write Data, annNode GetVisible = " << annNode->GetVisible() << std::endl;
std::cout << "After Write Data, annNode GetDisplayVisibility = " << annNode->GetDisplayVisibility() << std::endl;

vtkIndent in;
std::stringstream initialAnnotation, afterAnnotation;
Expand All @@ -103,9 +105,9 @@ int vtkMRMLAnnotationFiducialsStorageNodeTest1(int argc, char * argv[] )
{
annNode->GetAnnotationPointDisplayNode()->SetColor(0.0, 0.0, 0.0);
}
std::cout << "After ResetAnnotations, annNode GetVisible = " << annNode->GetVisible() << std::endl;
std::cout << "After ResetAnnotations, annNode GetDisplayVisibility = " << annNode->GetDisplayVisibility() << std::endl;
node2->ReadData(annNode);
std::cout << "After ReadData, annNode GetVisible = " << annNode->GetVisible() << std::endl;
std::cout << "After ReadData, annNode GetDisplayVisibility = " << annNode->GetDisplayVisibility() << std::endl;
annNode->PrintAnnotationInfo(afterAnnotation,in);
if (initialAnnotation.str().compare(afterAnnotation.str()))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ void qMRMLAnnotationROIWidget::onMRMLNodeModified()
d->IsProcessingOnMRMLNodeModified = true;

// Visibility
d->DisplayClippingBoxButton->setChecked(d->ROINode->GetVisibility());
d->DisplayClippingBoxButton->setChecked(d->ROINode->GetDisplayVisibility());

// Interactive Mode
bool interactive = d->ROINode->GetInteractiveMode();
Expand Down Expand Up @@ -191,7 +191,7 @@ void qMRMLAnnotationROIWidget::setExtent(double minLR, double maxLR,
void qMRMLAnnotationROIWidget::setDisplayClippingBox(bool visible)
{
Q_D(qMRMLAnnotationROIWidget);
d->ROINode->SetVisibility(visible);
d->ROINode->SetDisplayVisibility(visible);
emit displayClippingBoxChanged(visible);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,7 @@ void qMRMLAnnotationTreeView::onVisibilityColumnClicked(vtkMRMLNode* node)
if (annotationNode)
{
// this is a valid annotationNode
annotationNode->SetVisible(!annotationNode->GetVisible());

annotationNode->SetDisplayVisibility(!annotationNode->GetDisplayVisibility());
}

// taking out the switch for hierarchy nodes, do it via the buttons above
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void qMRMLSceneAnnotationModel::updateItemDataFromNode(QStandardItem* item, vtkM
// the visibility icon
if (annotationNode)
{
if (annotationNode->GetVisible())
if (annotationNode->GetDisplayVisibility())
{
item->setData(QPixmap(":/Icons/Small/SlicerVisible.png"),Qt::DecorationRole);
}
Expand Down

0 comments on commit f9f9308

Please sign in to comment.