Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow view to keep rotating while other tools are used #389

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions glue_vispy_viewers/common/qt/tests/test_vispy_toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,16 @@
app.close()


@pytest.mark.skipif('not IS_WIN', reason='Teardown disaster')
def test_rotate(capsys):

app = GlueApplication()
viewer = app.new_data_viewer(VispyScatterViewer)

viewer.toolbar.actions['vispy:rotate'].toggle()
assert viewer.toolbar.active_tool.tool_id == 'vispy:rotate'
viewer.toolbar.actions['vispy:rotate'].trigger()
assert viewer.toolbar.tools['vispy:rotate'].rotating

Check warning on line 59 in glue_vispy_viewers/common/qt/tests/test_vispy_toolbar.py

View check run for this annotation

Codecov / codecov/patch

glue_vispy_viewers/common/qt/tests/test_vispy_toolbar.py#L58-L59

Added lines #L58 - L59 were not covered by tests

viewer.toolbar.actions['vispy:rotate'].toggle()
assert viewer.toolbar.active_tool is None
viewer.toolbar.actions['vispy:rotate'].trigger()
assert not viewer.toolbar.tools['vispy:rotate'].rotating

Check warning on line 62 in glue_vispy_viewers/common/qt/tests/test_vispy_toolbar.py

View check run for this annotation

Codecov / codecov/patch

glue_vispy_viewers/common/qt/tests/test_vispy_toolbar.py#L61-L62

Added lines #L61 - L62 were not covered by tests

out, err = capsys.readouterr()
assert out.strip() == ""
Expand Down
14 changes: 8 additions & 6 deletions glue_vispy_viewers/common/tools.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os

from glue.viewers.common.tool import Tool, CheckableTool
from glue.viewers.common.tool import Tool

from glue.config import viewer_tool

Expand All @@ -25,22 +25,24 @@


@viewer_tool
class RotateTool(CheckableTool):
class RotateTool(Tool):

icon = ROTATE_ICON
tool_id = 'vispy:rotate'
action_text = 'Continuously rotate view'
tool_tip = 'Start/Stop rotation'

timer = None
rotating = False

def activate(self):
if self.timer is None:
self.timer = app.Timer(connect=self.rotate)
self.timer.start(0.1)

def deactivate(self):
self.timer.stop()
self.rotating = not self.rotating
if self.rotating:
self.timer.start(0.1)

Check warning on line 43 in glue_vispy_viewers/common/tools.py

View check run for this annotation

Codecov / codecov/patch

glue_vispy_viewers/common/tools.py#L41-L43

Added lines #L41 - L43 were not covered by tests
else:
self.timer.stop()

Check warning on line 45 in glue_vispy_viewers/common/tools.py

View check run for this annotation

Codecov / codecov/patch

glue_vispy_viewers/common/tools.py#L45

Added line #L45 was not covered by tests

def rotate(self, event):
self.viewer._vispy_widget.view.camera.azimuth -= 1. # set speed as constant first
10 changes: 5 additions & 5 deletions glue_vispy_viewers/volume/qt/tests/test_volume_toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
toolbar = v.toolbar

# test rotate tool
toolbar.actions['vispy:rotate'].toggle()
assert toolbar.active_tool.tool_id == 'vispy:rotate'
# TODO: assert a mode here
toolbar.actions['vispy:rotate'].toggle()
assert toolbar.active_tool is None
toolbar.actions['vispy:rotate'].trigger()
assert toolbar.tools['vispy:rotate'].rotating

Check warning on line 39 in glue_vispy_viewers/volume/qt/tests/test_volume_toolbar.py

View check run for this annotation

Codecov / codecov/patch

glue_vispy_viewers/volume/qt/tests/test_volume_toolbar.py#L38-L39

Added lines #L38 - L39 were not covered by tests

toolbar.actions['vispy:rotate'].trigger()
assert not toolbar.tools['vispy:rotate'].rotating

Check warning on line 42 in glue_vispy_viewers/volume/qt/tests/test_volume_toolbar.py

View check run for this annotation

Codecov / codecov/patch

glue_vispy_viewers/volume/qt/tests/test_volume_toolbar.py#L41-L42

Added lines #L41 - L42 were not covered by tests

# test lasso selection tool
toolbar.actions['vispy:lasso'].toggle()
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ deps =
pyqt64: PyQt6==6.4.*
pyside64: PySide6==6.4.*
dev: glue-core @ git+https://github.com/glue-viz/glue
dev: glue-qt @ git+https://github.com/glue-viz/glue-qt
dev: vispy @ git+https://github.com/vispy/vispy
oldestdeps: glue-core==1.13.*
oldestdeps: echo==0.6
Expand Down