How to move name and measure in vtkMRMLAnnotationRulerNode

Hi guys,

I have created a new scripted module that uses two rulers to do measure airways and veins on a CT image.

I know the rulers’ name and measure are automatically placed next to the Ruler. However, many times these are on the way and make the measure difficult.

Do you know a way to make them selectable (I don’t see any appropriate function in the three display nodes of the rulers), so that they can be moved away when needed?

Thanks a lot,
Pietro

Hi Pietro,

It is not possible to directly move the text around. That said, as illustrated below, you could change the visibility, opacity or scale of the text.

Hi JC,

thanks for your reply! OK, I see. And there is a way in python to at least remove the measure and just leave the name next to the ruler? Setting opacity to 0 removes both name and measure, but I need the name next to the ruler.

Thanks a lot,
Pietro

Do you mean displaying only 41.7mm instead of M: 41.7mm ?

Nope, the other way around, displaying only M instead of M: 41.7mm.

It is not currently possible to selectively display one or the other.

The code responsible for formatting the “name: value” string can be found here:

and here:

To achieve you describe, the annotation would have to be updated.

We had a similar need in SlicerIGT extension’s BreachWarning module. We ended up creating a string with custom content and set it as node name. If this does not work for you then submit a feature request at https://issues.slicer.org/ .

In the Modify Annotation properties pop up for the ruler, under Advanced,
Lines, you can move the position of the text along the ruler, from 0 at one
point to 1 at the other end point. From python:
displayNode = ruler.GetDisplayNode()
print displayNode.GetLabelPosition()
displayNode.SetLabelPosition(0.8)
So you’d have to set up a slider similar to the Label Position slider in
your module if you wanted to have a GUI interface to it.

The label format got over written when the Units code was integrated, the
ruler.Get/SetDistanceAnnotationFormat calls are there but the settings are
ignored by the annotation ruler displayable manager in GetLabelFormat.

Nicole