Commit 519c44b47cf8e1f371458de7518ee262cdaa0f43

Authored by Thiago Franco de Moraes
1 parent 45c7f6a4
Exists in get_pixel

Updated editor interactor style to new get position methods

invesalius/data/slice_.py
... ... @@ -434,7 +434,7 @@ class Slice(object):
434 434 thresh_min, thresh_max = self.current_mask.edition_threshold_range
435 435  
436 436 if hasattr(position, '__iter__'):
437   - py, px = position
  437 + px, py = position
438 438 if orientation == 'AXIAL':
439 439 sx = self.spacing[0]
440 440 sy = self.spacing[1]
... ...
invesalius/data/styles.py
... ... @@ -76,6 +76,7 @@ def get_LUT_value(data, window, level):
76 76 data.shape = shape
77 77 return data
78 78  
  79 +
79 80 class BaseImageInteractorStyle(vtk.vtkInteractorStyleImage):
80 81 def __init__(self, viewer):
81 82 self.right_pressed = False
... ... @@ -745,21 +746,13 @@ class EditorInteractorStyle(DefaultInteractorStyle):
745 746 #i.cursor.Show(0)
746 747 slice_data.cursor.Show()
747 748  
748   - self.picker.Pick(mouse_x, mouse_y, 0, render)
749   -
750   - coord = self.get_coordinate_cursor()
751   - position = slice_data.actor.GetInput().FindPoint(coord)
752   -
753   - if position != -1:
754   - coord = slice_data.actor.GetInput().GetPoint(position)
  749 + wx, wy, wz = viewer.get_coordinate_cursor(mouse_x, mouse_y, self.picker)
  750 + position = viewer.get_slice_pixel_coord_by_world_pos(wx, wy, wz)
755 751  
756   - slice_data.cursor.SetPosition(coord)
757 752 cursor = slice_data.cursor
758 753 radius = cursor.radius
759 754  
760   - if position < 0:
761   - position = viewer.calculate_matrix_position(coord)
762   -
  755 + slice_data.cursor.SetPosition((wx, wy, wz))
763 756 viewer.slice_.edit_mask_pixel(operation, cursor.GetPixels(),
764 757 position, radius, viewer.orientation)
765 758 #viewer._flush_buffer = True
... ... @@ -796,39 +789,19 @@ class EditorInteractorStyle(DefaultInteractorStyle):
796 789 elif operation == const.BRUSH_DRAW and iren.GetControlKey():
797 790 operation = const.BRUSH_ERASE
798 791  
799   - # TODO: Improve!
800   - #for i in self.slice_data_list:
801   - #i.cursor.Show(0)
802   -
803   - self.picker.Pick(mouse_x, mouse_y, 0, render)
804   -
805   - #if (self.pick.GetViewProp()):
806   - #self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_BLANK))
807   - #else:
808   - #self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT))
809   -
810   - coord = self.get_coordinate_cursor()
811   - position = viewer.slice_data.actor.GetInput().FindPoint(coord)
812   -
813   - # when position == -1 the cursos is not over the image, so is not
814   - # necessary to set the cursor position to world coordinate center of
815   - # pixel from slice image.
816   - if position != -1:
817   - coord = slice_data.actor.GetInput().GetPoint(position)
818   - slice_data.cursor.SetPosition(coord)
819   - #self.__update_cursor_position(slice_data, coord)
  792 + wx, wy, wz = viewer.get_coordinate_cursor(mouse_x, mouse_y, self.picker)
  793 + slice_data.cursor.SetPosition((wx, wy, wz))
820 794  
821 795 if (self.left_pressed):
822 796 cursor = slice_data.cursor
823   - position = slice_data.actor.GetInput().FindPoint(coord)
824 797 radius = cursor.radius
825 798  
826   - if position < 0:
827   - position = viewer.calculate_matrix_position(coord)
  799 + position = viewer.get_slice_pixel_coord_by_world_pos(wx, wy, wz)
828 800  
  801 + slice_data.cursor.SetPosition((wx, wy, wz))
829 802 viewer.slice_.edit_mask_pixel(operation, cursor.GetPixels(),
830   - position, radius, self.orientation)
831   - # TODO: To create a new function to reload images to viewer.
  803 + position, radius, viewer.orientation)
  804 +
832 805 viewer.OnScrollBar(update3D=False)
833 806  
834 807 else:
... ... @@ -878,18 +851,6 @@ class EditorInteractorStyle(DefaultInteractorStyle):
878 851 else:
879 852 self.OnScrollBackward(obj, evt)
880 853  
881   - def get_coordinate_cursor(self):
882   - # Find position
883   - x, y, z = self.picker.GetPickPosition()
884   - bounds = self.viewer.slice_data.actor.GetBounds()
885   - if bounds[0] == bounds[1]:
886   - x = bounds[0]
887   - elif bounds[2] == bounds[3]:
888   - y = bounds[2]
889   - elif bounds[4] == bounds[5]:
890   - z = bounds[4]
891   - return x, y, z
892   -
893 854  
894 855 class WatershedProgressWindow(object):
895 856 def __init__(self, process):
... ...