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 import data.surface as surface
8 8 import data.volume as volume
9 9 import reader.dicom_reader as dicom
10   -import reader.analyze_reader as analyze
  10 +#import reader.analyze_reader as analyze
11 11  
12 12 DEFAULT_THRESH_MODE = 0
13 13  
... ...
invesalius/data/viewer_slice.py
... ... @@ -176,6 +176,7 @@ class Viewer(wx.Panel):
176 176 coord = self.GetCoordinateCursor()
177 177 self.cursor.SetPosition(coord)
178 178 self.cursor.SetEditionPosition(self.GetCoordinateCursorEdition())
  179 + self.__update_cursor_position(coord)
179 180 self.ren.Render()
180 181  
181 182 if self._brush_cursor_op == 'Erase':
... ... @@ -360,7 +361,7 @@ class Viewer(wx.Panel):
360 361 # Insert cursor
361 362 cursor = ca.CursorCircle()
362 363 cursor.SetOrientation(self.orientation)
363   - self.__update_cursor_position()
  364 + self.__update_cursor_position([i for i in actor_bound[1::2]])
364 365 cursor.SetSpacing(imagedata.GetSpacing())
365 366 self.ren.AddActor(cursor.actor)
366 367 self.ren.Render()
... ... @@ -369,14 +370,14 @@ class Viewer(wx.Panel):
369 370  
370 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 375 if (self.cursor):
375 376 slice_number = self.slice_number
376 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 381 self.cursor.SetPosition(coordinates[self.orientation])
381 382  
382 383 def SetOrientation(self, orientation):
... ... @@ -430,7 +431,7 @@ class Viewer(wx.Panel):
430 431 self.text_actor.SetInput(str(index))
431 432 self.slice_number = index
432 433 self.__update_display_extent()
433   - self.__update_cursor_position()
  434 + actor_bound = self.actor.GetBounds()
434 435  
435 436 def ChangeSliceNumber(self, pubsub_evt):
436 437 index = pubsub_evt.data
... ...