Commit 1a6769c67b7a3bc66b6d9b699a72a7ac965d346b

Authored by tfmoraes
1 parent ddde2457

FIX: The function that verifies if the point is into the image now take counts t…

…he original orientation. Related to #202
Showing 1 changed file with 17 additions and 10 deletions   Show diff stats
invesalius/data/viewer_slice.py
@@ -681,6 +681,7 @@ class Viewer(wx.Panel): @@ -681,6 +681,7 @@ class Viewer(wx.Panel):
681 coord = self.CalcultateScrollPosition(coord_cross) 681 coord = self.CalcultateScrollPosition(coord_cross)
682 ps.Publisher().sendMessage('Update cross position', 682 ps.Publisher().sendMessage('Update cross position',
683 (self.orientation, coord_cross)) 683 (self.orientation, coord_cross))
  684 + print "Scroll to", coord
684 self.ScrollSlice(coord) 685 self.ScrollSlice(coord)
685 self.interactor.Render() 686 self.interactor.Render()
686 687
@@ -720,6 +721,9 @@ class Viewer(wx.Panel): @@ -720,6 +721,9 @@ class Viewer(wx.Panel):
720 # and the last, axial. 721 # and the last, axial.
721 x, y, z = coord 722 x, y, z = coord
722 723
  724 + proj = project.Project()
  725 + orig_orien = proj.original_orientation
  726 +
723 # First we fix the position origin, based on vtkActor bounds 727 # First we fix the position origin, based on vtkActor bounds
724 bounds = self.actor.GetBounds() 728 bounds = self.actor.GetBounds()
725 bound_xi, bound_xf, bound_yi, bound_yf, bound_zi, bound_zf = bounds 729 bound_xi, bound_xf, bound_yi, bound_yf, bound_zi, bound_zf = bounds
@@ -734,8 +738,8 @@ class Viewer(wx.Panel): @@ -734,8 +738,8 @@ class Viewer(wx.Panel):
734 y = y/spacing_y 738 y = y/spacing_y
735 z = z/spacing_z 739 z = z/spacing_z
736 740
737 - proj = project.Project()  
738 - orig_orien = proj.original_orientation 741 + x, y, z = self._assert_coord_into_image([x, y, z])
  742 +
739 # Based on the current orientation, we define 3D position 743 # Based on the current orientation, we define 3D position
740 # Sagita, coronal, axial 744 # Sagita, coronal, axial
741 coordinates = {const.AXIAL: [x, y, z], 745 coordinates = {const.AXIAL: [x, y, z],
@@ -747,14 +751,6 @@ class Viewer(wx.Panel): @@ -747,14 +751,6 @@ class Viewer(wx.Panel):
747 # According to vtkImageData extent, we limit min and max value 751 # According to vtkImageData extent, we limit min and max value
748 # If this is not done, a VTK Error occurs when mouse is pressed outside 752 # If this is not done, a VTK Error occurs when mouse is pressed outside
749 # vtkImageData extent 753 # vtkImageData extent
750 - extent = self.imagedata.GetWholeExtent()  
751 - extent_min = extent[0], extent[2], extent[4]  
752 - extent_max = extent[1], extent[3], extent[5]  
753 - for index in xrange(3):  
754 - if coord[index] > extent_max[index]:  
755 - coord[index] = extent_max[index]  
756 - elif coord[index] < extent_min[index]:  
757 - coord[index] = extent_min[index]  
758 return coord 754 return coord
759 755
760 def get_coordinate_cursor(self): 756 def get_coordinate_cursor(self):
@@ -1400,3 +1396,14 @@ class Viewer(wx.Panel): @@ -1400,3 +1396,14 @@ class Viewer(wx.Panel):
1400 and zi <= z <= zf: 1396 and zi <= z <= zf:
1401 return True 1397 return True
1402 return False 1398 return False
  1399 +
  1400 + def _assert_coord_into_image(self, coord):
  1401 + extent = self.imagedata.GetWholeExtent()
  1402 + extent_min = extent[0], extent[2], extent[4]
  1403 + extent_max = extent[1], extent[3], extent[5]
  1404 + for index in xrange(3):
  1405 + if coord[index] > extent_max[index]:
  1406 + coord[index] = extent_max[index]
  1407 + elif coord[index] < extent_min[index]:
  1408 + coord[index] = extent_min[index]
  1409 + return coord