Commit 216213cba381fd8f3fec98a47933797828892432

Authored by tfmoraes
1 parent 32a72e8b

ENH: Now the cursor is following the mouse position

invesalius/control.py
@@ -7,7 +7,7 @@ import data.imagedata_utils as utils @@ -7,7 +7,7 @@ import data.imagedata_utils as utils
7 import data.surface as surface 7 import data.surface as surface
8 import data.volume as volume 8 import data.volume as volume
9 import reader.dicom_reader as dicom 9 import reader.dicom_reader as dicom
10 -import reader.analyze_reader as analyze 10 +#import reader.analyze_reader as analyze
11 11
12 DEFAULT_THRESH_MODE = 0 12 DEFAULT_THRESH_MODE = 0
13 13
invesalius/data/viewer_slice.py
@@ -176,6 +176,7 @@ class Viewer(wx.Panel): @@ -176,6 +176,7 @@ class Viewer(wx.Panel):
176 coord = self.GetCoordinateCursor() 176 coord = self.GetCoordinateCursor()
177 self.cursor.SetPosition(coord) 177 self.cursor.SetPosition(coord)
178 self.cursor.SetEditionPosition(self.GetCoordinateCursorEdition()) 178 self.cursor.SetEditionPosition(self.GetCoordinateCursorEdition())
  179 + self.__update_cursor_position(coord)
179 self.ren.Render() 180 self.ren.Render()
180 181
181 if self._brush_cursor_op == 'Erase': 182 if self._brush_cursor_op == 'Erase':
@@ -360,7 +361,7 @@ class Viewer(wx.Panel): @@ -360,7 +361,7 @@ class Viewer(wx.Panel):
360 # Insert cursor 361 # Insert cursor
361 cursor = ca.CursorCircle() 362 cursor = ca.CursorCircle()
362 cursor.SetOrientation(self.orientation) 363 cursor.SetOrientation(self.orientation)
363 - self.__update_cursor_position() 364 + self.__update_cursor_position([i for i in actor_bound[1::2]])
364 cursor.SetSpacing(imagedata.GetSpacing()) 365 cursor.SetSpacing(imagedata.GetSpacing())
365 self.ren.AddActor(cursor.actor) 366 self.ren.AddActor(cursor.actor)
366 self.ren.Render() 367 self.ren.Render()
@@ -369,14 +370,14 @@ class Viewer(wx.Panel): @@ -369,14 +370,14 @@ class Viewer(wx.Panel):
369 370
370 self.AppendMode('EDITOR') 371 self.AppendMode('EDITOR')
371 372
372 - def __update_cursor_position(self, position = None):  
373 - 373 + def __update_cursor_position(self, position):
  374 + x, y, z = position
374 if (self.cursor): 375 if (self.cursor):
375 slice_number = self.slice_number 376 slice_number = self.slice_number
376 actor_bound = self.actor.GetBounds() 377 actor_bound = self.actor.GetBounds()
377 - coordinates = {"SAGITAL": [actor_bound[1] + 1 + slice_number, actor_bound[3], actor_bound[5]],  
378 - "CORONAL": [actor_bound[1], actor_bound[3] + 1 + slice_number, actor_bound[5]],  
379 - "AXIAL": [actor_bound[1], actor_bound[3], actor_bound[5] + 1 + slice_number]} 378 + coordinates = {"SAGITAL": [actor_bound[1] + 1 + slice_number, y, z],
  379 + "CORONAL": [x, actor_bound[3] - 1 - slice_number, z],
  380 + "AXIAL": [x, y, actor_bound[5] + 1 + slice_number]}
380 self.cursor.SetPosition(coordinates[self.orientation]) 381 self.cursor.SetPosition(coordinates[self.orientation])
381 382
382 def SetOrientation(self, orientation): 383 def SetOrientation(self, orientation):
@@ -430,7 +431,7 @@ class Viewer(wx.Panel): @@ -430,7 +431,7 @@ class Viewer(wx.Panel):
430 self.text_actor.SetInput(str(index)) 431 self.text_actor.SetInput(str(index))
431 self.slice_number = index 432 self.slice_number = index
432 self.__update_display_extent() 433 self.__update_display_extent()
433 - self.__update_cursor_position() 434 + actor_bound = self.actor.GetBounds()
434 435
435 def ChangeSliceNumber(self, pubsub_evt): 436 def ChangeSliceNumber(self, pubsub_evt):
436 index = pubsub_evt.data 437 index = pubsub_evt.data