Commit 4811ecf0f4aac5b53ff7c1f777a6e1273d9c2125

Authored by tfmoraes
1 parent ecfd1f2e

ENH: The cursor is always above the slice in all orientations

Showing 1 changed file with 28 additions and 29 deletions   Show diff stats
invesalius/data/viewer_slice.py
... ... @@ -550,7 +550,8 @@ class Viewer(wx.Panel):
550 550 self.pick.Pick(mouse_x, mouse_y, self.slice_data_list[0].number, renderer)
551 551 coord_cross = self.get_coordinate_cursor()
552 552 coord = self.get_coordinate()
553   - ps.Publisher().sendMessage('Update cross position', coord_cross)
  553 + ps.Publisher().sendMessage('Update cross position',
  554 + (self.orientation, coord_cross))
554 555 ps.Publisher().sendMessage(('Set scroll position', 'SAGITAL'),
555 556 coord[0])
556 557 ps.Publisher().sendMessage(('Set scroll position', 'CORONAL'),
... ... @@ -564,7 +565,8 @@ class Viewer(wx.Panel):
564 565 self.pick.Pick(mouse_x, mouse_y, self.slice_data_list[0].number, renderer)
565 566 coord_cross = self.get_coordinate_cursor()
566 567 coord = self.get_coordinate()
567   - ps.Publisher().sendMessage('Update cross position', coord_cross)
  568 + ps.Publisher().sendMessage('Update cross position',
  569 + (self.orientation, coord_cross))
568 570 ps.Publisher().sendMessage(('Set scroll position', 'SAGITAL'),
569 571 coord[0])
570 572 ps.Publisher().sendMessage(('Set scroll position', 'CORONAL'),
... ... @@ -873,7 +875,8 @@ class Viewer(wx.Panel):
873 875 renderer.AddActor(cross_actor)
874 876  
875 877 def __update_cross_position(self, pubsub_evt):
876   - x, y, z = pubsub_evt.data
  878 + x, y, z = pubsub_evt.data[1]
  879 + orientation = pubsub_evt.data[0]
877 880 #xi, yi, zi = self.vline.GetPoint1()
878 881 #xf, yf, zf = self.vline.GetPoint2()
879 882 #self.vline.SetPoint1(x, yi, z)
... ... @@ -894,12 +897,10 @@ class Viewer(wx.Panel):
894 897 print self.orientation
895 898 print x, y, z
896 899 print actor_bound
897   - print extent
898   - print
899 900  
900   - xy = [x, y, actor_bound[4]]
901   - yz = [actor_bound[0], y, z]
902   - xz = [x, actor_bound[2], z]
  901 + yz = [x + abs(x * 0.001), y, z]
  902 + xz = [x, y - abs(y * 0.001), z]
  903 + xy = [x, y, z + abs(z * 0.001)]
903 904  
904 905 proj = project.Project()
905 906 orig_orien = proj.original_orientation
... ... @@ -911,15 +912,16 @@ class Viewer(wx.Panel):
911 912 else:
912 913 coordinates = {"SAGITAL": yz, "CORONAL": xz, "AXIAL": xy}
913 914  
914   - pos = [x, y, z]
915   - if self.orientation == "AXIAL":
916   - pos[2] = pos[2] * 1.001
917   - elif self.orientation == "SAGITAL":
918   - pos[0] = pos[0] * 1.001
919   - else:
920   - pos[1] = pos[1] * 1.001
921   - print ">POS", pos
922   - self.cross.SetFocalPoint(pos)
  915 + #pos = [x, y, z]
  916 + #if orientation == "AXIAL":
  917 + # pos[2] += abs(pos[2] * 0.001)
  918 + #elif orientation == "SAGITAL":
  919 + # pos[0] += abs(pos[0] * 0.001)
  920 + #elif orientation == "CORONAL":
  921 + # pos[1] -= abs(pos[1] * 0.001)
  922 + #print ">POS", pos
  923 + #print
  924 + self.cross.SetFocalPoint(coordinates[orientation])
923 925  
924 926 #print
925 927 #print slice_number
... ... @@ -935,9 +937,14 @@ class Viewer(wx.Panel):
935 937 slice_number = slice_data.number
936 938 actor_bound = slice_data.actor.GetBounds()
937 939  
938   - yz = [actor_bound[1] + 1 + slice_number, y, z]
939   - xz = [x, actor_bound[3] - 1 - slice_number, z]
940   - xy = [x, y, actor_bound[5] + 1 + slice_number]
  940 + print
  941 + print self.orientation
  942 + print x, y, z
  943 + print actor_bound
  944 +
  945 + yz = [x + abs(x * 0.001), y, z]
  946 + xz = [x, y - abs(y * 0.001), z]
  947 + xy = [x, y, z + abs(z * 0.001)]
941 948  
942 949 proj = project.Project()
943 950 orig_orien = proj.original_orientation
... ... @@ -949,15 +956,7 @@ class Viewer(wx.Panel):
949 956 else:
950 957 coordinates = {"SAGITAL": yz, "CORONAL": xz, "AXIAL": xy}
951 958  
952   - pos = [x, y, z]
953   - if self.orientation == "AXIAL":
954   - pos[2] = pos[2] * 1.001
955   - elif self.orientation == "SAGITAL":
956   - pos[0] = pos[0] * 1.001
957   - else:
958   - pos[1] = pos[1] * 1.001
959   - print ">POS", pos
960   - slice_data.cursor.SetPosition(pos)
  959 + slice_data.cursor.SetPosition(coordinates[self.orientation])
961 960  
962 961 def SetOrientation(self, orientation):
963 962 self.orientation = orientation
... ...