From 216213cba381fd8f3fec98a47933797828892432 Mon Sep 17 00:00:00 2001 From: tfmoraes Date: Thu, 23 Jul 2009 13:05:28 +0000 Subject: [PATCH] ENH: Now the cursor is following the mouse position --- invesalius/control.py | 2 +- invesalius/data/viewer_slice.py | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/invesalius/control.py b/invesalius/control.py index cf208c3..cfee9be 100755 --- a/invesalius/control.py +++ b/invesalius/control.py @@ -7,7 +7,7 @@ import data.imagedata_utils as utils import data.surface as surface import data.volume as volume import reader.dicom_reader as dicom -import reader.analyze_reader as analyze +#import reader.analyze_reader as analyze DEFAULT_THRESH_MODE = 0 diff --git a/invesalius/data/viewer_slice.py b/invesalius/data/viewer_slice.py index 50a23e5..32a0642 100755 --- a/invesalius/data/viewer_slice.py +++ b/invesalius/data/viewer_slice.py @@ -176,6 +176,7 @@ class Viewer(wx.Panel): coord = self.GetCoordinateCursor() self.cursor.SetPosition(coord) self.cursor.SetEditionPosition(self.GetCoordinateCursorEdition()) + self.__update_cursor_position(coord) self.ren.Render() if self._brush_cursor_op == 'Erase': @@ -360,7 +361,7 @@ class Viewer(wx.Panel): # Insert cursor cursor = ca.CursorCircle() cursor.SetOrientation(self.orientation) - self.__update_cursor_position() + self.__update_cursor_position([i for i in actor_bound[1::2]]) cursor.SetSpacing(imagedata.GetSpacing()) self.ren.AddActor(cursor.actor) self.ren.Render() @@ -369,14 +370,14 @@ class Viewer(wx.Panel): self.AppendMode('EDITOR') - def __update_cursor_position(self, position = None): - + def __update_cursor_position(self, position): + x, y, z = position if (self.cursor): slice_number = self.slice_number actor_bound = self.actor.GetBounds() - coordinates = {"SAGITAL": [actor_bound[1] + 1 + slice_number, actor_bound[3], actor_bound[5]], - "CORONAL": [actor_bound[1], actor_bound[3] + 1 + slice_number, actor_bound[5]], - "AXIAL": [actor_bound[1], actor_bound[3], actor_bound[5] + 1 + slice_number]} + coordinates = {"SAGITAL": [actor_bound[1] + 1 + slice_number, y, z], + "CORONAL": [x, actor_bound[3] - 1 - slice_number, z], + "AXIAL": [x, y, actor_bound[5] + 1 + slice_number]} self.cursor.SetPosition(coordinates[self.orientation]) def SetOrientation(self, orientation): @@ -430,7 +431,7 @@ class Viewer(wx.Panel): self.text_actor.SetInput(str(index)) self.slice_number = index self.__update_display_extent() - self.__update_cursor_position() + actor_bound = self.actor.GetBounds() def ChangeSliceNumber(self, pubsub_evt): index = pubsub_evt.data -- libgit2 0.21.2