From 9a41893bf881fe17c5a312115bd5893ad335f675 Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Thu, 15 Aug 2024 01:32:08 -0400 Subject: [PATCH 1/4] Allow view to keep rotating while other tools are used. --- glue_vispy_viewers/common/tools.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/glue_vispy_viewers/common/tools.py b/glue_vispy_viewers/common/tools.py index 054b5b8..ca2349f 100644 --- a/glue_vispy_viewers/common/tools.py +++ b/glue_vispy_viewers/common/tools.py @@ -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 @@ -25,7 +25,7 @@ def activate(self): @viewer_tool -class RotateTool(CheckableTool): +class RotateTool(Tool): icon = ROTATE_ICON tool_id = 'vispy:rotate' @@ -33,14 +33,16 @@ class RotateTool(CheckableTool): 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) + else: + self.timer.stop() def rotate(self, event): self.viewer._vispy_widget.view.camera.azimuth -= 1. # set speed as constant first From ec50b1b736ffeeb09eed205218adb089bdfa4802 Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Fri, 16 Aug 2024 12:44:23 -0400 Subject: [PATCH 2/4] Update tests to account for rotation tool changes. --- .../common/qt/tests/test_vispy_toolbar.py | 8 ++++---- .../volume/qt/tests/test_volume_toolbar.py | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/glue_vispy_viewers/common/qt/tests/test_vispy_toolbar.py b/glue_vispy_viewers/common/qt/tests/test_vispy_toolbar.py index d373be5..8fff722 100644 --- a/glue_vispy_viewers/common/qt/tests/test_vispy_toolbar.py +++ b/glue_vispy_viewers/common/qt/tests/test_vispy_toolbar.py @@ -56,11 +56,11 @@ 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 - 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 out, err = capsys.readouterr() assert out.strip() == "" diff --git a/glue_vispy_viewers/volume/qt/tests/test_volume_toolbar.py b/glue_vispy_viewers/volume/qt/tests/test_volume_toolbar.py index 371eb15..c5fcc0d 100644 --- a/glue_vispy_viewers/volume/qt/tests/test_volume_toolbar.py +++ b/glue_vispy_viewers/volume/qt/tests/test_volume_toolbar.py @@ -35,11 +35,11 @@ def test_volumeviewer_toolbar(): 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 + + toolbar.actions['vispy:rotate'].trigger() + assert not toolbar.tools['vispy:rotate'].rotating # test lasso selection tool toolbar.actions['vispy:lasso'].toggle() From 190045c1d462773718882d6d7d71b7634aa21198 Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Mon, 9 Sep 2024 11:51:30 -0400 Subject: [PATCH 3/4] Use dev version of glue-qt for dev test envs. --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 9f42765..ac8d5ff 100644 --- a/tox.ini +++ b/tox.ini @@ -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 From 01419efaddd5147a728833bd6852bcf8d53d2935 Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Mon, 9 Sep 2024 15:24:41 -0400 Subject: [PATCH 4/4] See whether we still need to skip rotation test. --- glue_vispy_viewers/common/qt/tests/test_vispy_toolbar.py | 1 - 1 file changed, 1 deletion(-) diff --git a/glue_vispy_viewers/common/qt/tests/test_vispy_toolbar.py b/glue_vispy_viewers/common/qt/tests/test_vispy_toolbar.py index 8fff722..159456a 100644 --- a/glue_vispy_viewers/common/qt/tests/test_vispy_toolbar.py +++ b/glue_vispy_viewers/common/qt/tests/test_vispy_toolbar.py @@ -50,7 +50,6 @@ def test_save(tmpdir, capsys): app.close() -@pytest.mark.skipif('not IS_WIN', reason='Teardown disaster') def test_rotate(capsys): app = GlueApplication()