Commit 96dd7511bbbd28c9161dea9c3e2bc466be2646fe
1 parent
1a85e2a4
Exists in
interactor_style
Created a method to reset camera after a span camera
Showing
2 changed files
with
15 additions
and
29 deletions
Show diff stats
invesalius/data/styles.py
@@ -285,15 +285,26 @@ class PanMoveInteractorStyle(ZoomInteractorStyle): | @@ -285,15 +285,26 @@ class PanMoveInteractorStyle(ZoomInteractorStyle): | ||
285 | """ | 285 | """ |
286 | Interactor style responsible for translate the camera. | 286 | Interactor style responsible for translate the camera. |
287 | """ | 287 | """ |
288 | - def __init__(self): | 288 | + def __init__(self, viewer): |
289 | ZoomInteractorStyle.__init__(self) | 289 | ZoomInteractorStyle.__init__(self) |
290 | + | ||
291 | + self.viewer = viewer | ||
292 | + | ||
290 | self.AddObserver("MouseMoveEvent", self.OnPanMove) | 293 | self.AddObserver("MouseMoveEvent", self.OnPanMove) |
294 | + self.viewer.interactor.Bind(wx.EVT_LEFT_DCLICK, self.OnUnspan) | ||
291 | 295 | ||
292 | def OnPanMove(self, obj, evt): | 296 | def OnPanMove(self, obj, evt): |
293 | if self.left_pressed: | 297 | if self.left_pressed: |
294 | obj.Pan() | 298 | obj.Pan() |
295 | obj.OnRightButtonDown() | 299 | obj.OnRightButtonDown() |
296 | 300 | ||
301 | + def OnUnspan(self, evt): | ||
302 | + iren = self.viewer.interactor | ||
303 | + mouse_x, mouse_y = iren.GetLastEventPosition() | ||
304 | + ren = iren.FindPokedRenderer(mouse_x, mouse_y) | ||
305 | + ren.ResetCamera() | ||
306 | + iren.Render() | ||
307 | + | ||
297 | 308 | ||
298 | class SpinInteractorStyle(ZoomInteractorStyle): | 309 | class SpinInteractorStyle(ZoomInteractorStyle): |
299 | """ | 310 | """ |
@@ -305,7 +316,7 @@ class SpinInteractorStyle(ZoomInteractorStyle): | @@ -305,7 +316,7 @@ class SpinInteractorStyle(ZoomInteractorStyle): | ||
305 | self.viewer = viewer | 316 | self.viewer = viewer |
306 | 317 | ||
307 | self.AddObserver("MouseMoveEvent", self.OnSpinMove) | 318 | self.AddObserver("MouseMoveEvent", self.OnSpinMove) |
308 | - self.viewer.interactor.Bind(wx.EVT_LEFT_DCLICK, self.OnUnspinPan) | 319 | + self.viewer.interactor.Bind(wx.EVT_LEFT_DCLICK, self.OnUnspin) |
309 | 320 | ||
310 | def OnSpinMove(self, obj, evt): | 321 | def OnSpinMove(self, obj, evt): |
311 | iren = obj.GetInteractor() | 322 | iren = obj.GetInteractor() |
@@ -318,7 +329,7 @@ class SpinInteractorStyle(ZoomInteractorStyle): | @@ -318,7 +329,7 @@ class SpinInteractorStyle(ZoomInteractorStyle): | ||
318 | obj.Spin() | 329 | obj.Spin() |
319 | obj.OnRightButtonDown() | 330 | obj.OnRightButtonDown() |
320 | 331 | ||
321 | - def OnUnspinPan(self, evt): | 332 | + def OnUnspin(self, evt): |
322 | orig_orien = 1 | 333 | orig_orien = 1 |
323 | iren = self.viewer.interactor | 334 | iren = self.viewer.interactor |
324 | mouse_x, mouse_y = iren.GetLastEventPosition() | 335 | mouse_x, mouse_y = iren.GetLastEventPosition() |
invesalius/data/viewer_slice.py
@@ -218,7 +218,7 @@ class Viewer(wx.Panel): | @@ -218,7 +218,7 @@ class Viewer(wx.Panel): | ||
218 | self.interactor.Render() | 218 | self.interactor.Render() |
219 | 219 | ||
220 | elif state == const.STATE_PAN: | 220 | elif state == const.STATE_PAN: |
221 | - style = styles.PanMoveInteractorStyle() | 221 | + style = styles.PanMoveInteractorStyle(self) |
222 | 222 | ||
223 | self.style = style | 223 | self.style = style |
224 | self.interactor.SetInteractorStyle(style) | 224 | self.interactor.SetInteractorStyle(style) |
@@ -428,31 +428,6 @@ class Viewer(wx.Panel): | @@ -428,31 +428,6 @@ class Viewer(wx.Panel): | ||
428 | #self.Reposition(slice_data) | 428 | #self.Reposition(slice_data) |
429 | self.interactor.Render() | 429 | self.interactor.Render() |
430 | 430 | ||
431 | - def UnspinPan(self): | ||
432 | - orientation = self.orientation | ||
433 | - proj = project.Project() | ||
434 | - orig_orien = 1 | ||
435 | - mouse_x, mouse_y = self.interactor.GetLastEventPosition() | ||
436 | - ren = self.interactor.FindPokedRenderer(mouse_x, mouse_y) | ||
437 | - | ||
438 | - if((self.state == const.STATE_SPIN) and (self.spined_image)): | ||
439 | - self.cam.SetViewUp(const.SLICE_POSITION[orig_orien][0][self.orientation]) | ||
440 | - # Values are on ccw order, starting from the top: | ||
441 | - if self.orientation == 'AXIAL': | ||
442 | - values = [_("A"), _("R"), _("P"), _("L")] | ||
443 | - elif self.orientation == 'CORONAL': | ||
444 | - values = [_("T"), _("R"), _("B"), _("L")] | ||
445 | - else: # 'SAGITAL': | ||
446 | - values = [_("T"), _("P"), _("B"), _("A")] | ||
447 | - | ||
448 | - self.RenderTextDirection(values) | ||
449 | - self.interactor.Render() | ||
450 | - self.spined_image = False | ||
451 | - elif((self.state == const.STATE_PAN) and (self.paned_image)): | ||
452 | - ren.ResetCamera() | ||
453 | - self.interactor.Render() | ||
454 | - self.paned_image = False | ||
455 | - | ||
456 | def OnEnterInteractor(self, evt, obj): | 431 | def OnEnterInteractor(self, evt, obj): |
457 | if (self.slice_.buffer_slices[self.orientation].mask is None): | 432 | if (self.slice_.buffer_slices[self.orientation].mask is None): |
458 | return | 433 | return |