feat: add pan and zoom toggle controls with full camera state save/restore#3
feat: add pan and zoom toggle controls with full camera state save/restore#3patrickoleary wants to merge 1 commit intomasterfrom
Conversation
|
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? |
| @@ -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(), | |||
There was a problem hiding this comment.
you probably want to remove the zoom now that you have the full camera state?
| 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"]: |
There was a problem hiding this comment.
this could be just an if. And maybe even before the camera condition check.
| view.camera.SetParallelScale(scale) | ||
| view.render() | ||
|
|
||
| def _pan(self, dx, dy): |
There was a problem hiding this comment.
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.
I like it more compact like this. I think the toolbars are poorly organized and spilling. look at animation for instance. |
|
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. |
045c75b to
a9fabcf
Compare
a9fabcf to
22fec9d
Compare
| v_tooltip_bottom="'Pan up'", | ||
| icon="mdi-arrow-up", | ||
| flat=True, | ||
| click=lambda: pan(0, -1), |
| icon="mdi-fit-to-page-outline", | ||
| flat=True, | ||
| click=zoom_out, | ||
| click=lambda: reset_camera(), |
| v_tooltip_bottom="'Zoom in'", | ||
| icon="mdi-plus", | ||
| flat=True, | ||
| click=lambda: zoom(1 / 1.2), |
| v_tooltip_bottom="'Zoom out'", | ||
| icon="mdi-minus", | ||
| flat=True, | ||
| click=lambda: zoom(1.2), |
| v_tooltip_bottom="'Pan down'", | ||
| icon="mdi-arrow-down", | ||
| flat=True, | ||
| click=lambda: pan(0, 1), |
| v_tooltip_bottom="'Pan left'", | ||
| icon="mdi-arrow-left", | ||
| flat=True, | ||
| click=lambda: pan(1, 0), |
| v_tooltip_bottom="'Pan right'", | ||
| icon="mdi-arrow-right", | ||
| flat=True, | ||
| click=lambda: 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)
22fec9d to
81788b9
Compare

Adds pan and zoom controls to the Viewport Layout toolbar, with full camera state persistence.
UI Changes
State export now saves the full VTK camera configuration:
State import restores the full camera. Backward compatible — older state files with only zoom still work.
closes Kitware#80