Skip to content

feat: add pan and zoom toggle controls with full camera state save/restore#3

Closed
patrickoleary wants to merge 1 commit intomasterfrom
feature/pan-and-zoom
Closed

feat: add pan and zoom toggle controls with full camera state save/restore#3
patrickoleary wants to merge 1 commit intomasterfrom
feature/pan-and-zoom

Conversation

@patrickoleary
Copy link
Copy Markdown
Owner

@patrickoleary patrickoleary commented May 4, 2026

Adds pan and zoom controls to the Viewport Layout toolbar, with full camera state persistence.

pan-zoom

UI Changes

  • Zoom toggle (magnify icon) — click to reveal zoom in/out buttons
  • Pan toggle (arrow-all icon) — click to reveal up/down/left/right pan buttons
  • Toggles are mutually exclusive — activating one hides the other
  • Reset view button resets camera to default after pan/zoom
  • Keyboard shortcut z for reset still works as before
  • Camera State Save/Restore

State export now saves the full VTK camera configuration:

  • zoom (ParallelScale)
  • position (camera position x, y, z)
  • focal_point (camera focal point x, y, z)
  • view_up (camera up direction vector)
  • clipping_range (near/far clipping planes)

State import restores the full camera. Backward compatible — older state files with only zoom still work.

closes Kitware#80

@jourdain
Copy link
Copy Markdown

jourdain commented May 4, 2026

Any reason for not having all the buttons showing? Why do we need to toggle between the modes? Are we missing room in the toolbar?

Comment thread src/e3sm_quickview/app.py Outdated
@@ -308,6 +313,7 @@ def download_state(self):
"tools": self.state.active_tools,
"help": not self.state.compact_drawer,
"zoom": self.view_manager.get_zoom(),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

you probably want to remove the zoom now that you have the full camera state?

Comment thread src/e3sm_quickview/app.py Outdated
if "zoom" in state_content["layout"]:
if "camera" in state_content["layout"]:
self.view_manager.set_camera_state(state_content["layout"]["camera"])
elif "zoom" in state_content["layout"]:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

this could be just an if. And maybe even before the camera condition check.

Comment thread src/e3sm_quickview/view_manager.py Outdated
view.camera.SetParallelScale(scale)
view.render()

def _pan(self, dx, dy):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Maybe you can just expose that one and call it with the proper args from the UI? That will reduce the surface API that you move around.

@patrickoleary
Copy link
Copy Markdown
Owner Author

patrickoleary commented May 4, 2026

Any reason for not having all the buttons showing? Why do we need to toggle between the modes? Are we missing room in the toolbar?

I like it more compact like this. I think the toolbars are poorly organized and spilling. look at animation for instance.

@jourdain
Copy link
Copy Markdown

jourdain commented May 4, 2026

Then should we have a "mode" (button group?) instead of just buttons that acts as toggle mode with many state variable instead of a single one? Do we want then centered or attached to a side?

Also, it would be nice to bind the pan to the arrows using the mousetrap infrastructure. And maybe similar for zoom.

@patrickoleary patrickoleary force-pushed the feature/pan-and-zoom branch from 045c75b to a9fabcf Compare May 4, 2026 16:12
@patrickoleary
Copy link
Copy Markdown
Owner Author

Adds pan, zoom, and aspect ratio controls to the Viewport Layout toolbar as collapsible toggle groups, with full camera state persistence.

UI Changes

  • Aspect ratio toggle — reveals a slider (0–4, step 0.25) with tick marks
  • Zoom toggle — reveals zoom in/out buttons
  • Pan toggle — reveals up/down/left/right pan buttons
  • Reset view button resets camera to default
  • Toggles are mutually exclusive — activating one collapses the others
  • Active groups highlighted with a subtle background
  • Toolbar streamlined: removed "Viewport layout" label, grouped/uniform is now icon-only with tooltip, Size is icon-only with tooltip, hotkey badge removed
  • Keyboard shortcut z for reset and g for grouped still work

Everything collapses. I think the dimension sliders would look a lot better this way too.

viewport-toolbar

Camera State Save/Restore
State export now saves the full VTK camera configuration:

  • zoom (ParallelScale)
  • position (camera position)
  • focal_point (camera focal point)
  • view_up (camera up direction)
  • clipping_range (near/far clipping planes)

API Simplification

  • Replaced zoom_in/zoom_out with zoom(factor)
  • Replaced pan_up/pan_down/pan_left/pan_right with pan(dx, dy)
  • Button-specific logic (direction, factor) lives in toolbar lambdas

@patrickoleary patrickoleary force-pushed the feature/pan-and-zoom branch from a9fabcf to 22fec9d Compare May 4, 2026 16:35
v_tooltip_bottom="'Pan up'",
icon="mdi-arrow-up",
flat=True,
click=lambda: pan(0, -1),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

click=(pan, "[0,-1]"),

icon="mdi-fit-to-page-outline",
flat=True,
click=zoom_out,
click=lambda: reset_camera(),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

click=reset_camera

v_tooltip_bottom="'Zoom in'",
icon="mdi-plus",
flat=True,
click=lambda: zoom(1 / 1.2),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

click=(zoom, "[1/1.2]"),

v_tooltip_bottom="'Zoom out'",
icon="mdi-minus",
flat=True,
click=lambda: zoom(1.2),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

click=(zoom, "[1.2]")

v_tooltip_bottom="'Pan down'",
icon="mdi-arrow-down",
flat=True,
click=lambda: pan(0, 1),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

click=(pan, "[0,1]"),

v_tooltip_bottom="'Pan left'",
icon="mdi-arrow-left",
flat=True,
click=lambda: pan(1, 0),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

click=(pan, "[1,0]"),

v_tooltip_bottom="'Pan right'",
icon="mdi-arrow-right",
flat=True,
click=lambda: pan(-1, 0),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

click=(pan, "[-1,0]"),

…store

- Add zoom(factor) and pan(dx, dy) methods to both view managers
- Add aspect ratio, zoom, and pan toggle groups to Layout toolbar with background highlight
- Add reset view button with render fix
- Save/restore full camera state (zoom, position, focal point, view up, clipping range)
- Streamline toolbar: remove label, icon-only grouped/size buttons with tooltips
- Aspect ratio slider with 0.25 step ticks (0-4 range)
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.

Disable view interaction and add zoom-in/out

3 participants