Skip to content

added axes, zoom and pan control - #745

Closed
cpignedoli wants to merge 1 commit into
masterfrom
feature/viewercontrols
Closed

added axes, zoom and pan control#745
cpignedoli wants to merge 1 commit into
masterfrom
feature/viewercontrols

Conversation

@cpignedoli

Copy link
Copy Markdown
Member

This pull request introduces a comprehensive set of enhancements to the StructureDataViewer in aiidalab_widgets_base/viewers.py, focusing on improved view controls, axis visualization, and test coverage. The changes add user controls for view scaling, panning, and axes display, as well as robust validation and reset mechanisms. Corresponding tests ensure these features work as intended.

Key improvements and new features:

Viewer controls and UI enhancements:

  • Added new controls for view scale, pan (X/Y), reset to default view, and toggling axes display and centering in the viewer's appearance tab. Also included a help section explaining the controls. [1] [2] [3]

Axes visualization:

  • Implemented logic to add, remove, and center a coordinate axes triad in the viewer, with options to show/hide and center the axes based on user preference. [1] [2] [3]

View transformation logic:

  • Introduced properties and methods to handle view scaling and panning, including validation, trait observation, and JavaScript integration for real-time updates. Added a "reset view" function to restore default orientation, scale, and pan. [1] [2]

Test coverage:

  • Added tests to verify default view and axes rendering, toggling axes on/off, view transformation (scale and pan), and centered axes functionality. These tests ensure the new controls and visual features behave as expected.

Minor UI improvements:

  • Updated the "Center molecule" button label to "Center atoms" for clarity.

These changes collectively provide a more interactive and user-friendly structure viewer, with fine-grained control over visualization and improved test reliability.

Screen.Recording.2026-05-18.at.16.19.52.mov

@cpignedoli
cpignedoli marked this pull request as draft May 18, 2026 14:23
@codecov

codecov Bot commented May 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.65217% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.12%. Comparing base (7d6b446) to head (42bcd52).

Files with missing lines Patch % Lines
aiidalab_widgets_base/viewers.py 95.65% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #745      +/-   ##
==========================================
+ Coverage   84.77%   85.12%   +0.34%     
==========================================
  Files          18       18              
  Lines        3336     3421      +85     
==========================================
+ Hits         2828     2912      +84     
- Misses        508      509       +1     
Flag Coverage Δ
python-3.12 85.09% <95.65%> (+0.34%) ⬆️
python-3.9 85.10% <95.65%> (+0.34%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@danielhollas danielhollas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tbh I am not sure I am a fan of this PR, especially the inline JS code which seems like it will be very hard to maintain.

It seems like bigger features like this should be discussed in an issue before implementation.

Also I wonder how does this relate to the work on WEAS widget in #559?

cell: ase.cell.Cell object.
"""

show_axes = tl.Bool(True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To preserve the backwards compatibility, it would be better to not show axes by default (for example in AtmoSpec I don't want them).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @danielhollas, I agree that we should discuss. Let's discuss this at the next meeting, to understand when we will have the weas widget, and how we can quickly switch back to a more intuitive default orientation.

@cpignedoli

Copy link
Copy Markdown
Member Author

I will fix pan functionality after merging of #742

@cpignedoli

Copy link
Copy Markdown
Member Author

Closing this in favor of #765.

#765 keeps the scope narrow: optional axes plus a default-view button, without the zoom/pan controls or inline JavaScript that were problematic in this PR. It was restarted from current master and tested with both nglview 3.0.8 and 4.0.1.

@cpignedoli cpignedoli closed this Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants