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

fix: use last focused/resized view to determine shape of BqplotImageView #475

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
14 changes: 12 additions & 2 deletions glue_jupyter/bqplot/image/viewer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from datetime import datetime

from glue.viewers.image.composite_array import CompositeArray
from bqplot_image_gl.viewlistener import ViewListener

Expand Down Expand Up @@ -81,9 +83,17 @@ def _reset_limits(self, old, new):
self.state.reset_limits()

def _on_view_change(self, *args):
views = sorted(self._vl.view_data)
# Order view_data by focused_at and then resized_at, latest change first
views = sorted(
self._vl.view_data.values(),
key=lambda x: (
datetime.fromisoformat(x['focused_at']),
datetime.fromisoformat(x['resized_at'])
),
reverse=True
)
if len(views) > 0:
first_view = self._vl.view_data[views[0]]
first_view = views[0]
self.shape = (int(first_view['height']), int(first_view['width']))
self._composite_image.update()
else:
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ install_requires =
ipywidgets>=7.4.0
ipyvue>=1.2.0,<2
ipyvuetify>=1.2.0,<2
bqplot-image-gl>=1.5.0
bqplot-image-gl>=1.6.0
bqplot>=0.12.17
bqplot-gl
scikit-image
Expand Down