From 9c5200a199625d1630837da9ee422fa5f6e95ffb Mon Sep 17 00:00:00 2001 From: Merlin Nimier-David Date: Thu, 23 Oct 2025 15:04:30 +0200 Subject: [PATCH 01/17] Add bindings for Dear Imgui Image functions --- src/cpp/imgui.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/cpp/imgui.cpp b/src/cpp/imgui.cpp index 24d1f14..729ed4a 100644 --- a/src/cpp/imgui.cpp +++ b/src/cpp/imgui.cpp @@ -558,6 +558,42 @@ void bind_imgui_methods(py::module& m) { py::arg("size_arg") = std::make_tuple(-1.f, 0.f)); m.def("Bullet", []() { ImGui::Bullet(); }); + // Widgets: Image + m.def( + "Image", + [](ImTextureID user_texture_id, const Vec2T& image_size, const Vec2T& uv0, const Vec2T& uv1) { + ImGui::Image(user_texture_id, to_vec2(image_size), to_vec2(uv0), to_vec2(uv1)); + }, + py::arg("user_texture_id"), + py::arg("image_size"), + py::arg("uv0") = Vec2T(0.0f, 0.0f), + py::arg("uv1") = Vec2T(1.0f, 1.0f)); + m.def( + "ImageWithBg", + [](ImTextureID user_texture_id, const Vec2T& image_size, const Vec2T& uv0, const Vec2T& uv1, const Vec4T& bg_col, const Vec4T& tint_col) { + ImGui::ImageWithBg(user_texture_id, to_vec2(image_size), to_vec2(uv0), to_vec2(uv1), to_vec4(bg_col), to_vec4(tint_col)); + }, + py::arg("user_texture_id"), + py::arg("image_size"), + py::arg("uv0") = Vec2T(0.0f, 0.0f), + py::arg("uv1") = Vec2T(1.0f, 1.0f), + py::arg("bg_col") = Vec4T(0.0f, 0.0f, 0.0f, 0.0f), + py::arg("tint_col") = Vec4T(1.0f, 1.0f, 1.0f, 1.0f)); + + m.def( + "ImageButton", + [](const char* str_id, ImTextureID user_texture_id, const Vec2T& image_size, const Vec2T& uv0, const Vec2T& uv1, const Vec4T& bg_col, const Vec4T& tint_col) { + return ImGui::ImageButton(str_id, user_texture_id, to_vec2(image_size), to_vec2(uv0), to_vec2(uv1), to_vec4(bg_col), to_vec4(tint_col)); + }, + py::arg("str_id"), + py::arg("user_texture_id"), + py::arg("image_size"), + py::arg("uv0") = Vec2T(0.0f, 0.0f), + py::arg("uv1") = Vec2T(1.0f, 1.0f), + py::arg("bg_col") = Vec4T(0.0f, 0.0f, 0.0f, 0.0f), + py::arg("tint_col") = Vec4T(1.0f, 1.0f, 1.0f, 1.0f)); + + // Widgets: Combo Box m.def( "BeginCombo", From 75f5e57d8853ae633b5efabb730f05612cb91d09 Mon Sep 17 00:00:00 2001 From: Merlin Nimier-David Date: Fri, 5 Dec 2025 12:10:10 +0100 Subject: [PATCH 02/17] Bindings for `configureImGuiStyleCallback` --- src/cpp/core.cpp | 2 ++ src/polyscope/core.py | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/src/cpp/core.cpp b/src/cpp/core.cpp index dc3b62d..adeaf20 100644 --- a/src/cpp/core.cpp +++ b/src/cpp/core.cpp @@ -143,6 +143,8 @@ PYBIND11_MODULE(polyscope_bindings, m) { m.def("set_hide_window_after_show", [](bool x) { ps::options::hideWindowAfterShow = x; }); m.def("set_warn_for_invalid_values", [](bool x) { ps::options::warnForInvalidValues = x; }); m.def("set_display_message_popups", [](bool x) { ps::options::displayMessagePopups = x; }); + m.def("get_configure_imgui_style_callback", []() { return ps::options::configureImGuiStyleCallback; }); + m.def("set_configure_imgui_style_callback", [](std::function x) { ps::options::configureImGuiStyleCallback = x; }); // === Scene extents diff --git a/src/polyscope/core.py b/src/polyscope/core.py index e9cd241..5187c06 100644 --- a/src/polyscope/core.py +++ b/src/polyscope/core.py @@ -180,6 +180,12 @@ def set_warn_for_invalid_values(b): def set_display_message_popups(b): psb.set_display_message_popups(b) +def get_configure_imgui_style_callback(): + return psb.get_configure_imgui_style_callback() + +def set_configure_imgui_style_callback(f): + return psb.set_configure_imgui_style_callback(f) + def set_navigation_style(s): psb.set_navigation_style(str_to_navigate_style(s)) def get_navigation_style(): From d5d0ddbad5150fcfce36b9d1bef4b7346d8ba700 Mon Sep 17 00:00:00 2001 From: Merlin Nimier-David Date: Fri, 5 Dec 2025 14:35:02 +0100 Subject: [PATCH 03/17] ImGui: bindings for `ImGuiStyle` --- src/cpp/imgui.cpp | 98 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 97 insertions(+), 1 deletion(-) diff --git a/src/cpp/imgui.cpp b/src/cpp/imgui.cpp index 729ed4a..5fc812f 100644 --- a/src/cpp/imgui.cpp +++ b/src/cpp/imgui.cpp @@ -157,12 +157,109 @@ void bind_imgui_structs(py::module& m) { .def_readonly("SortDirection", &ImGuiTableColumnSortSpecs::SortDirection) ; + #define VEC2_PROPERTY(name) \ + def_property(#name, [](const ImGuiStyle& style) { \ + return from_vec2(style.name); \ + }, [](ImGuiStyle& style, const Vec2T& value) { \ + style.name = to_vec2(value); \ + }) + + + // Style + py::class_(m, "ImGuiStyle") + .def_readwrite("Alpha", &ImGuiStyle::Alpha) // float + .def_readwrite("DisabledAlpha", &ImGuiStyle::DisabledAlpha) // float + .VEC2_PROPERTY(WindowPadding) // ImVec2 + .def_readwrite("WindowRounding", &ImGuiStyle::WindowRounding) // float + .def_readwrite("WindowBorderSize", &ImGuiStyle::WindowBorderSize) // float + .def_readwrite("WindowBorderHoverPadding", &ImGuiStyle::WindowBorderHoverPadding) // float + .VEC2_PROPERTY(WindowMinSize) // ImVec2 + .VEC2_PROPERTY(WindowTitleAlign) // ImVec2 + .def_readwrite("WindowMenuButtonPosition", &ImGuiStyle::WindowMenuButtonPosition) // ImGuiDir + .def_readwrite("ChildRounding", &ImGuiStyle::ChildRounding) // float + .def_readwrite("ChildBorderSize", &ImGuiStyle::ChildBorderSize) // float + .def_readwrite("PopupRounding", &ImGuiStyle::PopupRounding) // float + .def_readwrite("PopupBorderSize", &ImGuiStyle::PopupBorderSize) // float + .VEC2_PROPERTY(FramePadding) // ImVec2 + .def_readwrite("FrameRounding", &ImGuiStyle::FrameRounding) // float + .def_readwrite("FrameBorderSize", &ImGuiStyle::FrameBorderSize) // float + .VEC2_PROPERTY(ItemSpacing) // ImVec2 + .VEC2_PROPERTY(ItemInnerSpacing) // ImVec2 + .VEC2_PROPERTY(CellPadding) // ImVec2 + .VEC2_PROPERTY(TouchExtraPadding) // ImVec2 + .def_readwrite("IndentSpacing", &ImGuiStyle::IndentSpacing) // float + .def_readwrite("ColumnsMinSpacing", &ImGuiStyle::ColumnsMinSpacing) // float + .def_readwrite("ScrollbarSize", &ImGuiStyle::ScrollbarSize) // float + .def_readwrite("ScrollbarRounding", &ImGuiStyle::ScrollbarRounding) // float + .def_readwrite("GrabMinSize", &ImGuiStyle::GrabMinSize) // float + .def_readwrite("GrabRounding", &ImGuiStyle::GrabRounding) // float + .def_readwrite("LogSliderDeadzone", &ImGuiStyle::LogSliderDeadzone) // float + .def_readwrite("ImageBorderSize", &ImGuiStyle::ImageBorderSize) // float + .def_readwrite("TabRounding", &ImGuiStyle::TabRounding) // float + .def_readwrite("TabBorderSize", &ImGuiStyle::TabBorderSize) // float + .def_readwrite("TabCloseButtonMinWidthSelected", &ImGuiStyle::TabCloseButtonMinWidthSelected) // float + .def_readwrite("TabCloseButtonMinWidthUnselected", &ImGuiStyle::TabCloseButtonMinWidthUnselected) // float + .def_readwrite("TabBarBorderSize", &ImGuiStyle::TabBarBorderSize) // float + .def_readwrite("TabBarOverlineSize", &ImGuiStyle::TabBarOverlineSize) // float + .def_readwrite("TableAngledHeadersAngle", &ImGuiStyle::TableAngledHeadersAngle) // float + .VEC2_PROPERTY(TableAngledHeadersTextAlign) // ImVec2 + .def_readwrite("ColorButtonPosition", &ImGuiStyle::ColorButtonPosition) // ImGuiDir + .VEC2_PROPERTY(ButtonTextAlign) // ImVec2 + .VEC2_PROPERTY(SelectableTextAlign) // ImVec2 + .def_readwrite("SeparatorTextBorderSize", &ImGuiStyle::SeparatorTextBorderSize) // float + .VEC2_PROPERTY(SeparatorTextAlign) // ImVec2 + .VEC2_PROPERTY(SeparatorTextPadding) // ImVec2 + .VEC2_PROPERTY(DisplayWindowPadding) // ImVec2 + .VEC2_PROPERTY(DisplaySafeAreaPadding) // ImVec2 + .def_readwrite("MouseCursorScale", &ImGuiStyle::MouseCursorScale) // float + .def_readwrite("AntiAliasedLines", &ImGuiStyle::AntiAliasedLines) // bool + .def_readwrite("AntiAliasedLinesUseTex", &ImGuiStyle::AntiAliasedLinesUseTex) // bool + .def_readwrite("AntiAliasedFill", &ImGuiStyle::AntiAliasedFill) // bool + .def_readwrite("CurveTessellationTol", &ImGuiStyle::CurveTessellationTol) // float + .def_readwrite("CircleTessellationMaxError", &ImGuiStyle::CircleTessellationMaxError) // float + + // Colors (ImVec4[ImGuiCol_COUNT]) + // Note: having explicit getter and setter functions for colors will avoid accidental no-ops such as: + // style.Colors[2] = ... + .def("GetColors", [](const ImGuiStyle &o) { + py::list colors; + for (int i = 0; i < ImGuiCol_COUNT; i++) { + colors.append(from_vec4(o.Colors[i])); + } + return colors; + }) + .def("SetColors", [](ImGuiStyle &o, const py::list& colors) { + if (colors.size() != ImGuiCol_COUNT) { + throw std::runtime_error("Expected " + std::to_string(ImGuiCol_COUNT) + + " colors, got " + std::to_string(colors.size())); + } + for (int i = 0; i < ImGuiCol_COUNT; i++) { + if (py::len(colors[i]) != 4) { + throw std::runtime_error("Expected 4 elements for color " + std::to_string(i) + + ", got " + std::to_string(py::len(colors[i]))); + } + o.Colors[i] = to_vec4(py::cast(colors[i])); + } + }, py::arg("colors")) + + // Behaviors + // (It is possible to modify those fields mid-frame if specific behavior need it, unlike e.g. configuration fields in ImGuiIO) + .def_readwrite("HoverStationaryDelay", &ImGuiStyle::HoverStationaryDelay) // float + .def_readwrite("HoverDelayShort", &ImGuiStyle::HoverDelayShort) // float + .def_readwrite("HoverDelayNormal", &ImGuiStyle::HoverDelayNormal) // float + .def_readwrite("HoverFlagsForTooltipMouse", &ImGuiStyle::HoverFlagsForTooltipMouse) // ImGuiHoveredFlags + .def_readwrite("HoverFlagsForTooltipNav", &ImGuiStyle::HoverFlagsForTooltipNav) // ImGuiHoveredFlags + + .def("ScaleAllSizes", &ImGuiStyle::ScaleAllSizes); + + #undef VEC2_PROPERTY } void bind_imgui_methods(py::module& m) { // Main m.def("GetIO", &ImGui::GetIO, py::return_value_policy::reference); + m.def("GetStyle", &ImGui::GetStyle, py::return_value_policy::reference); // Windows m.def( @@ -2625,4 +2722,3 @@ void bind_imgui_enums(py::module& m) { m.attr("ImDrawFlags_RoundCornersAll") = static_cast(ImDrawFlags_RoundCornersAll); } - From 31677a5fd23c6df2074b28f0fd3bb39a1e8606fd Mon Sep 17 00:00:00 2001 From: Merlin Nimier-David Date: Fri, 5 Dec 2025 14:35:21 +0100 Subject: [PATCH 04/17] ImGui: add missing `ImGuiCol` bindigs --- src/cpp/imgui.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/cpp/imgui.cpp b/src/cpp/imgui.cpp index 5fc812f..3a6fd06 100644 --- a/src/cpp/imgui.cpp +++ b/src/cpp/imgui.cpp @@ -2605,6 +2605,7 @@ void bind_imgui_enums(py::module& m) { m.attr("ImGuiCol_ScrollbarGrabActive") = static_cast(ImGuiCol_ScrollbarGrabActive); m.attr("ImGuiCol_CheckMark") = static_cast(ImGuiCol_CheckMark); m.attr("ImGuiCol_SliderGrab") = static_cast(ImGuiCol_SliderGrab); + m.attr("ImGuiCol_ScrollbarGrabHovered") = static_cast(ImGuiCol_ScrollbarGrabHovered); m.attr("ImGuiCol_SliderGrabActive") = static_cast(ImGuiCol_SliderGrabActive); m.attr("ImGuiCol_Button") = static_cast(ImGuiCol_Button); m.attr("ImGuiCol_ButtonHovered") = static_cast(ImGuiCol_ButtonHovered); @@ -2618,19 +2619,31 @@ void bind_imgui_enums(py::module& m) { m.attr("ImGuiCol_ResizeGrip") = static_cast(ImGuiCol_ResizeGrip); m.attr("ImGuiCol_ResizeGripHovered") = static_cast(ImGuiCol_ResizeGripHovered); m.attr("ImGuiCol_ResizeGripActive") = static_cast(ImGuiCol_ResizeGripActive); - m.attr("ImGuiCol_Tab") = static_cast(ImGuiCol_Tab); m.attr("ImGuiCol_TabHovered") = static_cast(ImGuiCol_TabHovered); - m.attr("ImGuiCol_TabActive") = static_cast(ImGuiCol_TabActive); + m.attr("ImGuiCol_Tab") = static_cast(ImGuiCol_Tab); + m.attr("ImGuiCol_TabSelected") = static_cast(ImGuiCol_TabSelected); + m.attr("ImGuiCol_TabSelectedOverline") = static_cast(ImGuiCol_TabSelectedOverline); + m.attr("ImGuiCol_TabDimmed") = static_cast(ImGuiCol_TabDimmed); + m.attr("ImGuiCol_TabDimmedSelected") = static_cast(ImGuiCol_TabDimmedSelected); + m.attr("ImGuiCol_TabDimmedSelectedOverline") = static_cast(ImGuiCol_TabDimmedSelectedOverline); + m.attr("ImGuiCol_TabActive") = static_cast(ImGuiCol_TabSelected); // Deprecated m.attr("ImGuiCol_TabUnfocused") = static_cast(ImGuiCol_TabUnfocused); m.attr("ImGuiCol_TabUnfocusedActive") = static_cast(ImGuiCol_TabUnfocusedActive); m.attr("ImGuiCol_PlotLines") = static_cast(ImGuiCol_PlotLines); m.attr("ImGuiCol_PlotLinesHovered") = static_cast(ImGuiCol_PlotLinesHovered); m.attr("ImGuiCol_PlotHistogram") = static_cast(ImGuiCol_PlotHistogram); m.attr("ImGuiCol_PlotHistogramHovered") = static_cast(ImGuiCol_PlotHistogramHovered); + m.attr("ImGuiCol_TableHeaderBg") = static_cast(ImGuiCol_TableHeaderBg); + m.attr("ImGuiCol_TableBorderStrong") = static_cast(ImGuiCol_TableBorderStrong); + m.attr("ImGuiCol_TableBorderLight") = static_cast(ImGuiCol_TableBorderLight); + m.attr("ImGuiCol_TableRowBg") = static_cast(ImGuiCol_TableRowBg); + m.attr("ImGuiCol_TableRowBgAlt") = static_cast(ImGuiCol_TableRowBgAlt); + m.attr("ImGuiCol_TextLink") = static_cast(ImGuiCol_TextLink); m.attr("ImGuiCol_TextSelectedBg") = static_cast(ImGuiCol_TextSelectedBg); m.attr("ImGuiCol_DragDropTarget") = static_cast(ImGuiCol_DragDropTarget); - m.attr("ImGuiCol_NavHighlight") = static_cast(ImGuiCol_NavHighlight); + m.attr("ImGuiCol_NavCursor") = static_cast(ImGuiCol_NavCursor); m.attr("ImGuiCol_NavWindowingHighlight") = static_cast(ImGuiCol_NavWindowingHighlight); + m.attr("ImGuiCol_NavHighlight") = static_cast(ImGuiCol_NavCursor); // Deprecated m.attr("ImGuiCol_NavWindowingDimBg") = static_cast(ImGuiCol_NavWindowingDimBg); m.attr("ImGuiCol_ModalWindowDimBg") = static_cast(ImGuiCol_ModalWindowDimBg); m.attr("ImGuiCol_COUNT") = static_cast(ImGuiCol_COUNT); From df8cc10e32f0952527f8a65d14d2c665f5ef02db Mon Sep 17 00:00:00 2001 From: Merlin Nimier-David Date: Fri, 5 Dec 2025 14:38:40 +0100 Subject: [PATCH 05/17] ImGui: add `SeparatorText` binding --- src/cpp/imgui.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cpp/imgui.cpp b/src/cpp/imgui.cpp index 3a6fd06..662feef 100644 --- a/src/cpp/imgui.cpp +++ b/src/cpp/imgui.cpp @@ -592,6 +592,10 @@ void bind_imgui_methods(py::module& m) { "BulletText", [](const char* fmt) { ImGui::BulletText("%s", fmt); }, py::arg("text")); + m.def( + "SeparatorText", + [](const char* label) { ImGui::SeparatorText(label); }, + py::arg("label")); // Widgets: Main m.def( From ede7fe475c86eb2f908a797806adf80e831e4b4a Mon Sep 17 00:00:00 2001 From: Merlin Nimier-David Date: Fri, 5 Dec 2025 15:18:14 +0100 Subject: [PATCH 06/17] Add customizable drag & drop callback (GLFW) --- src/cpp/core.cpp | 2 ++ src/polyscope/core.py | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/src/cpp/core.cpp b/src/cpp/core.cpp index adeaf20..4f8fced 100644 --- a/src/cpp/core.cpp +++ b/src/cpp/core.cpp @@ -145,6 +145,8 @@ PYBIND11_MODULE(polyscope_bindings, m) { m.def("set_display_message_popups", [](bool x) { ps::options::displayMessagePopups = x; }); m.def("get_configure_imgui_style_callback", []() { return ps::options::configureImGuiStyleCallback; }); m.def("set_configure_imgui_style_callback", [](std::function x) { ps::options::configureImGuiStyleCallback = x; }); + m.def("get_files_dropped_callback", []() { return ps::options::filesDroppedCallback; }); + m.def("set_files_dropped_callback", [](std::function&)> x) { ps::options::filesDroppedCallback = x; }); // === Scene extents diff --git a/src/polyscope/core.py b/src/polyscope/core.py index 5187c06..de15c39 100644 --- a/src/polyscope/core.py +++ b/src/polyscope/core.py @@ -186,6 +186,12 @@ def get_configure_imgui_style_callback(): def set_configure_imgui_style_callback(f): return psb.set_configure_imgui_style_callback(f) +def get_files_dropped_callback(): + return psb.get_files_dropped_callback() + +def set_files_dropped_callback(f): + return psb.set_files_dropped_callback(f) + def set_navigation_style(s): psb.set_navigation_style(str_to_navigate_style(s)) def get_navigation_style(): From 0db754c6eb7c2ca267d27d2e5c35911220373f86 Mon Sep 17 00:00:00 2001 From: Merlin Nimier-David Date: Wed, 10 Dec 2025 13:50:38 +0100 Subject: [PATCH 07/17] Add binding for `removeAllSlicePlanes()` --- src/cpp/core.cpp | 3 ++- src/polyscope/core.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cpp/core.cpp b/src/cpp/core.cpp index 4f8fced..cac0219 100644 --- a/src/cpp/core.cpp +++ b/src/cpp/core.cpp @@ -340,7 +340,8 @@ PYBIND11_MODULE(polyscope_bindings, m) { .def("get_volume_mesh_to_inspect", &ps::SlicePlane::getVolumeMeshToInspect, "get name of inspected volume mesh"); m.def("add_scene_slice_plane", ps::addSceneSlicePlane, "add a slice plane", py::return_value_policy::reference); - m.def("remove_last_scene_slice_plane", ps::removeLastSceneSlicePlane, "remove last scene plane"); + m.def("remove_last_scene_slice_plane", ps::removeLastSceneSlicePlane, "remove last scene slice plane"); + m.def("remove_all_slice_planes", ps::removeAllSlicePlanes, "remove all scene slice plane"); // === Camera Parameters py::class_(m, "CameraIntrinsics") diff --git a/src/polyscope/core.py b/src/polyscope/core.py index de15c39..1d0557c 100644 --- a/src/polyscope/core.py +++ b/src/polyscope/core.py @@ -578,6 +578,9 @@ def add_scene_slice_plane(): def remove_last_scene_slice_plane(): psb.remove_last_scene_slice_plane() +def remove_all_slice_planes(): + psb.remove_all_slice_planes() + ### Camera Parameters class CameraIntrinsics: From 91aee59374fad6c9e4df37889f47dcb588df6814 Mon Sep 17 00:00:00 2001 From: Merlin Nimier-David Date: Wed, 10 Dec 2025 15:16:49 +0100 Subject: [PATCH 08/17] Slice plane: bindings to get center and normal --- src/cpp/core.cpp | 2 ++ src/polyscope/core.py | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/src/cpp/core.cpp b/src/cpp/core.cpp index cac0219..3a06688 100644 --- a/src/cpp/core.cpp +++ b/src/cpp/core.cpp @@ -329,6 +329,8 @@ PYBIND11_MODULE(polyscope_bindings, m) { py::class_(m, "SlicePlane") .def(py::init()) .def_readonly("name", &ps::SlicePlane::name) + .def("get_center", &ps::SlicePlane::getCenter, "get plane center") + .def("get_normal", &ps::SlicePlane::getNormal, "get plane normal") .def("set_pose", &ps::SlicePlane::setPose, "set pose") .def("set_active", &ps::SlicePlane::setActive, "set active") .def("get_active", &ps::SlicePlane::getActive, "get active") diff --git a/src/polyscope/core.py b/src/polyscope/core.py index 1d0557c..b52b7e7 100644 --- a/src/polyscope/core.py +++ b/src/polyscope/core.py @@ -544,6 +544,15 @@ def __init__(self, instance): def get_name(self): return self.bound_slice_plane.name + def get_center(self): + return self.bound_slice_plane.get_center() + + def get_normal(self): + return self.bound_slice_plane.get_normal() + + def get_pose(self): + return (self.bound_slice_plane.get_center(), self.bound_slice_plane.get_normal()) + def set_pose(self, plane_position, plane_normal): self.bound_slice_plane.set_pose(glm3(plane_position), glm3(plane_normal)) From 2b2af6f652a3b35106058fdaee98eaebf4cf0385 Mon Sep 17 00:00:00 2001 From: Merlin Nimier-David Date: Thu, 11 Dec 2025 10:49:40 +0100 Subject: [PATCH 09/17] Update polyscope submodule --- deps/polyscope | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/polyscope b/deps/polyscope index 61fc32a..dc0c7c2 160000 --- a/deps/polyscope +++ b/deps/polyscope @@ -1 +1 @@ -Subproject commit 61fc32a3f45458a664de3f7f24fce0f3c3950a3a +Subproject commit dc0c7c204279c4f876d4e1b83c923df07d31d28f From bd95c04e2293a68291208e4ea3b93769f28b3d4c Mon Sep 17 00:00:00 2001 From: Nicholas Sharp Date: Sun, 14 Dec 2025 01:22:39 -0800 Subject: [PATCH 10/17] point dep at latest --- deps/polyscope | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/polyscope b/deps/polyscope index dc0c7c2..24ec7e3 160000 --- a/deps/polyscope +++ b/deps/polyscope @@ -1 +1 @@ -Subproject commit dc0c7c204279c4f876d4e1b83c923df07d31d28f +Subproject commit 24ec7e376ae657491c57014608eaadae8b35cdb3 From 3c84f94e2e8e3dd5ab88a2e741cab4fa0fe92be1 Mon Sep 17 00:00:00 2001 From: Nicholas Sharp Date: Sun, 14 Dec 2025 01:23:48 -0800 Subject: [PATCH 11/17] Revert "Slice plane: bindings to get center and normal" This reverts commit 91aee59374fad6c9e4df37889f47dcb588df6814. --- src/cpp/core.cpp | 2 -- src/polyscope/core.py | 9 --------- 2 files changed, 11 deletions(-) diff --git a/src/cpp/core.cpp b/src/cpp/core.cpp index 3a06688..cac0219 100644 --- a/src/cpp/core.cpp +++ b/src/cpp/core.cpp @@ -329,8 +329,6 @@ PYBIND11_MODULE(polyscope_bindings, m) { py::class_(m, "SlicePlane") .def(py::init()) .def_readonly("name", &ps::SlicePlane::name) - .def("get_center", &ps::SlicePlane::getCenter, "get plane center") - .def("get_normal", &ps::SlicePlane::getNormal, "get plane normal") .def("set_pose", &ps::SlicePlane::setPose, "set pose") .def("set_active", &ps::SlicePlane::setActive, "set active") .def("get_active", &ps::SlicePlane::getActive, "get active") diff --git a/src/polyscope/core.py b/src/polyscope/core.py index b52b7e7..1d0557c 100644 --- a/src/polyscope/core.py +++ b/src/polyscope/core.py @@ -544,15 +544,6 @@ def __init__(self, instance): def get_name(self): return self.bound_slice_plane.name - def get_center(self): - return self.bound_slice_plane.get_center() - - def get_normal(self): - return self.bound_slice_plane.get_normal() - - def get_pose(self): - return (self.bound_slice_plane.get_center(), self.bound_slice_plane.get_normal()) - def set_pose(self, plane_position, plane_normal): self.bound_slice_plane.set_pose(glm3(plane_position), glm3(plane_normal)) From 8557f8385b0a84c566835e5032a24e996ee0ca7a Mon Sep 17 00:00:00 2001 From: Nicholas Sharp Date: Sun, 14 Dec 2025 01:24:16 -0800 Subject: [PATCH 12/17] Revert "Add binding for `removeAllSlicePlanes()`" This reverts commit 0db754c6eb7c2ca267d27d2e5c35911220373f86. --- src/cpp/core.cpp | 3 +-- src/polyscope/core.py | 3 --- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/cpp/core.cpp b/src/cpp/core.cpp index cac0219..4f8fced 100644 --- a/src/cpp/core.cpp +++ b/src/cpp/core.cpp @@ -340,8 +340,7 @@ PYBIND11_MODULE(polyscope_bindings, m) { .def("get_volume_mesh_to_inspect", &ps::SlicePlane::getVolumeMeshToInspect, "get name of inspected volume mesh"); m.def("add_scene_slice_plane", ps::addSceneSlicePlane, "add a slice plane", py::return_value_policy::reference); - m.def("remove_last_scene_slice_plane", ps::removeLastSceneSlicePlane, "remove last scene slice plane"); - m.def("remove_all_slice_planes", ps::removeAllSlicePlanes, "remove all scene slice plane"); + m.def("remove_last_scene_slice_plane", ps::removeLastSceneSlicePlane, "remove last scene plane"); // === Camera Parameters py::class_(m, "CameraIntrinsics") diff --git a/src/polyscope/core.py b/src/polyscope/core.py index 1d0557c..de15c39 100644 --- a/src/polyscope/core.py +++ b/src/polyscope/core.py @@ -578,9 +578,6 @@ def add_scene_slice_plane(): def remove_last_scene_slice_plane(): psb.remove_last_scene_slice_plane() -def remove_all_slice_planes(): - psb.remove_all_slice_planes() - ### Camera Parameters class CameraIntrinsics: From d60602f89a7fa3159c7a61cdaac7144e5f5538f0 Mon Sep 17 00:00:00 2001 From: Nicholas Sharp Date: Sun, 14 Dec 2025 01:31:09 -0800 Subject: [PATCH 13/17] remove callback getters --- src/cpp/core.cpp | 2 -- src/polyscope/core.py | 6 ------ 2 files changed, 8 deletions(-) diff --git a/src/cpp/core.cpp b/src/cpp/core.cpp index 4f8fced..94cb294 100644 --- a/src/cpp/core.cpp +++ b/src/cpp/core.cpp @@ -143,9 +143,7 @@ PYBIND11_MODULE(polyscope_bindings, m) { m.def("set_hide_window_after_show", [](bool x) { ps::options::hideWindowAfterShow = x; }); m.def("set_warn_for_invalid_values", [](bool x) { ps::options::warnForInvalidValues = x; }); m.def("set_display_message_popups", [](bool x) { ps::options::displayMessagePopups = x; }); - m.def("get_configure_imgui_style_callback", []() { return ps::options::configureImGuiStyleCallback; }); m.def("set_configure_imgui_style_callback", [](std::function x) { ps::options::configureImGuiStyleCallback = x; }); - m.def("get_files_dropped_callback", []() { return ps::options::filesDroppedCallback; }); m.def("set_files_dropped_callback", [](std::function&)> x) { ps::options::filesDroppedCallback = x; }); diff --git a/src/polyscope/core.py b/src/polyscope/core.py index de15c39..9343898 100644 --- a/src/polyscope/core.py +++ b/src/polyscope/core.py @@ -180,15 +180,9 @@ def set_warn_for_invalid_values(b): def set_display_message_popups(b): psb.set_display_message_popups(b) -def get_configure_imgui_style_callback(): - return psb.get_configure_imgui_style_callback() - def set_configure_imgui_style_callback(f): return psb.set_configure_imgui_style_callback(f) -def get_files_dropped_callback(): - return psb.get_files_dropped_callback() - def set_files_dropped_callback(f): return psb.set_files_dropped_callback(f) From 5697a6439d17c523342ed2f3d93b548ecce09c19 Mon Sep 17 00:00:00 2001 From: Nicholas Sharp Date: Sun, 14 Dec 2025 01:38:32 -0800 Subject: [PATCH 14/17] add clear function for callbacks --- src/cpp/core.cpp | 3 +++ src/polyscope/core.py | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/src/cpp/core.cpp b/src/cpp/core.cpp index 94cb294..0dd3123 100644 --- a/src/cpp/core.cpp +++ b/src/cpp/core.cpp @@ -9,6 +9,7 @@ #include "polyscope/affine_remapper.h" #include "polyscope/camera_parameters.h" #include "polyscope/curve_network.h" +#include "polyscope/imgui_config.h" #include "polyscope/messages.h" #include "polyscope/pick.h" #include "polyscope/point_cloud.h" @@ -144,7 +145,9 @@ PYBIND11_MODULE(polyscope_bindings, m) { m.def("set_warn_for_invalid_values", [](bool x) { ps::options::warnForInvalidValues = x; }); m.def("set_display_message_popups", [](bool x) { ps::options::displayMessagePopups = x; }); m.def("set_configure_imgui_style_callback", [](std::function x) { ps::options::configureImGuiStyleCallback = x; }); + m.def("clear_configure_imgui_style_callback", []() {ps::options::configureImGuiStyleCallback = polyscope::configureImGuiStyle;}); m.def("set_files_dropped_callback", [](std::function&)> x) { ps::options::filesDroppedCallback = x; }); + m.def("clear_files_dropped_callback", []() {ps::options::filesDroppedCallback = nullptr;}); // === Scene extents diff --git a/src/polyscope/core.py b/src/polyscope/core.py index 9343898..c01c1fb 100644 --- a/src/polyscope/core.py +++ b/src/polyscope/core.py @@ -183,9 +183,15 @@ def set_display_message_popups(b): def set_configure_imgui_style_callback(f): return psb.set_configure_imgui_style_callback(f) +def clear_configure_imgui_style_callback(): + return psb.clear_configure_imgui_style_callback() + def set_files_dropped_callback(f): return psb.set_files_dropped_callback(f) +def clear_files_dropped_callback(): + return psb.clear_files_dropped_callback() + def set_navigation_style(s): psb.set_navigation_style(str_to_navigate_style(s)) def get_navigation_style(): From 01aa4e162daaff85ebe8bb522f00691abd713a6c Mon Sep 17 00:00:00 2001 From: Nicholas Sharp Date: Sun, 14 Dec 2025 01:38:43 -0800 Subject: [PATCH 15/17] add some tests --- test/polyscope_test.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/test/polyscope_test.py b/test/polyscope_test.py index 0a36448..847daa1 100644 --- a/test/polyscope_test.py +++ b/test/polyscope_test.py @@ -121,18 +121,22 @@ def sample_callback(): ps.set_user_callback(sample_callback) ps.show(3) - - # Make sure the callback got called - self.assertEqual(3, counts[0]) - + self.assertEqual(3, counts[0]) # Make sure the callback got called ps.clear_user_callback() ps.show(3) - - # Make sure the callback didn't get called any more - self.assertEqual(3, counts[0]) - - # Make sure clearing twice is ok - ps.clear_user_callback() + self.assertEqual(3, counts[0]) # Make sure the callback didn't get called any more + ps.clear_user_callback() # Make sure clearing twice is ok + + + ## Test other callback functions + def do_nothing_callback(): + pass + ps.set_configure_imgui_style_callback(do_nothing_callback) + ps.clear_configure_imgui_style_callback() + def do_nothing_callback_2(arg): + pass + ps.set_files_dropped_callback(do_nothing_callback) + ps.clear_files_dropped_callback() def test_view_options(self): From 36d05800175ce7285c510ea2c80d92c20b30e293 Mon Sep 17 00:00:00 2001 From: Nicholas Sharp Date: Sun, 14 Dec 2025 02:14:42 -0800 Subject: [PATCH 16/17] update for new callback namespace --- src/cpp/core.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cpp/core.cpp b/src/cpp/core.cpp index 0dd3123..b9be858 100644 --- a/src/cpp/core.cpp +++ b/src/cpp/core.cpp @@ -146,8 +146,8 @@ PYBIND11_MODULE(polyscope_bindings, m) { m.def("set_display_message_popups", [](bool x) { ps::options::displayMessagePopups = x; }); m.def("set_configure_imgui_style_callback", [](std::function x) { ps::options::configureImGuiStyleCallback = x; }); m.def("clear_configure_imgui_style_callback", []() {ps::options::configureImGuiStyleCallback = polyscope::configureImGuiStyle;}); - m.def("set_files_dropped_callback", [](std::function&)> x) { ps::options::filesDroppedCallback = x; }); - m.def("clear_files_dropped_callback", []() {ps::options::filesDroppedCallback = nullptr;}); + m.def("set_files_dropped_callback", [](std::function&)> x) { ps::state::filesDroppedCallback = x; }); + m.def("clear_files_dropped_callback", []() {ps::state::filesDroppedCallback = nullptr;}); // === Scene extents From e0e3940f37c350566afadc74d18347486c577037 Mon Sep 17 00:00:00 2001 From: Nicholas Sharp Date: Sun, 14 Dec 2025 02:14:57 -0800 Subject: [PATCH 17/17] update dep to latest --- deps/polyscope | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/polyscope b/deps/polyscope index 24ec7e3..bdec709 160000 --- a/deps/polyscope +++ b/deps/polyscope @@ -1 +1 @@ -Subproject commit 24ec7e376ae657491c57014608eaadae8b35cdb3 +Subproject commit bdec709a5eaf48f41cb1a7a527de2e065e73dc86