Commit 0ef22a3d1522de7f9009ae9e8d615273713e8f42

Authored by Paulo Henrique Junqueira Amorim
1 parent 38a8a71b

ENH: Added feature to reset imagem position from spin and pan actions

Showing 1 changed file with 34 additions and 1 deletions   Show diff stats
invesalius/data/viewer_slice.py
@@ -60,6 +60,10 @@ class Viewer(wx.Panel): @@ -60,6 +60,10 @@ class Viewer(wx.Panel):
60 #self.modes = []#['DEFAULT'] 60 #self.modes = []#['DEFAULT']
61 self.left_pressed = 0 61 self.left_pressed = 0
62 self.right_pressed = 0 62 self.right_pressed = 0
  63 +
  64 + self.spined_image = False #Use to control to spin
  65 + self.paned_image = False
  66 +
63 self.last_position_mouse_move = () 67 self.last_position_mouse_move = ()
64 self.state = const.STATE_DEFAULT 68 self.state = const.STATE_DEFAULT
65 69
@@ -274,7 +278,7 @@ class Viewer(wx.Panel): @@ -274,7 +278,7 @@ class Viewer(wx.Panel):
274 if ((state == const.STATE_ZOOM) or (state == const.STATE_ZOOM_SL)): 278 if ((state == const.STATE_ZOOM) or (state == const.STATE_ZOOM_SL)):
275 self.interactor.Bind(wx.EVT_LEFT_DCLICK, self.OnUnZoom) 279 self.interactor.Bind(wx.EVT_LEFT_DCLICK, self.OnUnZoom)
276 else: 280 else:
277 - self.interactor.Bind(wx.EVT_LEFT_DCLICK, None) 281 + self.interactor.Bind(wx.EVT_LEFT_DCLICK, self.OnUnSpinPan)
278 282
279 # Measures are using vtkPropPicker because they need to get which actor 283 # Measures are using vtkPropPicker because they need to get which actor
280 # was picked. 284 # was picked.
@@ -389,9 +393,18 @@ class Viewer(wx.Panel): @@ -389,9 +393,18 @@ class Viewer(wx.Panel):
389 self.last_position = position[1] 393 self.last_position = position[1]
390 394
391 def OnPanMove(self, evt, obj): 395 def OnPanMove(self, evt, obj):
  396 + mouse_x, mouse_y = self.interactor.GetLastEventPosition()
  397 + ren = self.interactor.FindPokedRenderer(mouse_x, mouse_y)
  398 + cam = ren.GetActiveCamera()
  399 +
392 if (self.left_pressed): 400 if (self.left_pressed):
393 evt.Pan() 401 evt.Pan()
394 evt.OnRightButtonDown() 402 evt.OnRightButtonDown()
  403 + print dir(cam)
  404 + print "CamPosition >>", cam.GetPosition()
  405 + print "CamViewUp>>", cam.GetViewUp()
  406 + print "CamOrientation", cam.GetOrientation()
  407 + self.paned_image = True
395 408
396 def OnPanClick(self, evt, obj): 409 def OnPanClick(self, evt, obj):
397 evt.StartPan() 410 evt.StartPan()
@@ -413,8 +426,28 @@ class Viewer(wx.Panel): @@ -413,8 +426,28 @@ class Viewer(wx.Panel):
413 #self.Reposition(slice_data) 426 #self.Reposition(slice_data)
414 self.interactor.Render() 427 self.interactor.Render()
415 428
  429 + def OnUnSpinPan(self, evt):
  430 + orientation = self.orientation
  431 + proj = project.Project()
  432 + orig_orien = 1
  433 + mouse_x, mouse_y = self.interactor.GetLastEventPosition()
  434 + ren = self.interactor.FindPokedRenderer(mouse_x, mouse_y)
  435 + if((self.state == const.STATE_SPIN) and (self.spined_image)):
  436 + self.cam.SetViewUp(const.SLICE_POSITION[orig_orien][0][self.orientation])
  437 + self.interactor.Render()
  438 + self.spined_image = False
  439 + elif((self.state == const.STATE_PAN) and (self.paned_image)):
  440 + #self.cam.SetPosition(const.SLICE_POSITION[orig_orien][1][self.orientation])
  441 + ren.ResetCamera()
  442 + self.interactor.Render()
  443 + self.paned_image = False
  444 +
416 def OnSpinMove(self, evt, obj): 445 def OnSpinMove(self, evt, obj):
  446 + mouse_x, mouse_y = self.interactor.GetLastEventPosition()
  447 + ren = self.interactor.FindPokedRenderer(mouse_x, mouse_y)
  448 + cam = ren.GetActiveCamera()
417 if (self.left_pressed): 449 if (self.left_pressed):
  450 + self.spined_image = True
418 evt.Spin() 451 evt.Spin()
419 evt.OnRightButtonDown() 452 evt.OnRightButtonDown()
420 453