Commit 345aba65c6cc4832992fdeeae9b79225ddfc3017

Authored by tfmoraes
1 parent 985da2aa

ENH: Removed the redundant pick.pick in the editor

invesalius/data/cursor_actors.py
... ... @@ -300,13 +300,15 @@ class CursorRectangle:
300 300 px, py, pz = self.edition_position
301 301 orient = self.orientation
302 302 xs, ys, zs = self.spacing
  303 + abs_pixel = {"AXIAL": lambda x,y: (px + x / xs, py+(y/ys), pz),
  304 + "CORONAL": lambda x,y: (px+(x/xs), py,
  305 + pz+(y/zs)),
  306 + "SAGITAL": lambda x,y: (px, py+(x/ys),
  307 + pz+(y/zs))}
  308 + function_orientation = abs_pixel[orient]
303 309 for pixel_0,pixel_1 in self.pixel_list:
304 310 # The position of the pixels in this list is relative (based only on
305 311 # the area, and not the cursor position).
306 312 # Let's calculate the absolute position
307 313 # TODO: Optimize this!!!!
308   - abs_pixel = {"AXIAL": [px+pixel_0/xs, py+(pixel_1/ys), pz],
309   - "CORONAL": [px+(pixel_0/xs), py, pz+(pixel_1/zs)],
310   - "SAGITAL": [px, py+(pixel_0/ys), pz+(pixel_1/zs)]}
311   - yield abs_pixel[orient]
312   -
  314 + yield function_orientation(pixel_0, pixel_1)
... ...
invesalius/data/viewer_slice.py
... ... @@ -179,6 +179,8 @@ class Viewer(wx.Panel):
179 179 def OnBrushClick(self, obj, evt_vtk):
180 180 self.mouse_pressed = 1
181 181  
  182 + mouse_x, mouse_y = self.interactor.GetEventPosition()
  183 + self.pick.Pick(mouse_x, mouse_y, 0, self.ren)
182 184  
183 185 coord = self.GetCoordinateCursor()
184 186 self.cursor.SetPosition(coord)
... ... @@ -203,6 +205,8 @@ class Viewer(wx.Panel):
203 205 ps.Publisher().sendMessage('Update slice viewer')
204 206  
205 207 def OnBrushMove(self, obj, evt_vtk):
  208 + mouse_x, mouse_y = self.interactor.GetEventPosition()
  209 + self.pick.Pick(mouse_x, mouse_y, 0, self.ren)
206 210 coord = self.GetCoordinateCursor()
207 211 self.cursor.SetPosition(coord)
208 212 self.cursor.SetEditionPosition(self.GetCoordinateCursorEdition())
... ... @@ -237,8 +241,6 @@ class Viewer(wx.Panel):
237 241  
238 242 def GetCoordinate(self):
239 243 # Find position
240   - mouse_x, mouse_y = self.interactor.GetEventPosition()
241   - self.pick.Pick(mouse_x, mouse_y, 0, self.ren)
242 244 x, y, z = self.pick.GetPickPosition()
243 245  
244 246 # First we fix the position origin, based on vtkActor bounds
... ... @@ -277,15 +279,11 @@ class Viewer(wx.Panel):
277 279  
278 280 def GetCoordinateCursor(self):
279 281 # Find position
280   - mouse_x, mouse_y = self.interactor.GetEventPosition()
281   - self.pick.Pick(mouse_x, mouse_y, 0, self.ren)
282 282 x, y, z = self.pick.GetPickPosition()
283 283 return x, y, z
284 284  
285 285 def GetCoordinateCursorEdition(self):
286 286 # Find position
287   - mouse_x, mouse_y = self.interactor.GetEventPosition()
288   - self.pick.Pick(mouse_x, mouse_y, 0, self.ren)
289 287 x, y, z = self.pick.GetPickPosition()
290 288  
291 289 # First we fix the position origin, based on vtkActor bounds
... ...