diff --git a/invesalius/data/cursor_actors.py b/invesalius/data/cursor_actors.py index 3f1cb05..6a1b704 100644 --- a/invesalius/data/cursor_actors.py +++ b/invesalius/data/cursor_actors.py @@ -300,13 +300,15 @@ class CursorRectangle: px, py, pz = self.edition_position orient = self.orientation xs, ys, zs = self.spacing + abs_pixel = {"AXIAL": lambda x,y: (px + x / xs, py+(y/ys), pz), + "CORONAL": lambda x,y: (px+(x/xs), py, + pz+(y/zs)), + "SAGITAL": lambda x,y: (px, py+(x/ys), + pz+(y/zs))} + function_orientation = abs_pixel[orient] for pixel_0,pixel_1 in self.pixel_list: # The position of the pixels in this list is relative (based only on # the area, and not the cursor position). # Let's calculate the absolute position # TODO: Optimize this!!!! - abs_pixel = {"AXIAL": [px+pixel_0/xs, py+(pixel_1/ys), pz], - "CORONAL": [px+(pixel_0/xs), py, pz+(pixel_1/zs)], - "SAGITAL": [px, py+(pixel_0/ys), pz+(pixel_1/zs)]} - yield abs_pixel[orient] - + yield function_orientation(pixel_0, pixel_1) diff --git a/invesalius/data/viewer_slice.py b/invesalius/data/viewer_slice.py index 16e8d7b..32a68d9 100755 --- a/invesalius/data/viewer_slice.py +++ b/invesalius/data/viewer_slice.py @@ -179,6 +179,8 @@ class Viewer(wx.Panel): def OnBrushClick(self, obj, evt_vtk): self.mouse_pressed = 1 + mouse_x, mouse_y = self.interactor.GetEventPosition() + self.pick.Pick(mouse_x, mouse_y, 0, self.ren) coord = self.GetCoordinateCursor() self.cursor.SetPosition(coord) @@ -203,6 +205,8 @@ class Viewer(wx.Panel): ps.Publisher().sendMessage('Update slice viewer') def OnBrushMove(self, obj, evt_vtk): + mouse_x, mouse_y = self.interactor.GetEventPosition() + self.pick.Pick(mouse_x, mouse_y, 0, self.ren) coord = self.GetCoordinateCursor() self.cursor.SetPosition(coord) self.cursor.SetEditionPosition(self.GetCoordinateCursorEdition()) @@ -237,8 +241,6 @@ class Viewer(wx.Panel): def GetCoordinate(self): # Find position - mouse_x, mouse_y = self.interactor.GetEventPosition() - self.pick.Pick(mouse_x, mouse_y, 0, self.ren) x, y, z = self.pick.GetPickPosition() # First we fix the position origin, based on vtkActor bounds @@ -277,15 +279,11 @@ class Viewer(wx.Panel): def GetCoordinateCursor(self): # Find position - mouse_x, mouse_y = self.interactor.GetEventPosition() - self.pick.Pick(mouse_x, mouse_y, 0, self.ren) x, y, z = self.pick.GetPickPosition() return x, y, z def GetCoordinateCursorEdition(self): # Find position - mouse_x, mouse_y = self.interactor.GetEventPosition() - self.pick.Pick(mouse_x, mouse_y, 0, self.ren) x, y, z = self.pick.GetPickPosition() # First we fix the position origin, based on vtkActor bounds -- libgit2 0.21.2