Commit 0ef22a3d1522de7f9009ae9e8d615273713e8f42
1 parent
38a8a71b
Exists in
master
and in
67 other branches
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 | 60 | #self.modes = []#['DEFAULT'] |
61 | 61 | self.left_pressed = 0 |
62 | 62 | self.right_pressed = 0 |
63 | + | |
64 | + self.spined_image = False #Use to control to spin | |
65 | + self.paned_image = False | |
66 | + | |
63 | 67 | self.last_position_mouse_move = () |
64 | 68 | self.state = const.STATE_DEFAULT |
65 | 69 | |
... | ... | @@ -274,7 +278,7 @@ class Viewer(wx.Panel): |
274 | 278 | if ((state == const.STATE_ZOOM) or (state == const.STATE_ZOOM_SL)): |
275 | 279 | self.interactor.Bind(wx.EVT_LEFT_DCLICK, self.OnUnZoom) |
276 | 280 | else: |
277 | - self.interactor.Bind(wx.EVT_LEFT_DCLICK, None) | |
281 | + self.interactor.Bind(wx.EVT_LEFT_DCLICK, self.OnUnSpinPan) | |
278 | 282 | |
279 | 283 | # Measures are using vtkPropPicker because they need to get which actor |
280 | 284 | # was picked. |
... | ... | @@ -389,9 +393,18 @@ class Viewer(wx.Panel): |
389 | 393 | self.last_position = position[1] |
390 | 394 | |
391 | 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 | 400 | if (self.left_pressed): |
393 | 401 | evt.Pan() |
394 | 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 | 409 | def OnPanClick(self, evt, obj): |
397 | 410 | evt.StartPan() |
... | ... | @@ -413,8 +426,28 @@ class Viewer(wx.Panel): |
413 | 426 | #self.Reposition(slice_data) |
414 | 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 | 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 | 449 | if (self.left_pressed): |
450 | + self.spined_image = True | |
418 | 451 | evt.Spin() |
419 | 452 | evt.OnRightButtonDown() |
420 | 453 | ... | ... |