Expose snapshot size to gRPC / rips clients#14042
Open
hakonhagland wants to merge 2 commits into
Open
Conversation
Snapshots exported via gRPC (rips Instance.export_snapshots, PlotWindow.export_snapshot) use whatever geometry Qt happens to give the plot widget at the time of export. In offscreen mode the widget is typically much smaller than the user expects, because set_plot_window_size resizes the outer RiuPlotMainWindow but leaves the MDI sub-windows maximized at the original layout geometry. The CLI --snapshotsize flag avoids this by calling RiuMainWindowTools::setWindowSizeOnWidgetsInMdiWindows, which un-maximizes each MDI sub-window and resizes the inner viewWidget to the requested dimensions. This commit wraps the same helper as a scripting command (setSnapshotSize) so Python clients can request a specific snapshot resolution before calling export_snapshot. Also handles 3D views via setFixedWindowSizeFor3dViews, mirroring what --snapshotsize does in RiaGuiApplication. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3 tasks
Wraps the new setSnapshotSize gRPC command so callers can do
ri.set_snapshot_size(1600, 1000)
for plot in ri.project.plots():
plot.export_snapshot(export_folder=...)
and get 1600x1000 PNGs back. Mirrors the existing
Instance.set_plot_window_size wrapper shape. The headless_plot_export
example is updated to demonstrate the call between plot creation and
the export_snapshot loop.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4de6fa7 to
898a847
Compare
Member
|
We are now working on replacing the MDI concept with docking widgets. The changes you suggest here will be revisited after this change is merged to dev. |
Collaborator
|
Should be part of work done in #14056 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
setSnapshotSize(width, height)scripting command so Python clients can request a specific snapshot resolution before exporting, instead of being stuck with whatever geometry Qt happens to give the plot widget.Motivation: snapshots exported over gRPC (
Instance.export_snapshots,PlotWindow.export_snapshot) render at the plot widget's current size. In offscreen mode that is typically much smaller than expected, becauseset_plot_window_sizeonly resizes the outerRiuPlotMainWindowand leaves the MDI sub-windows at their original layout geometry. The--snapshotsizeCLI flag already works around this viaRiuMainWindowTools::setWindowSizeOnWidgetsInMdiWindows, but that helper had no scripting binding — so headless, rips-driven export had no way to control the output resolution.Add
setSnapshotSizegRPC command (commit 1)RicfSetSnapshotSizescriptable command inApplicationLibCode/CommandFileInterface/, registered inCMakeLists_files.cmake.RiuMainWindowTools::setWindowSizeOnWidgetsInMdiWindowshelper the--snapshotsizeCLI flag uses, and also resizes 3D views viasetFixedWindowSizeFor3dViews, mirroringRiaGuiApplication.width/height > 0, returning a clearCOMMAND_ERRORotherwise.setSnapshotSizeentry in theCommandParamsoneof inCommands.proto(tag 40); dispatch is automatic via the reflection-based command service, so noRiaGrpcCommandServicechange is needed.set_plot_window_sizefirst so the plots are realized inside MDI sub-windows; otherwise only the outer wrapper resizes and the inner qwt canvas stays anchored at its initial geometry.Add
Instance.set_snapshot_sizeto the rips Python client (commit 2)Instance.set_snapshot_size(width, height)wrapper mirroring the existingset_plot_window_sizeshape.set_plot_window_sizebefore creating plots → create plots →project.plots()→set_snapshot_size→export_snapshot. (project.plots()can re-tile the MDI sub-windows back to defaults, soset_snapshot_sizemust come after it.)headless_plot_exportexample to demonstrate the call.Notes
CODE_HEAD_FILESCMake typo fix). Both are needed to actually build with-DRESINSIGHT_ENABLE_GRPC=ON; building this branch alone without Fix CODE_HEAD_FILES typo so gRPC headers reach MOC #14041 hits theundefined reference to vtable for RiaGrpcConsoleApplicationlink error.setSnapshotSizeoneof tag (40) is purely additive — olderripsclients are unaffected.Test plan
setSnapshotSizerejectswidth/height <= 0withFAILED_PRECONDITION.-platform offscreen) afterset_plot_window_size+set_snapshot_size(W, H)produces aW x HPNG with the plot filling the canvas (verified at 1600×1000 and 1000×800).