Repository navigation
pycvc_gl: bind ViewportManager + Viewport — picture-in-picture from Python - #390
Merged
Merged
Conversation
…ython Closes the largest gap the PiP work left: the whole ViewportManager/Viewport/ input-router surface (cvcGL #384/#386/#387) was C++-only, so volrover3 and grl-snam — both Python — could not build multi-viewport or minimap layouts. This wraps it, so the Python API mirrors C++: vm = pycvc_gl.ViewportManager(scene, 1024, 768, False, "main") inset = vm.addSceneViewport("inset", scene2, (0.62, 0.05, 0.97, 0.42), 1) mini = vm.addMirrorViewport("mini", "main", (0.62, 0.58, 0.97, 0.95), 2) inset.camera().setMode(pycvc_gl.CameraController.Mode_Fly) # per-viewport vm.routeMouseButton(pycvc_gl.ViewportManager.MouseButton_Left, True, x, y) vp = vm.viewportAt(x, y) # None over the gutter frame = vm.frameRGB() # bytes Binding details, following the existing pycvc_gl patterns: * frameRGB() -> bytes (a scoped typemap, like SceneRenderer's — the SceneRenderer one does not apply to ViewportManager). * region as a Python 4-sequence in (addSceneViewport/addMirrorViewport) and a 4-tuple out (Viewport.region()), via in/argout typemaps. * Viewport has a private ctor -> %nodefaultctor; it is only ever handed out by the manager. renderer()/renderWindow()/mirrorSource() reuse the existing vtkRenderer*/vtkRenderWindow* -> live vtkmodules typemaps. * KEEPALIVE chain mirrors C++ ownership so a live child pins its parent: the manager keeps its scene(s); every handed-out Viewport (primary/viewport/ viewportAt/activeViewport/add*Viewport) keeps the manager; a Viewport's camera() keeps the Viewport. * MouseButton enum -> ViewportManager.MouseButton_Left/Middle/Right. New test_pycvc_gl_viewport.py exercises the surface end to end: auto primary, addSceneViewport over a second scene + addMirrorViewport, viewportAt (layer/ visibility/inputEnabled/gutter), focus-follows-click into cvc::state, the per-viewport camera (its state under the viewer tree), region tuples, and frameRGB bytes — self-skipping without a GL driver, hard-exiting past cvcGL's static-teardown race like the other pycvc_gl tests. Validated locally by SWIG generation (all 24 ViewportManager + 15 Viewport methods, the MouseButton enum, and both typemaps wrap cleanly); the compiled .pyd + this test run in the cvcpkg pycvc-gl recipe, which builds against the python-enabled VTK the module needs.
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.
pycvc_gl: bind ViewportManager + Viewport — picture-in-picture from Python
Closes the largest gap the PiP work left: the whole ViewportManager/Viewport/
input-router surface (cvcGL #384/#386/#387) was C++-only, so volrover3 and
grl-snam — both Python — could not build multi-viewport or minimap layouts. This
wraps it, so the Python API mirrors C++:
Binding details, following the existing pycvc_gl patterns:
one does not apply to ViewportManager).
4-tuple out (Viewport.region()), via in/argout typemaps.
the manager. renderer()/renderWindow()/mirrorSource() reuse the existing
vtkRenderer*/vtkRenderWindow* -> live vtkmodules typemaps.
manager keeps its scene(s); every handed-out Viewport (primary/viewport/
viewportAt/activeViewport/add*Viewport) keeps the manager; a Viewport's
camera() keeps the Viewport.
New test_pycvc_gl_viewport.py exercises the surface end to end: auto primary,
addSceneViewport over a second scene + addMirrorViewport, viewportAt (layer/
visibility/inputEnabled/gutter), focus-follows-click into cvc::state, the
per-viewport camera (its state under the viewer tree), region tuples, and
frameRGB bytes — self-skipping without a GL driver, hard-exiting past cvcGL's
static-teardown race like the other pycvc_gl tests.
Validated locally by SWIG generation (all 24 ViewportManager + 15 Viewport
methods, the MouseButton enum, and both typemaps wrap cleanly); the compiled
.pyd + this test run in the cvcpkg pycvc-gl recipe, which builds against the
python-enabled VTK the module needs.