From 4df1d0612d7041ac2ecc27173483a79dc32b9bec Mon Sep 17 00:00:00 2001 From: Thiago Franco de Moraes Date: Tue, 26 Mar 2013 09:12:00 -0300 Subject: [PATCH] Created a new interactor style to handle the Zoom camera --- invesalius/data/styles.py | 26 ++++++++++++++++++++++++++ invesalius/data/viewer_slice.py | 7 +++++++ 2 files changed, 33 insertions(+), 0 deletions(-) diff --git a/invesalius/data/styles.py b/invesalius/data/styles.py index 94af109..f06f5d7 100644 --- a/invesalius/data/styles.py +++ b/invesalius/data/styles.py @@ -340,6 +340,32 @@ class SpinInteractorStyle(RightZoomInteractorStyle): iren.Render() +class ZoomInteractorStyle(RightZoomInteractorStyle): + """ + Interactor style responsible for zoom with movement of the mouse and the + left mouse button clicked. + """ + def __init__(self, viewer): + RightZoomInteractorStyle.__init__(self) + + self.viewer = viewer + + self.AddObserver("MouseMoveEvent", self.OnZoomMoveLeft) + self.viewer.interactor.Bind(wx.EVT_LEFT_DCLICK, self.OnUnZoom) + + def OnZoomMoveLeft(self, obj, evt): + if self.left_pressed: + obj.Dolly() + obj.OnRightButtonDown() + + def OnUnZoom(self, evt): + mouse_x, mouse_y = self.viewer.interactor.GetLastEventPosition() + ren = self.viewer.interactor.FindPokedRenderer(mouse_x, mouse_y) + #slice_data = self.get_slice_data(ren) + ren.ResetCamera() + ren.ResetCameraClippingRange() + #self.Reposition(slice_data) + self.viewer.interactor.Render() class ViewerStyle: diff --git a/invesalius/data/viewer_slice.py b/invesalius/data/viewer_slice.py index 071ae6a..b7a177e 100755 --- a/invesalius/data/viewer_slice.py +++ b/invesalius/data/viewer_slice.py @@ -231,6 +231,13 @@ class Viewer(wx.Panel): self.interactor.SetInteractorStyle(style) self.interactor.Render() + elif state == const.STATE_ZOOM: + style = styles.ZoomInteractorStyle(self) + + self.style = style + self.interactor.SetInteractorStyle(style) + self.interactor.Render() + else: self.state = state action = { -- libgit2 0.21.2