Skip to content

BUG: Fix ConvertDeviceToXYZ() 1 pixel offset

Sam Horvath requested to merge github/fork/vovythevov/FixConvertDeviceToXYZ into master

Created by: vovythevov

The issue appeared when using an annotation. When the annotation point is dragged at the bottom of a slice view, the annotation Z position would jump 1 pixel higher. For example in the axial view, the Z coordinate of the annotation would jump from 0.0 to 1.0 (when no module is loaded).

Here is a small python code exerpt that can be used to showcase the bug:

def PrintP1(caller, event):
    p1 = [0, 0, 0]
    caller.GetPosition1(p1)
    print(p1)

ruler = slicer.mrmlScene.AddNode(slicer.vtkMRMLAnnotationRulerNode())
ruler.SetPosition1([0, 0, 0])
ruler.SetPosition2([10, 0, 0])
ruler.AddObserver(vtk.vtkCommand.ModifiedEvent, PrintP1)

Fixing the computation of Z in ConvertDeviceToXYZ() fixes this.

Merge request reports