Expose picker, invocation and plotting APIs to Python bindings#200
Conversation
There was a problem hiding this comment.
Pull request overview
Exposes additional LightViewer / LightViewerContext capabilities to Python bindings so Python code can pick points, schedule callbacks on the viewer thread, and manage ImPlot-based plots.
Changes:
- Added Python bindings for
pick_pointonLightViewerContext. - Added Python bindings for invocation helpers (
invoke,invoke_after_rendering,invoke_once) and plot management APIs onLightViewer, includingupdate_plot_stairs. - Updated Python type stubs (
.pyi) to match the newly exposed APIs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/python/guik.cpp |
Adds pybind11 bindings for pick/invoke/plot-management APIs, plus a new update_plot_stairs wrapper. |
src/python/stubs/pyridescence/guik.pyi |
Updates type stubs to include the new LightViewer / LightViewerContext methods and signatures. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| .def("remove_plot", &guik::LightViewer::remove_plot, py::arg("plot_name"), py::arg("label") = "") | ||
| .def("setup_plot", &guik::LightViewer::setup_plot, py::arg("plot_name"), py::arg("width"), py::arg("height"), py::arg("plot_flags") = 0, py::arg("x_flags") = 0, py::arg("y_flags") = 0, py::arg("order") = -1) |
There was a problem hiding this comment.
LightViewer::remove_plot currently does data.erase(std::find_if(...)) without checking whether the label was found; if the label doesn't exist, this will attempt to erase end() (undefined behavior) and can crash. Since this method is now exposed to Python, it should be made safe (either fix LightViewer::remove_plot to only erase when the iterator != end, or wrap the binding with a guard and no-op / raise when not found).
There was a problem hiding this comment.
Implemented in ff237e3. LightViewer::remove_plot now checks the iterator returned by std::find_if before erase, so removing a missing label is a safe no-op instead of undefined behavior.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/koide3/iridescence/sessions/354ac627-5f59-4117-9cbd-0c6dce1eb58a Co-authored-by: koide3 <31344317+koide3@users.noreply.github.com>
Motivation
Description
pick_pointonLightViewerContextto allow retrieving a picked 3D point from Python.LightViewer:invoke,invoke_after_rendering, andinvoke_onceto schedule Python callbacks into the viewer.LightViewer:clear_plots,remove_plot,setup_plot,link_plot_axis,link_plot_axes,setup_legend,setup_plot_group_order, andupdate_plot_stairsto enable creating and updating plots from Python..pyi) to reflect all newly exposed methods and signatures.Testing
Codex Task