From 96dd7511bbbd28c9161dea9c3e2bc466be2646fe Mon Sep 17 00:00:00 2001 From: Thiago Franco de Moraes Date: Mon, 25 Mar 2013 16:25:55 -0300 Subject: [PATCH] Created a method to reset camera after a span camera --- invesalius/data/styles.py | 17 ++++++++++++++--- invesalius/data/viewer_slice.py | 27 +-------------------------- 2 files changed, 15 insertions(+), 29 deletions(-) diff --git a/invesalius/data/styles.py b/invesalius/data/styles.py index b7dddeb..2facbf0 100644 --- a/invesalius/data/styles.py +++ b/invesalius/data/styles.py @@ -285,15 +285,26 @@ class PanMoveInteractorStyle(ZoomInteractorStyle): """ Interactor style responsible for translate the camera. """ - def __init__(self): + def __init__(self, viewer): ZoomInteractorStyle.__init__(self) + + self.viewer = viewer + self.AddObserver("MouseMoveEvent", self.OnPanMove) + self.viewer.interactor.Bind(wx.EVT_LEFT_DCLICK, self.OnUnspan) def OnPanMove(self, obj, evt): if self.left_pressed: obj.Pan() obj.OnRightButtonDown() + def OnUnspan(self, evt): + iren = self.viewer.interactor + mouse_x, mouse_y = iren.GetLastEventPosition() + ren = iren.FindPokedRenderer(mouse_x, mouse_y) + ren.ResetCamera() + iren.Render() + class SpinInteractorStyle(ZoomInteractorStyle): """ @@ -305,7 +316,7 @@ class SpinInteractorStyle(ZoomInteractorStyle): self.viewer = viewer self.AddObserver("MouseMoveEvent", self.OnSpinMove) - self.viewer.interactor.Bind(wx.EVT_LEFT_DCLICK, self.OnUnspinPan) + self.viewer.interactor.Bind(wx.EVT_LEFT_DCLICK, self.OnUnspin) def OnSpinMove(self, obj, evt): iren = obj.GetInteractor() @@ -318,7 +329,7 @@ class SpinInteractorStyle(ZoomInteractorStyle): obj.Spin() obj.OnRightButtonDown() - def OnUnspinPan(self, evt): + def OnUnspin(self, evt): orig_orien = 1 iren = self.viewer.interactor mouse_x, mouse_y = iren.GetLastEventPosition() diff --git a/invesalius/data/viewer_slice.py b/invesalius/data/viewer_slice.py index 737cac9..071ae6a 100755 --- a/invesalius/data/viewer_slice.py +++ b/invesalius/data/viewer_slice.py @@ -218,7 +218,7 @@ class Viewer(wx.Panel): self.interactor.Render() elif state == const.STATE_PAN: - style = styles.PanMoveInteractorStyle() + style = styles.PanMoveInteractorStyle(self) self.style = style self.interactor.SetInteractorStyle(style) @@ -428,31 +428,6 @@ class Viewer(wx.Panel): #self.Reposition(slice_data) self.interactor.Render() - def UnspinPan(self): - orientation = self.orientation - proj = project.Project() - orig_orien = 1 - mouse_x, mouse_y = self.interactor.GetLastEventPosition() - ren = self.interactor.FindPokedRenderer(mouse_x, mouse_y) - - if((self.state == const.STATE_SPIN) and (self.spined_image)): - self.cam.SetViewUp(const.SLICE_POSITION[orig_orien][0][self.orientation]) - # Values are on ccw order, starting from the top: - if self.orientation == 'AXIAL': - values = [_("A"), _("R"), _("P"), _("L")] - elif self.orientation == 'CORONAL': - values = [_("T"), _("R"), _("B"), _("L")] - else: # 'SAGITAL': - values = [_("T"), _("P"), _("B"), _("A")] - - self.RenderTextDirection(values) - self.interactor.Render() - self.spined_image = False - elif((self.state == const.STATE_PAN) and (self.paned_image)): - ren.ResetCamera() - self.interactor.Render() - self.paned_image = False - def OnEnterInteractor(self, evt, obj): if (self.slice_.buffer_slices[self.orientation].mask is None): return -- libgit2 0.21.2