Commit be359ec485ba8ddd0cea261aa911695fc5a09361
1 parent
b2b98a16
Exists in
rotvol
Improvements
Showing
1 changed file
with
32 additions
and
17 deletions
Show diff stats
invesalius/data/styles.py
... | ... | @@ -1419,9 +1419,14 @@ class ReorientImageInteractorStyle(DefaultInteractorStyle): |
1419 | 1419 | |
1420 | 1420 | self.actors = [] |
1421 | 1421 | |
1422 | + self._over_center = False | |
1423 | + self.dragging = False | |
1424 | + | |
1422 | 1425 | self.picker = vtk.vtkWorldPointPicker() |
1423 | 1426 | |
1424 | 1427 | self.AddObserver("KeyPressEvent", self.OnKeyPress) |
1428 | + self.AddObserver("LeftButtonPressEvent",self.OnLeftClick) | |
1429 | + self.AddObserver("LeftButtonReleaseEvent", self.OnLeftRelease) | |
1425 | 1430 | self.AddObserver("MouseMoveEvent", self.OnMouseMove) |
1426 | 1431 | self.viewer.slice_data.renderer.AddObserver("StartEvent", self.OnUpdate) |
1427 | 1432 | |
... | ... | @@ -1461,6 +1466,13 @@ class ReorientImageInteractorStyle(DefaultInteractorStyle): |
1461 | 1466 | self.viewer.slice_.current_mask.clear_history() |
1462 | 1467 | Publisher.sendMessage('Reload actual slice') |
1463 | 1468 | |
1469 | + def OnLeftClick(self, obj, evt): | |
1470 | + if self._over_center: | |
1471 | + self.dragging = True | |
1472 | + | |
1473 | + def OnLeftRelease(self, obj, evt): | |
1474 | + self.dragging = False | |
1475 | + | |
1464 | 1476 | def OnMouseMove(self, obj, evt): |
1465 | 1477 | """ |
1466 | 1478 | This event is responsible to reorient image, set mouse cursors |
... | ... | @@ -1477,25 +1489,28 @@ class ReorientImageInteractorStyle(DefaultInteractorStyle): |
1477 | 1489 | |
1478 | 1490 | dist_center = ((mx - cx)**2 + (my - cy)**2)**0.5 |
1479 | 1491 | |
1480 | - if dist_center <= 15: | |
1481 | - cursor = wx.StockCursor(wx.CURSOR_SIZENESW) | |
1482 | - | |
1483 | - if self.left_pressed: | |
1484 | - self.picker.Pick(mx, my, 0, self.viewer.slice_data.renderer) | |
1485 | - x, y, z = self.picker.GetPickPosition() | |
1486 | - icx, icy, icz = self.viewer.slice_.center | |
1487 | - | |
1488 | - if self.viewer.orientation == 'AXIAL': | |
1489 | - self.viewer.slice_.center = (x, y, icz) | |
1490 | - elif self.viewer.orientation == 'CORONAL': | |
1491 | - self.viewer.slice_.center = (x, icy, z) | |
1492 | - elif self.viewer.orientation == 'SAGITAL': | |
1493 | - self.viewer.slice_.center = (icx, y, z) | |
1494 | - Publisher.sendMessage('Update slice viewer') | |
1492 | + if self.dragging: | |
1493 | + self.picker.Pick(mx, my, 0, self.viewer.slice_data.renderer) | |
1494 | + x, y, z = self.picker.GetPickPosition() | |
1495 | + icx, icy, icz = self.viewer.slice_.center | |
1496 | + | |
1497 | + if self.viewer.orientation == 'AXIAL': | |
1498 | + self.viewer.slice_.center = (x, y, icz) | |
1499 | + elif self.viewer.orientation == 'CORONAL': | |
1500 | + self.viewer.slice_.center = (x, icy, z) | |
1501 | + elif self.viewer.orientation == 'SAGITAL': | |
1502 | + self.viewer.slice_.center = (icx, y, z) | |
1503 | + Publisher.sendMessage('Update slice viewer') | |
1504 | + | |
1495 | 1505 | else: |
1496 | - cursor = wx.StockCursor(wx.CURSOR_DEFAULT) | |
1506 | + if dist_center <= 15: | |
1507 | + self._over_center = True | |
1508 | + cursor = wx.StockCursor(wx.CURSOR_SIZENESW) | |
1509 | + else: | |
1510 | + self._over_center = False | |
1511 | + cursor = wx.StockCursor(wx.CURSOR_DEFAULT) | |
1497 | 1512 | |
1498 | - self.viewer.interactor.SetCursor(cursor) | |
1513 | + self.viewer.interactor.SetCursor(cursor) | |
1499 | 1514 | |
1500 | 1515 | def OnUpdate(self, obj, evt): |
1501 | 1516 | w, h = self.viewer.slice_data.renderer.GetSize() | ... | ... |