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 | 285 | """ |
| 286 | 286 | Interactor style responsible for translate the camera. |
| 287 | 287 | """ |
| 288 | - def __init__(self): | |
| 288 | + def __init__(self, viewer): | |
| 289 | 289 | ZoomInteractorStyle.__init__(self) |
| 290 | + | |
| 291 | + self.viewer = viewer | |
| 292 | + | |
| 290 | 293 | self.AddObserver("MouseMoveEvent", self.OnPanMove) |
| 294 | + self.viewer.interactor.Bind(wx.EVT_LEFT_DCLICK, self.OnUnspan) | |
| 291 | 295 | |
| 292 | 296 | def OnPanMove(self, obj, evt): |
| 293 | 297 | if self.left_pressed: |
| 294 | 298 | obj.Pan() |
| 295 | 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 | 309 | class SpinInteractorStyle(ZoomInteractorStyle): |
| 299 | 310 | """ |
| ... | ... | @@ -305,7 +316,7 @@ class SpinInteractorStyle(ZoomInteractorStyle): |
| 305 | 316 | self.viewer = viewer |
| 306 | 317 | |
| 307 | 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 | 321 | def OnSpinMove(self, obj, evt): |
| 311 | 322 | iren = obj.GetInteractor() |
| ... | ... | @@ -318,7 +329,7 @@ class SpinInteractorStyle(ZoomInteractorStyle): |
| 318 | 329 | obj.Spin() |
| 319 | 330 | obj.OnRightButtonDown() |
| 320 | 331 | |
| 321 | - def OnUnspinPan(self, evt): | |
| 332 | + def OnUnspin(self, evt): | |
| 322 | 333 | orig_orien = 1 |
| 323 | 334 | iren = self.viewer.interactor |
| 324 | 335 | mouse_x, mouse_y = iren.GetLastEventPosition() | ... | ... |
invesalius/data/viewer_slice.py
| ... | ... | @@ -218,7 +218,7 @@ class Viewer(wx.Panel): |
| 218 | 218 | self.interactor.Render() |
| 219 | 219 | |
| 220 | 220 | elif state == const.STATE_PAN: |
| 221 | - style = styles.PanMoveInteractorStyle() | |
| 221 | + style = styles.PanMoveInteractorStyle(self) | |
| 222 | 222 | |
| 223 | 223 | self.style = style |
| 224 | 224 | self.interactor.SetInteractorStyle(style) |
| ... | ... | @@ -428,31 +428,6 @@ class Viewer(wx.Panel): |
| 428 | 428 | #self.Reposition(slice_data) |
| 429 | 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 | 431 | def OnEnterInteractor(self, evt, obj): |
| 457 | 432 | if (self.slice_.buffer_slices[self.orientation].mask is None): |
| 458 | 433 | return | ... | ... |