Commit 4df1d0612d7041ac2ecc27173483a79dc32b9bec

Authored by Thiago Franco de Moraes
1 parent 2ae6b471
Exists in interactor_style

Created a new interactor style to handle the Zoom camera

invesalius/data/styles.py
... ... @@ -340,6 +340,32 @@ class SpinInteractorStyle(RightZoomInteractorStyle):
340 340 iren.Render()
341 341  
342 342  
  343 +class ZoomInteractorStyle(RightZoomInteractorStyle):
  344 + """
  345 + Interactor style responsible for zoom with movement of the mouse and the
  346 + left mouse button clicked.
  347 + """
  348 + def __init__(self, viewer):
  349 + RightZoomInteractorStyle.__init__(self)
  350 +
  351 + self.viewer = viewer
  352 +
  353 + self.AddObserver("MouseMoveEvent", self.OnZoomMoveLeft)
  354 + self.viewer.interactor.Bind(wx.EVT_LEFT_DCLICK, self.OnUnZoom)
  355 +
  356 + def OnZoomMoveLeft(self, obj, evt):
  357 + if self.left_pressed:
  358 + obj.Dolly()
  359 + obj.OnRightButtonDown()
  360 +
  361 + def OnUnZoom(self, evt):
  362 + mouse_x, mouse_y = self.viewer.interactor.GetLastEventPosition()
  363 + ren = self.viewer.interactor.FindPokedRenderer(mouse_x, mouse_y)
  364 + #slice_data = self.get_slice_data(ren)
  365 + ren.ResetCamera()
  366 + ren.ResetCameraClippingRange()
  367 + #self.Reposition(slice_data)
  368 + self.viewer.interactor.Render()
343 369  
344 370  
345 371 class ViewerStyle:
... ...
invesalius/data/viewer_slice.py
... ... @@ -231,6 +231,13 @@ class Viewer(wx.Panel):
231 231 self.interactor.SetInteractorStyle(style)
232 232 self.interactor.Render()
233 233  
  234 + elif state == const.STATE_ZOOM:
  235 + style = styles.ZoomInteractorStyle(self)
  236 +
  237 + self.style = style
  238 + self.interactor.SetInteractorStyle(style)
  239 + self.interactor.Render()
  240 +
234 241 else:
235 242 self.state = state
236 243 action = {
... ...