Commit 58ec7c3a2b56db90ad6ca5fc06da8df731481634
1 parent
4df1d061
Exists in
interactor_style
Created a new interactor style to handle the Zoom camera by selecting a region
Showing
2 changed files
with
24 additions
and
0 deletions
Show diff stats
invesalius/data/styles.py
@@ -368,6 +368,23 @@ class ZoomInteractorStyle(RightZoomInteractorStyle): | @@ -368,6 +368,23 @@ class ZoomInteractorStyle(RightZoomInteractorStyle): | ||
368 | self.viewer.interactor.Render() | 368 | self.viewer.interactor.Render() |
369 | 369 | ||
370 | 370 | ||
371 | +class ZoomSLInteractorStyle(vtk.vtkInteractorStyleRubberBandZoom): | ||
372 | + """ | ||
373 | + Interactor style responsible for zoom by selecting a region. | ||
374 | + """ | ||
375 | + def __init__(self, viewer): | ||
376 | + self.viewer = viewer | ||
377 | + self.viewer.interactor.Bind(wx.EVT_LEFT_DCLICK, self.OnUnZoom) | ||
378 | + | ||
379 | + def OnUnZoom(self, evt): | ||
380 | + mouse_x, mouse_y = self.viewer.interactor.GetLastEventPosition() | ||
381 | + ren = self.viewer.interactor.FindPokedRenderer(mouse_x, mouse_y) | ||
382 | + #slice_data = self.get_slice_data(ren) | ||
383 | + ren.ResetCamera() | ||
384 | + ren.ResetCameraClippingRange() | ||
385 | + #self.Reposition(slice_data) | ||
386 | + self.viewer.interactor.Render() | ||
387 | + | ||
371 | class ViewerStyle: | 388 | class ViewerStyle: |
372 | def __init__(self): | 389 | def __init__(self): |
373 | self.interactor = None | 390 | self.interactor = None |
invesalius/data/viewer_slice.py
@@ -238,6 +238,13 @@ class Viewer(wx.Panel): | @@ -238,6 +238,13 @@ class Viewer(wx.Panel): | ||
238 | self.interactor.SetInteractorStyle(style) | 238 | self.interactor.SetInteractorStyle(style) |
239 | self.interactor.Render() | 239 | self.interactor.Render() |
240 | 240 | ||
241 | + elif state == const.STATE_ZOOM_SL: | ||
242 | + style = styles.ZoomSLInteractorStyle(self) | ||
243 | + | ||
244 | + self.style = style | ||
245 | + self.interactor.SetInteractorStyle(style) | ||
246 | + self.interactor.Render() | ||
247 | + | ||
241 | else: | 248 | else: |
242 | self.state = state | 249 | self.state = state |
243 | action = { | 250 | action = { |