diff --git a/.github/workflows/test_linux.yml b/.github/workflows/test_linux.yml index 0504655..cbf0318 100644 --- a/.github/workflows/test_linux.yml +++ b/.github/workflows/test_linux.yml @@ -44,7 +44,7 @@ jobs: cmake -DCMAKE_BUILD_TYPE=Debug -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") -DPOLYSCOPE_BACKEND_OPENGL3_EGL=ON .. - name: build - run: cd build && make + run: cd build && cmake --build . --parallel - name: run test backend mock run: python3 test/polyscope_test.py -v diff --git a/.github/workflows/test_macos.yml b/.github/workflows/test_macos.yml index e8619eb..501c6c9 100644 --- a/.github/workflows/test_macos.yml +++ b/.github/workflows/test_macos.yml @@ -37,7 +37,7 @@ jobs: run: mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Debug -DPOLYSCOPE_BACKEND_OPENGL3_GLFW=ON -DPOLYSCOPE_BACKEND_OPENGL_MOCK=ON .. - name: build - run: cd build && make + run: cd build && cmake --build . --parallel - name: run test run: python test/polyscope_test.py -v diff --git a/.github/workflows/test_windows.yml b/.github/workflows/test_windows.yml index afbfa58..557ec5f 100644 --- a/.github/workflows/test_windows.yml +++ b/.github/workflows/test_windows.yml @@ -39,7 +39,7 @@ jobs: run: mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Debug .. - name: build - run: cd build && cmake --build "." + run: cd build && cmake --build . --parallel - name: run test run: python test/polyscope_test.py -v diff --git a/.gitignore b/.gitignore index ba129da..9d270b9 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,9 @@ __pycache__/ .cache *.egg-info +# Stubs that get generated as part of the build process +src/polyscope_bindings/*.pyi + # Editor and OS things imgui.ini .polyscope.ini diff --git a/CMakeLists.txt b/CMakeLists.txt index 92aa9da..a84df09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,16 +42,110 @@ nanobind_add_module(polyscope_bindings src/cpp/floating_quantities.cpp src/cpp/implicit_helpers.cpp src/cpp/managed_buffer.cpp + + src/cpp/utils.h - src/cpp/imgui.cpp - src/cpp/implot.cpp + # ImGui related things + src/cpp/imgui/imgui.cpp + + src/cpp/imgui/imgui_enums.cpp + src/cpp/imgui/imgui_structs.cpp + src/cpp/imgui/imgui_structs_fonts.cpp + src/cpp/imgui/imgui_macros.cpp + src/cpp/imgui/imgui_structs_io.cpp + src/cpp/imgui/imgui_structs_style.cpp + src/cpp/imgui/imgui_structs_drawlist.cpp + + src/cpp/imgui/imgui_api_main.cpp + src/cpp/imgui/imgui_api_context_creation.cpp + src/cpp/imgui/imgui_api_demo_debug.cpp + src/cpp/imgui/imgui_api_styles.cpp + src/cpp/imgui/imgui_api_windows.cpp + src/cpp/imgui/imgui_api_child_windows.cpp + src/cpp/imgui/imgui_api_window_utilities.cpp + src/cpp/imgui/imgui_api_window_manipulation.cpp + src/cpp/imgui/imgui_api_scrolling.cpp + src/cpp/imgui/imgui_api_parameter_stacks.cpp + src/cpp/imgui/imgui_api_style_read.cpp + src/cpp/imgui/imgui_api_cursor_layout.cpp + src/cpp/imgui/imgui_api_id_stack.cpp + src/cpp/imgui/imgui_api_widgets_text.cpp + src/cpp/imgui/imgui_api_widgets_main.cpp + src/cpp/imgui/imgui_api_widgets_images.cpp + src/cpp/imgui/imgui_api_widgets_combo.cpp + src/cpp/imgui/imgui_api_widgets_drag.cpp + src/cpp/imgui/imgui_api_widgets_sliders.cpp + src/cpp/imgui/imgui_api_widgets_input.cpp + src/cpp/imgui/imgui_api_widgets_color.cpp + src/cpp/imgui/imgui_api_widgets_trees.cpp + src/cpp/imgui/imgui_api_widgets_selectables.cpp + src/cpp/imgui/imgui_api_widgets_listbox.cpp + src/cpp/imgui/imgui_api_data_plotting.cpp + src/cpp/imgui/imgui_api_menus.cpp + src/cpp/imgui/imgui_api_tooltips.cpp + src/cpp/imgui/imgui_api_popups.cpp + src/cpp/imgui/imgui_api_tables.cpp + src/cpp/imgui/imgui_api_columns_legacy.cpp + src/cpp/imgui/imgui_api_tab_bars.cpp + src/cpp/imgui/imgui_api_logging.cpp + src/cpp/imgui/imgui_api_drag_drop.cpp + src/cpp/imgui/imgui_api_disabling.cpp + src/cpp/imgui/imgui_api_clipping.cpp + src/cpp/imgui/imgui_api_focus_activation.cpp + src/cpp/imgui/imgui_api_overlapping_items.cpp + src/cpp/imgui/imgui_api_item_query.cpp + src/cpp/imgui/imgui_api_viewports.cpp + src/cpp/imgui/imgui_api_draw_lists.cpp + src/cpp/imgui/imgui_api_misc_utils.cpp + src/cpp/imgui/imgui_api_text_utils.cpp + src/cpp/imgui/imgui_api_color_utils.cpp + src/cpp/imgui/imgui_api_inputs_keyboard.cpp + src/cpp/imgui/imgui_api_inputs_mouse.cpp + src/cpp/imgui/imgui_api_clipboard.cpp + src/cpp/imgui/imgui_api_settings.cpp + src/cpp/imgui/imgui_api_debug.cpp + src/cpp/imgui/imgui_api_allocators.cpp + + src/cpp/imgui/implot.cpp + + src/cpp/imgui/imgui_utils.h - src/cpp/utils.h - src/cpp/imgui_utils.h ) set_target_properties(polyscope_bindings PROPERTIES CXX_VISIBILITY_PRESET "default") target_include_directories(polyscope_bindings PUBLIC "${EIGEN3_INCLUDE_DIR}") target_link_libraries(polyscope_bindings PRIVATE polyscope) +# Generate type stubs +nanobind_add_stub( + polyscope_stub + MODULE polyscope_bindings + + PYTHON_PATH $ + DEPENDS polyscope_bindings + + MARKER_FILE py.typed + + RECURSIVE + + OUTPUT_PATH . + OUTPUT + __init__.pyi + imgui.pyi + implot.pyi +) + +# Copy stub files into the appropriate place in the source directory after build +set(STUB_FILES __init__.pyi imgui.pyi implot.pyi) +foreach(STUB_FILE ${STUB_FILES}) + add_custom_command( + TARGET polyscope_stub POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${CMAKE_CURRENT_BINARY_DIR}/polyscope_bindings/${STUB_FILE} + ${CMAKE_CURRENT_SOURCE_DIR}/src/polyscope_bindings/${STUB_FILE} + VERBATIM + ) +endforeach() + + install(TARGETS polyscope_bindings LIBRARY DESTINATION .) \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in index 520cb13..ee79bea 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -8,4 +8,5 @@ recursive-include deps/pybind11 *.h CMakeLists.txt *.cmake recursive-include src *.cpp *.h recursive-include src/polyscope *.py *.pyi recursive-include src/polyscope_bindings *.py *.pyi +global-include py.typed exclude dist diff --git a/deps/polyscope b/deps/polyscope index 892a332..21f15ad 160000 --- a/deps/polyscope +++ b/deps/polyscope @@ -1 +1 @@ -Subproject commit 892a33257c0ba00621b160118065a52847fe46b0 +Subproject commit 21f15ad65ee518e9468bbefd69c7deef915a225e diff --git a/src/cpp/imgui.cpp b/src/cpp/imgui.cpp deleted file mode 100644 index cc95f80..0000000 --- a/src/cpp/imgui.cpp +++ /dev/null @@ -1,2892 +0,0 @@ -#include "imgui.h" -#include "implot.h" - -#include "Eigen/Dense" - -#include "utils.h" -#include "imgui_utils.h" - -#include - -void bind_imgui_structs(nb::module_& m); -void bind_imgui_methods(nb::module_& m); -void bind_imgui_enums(nb::module_& m); - -void bind_imgui(nb::module_& m) { - auto imgui_module = m.def_submodule("imgui", "ImGui bindings"); - bind_imgui_structs(imgui_module); - bind_imgui_methods(imgui_module); - bind_imgui_enums(imgui_module); -} - -// clang-format off - -struct InputTextCallback_UserData { - std::string* str; - ImGuiInputTextCallback chain_callback; - void* chain_callback_user_data; -}; - -static int input_text_callback(ImGuiInputTextCallbackData* data) { - auto* user_data = reinterpret_cast(data->UserData); - if (data->EventFlag == ImGuiInputTextFlags_CallbackResize) { - // Resize string callback - // If for some reason we refuse the new length (BufTextLen) and/or capacity (BufSize) we - // need to set them back to what we want. - auto* str = user_data->str; - IM_ASSERT(data->Buf == str->c_str()); - str->resize(data->BufTextLen); - data->Buf = (char*)str->c_str(); - } else if (user_data->chain_callback) { - // Forward to user callback, if any - data->UserData = user_data->chain_callback_user_data; - return user_data->chain_callback(data); - } - return 0; -} - - -// clang-format off -void bind_imgui_structs(nb::module_& m) { - - // ImGuiIO - nb::class_(m, "ImGuiIO") - .def_rw("DisplaySize" ,&ImGuiIO::DisplaySize ) - .def_rw("DeltaTime" ,&ImGuiIO::DeltaTime ) - .def_rw("IniSavingRate" ,&ImGuiIO::IniSavingRate ) - .def_rw("IniFilename" ,&ImGuiIO::IniFilename ) - .def_rw("MouseDoubleClickTime" ,&ImGuiIO::MouseDoubleClickTime ) - .def_rw("MouseDoubleClickMaxDist" ,&ImGuiIO::MouseDoubleClickMaxDist ) - .def_rw("MouseDragThreshold" ,&ImGuiIO::MouseDragThreshold ) - .def_rw("KeyRepeatDelay" ,&ImGuiIO::KeyRepeatDelay ) - .def_rw("KeyRepeatRate" ,&ImGuiIO::KeyRepeatRate ) - .def_rw("Fonts" ,&ImGuiIO::Fonts ) - .def_rw("FontGlobalScale" ,&ImGuiIO::FontGlobalScale ) - .def_rw("FontAllowUserScaling" ,&ImGuiIO::FontAllowUserScaling ) - .def_rw("FontDefault" ,&ImGuiIO::FontDefault ) - .def_rw("DisplayFramebufferScale" ,&ImGuiIO::DisplayFramebufferScale ) - .def_rw("MouseDrawCursor" ,&ImGuiIO::MouseDrawCursor ) - .def_rw("ConfigMacOSXBehaviors" ,&ImGuiIO::ConfigMacOSXBehaviors ) - .def_rw("ConfigInputTextCursorBlink" ,&ImGuiIO::ConfigInputTextCursorBlink ) - .def_rw("ConfigDragClickToInputText" ,&ImGuiIO::ConfigDragClickToInputText ) - .def_rw("ConfigWindowsResizeFromEdges" ,&ImGuiIO::ConfigWindowsResizeFromEdges ) - .def_rw("ConfigWindowsMoveFromTitleBarOnly" ,&ImGuiIO::ConfigWindowsMoveFromTitleBarOnly ) - .def_rw("ConfigMemoryCompactTimer" ,&ImGuiIO::ConfigMemoryCompactTimer ) - .def_prop_ro("MousePos" , [](ImGuiIO& o) { return from_vec2(o.MousePos);} ) - .def_prop_ro("MouseDown" , [](ImGuiIO& o) { return std::to_array(o.MouseDown);} ) - .def_rw("MouseWheel" ,&ImGuiIO::MouseWheel ) - .def_rw("MouseWheelH" ,&ImGuiIO::MouseWheelH ) - .def_rw("KeyCtrl" ,&ImGuiIO::KeyCtrl ) - .def_rw("KeyShift" ,&ImGuiIO::KeyShift ) - .def_rw("KeyAlt" ,&ImGuiIO::KeyAlt ) - .def_rw("KeySuper" ,&ImGuiIO::KeySuper ) - .def_rw("WantCaptureMouse" ,&ImGuiIO::WantCaptureMouse ) - .def_rw("WantCaptureKeyboard" ,&ImGuiIO::WantCaptureKeyboard ) - .def_rw("WantTextInput" ,&ImGuiIO::WantTextInput ) - .def_rw("WantSetMousePos" ,&ImGuiIO::WantSetMousePos ) - .def_rw("WantSaveIniSettings" ,&ImGuiIO::WantSaveIniSettings ) - .def_rw("NavActive" ,&ImGuiIO::NavActive ) - .def_rw("NavVisible" ,&ImGuiIO::NavVisible ) - .def_rw("Framerate" ,&ImGuiIO::Framerate ) - .def_rw("MetricsRenderVertices" ,&ImGuiIO::MetricsRenderVertices ) - .def_rw("MetricsRenderIndices" ,&ImGuiIO::MetricsRenderIndices ) - .def_rw("MetricsRenderWindows" ,&ImGuiIO::MetricsRenderWindows ) - .def_rw("MetricsActiveWindows" ,&ImGuiIO::MetricsActiveWindows ) - .def_prop_ro("MouseDelta" , [](ImGuiIO& o) { return from_vec2(o.MouseDelta);}) - .def_rw("WantCaptureMouseUnlessPopupClose" ,&ImGuiIO::WantCaptureMouseUnlessPopupClose ) - .def_rw("KeyMods" ,&ImGuiIO::KeyMods ) - .def_rw("MousePosPrev" ,&ImGuiIO::MousePosPrev ) - .def_prop_ro("MouseClickedPos" , [](ImGuiIO& o) { return std::to_array(o.MouseClickedPos); }) - .def_prop_ro("MouseClickedTime" , [](ImGuiIO& o) { return std::to_array(o.MouseClickedTime); }) - .def_prop_ro("MouseClicked" , [](ImGuiIO& o) { return std::to_array(o.MouseClicked); }) - .def_prop_ro("MouseDoubleClicked" , [](ImGuiIO& o) { return std::to_array(o.MouseDoubleClicked); }) - .def_prop_ro("MouseClickedCount" , [](ImGuiIO& o) { return std::to_array(o.MouseClickedCount); }) - .def_prop_ro("MouseClickedLastCount" , [](ImGuiIO& o) { return std::to_array(o.MouseClickedLastCount); }) - .def_prop_ro("MouseReleased" , [](ImGuiIO& o) { return std::to_array(o.MouseReleased); }) - .def_prop_ro("MouseDownOwned" , [](ImGuiIO& o) { return std::to_array(o.MouseDownOwned); }) - .def_prop_ro("MouseDownOwnedUnlessPopupClose" , [](ImGuiIO& o) { return std::to_array(o.MouseDownOwnedUnlessPopupClose); }) - .def_prop_ro("MouseDownDuration" , [](ImGuiIO& o) { return std::to_array(o.MouseDownDuration); }) - .def_prop_ro("MouseDownDurationPrev" , [](ImGuiIO& o) { return std::to_array(o.MouseDownDurationPrev); }) - .def_prop_ro("MouseDragMaxDistanceSqr" , [](ImGuiIO& o) { return std::to_array(o.MouseDragMaxDistanceSqr); }) - .def_rw("PenPressure" ,&ImGuiIO::PenPressure ) - .def_rw("AppFocusLost" ,&ImGuiIO::AppFocusLost ) - .def_rw("InputQueueSurrogate" ,&ImGuiIO::InputQueueSurrogate ) - .def_rw("InputQueueCharacters" ,&ImGuiIO::InputQueueCharacters ) - - ; - - - nb::class_(m, "ImFontAtlas") - .def("AddFontFromFileTTF", - [](ImFontAtlas& o, std::string filename, float size_pixels) { - return o.AddFontFromFileTTF(filename.c_str(), size_pixels);}, - nb::rv_policy::reference) - - // TODO add bindings to the rest of the font functions - - ; - - nb::class_(m, "ImFont") - - // TODO add bindings to the rest of the font functions - - ; - - - // Table sorting - nb::class_(m, "ImGuiTableSortSpecs") - .def("Specs", [](ImGuiTableSortSpecs& o) { - std::vector specs; - for (int i = 0; i < o.SpecsCount; i++) { - specs.push_back(o.Specs[i]); - } - return specs;} - ) - .def_ro("SpecsCount", &ImGuiTableSortSpecs::SpecsCount) - .def_rw("SpecsDirty", &ImGuiTableSortSpecs::SpecsDirty) - ; - - nb::class_(m, "ImGuiTableColumnSortSpecs") - .def_ro("ColumnUserID", &ImGuiTableColumnSortSpecs::ColumnUserID) - .def_ro("ColumnIndex", &ImGuiTableColumnSortSpecs::ColumnIndex) - .def_ro("SortOrder", &ImGuiTableColumnSortSpecs::SortOrder) - .def_ro("SortDirection", &ImGuiTableColumnSortSpecs::SortDirection) - ; - - #define VEC2_PROPERTY(name) \ - def_prop_rw(#name, [](const ImGuiStyle& style) { \ - return from_vec2(style.name); \ - }, [](ImGuiStyle& style, const Vec2T& value) { \ - style.name = to_vec2(value); \ - }) - - - // Style - nb::class_(m, "ImGuiStyle") - .def_rw("Alpha", &ImGuiStyle::Alpha) // float - .def_rw("DisabledAlpha", &ImGuiStyle::DisabledAlpha) // float - .VEC2_PROPERTY(WindowPadding) // ImVec2 - .def_rw("WindowRounding", &ImGuiStyle::WindowRounding) // float - .def_rw("WindowBorderSize", &ImGuiStyle::WindowBorderSize) // float - .def_rw("WindowBorderHoverPadding", &ImGuiStyle::WindowBorderHoverPadding) // float - .VEC2_PROPERTY(WindowMinSize) // ImVec2 - .VEC2_PROPERTY(WindowTitleAlign) // ImVec2 - .def_rw("WindowMenuButtonPosition", &ImGuiStyle::WindowMenuButtonPosition) // ImGuiDir - .def_rw("ChildRounding", &ImGuiStyle::ChildRounding) // float - .def_rw("ChildBorderSize", &ImGuiStyle::ChildBorderSize) // float - .def_rw("PopupRounding", &ImGuiStyle::PopupRounding) // float - .def_rw("PopupBorderSize", &ImGuiStyle::PopupBorderSize) // float - .VEC2_PROPERTY(FramePadding) // ImVec2 - .def_rw("FrameRounding", &ImGuiStyle::FrameRounding) // float - .def_rw("FrameBorderSize", &ImGuiStyle::FrameBorderSize) // float - .VEC2_PROPERTY(ItemSpacing) // ImVec2 - .VEC2_PROPERTY(ItemInnerSpacing) // ImVec2 - .VEC2_PROPERTY(CellPadding) // ImVec2 - .VEC2_PROPERTY(TouchExtraPadding) // ImVec2 - .def_rw("IndentSpacing", &ImGuiStyle::IndentSpacing) // float - .def_rw("ColumnsMinSpacing", &ImGuiStyle::ColumnsMinSpacing) // float - .def_rw("ScrollbarSize", &ImGuiStyle::ScrollbarSize) // float - .def_rw("ScrollbarRounding", &ImGuiStyle::ScrollbarRounding) // float - .def_rw("GrabMinSize", &ImGuiStyle::GrabMinSize) // float - .def_rw("GrabRounding", &ImGuiStyle::GrabRounding) // float - .def_rw("LogSliderDeadzone", &ImGuiStyle::LogSliderDeadzone) // float - .def_rw("ImageBorderSize", &ImGuiStyle::ImageBorderSize) // float - .def_rw("TabRounding", &ImGuiStyle::TabRounding) // float - .def_rw("TabBorderSize", &ImGuiStyle::TabBorderSize) // float - .def_rw("TabCloseButtonMinWidthSelected", &ImGuiStyle::TabCloseButtonMinWidthSelected) // float - .def_rw("TabCloseButtonMinWidthUnselected", &ImGuiStyle::TabCloseButtonMinWidthUnselected) // float - .def_rw("TabBarBorderSize", &ImGuiStyle::TabBarBorderSize) // float - .def_rw("TabBarOverlineSize", &ImGuiStyle::TabBarOverlineSize) // float - .def_rw("TableAngledHeadersAngle", &ImGuiStyle::TableAngledHeadersAngle) // float - .VEC2_PROPERTY(TableAngledHeadersTextAlign) // ImVec2 - .def_rw("ColorButtonPosition", &ImGuiStyle::ColorButtonPosition) // ImGuiDir - .VEC2_PROPERTY(ButtonTextAlign) // ImVec2 - .VEC2_PROPERTY(SelectableTextAlign) // ImVec2 - .def_rw("SeparatorTextBorderSize", &ImGuiStyle::SeparatorTextBorderSize) // float - .VEC2_PROPERTY(SeparatorTextAlign) // ImVec2 - .VEC2_PROPERTY(SeparatorTextPadding) // ImVec2 - .VEC2_PROPERTY(DisplayWindowPadding) // ImVec2 - .VEC2_PROPERTY(DisplaySafeAreaPadding) // ImVec2 - .def_rw("MouseCursorScale", &ImGuiStyle::MouseCursorScale) // float - .def_rw("AntiAliasedLines", &ImGuiStyle::AntiAliasedLines) // bool - .def_rw("AntiAliasedLinesUseTex", &ImGuiStyle::AntiAliasedLinesUseTex) // bool - .def_rw("AntiAliasedFill", &ImGuiStyle::AntiAliasedFill) // bool - .def_rw("CurveTessellationTol", &ImGuiStyle::CurveTessellationTol) // float - .def_rw("CircleTessellationMaxError", &ImGuiStyle::CircleTessellationMaxError) // float - - // FIXME - // .def_rw("Colors", &ImGuiStyle::Colors) - - // Colors (ImVec4[ImGuiCol_COUNT]) - // Note: having explicit getter and setter functions for colors will avoid accidental no-ops such as: - // style.Colors[2] = ... - // FIXME - /* - .def("GetColors", [](const ImGuiStyle &o) { - nb::list colors; - for (int i = 0; i < ImGuiCol_COUNT; i++) { - colors.append(from_vec4(o.Colors[i])); - } - return colors; - }) - .def("SetColors", [](ImGuiStyle &o, const nb::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 (nb::len(colors[i]) != 4) { - throw std::runtime_error("Expected 4 elements for color " + std::to_string(i) - + ", got " + std::to_string(nb::len(colors[i]))); - } - o.Colors[i] = to_vec4(nb::cast(colors[i])); - } - }, nb::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_rw("HoverStationaryDelay", &ImGuiStyle::HoverStationaryDelay) // float - .def_rw("HoverDelayShort", &ImGuiStyle::HoverDelayShort) // float - .def_rw("HoverDelayNormal", &ImGuiStyle::HoverDelayNormal) // float - .def_rw("HoverFlagsForTooltipMouse", &ImGuiStyle::HoverFlagsForTooltipMouse) // ImGuiHoveredFlags - .def_rw("HoverFlagsForTooltipNav", &ImGuiStyle::HoverFlagsForTooltipNav) // ImGuiHoveredFlags - - .def("ScaleAllSizes", &ImGuiStyle::ScaleAllSizes); - - #undef VEC2_PROPERTY -} - -void bind_imgui_methods(nb::module_& m) { - - // Main - m.def("GetIO", &ImGui::GetIO, nb::rv_policy::reference); - m.def("GetStyle", &ImGui::GetStyle, nb::rv_policy::reference); - - // Windows - m.def( - "Begin", - [](const char* name, bool open, ImGuiWindowFlags flags) { - const auto clicked = ImGui::Begin(name, &open, flags); - return std::make_tuple(clicked, open); - }, - nb::arg("name"), - nb::arg("open"), - nb::arg("flags") = 0); - m.def("End", []() { ImGui::End(); }); - - // Child Windows - m.def( - "BeginChild", - [](const char* str_id, Vec2T size, bool border, ImGuiWindowFlags flags) { - return ImGui::BeginChild(str_id, to_vec2(size), border, flags); - }, - nb::arg("str_id"), - nb::arg("size") = Vec2T(0.f, 0.f), - nb::arg("border") = false, - nb::arg("flags") = 0); - m.def( - "BeginChild", - [](ImGuiID id, const Vec2T& size, bool border, ImGuiWindowFlags flags) { - return ImGui::BeginChild(id, to_vec2(size), border, flags); - }, - nb::arg("id"), - nb::arg("size") = Vec2T(0.f, 0.f), - nb::arg("border") = false, - nb::arg("flags") = 0); - m.def("EndChild", []() { ImGui::EndChild(); }); - - // Windows Utilities - m.def("IsWindowAppearing", []() { return ImGui::IsWindowAppearing(); }); - m.def("IsWindowCollapsed", []() { return ImGui::IsWindowCollapsed(); }); - m.def( - "IsWindowFocused", - [](ImGuiFocusedFlags flags) { return ImGui::IsWindowFocused(flags); }, - nb::arg("flags") = 0); - m.def( - "IsWindowHovered", - [](ImGuiFocusedFlags flags) { return ImGui::IsWindowHovered(flags); }, - nb::arg("flags") = 0); - m.def("GetWindowDrawList", []() { return ImGui::GetWindowDrawList(); }, nb::rv_policy::reference); - m.def("GetWindowPos", []() { return from_vec2(ImGui::GetWindowPos()); }); - m.def("GetWindowSize", []() { return from_vec2(ImGui::GetWindowSize()); }); - m.def("GetWindowWidth", []() { return ImGui::GetWindowWidth(); }); - m.def("GetWindowHeight", []() { return ImGui::GetWindowHeight(); }); - m.def( - "SetNextWindowPos", - [](const Vec2T& pos, ImGuiCond cond, const Vec2T& pivot) { - ImGui::SetNextWindowPos(to_vec2(pos), cond, to_vec2(pivot)); - }, - nb::arg("pos"), - nb::arg("cond") = 0, - nb::arg("pivot") = Vec2T(0., 0.)); - m.def( - "SetNextWindowSize", - [](const Vec2T& size, ImGuiCond cond) { ImGui::SetNextWindowSize(to_vec2(size), cond); }, - nb::arg("size"), - nb::arg("cond") = 0); - m.def( - "SetNextWindowSizeConstraints", - [](const Vec2T& size_min, const Vec2T& size_max) { - ImGui::SetNextWindowSizeConstraints(to_vec2(size_min), to_vec2(size_max)); - }, - nb::arg("size_min"), - nb::arg("size_max")); - m.def( - "SetNextWindowContextSize", - [](const Vec2T& size) { ImGui::SetNextWindowContentSize(to_vec2(size)); }, - nb::arg("size")); - m.def( - "SetNextWindowCollapsed", - [](bool collapsed, ImGuiCond cond) { ImGui::SetNextWindowCollapsed(collapsed, cond); }, - nb::arg("collapsed"), - nb::arg("cond") = 0); - m.def("SetNextWindowFocus", []() { ImGui::SetNextWindowFocus(); }); - m.def("SetNextWindowBgAlpha", [](float alpha) { ImGui::SetNextWindowBgAlpha(alpha); }); - m.def( - "SetWindowPos", - [](const Vec2T& pos, ImGuiCond cond) { ImGui::SetWindowPos(to_vec2(pos), cond); }, - nb::arg("pos"), - nb::arg("cond") = 0); - m.def( - "SetWindowSize", - [](const Vec2T& size, ImGuiCond cond) { ImGui::SetWindowSize(to_vec2(size), cond); }, - nb::arg("size"), - nb::arg("cond") = 0); - m.def( - "SetWindowCollapsed", - [](bool collapsed, ImGuiCond cond) { ImGui::SetWindowCollapsed(collapsed, cond); }, - nb::arg("collapsed"), - nb::arg("cond") = 0); - m.def("set_window_focus", []() { ImGui::SetWindowFocus(); }); - m.def( - "SetWindowFontScale", - [](float scale) { ImGui::SetWindowFontScale(scale); }, - nb::arg("scale")); - m.def( - "SetWindowPos", - [](const char* name, const Vec2T& pos, ImGuiCond cond) { - ImGui::SetWindowPos(name, to_vec2(pos), cond); - }, - nb::arg("name"), - nb::arg("pos"), - nb::arg("cond") = 0); - m.def( - "SetWindowSize", - [](const char* name, const Vec2T& size, ImGuiCond cond) { - ImGui::SetWindowSize(name, to_vec2(size), cond); - }, - nb::arg("name"), - nb::arg("size"), - nb::arg("cond") = 0); - m.def( - "SetWindowCollapsed", - [](const char* name, bool collapsed, ImGuiCond cond) { - ImGui::SetWindowCollapsed(name, collapsed, cond); - }, - nb::arg("name"), - nb::arg("collapsed"), - nb::arg("cond") = 0); - m.def( - "SetWindowFocus", [](const char* name) { ImGui::SetWindowFocus(name); }, nb::arg("name")); - - // Content region - m.def("GetContentRegionMax", []() { - return from_vec2(ImGui::GetContentRegionMax()); }); - m.def("GetContentRegionAvail", []() { - return from_vec2(ImGui::GetContentRegionAvail()); }); - m.def("GetWindowContentRegionMin", []() { - return from_vec2(ImGui::GetWindowContentRegionMin()); }); - m.def("GetWindowContentRegionMax", []() { - return from_vec2(ImGui::GetWindowContentRegionMax()); }); - - // Windows Scrolling - m.def("GetScrollX", []() { return ImGui::GetScrollX(); }); - m.def("GetScrollY", []() { return ImGui::GetScrollY(); }); - m.def("GetScrollMaxX", []() { return ImGui::GetScrollMaxX(); }); - m.def("GetScrollMaxY", []() { return ImGui::GetScrollMaxY(); }); - m.def( - "SetScrollX", - [](float scroll_x) { ImGui::SetScrollX(scroll_x); }, - nb::arg("scroll_x")); - m.def( - "SetScrollY", - [](float scroll_y) { ImGui::SetScrollY(scroll_y); }, - nb::arg("scroll_y")); - m.def( - "SetScrollHereX", - [](float center_x_ratio) { ImGui::SetScrollHereX(center_x_ratio); }, - nb::arg("center_x_ratio") = 0.5f); - m.def( - "SetScrollHereY", - [](float center_y_ratio) { ImGui::SetScrollHereY(center_y_ratio); }, - nb::arg("center_y_ratio") = 0.5f); - m.def( - "SetScrollFromPosX", - [](float local_x, float center_x_ratio) { ImGui::SetScrollFromPosX(local_x, center_x_ratio); }, - nb::arg("local_x"), - nb::arg("center_x_ratio") = 0.5f); - m.def( - "SetScrollFromPosY", - [](float local_y, float center_y_ratio) { ImGui::SetScrollFromPosY(local_y, center_y_ratio); }, - nb::arg("local_y"), - nb::arg("center_y_ratio") = 0.5f); - - // Parameters stacks (shared) - IMGUI_API void PushFont(ImFont* font); // use NULL as a shortcut to push default font - IMGUI_API void PopFont(); - m.def( - "PushFont", - [](ImFont* font) { ImGui::PushFont(font); }, - nb::arg("font")); - m.def( - "PopFont", - []() { ImGui::PopFont(); } - ); - m.def( - "PushStyleColor", - [](ImGuiCol idx, ImU32 col) { ImGui::PushStyleColor(idx, col); }, - nb::arg("idx"), - nb::arg("col")); - m.def( - "PushStyleColor", - [](ImGuiCol idx, const Vec4T& col) { ImGui::PushStyleColor(idx, to_vec4(col)); }, - nb::arg("idx"), - nb::arg("col")); - m.def( - "PopStyleColor", [](int count) { ImGui::PopStyleColor(count); }, nb::arg("count") = 1); - m.def( - "PushStyleVar", - [](ImGuiCol idx, float val) { ImGui::PushStyleVar(idx, val); }, - nb::arg("idx"), - nb::arg("val")); - m.def( - "PushStyleVar", - [](ImGuiCol idx, const Vec2T& val) { ImGui::PushStyleVar(idx, to_vec2(val)); }, - nb::arg("idx"), - nb::arg("val")); - m.def( - "PopStyleVar", [](int count) { ImGui::PopStyleVar(count); }, nb::arg("count") = 1); - m.def( - "GetStyleColorVec4", - [](ImGuiCol idx) { return from_vec4(ImGui::GetStyleColorVec4(idx)); }, - nb::arg("idx")); - m.def("GetFontSize", []() { return ImGui::GetFontSize(); }); - m.def("GetFontTexUvWhitePixel", - []() { return from_vec2(ImGui::GetFontTexUvWhitePixel()); }); - m.def( - "GetColorU32", - [](ImGuiCol idx, float alpha_mul) { return ImGui::GetColorU32(idx, alpha_mul); }, - nb::arg("idx"), - nb::arg("alpha_mul") = 1.0f); - m.def( - "GetColorU32", [](const Vec4T& col) { return ImGui::GetColorU32(to_vec4(col)); }, nb::arg("col")); - m.def( - "GetColorU32", [](ImU32 col) { return ImGui::GetColorU32(col); }, nb::arg("col")); - - // Parameters stacks (current window) - m.def( - "PushItemWidth", - [](float item_width) { return ImGui::PushItemWidth(item_width); }, - nb::arg("item_width")); - m.def("PopItemWidth", []() { ImGui::PopItemWidth(); }); - m.def( - "SetNextItemWidth", - [](float item_width) { return ImGui::SetNextItemWidth(item_width); }, - nb::arg("item_width")); - m.def("CalcItemWidth", []() { return ImGui::CalcItemWidth(); }); - m.def( - "PushTextWrapPos", - [](float wrap_local_pos_x) { ImGui::PushTextWrapPos(wrap_local_pos_x); }, - nb::arg("wrap_local_pos_x") = 0.0f); - m.def("PopTextWrapPos", []() { ImGui::PopTextWrapPos(); }); - m.def( - "PushAllowKeyboardFocus", - [](bool allow_keyboard_focus) { ImGui::PushAllowKeyboardFocus(allow_keyboard_focus); }, - nb::arg("allow_keyboard_focus")); - m.def("PopAllowKeyboardFocus", []() { ImGui::PopAllowKeyboardFocus(); }); - m.def( - "PushButtonRepeat", - [](bool repeat) { ImGui::PushButtonRepeat(repeat); }, - nb::arg("allow_keyboard_focus")); - m.def("PopButtonRepeat", []() { ImGui::PopButtonRepeat(); }); - - // Cursor / Layout - m.def("Separator", []() { ImGui::Separator(); }); - m.def( - "SameLine", - [](float offset_from_start_x, float spacing) { ImGui::SameLine(); }, - nb::arg("offset_from_start_x") = 0.0f, - nb::arg("offset") = -1.0f); - m.def("NewLine", []() { ImGui::NewLine(); }); - m.def("Spacing", []() { ImGui::Spacing(); }); - m.def("Dummy", [](const Vec2T& size) { ImGui::Dummy(to_vec2(size)); }); - m.def( - "Indent", [](float indent_w) { ImGui::Indent(indent_w); }, nb::arg("indent_w") = 0.f); - m.def( - "Unindent", [](float indent_w) { ImGui::Unindent(indent_w); }, nb::arg("indent_w") = 0.f); - m.def("BeginGroup", []() { ImGui::BeginGroup(); }); - m.def("EndGroup", []() { ImGui::EndGroup(); }); - m.def("GetCursorPos", []() { return from_vec2(ImGui::GetCursorPos()); }); - m.def("GetCursorPosX", []() { return ImGui::GetCursorPosX(); }); - m.def("GetCursorPosY", []() { return ImGui::GetCursorPosY(); }); - m.def( - "SetCursorPos", - [](const Vec2T& local_pos) { ImGui::SetCursorPos(to_vec2(local_pos)); }, - nb::arg("local_pos")); - m.def( - "SetCursorPosX", - [](float local_x) { ImGui::SetCursorPosX(local_x); }, - nb::arg("local_x")); - m.def( - "SetCursorPosY", - [](float local_y) { ImGui::SetCursorPosY(local_y); }, - nb::arg("local_y")); - m.def("GetCursorStartPos", []() { return from_vec2(ImGui::GetCursorStartPos()); }); - m.def("GetCursorScreenPos", []() { return from_vec2(ImGui::GetCursorScreenPos()); }); - m.def( - "SetCursorScreenPos", - [](const Vec2T& pos) { ImGui::SetCursorScreenPos(to_vec2(pos)); }, - nb::arg("pos")); - m.def("AlignTextToFramePadding", []() { ImGui::AlignTextToFramePadding(); }); - m.def("GetTextLineHeight", []() { return ImGui::GetTextLineHeight(); }); - m.def("GetTextLineHeightWithSpacing", []() { return ImGui::GetTextLineHeightWithSpacing(); }); - m.def("GetFrameHeight", []() { return ImGui::GetFrameHeight(); }); - m.def("GetFrameHeightWithSpacing", []() { return ImGui::GetFrameHeightWithSpacing(); }); - - // ID stack/scopes - m.def( - "PushID", [](const char* str_id) { ImGui::PushID(str_id); }, nb::arg("str_id")); - m.def( - "PushID", [](int int_id) { ImGui::PushID(int_id); }, nb::arg("int_id")); - m.def("PopID", []() { ImGui::PopID(); }); - m.def( - "GetID", [](const char* str_id) { return ImGui::GetID(str_id); }, nb::arg("str_id")); - - // these are typos (bad capitalization). kept around to avoid needless breaking changes - m.def( - "PushId", [](const char* str_id) { ImGui::PushID(str_id); }, nb::arg("str_id")); - m.def( - "PushId", [](int int_id) { ImGui::PushID(int_id); }, nb::arg("int_id")); - m.def( - "GetId", [](const char* str_id) { return ImGui::GetID(str_id); }, nb::arg("str_id")); - - // Widgets: Text - m.def( - "TextUnformatted", [](const char* text) { ImGui::TextUnformatted(text); }, nb::arg("text")); - m.def( - "Text", [](const char* text) { ImGui::Text("%s", text); }, nb::arg("text")); - m.def( - "TextColored", - [](const Vec4T& color, const char* text) { ImGui::TextColored(to_vec4(color), "%s", text); }, - nb::arg("color"), - nb::arg("text")); - m.def( - "TextDisabled", [](const char* text) { ImGui::TextDisabled("%s", text); }, nb::arg("text")); - m.def( - "TextWrapped", [](const char* text) { ImGui::TextWrapped("%s", text); }, nb::arg("text")); - m.def( - "LabelText", - [](const char* label, const char* text) { ImGui::LabelText(label, "%s", text); }, - nb::arg("label"), - nb::arg("text")); - m.def( - "BulletText", - [](const char* fmt) { ImGui::BulletText("%s", fmt); }, - nb::arg("text")); - m.def( - "SeparatorText", - [](const char* label) { ImGui::SeparatorText(label); }, - nb::arg("label")); - - // Widgets: Main - m.def( - "Button", - [](const char* label, const Vec2T& size) { return ImGui::Button(label, to_vec2(size)); }, - nb::arg("label"), - nb::arg("size") = Vec2T(0.f, 0.f)); - m.def( - "SmallButton", - [](const char* label) { return ImGui::SmallButton(label); }, - nb::arg("label")); - m.def( - "InvisibleButton", - [](const char* str_id, const Vec2T& size) { - return ImGui::InvisibleButton(str_id, to_vec2(size)); - }, - nb::arg("str_id"), - nb::arg("size")); - m.def( - "ArrowButton", - [](const char* str_id, ImGuiDir dir) { return ImGui::ArrowButton(str_id, dir); }, - nb::arg("str_id"), - nb::arg("dir")); - m.def( - "Checkbox", - [](const char* label, bool v) { - const auto clicked = ImGui::Checkbox(label, &v); - return std::make_tuple(clicked, v); - }, - nb::arg("label"), - nb::arg("v")); - m.def( - "CheckboxFlags", - [](const char* label, unsigned int flags, unsigned int flags_value) { - const auto clicked = ImGui::CheckboxFlags(label, &flags, flags_value); - return std::make_tuple(clicked, flags); - }, - nb::arg("label"), - nb::arg("flags"), - nb::arg("flags_value")); - m.def( - "RadioButton", - [](const char* label, bool active) { return ImGui::RadioButton(label, active); }, - nb::arg("label"), - nb::arg("active")); - m.def( - "RadioButton", - [](const char* label, int v, int v_button) { - const auto clicked = ImGui::RadioButton(label, &v, v_button); - return std::make_tuple(clicked, v); - }, - nb::arg("label"), - nb::arg("v"), - nb::arg("v_button")); - m.def( - "ProgressBar", - [](float fraction, const Vec2T& size_arg) { - ImGui::ProgressBar(fraction, to_vec2(size_arg)); - }, - nb::arg("fraction"), - nb::arg("size_arg") = Vec2T(-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)); - }, - nb::arg("user_texture_id"), - nb::arg("image_size"), - nb::arg("uv0") = Vec2T(0.0f, 0.0f), - nb::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)); - }, - nb::arg("user_texture_id"), - nb::arg("image_size"), - nb::arg("uv0") = Vec2T(0.0f, 0.0f), - nb::arg("uv1") = Vec2T(1.0f, 1.0f), - nb::arg("bg_col") = Vec4T(0.0f, 0.0f, 0.0f, 0.0f), - nb::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)); - }, - nb::arg("str_id"), - nb::arg("user_texture_id"), - nb::arg("image_size"), - nb::arg("uv0") = Vec2T(0.0f, 0.0f), - nb::arg("uv1") = Vec2T(1.0f, 1.0f), - nb::arg("bg_col") = Vec4T(0.0f, 0.0f, 0.0f, 0.0f), - nb::arg("tint_col") = Vec4T(1.0f, 1.0f, 1.0f, 1.0f)); - - - // Widgets: Combo Box - m.def( - "BeginCombo", - [](const char* label, const char* preview_value, ImGuiComboFlags flags) { - return ImGui::BeginCombo(label, preview_value, flags); - }, - nb::arg("label"), - nb::arg("preview_value"), - nb::arg("flags") = 0); - m.def("EndCombo", []() { ImGui::EndCombo(); }); - m.def( - "Combo", - [](const char* label, - int current_item, - const std::vector& items, - int popup_max_height_in_items) { - const auto _items = convert_string_items(items); - const auto clicked = ImGui::Combo( - label, ¤t_item, _items.data(), _items.size(), popup_max_height_in_items); - return std::make_tuple(clicked, current_item); - }, - nb::arg("label"), - nb::arg("current_item"), - nb::arg("items"), - nb::arg("popup_max_height_in_items") = -1); - m.def( - "Combo", - [](const char* label, - int current_item, - const char* items_separated_by_zeros, - int popup_max_height_in_items) { - const auto clicked = ImGui::Combo( - label, ¤t_item, items_separated_by_zeros, popup_max_height_in_items); - return std::make_tuple(clicked, current_item); - }, - nb::arg("label"), - nb::arg("current_item"), - nb::arg("items_separated_by_zeros"), - nb::arg("popup_max_height_in_items") = -1); - - // Widgets: Drags - m.def( - "DragFloat", - [](const char* label, - float v, - float v_speed, - float v_min, - float v_max, - const char* format, - float power) { - auto clicked = ImGui::DragFloat(label, &v, v_speed, v_min, v_max, format, power); - return std::make_tuple(clicked, v); - }, - nb::arg("label"), - nb::arg("v"), - nb::arg("v_speed") = 1.0f, - nb::arg("v_min"), - nb::arg("v_max"), - nb::arg("format") = "%.3f", - nb::arg("power") = 1.0f); - m.def( - "DragFloat2", - [](const char* label, - std::array v, - float v_speed, - float v_min, - float v_max, - const char* format, - float power) { - auto clicked = - ImGui::DragFloat2(label, v.data(), v_speed, v_min, v_max, format, power); - return std::make_tuple(clicked, v); - }, - nb::arg("label"), - nb::arg("v"), - nb::arg("v_speed") = 1.0f, - nb::arg("v_min"), - nb::arg("v_max"), - nb::arg("format") = "%.3f", - nb::arg("power") = 1.0f); - m.def( - "DragFloat3", - [](const char* label, - std::array v, - float v_speed, - float v_min, - float v_max, - const char* format, - float power) { - auto clicked = - ImGui::DragFloat3(label, v.data(), v_speed, v_min, v_max, format, power); - return std::make_tuple(clicked, v); - }, - nb::arg("label"), - nb::arg("v"), - nb::arg("v_speed") = 1.0f, - nb::arg("v_min"), - nb::arg("v_max"), - nb::arg("format") = "%.3f", - nb::arg("power") = 1.0f); - m.def( - "DragFloat4", - [](const char* label, - std::array v, - float v_speed, - float v_min, - float v_max, - const char* format, - float power) { - auto clicked = - ImGui::DragFloat4(label, v.data(), v_speed, v_min, v_max, format, power); - return std::make_tuple(clicked, v); - }, - nb::arg("label"), - nb::arg("v"), - nb::arg("v_speed") = 1.0f, - nb::arg("v_min"), - nb::arg("v_max"), - nb::arg("format") = "%.3f", - nb::arg("power") = 1.0f); - m.def( - "DragFloatRange2", - [](const char* label, - std::array v_current_min, - std::array v_current_max, - float v_speed, - float v_min, - float v_max, - const char* format, - const char* format_max, - float power) { - auto clicked = ImGui::DragFloatRange2(label, - v_current_min.data(), - v_current_max.data(), - v_speed, - v_min, - v_max, - format, - format_max, - power); - return std::make_tuple(clicked, v_current_min, v_current_max); - }, - nb::arg("label"), - nb::arg("v_current_min"), - nb::arg("v_current_max"), - nb::arg("v_speed") = 1.0f, - nb::arg("v_min"), - nb::arg("v_max"), - nb::arg("format") = "%.3f", - nb::arg("format_max") = nullptr, - nb::arg("power") = 1.0f); - - m.def( - "DragInt", - [](const char* label, int v, float v_speed, int v_min, int v_max, const char* format) { - auto clicked = ImGui::DragInt(label, &v, v_speed, v_min, v_max, format); - return std::make_tuple(clicked, v); - }, - nb::arg("label"), - nb::arg("v"), - nb::arg("v_speed") = 1.0f, - nb::arg("v_min") = 0, - nb::arg("v_max") = 0, - nb::arg("format") = "%d"); - m.def( - "DragInt2", - [](const char* label, - std::array v, - float v_speed, - int v_min, - int v_max, - const char* format) { - auto clicked = ImGui::DragInt2(label, v.data(), v_speed, v_min, v_max, format); - return std::make_tuple(clicked, v); - }, - nb::arg("label"), - nb::arg("v"), - nb::arg("v_speed") = 1.0f, - nb::arg("v_min") = 0, - nb::arg("v_max") = 0, - nb::arg("format") = "%d"); - m.def( - "DragInt3", - [](const char* label, - std::array v, - float v_speed, - int v_min, - int v_max, - const char* format) { - auto clicked = ImGui::DragInt3(label, v.data(), v_speed, v_min, v_max, format); - return std::make_tuple(clicked, v); - }, - nb::arg("label"), - nb::arg("v"), - nb::arg("v_speed") = 1.0f, - nb::arg("v_min") = 0, - nb::arg("v_max") = 0, - nb::arg("format") = "%d"); - m.def( - "DragInt4", - [](const char* label, - std::array v, - float v_speed, - int v_min, - int v_max, - const char* format) { - auto clicked = ImGui::DragInt4(label, v.data(), v_speed, v_min, v_max, format); - return std::make_tuple(clicked, v); - }, - nb::arg("label"), - nb::arg("v"), - nb::arg("v_speed") = 1.0f, - nb::arg("v_min") = 0, - nb::arg("v_max") = 0, - nb::arg("format") = "%d"); - m.def( - "DragIntRange2", - [](const char* label, - std::array v_current_min, - std::array v_current_max, - float v_speed, - int v_min, - int v_max, - const char* format, - const char* format_max) { - auto clicked = ImGui::DragIntRange2(label, - v_current_min.data(), - v_current_max.data(), - v_speed, - v_min, - v_max, - format, - format_max); - return std::make_tuple(clicked, v_current_min, v_current_max); - }, - nb::arg("label"), - nb::arg("v_current_min"), - nb::arg("v_current_max"), - nb::arg("v_speed") = 1.0f, - nb::arg("v_min") = 0, - nb::arg("v_max") = 0, - nb::arg("format") = "%d", - nb::arg("format_max") = nullptr); - - // Widgets: Sliders - m.def( - "SliderFloat", - [](const char* label, float v, float v_min, float v_max, const char* format, float power) { - auto clicked = ImGui::SliderFloat(label, &v, v_min, v_max, format, power); - return std::make_tuple(clicked, v); - }, - nb::arg("label"), - nb::arg("v"), - nb::arg("v_min"), - nb::arg("v_max"), - nb::arg("format") = "%.3f", - nb::arg("power") = 1.0f); - m.def( - "SliderFloat2", - [](const char* label, - std::array v, - float v_min, - float v_max, - const char* format, - float power) { - auto clicked = ImGui::SliderFloat2(label, v.data(), v_min, v_max, format, power); - return std::make_tuple(clicked, v); - }, - nb::arg("label"), - nb::arg("v"), - nb::arg("v_min"), - nb::arg("v_max"), - nb::arg("format") = "%.3f", - nb::arg("power") = 1.0f); - m.def( - "SliderFloat3", - [](const char* label, - std::array v, - float v_min, - float v_max, - const char* format, - float power) { - auto clicked = ImGui::SliderFloat3(label, v.data(), v_min, v_max, format, power); - return std::make_tuple(clicked, v); - }, - nb::arg("label"), - nb::arg("v"), - nb::arg("v_min"), - nb::arg("v_max"), - nb::arg("format") = "%.3f", - nb::arg("power") = 1.0f); - m.def( - "SliderFloat4", - [](const char* label, - std::array v, - float v_min, - float v_max, - const char* format, - float power) { - auto clicked = ImGui::SliderFloat4(label, v.data(), v_min, v_max, format, power); - return std::make_tuple(clicked, v); - }, - nb::arg("label"), - nb::arg("v"), - nb::arg("v_min"), - nb::arg("v_max"), - nb::arg("format") = "%.3f", - nb::arg("power") = 1.0f); - - m.def( - "SliderAngle", - [](const char* label, - float v_rad, - float v_degrees_min, - float v_degrees_max, - const char* format) { - auto clicked = ImGui::SliderAngle(label, &v_rad, v_degrees_min, v_degrees_max, format); - return std::make_tuple(clicked, v_rad); - }, - nb::arg("label"), - nb::arg("v_rad"), - nb::arg("v_degrees_min") = -360.0f, - nb::arg("v_degrees_max") = +360.0f, - nb::arg("format") = "%.0f deg"); - - m.def( - "SliderInt", - [](const char* label, int v, int v_min, int v_max, const char* format) { - auto v_ = v; - auto clicked = ImGui::SliderInt(label, &v_, v_min, v_max, format); - return std::make_tuple(clicked, v_); - }, - nb::arg("label"), - nb::arg("v"), - nb::arg("v_min") = 0, - nb::arg("v_max") = 0, - nb::arg("format") = "%d"); - m.def( - "SliderInt2", - [](const char* label, - const std::array& v, - int v_min, - int v_max, - const char* format) { - auto v_ = v; - auto clicked = ImGui::SliderInt2(label, v_.data(), v_min, v_max, format); - return std::make_tuple(clicked, v_); - }, - nb::arg("label"), - nb::arg("v"), - nb::arg("v_min") = 0, - nb::arg("v_max") = 0, - nb::arg("format") = "%d"); - m.def( - "SliderInt3", - [](const char* label, - const std::array& v, - int v_min, - int v_max, - const char* format) { - auto v_ = v; - auto clicked = ImGui::SliderInt3(label, v_.data(), v_min, v_max, format); - return std::make_tuple(clicked, v_); - }, - nb::arg("label"), - nb::arg("v"), - nb::arg("v_min") = 0, - nb::arg("v_max") = 0, - nb::arg("format") = "%d"); - m.def( - "SliderInt4", - [](const char* label, - const std::array& v, - int v_min, - int v_max, - const char* format) { - auto v_ = v; - auto clicked = ImGui::SliderInt4(label, v_.data(), v_min, v_max, format); - return std::make_tuple(clicked, v_); - }, - nb::arg("label"), - nb::arg("v"), - nb::arg("v_min") = 0, - nb::arg("v_max") = 0, - nb::arg("format") = "%d"); - - // Widgets: Input with Keyboard - m.def( - "InputText", - [](const char* label, const std::string& buf, ImGuiInputTextFlags flags) { - IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0); - flags |= ImGuiInputTextFlags_CallbackResize; - - auto buf_ = buf; - InputTextCallback_UserData cb_user_data; - cb_user_data.str = &buf_; - cb_user_data.chain_callback = nullptr; - cb_user_data.chain_callback_user_data = nullptr; - const auto clicked = ImGui::InputText(label, - (char*)buf_.c_str(), - buf_.capacity() + 1, - flags, - input_text_callback, - &cb_user_data); - return std::make_tuple(clicked, buf_); - }, - nb::arg("label"), - nb::arg("buf"), - nb::arg("flags") = 0); - m.def( - "InputTextMultiline", - [](const char* label, - const std::string& buf, - const Vec2T& size, - ImGuiInputTextFlags flags) { - IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0); - flags |= ImGuiInputTextFlags_CallbackResize; - - auto buf_ = buf; - InputTextCallback_UserData cb_user_data; - cb_user_data.str = &buf_; - cb_user_data.chain_callback = nullptr; - cb_user_data.chain_callback_user_data = nullptr; - const auto clicked = ImGui::InputTextMultiline(label, - (char*)buf_.c_str(), - buf_.capacity() + 1, - to_vec2(size), - flags, - input_text_callback, - &cb_user_data); - return std::make_tuple(clicked, buf_); - }, - nb::arg("label"), - nb::arg("buf"), - nb::arg("size") = std::make_tuple(0.f, 0.f), - nb::arg("flags") = 0); - m.def( - "InputTextWithHint", - [](const char* label, const char* hint, const std::string& buf, ImGuiInputTextFlags flags) { - IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0); - flags |= ImGuiInputTextFlags_CallbackResize; - - auto buf_ = buf; - InputTextCallback_UserData cb_user_data; - cb_user_data.str = &buf_; - cb_user_data.chain_callback = nullptr; - cb_user_data.chain_callback_user_data = nullptr; - const auto clicked = ImGui::InputTextWithHint(label, - hint, - (char*)buf_.c_str(), - buf_.capacity() + 1, - flags, - input_text_callback, - &cb_user_data); - return std::make_tuple(clicked, buf_); - }, - nb::arg("label"), - nb::arg("hint"), - nb::arg("buf"), - nb::arg("flags") = 0); - m.def( - "InputFloat", - [](const char* label, - float v, - float step, - float step_fast, - const char* format, - ImGuiInputTextFlags flags) { - const auto clicked = ImGui::InputFloat(label, &v, step, step_fast, format, flags); - return std::make_tuple(clicked, v); - }, - nb::arg("label"), - nb::arg("v"), - nb::arg("step") = 0.f, - nb::arg("step_fast") = 0.f, - nb::arg("format") = "%.3f", - nb::arg("flags") = 0); - m.def( - "InputFloat2", - [](const char* label, - std::array v, - const char* format, - ImGuiInputTextFlags flags) { - const auto clicked = ImGui::InputFloat2(label, v.data(), format, flags); - return std::make_tuple(clicked, v); - }, - nb::arg("label"), - nb::arg("v"), - nb::arg("format") = "%.3f", - nb::arg("flags") = 0); - m.def( - "InputFloat3", - [](const char* label, - std::array v, - const char* format, - ImGuiInputTextFlags flags) { - const auto clicked = ImGui::InputFloat3(label, v.data(), format, flags); - return std::make_tuple(clicked, v); - }, - nb::arg("label"), - nb::arg("v"), - nb::arg("format") = "%.3f", - nb::arg("flags") = 0); - m.def( - "InputFloat4", - [](const char* label, - std::array v, - const char* format, - ImGuiInputTextFlags flags) { - const auto clicked = ImGui::InputFloat4(label, v.data(), format, flags); - return std::make_tuple(clicked, v); - }, - nb::arg("label"), - nb::arg("v"), - nb::arg("format") = "%.3f", - nb::arg("flags") = 0); - m.def( - "InputInt", - [](const char* label, int v, float step, float step_fast, ImGuiInputTextFlags flags) { - const auto clicked = ImGui::InputInt(label, &v, step, step_fast, flags); - return std::make_tuple(clicked, v); - }, - nb::arg("label"), - nb::arg("v"), - nb::arg("step") = 0.f, - nb::arg("step_fast") = 0.f, - nb::arg("flags") = 0); - m.def( - "InputInt2", - [](const char* label, std::array v, ImGuiInputTextFlags flags) { - const auto clicked = ImGui::InputInt2(label, v.data(), flags); - return std::make_tuple(clicked, v); - }, - nb::arg("label"), - nb::arg("v"), - nb::arg("flags") = 0); - m.def( - "InputInt3", - [](const char* label, std::array v, ImGuiInputTextFlags flags) { - auto v_ = v; - const auto clicked = ImGui::InputInt3(label, v.data(), flags); - return std::make_tuple(clicked, v); - }, - nb::arg("label"), - nb::arg("v"), - nb::arg("flags") = 0); - m.def( - "InputInt4", - [](const char* label, std::array v, ImGuiInputTextFlags flags) { - const auto clicked = ImGui::InputInt4(label, v.data(), flags); - return std::make_tuple(clicked, v); - }, - nb::arg("label"), - nb::arg("v"), - nb::arg("flags") = 0); - m.def( - "InputDouble", - [](const char* label, - double v, - double step, - double step_fast, - const char* format, - ImGuiInputTextFlags flags) { - const auto clicked = ImGui::InputDouble(label, &v, step, step_fast, format, flags); - return std::make_tuple(clicked, v); - }, - nb::arg("label"), - nb::arg("v"), - nb::arg("step") = 0.f, - nb::arg("step_fast") = 0.f, - nb::arg("format") = "%.6f", - nb::arg("flags") = 0); - - // Widgets: Color Editor/Picker - m.def( - "ColorEdit3", - [](const char* label, const std::array& col, ImGuiColorEditFlags flags) { - auto col_ = col; - const auto clicked = ImGui::ColorEdit3(label, col_.data(), flags); - return std::make_tuple(clicked, col_); - }, - nb::arg("label"), - nb::arg("def"), - nb::arg("flags") = 0); - m.def( - "ColorEdit4", - [](const char* label, const std::array& col, ImGuiColorEditFlags flags) { - auto col_ = col; - const auto clicked = ImGui::ColorEdit4(label, col_.data(), flags); - return std::make_tuple(clicked, col_); - }, - nb::arg("label"), - nb::arg("def"), - nb::arg("flags") = 0); - m.def( - "ColorPicker3", - [](const char* label, const std::array& col, ImGuiColorEditFlags flags) { - auto col_ = col; - const auto clicked = ImGui::ColorPicker3(label, col_.data(), flags); - return std::make_tuple(clicked, col_); - }, - nb::arg("label"), - nb::arg("def"), - nb::arg("flags") = 0); - m.def( - "ColorPicker4", - [](const char* label, const std::array& col, ImGuiColorEditFlags flags) { - auto col_ = col; - const auto clicked = ImGui::ColorPicker4(label, col_.data(), flags); - return std::make_tuple(clicked, col_); - }, - nb::arg("label"), - nb::arg("def"), - nb::arg("flags") = 0); - m.def( - "ColorButton", - [](const char* label, const Vec4T& col, ImGuiColorEditFlags flags, const Vec2T& size) { - auto col_ = col; - const auto clicked = ImGui::ColorButton(label, to_vec4(col), flags, to_vec2(size)); - return std::make_tuple(clicked, col_); - }, - nb::arg("label"), - nb::arg("def"), - nb::arg("flags") = 0, - nb::arg("size") = std::make_tuple(0.f, 0.f)); - m.def( - "SetColorEditOptions", - [](ImGuiColorEditFlags flags) { ImGui::SetColorEditOptions(flags); }, - nb::arg("flags")); - - // Widgets: Trees - m.def( - "TreeNode", [](const char* label) { return ImGui::TreeNode(label); }, nb::arg("label")); - m.def( - "TreeNodeEx", - [](const char* label, ImGuiTreeNodeFlags flags) { return ImGui::TreeNodeEx(label, flags); }, - nb::arg("label"), - nb::arg("flags") = 0); - m.def( - "TreePush", [](const char* str_id) { ImGui::TreePush(str_id); }, nb::arg("str_id")); - m.def("TreePop", []() { ImGui::TreePop(); }); - m.def("GetTreeNodeToLabelSpacing", []() { return ImGui::GetTreeNodeToLabelSpacing(); }); - m.def( - "CollapsingHeader", - [](const char* label, ImGuiTreeNodeFlags flags) { - return ImGui::CollapsingHeader(label, flags); - }, - nb::arg("label"), - nb::arg("flags") = 0); - m.def( - "CollapsingHeader", - [](const char* label, bool open, ImGuiTreeNodeFlags flags) { - const auto clicked = ImGui::CollapsingHeader(label, &open, flags); - return std::make_tuple(clicked, open); - }, - nb::arg("label"), - nb::arg("open"), - nb::arg("flags") = 0); - m.def( - "SetNextItemOpen", - [](bool is_open, ImGuiCond cond) { ImGui::SetNextItemOpen(is_open, cond); }, - nb::arg("is_open"), - nb::arg("cond") = 0); - - // Widgets: Selectables - m.def( - "Selectable", - [](const char* label, bool selected, ImGuiSelectableFlags flags, const Vec2T& size) { - const auto clicked = ImGui::Selectable(label, &selected, flags, to_vec2(size)); - return std::make_tuple(clicked, selected); - }, - nb::arg("label"), - nb::arg("selected") = false, - nb::arg("flags") = 0, - nb::arg("size") = std::make_tuple(0.f, 0.f)); - - // Widgets: List Boxes - m.def( - "BeginListBox", - [](const char* label, - const Vec2T& size - ) { - return ImGui::BeginListBox(label, to_vec2(size)); - }, - nb::arg("label"), - nb::arg("size") = Vec2T(0,0)); - m.def( - "EndListBox", - []() { - ImGui::EndListBox(); - }); - m.def( - "ListBox", - [](const char* label, - int current_item, - const std::vector& items, - int height_in_items) { - const auto _items = convert_string_items(items); - const auto clicked = - ImGui::ListBox(label, ¤t_item, _items.data(), _items.size(), height_in_items); - return std::make_tuple(clicked, current_item); - }, - nb::arg("label"), - nb::arg("current_item"), - nb::arg("items"), - nb::arg("height_in_items") = -1); - - // Widgets: Data Plotting - m.def( - "PlotLines", - []( - const char *label, - const std::vector& values, - int values_offset, - const char *overlay_text, - float scale_min, - float scale_max, - const Vec2T& graph_size - ) { - ImGui::PlotLines(label, values.data(), values.size(), values_offset, overlay_text, scale_min, scale_max, to_vec2(graph_size)); - }, - nb::arg("label"), - nb::arg("values"), - nb::arg("values_offset") = 0, - nb::arg("overlay_text") = nullptr, - nb::arg("scale_min") = FLT_MAX, - nb::arg("scale_max") = FLT_MAX, - nb::arg("graph_size") = std::make_tuple(0.f, 0.f) - ); - m.def( - "PlotHistogram", - []( - const char *label, - const std::vector& values, - int values_offset, - const char *overlay_text, - float scale_min, - float scale_max, - const Vec2T& graph_size - ) { - ImGui::PlotHistogram(label, values.data(), values.size(), values_offset, overlay_text, scale_min, scale_max, to_vec2(graph_size)); - }, - nb::arg("label"), - nb::arg("values"), - nb::arg("values_offset") = 0, - nb::arg("overlay_text") = nullptr, - nb::arg("scale_min") = FLT_MAX, - nb::arg("scale_max") = FLT_MAX, - nb::arg("graph_size") = std::make_tuple(0.f, 0.f) - ); - - // Widgets: Value() Helpers. - m.def("Value", [](const char *prefix, bool b){ ImGui::Value(prefix, b); }, nb::arg("prefix"), nb::arg("b")); - m.def("Value", [](const char *prefix, int v){ ImGui::Value(prefix, v); }, nb::arg("prefix"), nb::arg("v")); - m.def( - "Value", - [](const char *prefix, float v, const char * float_format) { - ImGui::Value(prefix, v, float_format); - }, - nb::arg("prefix"), - nb::arg("b"), - nb::arg("float_format") = nullptr - ); - - // Widgets: Menus - m.def("BeginMenuBar", []() { return ImGui::BeginMenuBar(); }); - m.def("EndMenuBar", []() { ImGui::EndMenuBar(); }); - m.def("BeginMainMenuBar", []() { return ImGui::BeginMainMenuBar(); }); - m.def("EndMainMenuBar", []() { return ImGui::EndMainMenuBar(); }); - m.def( - "BeginMenu", - [](const char* label, bool enabled) { return ImGui::BeginMenu(label, enabled); }, - nb::arg("label"), - nb::arg("enabled") = true); - m.def("EndMenu", []() { ImGui::EndMenu(); }); - m.def( - "MenuItem", - [](const char* label, const char* shortcut, bool selected, bool enabled) { - return ImGui::MenuItem(label, shortcut, selected, enabled); - }, - nb::arg("label"), - nb::arg("shortcut") = nullptr, - nb::arg("selected") = false, - nb::arg("enabled") = true); - - // Tooltips - m.def("BeginTooltip", []() { ImGui::BeginTooltip(); }); - m.def("EndTooltip", []() { ImGui::EndTooltip(); }); - m.def("SetTooltip", [](const char *value) { ImGui::SetTooltip("%s", value); }); - - // Popups, Modals - m.def( - "OpenPopup", [](const char* str_id) { ImGui::OpenPopup(str_id); }, nb::arg("str_id")); - m.def( - "BeginPopup", - [](const char* str_id, ImGuiWindowFlags flags) { return ImGui::BeginPopup(str_id, flags); }, - nb::arg("str_id"), - nb::arg("flags") = 0); - m.def( - "BeginPopupContextItem", - [](const char* str_id, ImGuiPopupFlags popup_flags) { - return ImGui::BeginPopupContextItem(str_id, popup_flags); - }, - nb::arg("str_id"), - nb::arg("popup_flags") = 1); - m.def( - "BeginPopupContextWindow", - [](const char* str_id, ImGuiPopupFlags popup_flags) { - return ImGui::BeginPopupContextWindow(str_id, popup_flags); - }, - nb::arg("str_id"), - nb::arg("popup_flags") = 1); - m.def( - "BeginPopupContextVoid", - [](const char* str_id, ImGuiPopupFlags popup_flags) { - return ImGui::BeginPopupContextVoid(str_id, popup_flags); - }, - nb::arg("str_id"), - nb::arg("popup_flags") = 1); - m.def( - "BeginPopupModal", - [](const char* str_id, bool open, ImGuiWindowFlags flags) { - auto open_ = open; - return ImGui::BeginPopupModal(str_id, &open_, flags); - }, - nb::arg("str_id"), - nb::arg("open"), - nb::arg("flags") = 0); - m.def("EndPopup", []() { ImGui::EndPopup(); }); - m.def( - "OpenPopupOnItemClick", - [](const char* str_id, ImGuiWindowFlags popup_flags) { - return ImGui::OpenPopupOnItemClick(str_id, popup_flags); - }, - nb::arg("str_id"), - nb::arg("popup_flags") = 1); - m.def( - "IsPopupOpen", - [](const char* str_id, ImGuiPopupFlags popup_flags) { return ImGui::IsPopupOpen(str_id, popup_flags); }, - nb::arg("str_id"), - nb::arg("flags") = 0); - m.def("CloseCurrentPopup", []() { ImGui::CloseCurrentPopup(); }); - - // Tables - m.def( - "BeginTable", - [](const char*str_id, int columns, ImGuiTableFlags flags, Vec2T size, float innerwidth) -> bool { - return ImGui::BeginTable(str_id, columns, flags, to_vec2(size), innerwidth); - }, - nb::arg("str"), - nb::arg("columns"), - nb::arg("flags") = 0, - nb::arg("size") = std::make_tuple(0.f, 0.f), - nb::arg("inner_width") = 0.f - ); - m.def( "EndTable", []() { ImGui::EndTable(); } ); - m.def( - "TableNextRow", - [](ImGuiTableRowFlags flags, float min_row_height) { - ImGui::TableNextRow(flags, min_row_height); - }, - nb::arg("flags") = 0, - nb::arg("min_row_height") = 0.f - ); - m.def( - "TableNextColumn", - []() -> bool { - return ImGui::TableNextColumn(); - } - ); - m.def( - "TableSetColumnIndex", - [](int column_n) -> bool { - return ImGui::TableSetColumnIndex(column_n); - }, - nb::arg("column_n") - ); - - // Table headers and columns - m.def( - "TableSetupColumn", - [](const char* label, ImGuiTableColumnFlags flags, float init_width_or_height, ImGuiID user_id) { - ImGui::TableSetupColumn(label, flags, init_width_or_height, user_id); - }, - nb::arg("label"), - nb::arg("flags") = 0, - nb::arg("init_width_or_height") = 0.f, - nb::arg("user_id") = 0u - ); - m.def( - "TableSetupScrollFreeze", - [](int cols, int rows) { - ImGui::TableSetupScrollFreeze(cols, rows); - }, - nb::arg("cols"), - nb::arg("rows") - ); - m.def( - "TableHeader", - [](const char* label) { - ImGui::TableHeader(label); - }, - nb::arg("label") - ); - m.def("TableHeadersRow", []() { ImGui::TableHeadersRow(); }); - m.def("TableAngledHeadersRow", []() { ImGui::TableAngledHeadersRow(); }); - - // Table miscellaneous functions - - // warning! this function returns a pointer which is only valid for a short time, within the same frame and before next call to BeginTable() (see imgui docs) - // you will get undefined behavior if you try to use it later - m.def("TableGetSortSpecs", []() -> ImGuiTableSortSpecs* { return ImGui::TableGetSortSpecs(); }, nb::rv_policy::reference); - m.def("TableGetColumnCount", []() -> int { return ImGui::TableGetColumnCount(); }); - m.def("TableGetColumnIndex", []() -> int { return ImGui::TableGetColumnIndex(); }); - m.def("TableGetRowIndex", []() -> int { return ImGui::TableGetRowIndex(); }); - m.def( - "TableGetColumnName", - [](int column_n) { return nb::str(ImGui::TableGetColumnName(column_n)); }, - nb::arg("column_n") = -1 - ); - /* TableGetColumnFlags not included for the same reasons. */ - m.def( - "TableSetColumnEnabled", - [](int column_n, bool enable) { return ImGui::TableSetColumnEnabled(column_n, enable); }, - nb::arg("column_n"), - nb::arg("v") - ); - m.def("TableGetHoveredColumn", []() -> int { return ImGui::TableGetHoveredColumn(); }); - m.def( - "TableSetBgColor", - [](ImGuiTableBgTarget target, ImU32 color, int column_n) { - return ImGui::TableSetBgColor(target, color, column_n); - }, - nb::arg("target"), - nb::arg("color"), - nb::arg("column_n") = -1 - ); - - // Columns - m.def( - "Columns", - [](int count, const char *id, bool border) { - ImGui::Columns(count, id, border); - }, - nb::arg("count") = 1, - nb::arg("id") = nullptr, - nb::arg("border") = true - ); - m.def("NextColumn", []() { ImGui::NextColumn(); }); - m.def("GetColumnIndex", []() { return ImGui::GetColumnIndex(); }); - m.def( - "GetColumnWidth", - [](int column_index) { - return ImGui::GetColumnWidth(column_index); - }, - nb::arg("column_index") = -1 - ); - m.def( - "SetColumnWidth", - [](int column_index, float width) { - ImGui::SetColumnWidth(column_index, width); - }, - nb::arg("column_index"), - nb::arg("width") - ); - m.def( - "GetColumnOffset", - [](int column_index) { - return ImGui::GetColumnOffset(column_index); - }, - nb::arg("column_index") = -1 - ); - m.def( - "SetColumnOffset", - [](int column_index, float width) { - ImGui::SetColumnOffset(column_index, width); - }, - nb::arg("column_index"), - nb::arg("offset_x") - ); - m.def("GetColumnsCount", []() { return ImGui::GetColumnsCount(); }); - - // Tab Bars, Tabs - m.def( - "BeginTabBar", - [](const char *str_id, ImGuiTabBarFlags flags) { - return ImGui::BeginTabBar(str_id, flags); - }, - nb::arg("str_id"), - nb::arg("flags") = 0 - ); - m.def("EndTabBar", []() { ImGui::EndTabBar(); }); - m.def( - "BeginTabItem", - [](const char *str, bool open, ImGuiTabBarFlags flags) { - const auto clicked = ImGui::BeginTabItem(str, &open, flags); - return std::make_tuple(clicked, open); - }, - nb::arg("str"), - nb::arg("open"), - nb::arg("flags") = 0 - ); - m.def("EndTabItem", []() { ImGui::EndTabItem(); }); - m.def( - "SetTabItemClosed", - [](const char *tab_or_docked_window_label) { - ImGui::SetTabItemClosed(tab_or_docked_window_label); - }, - nb::arg("tab_or_docked_window_label") - ); - - // Logging/Capture - m.def( - "LogToTTY", - [](int auto_open_depth) { - ImGui::LogToTTY(auto_open_depth); - }, - nb::arg("auto_open_depth") = -1 - ); - m.def( - "LogToFile", - [](int auto_open_depth, const char *filename) { - ImGui::LogToFile(auto_open_depth, filename); - }, - nb::arg("auto_open_depth") = -1, - nb::arg("filename") = nullptr - ); - m.def( - "LogToClipboard", - [](int auto_open_depth) { - ImGui::LogToClipboard(auto_open_depth); - }, - nb::arg("auto_open_depth") = -1 - ); - m.def("LogFinish", []() { ImGui::LogFinish(); }); - m.def("LogButtons", []() { ImGui::LogButtons(); }); - - // Disabling - m.def("BeginDisabled", - [](bool disable) { - return ImGui::BeginDisabled(disable); - }, nb::arg("disable")); - m.def("EndDisabled", []() { ImGui::EndDisabled(); }); - - // Clipping - m.def( - "PushClipRect", - []( - const Vec2T& clip_rect_min, - const Vec2T& clip_rect_max, - bool intersect_with_current_clip_rect - ) { - ImGui::PushClipRect(to_vec2(clip_rect_min), to_vec2(clip_rect_max), intersect_with_current_clip_rect); - }, - nb::arg("clip_rect_min"), - nb::arg("clip_rect_max"), - nb::arg("intersect_with_current_clip_rect") - ); - m.def("PopClipRect", []() { ImGui::PopClipRect(); }); - - // Focus, Activation - m.def("SetItemDefaultFocus", []() { ImGui::SetItemDefaultFocus(); }); - m.def( - "SetKeyboardFocusHere", - [](int offset) { ImGui::SetKeyboardFocusHere(offset); }, - nb::arg("offset") - ); - - // Item/Widgets Utilities - m.def( - "IsItemHovered", - [](ImGuiHoveredFlags flags) { return ImGui::IsItemHovered(flags); }, - nb::arg("flags") = 0); - m.def("IsItemActive", []() { return ImGui::IsItemActive(); }); - m.def("IsItemFocused", []() { return ImGui::IsItemFocused(); }); - m.def( - "IsItemClicked", - [](ImGuiMouseButton mouse_button) { return ImGui::IsItemClicked(mouse_button); }, - nb::arg("mouse_button") = 0); - m.def("IsItemVisible", []() { return ImGui::IsItemVisible(); }); - m.def("IsItemEdited", []() { return ImGui::IsItemEdited(); }); - m.def("IsItemActivated", []() { return ImGui::IsItemActivated(); }); - m.def("IsItemDeactivated", []() { return ImGui::IsItemDeactivated(); }); - m.def("IsItemDeactivatedAfterEdit", []() { return ImGui::IsItemDeactivatedAfterEdit(); }); - m.def("IsItemToggledOpen", []() { return ImGui::IsItemToggledOpen(); }); - m.def("IsAnyItemHovered", []() { return ImGui::IsAnyItemHovered(); }); - m.def("IsAnyItemActive", []() { return ImGui::IsAnyItemActive(); }); - m.def("IsAnyItemFocused", []() { return ImGui::IsAnyItemFocused(); }); - m.def("GetItemRectMin", []() { return from_vec2(ImGui::GetItemRectMin()); }); - m.def("GetItemRectMax", []() { return from_vec2(ImGui::GetItemRectMax()); }); - m.def("GetItemRectSize", []() { return from_vec2(ImGui::GetItemRectSize()); }); - m.def("SetItemAllowOverlap", []() { ImGui::SetItemAllowOverlap(); }); - - // Background/Foreground Draw Lists - m.def("GetBackgroundDrawList", &ImGui::GetBackgroundDrawList, nb::rv_policy::reference); - m.def("GetForegroundDrawList", &ImGui::GetForegroundDrawList, nb::rv_policy::reference); - - // Miscellaneous Utilities - m.def( - "IsRectVisible", - [](const Vec2T& size) { - return ImGui::IsRectVisible(to_vec2(size)); - }, - nb::arg("size") - ); - m.def( - "IsRectVisible", - [](const Vec2T& rect_min, const Vec2T& rect_max) { - return ImGui::IsRectVisible(to_vec2(rect_min), to_vec2(rect_max)); - }, - nb::arg("rect_min"), - nb::arg("rect_max") - ); - m.def("GetTime", []() { return ImGui::GetTime(); }); - m.def("GetFrameCount", []() { return ImGui::GetFrameCount(); }); - m.def("GetStyleColorName", [](ImGuiCol idx) { return ImGui::GetStyleColorName(idx); }); - m.def( - "BeginChildFrame", - [](ImGuiID id, const Vec2T& size, ImGuiWindowFlags flags) { - return ImGui::BeginChildFrame(id, to_vec2(size), flags); - }, - nb::arg("id"), - nb::arg("size"), - nb::arg("flags") = 0 - ); - m.def("EndChildFrame", []() { ImGui::EndChildFrame(); }); - - // Text Utilities - m.def( - "CalcTextSize", - [](const char *text, const char *text_end, bool hide_text_after_double_hash, float wrap_width) { - return from_vec2(ImGui::CalcTextSize(text, text_end, hide_text_after_double_hash, wrap_width)); - }, - nb::arg("text"), - nb::arg("text_end") = nullptr, - nb::arg("hide_text_after_double_hash") = false, - nb::arg("wrap_width") = -1.f - ); - - // Utilities: Mouse - m.def("IsMouseDown", [](ImGuiMouseButton button) { return ImGui::IsMouseDown(button); }, nb::arg("button")); - m.def( - "IsMouseClicked", - [](ImGuiMouseButton button, bool repeat) { return ImGui::IsMouseClicked(button, repeat); }, - nb::arg("button"), - nb::arg("repeat") = false - ); - m.def("IsMouseReleased", [](ImGuiMouseButton button) { return ImGui::IsMouseReleased(button); }, nb::arg("button")); - m.def("IsMouseDoubleClicked", [](ImGuiMouseButton button) { return ImGui::IsMouseDoubleClicked(button); }, nb::arg("button")); - m.def( - "IsMouseHoveringRect", - [](const Vec2T& r_min, const Vec2T& r_max, bool clip) { - return ImGui::IsMouseHoveringRect(to_vec2(r_min), to_vec2(r_max), clip); - }, - nb::arg("r_min"), - nb::arg("r_max"), - nb::arg("clip") = true - ); - m.def("IsAnyMouseDown", []() { return ImGui::IsAnyMouseDown(); }); - m.def("GetMousePos", []() { return from_vec2(ImGui::GetMousePos()); }); - m.def("GetMousePosOnOpeningCurrentPopup", []() { return from_vec2(ImGui::GetMousePosOnOpeningCurrentPopup()); }); - m.def( - "IsMouseDragging", - [](ImGuiMouseButton button, float lock_threshold) { return ImGui::IsMouseDragging(button, lock_threshold); }, - nb::arg("button"), - nb::arg("lock_threshold") = -1.f - ); - m.def("ResetMouseDragDelta", [](ImGuiMouseButton button) { ImGui::ResetMouseDragDelta(button); }, nb::arg("button")); - m.def("GetMouseCursor", []() { return ImGui::GetMouseCursor(); }); - m.def("SetMouseCursor", [](ImGuiMouseCursor cursor_type) { ImGui::SetMouseCursor(cursor_type); }, nb::arg("cursor_type")); - m.def("SetNextFrameWantCaptureMouse", [](bool want_capture_mouse) { ImGui::SetNextFrameWantCaptureMouse(want_capture_mouse); }, nb::arg("want_capture_mouse")); - - // Inputs Utilities: Keyboard - m.def("IsKeyDown", [](ImGuiKey user_key_index) { return ImGui::IsKeyDown(user_key_index); }, nb::arg("user_key_index")); - m.def("IsKeyPressed", [](ImGuiKey user_key_index, bool repeat) { return ImGui::IsKeyPressed(user_key_index, repeat); }, nb::arg("user_key_index"), nb::arg("repeat")=true); - m.def("IsKeyReleased", [](ImGuiKey user_key_index) { return ImGui::IsKeyReleased(user_key_index); }, nb::arg("user_key_index")); - m.def( - "GetKeyPressedAmount", - [](ImGuiKey key_index, float repeat_delay, float rate) { - return ImGui::GetKeyPressedAmount(key_index, repeat_delay, rate); - }, - nb::arg("key_index"), - nb::arg("repeat_delay"), - nb::arg("rate") - ); - m.def( - "SetNextFrameWantCaptureKeyboard", - [](bool want_capture_keyboard) { - ImGui::SetNextFrameWantCaptureKeyboard(want_capture_keyboard); - }, - nb::arg("want_capture_keyboard") = true - ); - - // Clipboard Utilities - m.def("GetClipboardText", []() { return ImGui::GetClipboardText(); }); - m.def("SetClipboardText", [](const char *text) { ImGui::SetClipboardText(text); }, nb::arg("text")); - - // Settings/.Ini Utilities - m.def("LoadIniSettingsFromDisk", [](const char *ini_filename) { ImGui::LoadIniSettingsFromDisk(ini_filename); }, nb::arg("ini_filename")); - m.def("LoadIniSettingsFromMemory", [](const char *ini_data) { ImGui::LoadIniSettingsFromMemory(ini_data); }, nb::arg("ini_data")); - m.def("SaveIniSettingsToDisk", [](const char *ini_filename) { ImGui::SaveIniSettingsToDisk(ini_filename); }, nb::arg("ini_filename")); - m.def("SaveIniSettingsToMemory", []() { return ImGui::SaveIniSettingsToMemory(); }); - - // Draw Commands - nb::class_(m, "ImDrawList") - - // Clip Rect - - .def( - "PushClipRect", - [](ImDrawList& self, const Vec2T& clip_rect_min, const Vec2T& clip_rect_max, bool intersect_with_current_clip_rect) { - self.PushClipRect(to_vec2(clip_rect_min), to_vec2(clip_rect_max), intersect_with_current_clip_rect); - }, - nb::arg("clip_rect_min"), - nb::arg("clip_rect_max"), - nb::arg("intersect_with_current_clip_rect") = false - ) - .def("PushClipRectFullScreen", &ImDrawList::PushClipRectFullScreen) - .def("PopClipRect", &ImDrawList::PopClipRect) - .def("GetClipRectMin", [](ImDrawList& self) { return from_vec2(self.GetClipRectMin()); }) - .def("GetClipRectMax", [](ImDrawList& self) { return from_vec2(self.GetClipRectMax()); }) - - // Primitives - - .def( - "AddLine", - [](ImDrawList& draw_list, const Vec2T& p1, const Vec2T& p2, ImU32 col, float thickness) { - draw_list.AddLine(to_vec2(p1), to_vec2(p2), col, thickness); - }, - nb::arg("p1"), - nb::arg("p2"), - nb::arg("col"), - nb::arg("thickness") = 1.0f - ) - .def( - "AddRect", - [](ImDrawList& self, const Vec2T& p_min, const Vec2T& p_max, ImU32 col, float rounding, ImDrawFlags flags, float thickness) { - self.AddRect(to_vec2(p_min), to_vec2(p_max), col, rounding, flags, thickness); - }, - nb::arg("p_min"), - nb::arg("p_max"), - nb::arg("col"), - nb::arg("rounding") = 0.0f, - nb::arg("flags") = 0, - nb::arg("thickness") = 1.0f - ) - .def( - "AddRectFilled", - [](ImDrawList& self, const Vec2T& p_min, const Vec2T& p_max, ImU32 col, float rounding, ImDrawFlags flags) { - self.AddRectFilled(to_vec2(p_min), to_vec2(p_max), col, rounding, flags); - }, - nb::arg("p_min"), - nb::arg("p_max"), - nb::arg("col"), - nb::arg("rounding") = 0.0f, - nb::arg("flags") = 0 - ) - .def( - "AddRectFilledMultiColor", - [](ImDrawList& self, const Vec2T& p_min, const Vec2T& p_max, ImU32 col_upr_left, ImU32 col_upr_right, ImU32 col_bot_right, ImU32 col_bot_left) { - self.AddRectFilledMultiColor(to_vec2(p_min), to_vec2(p_max), col_upr_left, col_upr_right, col_bot_right, col_bot_left); - }, - nb::arg("p_min"), - nb::arg("p_max"), - nb::arg("col_upr_left"), - nb::arg("col_upr_right"), - nb::arg("col_bot_right"), - nb::arg("col_bot_left") - ) - .def( - "AddQuad", - [](ImDrawList& self, const Vec2T& p1, const Vec2T& p2, const Vec2T& p3, const Vec2T& p4, ImU32 col, float thickness) { - self.AddQuad(to_vec2(p1), to_vec2(p2), to_vec2(p3), to_vec2(p4), col, thickness); - }, - nb::arg("p1"), - nb::arg("p2"), - nb::arg("p3"), - nb::arg("p4"), - nb::arg("col"), - nb::arg("thickness") = 1.0f - ) - .def( - "AddQuadFilled", - [](ImDrawList& self, const Vec2T& p1, const Vec2T& p2, const Vec2T& p3, const Vec2T& p4, ImU32 col) { - self.AddQuadFilled(to_vec2(p1), to_vec2(p2), to_vec2(p3), to_vec2(p4), col); - }, - nb::arg("p1"), - nb::arg("p2"), - nb::arg("p3"), - nb::arg("p4"), - nb::arg("col") - ) - .def( - "AddTriangle", - [](ImDrawList& self, const Vec2T& p1, const Vec2T& p2, const Vec2T& p3, ImU32 col, float thickness) { - self.AddTriangle(to_vec2(p1), to_vec2(p2), to_vec2(p3), col, thickness); - }, - nb::arg("p1"), - nb::arg("p2"), - nb::arg("p3"), - nb::arg("col"), - nb::arg("thickness") = 1.0f - ) - .def( - "AddTriangleFilled", - [](ImDrawList& self, const Vec2T& p1, const Vec2T& p2, const Vec2T& p3, ImU32 col) { - self.AddTriangleFilled(to_vec2(p1), to_vec2(p2), to_vec2(p3), col); - }, - nb::arg("p1"), - nb::arg("p2"), - nb::arg("p3"), - nb::arg("col") - ) - .def( - "AddCircle", - [](ImDrawList& self, const Vec2T& center, const float radius, ImU32 col, int num_segments, float thickness) { - self.AddCircle(to_vec2(center), radius, col, num_segments, thickness); - }, - nb::arg("center"), - nb::arg("radius"), - nb::arg("col"), - nb::arg("num_segments") = 0, - nb::arg("thickness") = 1.0f - ) - .def( - "AddCircleFilled", - [](ImDrawList& self, const Vec2T& center, const float radius, ImU32 col, int num_segments) { - self.AddCircleFilled(to_vec2(center), radius, col, num_segments); - }, - nb::arg("center"), - nb::arg("radius"), - nb::arg("col"), - nb::arg("num_segments") = 0 - ) - .def( - "AddNgon", - [](ImDrawList& self, const Vec2T& center, const float radius, ImU32 col, int num_segments, float thickness) { - self.AddNgon(to_vec2(center), radius, col, num_segments, thickness); - }, - nb::arg("center"), - nb::arg("radius"), - nb::arg("col"), - nb::arg("num_segments") = 0, - nb::arg("thickness") = 1.0f - ) - .def( - "AddNgonFilled", - [](ImDrawList& self, const Vec2T& center, const float radius, ImU32 col, int num_segments) { - self.AddNgonFilled(to_vec2(center), radius, col, num_segments); - }, - nb::arg("center"), - nb::arg("radius"), - nb::arg("col"), - nb::arg("num_segments") = 0 - ) - .def( - "AddText", - [](ImDrawList& self, const Vec2T& pos, ImU32 col, const char* text_begin, const char* text_end) { - self.AddText(to_vec2(pos), col, text_begin, text_end); - }, - nb::arg("pos"), - nb::arg("col"), - nb::arg("text_begin"), - nb::arg("text_end") = nullptr - ) - .def( - "AddText", - [](ImDrawList& self, ImFont* font, float font_size, const Vec2T& pos, ImU32 col, const char* text_begin, const char* text_end, float wrap_width) { - self.AddText(font, font_size, to_vec2(pos), col, text_begin, text_end, wrap_width); - }, - nb::arg("font"), - nb::arg("font_size"), - nb::arg("pos"), - nb::arg("col"), - nb::arg("text_begin"), - nb::arg("text_end") = nullptr, - nb::arg("wrap_width") = 0.0f - ) - .def( - "AddPolyline", - [](ImDrawList& self, const std::vector& points, int num_points, ImU32 col, ImDrawFlags flags, float thickness) { - std::vector points_vec2(points.size()); - for (int i = 0; i < points.size(); i++) { - points_vec2[i] = to_vec2(points[i]); - } - self.AddPolyline(points_vec2.data(), num_points, col, flags, thickness); - }, - nb::arg("points"), - nb::arg("num_points"), - nb::arg("col"), - nb::arg("flags"), - nb::arg("thickness") - ) - .def( - "AddConvexPolyFilled", - [](ImDrawList& self, const std::vector& points, int num_points, ImU32 col) { - std::vector points_vec2(points.size()); - for (int i = 0; i < points.size(); i++) { - points_vec2[i] = to_vec2(points[i]); - } - self.AddConvexPolyFilled(points_vec2.data(), num_points, col); - }, - nb::arg("points"), - nb::arg("num_points"), - nb::arg("col") - ) - .def( - "AddBezierCubic", - [](ImDrawList& self, const Vec2T& p1, const Vec2T& p2, const Vec2T& p3, const Vec2T& p4, ImU32 col, float thickness, int num_segments = 0) { - self.AddBezierCubic(to_vec2(p1), to_vec2(p2), to_vec2(p3), to_vec2(p4), col, thickness, num_segments); - }, - nb::arg("p1"), - nb::arg("p2"), - nb::arg("p3"), - nb::arg("p4"), - nb::arg("col"), - nb::arg("thickness"), - nb::arg("num_segments") = 0 - ) - .def( - "AddBezierQuadratic", - [](ImDrawList& self, const Vec2T& p1, const Vec2T& p2, const Vec2T& p3, ImU32 col, float thickness, int num_segments = 0) { - self.AddBezierQuadratic(to_vec2(p1), to_vec2(p2), to_vec2(p3), col, thickness, num_segments); - }, - nb::arg("p1"), - nb::arg("p2"), - nb::arg("p3"), - nb::arg("col"), - nb::arg("thickness"), - nb::arg("num_segments") = 0 - ) - - // General Polygon - - .def( - "AddPolyline", - [](ImDrawList& self, const std::vector& points, int num_points, ImU32 col, ImDrawFlags flags, float thickness) { - std::vector points_vec2(points.size()); - for (int i = 0; i < points.size(); i++) { - points_vec2[i] = to_vec2(points[i]); - } - self.AddPolyline(points_vec2.data(), num_points, col, flags, thickness); - }, - nb::arg("points"), - nb::arg("num_points"), - nb::arg("col"), - nb::arg("flags"), - nb::arg("thickness") - ) - .def( - "AddConvexPolyFilled", - [](ImDrawList& self, const std::vector& points, int num_points, ImU32 col) { - std::vector points_vec2(points.size()); - for (int i = 0; i < points.size(); i++) { - points_vec2[i] = to_vec2(points[i]); - } - self.AddConvexPolyFilled(points_vec2.data(), num_points, col); - }, - nb::arg("points"), - nb::arg("num_points"), - nb::arg("col") - ) - .def( - "AddConcavePolyFilled", - [](ImDrawList& self, const std::vector& points, int num_points, ImU32 col) { - std::vector points_vec2(points.size()); - for (int i = 0; i < points.size(); i++) { - points_vec2[i] = to_vec2(points[i]); - } - self.AddConcavePolyFilled(points_vec2.data(), num_points, col); - }, - nb::arg("points"), - nb::arg("num_points"), - nb::arg("col") - ) - - ; - - - // Macros etc - m.def("IM_COL32", [](uint8_t R, uint8_t G, uint8_t B, uint8_t A) { return IM_COL32(R,G,B,A); }); -} -// clang-format on - -void bind_imgui_enums(nb::module_& m) { - - nb::enum_(m, "ImGuiDir"); - nb::enum_(m, "ImGuiMouseSource"); - nb::enum_(m, "ImGuiSortDirection"); - - m.attr("ImGuiWindowFlags_None") = static_cast(ImGuiWindowFlags_None); - m.attr("ImGuiWindowFlags_NoTitleBar") = static_cast(ImGuiWindowFlags_NoTitleBar); - m.attr("ImGuiWindowFlags_NoResize") = static_cast(ImGuiWindowFlags_NoResize); - m.attr("ImGuiWindowFlags_NoMove") = static_cast(ImGuiWindowFlags_NoMove); - m.attr("ImGuiWindowFlags_NoScrollbar") = static_cast(ImGuiWindowFlags_NoScrollbar); - m.attr("ImGuiWindowFlags_NoScrollWithMouse") = static_cast(ImGuiWindowFlags_NoScrollWithMouse); - m.attr("ImGuiWindowFlags_NoCollapse") = static_cast(ImGuiWindowFlags_NoCollapse); - m.attr("ImGuiWindowFlags_AlwaysAutoResize") = static_cast(ImGuiWindowFlags_AlwaysAutoResize); - m.attr("ImGuiWindowFlags_NoBackground") = static_cast(ImGuiWindowFlags_NoBackground); - m.attr("ImGuiWindowFlags_NoSavedSettings") = static_cast(ImGuiWindowFlags_NoSavedSettings); - m.attr("ImGuiWindowFlags_NoMouseInputs") = static_cast(ImGuiWindowFlags_NoMouseInputs); - m.attr("ImGuiWindowFlags_MenuBar") = static_cast(ImGuiWindowFlags_MenuBar); - m.attr("ImGuiWindowFlags_HorizontalScrollbar") = static_cast(ImGuiWindowFlags_HorizontalScrollbar); - m.attr("ImGuiWindowFlags_NoFocusOnAppearing") = static_cast(ImGuiWindowFlags_NoFocusOnAppearing); - m.attr("ImGuiWindowFlags_NoBringToFrontOnFocus") = static_cast(ImGuiWindowFlags_NoBringToFrontOnFocus); - m.attr("ImGuiWindowFlags_AlwaysVerticalScrollbar") = static_cast(ImGuiWindowFlags_AlwaysVerticalScrollbar); - m.attr("ImGuiWindowFlags_AlwaysHorizontalScrollbar") = static_cast(ImGuiWindowFlags_AlwaysHorizontalScrollbar); - m.attr("ImGuiWindowFlags_AlwaysUseWindowPadding") = static_cast(ImGuiWindowFlags_AlwaysUseWindowPadding); - m.attr("ImGuiWindowFlags_NoNavInputs") = static_cast(ImGuiWindowFlags_NoNavInputs); - m.attr("ImGuiWindowFlags_NoNavFocus") = static_cast(ImGuiWindowFlags_NoNavFocus); - m.attr("ImGuiWindowFlags_UnsavedDocument") = static_cast(ImGuiWindowFlags_UnsavedDocument); - m.attr("ImGuiWindowFlags_NoNav") = static_cast(ImGuiWindowFlags_NoNav); - m.attr("ImGuiWindowFlags_NoDecoration") = static_cast(ImGuiWindowFlags_NoDecoration); - m.attr("ImGuiWindowFlags_NoInputs") = static_cast(ImGuiWindowFlags_NoInputs); - m.attr("ImGuiWindowFlags_NavFlattened") = static_cast(ImGuiWindowFlags_NavFlattened); - m.attr("ImGuiWindowFlags_ChildWindow") = static_cast(ImGuiWindowFlags_ChildWindow); - m.attr("ImGuiWindowFlags_Tooltip") = static_cast(ImGuiWindowFlags_Tooltip); - m.attr("ImGuiWindowFlags_Popup") = static_cast(ImGuiWindowFlags_Popup); - m.attr("ImGuiWindowFlags_Modal") = static_cast(ImGuiWindowFlags_Modal); - m.attr("ImGuiWindowFlags_ChildMenu") = static_cast(ImGuiWindowFlags_ChildMenu); - - m.attr("ImGuiInputTextFlags_None") = static_cast(ImGuiInputTextFlags_None); - m.attr("ImGuiInputTextFlags_CharsDecimal") = static_cast(ImGuiInputTextFlags_CharsDecimal); - m.attr("ImGuiInputTextFlags_CharsHexadecimal") = static_cast(ImGuiInputTextFlags_CharsHexadecimal); - m.attr("ImGuiInputTextFlags_CharsUppercase") = static_cast(ImGuiInputTextFlags_CharsUppercase); - m.attr("ImGuiInputTextFlags_CharsNoBlank") = static_cast(ImGuiInputTextFlags_CharsNoBlank); - m.attr("ImGuiInputTextFlags_AutoSelectAll") = static_cast(ImGuiInputTextFlags_AutoSelectAll); - m.attr("ImGuiInputTextFlags_EnterReturnsTrue") = static_cast(ImGuiInputTextFlags_EnterReturnsTrue); - m.attr("ImGuiInputTextFlags_CallbackCompletion") = static_cast(ImGuiInputTextFlags_CallbackCompletion); - m.attr("ImGuiInputTextFlags_CallbackHistory") = static_cast(ImGuiInputTextFlags_CallbackHistory); - m.attr("ImGuiInputTextFlags_CallbackAlways") = static_cast(ImGuiInputTextFlags_CallbackAlways); - m.attr("ImGuiInputTextFlags_CallbackCharFilter") = static_cast(ImGuiInputTextFlags_CallbackCharFilter); - m.attr("ImGuiInputTextFlags_AllowTabInput") = static_cast(ImGuiInputTextFlags_AllowTabInput); - m.attr("ImGuiInputTextFlags_CtrlEnterForNewLine") = static_cast(ImGuiInputTextFlags_CtrlEnterForNewLine); - m.attr("ImGuiInputTextFlags_NoHorizontalScroll") = static_cast(ImGuiInputTextFlags_NoHorizontalScroll); - m.attr("ImGuiInputTextFlags_AlwaysOverwrite") = static_cast(ImGuiInputTextFlags_AlwaysOverwrite); - m.attr("ImGuiInputTextFlags_ReadOnly") = static_cast(ImGuiInputTextFlags_ReadOnly); - m.attr("ImGuiInputTextFlags_Password") = static_cast(ImGuiInputTextFlags_Password); - m.attr("ImGuiInputTextFlags_NoUndoRedo") = static_cast(ImGuiInputTextFlags_NoUndoRedo); - m.attr("ImGuiInputTextFlags_CharsScientific") = static_cast(ImGuiInputTextFlags_CharsScientific); - m.attr("ImGuiInputTextFlags_CallbackResize") = static_cast(ImGuiInputTextFlags_CallbackResize); - - m.attr("ImGuiTreeNodeFlags_None") = static_cast(ImGuiTreeNodeFlags_None); - m.attr("ImGuiTreeNodeFlags_Selected") = static_cast(ImGuiTreeNodeFlags_Selected); - m.attr("ImGuiTreeNodeFlags_Framed") = static_cast(ImGuiTreeNodeFlags_Framed); - m.attr("ImGuiTreeNodeFlags_AllowItemOverlap") = static_cast(ImGuiTreeNodeFlags_AllowItemOverlap); - m.attr("ImGuiTreeNodeFlags_NoTreePushOnOpen") = static_cast(ImGuiTreeNodeFlags_NoTreePushOnOpen); - m.attr("ImGuiTreeNodeFlags_NoAutoOpenOnLog") = static_cast(ImGuiTreeNodeFlags_NoAutoOpenOnLog); - m.attr("ImGuiTreeNodeFlags_DefaultOpen") = static_cast(ImGuiTreeNodeFlags_DefaultOpen); - m.attr("ImGuiTreeNodeFlags_OpenOnDoubleClick") = static_cast(ImGuiTreeNodeFlags_OpenOnDoubleClick); - m.attr("ImGuiTreeNodeFlags_OpenOnArrow") = static_cast(ImGuiTreeNodeFlags_OpenOnArrow); - m.attr("ImGuiTreeNodeFlags_Leaf") = static_cast(ImGuiTreeNodeFlags_Leaf); - m.attr("ImGuiTreeNodeFlags_Bullet") = static_cast(ImGuiTreeNodeFlags_Bullet); - m.attr("ImGuiTreeNodeFlags_FramePadding") = static_cast(ImGuiTreeNodeFlags_FramePadding); - m.attr("ImGuiTreeNodeFlags_SpanAvailWidth") = static_cast(ImGuiTreeNodeFlags_SpanAvailWidth); - m.attr("ImGuiTreeNodeFlags_SpanFullWidth") = static_cast(ImGuiTreeNodeFlags_SpanFullWidth); - m.attr("ImGuiTreeNodeFlags_NavLeftJumpsBackHere") = static_cast(ImGuiTreeNodeFlags_NavLeftJumpsBackHere); - m.attr("ImGuiTreeNodeFlags_CollapsingHeader") = static_cast(ImGuiTreeNodeFlags_CollapsingHeader); - - m.attr("ImGuiSelectableFlags_None") = static_cast(ImGuiSelectableFlags_None); - m.attr("ImGuiSelectableFlags_DontClosePopups") = static_cast(ImGuiSelectableFlags_DontClosePopups); - m.attr("ImGuiSelectableFlags_SpanAllColumns") = static_cast(ImGuiSelectableFlags_SpanAllColumns); - m.attr("ImGuiSelectableFlags_AllowDoubleClick") = static_cast(ImGuiSelectableFlags_AllowDoubleClick); - m.attr("ImGuiSelectableFlags_Disabled") = static_cast(ImGuiSelectableFlags_Disabled); - m.attr("ImGuiSelectableFlags_AllowItemOverlap") = static_cast(ImGuiSelectableFlags_AllowItemOverlap); - - m.attr("ImGuiComboFlags_None") = static_cast(ImGuiComboFlags_None); - m.attr("ImGuiComboFlags_PopupAlignLeft") = static_cast(ImGuiComboFlags_PopupAlignLeft); - m.attr("ImGuiComboFlags_HeightSmall") = static_cast(ImGuiComboFlags_HeightSmall); - m.attr("ImGuiComboFlags_HeightRegular") = static_cast(ImGuiComboFlags_HeightRegular); - m.attr("ImGuiComboFlags_HeightLarge") = static_cast(ImGuiComboFlags_HeightLarge); - m.attr("ImGuiComboFlags_HeightLargest") = static_cast(ImGuiComboFlags_HeightLargest); - m.attr("ImGuiComboFlags_NoArrowButton") = static_cast(ImGuiComboFlags_NoArrowButton); - m.attr("ImGuiComboFlags_NoPreview") = static_cast(ImGuiComboFlags_NoPreview); - m.attr("ImGuiComboFlags_HeightMask_") = static_cast(ImGuiComboFlags_HeightMask_); - - m.attr("ImGuiTabBarFlags_None") = static_cast(ImGuiTabBarFlags_None); - m.attr("ImGuiTabBarFlags_Reorderable") = static_cast(ImGuiTabBarFlags_Reorderable); - m.attr("ImGuiTabBarFlags_AutoSelectNewTabs") = static_cast(ImGuiTabBarFlags_AutoSelectNewTabs); - m.attr("ImGuiTabBarFlags_TabListPopupButton") = static_cast(ImGuiTabBarFlags_TabListPopupButton); - m.attr("ImGuiTabBarFlags_NoCloseWithMiddleMouseButton") = - static_cast(ImGuiTabBarFlags_NoCloseWithMiddleMouseButton); - m.attr("ImGuiTabBarFlags_NoTabListScrollingButtons") = static_cast(ImGuiTabBarFlags_NoTabListScrollingButtons); - m.attr("ImGuiTabBarFlags_NoTooltip") = static_cast(ImGuiTabBarFlags_NoTooltip); - m.attr("ImGuiTabBarFlags_FittingPolicyResizeDown") = static_cast(ImGuiTabBarFlags_FittingPolicyResizeDown); - m.attr("ImGuiTabBarFlags_FittingPolicyScroll") = static_cast(ImGuiTabBarFlags_FittingPolicyScroll); - m.attr("ImGuiTabBarFlags_FittingPolicyMask_") = static_cast(ImGuiTabBarFlags_FittingPolicyMask_); - m.attr("ImGuiTabBarFlags_FittingPolicyDefault_") = static_cast(ImGuiTabBarFlags_FittingPolicyDefault_); - - m.attr("ImGuiTabItemFlags_None") = static_cast(ImGuiTabItemFlags_None); - m.attr("ImGuiTabItemFlags_UnsavedDocument") = static_cast(ImGuiTabItemFlags_UnsavedDocument); - m.attr("ImGuiTabItemFlags_SetSelected") = static_cast(ImGuiTabItemFlags_SetSelected); - m.attr("ImGuiTabItemFlags_NoCloseWithMiddleMouseButton") = - static_cast(ImGuiTabItemFlags_NoCloseWithMiddleMouseButton); - m.attr("ImGuiTabItemFlags_NoPushId") = static_cast(ImGuiTabItemFlags_NoPushId); - - m.attr("ImGuiTableFlags_None") = static_cast(ImGuiTableFlags_None); - m.attr("ImGuiTableFlags_Resizable") = static_cast(ImGuiTableFlags_Resizable); - m.attr("ImGuiTableFlags_Reorderable") = static_cast(ImGuiTableFlags_Reorderable); - m.attr("ImGuiTableFlags_Hideable") = static_cast(ImGuiTableFlags_Hideable); - m.attr("ImGuiTableFlags_Sortable") = static_cast(ImGuiTableFlags_Sortable); - m.attr("ImGuiTableFlags_NoSavedSettings") = static_cast(ImGuiTableFlags_NoSavedSettings); - m.attr("ImGuiTableFlags_ContextMenuInBody") = static_cast(ImGuiTableFlags_ContextMenuInBody); - m.attr("ImGuiTableFlags_RowBg") = static_cast(ImGuiTableFlags_RowBg); - m.attr("ImGuiTableFlags_BordersInnerH") = static_cast(ImGuiTableFlags_BordersInnerH); - m.attr("ImGuiTableFlags_BordersOuterH") = static_cast(ImGuiTableFlags_BordersOuterH); - m.attr("ImGuiTableFlags_BordersInnerV") = static_cast(ImGuiTableFlags_BordersInnerV); - m.attr("ImGuiTableFlags_BordersOuterV") = static_cast(ImGuiTableFlags_BordersOuterV); - m.attr("ImGuiTableFlags_BordersH") = static_cast(ImGuiTableFlags_BordersH); - m.attr("ImGuiTableFlags_BordersV") = static_cast(ImGuiTableFlags_BordersV); - m.attr("ImGuiTableFlags_BordersInner") = static_cast(ImGuiTableFlags_BordersInner); - m.attr("ImGuiTableFlags_BordersOuter") = static_cast(ImGuiTableFlags_BordersOuter); - m.attr("ImGuiTableFlags_Borders") = static_cast(ImGuiTableFlags_Borders); - m.attr("ImGuiTableFlags_NoBordersInBody") = static_cast(ImGuiTableFlags_NoBordersInBody); - m.attr("ImGuiTableFlags_NoBordersInBodyUntilResize") = static_cast(ImGuiTableFlags_NoBordersInBodyUntilResize); - m.attr("ImGuiTableFlags_SizingFixedFit") = static_cast(ImGuiTableFlags_SizingFixedFit); - m.attr("ImGuiTableFlags_SizingFixedSame") = static_cast(ImGuiTableFlags_SizingFixedSame); - m.attr("ImGuiTableFlags_SizingStretchProp") = static_cast(ImGuiTableFlags_SizingStretchProp); - m.attr("ImGuiTableFlags_SizingStretchSame") = static_cast(ImGuiTableFlags_SizingStretchSame); - m.attr("ImGuiTableFlags_NoHostExtendX") = static_cast(ImGuiTableFlags_NoHostExtendX); - m.attr("ImGuiTableFlags_NoHostExtendY") = static_cast(ImGuiTableFlags_NoHostExtendY); - m.attr("ImGuiTableFlags_NoKeepColumnsVisible") = static_cast(ImGuiTableFlags_NoKeepColumnsVisible); - m.attr("ImGuiTableFlags_PreciseWidths") = static_cast(ImGuiTableFlags_PreciseWidths); - m.attr("ImGuiTableFlags_NoClip") = static_cast(ImGuiTableFlags_NoClip); - m.attr("ImGuiTableFlags_PadOuterX") = static_cast(ImGuiTableFlags_PadOuterX); - m.attr("ImGuiTableFlags_NoPadOuterX") = static_cast(ImGuiTableFlags_NoPadOuterX); - m.attr("ImGuiTableFlags_NoPadInnerX") = static_cast(ImGuiTableFlags_NoPadInnerX); - m.attr("ImGuiTableFlags_ScrollX") = static_cast(ImGuiTableFlags_ScrollX); - m.attr("ImGuiTableFlags_ScrollY") = static_cast(ImGuiTableFlags_ScrollY); - m.attr("ImGuiTableFlags_SortMulti") = static_cast(ImGuiTableFlags_SortMulti); - m.attr("ImGuiTableFlags_SortTristate") = static_cast(ImGuiTableFlags_SortTristate); - m.attr("ImGuiTableFlags_HighlightHoveredColumn") = static_cast(ImGuiTableFlags_HighlightHoveredColumn); - - m.attr("ImGuiTableColumnFlags_None") = static_cast(ImGuiTableColumnFlags_None); - m.attr("ImGuiTableColumnFlags_Disabled") = static_cast(ImGuiTableColumnFlags_Disabled); - m.attr("ImGuiTableColumnFlags_DefaultHide") = static_cast(ImGuiTableColumnFlags_DefaultHide); - m.attr("ImGuiTableColumnFlags_DefaultSort") = static_cast(ImGuiTableColumnFlags_DefaultSort); - m.attr("ImGuiTableColumnFlags_WidthStretch") = static_cast(ImGuiTableColumnFlags_WidthStretch); - m.attr("ImGuiTableColumnFlags_WidthFixed") = static_cast(ImGuiTableColumnFlags_WidthFixed); - m.attr("ImGuiTableColumnFlags_NoResize") = static_cast(ImGuiTableColumnFlags_NoResize); - m.attr("ImGuiTableColumnFlags_NoReorder") = static_cast(ImGuiTableColumnFlags_NoReorder); - m.attr("ImGuiTableColumnFlags_NoHide") = static_cast(ImGuiTableColumnFlags_NoHide); - m.attr("ImGuiTableColumnFlags_NoClip") = static_cast(ImGuiTableColumnFlags_NoClip); - m.attr("ImGuiTableColumnFlags_NoSort") = static_cast(ImGuiTableColumnFlags_NoSort); - m.attr("ImGuiTableColumnFlags_NoSortAscending") = static_cast(ImGuiTableColumnFlags_NoSortAscending); - m.attr("ImGuiTableColumnFlags_NoSortDescending") = static_cast(ImGuiTableColumnFlags_NoSortDescending); - m.attr("ImGuiTableColumnFlags_NoHeaderLabel") = static_cast(ImGuiTableColumnFlags_NoHeaderLabel); - m.attr("ImGuiTableColumnFlags_NoHeaderWidth") = static_cast(ImGuiTableColumnFlags_NoHeaderWidth); - m.attr("ImGuiTableColumnFlags_PreferSortAscending") = static_cast(ImGuiTableColumnFlags_PreferSortAscending); - m.attr("ImGuiTableColumnFlags_PreferSortDescending") = static_cast(ImGuiTableColumnFlags_PreferSortDescending); - m.attr("ImGuiTableColumnFlags_IndentEnable") = static_cast(ImGuiTableColumnFlags_IndentEnable); - m.attr("ImGuiTableColumnFlags_IndentDisable") = static_cast(ImGuiTableColumnFlags_IndentDisable); - m.attr("ImGuiTableColumnFlags_AngledHeader") = static_cast(ImGuiTableColumnFlags_AngledHeader); - m.attr("ImGuiTableColumnFlags_IsEnabled") = static_cast(ImGuiTableColumnFlags_IsEnabled); - m.attr("ImGuiTableColumnFlags_IsVisible") = static_cast(ImGuiTableColumnFlags_IsVisible); - m.attr("ImGuiTableColumnFlags_IsSorted") = static_cast(ImGuiTableColumnFlags_IsSorted); - m.attr("ImGuiTableColumnFlags_IsHovered") = static_cast(ImGuiTableColumnFlags_IsHovered); - - m.attr("ImGuiTableRowFlags_None") = static_cast(ImGuiTableRowFlags_None); - m.attr("ImGuiTableRowFlags_Headers") = static_cast(ImGuiTableRowFlags_Headers); - - m.attr("ImGuiTableBgTarget_None") = static_cast(ImGuiTableBgTarget_None); - m.attr("ImGuiTableBgTarget_RowBg0") = static_cast(ImGuiTableBgTarget_RowBg0); - m.attr("ImGuiTableBgTarget_RowBg1") = static_cast(ImGuiTableBgTarget_RowBg1); - m.attr("ImGuiTableBgTarget_CellBg") = static_cast(ImGuiTableBgTarget_CellBg); - - m.attr("ImGuiFocusedFlags_None") = static_cast(ImGuiFocusedFlags_None); - m.attr("ImGuiFocusedFlags_ChildWindows") = static_cast(ImGuiFocusedFlags_ChildWindows); - m.attr("ImGuiFocusedFlags_RootWindow") = static_cast(ImGuiFocusedFlags_RootWindow); - m.attr("ImGuiFocusedFlags_AnyWindow") = static_cast(ImGuiFocusedFlags_AnyWindow); - m.attr("ImGuiFocusedFlags_RootAndChildWindows") = static_cast(ImGuiFocusedFlags_RootAndChildWindows); - - m.attr("ImGuiHoveredFlags_None") = static_cast(ImGuiHoveredFlags_None); - m.attr("ImGuiHoveredFlags_ChildWindows") = static_cast(ImGuiHoveredFlags_ChildWindows); - m.attr("ImGuiHoveredFlags_RootWindow") = static_cast(ImGuiHoveredFlags_RootWindow); - m.attr("ImGuiHoveredFlags_AnyWindow") = static_cast(ImGuiHoveredFlags_AnyWindow); - m.attr("ImGuiHoveredFlags_AllowWhenBlockedByPopup") = static_cast(ImGuiHoveredFlags_AllowWhenBlockedByPopup); - m.attr("ImGuiHoveredFlags_AllowWhenBlockedByActiveItem") = - static_cast(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem); - m.attr("ImGuiHoveredFlags_AllowWhenOverlapped") = static_cast(ImGuiHoveredFlags_AllowWhenOverlapped); - m.attr("ImGuiHoveredFlags_AllowWhenDisabled") = static_cast(ImGuiHoveredFlags_AllowWhenDisabled); - m.attr("ImGuiHoveredFlags_RectOnly") = static_cast(ImGuiHoveredFlags_RectOnly); - m.attr("ImGuiHoveredFlags_RootAndChildWindows") = static_cast(ImGuiHoveredFlags_RootAndChildWindows); - - m.attr("ImGuiDragDropFlags_None") = static_cast(ImGuiDragDropFlags_None); - m.attr("ImGuiDragDropFlags_SourceNoPreviewTooltip") = static_cast(ImGuiDragDropFlags_SourceNoPreviewTooltip); - m.attr("ImGuiDragDropFlags_SourceNoDisableHover") = static_cast(ImGuiDragDropFlags_SourceNoDisableHover); - m.attr("ImGuiDragDropFlags_SourceNoHoldToOpenOthers") = static_cast(ImGuiDragDropFlags_SourceNoHoldToOpenOthers); - m.attr("ImGuiDragDropFlags_SourceAllowNullID") = static_cast(ImGuiDragDropFlags_SourceAllowNullID); - m.attr("ImGuiDragDropFlags_SourceExtern") = static_cast(ImGuiDragDropFlags_SourceExtern); - m.attr("ImGuiDragDropFlags_SourceAutoExpirePayload") = static_cast(ImGuiDragDropFlags_SourceAutoExpirePayload); - m.attr("ImGuiDragDropFlags_AcceptBeforeDelivery") = static_cast(ImGuiDragDropFlags_AcceptBeforeDelivery); - m.attr("ImGuiDragDropFlags_AcceptNoDrawDefaultRect") = static_cast(ImGuiDragDropFlags_AcceptNoDrawDefaultRect); - m.attr("ImGuiDragDropFlags_AcceptNoPreviewTooltip") = static_cast(ImGuiDragDropFlags_AcceptNoPreviewTooltip); - m.attr("ImGuiDragDropFlags_AcceptPeekOnly") = static_cast(ImGuiDragDropFlags_AcceptPeekOnly); - - m.attr("ImGuiDataType_S8") = static_cast(ImGuiDataType_S8); - m.attr("ImGuiDataType_U8") = static_cast(ImGuiDataType_U8); - m.attr("ImGuiDataType_S16") = static_cast(ImGuiDataType_S16); - m.attr("ImGuiDataType_U16") = static_cast(ImGuiDataType_U16); - m.attr("ImGuiDataType_S32") = static_cast(ImGuiDataType_S32); - m.attr("ImGuiDataType_U32") = static_cast(ImGuiDataType_U32); - m.attr("ImGuiDataType_S64") = static_cast(ImGuiDataType_S64); - m.attr("ImGuiDataType_U64") = static_cast(ImGuiDataType_U64); - m.attr("ImGuiDataType_Float") = static_cast(ImGuiDataType_Float); - m.attr("ImGuiDataType_Double") = static_cast(ImGuiDataType_Double); - m.attr("ImGuiDataType_COUNT") = static_cast(ImGuiDataType_COUNT); - - m.attr("ImGuiDir_None") = static_cast(ImGuiDir_None); - m.attr("ImGuiDir_Left") = static_cast(ImGuiDir_Left); - m.attr("ImGuiDir_Right") = static_cast(ImGuiDir_Right); - m.attr("ImGuiDir_Up") = static_cast(ImGuiDir_Up); - m.attr("ImGuiDir_Down") = static_cast(ImGuiDir_Down); - m.attr("ImGuiDir_COUNT") = static_cast(ImGuiDir_COUNT); - - m.attr("ImGuiSortDirection_None") = static_cast(ImGuiSortDirection_None); - m.attr("ImGuiSortDirection_Ascending") = static_cast(ImGuiSortDirection_Ascending); - m.attr("ImGuiSortDirection_Descending") = static_cast(ImGuiSortDirection_Descending); - - // TODO replace all enum bindings to work like this (although it does force us to repeat ourselves twice) - nb::enum_(m, "ImGuiKey") - .value("ImGuiKey_None", ImGuiKey::ImGuiKey_None) - .value("ImGuiKey_Tab", ImGuiKey::ImGuiKey_Tab) - .value("ImGuiKey_LeftArrow", ImGuiKey::ImGuiKey_LeftArrow) - .value("ImGuiKey_RightArrow", ImGuiKey::ImGuiKey_RightArrow) - .value("ImGuiKey_UpArrow", ImGuiKey::ImGuiKey_UpArrow) - .value("ImGuiKey_DownArrow", ImGuiKey::ImGuiKey_DownArrow) - .value("ImGuiKey_PageUp", ImGuiKey::ImGuiKey_PageUp) - .value("ImGuiKey_PageDown", ImGuiKey::ImGuiKey_PageDown) - .value("ImGuiKey_Home", ImGuiKey::ImGuiKey_Home) - .value("ImGuiKey_End", ImGuiKey::ImGuiKey_End) - .value("ImGuiKey_Insert", ImGuiKey::ImGuiKey_Insert) - .value("ImGuiKey_Delete", ImGuiKey::ImGuiKey_Delete) - .value("ImGuiKey_Backspace", ImGuiKey::ImGuiKey_Backspace) - .value("ImGuiKey_Space", ImGuiKey::ImGuiKey_Space) - .value("ImGuiKey_Enter", ImGuiKey::ImGuiKey_Enter) - .value("ImGuiKey_Escape", ImGuiKey::ImGuiKey_Escape) - .value("ImGuiKey_LeftCtrl", ImGuiKey::ImGuiKey_LeftCtrl) - .value("ImGuiKey_LeftShift", ImGuiKey::ImGuiKey_LeftShift) - .value("ImGuiKey_LeftAlt", ImGuiKey::ImGuiKey_LeftAlt) - .value("ImGuiKey_LeftSuper", ImGuiKey::ImGuiKey_LeftSuper) - .value("ImGuiKey_RightCtrl", ImGuiKey::ImGuiKey_RightCtrl) - .value("ImGuiKey_RightShift", ImGuiKey::ImGuiKey_RightShift) - .value("ImGuiKey_RightAlt", ImGuiKey::ImGuiKey_RightAlt) - .value("ImGuiKey_RightSuper", ImGuiKey::ImGuiKey_RightSuper) - .value("ImGuiKey_Menu", ImGuiKey::ImGuiKey_Menu) - .value("ImGuiKey_0", ImGuiKey::ImGuiKey_0) - .value("ImGuiKey_1", ImGuiKey::ImGuiKey_1) - .value("ImGuiKey_2", ImGuiKey::ImGuiKey_2) - .value("ImGuiKey_3", ImGuiKey::ImGuiKey_3) - .value("ImGuiKey_4", ImGuiKey::ImGuiKey_4) - .value("ImGuiKey_5", ImGuiKey::ImGuiKey_5) - .value("ImGuiKey_6", ImGuiKey::ImGuiKey_6) - .value("ImGuiKey_7", ImGuiKey::ImGuiKey_7) - .value("ImGuiKey_8", ImGuiKey::ImGuiKey_8) - .value("ImGuiKey_9", ImGuiKey::ImGuiKey_9) - .value("ImGuiKey_A", ImGuiKey::ImGuiKey_A) - .value("ImGuiKey_B", ImGuiKey::ImGuiKey_B) - .value("ImGuiKey_C", ImGuiKey::ImGuiKey_C) - .value("ImGuiKey_D", ImGuiKey::ImGuiKey_D) - .value("ImGuiKey_E", ImGuiKey::ImGuiKey_E) - .value("ImGuiKey_F", ImGuiKey::ImGuiKey_F) - .value("ImGuiKey_G", ImGuiKey::ImGuiKey_G) - .value("ImGuiKey_H", ImGuiKey::ImGuiKey_H) - .value("ImGuiKey_I", ImGuiKey::ImGuiKey_I) - .value("ImGuiKey_J", ImGuiKey::ImGuiKey_J) - .value("ImGuiKey_K", ImGuiKey::ImGuiKey_K) - .value("ImGuiKey_L", ImGuiKey::ImGuiKey_L) - .value("ImGuiKey_M", ImGuiKey::ImGuiKey_M) - .value("ImGuiKey_N", ImGuiKey::ImGuiKey_N) - .value("ImGuiKey_O", ImGuiKey::ImGuiKey_O) - .value("ImGuiKey_P", ImGuiKey::ImGuiKey_P) - .value("ImGuiKey_Q", ImGuiKey::ImGuiKey_Q) - .value("ImGuiKey_R", ImGuiKey::ImGuiKey_R) - .value("ImGuiKey_S", ImGuiKey::ImGuiKey_S) - .value("ImGuiKey_T", ImGuiKey::ImGuiKey_T) - .value("ImGuiKey_U", ImGuiKey::ImGuiKey_U) - .value("ImGuiKey_V", ImGuiKey::ImGuiKey_V) - .value("ImGuiKey_W", ImGuiKey::ImGuiKey_W) - .value("ImGuiKey_X", ImGuiKey::ImGuiKey_X) - .value("ImGuiKey_Y", ImGuiKey::ImGuiKey_Y) - .value("ImGuiKey_Z", ImGuiKey::ImGuiKey_Z) - .value("ImGuiKey_F1", ImGuiKey::ImGuiKey_F1) - .value("ImGuiKey_F2", ImGuiKey::ImGuiKey_F2) - .value("ImGuiKey_F3", ImGuiKey::ImGuiKey_F3) - .value("ImGuiKey_F4", ImGuiKey::ImGuiKey_F4) - .value("ImGuiKey_F5", ImGuiKey::ImGuiKey_F5) - .value("ImGuiKey_F6", ImGuiKey::ImGuiKey_F6) - .value("ImGuiKey_F7", ImGuiKey::ImGuiKey_F7) - .value("ImGuiKey_F8", ImGuiKey::ImGuiKey_F8) - .value("ImGuiKey_F9", ImGuiKey::ImGuiKey_F9) - .value("ImGuiKey_F10", ImGuiKey::ImGuiKey_F10) - .value("ImGuiKey_F11", ImGuiKey::ImGuiKey_F11) - .value("ImGuiKey_F12", ImGuiKey::ImGuiKey_F12) - .value("ImGuiKey_F13", ImGuiKey::ImGuiKey_F13) - .value("ImGuiKey_F14", ImGuiKey::ImGuiKey_F14) - .value("ImGuiKey_F15", ImGuiKey::ImGuiKey_F15) - .value("ImGuiKey_F16", ImGuiKey::ImGuiKey_F16) - .value("ImGuiKey_F17", ImGuiKey::ImGuiKey_F17) - .value("ImGuiKey_F18", ImGuiKey::ImGuiKey_F18) - .value("ImGuiKey_F19", ImGuiKey::ImGuiKey_F19) - .value("ImGuiKey_F20", ImGuiKey::ImGuiKey_F20) - .value("ImGuiKey_F21", ImGuiKey::ImGuiKey_F21) - .value("ImGuiKey_F22", ImGuiKey::ImGuiKey_F22) - .value("ImGuiKey_F23", ImGuiKey::ImGuiKey_F23) - .value("ImGuiKey_F24", ImGuiKey::ImGuiKey_F24) - .value("ImGuiKey_Apostrophe", ImGuiKey::ImGuiKey_Apostrophe) - .value("ImGuiKey_Comma", ImGuiKey::ImGuiKey_Comma) - .value("ImGuiKey_Minus", ImGuiKey::ImGuiKey_Minus) - .value("ImGuiKey_Period", ImGuiKey::ImGuiKey_Period) - .value("ImGuiKey_Slash", ImGuiKey::ImGuiKey_Slash) - .value("ImGuiKey_Semicolon", ImGuiKey::ImGuiKey_Semicolon) - .value("ImGuiKey_Equal", ImGuiKey::ImGuiKey_Equal) - .value("ImGuiKey_LeftBracket", ImGuiKey::ImGuiKey_LeftBracket) - .value("ImGuiKey_Backslash", ImGuiKey::ImGuiKey_Backslash) - .value("ImGuiKey_RightBracket", ImGuiKey::ImGuiKey_RightBracket) - .value("ImGuiKey_GraveAccent", ImGuiKey::ImGuiKey_GraveAccent) - .value("ImGuiKey_CapsLock", ImGuiKey::ImGuiKey_CapsLock) - .value("ImGuiKey_ScrollLock", ImGuiKey::ImGuiKey_ScrollLock) - .value("ImGuiKey_NumLock", ImGuiKey::ImGuiKey_NumLock) - .value("ImGuiKey_PrintScreen", ImGuiKey::ImGuiKey_PrintScreen) - .value("ImGuiKey_Pause", ImGuiKey::ImGuiKey_Pause) - .value("ImGuiKey_Keypad0", ImGuiKey::ImGuiKey_Keypad0) - .value("ImGuiKey_Keypad1", ImGuiKey::ImGuiKey_Keypad1) - .value("ImGuiKey_Keypad2", ImGuiKey::ImGuiKey_Keypad2) - .value("ImGuiKey_Keypad3", ImGuiKey::ImGuiKey_Keypad3) - .value("ImGuiKey_Keypad4", ImGuiKey::ImGuiKey_Keypad4) - .value("ImGuiKey_Keypad5", ImGuiKey::ImGuiKey_Keypad5) - .value("ImGuiKey_Keypad6", ImGuiKey::ImGuiKey_Keypad6) - .value("ImGuiKey_Keypad7", ImGuiKey::ImGuiKey_Keypad7) - .value("ImGuiKey_Keypad8", ImGuiKey::ImGuiKey_Keypad8) - .value("ImGuiKey_Keypad9", ImGuiKey::ImGuiKey_Keypad9) - .value("ImGuiKey_KeypadDecimal", ImGuiKey::ImGuiKey_KeypadDecimal) - .value("ImGuiKey_KeypadDivide", ImGuiKey::ImGuiKey_KeypadDivide) - .value("ImGuiKey_KeypadMultiply", ImGuiKey::ImGuiKey_KeypadMultiply) - .value("ImGuiKey_KeypadSubtract", ImGuiKey::ImGuiKey_KeypadSubtract) - .value("ImGuiKey_KeypadAdd", ImGuiKey::ImGuiKey_KeypadAdd) - .value("ImGuiKey_KeypadEnter", ImGuiKey::ImGuiKey_KeypadEnter) - .value("ImGuiKey_KeypadEqual", ImGuiKey::ImGuiKey_KeypadEqual) - .value("ImGuiKey_AppBack", ImGuiKey::ImGuiKey_AppBack) - .value("ImGuiKey_AppForward", ImGuiKey::ImGuiKey_AppForward) - .value("ImGuiKey_GamepadStart", ImGuiKey::ImGuiKey_GamepadStart) - .value("ImGuiKey_GamepadBack", ImGuiKey::ImGuiKey_GamepadBack) - .value("ImGuiKey_GamepadFaceUp", ImGuiKey::ImGuiKey_GamepadFaceUp) - .value("ImGuiKey_GamepadFaceDown", ImGuiKey::ImGuiKey_GamepadFaceDown) - .value("ImGuiKey_GamepadFaceLeft", ImGuiKey::ImGuiKey_GamepadFaceLeft) - .value("ImGuiKey_GamepadFaceRight", ImGuiKey::ImGuiKey_GamepadFaceRight) - .value("ImGuiKey_GamepadDpadUp", ImGuiKey::ImGuiKey_GamepadDpadUp) - .value("ImGuiKey_GamepadDpadDown", ImGuiKey::ImGuiKey_GamepadDpadDown) - .value("ImGuiKey_GamepadDpadLeft", ImGuiKey::ImGuiKey_GamepadDpadLeft) - .value("ImGuiKey_GamepadDpadRight", ImGuiKey::ImGuiKey_GamepadDpadRight) - .value("ImGuiKey_GamepadL1", ImGuiKey::ImGuiKey_GamepadL1) - .value("ImGuiKey_GamepadR1", ImGuiKey::ImGuiKey_GamepadR1) - .value("ImGuiKey_GamepadL2", ImGuiKey::ImGuiKey_GamepadL2) - .value("ImGuiKey_GamepadR2", ImGuiKey::ImGuiKey_GamepadR2) - .value("ImGuiKey_GamepadL3", ImGuiKey::ImGuiKey_GamepadL3) - .value("ImGuiKey_GamepadR3", ImGuiKey::ImGuiKey_GamepadR3) - .value("ImGuiKey_GamepadLStickUp", ImGuiKey::ImGuiKey_GamepadLStickUp) - .value("ImGuiKey_GamepadLStickDown", ImGuiKey::ImGuiKey_GamepadLStickDown) - .value("ImGuiKey_GamepadLStickLeft", ImGuiKey::ImGuiKey_GamepadLStickLeft) - .value("ImGuiKey_GamepadLStickRight", ImGuiKey::ImGuiKey_GamepadLStickRight) - .value("ImGuiKey_GamepadRStickUp", ImGuiKey::ImGuiKey_GamepadRStickUp) - .value("ImGuiKey_GamepadRStickDown", ImGuiKey::ImGuiKey_GamepadRStickDown) - .value("ImGuiKey_GamepadRStickLeft", ImGuiKey::ImGuiKey_GamepadRStickLeft) - .value("ImGuiKey_GamepadRStickRight", ImGuiKey::ImGuiKey_GamepadRStickRight) - .value("ImGuiKey_ModCtrl", ImGuiKey::ImGuiKey_ModCtrl) - .value("ImGuiKey_ModShift", ImGuiKey::ImGuiKey_ModShift) - .value("ImGuiKey_ModAlt", ImGuiKey::ImGuiKey_ModAlt) - .value("ImGuiKey_ModSuper", ImGuiKey::ImGuiKey_ModSuper) - ; - - m.attr("ImGuiKey_None") = ImGuiKey::ImGuiKey_None; - m.attr("ImGuiKey_Tab") = ImGuiKey::ImGuiKey_Tab; - m.attr("ImGuiKey_LeftArrow") = ImGuiKey::ImGuiKey_LeftArrow; - m.attr("ImGuiKey_RightArrow") = ImGuiKey::ImGuiKey_RightArrow; - m.attr("ImGuiKey_UpArrow") = ImGuiKey::ImGuiKey_UpArrow; - m.attr("ImGuiKey_DownArrow") = ImGuiKey::ImGuiKey_DownArrow; - m.attr("ImGuiKey_PageUp") = ImGuiKey::ImGuiKey_PageUp; - m.attr("ImGuiKey_PageDown") = ImGuiKey::ImGuiKey_PageDown; - m.attr("ImGuiKey_Home") = ImGuiKey::ImGuiKey_Home; - m.attr("ImGuiKey_End") = ImGuiKey::ImGuiKey_End; - m.attr("ImGuiKey_Insert") = ImGuiKey::ImGuiKey_Insert; - m.attr("ImGuiKey_Delete") = ImGuiKey::ImGuiKey_Delete; - m.attr("ImGuiKey_Backspace") = ImGuiKey::ImGuiKey_Backspace; - m.attr("ImGuiKey_Space") = ImGuiKey::ImGuiKey_Space; - m.attr("ImGuiKey_Enter") = ImGuiKey::ImGuiKey_Enter; - m.attr("ImGuiKey_Escape") = ImGuiKey::ImGuiKey_Escape; - m.attr("ImGuiKey_LeftCtrl") = ImGuiKey::ImGuiKey_LeftCtrl; - m.attr("ImGuiKey_LeftShift") = ImGuiKey::ImGuiKey_LeftShift; - m.attr("ImGuiKey_LeftAlt") = ImGuiKey::ImGuiKey_LeftAlt; - m.attr("ImGuiKey_LeftSuper") = ImGuiKey::ImGuiKey_LeftSuper; - m.attr("ImGuiKey_RightCtrl") = ImGuiKey::ImGuiKey_RightCtrl; - m.attr("ImGuiKey_RightShift") = ImGuiKey::ImGuiKey_RightShift; - m.attr("ImGuiKey_RightAlt") = ImGuiKey::ImGuiKey_RightAlt; - m.attr("ImGuiKey_RightSuper") = ImGuiKey::ImGuiKey_RightSuper; - m.attr("ImGuiKey_Menu") = ImGuiKey::ImGuiKey_Menu; - m.attr("ImGuiKey_0") = ImGuiKey::ImGuiKey_0; - m.attr("ImGuiKey_1") = ImGuiKey::ImGuiKey_1; - m.attr("ImGuiKey_2") = ImGuiKey::ImGuiKey_2; - m.attr("ImGuiKey_3") = ImGuiKey::ImGuiKey_3; - m.attr("ImGuiKey_4") = ImGuiKey::ImGuiKey_4; - m.attr("ImGuiKey_5") = ImGuiKey::ImGuiKey_5; - m.attr("ImGuiKey_6") = ImGuiKey::ImGuiKey_6; - m.attr("ImGuiKey_7") = ImGuiKey::ImGuiKey_7; - m.attr("ImGuiKey_8") = ImGuiKey::ImGuiKey_8; - m.attr("ImGuiKey_9") = ImGuiKey::ImGuiKey_9; - m.attr("ImGuiKey_A") = ImGuiKey::ImGuiKey_A; - m.attr("ImGuiKey_B") = ImGuiKey::ImGuiKey_B; - m.attr("ImGuiKey_C") = ImGuiKey::ImGuiKey_C; - m.attr("ImGuiKey_D") = ImGuiKey::ImGuiKey_D; - m.attr("ImGuiKey_E") = ImGuiKey::ImGuiKey_E; - m.attr("ImGuiKey_F") = ImGuiKey::ImGuiKey_F; - m.attr("ImGuiKey_G") = ImGuiKey::ImGuiKey_G; - m.attr("ImGuiKey_H") = ImGuiKey::ImGuiKey_H; - m.attr("ImGuiKey_I") = ImGuiKey::ImGuiKey_I; - m.attr("ImGuiKey_J") = ImGuiKey::ImGuiKey_J; - m.attr("ImGuiKey_K") = ImGuiKey::ImGuiKey_K; - m.attr("ImGuiKey_L") = ImGuiKey::ImGuiKey_L; - m.attr("ImGuiKey_M") = ImGuiKey::ImGuiKey_M; - m.attr("ImGuiKey_N") = ImGuiKey::ImGuiKey_N; - m.attr("ImGuiKey_O") = ImGuiKey::ImGuiKey_O; - m.attr("ImGuiKey_P") = ImGuiKey::ImGuiKey_P; - m.attr("ImGuiKey_Q") = ImGuiKey::ImGuiKey_Q; - m.attr("ImGuiKey_R") = ImGuiKey::ImGuiKey_R; - m.attr("ImGuiKey_S") = ImGuiKey::ImGuiKey_S; - m.attr("ImGuiKey_T") = ImGuiKey::ImGuiKey_T; - m.attr("ImGuiKey_U") = ImGuiKey::ImGuiKey_U; - m.attr("ImGuiKey_V") = ImGuiKey::ImGuiKey_V; - m.attr("ImGuiKey_W") = ImGuiKey::ImGuiKey_W; - m.attr("ImGuiKey_X") = ImGuiKey::ImGuiKey_X; - m.attr("ImGuiKey_Y") = ImGuiKey::ImGuiKey_Y; - m.attr("ImGuiKey_Z") = ImGuiKey::ImGuiKey_Z; - m.attr("ImGuiKey_F1") = ImGuiKey::ImGuiKey_F1; - m.attr("ImGuiKey_F2") = ImGuiKey::ImGuiKey_F2; - m.attr("ImGuiKey_F3") = ImGuiKey::ImGuiKey_F3; - m.attr("ImGuiKey_F4") = ImGuiKey::ImGuiKey_F4; - m.attr("ImGuiKey_F5") = ImGuiKey::ImGuiKey_F5; - m.attr("ImGuiKey_F6") = ImGuiKey::ImGuiKey_F6; - m.attr("ImGuiKey_F7") = ImGuiKey::ImGuiKey_F7; - m.attr("ImGuiKey_F8") = ImGuiKey::ImGuiKey_F8; - m.attr("ImGuiKey_F9") = ImGuiKey::ImGuiKey_F9; - m.attr("ImGuiKey_F10") = ImGuiKey::ImGuiKey_F10; - m.attr("ImGuiKey_F11") = ImGuiKey::ImGuiKey_F11; - m.attr("ImGuiKey_F12") = ImGuiKey::ImGuiKey_F12; - m.attr("ImGuiKey_F13") = ImGuiKey::ImGuiKey_F13; - m.attr("ImGuiKey_F14") = ImGuiKey::ImGuiKey_F14; - m.attr("ImGuiKey_F15") = ImGuiKey::ImGuiKey_F15; - m.attr("ImGuiKey_F16") = ImGuiKey::ImGuiKey_F16; - m.attr("ImGuiKey_F17") = ImGuiKey::ImGuiKey_F17; - m.attr("ImGuiKey_F18") = ImGuiKey::ImGuiKey_F18; - m.attr("ImGuiKey_F19") = ImGuiKey::ImGuiKey_F19; - m.attr("ImGuiKey_F20") = ImGuiKey::ImGuiKey_F20; - m.attr("ImGuiKey_F21") = ImGuiKey::ImGuiKey_F21; - m.attr("ImGuiKey_F22") = ImGuiKey::ImGuiKey_F22; - m.attr("ImGuiKey_F23") = ImGuiKey::ImGuiKey_F23; - m.attr("ImGuiKey_F24") = ImGuiKey::ImGuiKey_F24; - m.attr("ImGuiKey_Apostrophe") = ImGuiKey::ImGuiKey_Apostrophe; - m.attr("ImGuiKey_Comma") = ImGuiKey::ImGuiKey_Comma; - m.attr("ImGuiKey_Minus") = ImGuiKey::ImGuiKey_Minus; - m.attr("ImGuiKey_Period") = ImGuiKey::ImGuiKey_Period; - m.attr("ImGuiKey_Slash") = ImGuiKey::ImGuiKey_Slash; - m.attr("ImGuiKey_Semicolon") = ImGuiKey::ImGuiKey_Semicolon; - m.attr("ImGuiKey_Equal") = ImGuiKey::ImGuiKey_Equal; - m.attr("ImGuiKey_LeftBracket") = ImGuiKey::ImGuiKey_LeftBracket; - m.attr("ImGuiKey_Backslash") = ImGuiKey::ImGuiKey_Backslash; - m.attr("ImGuiKey_RightBracket") = ImGuiKey::ImGuiKey_RightBracket; - m.attr("ImGuiKey_GraveAccent") = ImGuiKey::ImGuiKey_GraveAccent; - m.attr("ImGuiKey_CapsLock") = ImGuiKey::ImGuiKey_CapsLock; - m.attr("ImGuiKey_ScrollLock") = ImGuiKey::ImGuiKey_ScrollLock; - m.attr("ImGuiKey_NumLock") = ImGuiKey::ImGuiKey_NumLock; - m.attr("ImGuiKey_PrintScreen") = ImGuiKey::ImGuiKey_PrintScreen; - m.attr("ImGuiKey_Pause") = ImGuiKey::ImGuiKey_Pause; - m.attr("ImGuiKey_Keypad0") = ImGuiKey::ImGuiKey_Keypad0; - m.attr("ImGuiKey_Keypad1") = ImGuiKey::ImGuiKey_Keypad1; - m.attr("ImGuiKey_Keypad2") = ImGuiKey::ImGuiKey_Keypad2; - m.attr("ImGuiKey_Keypad3") = ImGuiKey::ImGuiKey_Keypad3; - m.attr("ImGuiKey_Keypad4") = ImGuiKey::ImGuiKey_Keypad4; - m.attr("ImGuiKey_Keypad5") = ImGuiKey::ImGuiKey_Keypad5; - m.attr("ImGuiKey_Keypad6") = ImGuiKey::ImGuiKey_Keypad6; - m.attr("ImGuiKey_Keypad7") = ImGuiKey::ImGuiKey_Keypad7; - m.attr("ImGuiKey_Keypad8") = ImGuiKey::ImGuiKey_Keypad8; - m.attr("ImGuiKey_Keypad9") = ImGuiKey::ImGuiKey_Keypad9; - m.attr("ImGuiKey_KeypadDecimal") = ImGuiKey::ImGuiKey_KeypadDecimal; - m.attr("ImGuiKey_KeypadDivide") = ImGuiKey::ImGuiKey_KeypadDivide; - m.attr("ImGuiKey_KeypadMultiply") = ImGuiKey::ImGuiKey_KeypadMultiply; - m.attr("ImGuiKey_KeypadSubtract") = ImGuiKey::ImGuiKey_KeypadSubtract; - m.attr("ImGuiKey_KeypadAdd") = ImGuiKey::ImGuiKey_KeypadAdd; - m.attr("ImGuiKey_KeypadEnter") = ImGuiKey::ImGuiKey_KeypadEnter; - m.attr("ImGuiKey_KeypadEqual") = ImGuiKey::ImGuiKey_KeypadEqual; - m.attr("ImGuiKey_AppBack") = ImGuiKey::ImGuiKey_AppBack; - m.attr("ImGuiKey_AppForward") = ImGuiKey::ImGuiKey_AppForward; - m.attr("ImGuiKey_GamepadStart") = ImGuiKey::ImGuiKey_GamepadStart; - m.attr("ImGuiKey_GamepadBack") = ImGuiKey::ImGuiKey_GamepadBack; - m.attr("ImGuiKey_GamepadFaceUp") = ImGuiKey::ImGuiKey_GamepadFaceUp; - m.attr("ImGuiKey_GamepadFaceDown") = ImGuiKey::ImGuiKey_GamepadFaceDown; - m.attr("ImGuiKey_GamepadFaceLeft") = ImGuiKey::ImGuiKey_GamepadFaceLeft; - m.attr("ImGuiKey_GamepadFaceRight") = ImGuiKey::ImGuiKey_GamepadFaceRight; - m.attr("ImGuiKey_GamepadDpadUp") = ImGuiKey::ImGuiKey_GamepadDpadUp; - m.attr("ImGuiKey_GamepadDpadDown") = ImGuiKey::ImGuiKey_GamepadDpadDown; - m.attr("ImGuiKey_GamepadDpadLeft") = ImGuiKey::ImGuiKey_GamepadDpadLeft; - m.attr("ImGuiKey_GamepadDpadRight") = ImGuiKey::ImGuiKey_GamepadDpadRight; - m.attr("ImGuiKey_GamepadL1") = ImGuiKey::ImGuiKey_GamepadL1; - m.attr("ImGuiKey_GamepadR1") = ImGuiKey::ImGuiKey_GamepadR1; - m.attr("ImGuiKey_GamepadL2") = ImGuiKey::ImGuiKey_GamepadL2; - m.attr("ImGuiKey_GamepadR2") = ImGuiKey::ImGuiKey_GamepadR2; - m.attr("ImGuiKey_GamepadL3") = ImGuiKey::ImGuiKey_GamepadL3; - m.attr("ImGuiKey_GamepadR3") = ImGuiKey::ImGuiKey_GamepadR3; - m.attr("ImGuiKey_GamepadLStickUp") = ImGuiKey::ImGuiKey_GamepadLStickUp; - m.attr("ImGuiKey_GamepadLStickDown") = ImGuiKey::ImGuiKey_GamepadLStickDown; - m.attr("ImGuiKey_GamepadLStickLeft") = ImGuiKey::ImGuiKey_GamepadLStickLeft; - m.attr("ImGuiKey_GamepadLStickRight") = ImGuiKey::ImGuiKey_GamepadLStickRight; - m.attr("ImGuiKey_GamepadRStickUp") = ImGuiKey::ImGuiKey_GamepadRStickUp; - m.attr("ImGuiKey_GamepadRStickDown") = ImGuiKey::ImGuiKey_GamepadRStickDown; - m.attr("ImGuiKey_GamepadRStickLeft") = ImGuiKey::ImGuiKey_GamepadRStickLeft; - m.attr("ImGuiKey_GamepadRStickRight") = ImGuiKey::ImGuiKey_GamepadRStickRight; - m.attr("ImGuiKey_ModCtrl") = ImGuiKey::ImGuiKey_ModCtrl; - m.attr("ImGuiKey_ModShift") = ImGuiKey::ImGuiKey_ModShift; - m.attr("ImGuiKey_ModAlt") = ImGuiKey::ImGuiKey_ModAlt; - m.attr("ImGuiKey_ModSuper") = ImGuiKey::ImGuiKey_ModSuper; - - m.attr("ImGuiMod_None") = static_cast(ImGuiMod_None); - m.attr("ImGuiMod_Ctrl") = static_cast(ImGuiMod_Ctrl); - m.attr("ImGuiMod_Shift") = static_cast(ImGuiMod_Shift); - m.attr("ImGuiMod_Alt") = static_cast(ImGuiMod_Alt); - m.attr("ImGuiMod_Super") = static_cast(ImGuiMod_Super); - m.attr("ImGuiMod_Mask_") = static_cast(ImGuiMod_Mask_); - - m.attr("ImGuiConfigFlags_None") = static_cast(ImGuiConfigFlags_None); - m.attr("ImGuiConfigFlags_NavEnableKeyboard") = static_cast(ImGuiConfigFlags_NavEnableKeyboard); - m.attr("ImGuiConfigFlags_NavEnableGamepad") = static_cast(ImGuiConfigFlags_NavEnableGamepad); - m.attr("ImGuiConfigFlags_NavEnableSetMousePos") = static_cast(ImGuiConfigFlags_NavEnableSetMousePos); - m.attr("ImGuiConfigFlags_NavNoCaptureKeyboard") = static_cast(ImGuiConfigFlags_NavNoCaptureKeyboard); - m.attr("ImGuiConfigFlags_NoMouse") = static_cast(ImGuiConfigFlags_NoMouse); - m.attr("ImGuiConfigFlags_NoMouseCursorChange") = static_cast(ImGuiConfigFlags_NoMouseCursorChange); - m.attr("ImGuiConfigFlags_IsSRGB") = static_cast(ImGuiConfigFlags_IsSRGB); - m.attr("ImGuiConfigFlags_IsTouchScreen") = static_cast(ImGuiConfigFlags_IsTouchScreen); - - m.attr("ImGuiBackendFlags_None") = static_cast(ImGuiBackendFlags_None); - m.attr("ImGuiBackendFlags_HasGamepad") = static_cast(ImGuiBackendFlags_HasGamepad); - m.attr("ImGuiBackendFlags_HasMouseCursors") = static_cast(ImGuiBackendFlags_HasMouseCursors); - m.attr("ImGuiBackendFlags_HasSetMousePos") = static_cast(ImGuiBackendFlags_HasSetMousePos); - m.attr("ImGuiBackendFlags_RendererHasVtxOffset") = static_cast(ImGuiBackendFlags_RendererHasVtxOffset); - - m.attr("ImGuiCol_Text") = static_cast(ImGuiCol_Text); - m.attr("ImGuiCol_TextDisabled") = static_cast(ImGuiCol_TextDisabled); - m.attr("ImGuiCol_WindowBg") = static_cast(ImGuiCol_WindowBg); - m.attr("ImGuiCol_ChildBg") = static_cast(ImGuiCol_ChildBg); - m.attr("ImGuiCol_PopupBg") = static_cast(ImGuiCol_PopupBg); - m.attr("ImGuiCol_Border") = static_cast(ImGuiCol_Border); - m.attr("ImGuiCol_BorderShadow") = static_cast(ImGuiCol_BorderShadow); - m.attr("ImGuiCol_FrameBg") = static_cast(ImGuiCol_FrameBg); - m.attr("ImGuiCol_FrameBgHovered") = static_cast(ImGuiCol_FrameBgHovered); - m.attr("ImGuiCol_FrameBgActive") = static_cast(ImGuiCol_FrameBgActive); - m.attr("ImGuiCol_TitleBg") = static_cast(ImGuiCol_TitleBg); - m.attr("ImGuiCol_TitleBgActive") = static_cast(ImGuiCol_TitleBgActive); - m.attr("ImGuiCol_TitleBgCollapsed") = static_cast(ImGuiCol_TitleBgCollapsed); - m.attr("ImGuiCol_MenuBarBg") = static_cast(ImGuiCol_MenuBarBg); - m.attr("ImGuiCol_ScrollbarBg") = static_cast(ImGuiCol_ScrollbarBg); - m.attr("ImGuiCol_ScrollbarGrab") = static_cast(ImGuiCol_ScrollbarGrab); - m.attr("ImGuiCol_ScrollbarGrabHovered") = static_cast(ImGuiCol_ScrollbarGrabHovered); - 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); - m.attr("ImGuiCol_ButtonActive") = static_cast(ImGuiCol_ButtonActive); - m.attr("ImGuiCol_Header") = static_cast(ImGuiCol_Header); - m.attr("ImGuiCol_HeaderHovered") = static_cast(ImGuiCol_HeaderHovered); - m.attr("ImGuiCol_HeaderActive") = static_cast(ImGuiCol_HeaderActive); - m.attr("ImGuiCol_Separator") = static_cast(ImGuiCol_Separator); - m.attr("ImGuiCol_SeparatorHovered") = static_cast(ImGuiCol_SeparatorHovered); - m.attr("ImGuiCol_SeparatorActive") = static_cast(ImGuiCol_SeparatorActive); - 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_TabHovered") = static_cast(ImGuiCol_TabHovered); - 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_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); - - m.attr("ImGuiStyleVar_Alpha") = static_cast(ImGuiStyleVar_Alpha); - m.attr("ImGuiStyleVar_WindowPadding") = static_cast(ImGuiStyleVar_WindowPadding); - m.attr("ImGuiStyleVar_WindowRounding") = static_cast(ImGuiStyleVar_WindowRounding); - m.attr("ImGuiStyleVar_WindowBorderSize") = static_cast(ImGuiStyleVar_WindowBorderSize); - m.attr("ImGuiStyleVar_WindowMinSize") = static_cast(ImGuiStyleVar_WindowMinSize); - m.attr("ImGuiStyleVar_WindowTitleAlign") = static_cast(ImGuiStyleVar_WindowTitleAlign); - m.attr("ImGuiStyleVar_ChildRounding") = static_cast(ImGuiStyleVar_ChildRounding); - m.attr("ImGuiStyleVar_ChildBorderSize") = static_cast(ImGuiStyleVar_ChildBorderSize); - m.attr("ImGuiStyleVar_PopupRounding") = static_cast(ImGuiStyleVar_PopupRounding); - m.attr("ImGuiStyleVar_PopupBorderSize") = static_cast(ImGuiStyleVar_PopupBorderSize); - m.attr("ImGuiStyleVar_FramePadding") = static_cast(ImGuiStyleVar_FramePadding); - m.attr("ImGuiStyleVar_FrameRounding") = static_cast(ImGuiStyleVar_FrameRounding); - m.attr("ImGuiStyleVar_FrameBorderSize") = static_cast(ImGuiStyleVar_FrameBorderSize); - m.attr("ImGuiStyleVar_ItemSpacing") = static_cast(ImGuiStyleVar_ItemSpacing); - m.attr("ImGuiStyleVar_ItemInnerSpacing") = static_cast(ImGuiStyleVar_ItemInnerSpacing); - m.attr("ImGuiStyleVar_IndentSpacing") = static_cast(ImGuiStyleVar_IndentSpacing); - m.attr("ImGuiStyleVar_ScrollbarSize") = static_cast(ImGuiStyleVar_ScrollbarSize); - m.attr("ImGuiStyleVar_ScrollbarRounding") = static_cast(ImGuiStyleVar_ScrollbarRounding); - m.attr("ImGuiStyleVar_GrabMinSize") = static_cast(ImGuiStyleVar_GrabMinSize); - m.attr("ImGuiStyleVar_GrabRounding") = static_cast(ImGuiStyleVar_GrabRounding); - m.attr("ImGuiStyleVar_TabRounding") = static_cast(ImGuiStyleVar_TabRounding); - m.attr("ImGuiStyleVar_ButtonTextAlign") = static_cast(ImGuiStyleVar_ButtonTextAlign); - m.attr("ImGuiStyleVar_SelectableTextAlign") = static_cast(ImGuiStyleVar_SelectableTextAlign); - m.attr("ImGuiStyleVar_COUNT") = static_cast(ImGuiStyleVar_COUNT); - - m.attr("ImGuiColorEditFlags_None") = static_cast(ImGuiColorEditFlags_None); - m.attr("ImGuiColorEditFlags_NoAlpha") = static_cast(ImGuiColorEditFlags_NoAlpha); - m.attr("ImGuiColorEditFlags_NoPicker") = static_cast(ImGuiColorEditFlags_NoPicker); - m.attr("ImGuiColorEditFlags_NoOptions") = static_cast(ImGuiColorEditFlags_NoOptions); - m.attr("ImGuiColorEditFlags_NoSmallPreview") = static_cast(ImGuiColorEditFlags_NoSmallPreview); - m.attr("ImGuiColorEditFlags_NoInputs") = static_cast(ImGuiColorEditFlags_NoInputs); - m.attr("ImGuiColorEditFlags_NoTooltip") = static_cast(ImGuiColorEditFlags_NoTooltip); - m.attr("ImGuiColorEditFlags_NoLabel") = static_cast(ImGuiColorEditFlags_NoLabel); - m.attr("ImGuiColorEditFlags_NoSidePreview") = static_cast(ImGuiColorEditFlags_NoSidePreview); - m.attr("ImGuiColorEditFlags_NoDragDrop") = static_cast(ImGuiColorEditFlags_NoDragDrop); - m.attr("ImGuiColorEditFlags_NoBorder") = static_cast(ImGuiColorEditFlags_NoBorder); - m.attr("ImGuiColorEditFlags_AlphaBar") = static_cast(ImGuiColorEditFlags_AlphaBar); - m.attr("ImGuiColorEditFlags_AlphaPreview") = static_cast(ImGuiColorEditFlags_AlphaPreview); - m.attr("ImGuiColorEditFlags_AlphaPreviewHalf") = static_cast(ImGuiColorEditFlags_AlphaPreviewHalf); - m.attr("ImGuiColorEditFlags_HDR") = static_cast(ImGuiColorEditFlags_HDR); - m.attr("ImGuiColorEditFlags_DisplayRGB") = static_cast(ImGuiColorEditFlags_DisplayRGB); - m.attr("ImGuiColorEditFlags_DisplayHSV") = static_cast(ImGuiColorEditFlags_DisplayHSV); - m.attr("ImGuiColorEditFlags_DisplayHex") = static_cast(ImGuiColorEditFlags_DisplayHex); - m.attr("ImGuiColorEditFlags_Uint8") = static_cast(ImGuiColorEditFlags_Uint8); - m.attr("ImGuiColorEditFlags_Float") = static_cast(ImGuiColorEditFlags_Float); - m.attr("ImGuiColorEditFlags_PickerHueBar") = static_cast(ImGuiColorEditFlags_PickerHueBar); - m.attr("ImGuiColorEditFlags_PickerHueWheel") = static_cast(ImGuiColorEditFlags_PickerHueWheel); - m.attr("ImGuiColorEditFlags_InputRGB") = static_cast(ImGuiColorEditFlags_InputRGB); - m.attr("ImGuiColorEditFlags_InputHSV") = static_cast(ImGuiColorEditFlags_InputHSV); - - m.attr("ImGuiMouseButton_Left") = static_cast(ImGuiMouseButton_Left); - m.attr("ImGuiMouseButton_Right") = static_cast(ImGuiMouseButton_Right); - m.attr("ImGuiMouseButton_Middle") = static_cast(ImGuiMouseButton_Middle); - m.attr("ImGuiMouseButton_COUNT") = static_cast(ImGuiMouseButton_COUNT); - - m.attr("ImGuiMouseCursor_None") = static_cast(ImGuiMouseCursor_None); - m.attr("ImGuiMouseCursor_Arrow") = static_cast(ImGuiMouseCursor_Arrow); - m.attr("ImGuiMouseCursor_TextInput") = static_cast(ImGuiMouseCursor_TextInput); - m.attr("ImGuiMouseCursor_ResizeAll") = static_cast(ImGuiMouseCursor_ResizeAll); - m.attr("ImGuiMouseCursor_ResizeNS") = static_cast(ImGuiMouseCursor_ResizeNS); - m.attr("ImGuiMouseCursor_ResizeEW") = static_cast(ImGuiMouseCursor_ResizeEW); - m.attr("ImGuiMouseCursor_ResizeNESW") = static_cast(ImGuiMouseCursor_ResizeNESW); - m.attr("ImGuiMouseCursor_ResizeNWSE") = static_cast(ImGuiMouseCursor_ResizeNWSE); - m.attr("ImGuiMouseCursor_Hand") = static_cast(ImGuiMouseCursor_Hand); - m.attr("ImGuiMouseCursor_NotAllowed") = static_cast(ImGuiMouseCursor_NotAllowed); - m.attr("ImGuiMouseCursor_COUNT") = static_cast(ImGuiMouseCursor_COUNT); - - m.attr("ImGuiCond_Always") = static_cast(ImGuiCond_Always); - m.attr("ImGuiCond_Once") = static_cast(ImGuiCond_Once); - m.attr("ImGuiCond_FirstUseEver") = static_cast(ImGuiCond_FirstUseEver); - m.attr("ImGuiCond_Appearing") = static_cast(ImGuiCond_Appearing); - - // ImDrawFlags - m.attr("ImDrawFlags_None") = static_cast(ImDrawFlags_None); - m.attr("ImDrawFlags_Closed") = static_cast(ImDrawFlags_Closed); - m.attr("ImDrawFlags_RoundCornersTopLeft") = static_cast(ImDrawFlags_RoundCornersTopLeft); - m.attr("ImDrawFlags_RoundCornersTopRight") = static_cast(ImDrawFlags_RoundCornersTopRight); - m.attr("ImDrawFlags_RoundCornersBottomLeft") = static_cast(ImDrawFlags_RoundCornersBottomLeft); - m.attr("ImDrawFlags_RoundCornersBottomRight") = static_cast(ImDrawFlags_RoundCornersBottomRight); - m.attr("ImDrawFlags_RoundCornersNone") = static_cast(ImDrawFlags_RoundCornersNone); - m.attr("ImDrawFlags_RoundCornersTop") = static_cast(ImDrawFlags_RoundCornersTop); - m.attr("ImDrawFlags_RoundCornersBottom") = static_cast(ImDrawFlags_RoundCornersBottom); - m.attr("ImDrawFlags_RoundCornersLeft") = static_cast(ImDrawFlags_RoundCornersLeft); - m.attr("ImDrawFlags_RoundCornersRight") = static_cast(ImDrawFlags_RoundCornersRight); - m.attr("ImDrawFlags_RoundCornersAll") = static_cast(ImDrawFlags_RoundCornersAll); - -} diff --git a/src/cpp/imgui/imgui.cpp b/src/cpp/imgui/imgui.cpp new file mode 100644 index 0000000..20f21c1 --- /dev/null +++ b/src/cpp/imgui/imgui.cpp @@ -0,0 +1,128 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include + +void bind_imgui_enums(nb::module_& m); +void bind_imgui_structs(nb::module_& m); +void bind_imgui_macros(nb::module_& m); +void bind_imgui_io(nb::module_& m); +void bind_imgui_style(nb::module_& m); +void bind_imgui_drawlist(nb::module_& m); +void bind_imgui_fonts(nb::module_& m); + +void bind_imgui_api_main(nb::module_& m); +void bind_imgui_api_context_creation(nb::module_& m); +void bind_imgui_api_demo_debug(nb::module_& m); +void bind_imgui_api_styles(nb::module_& m); +void bind_imgui_api_windows(nb::module_& m); +void bind_imgui_api_child_windows(nb::module_& m); +void bind_imgui_api_window_utilities(nb::module_& m); +void bind_imgui_api_window_manipulation(nb::module_& m); +void bind_imgui_api_scrolling(nb::module_& m); +void bind_imgui_api_parameter_stacks(nb::module_& m); +void bind_imgui_api_style_read(nb::module_& m); +void bind_imgui_api_cursor_layout(nb::module_& m); +void bind_imgui_api_id_stack(nb::module_& m); +void bind_imgui_api_widgets_text(nb::module_& m); +void bind_imgui_api_widgets_main(nb::module_& m); +void bind_imgui_api_widgets_images(nb::module_& m); +void bind_imgui_api_widgets_combo(nb::module_& m); +void bind_imgui_api_widgets_drag(nb::module_& m); +void bind_imgui_api_widgets_sliders(nb::module_& m); +void bind_imgui_api_widgets_input(nb::module_& m); +void bind_imgui_api_widgets_color(nb::module_& m); +void bind_imgui_api_widgets_trees(nb::module_& m); +void bind_imgui_api_widgets_selectables(nb::module_& m); +void bind_imgui_api_widgets_listbox(nb::module_& m); +void bind_imgui_api_data_plotting(nb::module_& m); +void bind_imgui_api_menus(nb::module_& m); +void bind_imgui_api_tooltips(nb::module_& m); +void bind_imgui_api_popups(nb::module_& m); +void bind_imgui_api_tables(nb::module_& m); +void bind_imgui_api_columns_legacy(nb::module_& m); +void bind_imgui_api_tab_bars(nb::module_& m); +void bind_imgui_api_logging(nb::module_& m); +void bind_imgui_api_drag_drop(nb::module_& m); +void bind_imgui_api_disabling(nb::module_& m); +void bind_imgui_api_clipping(nb::module_& m); +void bind_imgui_api_focus_activation(nb::module_& m); +void bind_imgui_api_overlapping_items(nb::module_& m); +void bind_imgui_api_item_query(nb::module_& m); +void bind_imgui_api_viewports(nb::module_& m); +void bind_imgui_api_draw_lists(nb::module_& m); +void bind_imgui_api_misc_utils(nb::module_& m); +void bind_imgui_api_text_utils(nb::module_& m); +void bind_imgui_api_color_utils(nb::module_& m); +void bind_imgui_api_inputs_keyboard(nb::module_& m); +void bind_imgui_api_inputs_mouse(nb::module_& m); +void bind_imgui_api_clipboard(nb::module_& m); +void bind_imgui_api_settings(nb::module_& m); +void bind_imgui_api_debug(nb::module_& m); +void bind_imgui_api_allocators(nb::module_& m); + +void bind_imgui(nb::module_& m) { + auto imgui_module = m.def_submodule("imgui", "ImGui bindings"); + bind_imgui_enums(imgui_module); + bind_imgui_structs(imgui_module); + bind_imgui_macros(imgui_module); + bind_imgui_io(imgui_module); + bind_imgui_style(imgui_module); + bind_imgui_drawlist(imgui_module); + bind_imgui_fonts(imgui_module); + + bind_imgui_api_main(imgui_module); + bind_imgui_api_context_creation(imgui_module); + bind_imgui_api_demo_debug(imgui_module); + bind_imgui_api_styles(imgui_module); + bind_imgui_api_windows(imgui_module); + bind_imgui_api_child_windows(imgui_module); + bind_imgui_api_window_utilities(imgui_module); + bind_imgui_api_window_manipulation(imgui_module); + bind_imgui_api_scrolling(imgui_module); + bind_imgui_api_parameter_stacks(imgui_module); + bind_imgui_api_style_read(imgui_module); + bind_imgui_api_cursor_layout(imgui_module); + bind_imgui_api_id_stack(imgui_module); + bind_imgui_api_widgets_text(imgui_module); + bind_imgui_api_widgets_main(imgui_module); + bind_imgui_api_widgets_images(imgui_module); + bind_imgui_api_widgets_combo(imgui_module); + bind_imgui_api_widgets_drag(imgui_module); + bind_imgui_api_widgets_sliders(imgui_module); + bind_imgui_api_widgets_input(imgui_module); + bind_imgui_api_widgets_color(imgui_module); + bind_imgui_api_widgets_trees(imgui_module); + bind_imgui_api_widgets_selectables(imgui_module); + bind_imgui_api_widgets_listbox(imgui_module); + bind_imgui_api_data_plotting(imgui_module); + bind_imgui_api_menus(imgui_module); + bind_imgui_api_tooltips(imgui_module); + bind_imgui_api_popups(imgui_module); + bind_imgui_api_tables(imgui_module); + bind_imgui_api_columns_legacy(imgui_module); + bind_imgui_api_tab_bars(imgui_module); + bind_imgui_api_logging(imgui_module); + bind_imgui_api_drag_drop(imgui_module); + bind_imgui_api_disabling(imgui_module); + bind_imgui_api_clipping(imgui_module); + bind_imgui_api_focus_activation(imgui_module); + bind_imgui_api_overlapping_items(imgui_module); + bind_imgui_api_item_query(imgui_module); + bind_imgui_api_viewports(imgui_module); + bind_imgui_api_draw_lists(imgui_module); + bind_imgui_api_misc_utils(imgui_module); + bind_imgui_api_text_utils(imgui_module); + bind_imgui_api_color_utils(imgui_module); + bind_imgui_api_inputs_keyboard(imgui_module); + bind_imgui_api_inputs_mouse(imgui_module); + bind_imgui_api_clipboard(imgui_module); + bind_imgui_api_settings(imgui_module); + bind_imgui_api_debug(imgui_module); + bind_imgui_api_allocators(imgui_module); +} \ No newline at end of file diff --git a/src/cpp/imgui/imgui_api_allocators.cpp b/src/cpp/imgui/imgui_api_allocators.cpp new file mode 100644 index 0000000..c6715af --- /dev/null +++ b/src/cpp/imgui/imgui_api_allocators.cpp @@ -0,0 +1,19 @@ +// Memory Allocators + +#include "imgui_utils.h" + +// clang-format off + +void bind_imgui_api_allocators(nb::module_& m) { + // IMGUI_API void SetAllocatorFunctions(ImGuiMemAllocFunc alloc_func, ImGuiMemFreeFunc free_func, void* user_data = NULL); + // Not bound - takes function pointers and void* user_data, difficult to bind properly for Python use + + // IMGUI_API void GetAllocatorFunctions(ImGuiMemAllocFunc* p_alloc_func, ImGuiMemFreeFunc* p_free_func, void** p_user_data); + // Not bound - takes function pointers and void* user_data, difficult to bind properly for Python use + + // IMGUI_API void* MemAlloc(size_t size); + m.def("MemAlloc", &ImGui::MemAlloc, nb::arg("size"), nb::rv_policy::reference); + + // IMGUI_API void MemFree(void* ptr); + m.def("MemFree", &ImGui::MemFree, nb::arg("ptr")); +} diff --git a/src/cpp/imgui/imgui_api_child_windows.cpp b/src/cpp/imgui/imgui_api_child_windows.cpp new file mode 100644 index 0000000..aa3e0e3 --- /dev/null +++ b/src/cpp/imgui/imgui_api_child_windows.cpp @@ -0,0 +1,41 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include + +// clang-format off +void bind_imgui_api_child_windows(nb::module_& m) { + + // Child Windows + // IMGUI_API bool BeginChild(const char* str_id, const ImVec2& size = ImVec2(0, 0), ImGuiChildFlags child_flags = 0, ImGuiWindowFlags window_flags = 0); + m.def( + "BeginChild", + [](const char* str_id, Vec2T size, ImGuiChildFlags child_flags, ImGuiWindowFlags window_flags) { + return ImGui::BeginChild(str_id, to_vec2(size), child_flags, window_flags); + }, + nb::arg("str_id"), + nb::arg("size") = Vec2T(0.f, 0.f), + nb::arg("child_flags") = 0, + nb::arg("window_flags") = 0); + + // IMGUI_API bool BeginChild(ImGuiID id, const ImVec2& size = ImVec2(0, 0), ImGuiChildFlags child_flags = 0, ImGuiWindowFlags window_flags = 0); + m.def( + "BeginChild", + [](ImGuiID id, const Vec2T& size, ImGuiChildFlags child_flags, ImGuiWindowFlags window_flags) { + return ImGui::BeginChild(id, to_vec2(size), child_flags, window_flags); + }, + nb::arg("id"), + nb::arg("size") = Vec2T(0.f, 0.f), + nb::arg("child_flags") = 0, + nb::arg("window_flags") = 0); + + // IMGUI_API void EndChild(); + m.def("EndChild", []() { ImGui::EndChild(); }); + +} +// clang-format on diff --git a/src/cpp/imgui/imgui_api_clipboard.cpp b/src/cpp/imgui/imgui_api_clipboard.cpp new file mode 100644 index 0000000..002dfa6 --- /dev/null +++ b/src/cpp/imgui/imgui_api_clipboard.cpp @@ -0,0 +1,13 @@ +// Clipboard Utilities + +#include "imgui_utils.h" + +// clang-format off + +void bind_imgui_api_clipboard(nb::module_& m) { + // IMGUI_API const char* GetClipboardText(); + m.def("GetClipboardText", &ImGui::GetClipboardText); + + // IMGUI_API void SetClipboardText(const char* text); + m.def("SetClipboardText", &ImGui::SetClipboardText, nb::arg("text")); +} diff --git a/src/cpp/imgui/imgui_api_clipping.cpp b/src/cpp/imgui/imgui_api_clipping.cpp new file mode 100644 index 0000000..850ca06 --- /dev/null +++ b/src/cpp/imgui/imgui_api_clipping.cpp @@ -0,0 +1,29 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include + +// clang-format off +void bind_imgui_api_clipping(nb::module_& m) { + + // Clipping + // IMGUI_API void PushClipRect(const ImVec2& clip_rect_min, const ImVec2& clip_rect_max, bool intersect_with_current_clip_rect); + m.def( + "PushClipRect", + [](const Vec2T& clip_rect_min, const Vec2T& clip_rect_max, bool intersect_with_current_clip_rect) { + ImGui::PushClipRect(to_vec2(clip_rect_min), to_vec2(clip_rect_max), intersect_with_current_clip_rect); + }, + nb::arg("clip_rect_min"), + nb::arg("clip_rect_max"), + nb::arg("intersect_with_current_clip_rect")); + + // IMGUI_API void PopClipRect(); + m.def("PopClipRect", []() { ImGui::PopClipRect(); }); + +} +// clang-format on diff --git a/src/cpp/imgui/imgui_api_color_utils.cpp b/src/cpp/imgui/imgui_api_color_utils.cpp new file mode 100644 index 0000000..537247d --- /dev/null +++ b/src/cpp/imgui/imgui_api_color_utils.cpp @@ -0,0 +1,31 @@ +// Color Utilities + +#include "imgui_utils.h" + +// clang-format off + +void bind_imgui_api_color_utils(nb::module_& m) { + // IMGUI_API ImVec4 ColorConvertU32ToFloat4(ImU32 in); + m.def("ColorConvertU32ToFloat4", [](ImU32 in) { + return from_vec4(ImGui::ColorConvertU32ToFloat4(in)); + }, nb::arg("in")); + + // IMGUI_API ImU32 ColorConvertFloat4ToU32(const ImVec4& in); + m.def("ColorConvertFloat4ToU32", [](const Vec4T& in) { + return ImGui::ColorConvertFloat4ToU32(to_vec4(in)); + }, nb::arg("in")); + + // IMGUI_API void ColorConvertRGBtoHSV(float r, float g, float b, float& out_h, float& out_s, float& out_v); + m.def("ColorConvertRGBtoHSV", [](float r, float g, float b) { + float h, s, v; + ImGui::ColorConvertRGBtoHSV(r, g, b, h, s, v); + return std::make_tuple(h, s, v); + }, nb::arg("r"), nb::arg("g"), nb::arg("b")); + + // IMGUI_API void ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b); + m.def("ColorConvertHSVtoRGB", [](float h, float s, float v) { + float r, g, b; + ImGui::ColorConvertHSVtoRGB(h, s, v, r, g, b); + return std::make_tuple(r, g, b); + }, nb::arg("h"), nb::arg("s"), nb::arg("v")); +} diff --git a/src/cpp/imgui/imgui_api_columns_legacy.cpp b/src/cpp/imgui/imgui_api_columns_legacy.cpp new file mode 100644 index 0000000..dff9b50 --- /dev/null +++ b/src/cpp/imgui/imgui_api_columns_legacy.cpp @@ -0,0 +1,59 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include + +// clang-format off +void bind_imgui_api_columns_legacy(nb::module_& m) { + + // Legacy Columns API (prefer using Tables!) + // IMGUI_API void Columns(int count = 1, const char* id = NULL, bool borders = true); + m.def( + "Columns", + [](int count, const char* id, bool borders) { ImGui::Columns(count, id, borders); }, + nb::arg("count") = 1, + nb::arg("id") = nb::none(), + nb::arg("borders") = true); + + // IMGUI_API void NextColumn(); + m.def("NextColumn", []() { ImGui::NextColumn(); }); + + // IMGUI_API int GetColumnIndex(); + m.def("GetColumnIndex", []() { return ImGui::GetColumnIndex(); }); + + // IMGUI_API float GetColumnWidth(int column_index = -1); + m.def( + "GetColumnWidth", + [](int column_index) { return ImGui::GetColumnWidth(column_index); }, + nb::arg("column_index") = -1); + + // IMGUI_API void SetColumnWidth(int column_index, float width); + m.def( + "SetColumnWidth", + [](int column_index, float width) { ImGui::SetColumnWidth(column_index, width); }, + nb::arg("column_index"), + nb::arg("width")); + + // IMGUI_API float GetColumnOffset(int column_index = -1); + m.def( + "GetColumnOffset", + [](int column_index) { return ImGui::GetColumnOffset(column_index); }, + nb::arg("column_index") = -1); + + // IMGUI_API void SetColumnOffset(int column_index, float offset_x); + m.def( + "SetColumnOffset", + [](int column_index, float offset_x) { ImGui::SetColumnOffset(column_index, offset_x); }, + nb::arg("column_index"), + nb::arg("offset_x")); + + // IMGUI_API int GetColumnsCount(); + m.def("GetColumnsCount", []() { return ImGui::GetColumnsCount(); }); + +} +// clang-format on diff --git a/src/cpp/imgui/imgui_api_context_creation.cpp b/src/cpp/imgui/imgui_api_context_creation.cpp new file mode 100644 index 0000000..8184bda --- /dev/null +++ b/src/cpp/imgui/imgui_api_context_creation.cpp @@ -0,0 +1,31 @@ +#include "imgui_utils.h" + +NB_MAKE_OPAQUE(ImGuiContext); + +// clang-format off +void bind_imgui_api_context_creation(nb::module_& m) { + + // Context creation and access + + // IMGUI_API ImGuiContext* CreateContext(ImFontAtlas* shared_font_atlas = NULL); + m.def("CreateContext", [](ImFontAtlas* shared_font_atlas) { + return nb::capsule(ImGui::CreateContext(shared_font_atlas), "ImGuiContext"); + }, nb::arg("shared_font_atlas") = nb::none(), nb::rv_policy::reference); + + // IMGUI_API void DestroyContext(ImGuiContext* ctx = NULL); // NULL = destroy current context + m.def("DestroyContext", [](nb::capsule ctx) { + ImGui::DestroyContext(static_cast(ctx.data("ImGuiContext"))); + }, nb::arg("ctx") = nb::none()); + + // IMGUI_API ImGuiContext* GetCurrentContext(); + m.def("GetCurrentContext", []() { + return nb::capsule(ImGui::GetCurrentContext(), "ImGuiContext"); + }, nb::rv_policy::reference); + + // IMGUI_API void SetCurrentContext(ImGuiContext* ctx); + m.def("SetCurrentContext", [](nb::capsule ctx) { + ImGui::SetCurrentContext(static_cast(ctx.data("ImGuiContext"))); + }, nb::arg("ctx")); + +} +// clang-format on \ No newline at end of file diff --git a/src/cpp/imgui/imgui_api_cursor_layout.cpp b/src/cpp/imgui/imgui_api_cursor_layout.cpp new file mode 100644 index 0000000..35d4774 --- /dev/null +++ b/src/cpp/imgui/imgui_api_cursor_layout.cpp @@ -0,0 +1,114 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include + +// clang-format off +void bind_imgui_api_cursor_layout(nb::module_& m) { + + // Layout cursor positioning + // IMGUI_API ImVec2 GetCursorScreenPos(); + m.def("GetCursorScreenPos", []() { return from_vec2(ImGui::GetCursorScreenPos()); }); + + // IMGUI_API void SetCursorScreenPos(const ImVec2& pos); + m.def( + "SetCursorScreenPos", + [](const Vec2T& pos) { ImGui::SetCursorScreenPos(to_vec2(pos)); }, + nb::arg("pos")); + + // IMGUI_API ImVec2 GetContentRegionAvail(); + m.def("GetContentRegionAvail", []() { return from_vec2(ImGui::GetContentRegionAvail()); }); + + // IMGUI_API ImVec2 GetCursorPos(); + m.def("GetCursorPos", []() { return from_vec2(ImGui::GetCursorPos()); }); + + // IMGUI_API float GetCursorPosX(); + m.def("GetCursorPosX", []() { return ImGui::GetCursorPosX(); }); + + // IMGUI_API float GetCursorPosY(); + m.def("GetCursorPosY", []() { return ImGui::GetCursorPosY(); }); + + // IMGUI_API void SetCursorPos(const ImVec2& local_pos); + m.def( + "SetCursorPos", + [](const Vec2T& local_pos) { ImGui::SetCursorPos(to_vec2(local_pos)); }, + nb::arg("local_pos")); + + // IMGUI_API void SetCursorPosX(float local_x); + m.def( + "SetCursorPosX", + [](float local_x) { ImGui::SetCursorPosX(local_x); }, + nb::arg("local_x")); + + // IMGUI_API void SetCursorPosY(float local_y); + m.def( + "SetCursorPosY", + [](float local_y) { ImGui::SetCursorPosY(local_y); }, + nb::arg("local_y")); + + // IMGUI_API ImVec2 GetCursorStartPos(); + m.def("GetCursorStartPos", []() { return from_vec2(ImGui::GetCursorStartPos()); }); + + // Other layout functions + // IMGUI_API void Separator(); + m.def("Separator", []() { ImGui::Separator(); }); + + // IMGUI_API void SameLine(float offset_from_start_x=0.0f, float spacing=-1.0f); + m.def( + "SameLine", + [](float offset_from_start_x, float spacing) { ImGui::SameLine(offset_from_start_x, spacing); }, + nb::arg("offset_from_start_x") = 0.0f, + nb::arg("spacing") = -1.0f); + + // IMGUI_API void NewLine(); + m.def("NewLine", []() { ImGui::NewLine(); }); + + // IMGUI_API void Spacing(); + m.def("Spacing", []() { ImGui::Spacing(); }); + + // IMGUI_API void Dummy(const ImVec2& size); + m.def( + "Dummy", + [](const Vec2T& size) { ImGui::Dummy(to_vec2(size)); }, + nb::arg("size")); + + // IMGUI_API void Indent(float indent_w = 0.0f); + m.def( + "Indent", + [](float indent_w) { ImGui::Indent(indent_w); }, + nb::arg("indent_w") = 0.0f); + + // IMGUI_API void Unindent(float indent_w = 0.0f); + m.def( + "Unindent", + [](float indent_w) { ImGui::Unindent(indent_w); }, + nb::arg("indent_w") = 0.0f); + + // IMGUI_API void BeginGroup(); + m.def("BeginGroup", []() { ImGui::BeginGroup(); }); + + // IMGUI_API void EndGroup(); + m.def("EndGroup", []() { ImGui::EndGroup(); }); + + // IMGUI_API void AlignTextToFramePadding(); + m.def("AlignTextToFramePadding", []() { ImGui::AlignTextToFramePadding(); }); + + // IMGUI_API float GetTextLineHeight(); + m.def("GetTextLineHeight", []() { return ImGui::GetTextLineHeight(); }); + + // IMGUI_API float GetTextLineHeightWithSpacing(); + m.def("GetTextLineHeightWithSpacing", []() { return ImGui::GetTextLineHeightWithSpacing(); }); + + // IMGUI_API float GetFrameHeight(); + m.def("GetFrameHeight", []() { return ImGui::GetFrameHeight(); }); + + // IMGUI_API float GetFrameHeightWithSpacing(); + m.def("GetFrameHeightWithSpacing", []() { return ImGui::GetFrameHeightWithSpacing(); }); + +} +// clang-format on diff --git a/src/cpp/imgui/imgui_api_data_plotting.cpp b/src/cpp/imgui/imgui_api_data_plotting.cpp new file mode 100644 index 0000000..601cb16 --- /dev/null +++ b/src/cpp/imgui/imgui_api_data_plotting.cpp @@ -0,0 +1,80 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include +#include + +// clang-format off +void bind_imgui_api_data_plotting(nb::module_& m) { + + // Widgets: Data Plotting + // IMGUI_API void PlotLines(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0, 0), int stride = sizeof(float)); + m.def( + "PlotLines", + [](const char* label, const Eigen::Ref& values, int values_offset, const char* overlay_text, float scale_min, float scale_max, const Vec2T& graph_size) { + ImGui::PlotLines(label, values.data(), static_cast(values.size()), values_offset, overlay_text, scale_min, scale_max, to_vec2(graph_size)); + }, + nb::arg("label"), + nb::arg("values"), + nb::arg("values_offset") = 0, + nb::arg("overlay_text") = nb::none(), + nb::arg("scale_min") = FLT_MAX, + nb::arg("scale_max") = FLT_MAX, + nb::arg("graph_size") = Vec2T(0.f, 0.f)); + + // IMGUI_API void PlotLines(const char* label, float(*values_getter)(void* data, int idx), void* data, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0, 0)); + // TODO: Callback version not bound + + // IMGUI_API void PlotHistogram(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0, 0), int stride = sizeof(float)); + m.def( + "PlotHistogram", + [](const char* label, const Eigen::Ref& values, int values_offset, const char* overlay_text, float scale_min, float scale_max, const Vec2T& graph_size) { + ImGui::PlotHistogram(label, values.data(), static_cast(values.size()), values_offset, overlay_text, scale_min, scale_max, to_vec2(graph_size)); + }, + nb::arg("label"), + nb::arg("values"), + nb::arg("values_offset") = 0, + nb::arg("overlay_text") = nb::none(), + nb::arg("scale_min") = FLT_MAX, + nb::arg("scale_max") = FLT_MAX, + nb::arg("graph_size") = Vec2T(0.f, 0.f)); + + // IMGUI_API void PlotHistogram(const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0, 0)); + // TODO: Callback version not bound + + // IMGUI_API void Value(const char* prefix, bool b); + m.def( + "Value", + [](const char* prefix, bool b) { ImGui::Value(prefix, b); }, + nb::arg("prefix"), + nb::arg("b")); + + // IMGUI_API void Value(const char* prefix, int v); + m.def( + "Value", + [](const char* prefix, int v) { ImGui::Value(prefix, v); }, + nb::arg("prefix"), + nb::arg("v")); + + // IMGUI_API void Value(const char* prefix, unsigned int v); + m.def( + "Value", + [](const char* prefix, unsigned int v) { ImGui::Value(prefix, v); }, + nb::arg("prefix"), + nb::arg("v")); + + // IMGUI_API void Value(const char* prefix, float v, const char* float_format = NULL); + m.def( + "Value", + [](const char* prefix, float v, const char* float_format) { ImGui::Value(prefix, v, float_format); }, + nb::arg("prefix"), + nb::arg("v"), + nb::arg("float_format") = nb::none()); + +} +// clang-format on diff --git a/src/cpp/imgui/imgui_api_debug.cpp b/src/cpp/imgui/imgui_api_debug.cpp new file mode 100644 index 0000000..3102900 --- /dev/null +++ b/src/cpp/imgui/imgui_api_debug.cpp @@ -0,0 +1,29 @@ +// Debug Utilities + +#include "imgui_utils.h" + +// clang-format off + +void bind_imgui_api_debug(nb::module_& m) { + + // IMGUI_API void DebugTextEncoding(const char* text); + m.def("DebugTextEncoding", &ImGui::DebugTextEncoding, nb::arg("text")); + + // IMGUI_API void DebugFlashStyleColor(ImGuiCol idx); + m.def("DebugFlashStyleColor", &ImGui::DebugFlashStyleColor, nb::arg("idx")); + + // IMGUI_API void DebugStartItemPicker(); + m.def("DebugStartItemPicker", &ImGui::DebugStartItemPicker); + + // IMGUI_API bool DebugCheckVersionAndDataLayout(const char* version_str, size_t sz_io, size_t sz_style, size_t sz_vec2, size_t sz_vec4, size_t sz_drawvert, size_t sz_drawidx); // This is called by IMGUI_CHECKVERSION() macro. + m.def("DebugCheckVersionAndDataLayout", &ImGui::DebugCheckVersionAndDataLayout, + nb::arg("version_str"), + nb::arg("sz_io"), + nb::arg("sz_style"), + nb::arg("sz_vec2"), + nb::arg("sz_vec4"), + nb::arg("sz_drawvert"), + nb::arg("sz_drawidx")); + + // DebugLog and DebugLogV are variadic - not binding them +} diff --git a/src/cpp/imgui/imgui_api_demo_debug.cpp b/src/cpp/imgui/imgui_api_demo_debug.cpp new file mode 100644 index 0000000..69bc5f1 --- /dev/null +++ b/src/cpp/imgui/imgui_api_demo_debug.cpp @@ -0,0 +1,91 @@ +#include "imgui_utils.h" + +// clang-format off +void bind_imgui_api_demo_debug(nb::module_& m) { + + // Demo, Debug, Information + + // IMGUI_API void ShowDemoWindow(bool* p_open = NULL); + m.def( + "ShowDemoWindow", + [](bool open) { + auto open_ = open; + ImGui::ShowDemoWindow(&open_); + return open_; + }, + nb::arg("open") = true); + + // IMGUI_API void ShowMetricsWindow(bool* p_open = NULL); + m.def( + "ShowMetricsWindow", + [](bool open) { + auto open_ = open; + ImGui::ShowMetricsWindow(&open_); + return open_; + }, + nb::arg("open") = true); + + // IMGUI_API void ShowDebugLogWindow(bool* p_open = NULL); + m.def( + "ShowDebugLogWindow", + [](bool open) { + auto open_ = open; + ImGui::ShowDebugLogWindow(&open_); + return open_; + }, + nb::arg("open") = true); + + // IMGUI_API void ShowIDStackToolWindow(bool* p_open = NULL); + m.def( + "ShowIDStackToolWindow", + [](bool open) { + auto open_ = open; + ImGui::ShowIDStackToolWindow(&open_); + return open_; + }, + nb::arg("open") = true); + + // IMGUI_API void ShowAboutWindow(bool* p_open = NULL); + m.def( + "ShowAboutWindow", + [](bool open) { + auto open_ = open; + ImGui::ShowAboutWindow(&open_); + return open_; + }, + nb::arg("open") = true); + + // IMGUI_API void ShowStyleEditor(ImGuiStyle* ref = NULL); + m.def( + "ShowStyleEditor", + [](bool open) { + auto open_ = open; + ImGui::ShowStyleEditor(nullptr); + return open_; + }, + nb::arg("open") = true); + + // IMGUI_API bool ShowStyleSelector(const char* label); + m.def( + "ShowStyleSelector", + [](const char* label) { + return ImGui::ShowStyleSelector(label); + }, + nb::arg("label")); + + // IMGUI_API void ShowFontSelector(const char* label); + m.def( + "ShowFontSelector", + [](const char* label) { + ImGui::ShowFontSelector(label); + }, + nb::arg("label")); + + // IMGUI_API void ShowUserGuide(); + m.def("ShowUserGuide", []() { ImGui::ShowUserGuide(); }); + + // IMGUI_API const char* GetVersion(); + m.def("GetVersion", []() { return ImGui::GetVersion(); }); + +} +// clang-format on \ No newline at end of file diff --git a/src/cpp/imgui/imgui_api_disabling.cpp b/src/cpp/imgui/imgui_api_disabling.cpp new file mode 100644 index 0000000..fe8eeb4 --- /dev/null +++ b/src/cpp/imgui/imgui_api_disabling.cpp @@ -0,0 +1,25 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include + +// clang-format off +void bind_imgui_api_disabling(nb::module_& m) { + + // Disabling [BETA API] + // IMGUI_API void BeginDisabled(bool disabled = true); + m.def( + "BeginDisabled", + [](bool disabled) { ImGui::BeginDisabled(disabled); }, + nb::arg("disabled") = true); + + // IMGUI_API void EndDisabled(); + m.def("EndDisabled", []() { ImGui::EndDisabled(); }); + +} +// clang-format on diff --git a/src/cpp/imgui/imgui_api_drag_drop.cpp b/src/cpp/imgui/imgui_api_drag_drop.cpp new file mode 100644 index 0000000..6f86faf --- /dev/null +++ b/src/cpp/imgui/imgui_api_drag_drop.cpp @@ -0,0 +1,55 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include +#include + +// clang-format off +void bind_imgui_api_drag_drop(nb::module_& m) { + + // Drag and Drop + // IMGUI_API bool BeginDragDropSource(ImGuiDragDropFlags flags = 0); + m.def( + "BeginDragDropSource", + [](ImGuiDragDropFlags flags) { return ImGui::BeginDragDropSource(flags); }, + nb::arg("flags") = 0); + + // IMGUI_API bool SetDragDropPayload(const char* type, const void* data, size_t sz, ImGuiCond cond = 0); + m.def( + "SetDragDropPayload", + [](const char* type, const std::string& data, ImGuiCond cond) { + return ImGui::SetDragDropPayload(type, data.c_str(), data.size(), cond); + }, + nb::arg("type"), + nb::arg("data"), + nb::arg("cond") = 0); + + // IMGUI_API void EndDragDropSource(); + m.def("EndDragDropSource", []() { ImGui::EndDragDropSource(); }); + + // IMGUI_API bool BeginDragDropTarget(); + m.def("BeginDragDropTarget", []() { return ImGui::BeginDragDropTarget(); }); + + // IMGUI_API const ImGuiPayload* AcceptDragDropPayload(const char* type, ImGuiDragDropFlags flags = 0); + m.def( + "AcceptDragDropPayload", + [](const char* type, ImGuiDragDropFlags flags) { + return ImGui::AcceptDragDropPayload(type, flags); + }, + nb::arg("type"), + nb::arg("flags") = 0, + nb::rv_policy::reference); + + // IMGUI_API void EndDragDropTarget(); + m.def("EndDragDropTarget", []() { ImGui::EndDragDropTarget(); }); + + // IMGUI_API const ImGuiPayload* GetDragDropPayload(); + m.def("GetDragDropPayload", []() { return ImGui::GetDragDropPayload(); }, nb::rv_policy::reference); + +} +// clang-format on diff --git a/src/cpp/imgui/imgui_api_draw_lists.cpp b/src/cpp/imgui/imgui_api_draw_lists.cpp new file mode 100644 index 0000000..cc73149 --- /dev/null +++ b/src/cpp/imgui/imgui_api_draw_lists.cpp @@ -0,0 +1,13 @@ +// Background/Foreground Draw Lists + +#include "imgui_utils.h" + +// clang-format off + +void bind_imgui_api_draw_lists(nb::module_& m) { + // IMGUI_API ImDrawList* GetBackgroundDrawList(); // get background draw list for the viewport associated to the current window. this draw list will be the first rendering one. Useful to quickly draw shapes/text behind dear imgui contents. + m.def("GetBackgroundDrawList", &ImGui::GetBackgroundDrawList, nb::rv_policy::reference); + + // IMGUI_API ImDrawList* GetForegroundDrawList(); // get foreground draw list for the viewport associated to the current window. this draw list will be the last rendered one. Useful to quickly draw shapes/text over dear imgui contents. + m.def("GetForegroundDrawList", &ImGui::GetForegroundDrawList, nb::rv_policy::reference); +} diff --git a/src/cpp/imgui/imgui_api_focus_activation.cpp b/src/cpp/imgui/imgui_api_focus_activation.cpp new file mode 100644 index 0000000..f64f60e --- /dev/null +++ b/src/cpp/imgui/imgui_api_focus_activation.cpp @@ -0,0 +1,31 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include + +// clang-format off +void bind_imgui_api_focus_activation(nb::module_& m) { + + // Focus, Activation + // IMGUI_API void SetItemDefaultFocus(); + m.def("SetItemDefaultFocus", []() { ImGui::SetItemDefaultFocus(); }); + + // IMGUI_API void SetKeyboardFocusHere(int offset = 0); + m.def( + "SetKeyboardFocusHere", + [](int offset) { ImGui::SetKeyboardFocusHere(offset); }, + nb::arg("offset") = 0); + + // IMGUI_API void SetNavCursorVisible(bool visible); + m.def( + "SetNavCursorVisible", + [](bool visible) { ImGui::SetNavCursorVisible(visible); }, + nb::arg("visible")); + +} +// clang-format on diff --git a/src/cpp/imgui/imgui_api_id_stack.cpp b/src/cpp/imgui/imgui_api_id_stack.cpp new file mode 100644 index 0000000..459f48a --- /dev/null +++ b/src/cpp/imgui/imgui_api_id_stack.cpp @@ -0,0 +1,55 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include + +// clang-format off +void bind_imgui_api_id_stack(nb::module_& m) { + + // ID stack/scopes + // IMGUI_API void PushID(const char* str_id); + m.def( + "PushID", + [](const char* str_id) { ImGui::PushID(str_id); }, + nb::arg("str_id")); + + // IMGUI_API void PushID(const char* str_id_begin, const char* str_id_end); + // TODO: bind this overload + + // IMGUI_API void PushID(const void* ptr_id); + // TODO: bind this overload + + // IMGUI_API void PushID(int int_id); + m.def( + "PushID", + [](int int_id) { ImGui::PushID(int_id); }, + nb::arg("int_id")); + + // IMGUI_API void PopID(); + m.def("PopID", []() { ImGui::PopID(); }); + + // IMGUI_API ImGuiID GetID(const char* str_id); + m.def( + "GetID", + [](const char* str_id) { return ImGui::GetID(str_id); }, + nb::arg("str_id")); + + // IMGUI_API ImGuiID GetID(const char* str_id_begin, const char* str_id_end); + // TODO: bind this overload + + // IMGUI_API ImGuiID GetID(const void* ptr_id); + // TODO: bind this overload + + // IMGUI_API ImGuiID GetID(int int_id); + m.def( + "GetID", + [](int int_id) { return ImGui::GetID(int_id); }, + nb::arg("int_id")); + +} +// clang-format on diff --git a/src/cpp/imgui/imgui_api_inputs_keyboard.cpp b/src/cpp/imgui/imgui_api_inputs_keyboard.cpp new file mode 100644 index 0000000..a69850b --- /dev/null +++ b/src/cpp/imgui/imgui_api_inputs_keyboard.cpp @@ -0,0 +1,39 @@ +// Inputs Utilities: Keyboard + +#include "imgui_utils.h" + +// clang-format off + +void bind_imgui_api_inputs_keyboard(nb::module_& m) { + // IMGUI_API bool IsKeyDown(ImGuiKey key); // is key being held. + m.def("IsKeyDown", &ImGui::IsKeyDown, nb::arg("key")); + + // IMGUI_API bool IsKeyPressed(ImGuiKey key, bool repeat = true); // was key pressed (went from !Down to Down)? if repeat=true, uses io.KeyRepeatDelay / KeyRepeatRate + m.def("IsKeyPressed", &ImGui::IsKeyPressed, nb::arg("key"), nb::arg("repeat") = true); + + // IMGUI_API bool IsKeyReleased(ImGuiKey key); // was key released (went from Down to !Down)? + m.def("IsKeyReleased", &ImGui::IsKeyReleased, nb::arg("key")); + + // IMGUI_API bool IsKeyChordPressed(ImGuiKeyChord key_chord); // was key chord (mods + key) pressed, e.g. you can pass 'ImGuiMod_Ctrl | ImGuiKey_S' as a key-chord. This doesn't do any routing or focus check, please consider using Shortcut() function instead. + m.def("IsKeyChordPressed", &ImGui::IsKeyChordPressed, nb::arg("key_chord")); + + // IMGUI_API int GetKeyPressedAmount(ImGuiKey key, float repeat_delay, float rate); // uses provided repeat rate/delay. return a count, most often 0 or 1 but might be >1 if RepeatRate is small enough that DeltaTime > RepeatRate + m.def("GetKeyPressedAmount", &ImGui::GetKeyPressedAmount, nb::arg("key"), nb::arg("repeat_delay"), nb::arg("rate")); + + // IMGUI_API const char* GetKeyName(ImGuiKey key); // [DEBUG] returns English name of the key. Those names a provided for debugging purpose and are not meant to be saved persistently not compared. + m.def("GetKeyName", &ImGui::GetKeyName, nb::arg("key")); + + // IMGUI_API void SetNextFrameWantCaptureKeyboard(bool want_capture_keyboard); // Override io.WantCaptureKeyboard flag next frame (said flag is left for your application to handle, typically when true it instructs your app to ignore inputs). e.g. force capture keyboard when your widget is being hovered. This is equivalent to setting "io.WantCaptureKeyboard = want_capture_keyboard"; after the next NewFrame() call. + m.def("SetNextFrameWantCaptureKeyboard", &ImGui::SetNextFrameWantCaptureKeyboard, nb::arg("want_capture_keyboard")); + + // Shortcut Testing & Routing [BETA] + // IMGUI_API bool Shortcut(ImGuiKeyChord key_chord, ImGuiInputFlags flags = 0); + // m.def("Shortcut", &ImGui::Shortcut, nb::arg("key_chord"), nb::arg("flags") = 0); + + // IMGUI_API void SetNextItemShortcut(ImGuiKeyChord key_chord, ImGuiInputFlags flags = 0); + // m.def("SetNextItemShortcut", &ImGui::SetNextItemShortcut, nb::arg("key_chord"), nb::arg("flags") = 0); + + // Key Ownership [BETA] + // IMGUI_API void SetItemKeyOwner(ImGuiKey key); // Set key owner to last item ID if it is hovered or active. Equivalent to 'if (IsItemHovered() || IsItemActive()) { SetKeyOwner(key, GetItemID());'. + // m.def("SetItemKeyOwner", &ImGui::SetItemKeyOwner, nb::arg("key")); +} diff --git a/src/cpp/imgui/imgui_api_inputs_mouse.cpp b/src/cpp/imgui/imgui_api_inputs_mouse.cpp new file mode 100644 index 0000000..7a2d080 --- /dev/null +++ b/src/cpp/imgui/imgui_api_inputs_mouse.cpp @@ -0,0 +1,71 @@ +// Inputs Utilities: Mouse + +#include "imgui_utils.h" + +// clang-format off + +void bind_imgui_api_inputs_mouse(nb::module_& m) { + // IMGUI_API bool IsMouseDown(ImGuiMouseButton button); // is mouse button held? + m.def("IsMouseDown", &ImGui::IsMouseDown, nb::arg("button")); + + // IMGUI_API bool IsMouseClicked(ImGuiMouseButton button, bool repeat = false); // did mouse button clicked? (went from !Down to Down). Same as GetMouseClickedCount() == 1. + m.def("IsMouseClicked", &ImGui::IsMouseClicked, nb::arg("button"), nb::arg("repeat") = false); + + // IMGUI_API bool IsMouseReleased(ImGuiMouseButton button); // did mouse button released? (went from Down to !Down) + m.def("IsMouseReleased", &ImGui::IsMouseReleased, nb::arg("button")); + + // IMGUI_API bool IsMouseDoubleClicked(ImGuiMouseButton button); // did mouse button double-clicked? Same as GetMouseClickedCount() == 2. (note that a double-click will also report IsMouseClicked() == true) + m.def("IsMouseDoubleClicked", &ImGui::IsMouseDoubleClicked, nb::arg("button")); + + // IMGUI_API bool IsMouseReleasedWithDelay(ImGuiMouseButton button, float delay); // was a mouse release right after a double-click that was previously latched by a mouse click with delay? + m.def("IsMouseReleasedWithDelay", &ImGui::IsMouseReleasedWithDelay, nb::arg("button"), nb::arg("delay")); + + // IMGUI_API int GetMouseClickedCount(ImGuiMouseButton button); // return the number of successive mouse-clicks at the time where a click happen (otherwise 0). + m.def("GetMouseClickedCount", &ImGui::GetMouseClickedCount, nb::arg("button")); + + // IMGUI_API bool IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool clip = true);// is mouse hovering given bounding rect (in screen space). clipped by current clipping settings, but disregarding of other consideration of focus/window ordering/popup-block. + m.def("IsMouseHoveringRect", &ImGui::IsMouseHoveringRect, nb::arg("r_min"), nb::arg("r_max"), nb::arg("clip") = true); + + // IMGUI_API bool IsMousePosValid(const ImVec2* mouse_pos = NULL); // by convention we use (-FLT_MAX,-FLT_MAX) to denote that there is no mouse available + m.def("IsMousePosValid", [](std::optional mouse_pos) { + if (mouse_pos.has_value()) { + ImVec2 pos = mouse_pos.value(); + return ImGui::IsMousePosValid(&pos); + } else { + return ImGui::IsMousePosValid(nullptr); + } + }, nb::arg("mouse_pos") = std::nullopt); + + // IMGUI_API bool IsAnyMouseDown(); // [WILL OBSOLETE] is any mouse button held? This was designed for backends, but prefer having backend maintain a mask of held mouse buttons, because upcoming input queue system will make this invalid. + m.def("IsAnyMouseDown", &ImGui::IsAnyMouseDown); + + // IMGUI_API ImVec2 GetMousePos(); // shortcut to ImGui::GetIO().MousePos provided by user, to be consistent with other calls + m.def("GetMousePos", []() { + return from_vec2(ImGui::GetMousePos()); + }); + + // IMGUI_API ImVec2 GetMousePosOnOpeningCurrentPopup(); // retrieve mouse position at the time of opening popup we have BeginPopup() into (helper to avoid user backing that value themselves) + m.def("GetMousePosOnOpeningCurrentPopup", []() { + return from_vec2(ImGui::GetMousePosOnOpeningCurrentPopup()); + }); + + // IMGUI_API bool IsMouseDragging(ImGuiMouseButton button, float lock_threshold = -1.0f); // is mouse dragging? (if lock_threshold < -1.0f, uses io.MouseDraggingThreshold) + m.def("IsMouseDragging", &ImGui::IsMouseDragging, nb::arg("button"), nb::arg("lock_threshold") = -1.0f); + + // IMGUI_API ImVec2 GetMouseDragDelta(ImGuiMouseButton button = 0, float lock_threshold = -1.0f); // return the delta from the initial clicking position while the mouse button is pressed or was just released. This is locked and return 0.0f until the mouse moves past a distance threshold at least once (if lock_threshold < -1.0f, uses io.MouseDraggingThreshold) + m.def("GetMouseDragDelta", [](ImGuiMouseButton button, float lock_threshold) { + return from_vec2(ImGui::GetMouseDragDelta(button, lock_threshold)); + }, nb::arg("button") = 0, nb::arg("lock_threshold") = -1.0f); + + // IMGUI_API void ResetMouseDragDelta(ImGuiMouseButton button = 0); // + m.def("ResetMouseDragDelta", &ImGui::ResetMouseDragDelta, nb::arg("button") = 0); + + // IMGUI_API ImGuiMouseCursor GetMouseCursor(); // get desired mouse cursor shape. Important: reset in ImGui::NewFrame(), this is updated during the frame. valid before Render(). If you use software rendering by setting io.MouseDrawCursor ImGui will render those for you + m.def("GetMouseCursor", &ImGui::GetMouseCursor); + + // IMGUI_API void SetMouseCursor(ImGuiMouseCursor cursor_type); // set desired mouse cursor shape + m.def("SetMouseCursor", &ImGui::SetMouseCursor, nb::arg("cursor_type")); + + // IMGUI_API void SetNextFrameWantCaptureMouse(bool want_capture_mouse); // Override io.WantCaptureMouse flag next frame (said flag is left for your application to handle, typical when true it instructs your app to ignore inputs). This is equivalent to setting "io.WantCaptureMouse = want_capture_mouse;" after the next NewFrame() call. + m.def("SetNextFrameWantCaptureMouse", &ImGui::SetNextFrameWantCaptureMouse, nb::arg("want_capture_mouse")); +} diff --git a/src/cpp/imgui/imgui_api_item_query.cpp b/src/cpp/imgui/imgui_api_item_query.cpp new file mode 100644 index 0000000..bc11087 --- /dev/null +++ b/src/cpp/imgui/imgui_api_item_query.cpp @@ -0,0 +1,73 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include + +// clang-format off +void bind_imgui_api_item_query(nb::module_& m) { + + // Item/Widgets Utilities and Query Functions + // IMGUI_API bool IsItemHovered(ImGuiHoveredFlags flags = 0); + m.def( + "IsItemHovered", + [](ImGuiHoveredFlags flags) { return ImGui::IsItemHovered(flags); }, + nb::arg("flags") = 0); + + // IMGUI_API bool IsItemActive(); + m.def("IsItemActive", []() { return ImGui::IsItemActive(); }); + + // IMGUI_API bool IsItemFocused(); + m.def("IsItemFocused", []() { return ImGui::IsItemFocused(); }); + + // IMGUI_API bool IsItemClicked(ImGuiMouseButton mouse_button = 0); + m.def( + "IsItemClicked", + [](ImGuiMouseButton mouse_button) { return ImGui::IsItemClicked(mouse_button); }, + nb::arg("mouse_button") = 0); + + // IMGUI_API bool IsItemVisible(); + m.def("IsItemVisible", []() { return ImGui::IsItemVisible(); }); + + // IMGUI_API bool IsItemEdited(); + m.def("IsItemEdited", []() { return ImGui::IsItemEdited(); }); + + // IMGUI_API bool IsItemActivated(); + m.def("IsItemActivated", []() { return ImGui::IsItemActivated(); }); + + // IMGUI_API bool IsItemDeactivated(); + m.def("IsItemDeactivated", []() { return ImGui::IsItemDeactivated(); }); + + // IMGUI_API bool IsItemDeactivatedAfterEdit(); + m.def("IsItemDeactivatedAfterEdit", []() { return ImGui::IsItemDeactivatedAfterEdit(); }); + + // IMGUI_API bool IsItemToggledOpen(); + m.def("IsItemToggledOpen", []() { return ImGui::IsItemToggledOpen(); }); + + // IMGUI_API bool IsAnyItemHovered(); + m.def("IsAnyItemHovered", []() { return ImGui::IsAnyItemHovered(); }); + + // IMGUI_API bool IsAnyItemActive(); + m.def("IsAnyItemActive", []() { return ImGui::IsAnyItemActive(); }); + + // IMGUI_API bool IsAnyItemFocused(); + m.def("IsAnyItemFocused", []() { return ImGui::IsAnyItemFocused(); }); + + // IMGUI_API ImGuiID GetItemID(); + m.def("GetItemID", []() { return ImGui::GetItemID(); }); + + // IMGUI_API ImVec2 GetItemRectMin(); + m.def("GetItemRectMin", []() { return from_vec2(ImGui::GetItemRectMin()); }); + + // IMGUI_API ImVec2 GetItemRectMax(); + m.def("GetItemRectMax", []() { return from_vec2(ImGui::GetItemRectMax()); }); + + // IMGUI_API ImVec2 GetItemRectSize(); + m.def("GetItemRectSize", []() { return from_vec2(ImGui::GetItemRectSize()); }); + +} +// clang-format on diff --git a/src/cpp/imgui/imgui_api_logging.cpp b/src/cpp/imgui/imgui_api_logging.cpp new file mode 100644 index 0000000..bd9fd63 --- /dev/null +++ b/src/cpp/imgui/imgui_api_logging.cpp @@ -0,0 +1,50 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include + +// clang-format off +void bind_imgui_api_logging(nb::module_& m) { + + // Logging/Capture + // IMGUI_API void LogToTTY(int auto_open_depth = -1); + m.def( + "LogToTTY", + [](int auto_open_depth) { ImGui::LogToTTY(auto_open_depth); }, + nb::arg("auto_open_depth") = -1); + + // IMGUI_API void LogToFile(int auto_open_depth = -1, const char* filename = NULL); + m.def( + "LogToFile", + [](int auto_open_depth, const char* filename) { ImGui::LogToFile(auto_open_depth, filename); }, + nb::arg("auto_open_depth") = -1, + nb::arg("filename") = nb::none()); + + // IMGUI_API void LogToClipboard(int auto_open_depth = -1); + m.def( + "LogToClipboard", + [](int auto_open_depth) { ImGui::LogToClipboard(auto_open_depth); }, + nb::arg("auto_open_depth") = -1); + + // IMGUI_API void LogFinish(); + m.def("LogFinish", []() { ImGui::LogFinish(); }); + + // IMGUI_API void LogButtons(); + m.def("LogButtons", []() { ImGui::LogButtons(); }); + + // IMGUI_API void LogText(const char* fmt, ...) IM_FMTARGS(1); + m.def( + "LogText", + [](const char* text) { ImGui::LogText("%s", text); }, + nb::arg("text")); + + // IMGUI_API void LogTextV(const char* fmt, va_list args) IM_FMTLIST(1); + // TODO: Variadic version not bound + +} +// clang-format on diff --git a/src/cpp/imgui/imgui_api_main.cpp b/src/cpp/imgui/imgui_api_main.cpp new file mode 100644 index 0000000..4b52947 --- /dev/null +++ b/src/cpp/imgui/imgui_api_main.cpp @@ -0,0 +1,31 @@ +#include "imgui_utils.h" + +// clang-format off +void bind_imgui_api_main(nb::module_& m) { + + // Main + + // IMGUI_API ImGuiIO& GetIO(); + m.def("GetIO", &ImGui::GetIO, nb::rv_policy::reference); + + // IMGUI_API ImGuiPlatformIO& GetPlatformIO(); + // This is very low-level. + // m.def("GetPlatformIO", &ImGui::GetPlatformIO, nb::rv_policy::reference); + + // IMGUI_API ImGuiStyle& GetStyle(); // access the Style structure (colors, sizes). Always use PushStyleColor(), PushStyleVar() to modify style mid-frame! + m.def("GetStyle", &ImGui::GetStyle, nb::rv_policy::reference); + + // IMGUI_API void NewFrame(); + m.def("NewFrame", &ImGui::NewFrame); + + // IMGUI_API void EndFrame(); + m.def("EndFrame", &ImGui::EndFrame); + + // IMGUI_API void Render(); + m.def("Render", &ImGui::Render); + + // IMGUI_API ImDrawData* GetDrawData(); + m.def("GetDrawData", &ImGui::GetDrawData, nb::rv_policy::reference); + +} +// clang-format on \ No newline at end of file diff --git a/src/cpp/imgui/imgui_api_menus.cpp b/src/cpp/imgui/imgui_api_menus.cpp new file mode 100644 index 0000000..0c16e01 --- /dev/null +++ b/src/cpp/imgui/imgui_api_menus.cpp @@ -0,0 +1,61 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include + +// clang-format off +void bind_imgui_api_menus(nb::module_& m) { + + // Widgets: Menus + // IMGUI_API bool BeginMenuBar(); + m.def("BeginMenuBar", []() { return ImGui::BeginMenuBar(); }); + + // IMGUI_API void EndMenuBar(); + m.def("EndMenuBar", []() { ImGui::EndMenuBar(); }); + + // IMGUI_API bool BeginMainMenuBar(); + m.def("BeginMainMenuBar", []() { return ImGui::BeginMainMenuBar(); }); + + // IMGUI_API void EndMainMenuBar(); + m.def("EndMainMenuBar", []() { ImGui::EndMainMenuBar(); }); + + // IMGUI_API bool BeginMenu(const char* label, bool enabled = true); + m.def( + "BeginMenu", + [](const char* label, bool enabled) { return ImGui::BeginMenu(label, enabled); }, + nb::arg("label"), + nb::arg("enabled") = true); + + // IMGUI_API void EndMenu(); + m.def("EndMenu", []() { ImGui::EndMenu(); }); + + // IMGUI_API bool MenuItem(const char* label, const char* shortcut = NULL, bool selected = false, bool enabled = true); + m.def( + "MenuItem", + [](const char* label, const char* shortcut, bool selected, bool enabled) { + return ImGui::MenuItem(label, shortcut, selected, enabled); + }, + nb::arg("label"), + nb::arg("shortcut") = nb::none(), + nb::arg("selected") = false, + nb::arg("enabled") = true); + + // IMGUI_API bool MenuItem(const char* label, const char* shortcut, bool* p_selected, bool enabled = true); + m.def( + "MenuItem", + [](const char* label, const char* shortcut, bool p_selected, bool enabled) { + bool result = ImGui::MenuItem(label, shortcut, &p_selected, enabled); + return std::make_tuple(result, p_selected); + }, + nb::arg("label"), + nb::arg("shortcut"), + nb::arg("p_selected"), + nb::arg("enabled") = true); + +} +// clang-format on diff --git a/src/cpp/imgui/imgui_api_misc_utils.cpp b/src/cpp/imgui/imgui_api_misc_utils.cpp new file mode 100644 index 0000000..1ac24e8 --- /dev/null +++ b/src/cpp/imgui/imgui_api_misc_utils.cpp @@ -0,0 +1,35 @@ +// Miscellaneous Utilities + +#include "imgui_utils.h" + +// clang-format off + +void bind_imgui_api_misc_utils(nb::module_& m) { + // IMGUI_API bool IsRectVisible(const ImVec2& size); // test if rectangle (of given size, starting from cursor position) is visible / not clipped. + m.def("IsRectVisible", [](const Vec2T& size) { + return ImGui::IsRectVisible(to_vec2(size)); + }, nb::arg("size")); + + // IMGUI_API bool IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max); // test if rectangle (in screen space) is visible / not clipped. to perform coarse clipping on user's side. + m.def("IsRectVisible", [](const Vec2T& rect_min, const Vec2T& rect_max) { + return ImGui::IsRectVisible(to_vec2(rect_min), to_vec2(rect_max)); + }, nb::arg("rect_min"), nb::arg("rect_max")); + + // IMGUI_API double GetTime(); // get global imgui time. incremented by io.DeltaTime every frame. + m.def("GetTime", &ImGui::GetTime); + + // IMGUI_API int GetFrameCount(); // get global imgui frame count. incremented by 1 every frame. + m.def("GetFrameCount", &ImGui::GetFrameCount); + + // IMGUI_API ImDrawListSharedData* GetDrawListSharedData(); // you may use this when creating your own ImDrawList instances. + // Not bound, this is only useful to create your own ImDrawList instances, which we do not support + + // IMGUI_API const char* GetStyleColorName(ImGuiCol idx); // get a string corresponding to the enum value (for display, saving, etc.). + m.def("GetStyleColorName", &ImGui::GetStyleColorName, nb::arg("idx")); + + // IMGUI_API void SetStateStorage(ImGuiStorage* storage); // replace current window storage with our own (if you want to manipulate it yourself, typically clear subsection of it) + m.def("SetStateStorage", &ImGui::SetStateStorage, nb::arg("storage")); + + // IMGUI_API ImGuiStorage* GetStateStorage(); + m.def("GetStateStorage", &ImGui::GetStateStorage, nb::rv_policy::reference); +} diff --git a/src/cpp/imgui/imgui_api_overlapping_items.cpp b/src/cpp/imgui/imgui_api_overlapping_items.cpp new file mode 100644 index 0000000..85c4e23 --- /dev/null +++ b/src/cpp/imgui/imgui_api_overlapping_items.cpp @@ -0,0 +1,19 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include + +// clang-format off +void bind_imgui_api_overlapping_items(nb::module_& m) { + + // Overlapping mode + // IMGUI_API void SetNextItemAllowOverlap(); + m.def("SetNextItemAllowOverlap", []() { ImGui::SetNextItemAllowOverlap(); }); + +} +// clang-format on diff --git a/src/cpp/imgui/imgui_api_parameter_stacks.cpp b/src/cpp/imgui/imgui_api_parameter_stacks.cpp new file mode 100644 index 0000000..2c30bb3 --- /dev/null +++ b/src/cpp/imgui/imgui_api_parameter_stacks.cpp @@ -0,0 +1,127 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include + +// clang-format off +void bind_imgui_api_parameter_stacks(nb::module_& m) { + + // Parameters stacks (shared) + // IMGUI_API void PushFont(ImFont* font, float font_size_base_unscaled); // Use NULL as a shortcut to keep current font. Use 0.0f to keep current size. + m.def( + "PushFont", + [](ImFont* font, float font_size_base_unscaled) { ImGui::PushFont(font); }, + nb::arg("font")=nb::none(), + nb::arg("font_size_base_unscaled")=0.0f); + + // IMGUI_API void PopFont(); + m.def("PopFont", []() { ImGui::PopFont(); }); + + // IMGUI_API ImFont* GetFont(); // get current font + m.def("GetFont", []() { return ImGui::GetFont(); }, nb::rv_policy::reference, "Get current font"); + + // IMGUI_API float GetFontSize(); + m.def("GetFontSize", []() { return ImGui::GetFontSize(); }, "Get current scaled font size (height in pixels) after global scale factors applied"); + + // IMGUI_API ImFontBaked* GetFontBaked(); + m.def("GetFontBaked", []() { return ImGui::GetFontBaked(); }, nb::rv_policy::reference, "Get current font baked at current size"); + + // IMGUI_API void PushStyleColor(ImGuiCol idx, ImU32 col); + m.def( + "PushStyleColor", + [](ImGuiCol idx, ImU32 col) { ImGui::PushStyleColor(idx, col); }, + nb::arg("idx"), + nb::arg("col")); + + // IMGUI_API void PushStyleColor(ImGuiCol idx, const ImVec4& col); + m.def( + "PushStyleColor", + [](ImGuiCol idx, const Vec4T& col) { ImGui::PushStyleColor(idx, to_vec4(col)); }, + nb::arg("idx"), + nb::arg("col")); + + // IMGUI_API void PopStyleColor(int count = 1); + m.def( + "PopStyleColor", + [](int count) { ImGui::PopStyleColor(count); }, + nb::arg("count") = 1); + + // IMGUI_API void PushStyleVar(ImGuiStyleVar idx, float val); + m.def( + "PushStyleVar", + [](ImGuiStyleVar idx, float val) { ImGui::PushStyleVar(idx, val); }, + nb::arg("idx"), + nb::arg("val")); + + // IMGUI_API void PushStyleVar(ImGuiStyleVar idx, const ImVec2& val); + m.def( + "PushStyleVar", + [](ImGuiStyleVar idx, const Vec2T& val) { ImGui::PushStyleVar(idx, to_vec2(val)); }, + nb::arg("idx"), + nb::arg("val")); + + // IMGUI_API void PushStyleVarX(ImGuiStyleVar idx, float val_x); + m.def( + "PushStyleVarX", + [](ImGuiStyleVar idx, float val_x) { ImGui::PushStyleVarX(idx, val_x); }, + nb::arg("idx"), + nb::arg("val_x")); + + // IMGUI_API void PushStyleVarY(ImGuiStyleVar idx, float val_y); + m.def( + "PushStyleVarY", + [](ImGuiStyleVar idx, float val_y) { ImGui::PushStyleVarY(idx, val_y); }, + nb::arg("idx"), + nb::arg("val_y")); + + // IMGUI_API void PopStyleVar(int count = 1); + m.def( + "PopStyleVar", + [](int count) { ImGui::PopStyleVar(count); }, + nb::arg("count") = 1); + + // IMGUI_API void PushItemFlag(ImGuiItemFlags option, bool enabled); + m.def( + "PushItemFlag", + [](ImGuiItemFlags option, bool enabled) { ImGui::PushItemFlag(option, enabled); }, + nb::arg("option"), + nb::arg("enabled")); + + // IMGUI_API void PopItemFlag(); + m.def("PopItemFlag", []() { ImGui::PopItemFlag(); }); + + // Parameters stacks (current window) + // IMGUI_API void PushItemWidth(float item_width); + m.def( + "PushItemWidth", + [](float item_width) { ImGui::PushItemWidth(item_width); }, + nb::arg("item_width")); + + // IMGUI_API void PopItemWidth(); + m.def("PopItemWidth", []() { ImGui::PopItemWidth(); }); + + // IMGUI_API void SetNextItemWidth(float item_width); + m.def( + "SetNextItemWidth", + [](float item_width) { ImGui::SetNextItemWidth(item_width); }, + nb::arg("item_width")); + + // IMGUI_API float CalcItemWidth(); + m.def("CalcItemWidth", []() { return ImGui::CalcItemWidth(); }); + + // IMGUI_API void PushTextWrapPos(float wrap_local_pos_x = 0.0f); + m.def( + "PushTextWrapPos", + [](float wrap_local_pos_x) { ImGui::PushTextWrapPos(wrap_local_pos_x); }, + nb::arg("wrap_local_pos_x") = 0.0f); + + // IMGUI_API void PopTextWrapPos(); + m.def("PopTextWrapPos", []() { ImGui::PopTextWrapPos(); }); + +} +// clang-format on diff --git a/src/cpp/imgui/imgui_api_popups.cpp b/src/cpp/imgui/imgui_api_popups.cpp new file mode 100644 index 0000000..8081c23 --- /dev/null +++ b/src/cpp/imgui/imgui_api_popups.cpp @@ -0,0 +1,106 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include + +// clang-format off +void bind_imgui_api_popups(nb::module_& m) { + + // Popups, Modals + // IMGUI_API bool BeginPopup(const char* str_id, ImGuiWindowFlags flags = 0); + m.def( + "BeginPopup", + [](const char* str_id, ImGuiWindowFlags flags) { return ImGui::BeginPopup(str_id, flags); }, + nb::arg("str_id"), + nb::arg("flags") = 0); + + // IMGUI_API bool BeginPopupModal(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0); + m.def( + "BeginPopupModal", + [](const char* name, bool p_open, ImGuiWindowFlags flags) { + bool result = ImGui::BeginPopupModal(name, &p_open, flags); + return std::make_tuple(result, p_open); + }, + nb::arg("name"), + nb::arg("p_open"), + nb::arg("flags") = 0); + m.def( + "BeginPopupModal", + [](const char* name, ImGuiWindowFlags flags) { + bool result = ImGui::BeginPopupModal(name, nullptr, flags); + return result; + }, + nb::arg("name"), + nb::arg("flags") = 0); + + // IMGUI_API void EndPopup(); + m.def("EndPopup", []() { ImGui::EndPopup(); }); + + // Popups: open/close functions + // IMGUI_API void OpenPopup(const char* str_id, ImGuiPopupFlags popup_flags = 0); + m.def( + "OpenPopup", + [](const char* str_id, ImGuiPopupFlags popup_flags) { ImGui::OpenPopup(str_id, popup_flags); }, + nb::arg("str_id"), + nb::arg("popup_flags") = 0); + + // IMGUI_API void OpenPopup(ImGuiID id, ImGuiPopupFlags popup_flags = 0); + m.def( + "OpenPopup", + [](ImGuiID id, ImGuiPopupFlags popup_flags) { ImGui::OpenPopup(id, popup_flags); }, + nb::arg("id"), + nb::arg("popup_flags") = 0); + + // IMGUI_API void OpenPopupOnItemClick(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); + m.def( + "OpenPopupOnItemClick", + [](const char* str_id, ImGuiPopupFlags popup_flags) { ImGui::OpenPopupOnItemClick(str_id, popup_flags); }, + nb::arg("str_id") = nb::none(), + nb::arg("popup_flags") = 1); + + // IMGUI_API void CloseCurrentPopup(); + m.def("CloseCurrentPopup", []() { ImGui::CloseCurrentPopup(); }); + + // Popups: open+begin combined functions helpers + // IMGUI_API bool BeginPopupContextItem(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); + m.def( + "BeginPopupContextItem", + [](const char* str_id, ImGuiPopupFlags popup_flags) { + return ImGui::BeginPopupContextItem(str_id, popup_flags); + }, + nb::arg("str_id") = nb::none(), + nb::arg("popup_flags") = 1); + + // IMGUI_API bool BeginPopupContextWindow(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); + m.def( + "BeginPopupContextWindow", + [](const char* str_id, ImGuiPopupFlags popup_flags) { + return ImGui::BeginPopupContextWindow(str_id, popup_flags); + }, + nb::arg("str_id") = nb::none(), + nb::arg("popup_flags") = 1); + + // IMGUI_API bool BeginPopupContextVoid(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); + m.def( + "BeginPopupContextVoid", + [](const char* str_id, ImGuiPopupFlags popup_flags) { + return ImGui::BeginPopupContextVoid(str_id, popup_flags); + }, + nb::arg("str_id") = nb::none(), + nb::arg("popup_flags") = 1); + + // Popups: query functions + // IMGUI_API bool IsPopupOpen(const char* str_id, ImGuiPopupFlags flags = 0); + m.def( + "IsPopupOpen", + [](const char* str_id, ImGuiPopupFlags flags) { return ImGui::IsPopupOpen(str_id, flags); }, + nb::arg("str_id"), + nb::arg("flags") = 0); + +} +// clang-format on diff --git a/src/cpp/imgui/imgui_api_scrolling.cpp b/src/cpp/imgui/imgui_api_scrolling.cpp new file mode 100644 index 0000000..028c160 --- /dev/null +++ b/src/cpp/imgui/imgui_api_scrolling.cpp @@ -0,0 +1,66 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include + +// clang-format off +void bind_imgui_api_scrolling(nb::module_& m) { + + // Windows Scrolling + // IMGUI_API float GetScrollX(); + m.def("GetScrollX", []() { return ImGui::GetScrollX(); }); + + // IMGUI_API float GetScrollY(); + m.def("GetScrollY", []() { return ImGui::GetScrollY(); }); + + // IMGUI_API void SetScrollX(float scroll_x); + m.def( + "SetScrollX", + [](float scroll_x) { ImGui::SetScrollX(scroll_x); }, + nb::arg("scroll_x")); + + // IMGUI_API void SetScrollY(float scroll_y); + m.def( + "SetScrollY", + [](float scroll_y) { ImGui::SetScrollY(scroll_y); }, + nb::arg("scroll_y")); + + // IMGUI_API float GetScrollMaxX(); + m.def("GetScrollMaxX", []() { return ImGui::GetScrollMaxX(); }); + + // IMGUI_API float GetScrollMaxY(); + m.def("GetScrollMaxY", []() { return ImGui::GetScrollMaxY(); }); + + // IMGUI_API void SetScrollHereX(float center_x_ratio = 0.5f); + m.def( + "SetScrollHereX", + [](float center_x_ratio) { ImGui::SetScrollHereX(center_x_ratio); }, + nb::arg("center_x_ratio") = 0.5f); + + // IMGUI_API void SetScrollHereY(float center_y_ratio = 0.5f); + m.def( + "SetScrollHereY", + [](float center_y_ratio) { ImGui::SetScrollHereY(center_y_ratio); }, + nb::arg("center_y_ratio") = 0.5f); + + // IMGUI_API void SetScrollFromPosX(float local_x, float center_x_ratio = 0.5f); + m.def( + "SetScrollFromPosX", + [](float local_x, float center_x_ratio) { ImGui::SetScrollFromPosX(local_x, center_x_ratio); }, + nb::arg("local_x"), + nb::arg("center_x_ratio") = 0.5f); + + // IMGUI_API void SetScrollFromPosY(float local_y, float center_y_ratio = 0.5f); + m.def( + "SetScrollFromPosY", + [](float local_y, float center_y_ratio) { ImGui::SetScrollFromPosY(local_y, center_y_ratio); }, + nb::arg("local_y"), + nb::arg("center_y_ratio") = 0.5f); + +} +// clang-format on diff --git a/src/cpp/imgui/imgui_api_settings.cpp b/src/cpp/imgui/imgui_api_settings.cpp new file mode 100644 index 0000000..baafbba --- /dev/null +++ b/src/cpp/imgui/imgui_api_settings.cpp @@ -0,0 +1,20 @@ +// Settings/.Ini Utilities + +#include "imgui_utils.h" + +// clang-format off + +void bind_imgui_api_settings(nb::module_& m) { + + // IMGUI_API void LoadIniSettingsFromDisk(const char* ini_filename); // call after CreateContext() and before the first call to NewFrame(). NewFrame() automatically calls LoadIniSettingsFromDisk(io.IniFilename). + m.def("LoadIniSettingsFromDisk", &ImGui::LoadIniSettingsFromDisk, nb::arg("ini_filename")); + + // IMGUI_API void LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size=0); // call after CreateContext() and before the first call to NewFrame() to provide .ini data from your own data source. + m.def("LoadIniSettingsFromMemory", &ImGui::LoadIniSettingsFromMemory, nb::arg("ini_data"), nb::arg("ini_size") = 0); + + // IMGUI_API void SaveIniSettingsToDisk(const char* ini_filename); // this is automatically called (if io.IniFilename is not empty) a few seconds after any modification that should be reflected in the .ini file (and also by DestroyContext). + m.def("SaveIniSettingsToDisk", &ImGui::SaveIniSettingsToDisk, nb::arg("ini_filename")); + + // IMGUI_API const char* SaveIniSettingsToMemory(size_t* out_ini_size = NULL); // return a zero-terminated string with the .ini data which you can save by your own mean. call when io.WantSaveIniSettings is set, then save data by your own mean and clear io.WantSaveIniSettings. + m.def("SaveIniSettingsToMemory", []() { return ImGui::SaveIniSettingsToMemory(); }); +} diff --git a/src/cpp/imgui/imgui_api_style_read.cpp b/src/cpp/imgui/imgui_api_style_read.cpp new file mode 100644 index 0000000..7239489 --- /dev/null +++ b/src/cpp/imgui/imgui_api_style_read.cpp @@ -0,0 +1,46 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include + +// clang-format off +void bind_imgui_api_style_read(nb::module_& m) { + + // Style read access + + // IMGUI_API ImVec2 GetFontTexUvWhitePixel(); + m.def("GetFontTexUvWhitePixel", []() { return from_vec2(ImGui::GetFontTexUvWhitePixel()); }); + + // IMGUI_API ImU32 GetColorU32(ImGuiCol idx, float alpha_mul = 1.0f); + m.def( + "GetColorU32", + [](ImGuiCol idx, float alpha_mul) { return ImGui::GetColorU32(idx, alpha_mul); }, + nb::arg("idx"), + nb::arg("alpha_mul") = 1.0f); + + // IMGUI_API ImU32 GetColorU32(const ImVec4& col); + m.def( + "GetColorU32", + [](const Vec4T& col) { return ImGui::GetColorU32(to_vec4(col)); }, + nb::arg("col")); + + // IMGUI_API ImU32 GetColorU32(ImU32 col, float alpha_mul = 1.0f); + m.def( + "GetColorU32", + [](ImU32 col, float alpha_mul) { return ImGui::GetColorU32(col, alpha_mul); }, + nb::arg("col"), + nb::arg("alpha_mul") = 1.0f); + + // IMGUI_API const ImVec4& GetStyleColorVec4(ImGuiCol idx); + m.def( + "GetStyleColorVec4", + [](ImGuiCol idx) { return from_vec4(ImGui::GetStyleColorVec4(idx)); }, + nb::arg("idx")); + +} +// clang-format on diff --git a/src/cpp/imgui/imgui_api_styles.cpp b/src/cpp/imgui/imgui_api_styles.cpp new file mode 100644 index 0000000..be6ec0f --- /dev/null +++ b/src/cpp/imgui/imgui_api_styles.cpp @@ -0,0 +1,16 @@ +#include "imgui_utils.h" + +// clang-format off +void bind_imgui_api_styles(nb::module_& m) { + + // IMGUI_API void StyleColorsDark(ImGuiStyle* dst = NULL); + m.def("StyleColorsDark", [](ImGuiStyle* dst) { ImGui::StyleColorsDark(dst); }, nb::arg("dst") = nb::none()); + + // IMGUI_API void StyleColorsLight(ImGuiStyle* dst = NULL); + m.def("StyleColorsLight", [](ImGuiStyle* dst) { ImGui::StyleColorsLight(dst); }, nb::arg("dst") = nb::none()); + + // IMGUI_API void StyleColorsClassic(ImGuiStyle* dst = NULL); + m.def("StyleColorsClassic", [](ImGuiStyle* dst) { ImGui::StyleColorsClassic(dst); }, nb::arg("dst") = nb::none()); + +} +// clang-format on \ No newline at end of file diff --git a/src/cpp/imgui/imgui_api_tab_bars.cpp b/src/cpp/imgui/imgui_api_tab_bars.cpp new file mode 100644 index 0000000..4569cd2 --- /dev/null +++ b/src/cpp/imgui/imgui_api_tab_bars.cpp @@ -0,0 +1,53 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include + +// clang-format off +void bind_imgui_api_tab_bars(nb::module_& m) { + + // Tab Bars, Tab Items + // IMGUI_API bool BeginTabBar(const char* str_id, ImGuiTabBarFlags flags = 0); + m.def( + "BeginTabBar", + [](const char* str_id, ImGuiTabBarFlags flags) { return ImGui::BeginTabBar(str_id, flags); }, + nb::arg("str_id"), + nb::arg("flags") = 0); + + // IMGUI_API void EndTabBar(); + m.def("EndTabBar", []() { ImGui::EndTabBar(); }); + + // IMGUI_API bool BeginTabItem(const char* label, bool* p_open = NULL, ImGuiTabItemFlags flags = 0); + m.def( + "BeginTabItem", + [](const char* label, bool p_open, ImGuiTabItemFlags flags) { + bool result = ImGui::BeginTabItem(label, &p_open, flags); + return std::make_tuple(result, p_open); + }, + nb::arg("label"), + nb::arg("p_open"), + nb::arg("flags") = 0); + + // IMGUI_API void EndTabItem(); + m.def("EndTabItem", []() { ImGui::EndTabItem(); }); + + // IMGUI_API bool TabItemButton(const char* label, ImGuiTabItemFlags flags = 0); + m.def( + "TabItemButton", + [](const char* label, ImGuiTabItemFlags flags) { return ImGui::TabItemButton(label, flags); }, + nb::arg("label"), + nb::arg("flags") = 0); + + // IMGUI_API void SetTabItemClosed(const char* tab_or_docked_window_label); + m.def( + "SetTabItemClosed", + [](const char* tab_or_docked_window_label) { ImGui::SetTabItemClosed(tab_or_docked_window_label); }, + nb::arg("tab_or_docked_window_label")); + +} +// clang-format on diff --git a/src/cpp/imgui/imgui_api_tables.cpp b/src/cpp/imgui/imgui_api_tables.cpp new file mode 100644 index 0000000..2082562 --- /dev/null +++ b/src/cpp/imgui/imgui_api_tables.cpp @@ -0,0 +1,123 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include + +// clang-format off +void bind_imgui_api_tables(nb::module_& m) { + + // Tables + // IMGUI_API bool BeginTable(const char* str_id, int columns, ImGuiTableFlags flags = 0, const ImVec2& outer_size = ImVec2(0.0f, 0.0f), float inner_width = 0.0f); + m.def( + "BeginTable", + [](const char* str_id, int columns, ImGuiTableFlags flags, const Vec2T& outer_size, float inner_width) { + return ImGui::BeginTable(str_id, columns, flags, to_vec2(outer_size), inner_width); + }, + nb::arg("str_id"), + nb::arg("columns"), + nb::arg("flags") = 0, + nb::arg("outer_size") = Vec2T(0.f, 0.f), + nb::arg("inner_width") = 0.0f); + + // IMGUI_API void EndTable(); + m.def("EndTable", []() { ImGui::EndTable(); }); + + // IMGUI_API void TableNextRow(ImGuiTableRowFlags row_flags = 0, float min_row_height = 0.0f); + m.def( + "TableNextRow", + [](ImGuiTableRowFlags row_flags, float min_row_height) { + ImGui::TableNextRow(row_flags, min_row_height); + }, + nb::arg("row_flags") = 0, + nb::arg("min_row_height") = 0.0f); + + // IMGUI_API bool TableNextColumn(); + m.def("TableNextColumn", []() { return ImGui::TableNextColumn(); }); + + // IMGUI_API bool TableSetColumnIndex(int column_n); + m.def( + "TableSetColumnIndex", + [](int column_n) { return ImGui::TableSetColumnIndex(column_n); }, + nb::arg("column_n")); + + // IMGUI_API void TableSetupColumn(const char* label, ImGuiTableColumnFlags flags = 0, float init_width_or_weight = 0.0f, ImGuiID user_id = 0); + m.def( + "TableSetupColumn", + [](const char* label, ImGuiTableColumnFlags flags, float init_width_or_weight, ImGuiID user_id) { + ImGui::TableSetupColumn(label, flags, init_width_or_weight, user_id); + }, + nb::arg("label"), + nb::arg("flags") = 0, + nb::arg("init_width_or_weight") = 0.0f, + nb::arg("user_id") = 0); + + // IMGUI_API void TableSetupScrollFreeze(int cols, int rows); + m.def( + "TableSetupScrollFreeze", + [](int cols, int rows) { ImGui::TableSetupScrollFreeze(cols, rows); }, + nb::arg("cols"), + nb::arg("rows")); + + // IMGUI_API void TableHeader(const char* label); + m.def( + "TableHeader", + [](const char* label) { ImGui::TableHeader(label); }, + nb::arg("label")); + + // IMGUI_API void TableHeadersRow(); + m.def("TableHeadersRow", []() { ImGui::TableHeadersRow(); }); + + // IMGUI_API void TableAngledHeadersRow(); + m.def("TableAngledHeadersRow", []() { ImGui::TableAngledHeadersRow(); }); + + // IMGUI_API ImGuiTableSortSpecs* TableGetSortSpecs(); + m.def("TableGetSortSpecs", []() { return ImGui::TableGetSortSpecs(); }, nb::rv_policy::reference); + + // IMGUI_API int TableGetColumnCount(); + m.def("TableGetColumnCount", []() { return ImGui::TableGetColumnCount(); }); + + // IMGUI_API int TableGetColumnIndex(); + m.def("TableGetColumnIndex", []() { return ImGui::TableGetColumnIndex(); }); + + // IMGUI_API int TableGetRowIndex(); + m.def("TableGetRowIndex", []() { return ImGui::TableGetRowIndex(); }); + + // IMGUI_API const char* TableGetColumnName(int column_n = -1); + m.def( + "TableGetColumnName", + [](int column_n) { return ImGui::TableGetColumnName(column_n); }, + nb::arg("column_n") = -1); + + // IMGUI_API ImGuiTableColumnFlags TableGetColumnFlags(int column_n = -1); + m.def( + "TableGetColumnFlags", + [](int column_n) { return ImGui::TableGetColumnFlags(column_n); }, + nb::arg("column_n") = -1); + + // IMGUI_API void TableSetColumnEnabled(int column_n, bool v); + m.def( + "TableSetColumnEnabled", + [](int column_n, bool v) { ImGui::TableSetColumnEnabled(column_n, v); }, + nb::arg("column_n"), + nb::arg("v")); + + // IMGUI_API int TableGetHoveredColumn(); + m.def("TableGetHoveredColumn", []() { return ImGui::TableGetHoveredColumn(); }); + + // IMGUI_API void TableSetBgColor(ImGuiTableBgTarget target, ImU32 color, int column_n = -1); + m.def( + "TableSetBgColor", + [](ImGuiTableBgTarget target, ImU32 color, int column_n) { + ImGui::TableSetBgColor(target, color, column_n); + }, + nb::arg("target"), + nb::arg("color"), + nb::arg("column_n") = -1); + +} +// clang-format on diff --git a/src/cpp/imgui/imgui_api_text_utils.cpp b/src/cpp/imgui/imgui_api_text_utils.cpp new file mode 100644 index 0000000..a33d236 --- /dev/null +++ b/src/cpp/imgui/imgui_api_text_utils.cpp @@ -0,0 +1,15 @@ +// Text Utilities + +#include "imgui_utils.h" + +// clang-format off + +void bind_imgui_api_text_utils(nb::module_& m) { + // IMGUI_API ImVec2 CalcTextSize(const char* text, const char* text_end = NULL, bool hide_text_after_double_hash = false, float wrap_width = -1.0f); + m.def("CalcTextSize", [](std::string text, bool hide_text_after_double_hash, float wrap_width) { + return from_vec2(ImGui::CalcTextSize(text.c_str(), nullptr, hide_text_after_double_hash, wrap_width)); + }, + nb::arg("text"), + nb::arg("hide_text_after_double_hash") = false, + nb::arg("wrap_width") = -1.0f); +} diff --git a/src/cpp/imgui/imgui_api_tooltips.cpp b/src/cpp/imgui/imgui_api_tooltips.cpp new file mode 100644 index 0000000..3456f0b --- /dev/null +++ b/src/cpp/imgui/imgui_api_tooltips.cpp @@ -0,0 +1,43 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include + +// clang-format off +void bind_imgui_api_tooltips(nb::module_& m) { + + // Tooltips + // IMGUI_API bool BeginTooltip(); + m.def("BeginTooltip", []() { return ImGui::BeginTooltip(); }); + + // IMGUI_API void EndTooltip(); + m.def("EndTooltip", []() { ImGui::EndTooltip(); }); + + // IMGUI_API void SetTooltip(const char* fmt, ...) IM_FMTARGS(1); + m.def( + "SetTooltip", + [](const char* text) { ImGui::SetTooltip("%s", text); }, + nb::arg("text")); + + // IMGUI_API void SetTooltipV(const char* fmt, va_list args) IM_FMTLIST(1); + // TODO: Variadic version not bound + + // IMGUI_API bool BeginItemTooltip(); + m.def("BeginItemTooltip", []() { return ImGui::BeginItemTooltip(); }); + + // IMGUI_API void SetItemTooltip(const char* fmt, ...) IM_FMTARGS(1); + m.def( + "SetItemTooltip", + [](const char* text) { ImGui::SetItemTooltip("%s", text); }, + nb::arg("text")); + + // IMGUI_API void SetItemTooltipV(const char* fmt, va_list args) IM_FMTLIST(1); + // TODO: Variadic version not bound + +} +// clang-format on diff --git a/src/cpp/imgui/imgui_api_viewports.cpp b/src/cpp/imgui/imgui_api_viewports.cpp new file mode 100644 index 0000000..c53210e --- /dev/null +++ b/src/cpp/imgui/imgui_api_viewports.cpp @@ -0,0 +1,19 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include + +// clang-format off +void bind_imgui_api_viewports(nb::module_& m) { + + // Viewports + // IMGUI_API ImGuiViewport* GetMainViewport(); + m.def("GetMainViewport", []() { return ImGui::GetMainViewport(); }, nb::rv_policy::reference); + +} +// clang-format on diff --git a/src/cpp/imgui/imgui_api_widgets_color.cpp b/src/cpp/imgui/imgui_api_widgets_color.cpp new file mode 100644 index 0000000..0d8fa13 --- /dev/null +++ b/src/cpp/imgui/imgui_api_widgets_color.cpp @@ -0,0 +1,78 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include + +// clang-format off +void bind_imgui_api_widgets_color(nb::module_& m) { + + // Widgets: Color Editor/Picker + // IMGUI_API bool ColorEdit3(const char* label, float col[3], ImGuiColorEditFlags flags = 0); + m.def( + "ColorEdit3", + [](const char* label, std::array col, ImGuiColorEditFlags flags) { + bool result = ImGui::ColorEdit3(label, col.data(), flags); + return std::make_tuple(result, std::make_tuple(col[0], col[1], col[2])); + }, + nb::arg("label"), + nb::arg("col"), + nb::arg("flags") = 0); + + // IMGUI_API bool ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flags = 0); + m.def( + "ColorEdit4", + [](const char* label, std::array col, ImGuiColorEditFlags flags) { + bool result = ImGui::ColorEdit4(label, col.data(), flags); + return std::make_tuple(result, std::make_tuple(col[0], col[1], col[2], col[3])); + }, + nb::arg("label"), + nb::arg("col"), + nb::arg("flags") = 0); + + // IMGUI_API bool ColorPicker3(const char* label, float col[3], ImGuiColorEditFlags flags = 0); + m.def( + "ColorPicker3", + [](const char* label, std::array col, ImGuiColorEditFlags flags) { + bool result = ImGui::ColorPicker3(label, col.data(), flags); + return std::make_tuple(result, std::make_tuple(col[0], col[1], col[2])); + }, + nb::arg("label"), + nb::arg("col"), + nb::arg("flags") = 0); + + // IMGUI_API bool ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags flags = 0, const float* ref_col = NULL); + m.def( + "ColorPicker4", + [](const char* label, std::array col, ImGuiColorEditFlags flags) { + bool result = ImGui::ColorPicker4(label, col.data(), flags); + return std::make_tuple(result, std::make_tuple(col[0], col[1], col[2], col[3])); + }, + nb::arg("label"), + nb::arg("col"), + nb::arg("flags") = 0); + // TODO: ref_col parameter not bound + + // IMGUI_API bool ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFlags flags = 0, const ImVec2& size = ImVec2(0, 0)); + m.def( + "ColorButton", + [](const char* desc_id, const Vec4T& col, ImGuiColorEditFlags flags, const Vec2T& size) { + return ImGui::ColorButton(desc_id, to_vec4(col), flags, to_vec2(size)); + }, + nb::arg("desc_id"), + nb::arg("col"), + nb::arg("flags") = 0, + nb::arg("size") = Vec2T(0.f, 0.f)); + + // IMGUI_API void SetColorEditOptions(ImGuiColorEditFlags flags); + m.def( + "SetColorEditOptions", + [](ImGuiColorEditFlags flags) { ImGui::SetColorEditOptions(flags); }, + nb::arg("flags")); + +} +// clang-format on diff --git a/src/cpp/imgui/imgui_api_widgets_combo.cpp b/src/cpp/imgui/imgui_api_widgets_combo.cpp new file mode 100644 index 0000000..b678c5c --- /dev/null +++ b/src/cpp/imgui/imgui_api_widgets_combo.cpp @@ -0,0 +1,63 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include +#include +#include + +// clang-format off +void bind_imgui_api_widgets_combo(nb::module_& m) { + + // Widgets: Combo Box (Dropdown) + // IMGUI_API bool BeginCombo(const char* label, const char* preview_value, ImGuiComboFlags flags = 0); + m.def( + "BeginCombo", + [](const char* label, const char* preview_value, ImGuiComboFlags flags) { + return ImGui::BeginCombo(label, preview_value, flags); + }, + nb::arg("label"), + nb::arg("preview_value"), + nb::arg("flags") = 0); + + // IMGUI_API void EndCombo(); + m.def("EndCombo", []() { ImGui::EndCombo(); }); + + // IMGUI_API bool Combo(const char* label, int* current_item, const char* const items[], int items_count, int popup_max_height_in_items = -1); + m.def( + "Combo", + [](const char* label, int current_item, const std::vector& items, int popup_max_height_in_items) { + std::vector item_ptrs; + item_ptrs.reserve(items.size()); + for (const auto& item : items) { + item_ptrs.push_back(item.c_str()); + } + bool result = ImGui::Combo(label, ¤t_item, item_ptrs.data(), static_cast(item_ptrs.size()), popup_max_height_in_items); + return std::make_tuple(result, current_item); + }, + nb::arg("label"), + nb::arg("current_item"), + nb::arg("items"), + nb::arg("popup_max_height_in_items") = -1); + + // IMGUI_API bool Combo(const char* label, int* current_item, const char* items_separated_by_zeros, int popup_max_height_in_items = -1); + m.def( + "Combo", + [](const char* label, int current_item, const char* items_separated_by_zeros, int popup_max_height_in_items) { + bool result = ImGui::Combo(label, ¤t_item, items_separated_by_zeros, popup_max_height_in_items); + return std::make_tuple(result, current_item); + }, + nb::arg("label"), + nb::arg("current_item"), + nb::arg("items_separated_by_zeros"), + nb::arg("popup_max_height_in_items") = -1); + + // IMGUI_API bool Combo(const char* label, int* current_item, const char* (*getter)(void* user_data, int idx), void* user_data, int items_count, int popup_max_height_in_items = -1); + // TODO: Callback version requires binding function pointers from Python + +} +// clang-format on diff --git a/src/cpp/imgui/imgui_api_widgets_drag.cpp b/src/cpp/imgui/imgui_api_widgets_drag.cpp new file mode 100644 index 0000000..3afbb0f --- /dev/null +++ b/src/cpp/imgui/imgui_api_widgets_drag.cpp @@ -0,0 +1,180 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include + +// clang-format off +void bind_imgui_api_widgets_drag(nb::module_& m) { + + // Widgets: Drag Sliders + // IMGUI_API bool DragFloat(const char* label, float* v, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0); + m.def( + "DragFloat", + [](const char* label, float v, float v_speed, float v_min, float v_max, const char* format, ImGuiSliderFlags flags) { + bool result = ImGui::DragFloat(label, &v, v_speed, v_min, v_max, format, flags); + return std::make_tuple(result, v); + }, + nb::arg("label"), + nb::arg("v"), + nb::arg("v_speed") = 1.0f, + nb::arg("v_min") = 0.0f, + nb::arg("v_max") = 0.0f, + nb::arg("format") = "%.3f", + nb::arg("flags") = 0); + + // IMGUI_API bool DragFloat2(const char* label, float v[2], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0); + m.def( + "DragFloat2", + [](const char* label, std::array v, float v_speed, float v_min, float v_max, const char* format, ImGuiSliderFlags flags) { + bool result = ImGui::DragFloat2(label, v.data(), v_speed, v_min, v_max, format, flags); + return std::make_tuple(result, std::make_tuple(v[0], v[1])); + }, + nb::arg("label"), + nb::arg("v"), + nb::arg("v_speed") = 1.0f, + nb::arg("v_min") = 0.0f, + nb::arg("v_max") = 0.0f, + nb::arg("format") = "%.3f", + nb::arg("flags") = 0); + + // IMGUI_API bool DragFloat3(const char* label, float v[3], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0); + m.def( + "DragFloat3", + [](const char* label, std::array v, float v_speed, float v_min, float v_max, const char* format, ImGuiSliderFlags flags) { + bool result = ImGui::DragFloat3(label, v.data(), v_speed, v_min, v_max, format, flags); + return std::make_tuple(result, std::make_tuple(v[0], v[1], v[2])); + }, + nb::arg("label"), + nb::arg("v"), + nb::arg("v_speed") = 1.0f, + nb::arg("v_min") = 0.0f, + nb::arg("v_max") = 0.0f, + nb::arg("format") = "%.3f", + nb::arg("flags") = 0); + + // IMGUI_API bool DragFloat4(const char* label, float v[4], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0); + m.def( + "DragFloat4", + [](const char* label, std::array v, float v_speed, float v_min, float v_max, const char* format, ImGuiSliderFlags flags) { + bool result = ImGui::DragFloat4(label, v.data(), v_speed, v_min, v_max, format, flags); + return std::make_tuple(result, std::make_tuple(v[0], v[1], v[2], v[3])); + }, + nb::arg("label"), + nb::arg("v"), + nb::arg("v_speed") = 1.0f, + nb::arg("v_min") = 0.0f, + nb::arg("v_max") = 0.0f, + nb::arg("format") = "%.3f", + nb::arg("flags") = 0); + + // IMGUI_API bool DragFloatRange2(const char* label, float* v_current_min, float* v_current_max, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", const char* format_max = NULL, ImGuiSliderFlags flags = 0); + m.def( + "DragFloatRange2", + [](const char* label, float v_current_min, float v_current_max, float v_speed, float v_min, float v_max, std::string format, std::optional format_max, ImGuiSliderFlags flags) { + const char* format_max_ptr = nullptr; + if(format_max.has_value()) { + format_max_ptr = format_max->c_str(); + } + bool result = ImGui::DragFloatRange2(label, &v_current_min, &v_current_max, v_speed, v_min, v_max, format.c_str(), format_max_ptr, flags); + return std::make_tuple(result, v_current_min, v_current_max); + }, + nb::arg("label"), + nb::arg("v_current_min"), + nb::arg("v_current_max"), + nb::arg("v_speed") = 1.0f, + nb::arg("v_min") = 0.0f, + nb::arg("v_max") = 0.0f, + nb::arg("format") = "%.3f", + nb::arg("format_max") = nb::none(), + nb::arg("flags") = 0); + + // IMGUI_API bool DragInt(const char* label, int* v, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", ImGuiSliderFlags flags = 0); + m.def( + "DragInt", + [](const char* label, int v, float v_speed, int v_min, int v_max, const char* format, ImGuiSliderFlags flags) { + bool result = ImGui::DragInt(label, &v, v_speed, v_min, v_max, format, flags); + return std::make_tuple(result, v); + }, + nb::arg("label"), + nb::arg("v"), + nb::arg("v_speed") = 1.0f, + nb::arg("v_min") = 0, + nb::arg("v_max") = 0, + nb::arg("format") = "%d", + nb::arg("flags") = 0); + + // IMGUI_API bool DragInt2(const char* label, int v[2], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", ImGuiSliderFlags flags = 0); + m.def( + "DragInt2", + [](const char* label, std::array v, float v_speed, int v_min, int v_max, const char* format, ImGuiSliderFlags flags) { + bool result = ImGui::DragInt2(label, v.data(), v_speed, v_min, v_max, format, flags); + return std::make_tuple(result, std::make_tuple(v[0], v[1])); + }, + nb::arg("label"), + nb::arg("v"), + nb::arg("v_speed") = 1.0f, + nb::arg("v_min") = 0, + nb::arg("v_max") = 0, + nb::arg("format") = "%d", + nb::arg("flags") = 0); + + // IMGUI_API bool DragInt3(const char* label, int v[3], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", ImGuiSliderFlags flags = 0); + m.def( + "DragInt3", + [](const char* label, std::array v, float v_speed, int v_min, int v_max, const char* format, ImGuiSliderFlags flags) { + bool result = ImGui::DragInt3(label, v.data(), v_speed, v_min, v_max, format, flags); + return std::make_tuple(result, std::make_tuple(v[0], v[1], v[2])); + }, + nb::arg("label"), + nb::arg("v"), + nb::arg("v_speed") = 1.0f, + nb::arg("v_min") = 0, + nb::arg("v_max") = 0, + nb::arg("format") = "%d", + nb::arg("flags") = 0); + + // IMGUI_API bool DragInt4(const char* label, int v[4], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", ImGuiSliderFlags flags = 0); + m.def( + "DragInt4", + [](const char* label, std::array v, float v_speed, int v_min, int v_max, const char* format, ImGuiSliderFlags flags) { + bool result = ImGui::DragInt4(label, v.data(), v_speed, v_min, v_max, format, flags); + return std::make_tuple(result, std::make_tuple(v[0], v[1], v[2], v[3])); + }, + nb::arg("label"), + nb::arg("v"), + nb::arg("v_speed") = 1.0f, + nb::arg("v_min") = 0, + nb::arg("v_max") = 0, + nb::arg("format") = "%d", + nb::arg("flags") = 0); + + // IMGUI_API bool DragIntRange2(const char* label, int* v_current_min, int* v_current_max, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", const char* format_max = NULL, ImGuiSliderFlags flags = 0); + m.def( + "DragIntRange2", + [](const char* label, int v_current_min, int v_current_max, float v_speed, int v_min, int v_max, const char* format, const char* format_max, ImGuiSliderFlags flags) { + bool result = ImGui::DragIntRange2(label, &v_current_min, &v_current_max, v_speed, v_min, v_max, format, format_max, flags); + return std::make_tuple(result, v_current_min, v_current_max); + }, + nb::arg("label"), + nb::arg("v_current_min"), + nb::arg("v_current_max"), + nb::arg("v_speed") = 1.0f, + nb::arg("v_min") = 0, + nb::arg("v_max") = 0, + nb::arg("format") = "%d", + nb::arg("format_max") = nb::none(), + nb::arg("flags") = 0); + + // IMGUI_API bool DragScalar(const char* label, ImGuiDataType data_type, void* p_data, float v_speed = 1.0f, const void* p_min = NULL, const void* p_max = NULL, const char* format = NULL, ImGuiSliderFlags flags = 0); + // TODO: DragScalar requires void* handling which is complex for Python bindings + + // IMGUI_API bool DragScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, float v_speed = 1.0f, const void* p_min = NULL, const void* p_max = NULL, const char* format = NULL, ImGuiSliderFlags flags = 0); + // TODO: DragScalarN requires void* handling which is complex for Python bindings + +} +// clang-format on diff --git a/src/cpp/imgui/imgui_api_widgets_images.cpp b/src/cpp/imgui/imgui_api_widgets_images.cpp new file mode 100644 index 0000000..9f8778c --- /dev/null +++ b/src/cpp/imgui/imgui_api_widgets_images.cpp @@ -0,0 +1,54 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include + +// clang-format off +void bind_imgui_api_widgets_images(nb::module_& m) { + + // Widgets: Images + // IMGUI_API void Image(ImTextureRef tex_ref, const ImVec2& image_size, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1, 1)); + m.def( + "Image", + [](ImTextureRef tex_ref, const Vec2T& image_size, const Vec2T& uv0, const Vec2T& uv1) { + ImGui::Image(tex_ref, to_vec2(image_size), to_vec2(uv0), to_vec2(uv1)); + }, + nb::arg("user_texture_ref"), + nb::arg("image_size"), + nb::arg("uv0") = Vec2T(0.f, 0.f), + nb::arg("uv1") = Vec2T(1.f, 1.f)); + + // IMGUI_API void ImageWithBg(ImTextureRef tex_ref, const ImVec2& image_size, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1, 1), const ImVec4& bg_col = ImVec4(0, 0, 0, 0), const ImVec4& tint_col = ImVec4(1, 1, 1, 1)); + m.def( + "ImageWithBg", + [](ImTextureRef tex_ref, const Vec2T& image_size, const Vec2T& uv0, const Vec2T& uv1, const Vec4T& bg_col, const Vec4T& tint_col) { + ImGui::ImageWithBg(tex_ref, to_vec2(image_size), to_vec2(uv0), to_vec2(uv1), to_vec4(bg_col), to_vec4(tint_col)); + }, + nb::arg("user_texture_ref"), + nb::arg("image_size"), + nb::arg("uv0") = Vec2T(0.f, 0.f), + nb::arg("uv1") = Vec2T(1.f, 1.f), + nb::arg("bg_col") = Vec4T(0.f, 0.f, 0.f, 0.f), + nb::arg("tint_col") = Vec4T(1.f, 1.f, 1.f, 1.f)); + + // IMGUI_API bool ImageButton(const char* str_id, ImTextureRef tex_ref, const ImVec2& image_size, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1, 1), const ImVec4& bg_col = ImVec4(0, 0, 0, 0), const ImVec4& tint_col = ImVec4(1, 1, 1, 1)); + m.def( + "ImageButton", + [](const char* str_id, ImTextureRef tex_ref, const Vec2T& image_size, const Vec2T& uv0, const Vec2T& uv1, const Vec4T& bg_col, const Vec4T& tint_col) { + return ImGui::ImageButton(str_id, tex_ref, to_vec2(image_size), to_vec2(uv0), to_vec2(uv1), to_vec4(bg_col), to_vec4(tint_col)); + }, + nb::arg("str_id"), + nb::arg("user_texture_ref"), + nb::arg("image_size"), + nb::arg("uv0") = Vec2T(0.f, 0.f), + nb::arg("uv1") = Vec2T(1.f, 1.f), + nb::arg("bg_col") = Vec4T(0.f, 0.f, 0.f, 0.f), + nb::arg("tint_col") = Vec4T(1.f, 1.f, 1.f, 1.f)); + +} +// clang-format on diff --git a/src/cpp/imgui/imgui_api_widgets_input.cpp b/src/cpp/imgui/imgui_api_widgets_input.cpp new file mode 100644 index 0000000..faf85ee --- /dev/null +++ b/src/cpp/imgui/imgui_api_widgets_input.cpp @@ -0,0 +1,187 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include +#include + +// clang-format off +void bind_imgui_api_widgets_input(nb::module_& m) { + + // Widgets: Input with Keyboard + // IMGUI_API bool InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); + m.def( + "InputText", + [](const char* label, const std::string& buf, ImGuiInputTextFlags flags, int32_t max_str_len) { + std::string buffer = buf; + buffer.resize(max_str_len); // Reserve space for editing + bool result = ImGui::InputText(label, buffer.data(), buffer.capacity(), flags); + // Trim to actual string length + buffer.resize(strlen(buffer.c_str())); + return std::make_tuple(result, buffer); + }, + nb::arg("label"), + nb::arg("buf"), + nb::arg("flags") = 0, + nb::arg("max_str_len") = 1024 + ); + // TODO: Callback version not bound + + // IMGUI_API bool InputTextMultiline(const char* label, char* buf, size_t buf_size, const ImVec2& size = ImVec2(0, 0), ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); + m.def( + "InputTextMultiline", + [](const char* label, const std::string& buf, const Vec2T& size, ImGuiInputTextFlags flags, int32_t max_str_len) { + std::string buffer = buf; + buffer.resize(max_str_len); // Reserve larger space for multiline + bool result = ImGui::InputTextMultiline(label, buffer.data(), buffer.capacity(), to_vec2(size), flags); + buffer.resize(strlen(buffer.c_str())); + return std::make_tuple(result, buffer); + }, + nb::arg("label"), + nb::arg("buf"), + nb::arg("size") = Vec2T(0.f, 0.f), + nb::arg("flags") = 0, + nb::arg("max_str_len") = 4096 + ); + // TODO: Callback version not bound + + // IMGUI_API bool InputTextWithHint(const char* label, const char* hint, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); + m.def( + "InputTextWithHint", + [](const char* label, const char* hint, const std::string& buf, ImGuiInputTextFlags flags, int32_t max_str_len) { + std::string buffer = buf; + buffer.resize(max_str_len); + bool result = ImGui::InputTextWithHint(label, hint, buffer.data(), buffer.capacity(), flags); + buffer.resize(strlen(buffer.c_str())); + return std::make_tuple(result, buffer); + }, + nb::arg("label"), + nb::arg("hint"), + nb::arg("buf"), + nb::arg("flags") = 0, + nb::arg("max_str_len") = 1024 + ); + // TODO: Callback version not bound + + // IMGUI_API bool InputFloat(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, const char* format = "%.3f", ImGuiInputTextFlags flags = 0); + m.def( + "InputFloat", + [](const char* label, float v, float step, float step_fast, const char* format, ImGuiInputTextFlags flags) { + bool result = ImGui::InputFloat(label, &v, step, step_fast, format, flags); + return std::make_tuple(result, v); + }, + nb::arg("label"), + nb::arg("v"), + nb::arg("step") = 0.0f, + nb::arg("step_fast") = 0.0f, + nb::arg("format") = "%.3f", + nb::arg("flags") = 0); + + // IMGUI_API bool InputFloat2(const char* label, float v[2], const char* format = "%.3f", ImGuiInputTextFlags flags = 0); + m.def( + "InputFloat2", + [](const char* label, std::array v, const char* format, ImGuiInputTextFlags flags) { + bool result = ImGui::InputFloat2(label, v.data(), format, flags); + return std::make_tuple(result, std::make_tuple(v[0], v[1])); + }, + nb::arg("label"), + nb::arg("v"), + nb::arg("format") = "%.3f", + nb::arg("flags") = 0); + + // IMGUI_API bool InputFloat3(const char* label, float v[3], const char* format = "%.3f", ImGuiInputTextFlags flags = 0); + m.def( + "InputFloat3", + [](const char* label, std::array v, const char* format, ImGuiInputTextFlags flags) { + bool result = ImGui::InputFloat3(label, v.data(), format, flags); + return std::make_tuple(result, std::make_tuple(v[0], v[1], v[2])); + }, + nb::arg("label"), + nb::arg("v"), + nb::arg("format") = "%.3f", + nb::arg("flags") = 0); + + // IMGUI_API bool InputFloat4(const char* label, float v[4], const char* format = "%.3f", ImGuiInputTextFlags flags = 0); + m.def( + "InputFloat4", + [](const char* label, std::array v, const char* format, ImGuiInputTextFlags flags) { + bool result = ImGui::InputFloat4(label, v.data(), format, flags); + return std::make_tuple(result, std::make_tuple(v[0], v[1], v[2], v[3])); + }, + nb::arg("label"), + nb::arg("v"), + nb::arg("format") = "%.3f", + nb::arg("flags") = 0); + + // IMGUI_API bool InputInt(const char* label, int* v, int step = 1, int step_fast = 100, ImGuiInputTextFlags flags = 0); + m.def( + "InputInt", + [](const char* label, int v, int step, int step_fast, ImGuiInputTextFlags flags) { + bool result = ImGui::InputInt(label, &v, step, step_fast, flags); + return std::make_tuple(result, v); + }, + nb::arg("label"), + nb::arg("v"), + nb::arg("step") = 1, + nb::arg("step_fast") = 100, + nb::arg("flags") = 0); + + // IMGUI_API bool InputInt2(const char* label, int v[2], ImGuiInputTextFlags flags = 0); + m.def( + "InputInt2", + [](const char* label, std::array v, ImGuiInputTextFlags flags) { + bool result = ImGui::InputInt2(label, v.data(), flags); + return std::make_tuple(result, std::make_tuple(v[0], v[1])); + }, + nb::arg("label"), + nb::arg("v"), + nb::arg("flags") = 0); + + // IMGUI_API bool InputInt3(const char* label, int v[3], ImGuiInputTextFlags flags = 0); + m.def( + "InputInt3", + [](const char* label, std::array v, ImGuiInputTextFlags flags) { + bool result = ImGui::InputInt3(label, v.data(), flags); + return std::make_tuple(result, std::make_tuple(v[0], v[1], v[2])); + }, + nb::arg("label"), + nb::arg("v"), + nb::arg("flags") = 0); + + // IMGUI_API bool InputInt4(const char* label, int v[4], ImGuiInputTextFlags flags = 0); + m.def( + "InputInt4", + [](const char* label, std::array v, ImGuiInputTextFlags flags) { + bool result = ImGui::InputInt4(label, v.data(), flags); + return std::make_tuple(result, std::make_tuple(v[0], v[1], v[2], v[3])); + }, + nb::arg("label"), + nb::arg("v"), + nb::arg("flags") = 0); + + // IMGUI_API bool InputDouble(const char* label, double* v, double step = 0.0, double step_fast = 0.0, const char* format = "%.6f", ImGuiInputTextFlags flags = 0); + m.def( + "InputDouble", + [](const char* label, double v, double step, double step_fast, const char* format, ImGuiInputTextFlags flags) { + bool result = ImGui::InputDouble(label, &v, step, step_fast, format, flags); + return std::make_tuple(result, v); + }, + nb::arg("label"), + nb::arg("v"), + nb::arg("step") = 0.0, + nb::arg("step_fast") = 0.0, + nb::arg("format") = "%.6f", + nb::arg("flags") = 0); + + // IMGUI_API bool InputScalar(const char* label, ImGuiDataType data_type, void* p_data, const void* p_step = NULL, const void* p_step_fast = NULL, const char* format = NULL, ImGuiInputTextFlags flags = 0); + // TODO: InputScalar requires void* handling which is complex for Python bindings + + // IMGUI_API bool InputScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, const void* p_step = NULL, const void* p_step_fast = NULL, const char* format = NULL, ImGuiInputTextFlags flags = 0); + // TODO: InputScalarN requires void* handling which is complex for Python bindings + +} +// clang-format on diff --git a/src/cpp/imgui/imgui_api_widgets_listbox.cpp b/src/cpp/imgui/imgui_api_widgets_listbox.cpp new file mode 100644 index 0000000..c1cde8c --- /dev/null +++ b/src/cpp/imgui/imgui_api_widgets_listbox.cpp @@ -0,0 +1,48 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include +#include +#include + +// clang-format off +void bind_imgui_api_widgets_listbox(nb::module_& m) { + + // Widgets: List Boxes + // IMGUI_API bool BeginListBox(const char* label, const ImVec2& size = ImVec2(0, 0)); + m.def( + "BeginListBox", + [](const char* label, const Vec2T& size) { return ImGui::BeginListBox(label, to_vec2(size)); }, + nb::arg("label"), + nb::arg("size") = Vec2T(0.f, 0.f)); + + // IMGUI_API void EndListBox(); + m.def("EndListBox", []() { ImGui::EndListBox(); }); + + // IMGUI_API bool ListBox(const char* label, int* current_item, const char* const items[], int items_count, int height_in_items = -1); + m.def( + "ListBox", + [](const char* label, int current_item, const std::vector& items, int height_in_items) { + std::vector item_ptrs; + item_ptrs.reserve(items.size()); + for (const auto& item : items) { + item_ptrs.push_back(item.c_str()); + } + bool result = ImGui::ListBox(label, ¤t_item, item_ptrs.data(), static_cast(item_ptrs.size()), height_in_items); + return std::make_tuple(result, current_item); + }, + nb::arg("label"), + nb::arg("current_item"), + nb::arg("items"), + nb::arg("height_in_items") = -1); + + // IMGUI_API bool ListBox(const char* label, int* current_item, const char* (*getter)(void* user_data, int idx), void* user_data, int items_count, int height_in_items = -1); + // TODO: Callback version requires binding function pointers from Python + +} +// clang-format on diff --git a/src/cpp/imgui/imgui_api_widgets_main.cpp b/src/cpp/imgui/imgui_api_widgets_main.cpp new file mode 100644 index 0000000..2f22c5b --- /dev/null +++ b/src/cpp/imgui/imgui_api_widgets_main.cpp @@ -0,0 +1,124 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include + +// clang-format off +void bind_imgui_api_widgets_main(nb::module_& m) { + + // Widgets: Main + // IMGUI_API bool Button(const char* label, const ImVec2& size = ImVec2(0, 0)); + m.def( + "Button", + [](const char* label, const Vec2T& size) { return ImGui::Button(label, to_vec2(size)); }, + nb::arg("label"), + nb::arg("size") = Vec2T(0.f, 0.f)); + + // IMGUI_API bool SmallButton(const char* label); + m.def( + "SmallButton", + [](const char* label) { return ImGui::SmallButton(label); }, + nb::arg("label")); + + // IMGUI_API bool InvisibleButton(const char* str_id, const ImVec2& size, ImGuiButtonFlags flags = 0); + m.def( + "InvisibleButton", + [](const char* str_id, const Vec2T& size, ImGuiButtonFlags flags) { + return ImGui::InvisibleButton(str_id, to_vec2(size), flags); + }, + nb::arg("str_id"), + nb::arg("size"), + nb::arg("flags") = 0); + + // IMGUI_API bool ArrowButton(const char* str_id, ImGuiDir dir); + m.def( + "ArrowButton", + [](const char* str_id, ImGuiDir dir) { return ImGui::ArrowButton(str_id, dir); }, + nb::arg("str_id"), + nb::arg("dir")); + + // IMGUI_API bool Checkbox(const char* label, bool* v); + m.def( + "Checkbox", + [](const char* label, bool v) { + bool result = ImGui::Checkbox(label, &v); + return std::make_tuple(result, v); + }, + nb::arg("label"), + nb::arg("v")); + + // IMGUI_API bool CheckboxFlags(const char* label, int* flags, int flags_value); + m.def( + "CheckboxFlags", + [](const char* label, int flags, int flags_value) { + bool result = ImGui::CheckboxFlags(label, &flags, flags_value); + return std::make_tuple(result, flags); + }, + nb::arg("label"), + nb::arg("flags"), + nb::arg("flags_value")); + + // IMGUI_API bool CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value); + m.def( + "CheckboxFlags", + [](const char* label, unsigned int flags, unsigned int flags_value) { + bool result = ImGui::CheckboxFlags(label, &flags, flags_value); + return std::make_tuple(result, flags); + }, + nb::arg("label"), + nb::arg("flags"), + nb::arg("flags_value")); + + // IMGUI_API bool RadioButton(const char* label, bool active); + m.def( + "RadioButton", + [](const char* label, bool active) { return ImGui::RadioButton(label, active); }, + nb::arg("label"), + nb::arg("active")); + + // IMGUI_API bool RadioButton(const char* label, int* v, int v_button); + m.def( + "RadioButton", + [](const char* label, int v, int v_button) { + bool result = ImGui::RadioButton(label, &v, v_button); + return std::make_tuple(result, v); + }, + nb::arg("label"), + nb::arg("v"), + nb::arg("v_button")); + + // IMGUI_API void ProgressBar(float fraction, const ImVec2& size_arg = ImVec2(-FLT_MIN, 0), const char* overlay = NULL); + m.def( + "ProgressBar", + [](float fraction, const Vec2T& size_arg, std::string overlay) { + ImGui::ProgressBar(fraction, to_vec2(size_arg), overlay.empty() ? nullptr : overlay.c_str()); + }, + nb::arg("fraction"), + nb::arg("size_arg") = Vec2T(-FLT_MIN, 0.f), + nb::arg("overlay") = ""); + + // IMGUI_API void Bullet(); + m.def("Bullet", []() { ImGui::Bullet(); }); + + // IMGUI_API bool TextLink(const char* label); + m.def( + "TextLink", + [](std::string label) { return ImGui::TextLink(label.c_str()); }, + nb::arg("label")); + + // IMGUI_API void TextLinkOpenURL(const char* label, const char* url = NULL); + m.def( + "TextLinkOpenURL", + [](std::string label, std::string url) { + return ImGui::TextLinkOpenURL(label.c_str(), url.empty() ? nullptr : url.c_str()); + }, + nb::arg("label"), + nb::arg("url") = ""); + +} +// clang-format on diff --git a/src/cpp/imgui/imgui_api_widgets_selectables.cpp b/src/cpp/imgui/imgui_api_widgets_selectables.cpp new file mode 100644 index 0000000..76f2bf7 --- /dev/null +++ b/src/cpp/imgui/imgui_api_widgets_selectables.cpp @@ -0,0 +1,64 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include + +// clang-format off +void bind_imgui_api_widgets_selectables(nb::module_& m) { + + // Widgets: Selectables + // IMGUI_API bool Selectable(const char* label, bool selected = false, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0, 0)); + m.def( + "Selectable", + [](const char* label, bool selected, ImGuiSelectableFlags flags, const Vec2T& size) { + return ImGui::Selectable(label, selected, flags, to_vec2(size)); + }, + nb::arg("label"), + nb::arg("selected") = false, + nb::arg("flags") = 0, + nb::arg("size") = Vec2T(0.f, 0.f)); + + // IMGUI_API bool Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0, 0)); + m.def( + "Selectable", + [](const char* label, bool p_selected, ImGuiSelectableFlags flags, const Vec2T& size) { + bool result = ImGui::Selectable(label, &p_selected, flags, to_vec2(size)); + return std::make_tuple(result, p_selected); + }, + nb::arg("label"), + nb::arg("p_selected"), + nb::arg("flags") = 0, + nb::arg("size") = Vec2T(0.f, 0.f)); + + // IMGUI_API ImGuiMultiSelectIO* BeginMultiSelect(ImGuiMultiSelectFlags flags, int selection_size = -1, int items_count = -1); + m.def( + "BeginMultiSelect", + [](ImGuiMultiSelectFlags flags, int selection_size, int items_count) { + return ImGui::BeginMultiSelect(flags, selection_size, items_count); + }, + nb::arg("flags"), + nb::arg("selection_size") = -1, + nb::arg("items_count") = -1, + nb::rv_policy::reference); + + // IMGUI_API ImGuiMultiSelectIO* EndMultiSelect(); + m.def("EndMultiSelect", []() { return ImGui::EndMultiSelect(); }, nb::rv_policy::reference); + + // IMGUI_API void SetNextItemSelectionUserData(ImGuiSelectionUserData selection_user_data); + m.def( + "SetNextItemSelectionUserData", + [](ImGuiSelectionUserData selection_user_data) { + ImGui::SetNextItemSelectionUserData(selection_user_data); + }, + nb::arg("selection_user_data")); + + // IMGUI_API bool IsItemToggledSelection(); + m.def("IsItemToggledSelection", []() { return ImGui::IsItemToggledSelection(); }); + +} +// clang-format on diff --git a/src/cpp/imgui/imgui_api_widgets_sliders.cpp b/src/cpp/imgui/imgui_api_widgets_sliders.cpp new file mode 100644 index 0000000..a007a36 --- /dev/null +++ b/src/cpp/imgui/imgui_api_widgets_sliders.cpp @@ -0,0 +1,181 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include + +// clang-format off +void bind_imgui_api_widgets_sliders(nb::module_& m) { + + // Widgets: Regular Sliders + // IMGUI_API bool SliderFloat(const char* label, float* v, float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0); + m.def( + "SliderFloat", + [](const char* label, float v, float v_min, float v_max, const char* format, ImGuiSliderFlags flags) { + bool result = ImGui::SliderFloat(label, &v, v_min, v_max, format, flags); + return std::make_tuple(result, v); + }, + nb::arg("label"), + nb::arg("v"), + nb::arg("v_min"), + nb::arg("v_max"), + nb::arg("format") = "%.3f", + nb::arg("flags") = 0); + + // IMGUI_API bool SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0); + m.def( + "SliderFloat2", + [](const char* label, std::array v, float v_min, float v_max, const char* format, ImGuiSliderFlags flags) { + bool result = ImGui::SliderFloat2(label, v.data(), v_min, v_max, format, flags); + return std::make_tuple(result, std::make_tuple(v[0], v[1])); + }, + nb::arg("label"), + nb::arg("v"), + nb::arg("v_min"), + nb::arg("v_max"), + nb::arg("format") = "%.3f", + nb::arg("flags") = 0); + + // IMGUI_API bool SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0); + m.def( + "SliderFloat3", + [](const char* label, std::array v, float v_min, float v_max, const char* format, ImGuiSliderFlags flags) { + bool result = ImGui::SliderFloat3(label, v.data(), v_min, v_max, format, flags); + return std::make_tuple(result, std::make_tuple(v[0], v[1], v[2])); + }, + nb::arg("label"), + nb::arg("v"), + nb::arg("v_min"), + nb::arg("v_max"), + nb::arg("format") = "%.3f", + nb::arg("flags") = 0); + + // IMGUI_API bool SliderFloat4(const char* label, float v[4], float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0); + m.def( + "SliderFloat4", + [](const char* label, std::array v, float v_min, float v_max, const char* format, ImGuiSliderFlags flags) { + bool result = ImGui::SliderFloat4(label, v.data(), v_min, v_max, format, flags); + return std::make_tuple(result, std::make_tuple(v[0], v[1], v[2], v[3])); + }, + nb::arg("label"), + nb::arg("v"), + nb::arg("v_min"), + nb::arg("v_max"), + nb::arg("format") = "%.3f", + nb::arg("flags") = 0); + + // IMGUI_API bool SliderAngle(const char* label, float* v_rad, float v_degrees_min = -360.0f, float v_degrees_max = +360.0f, const char* format = "%.0f deg", ImGuiSliderFlags flags = 0); + m.def( + "SliderAngle", + [](const char* label, float v_rad, float v_degrees_min, float v_degrees_max, const char* format, ImGuiSliderFlags flags) { + bool result = ImGui::SliderAngle(label, &v_rad, v_degrees_min, v_degrees_max, format, flags); + return std::make_tuple(result, v_rad); + }, + nb::arg("label"), + nb::arg("v_rad"), + nb::arg("v_degrees_min") = -360.0f, + nb::arg("v_degrees_max") = +360.0f, + nb::arg("format") = "%.0f deg", + nb::arg("flags") = 0); + + // IMGUI_API bool SliderInt(const char* label, int* v, int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0); + m.def( + "SliderInt", + [](const char* label, int v, int v_min, int v_max, const char* format, ImGuiSliderFlags flags) { + bool result = ImGui::SliderInt(label, &v, v_min, v_max, format, flags); + return std::make_tuple(result, v); + }, + nb::arg("label"), + nb::arg("v"), + nb::arg("v_min"), + nb::arg("v_max"), + nb::arg("format") = "%d", + nb::arg("flags") = 0); + + // IMGUI_API bool SliderInt2(const char* label, int v[2], int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0); + m.def( + "SliderInt2", + [](const char* label, std::array v, int v_min, int v_max, const char* format, ImGuiSliderFlags flags) { + bool result = ImGui::SliderInt2(label, v.data(), v_min, v_max, format, flags); + return std::make_tuple(result, std::make_tuple(v[0], v[1])); + }, + nb::arg("label"), + nb::arg("v"), + nb::arg("v_min"), + nb::arg("v_max"), + nb::arg("format") = "%d", + nb::arg("flags") = 0); + + // IMGUI_API bool SliderInt3(const char* label, int v[3], int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0); + m.def( + "SliderInt3", + [](const char* label, std::array v, int v_min, int v_max, const char* format, ImGuiSliderFlags flags) { + bool result = ImGui::SliderInt3(label, v.data(), v_min, v_max, format, flags); + return std::make_tuple(result, std::make_tuple(v[0], v[1], v[2])); + }, + nb::arg("label"), + nb::arg("v"), + nb::arg("v_min"), + nb::arg("v_max"), + nb::arg("format") = "%d", + nb::arg("flags") = 0); + + // IMGUI_API bool SliderInt4(const char* label, int v[4], int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0); + m.def( + "SliderInt4", + [](const char* label, std::array v, int v_min, int v_max, const char* format, ImGuiSliderFlags flags) { + bool result = ImGui::SliderInt4(label, v.data(), v_min, v_max, format, flags); + return std::make_tuple(result, std::make_tuple(v[0], v[1], v[2], v[3])); + }, + nb::arg("label"), + nb::arg("v"), + nb::arg("v_min"), + nb::arg("v_max"), + nb::arg("format") = "%d", + nb::arg("flags") = 0); + + // IMGUI_API bool SliderScalar(const char* label, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format = NULL, ImGuiSliderFlags flags = 0); + // TODO: SliderScalar requires void* handling which is complex for Python bindings + + // IMGUI_API bool SliderScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, const void* p_min, const void* p_max, const char* format = NULL, ImGuiSliderFlags flags = 0); + // TODO: SliderScalarN requires void* handling which is complex for Python bindings + + // IMGUI_API bool VSliderFloat(const char* label, const ImVec2& size, float* v, float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0); + m.def( + "VSliderFloat", + [](const char* label, const Vec2T& size, float v, float v_min, float v_max, const char* format, ImGuiSliderFlags flags) { + bool result = ImGui::VSliderFloat(label, to_vec2(size), &v, v_min, v_max, format, flags); + return std::make_tuple(result, v); + }, + nb::arg("label"), + nb::arg("size"), + nb::arg("v"), + nb::arg("v_min"), + nb::arg("v_max"), + nb::arg("format") = "%.3f", + nb::arg("flags") = 0); + + // IMGUI_API bool VSliderInt(const char* label, const ImVec2& size, int* v, int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0); + m.def( + "VSliderInt", + [](const char* label, const Vec2T& size, int v, int v_min, int v_max, const char* format, ImGuiSliderFlags flags) { + bool result = ImGui::VSliderInt(label, to_vec2(size), &v, v_min, v_max, format, flags); + return std::make_tuple(result, v); + }, + nb::arg("label"), + nb::arg("size"), + nb::arg("v"), + nb::arg("v_min"), + nb::arg("v_max"), + nb::arg("format") = "%d", + nb::arg("flags") = 0); + + // IMGUI_API bool VSliderScalar(const char* label, const ImVec2& size, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format = NULL, ImGuiSliderFlags flags = 0); + // TODO: VSliderScalar requires void* handling which is complex for Python bindings + +} +// clang-format on diff --git a/src/cpp/imgui/imgui_api_widgets_text.cpp b/src/cpp/imgui/imgui_api_widgets_text.cpp new file mode 100644 index 0000000..3e072bd --- /dev/null +++ b/src/cpp/imgui/imgui_api_widgets_text.cpp @@ -0,0 +1,84 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include + +// clang-format off +void bind_imgui_api_widgets_text(nb::module_& m) { + + // Widgets: Text + // IMGUI_API void TextUnformatted(const char* text, const char* text_end = NULL); + m.def( + "TextUnformatted", + [](const char* text) { ImGui::TextUnformatted(text); }, + nb::arg("text")); + + // IMGUI_API void Text(const char* fmt, ...) IM_FMTARGS(1); + m.def( + "Text", + [](const char* text) { ImGui::TextUnformatted(text); }, + nb::arg("text")); + + // IMGUI_API void TextV(const char* fmt, va_list args) IM_FMTLIST(1); + // TODO: variadic/va_list functions not bound - use Text() with pre-formatted string from Python + + // IMGUI_API void TextColored(const ImVec4& col, const char* fmt, ...) IM_FMTARGS(2); + m.def( + "TextColored", + [](const Vec4T& col, const char* text) { ImGui::TextColored(to_vec4(col), "%s", text); }, + nb::arg("col"), + nb::arg("text")); + + // IMGUI_API void TextColoredV(const ImVec4& col, const char* fmt, va_list args) IM_FMTLIST(2); + // TODO: variadic/va_list functions not bound - use TextColored() with pre-formatted string from Python + + // IMGUI_API void TextDisabled(const char* fmt, ...) IM_FMTARGS(1); + m.def( + "TextDisabled", + [](const char* text) { ImGui::TextDisabled("%s", text); }, + nb::arg("text")); + + // IMGUI_API void TextDisabledV(const char* fmt, va_list args) IM_FMTLIST(1); + // TODO: variadic/va_list functions not bound - use TextDisabled() with pre-formatted string from Python + + // IMGUI_API void TextWrapped(const char* fmt, ...) IM_FMTARGS(1); + m.def( + "TextWrapped", + [](const char* text) { ImGui::TextWrapped("%s", text); }, + nb::arg("text")); + + // IMGUI_API void TextWrappedV(const char* fmt, va_list args) IM_FMTLIST(1); + // TODO: variadic/va_list functions not bound - use TextWrapped() with pre-formatted string from Python + + // IMGUI_API void LabelText(const char* label, const char* fmt, ...) IM_FMTARGS(2); + m.def( + "LabelText", + [](const char* label, const char* text) { ImGui::LabelText(label, "%s", text); }, + nb::arg("label"), + nb::arg("text")); + + // IMGUI_API void LabelTextV(const char* label, const char* fmt, va_list args) IM_FMTLIST(2); + // TODO: variadic/va_list functions not bound - use LabelText() with pre-formatted string from Python + + // IMGUI_API void BulletText(const char* fmt, ...) IM_FMTARGS(1); + m.def( + "BulletText", + [](const char* text) { ImGui::BulletText("%s", text); }, + nb::arg("text")); + + // IMGUI_API void BulletTextV(const char* fmt, va_list args) IM_FMTLIST(1); + // TODO: variadic/va_list functions not bound - use BulletText() with pre-formatted string from Python + + // IMGUI_API void SeparatorText(const char* label); + m.def( + "SeparatorText", + [](const char* label) { ImGui::SeparatorText(label); }, + nb::arg("label")); + +} +// clang-format on diff --git a/src/cpp/imgui/imgui_api_widgets_trees.cpp b/src/cpp/imgui/imgui_api_widgets_trees.cpp new file mode 100644 index 0000000..aeb5470 --- /dev/null +++ b/src/cpp/imgui/imgui_api_widgets_trees.cpp @@ -0,0 +1,110 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include + +// clang-format off +void bind_imgui_api_widgets_trees(nb::module_& m) { + + // Widgets: Trees + // IMGUI_API bool TreeNode(const char* label); + m.def( + "TreeNode", + [](const char* label) { return ImGui::TreeNode(label); }, + nb::arg("label")); + + // IMGUI_API bool TreeNode(const char* str_id, const char* fmt, ...) IM_FMTARGS(2); + m.def( + "TreeNode", + [](const char* str_id, const char* text) { return ImGui::TreeNode(str_id, "%s", text); }, + nb::arg("str_id"), + nb::arg("text")); + + // IMGUI_API bool TreeNode(const void* ptr_id, const char* fmt, ...) IM_FMTARGS(2); + // TODO: Pointer ID version not bound + + // IMGUI_API bool TreeNodeV(const char* str_id, const char* fmt, va_list args) IM_FMTLIST(2); + // TODO: Variadic version not bound + + // IMGUI_API bool TreeNodeV(const void* ptr_id, const char* fmt, va_list args) IM_FMTLIST(2); + // TODO: Variadic version not bound + + // IMGUI_API bool TreeNodeEx(const char* label, ImGuiTreeNodeFlags flags = 0); + m.def( + "TreeNodeEx", + [](const char* label, ImGuiTreeNodeFlags flags) { return ImGui::TreeNodeEx(label, flags); }, + nb::arg("label"), + nb::arg("flags") = 0); + + // IMGUI_API bool TreeNodeEx(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, ...) IM_FMTARGS(3); + m.def( + "TreeNodeEx", + [](const char* str_id, ImGuiTreeNodeFlags flags, const char* text) { + return ImGui::TreeNodeEx(str_id, flags, "%s", text); + }, + nb::arg("str_id"), + nb::arg("flags"), + nb::arg("text")); + + // IMGUI_API bool TreeNodeEx(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, ...) IM_FMTARGS(3); + // TODO: Pointer ID version not bound + + // IMGUI_API bool TreeNodeExV(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args) IM_FMTLIST(3); + // TODO: Variadic version not bound + + // IMGUI_API bool TreeNodeExV(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args) IM_FMTLIST(3); + // TODO: Variadic version not bound + + // IMGUI_API void TreePush(const char* str_id); + m.def( + "TreePush", + [](const char* str_id) { ImGui::TreePush(str_id); }, + nb::arg("str_id")); + + // IMGUI_API void TreePush(const void* ptr_id); + // TODO: Pointer ID version not bound + + // IMGUI_API void TreePop(); + m.def("TreePop", []() { ImGui::TreePop(); }); + + // IMGUI_API float GetTreeNodeToLabelSpacing(); + m.def("GetTreeNodeToLabelSpacing", []() { return ImGui::GetTreeNodeToLabelSpacing(); }); + + // IMGUI_API bool CollapsingHeader(const char* label, ImGuiTreeNodeFlags flags = 0); + m.def( + "CollapsingHeader", + [](const char* label, ImGuiTreeNodeFlags flags) { return ImGui::CollapsingHeader(label, flags); }, + nb::arg("label"), + nb::arg("flags") = 0); + + // IMGUI_API bool CollapsingHeader(const char* label, bool* p_visible, ImGuiTreeNodeFlags flags = 0); + m.def( + "CollapsingHeader", + [](const char* label, bool p_visible, ImGuiTreeNodeFlags flags) { + bool result = ImGui::CollapsingHeader(label, &p_visible, flags); + return std::make_tuple(result, p_visible); + }, + nb::arg("label"), + nb::arg("p_visible"), + nb::arg("flags") = 0); + + // IMGUI_API void SetNextItemOpen(bool is_open, ImGuiCond cond = 0); + m.def( + "SetNextItemOpen", + [](bool is_open, ImGuiCond cond) { ImGui::SetNextItemOpen(is_open, cond); }, + nb::arg("is_open"), + nb::arg("cond") = 0); + + // IMGUI_API void SetNextItemStorageID(ImGuiID storage_id); + m.def( + "SetNextItemStorageID", + [](ImGuiID storage_id) { ImGui::SetNextItemStorageID(storage_id); }, + nb::arg("storage_id")); + +} +// clang-format on diff --git a/src/cpp/imgui/imgui_api_window_manipulation.cpp b/src/cpp/imgui/imgui_api_window_manipulation.cpp new file mode 100644 index 0000000..a1ed9eb --- /dev/null +++ b/src/cpp/imgui/imgui_api_window_manipulation.cpp @@ -0,0 +1,131 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include + +// clang-format off +void bind_imgui_api_window_manipulation(nb::module_& m) { + + // Window manipulation + // IMGUI_API void SetNextWindowPos(const ImVec2& pos, ImGuiCond cond = 0, const ImVec2& pivot = ImVec2(0, 0)); + m.def( + "SetNextWindowPos", + [](const Vec2T& pos, ImGuiCond cond, const Vec2T& pivot) { + ImGui::SetNextWindowPos(to_vec2(pos), cond, to_vec2(pivot)); + }, + nb::arg("pos"), + nb::arg("cond") = 0, + nb::arg("pivot") = Vec2T(0., 0.)); + + // IMGUI_API void SetNextWindowSize(const ImVec2& size, ImGuiCond cond = 0); + m.def( + "SetNextWindowSize", + [](const Vec2T& size, ImGuiCond cond) { ImGui::SetNextWindowSize(to_vec2(size), cond); }, + nb::arg("size"), + nb::arg("cond") = 0); + + // IMGUI_API void SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& size_max, ImGuiSizeCallback custom_callback = NULL, void* custom_callback_data = NULL); + // TODO: bind callback version + m.def( + "SetNextWindowSizeConstraints", + [](const Vec2T& size_min, const Vec2T& size_max) { + ImGui::SetNextWindowSizeConstraints(to_vec2(size_min), to_vec2(size_max)); + }, + nb::arg("size_min"), + nb::arg("size_max")); + + // IMGUI_API void SetNextWindowContentSize(const ImVec2& size); + m.def( + "SetNextWindowContentSize", + [](const Vec2T& size) { ImGui::SetNextWindowContentSize(to_vec2(size)); }, + nb::arg("size")); + + // IMGUI_API void SetNextWindowCollapsed(bool collapsed, ImGuiCond cond = 0); + m.def( + "SetNextWindowCollapsed", + [](bool collapsed, ImGuiCond cond) { ImGui::SetNextWindowCollapsed(collapsed, cond); }, + nb::arg("collapsed"), + nb::arg("cond") = 0); + + // IMGUI_API void SetNextWindowFocus(); + m.def("SetNextWindowFocus", []() { ImGui::SetNextWindowFocus(); }); + + // IMGUI_API void SetNextWindowScroll(const ImVec2& scroll); + m.def( + "SetNextWindowScroll", + [](const Vec2T& scroll) { ImGui::SetNextWindowScroll(to_vec2(scroll)); }, + nb::arg("scroll")); + + // IMGUI_API void SetNextWindowBgAlpha(float alpha); + m.def( + "SetNextWindowBgAlpha", + [](float alpha) { ImGui::SetNextWindowBgAlpha(alpha); }, + nb::arg("alpha")); + + // IMGUI_API void SetWindowPos(const ImVec2& pos, ImGuiCond cond = 0); + m.def( + "SetWindowPos", + [](const Vec2T& pos, ImGuiCond cond) { ImGui::SetWindowPos(to_vec2(pos), cond); }, + nb::arg("pos"), + nb::arg("cond") = 0); + + // IMGUI_API void SetWindowSize(const ImVec2& size, ImGuiCond cond = 0); + m.def( + "SetWindowSize", + [](const Vec2T& size, ImGuiCond cond) { ImGui::SetWindowSize(to_vec2(size), cond); }, + nb::arg("size"), + nb::arg("cond") = 0); + + // IMGUI_API void SetWindowCollapsed(bool collapsed, ImGuiCond cond = 0); + m.def( + "SetWindowCollapsed", + [](bool collapsed, ImGuiCond cond) { ImGui::SetWindowCollapsed(collapsed, cond); }, + nb::arg("collapsed"), + nb::arg("cond") = 0); + + // IMGUI_API void SetWindowFocus(); + m.def("SetWindowFocus", []() { ImGui::SetWindowFocus(); }); + + // IMGUI_API void SetWindowPos(const char* name, const ImVec2& pos, ImGuiCond cond = 0); + m.def( + "SetWindowPos", + [](const char* name, const Vec2T& pos, ImGuiCond cond) { + ImGui::SetWindowPos(name, to_vec2(pos), cond); + }, + nb::arg("name"), + nb::arg("pos"), + nb::arg("cond") = 0); + + // IMGUI_API void SetWindowSize(const char* name, const ImVec2& size, ImGuiCond cond = 0); + m.def( + "SetWindowSize", + [](const char* name, const Vec2T& size, ImGuiCond cond) { + ImGui::SetWindowSize(name, to_vec2(size), cond); + }, + nb::arg("name"), + nb::arg("size"), + nb::arg("cond") = 0); + + // IMGUI_API void SetWindowCollapsed(const char* name, bool collapsed, ImGuiCond cond = 0); + m.def( + "SetWindowCollapsed", + [](const char* name, bool collapsed, ImGuiCond cond) { + ImGui::SetWindowCollapsed(name, collapsed, cond); + }, + nb::arg("name"), + nb::arg("collapsed"), + nb::arg("cond") = 0); + + // IMGUI_API void SetWindowFocus(const char* name); + m.def( + "SetWindowFocus", + [](const char* name) { ImGui::SetWindowFocus(name); }, + nb::arg("name")); + +} +// clang-format on diff --git a/src/cpp/imgui/imgui_api_window_utilities.cpp b/src/cpp/imgui/imgui_api_window_utilities.cpp new file mode 100644 index 0000000..8152432 --- /dev/null +++ b/src/cpp/imgui/imgui_api_window_utilities.cpp @@ -0,0 +1,49 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include + +// clang-format off +void bind_imgui_api_window_utilities(nb::module_& m) { + + // Windows Utilities + // IMGUI_API bool IsWindowAppearing(); + m.def("IsWindowAppearing", []() { return ImGui::IsWindowAppearing(); }); + + // IMGUI_API bool IsWindowCollapsed(); + m.def("IsWindowCollapsed", []() { return ImGui::IsWindowCollapsed(); }); + + // IMGUI_API bool IsWindowFocused(ImGuiFocusedFlags flags=0); + m.def( + "IsWindowFocused", + [](ImGuiFocusedFlags flags) { return ImGui::IsWindowFocused(flags); }, + nb::arg("flags") = 0); + + // IMGUI_API bool IsWindowHovered(ImGuiHoveredFlags flags=0); + m.def( + "IsWindowHovered", + [](ImGuiHoveredFlags flags) { return ImGui::IsWindowHovered(flags); }, + nb::arg("flags") = 0); + + // IMGUI_API ImDrawList* GetWindowDrawList(); + m.def("GetWindowDrawList", []() { return ImGui::GetWindowDrawList(); }, nb::rv_policy::reference); + + // IMGUI_API ImVec2 GetWindowPos(); + m.def("GetWindowPos", []() { return from_vec2(ImGui::GetWindowPos()); }); + + // IMGUI_API ImVec2 GetWindowSize(); + m.def("GetWindowSize", []() { return from_vec2(ImGui::GetWindowSize()); }); + + // IMGUI_API float GetWindowWidth(); + m.def("GetWindowWidth", []() { return ImGui::GetWindowWidth(); }); + + // IMGUI_API float GetWindowHeight(); + m.def("GetWindowHeight", []() { return ImGui::GetWindowHeight(); }); + +} +// clang-format on diff --git a/src/cpp/imgui/imgui_api_windows.cpp b/src/cpp/imgui/imgui_api_windows.cpp new file mode 100644 index 0000000..8bf0e8f --- /dev/null +++ b/src/cpp/imgui/imgui_api_windows.cpp @@ -0,0 +1,38 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include + +// clang-format off +void bind_imgui_api_windows(nb::module_& m) { + + // Windows + // IMGUI_API bool Begin(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0); + m.def( + "Begin", + [](const char* name, ImGuiWindowFlags flags) { + const auto clicked = ImGui::Begin(name, nullptr, flags); + return clicked; + }, + nb::arg("name"), + nb::arg("flags") = 0); + m.def( + "Begin", + [](const char* name, bool open, ImGuiWindowFlags flags) { + const auto clicked = ImGui::Begin(name, &open, flags); + return std::make_tuple(clicked, open); + }, + nb::arg("name"), + nb::arg("open"), + nb::arg("flags") = 0); + + // IMGUI_API void End(); + m.def("End", []() { ImGui::End(); }); + +} +// clang-format on diff --git a/src/cpp/imgui/imgui_enums.cpp b/src/cpp/imgui/imgui_enums.cpp new file mode 100644 index 0000000..4497b7b --- /dev/null +++ b/src/cpp/imgui/imgui_enums.cpp @@ -0,0 +1,853 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +void bind_imgui_enums(nb::module_& m) { + + { // ImGuiDir ImGuiDir + auto e = nb::enum_(m, "ImGuiDir"); + e.value("ImGuiDir_None", ImGuiDir_None); m.attr("ImGuiDir_None") = static_cast(ImGuiDir_None); + e.value("ImGuiDir_Left", ImGuiDir_Left); m.attr("ImGuiDir_Left") = static_cast(ImGuiDir_Left); + e.value("ImGuiDir_Right", ImGuiDir_Right); m.attr("ImGuiDir_Right") = static_cast(ImGuiDir_Right); + e.value("ImGuiDir_Up", ImGuiDir_Up); m.attr("ImGuiDir_Up") = static_cast(ImGuiDir_Up); + e.value("ImGuiDir_Down", ImGuiDir_Down); m.attr("ImGuiDir_Down") = static_cast(ImGuiDir_Down); + e.value("ImGuiDir_COUNT", ImGuiDir_COUNT); m.attr("ImGuiDir_COUNT") = static_cast(ImGuiDir_COUNT); + ; + } + + { // ImGuiSortDirection ImGuiSortDirection + auto e = nb::enum_(m, "ImGuiSortDirection"); + e.value("ImGuiSortDirection_None", ImGuiSortDirection_None); m.attr("ImGuiSortDirection_None") = static_cast(ImGuiSortDirection_None); + e.value("ImGuiSortDirection_Ascending", ImGuiSortDirection_Ascending); m.attr("ImGuiSortDirection_Ascending") = static_cast(ImGuiSortDirection_Ascending); + e.value("ImGuiSortDirection_Descending", ImGuiSortDirection_Descending); m.attr("ImGuiSortDirection_Descending") = static_cast(ImGuiSortDirection_Descending); + ; + } + + { // ImGuiWindowFlags ImGuiWindowFlags_ + auto e = nb::enum_(m, "ImGuiWindowFlags"); + e.value("ImGuiWindowFlags_None", ImGuiWindowFlags_None); m.attr("ImGuiWindowFlags_None") = static_cast(ImGuiWindowFlags_None); + e.value("ImGuiWindowFlags_NoTitleBar", ImGuiWindowFlags_NoTitleBar); m.attr("ImGuiWindowFlags_NoTitleBar") = static_cast(ImGuiWindowFlags_NoTitleBar); + e.value("ImGuiWindowFlags_NoResize", ImGuiWindowFlags_NoResize); m.attr("ImGuiWindowFlags_NoResize") = static_cast(ImGuiWindowFlags_NoResize); + e.value("ImGuiWindowFlags_NoMove", ImGuiWindowFlags_NoMove); m.attr("ImGuiWindowFlags_NoMove") = static_cast(ImGuiWindowFlags_NoMove); + e.value("ImGuiWindowFlags_NoScrollbar", ImGuiWindowFlags_NoScrollbar); m.attr("ImGuiWindowFlags_NoScrollbar") = static_cast(ImGuiWindowFlags_NoScrollbar); + e.value("ImGuiWindowFlags_NoScrollWithMouse", ImGuiWindowFlags_NoScrollWithMouse); m.attr("ImGuiWindowFlags_NoScrollWithMouse") = static_cast(ImGuiWindowFlags_NoScrollWithMouse); + e.value("ImGuiWindowFlags_NoCollapse", ImGuiWindowFlags_NoCollapse); m.attr("ImGuiWindowFlags_NoCollapse") = static_cast(ImGuiWindowFlags_NoCollapse); + e.value("ImGuiWindowFlags_AlwaysAutoResize", ImGuiWindowFlags_AlwaysAutoResize); m.attr("ImGuiWindowFlags_AlwaysAutoResize") = static_cast(ImGuiWindowFlags_AlwaysAutoResize); + e.value("ImGuiWindowFlags_NoBackground", ImGuiWindowFlags_NoBackground); m.attr("ImGuiWindowFlags_NoBackground") = static_cast(ImGuiWindowFlags_NoBackground); + e.value("ImGuiWindowFlags_NoSavedSettings", ImGuiWindowFlags_NoSavedSettings); m.attr("ImGuiWindowFlags_NoSavedSettings") = static_cast(ImGuiWindowFlags_NoSavedSettings); + e.value("ImGuiWindowFlags_NoMouseInputs", ImGuiWindowFlags_NoMouseInputs); m.attr("ImGuiWindowFlags_NoMouseInputs") = static_cast(ImGuiWindowFlags_NoMouseInputs); + e.value("ImGuiWindowFlags_MenuBar", ImGuiWindowFlags_MenuBar); m.attr("ImGuiWindowFlags_MenuBar") = static_cast(ImGuiWindowFlags_MenuBar); + e.value("ImGuiWindowFlags_HorizontalScrollbar", ImGuiWindowFlags_HorizontalScrollbar); m.attr("ImGuiWindowFlags_HorizontalScrollbar") = static_cast(ImGuiWindowFlags_HorizontalScrollbar); + e.value("ImGuiWindowFlags_NoFocusOnAppearing", ImGuiWindowFlags_NoFocusOnAppearing); m.attr("ImGuiWindowFlags_NoFocusOnAppearing") = static_cast(ImGuiWindowFlags_NoFocusOnAppearing); + e.value("ImGuiWindowFlags_NoBringToFrontOnFocus", ImGuiWindowFlags_NoBringToFrontOnFocus); m.attr("ImGuiWindowFlags_NoBringToFrontOnFocus") = static_cast(ImGuiWindowFlags_NoBringToFrontOnFocus); + e.value("ImGuiWindowFlags_AlwaysVerticalScrollbar", ImGuiWindowFlags_AlwaysVerticalScrollbar); m.attr("ImGuiWindowFlags_AlwaysVerticalScrollbar") = static_cast(ImGuiWindowFlags_AlwaysVerticalScrollbar); + e.value("ImGuiWindowFlags_AlwaysHorizontalScrollbar", ImGuiWindowFlags_AlwaysHorizontalScrollbar); m.attr("ImGuiWindowFlags_AlwaysHorizontalScrollbar") = static_cast(ImGuiWindowFlags_AlwaysHorizontalScrollbar); + e.value("ImGuiWindowFlags_NoNavInputs", ImGuiWindowFlags_NoNavInputs); m.attr("ImGuiWindowFlags_NoNavInputs") = static_cast(ImGuiWindowFlags_NoNavInputs); + e.value("ImGuiWindowFlags_NoNavFocus", ImGuiWindowFlags_NoNavFocus); m.attr("ImGuiWindowFlags_NoNavFocus") = static_cast(ImGuiWindowFlags_NoNavFocus); + e.value("ImGuiWindowFlags_UnsavedDocument", ImGuiWindowFlags_UnsavedDocument); m.attr("ImGuiWindowFlags_UnsavedDocument") = static_cast(ImGuiWindowFlags_UnsavedDocument); + e.value("ImGuiWindowFlags_NoNav", ImGuiWindowFlags_NoNav); m.attr("ImGuiWindowFlags_NoNav") = static_cast(ImGuiWindowFlags_NoNav); + e.value("ImGuiWindowFlags_NoDecoration", ImGuiWindowFlags_NoDecoration); m.attr("ImGuiWindowFlags_NoDecoration") = static_cast(ImGuiWindowFlags_NoDecoration); + e.value("ImGuiWindowFlags_NoInputs", ImGuiWindowFlags_NoInputs); m.attr("ImGuiWindowFlags_NoInputs") = static_cast(ImGuiWindowFlags_NoInputs); + e.value("ImGuiWindowFlags_ChildWindow", ImGuiWindowFlags_ChildWindow); m.attr("ImGuiWindowFlags_ChildWindow") = static_cast(ImGuiWindowFlags_ChildWindow); + e.value("ImGuiWindowFlags_Tooltip", ImGuiWindowFlags_Tooltip); m.attr("ImGuiWindowFlags_Tooltip") = static_cast(ImGuiWindowFlags_Tooltip); + e.value("ImGuiWindowFlags_Popup", ImGuiWindowFlags_Popup); m.attr("ImGuiWindowFlags_Popup") = static_cast(ImGuiWindowFlags_Popup); + e.value("ImGuiWindowFlags_Modal", ImGuiWindowFlags_Modal); m.attr("ImGuiWindowFlags_Modal") = static_cast(ImGuiWindowFlags_Modal); + e.value("ImGuiWindowFlags_ChildMenu", ImGuiWindowFlags_ChildMenu); m.attr("ImGuiWindowFlags_ChildMenu") = static_cast(ImGuiWindowFlags_ChildMenu); + ; + } + + { // ImGuiChildFlags ImGuiChildFlags_ + auto e = nb::enum_(m, "ImGuiChildFlags"); + e.value("ImGuiChildFlags_None", ImGuiChildFlags_None); m.attr("ImGuiChildFlags_None") = static_cast(ImGuiChildFlags_None); + e.value("ImGuiChildFlags_Borders", ImGuiChildFlags_Borders); m.attr("ImGuiChildFlags_Borders") = static_cast(ImGuiChildFlags_Borders); + e.value("ImGuiChildFlags_AlwaysUseWindowPadding", ImGuiChildFlags_AlwaysUseWindowPadding); m.attr("ImGuiChildFlags_AlwaysUseWindowPadding") = static_cast(ImGuiChildFlags_AlwaysUseWindowPadding); + e.value("ImGuiChildFlags_ResizeX", ImGuiChildFlags_ResizeX); m.attr("ImGuiChildFlags_ResizeX") = static_cast(ImGuiChildFlags_ResizeX); + e.value("ImGuiChildFlags_ResizeY", ImGuiChildFlags_ResizeY); m.attr("ImGuiChildFlags_ResizeY") = static_cast(ImGuiChildFlags_ResizeY); + e.value("ImGuiChildFlags_AutoResizeX", ImGuiChildFlags_AutoResizeX); m.attr("ImGuiChildFlags_AutoResizeX") = static_cast(ImGuiChildFlags_AutoResizeX); + e.value("ImGuiChildFlags_AutoResizeY", ImGuiChildFlags_AutoResizeY); m.attr("ImGuiChildFlags_AutoResizeY") = static_cast(ImGuiChildFlags_AutoResizeY); + e.value("ImGuiChildFlags_AlwaysAutoResize", ImGuiChildFlags_AlwaysAutoResize); m.attr("ImGuiChildFlags_AlwaysAutoResize") = static_cast(ImGuiChildFlags_AlwaysAutoResize); + e.value("ImGuiChildFlags_FrameStyle", ImGuiChildFlags_FrameStyle); m.attr("ImGuiChildFlags_FrameStyle") = static_cast(ImGuiChildFlags_FrameStyle); + e.value("ImGuiChildFlags_NavFlattened", ImGuiChildFlags_NavFlattened); m.attr("ImGuiChildFlags_NavFlattened") = static_cast(ImGuiChildFlags_NavFlattened); + ; + } + + { // ImGuiItemFlags ImGuiItemFlags_ + auto e = nb::enum_(m, "ImGuiItemFlags"); + e.value("ImGuiItemFlags_None", ImGuiItemFlags_None); m.attr("ImGuiItemFlags_None") = static_cast(ImGuiItemFlags_None); + e.value("ImGuiItemFlags_NoTabStop", ImGuiItemFlags_NoTabStop); m.attr("ImGuiItemFlags_NoTabStop") = static_cast(ImGuiItemFlags_NoTabStop); + e.value("ImGuiItemFlags_NoNav", ImGuiItemFlags_NoNav); m.attr("ImGuiItemFlags_NoNav") = static_cast(ImGuiItemFlags_NoNav); + e.value("ImGuiItemFlags_NoNavDefaultFocus", ImGuiItemFlags_NoNavDefaultFocus); m.attr("ImGuiItemFlags_NoNavDefaultFocus") = static_cast(ImGuiItemFlags_NoNavDefaultFocus); + e.value("ImGuiItemFlags_ButtonRepeat", ImGuiItemFlags_ButtonRepeat); m.attr("ImGuiItemFlags_ButtonRepeat") = static_cast(ImGuiItemFlags_ButtonRepeat); + e.value("ImGuiItemFlags_AutoClosePopups", ImGuiItemFlags_AutoClosePopups); m.attr("ImGuiItemFlags_AutoClosePopups") = static_cast(ImGuiItemFlags_AutoClosePopups); + e.value("ImGuiItemFlags_AllowDuplicateId", ImGuiItemFlags_AllowDuplicateId); m.attr("ImGuiItemFlags_AllowDuplicateId") = static_cast(ImGuiItemFlags_AllowDuplicateId); + ; + } + + { // ImGuiInputTextFlags ImGuiInputTextFlags_ + auto e = nb::enum_(m, "ImGuiInputTextFlags"); + e.value("ImGuiInputTextFlags_None", ImGuiInputTextFlags_None); m.attr("ImGuiInputTextFlags_None") = static_cast(ImGuiInputTextFlags_None); + e.value("ImGuiInputTextFlags_CharsDecimal", ImGuiInputTextFlags_CharsDecimal); m.attr("ImGuiInputTextFlags_CharsDecimal") = static_cast(ImGuiInputTextFlags_CharsDecimal); + e.value("ImGuiInputTextFlags_CharsHexadecimal", ImGuiInputTextFlags_CharsHexadecimal); m.attr("ImGuiInputTextFlags_CharsHexadecimal") = static_cast(ImGuiInputTextFlags_CharsHexadecimal); + e.value("ImGuiInputTextFlags_CharsScientific", ImGuiInputTextFlags_CharsScientific); m.attr("ImGuiInputTextFlags_CharsScientific") = static_cast(ImGuiInputTextFlags_CharsScientific); + e.value("ImGuiInputTextFlags_CharsUppercase", ImGuiInputTextFlags_CharsUppercase); m.attr("ImGuiInputTextFlags_CharsUppercase") = static_cast(ImGuiInputTextFlags_CharsUppercase); + e.value("ImGuiInputTextFlags_CharsNoBlank", ImGuiInputTextFlags_CharsNoBlank); m.attr("ImGuiInputTextFlags_CharsNoBlank") = static_cast(ImGuiInputTextFlags_CharsNoBlank); + e.value("ImGuiInputTextFlags_AllowTabInput", ImGuiInputTextFlags_AllowTabInput); m.attr("ImGuiInputTextFlags_AllowTabInput") = static_cast(ImGuiInputTextFlags_AllowTabInput); + e.value("ImGuiInputTextFlags_EnterReturnsTrue", ImGuiInputTextFlags_EnterReturnsTrue); m.attr("ImGuiInputTextFlags_EnterReturnsTrue") = static_cast(ImGuiInputTextFlags_EnterReturnsTrue); + e.value("ImGuiInputTextFlags_EscapeClearsAll", ImGuiInputTextFlags_EscapeClearsAll); m.attr("ImGuiInputTextFlags_EscapeClearsAll") = static_cast(ImGuiInputTextFlags_EscapeClearsAll); + e.value("ImGuiInputTextFlags_CtrlEnterForNewLine", ImGuiInputTextFlags_CtrlEnterForNewLine); m.attr("ImGuiInputTextFlags_CtrlEnterForNewLine") = static_cast(ImGuiInputTextFlags_CtrlEnterForNewLine); + e.value("ImGuiInputTextFlags_ReadOnly", ImGuiInputTextFlags_ReadOnly); m.attr("ImGuiInputTextFlags_ReadOnly") = static_cast(ImGuiInputTextFlags_ReadOnly); + e.value("ImGuiInputTextFlags_Password", ImGuiInputTextFlags_Password); m.attr("ImGuiInputTextFlags_Password") = static_cast(ImGuiInputTextFlags_Password); + e.value("ImGuiInputTextFlags_AlwaysOverwrite", ImGuiInputTextFlags_AlwaysOverwrite); m.attr("ImGuiInputTextFlags_AlwaysOverwrite") = static_cast(ImGuiInputTextFlags_AlwaysOverwrite); + e.value("ImGuiInputTextFlags_AutoSelectAll", ImGuiInputTextFlags_AutoSelectAll); m.attr("ImGuiInputTextFlags_AutoSelectAll") = static_cast(ImGuiInputTextFlags_AutoSelectAll); + e.value("ImGuiInputTextFlags_ParseEmptyRefVal", ImGuiInputTextFlags_ParseEmptyRefVal); m.attr("ImGuiInputTextFlags_ParseEmptyRefVal") = static_cast(ImGuiInputTextFlags_ParseEmptyRefVal); + e.value("ImGuiInputTextFlags_DisplayEmptyRefVal", ImGuiInputTextFlags_DisplayEmptyRefVal); m.attr("ImGuiInputTextFlags_DisplayEmptyRefVal") = static_cast(ImGuiInputTextFlags_DisplayEmptyRefVal); + e.value("ImGuiInputTextFlags_NoHorizontalScroll", ImGuiInputTextFlags_NoHorizontalScroll); m.attr("ImGuiInputTextFlags_NoHorizontalScroll") = static_cast(ImGuiInputTextFlags_NoHorizontalScroll); + e.value("ImGuiInputTextFlags_NoUndoRedo", ImGuiInputTextFlags_NoUndoRedo); m.attr("ImGuiInputTextFlags_NoUndoRedo") = static_cast(ImGuiInputTextFlags_NoUndoRedo); + e.value("ImGuiInputTextFlags_ElideLeft", ImGuiInputTextFlags_ElideLeft); m.attr("ImGuiInputTextFlags_ElideLeft") = static_cast(ImGuiInputTextFlags_ElideLeft); + e.value("ImGuiInputTextFlags_CallbackCompletion", ImGuiInputTextFlags_CallbackCompletion); m.attr("ImGuiInputTextFlags_CallbackCompletion") = static_cast(ImGuiInputTextFlags_CallbackCompletion); + e.value("ImGuiInputTextFlags_CallbackHistory", ImGuiInputTextFlags_CallbackHistory); m.attr("ImGuiInputTextFlags_CallbackHistory") = static_cast(ImGuiInputTextFlags_CallbackHistory); + e.value("ImGuiInputTextFlags_CallbackAlways", ImGuiInputTextFlags_CallbackAlways); m.attr("ImGuiInputTextFlags_CallbackAlways") = static_cast(ImGuiInputTextFlags_CallbackAlways); + e.value("ImGuiInputTextFlags_CallbackCharFilter", ImGuiInputTextFlags_CallbackCharFilter); m.attr("ImGuiInputTextFlags_CallbackCharFilter") = static_cast(ImGuiInputTextFlags_CallbackCharFilter); + e.value("ImGuiInputTextFlags_CallbackResize", ImGuiInputTextFlags_CallbackResize); m.attr("ImGuiInputTextFlags_CallbackResize") = static_cast(ImGuiInputTextFlags_CallbackResize); + e.value("ImGuiInputTextFlags_CallbackEdit", ImGuiInputTextFlags_CallbackEdit); m.attr("ImGuiInputTextFlags_CallbackEdit") = static_cast(ImGuiInputTextFlags_CallbackEdit); + e.value("ImGuiInputTextFlags_WordWrap", ImGuiInputTextFlags_WordWrap); m.attr("ImGuiInputTextFlags_WordWrap") = static_cast(ImGuiInputTextFlags_WordWrap); + ; + } + + { // ImGuiTreeNodeFlags ImGuiTreeNodeFlags_ + auto e = nb::enum_(m, "ImGuiTreeNodeFlags"); + e.value("ImGuiTreeNodeFlags_None", ImGuiTreeNodeFlags_None); m.attr("ImGuiTreeNodeFlags_None") = static_cast(ImGuiTreeNodeFlags_None); + e.value("ImGuiTreeNodeFlags_Selected", ImGuiTreeNodeFlags_Selected); m.attr("ImGuiTreeNodeFlags_Selected") = static_cast(ImGuiTreeNodeFlags_Selected); + e.value("ImGuiTreeNodeFlags_Framed", ImGuiTreeNodeFlags_Framed); m.attr("ImGuiTreeNodeFlags_Framed") = static_cast(ImGuiTreeNodeFlags_Framed); + e.value("ImGuiTreeNodeFlags_AllowOverlap", ImGuiTreeNodeFlags_AllowOverlap); m.attr("ImGuiTreeNodeFlags_AllowOverlap") = static_cast(ImGuiTreeNodeFlags_AllowOverlap); + e.value("ImGuiTreeNodeFlags_NoTreePushOnOpen", ImGuiTreeNodeFlags_NoTreePushOnOpen); m.attr("ImGuiTreeNodeFlags_NoTreePushOnOpen") = static_cast(ImGuiTreeNodeFlags_NoTreePushOnOpen); + e.value("ImGuiTreeNodeFlags_NoAutoOpenOnLog", ImGuiTreeNodeFlags_NoAutoOpenOnLog); m.attr("ImGuiTreeNodeFlags_NoAutoOpenOnLog") = static_cast(ImGuiTreeNodeFlags_NoAutoOpenOnLog); + e.value("ImGuiTreeNodeFlags_DefaultOpen", ImGuiTreeNodeFlags_DefaultOpen); m.attr("ImGuiTreeNodeFlags_DefaultOpen") = static_cast(ImGuiTreeNodeFlags_DefaultOpen); + e.value("ImGuiTreeNodeFlags_OpenOnDoubleClick", ImGuiTreeNodeFlags_OpenOnDoubleClick); m.attr("ImGuiTreeNodeFlags_OpenOnDoubleClick") = static_cast(ImGuiTreeNodeFlags_OpenOnDoubleClick); + e.value("ImGuiTreeNodeFlags_OpenOnArrow", ImGuiTreeNodeFlags_OpenOnArrow); m.attr("ImGuiTreeNodeFlags_OpenOnArrow") = static_cast(ImGuiTreeNodeFlags_OpenOnArrow); + e.value("ImGuiTreeNodeFlags_Leaf", ImGuiTreeNodeFlags_Leaf); m.attr("ImGuiTreeNodeFlags_Leaf") = static_cast(ImGuiTreeNodeFlags_Leaf); + e.value("ImGuiTreeNodeFlags_Bullet", ImGuiTreeNodeFlags_Bullet); m.attr("ImGuiTreeNodeFlags_Bullet") = static_cast(ImGuiTreeNodeFlags_Bullet); + e.value("ImGuiTreeNodeFlags_FramePadding", ImGuiTreeNodeFlags_FramePadding); m.attr("ImGuiTreeNodeFlags_FramePadding") = static_cast(ImGuiTreeNodeFlags_FramePadding); + e.value("ImGuiTreeNodeFlags_SpanAvailWidth", ImGuiTreeNodeFlags_SpanAvailWidth); m.attr("ImGuiTreeNodeFlags_SpanAvailWidth") = static_cast(ImGuiTreeNodeFlags_SpanAvailWidth); + e.value("ImGuiTreeNodeFlags_SpanFullWidth", ImGuiTreeNodeFlags_SpanFullWidth); m.attr("ImGuiTreeNodeFlags_SpanFullWidth") = static_cast(ImGuiTreeNodeFlags_SpanFullWidth); + e.value("ImGuiTreeNodeFlags_SpanLabelWidth", ImGuiTreeNodeFlags_SpanLabelWidth); m.attr("ImGuiTreeNodeFlags_SpanLabelWidth") = static_cast(ImGuiTreeNodeFlags_SpanLabelWidth); + e.value("ImGuiTreeNodeFlags_SpanAllColumns", ImGuiTreeNodeFlags_SpanAllColumns); m.attr("ImGuiTreeNodeFlags_SpanAllColumns") = static_cast(ImGuiTreeNodeFlags_SpanAllColumns); + e.value("ImGuiTreeNodeFlags_LabelSpanAllColumns", ImGuiTreeNodeFlags_LabelSpanAllColumns); m.attr("ImGuiTreeNodeFlags_LabelSpanAllColumns") = static_cast(ImGuiTreeNodeFlags_LabelSpanAllColumns); + e.value("ImGuiTreeNodeFlags_NavLeftJumpsToParent", ImGuiTreeNodeFlags_NavLeftJumpsToParent); m.attr("ImGuiTreeNodeFlags_NavLeftJumpsToParent") = static_cast(ImGuiTreeNodeFlags_NavLeftJumpsToParent); + e.value("ImGuiTreeNodeFlags_CollapsingHeader", ImGuiTreeNodeFlags_CollapsingHeader); m.attr("ImGuiTreeNodeFlags_CollapsingHeader") = static_cast(ImGuiTreeNodeFlags_CollapsingHeader); + e.value("ImGuiTreeNodeFlags_DrawLinesNone", ImGuiTreeNodeFlags_DrawLinesNone); m.attr("ImGuiTreeNodeFlags_DrawLinesNone") = static_cast(ImGuiTreeNodeFlags_DrawLinesNone); + e.value("ImGuiTreeNodeFlags_DrawLinesFull", ImGuiTreeNodeFlags_DrawLinesFull); m.attr("ImGuiTreeNodeFlags_DrawLinesFull") = static_cast(ImGuiTreeNodeFlags_DrawLinesFull); + e.value("ImGuiTreeNodeFlags_DrawLinesToNodes", ImGuiTreeNodeFlags_DrawLinesToNodes); m.attr("ImGuiTreeNodeFlags_DrawLinesToNodes") = static_cast(ImGuiTreeNodeFlags_DrawLinesToNodes); + ; + } + + { // ImGuiListClipperFlags ImGuiListClipperFlags_ + auto e = nb::enum_(m, "ImGuiListClipperFlags"); + e.value("ImGuiListClipperFlags_None", ImGuiListClipperFlags_None); m.attr("ImGuiListClipperFlags_None") = static_cast(ImGuiListClipperFlags_None); + e.value("ImGuiListClipperFlags_NoSetTableRowCounters", ImGuiListClipperFlags_NoSetTableRowCounters); m.attr("ImGuiListClipperFlags_NoSetTableRowCounters") = static_cast(ImGuiListClipperFlags_NoSetTableRowCounters); + ; + } + + { // ImGuiPopupFlags ImGuiPopupFlags_ + auto e = nb::enum_(m, "ImGuiPopupFlags"); + e.value("ImGuiPopupFlags_None", ImGuiPopupFlags_None); m.attr("ImGuiPopupFlags_None") = static_cast(ImGuiPopupFlags_None); + e.value("ImGuiPopupFlags_MouseButtonLeft", ImGuiPopupFlags_MouseButtonLeft); m.attr("ImGuiPopupFlags_MouseButtonLeft") = static_cast(ImGuiPopupFlags_MouseButtonLeft); + e.value("ImGuiPopupFlags_MouseButtonRight", ImGuiPopupFlags_MouseButtonRight); m.attr("ImGuiPopupFlags_MouseButtonRight") = static_cast(ImGuiPopupFlags_MouseButtonRight); + e.value("ImGuiPopupFlags_MouseButtonMiddle", ImGuiPopupFlags_MouseButtonMiddle); m.attr("ImGuiPopupFlags_MouseButtonMiddle") = static_cast(ImGuiPopupFlags_MouseButtonMiddle); + e.value("ImGuiPopupFlags_MouseButtonMask_", ImGuiPopupFlags_MouseButtonMask_); m.attr("ImGuiPopupFlags_MouseButtonMask_") = static_cast(ImGuiPopupFlags_MouseButtonMask_); + e.value("ImGuiPopupFlags_MouseButtonDefault_", ImGuiPopupFlags_MouseButtonDefault_); m.attr("ImGuiPopupFlags_MouseButtonDefault_") = static_cast(ImGuiPopupFlags_MouseButtonDefault_); + e.value("ImGuiPopupFlags_NoReopen", ImGuiPopupFlags_NoReopen); m.attr("ImGuiPopupFlags_NoReopen") = static_cast(ImGuiPopupFlags_NoReopen); + e.value("ImGuiPopupFlags_NoOpenOverExistingPopup", ImGuiPopupFlags_NoOpenOverExistingPopup); m.attr("ImGuiPopupFlags_NoOpenOverExistingPopup") = static_cast(ImGuiPopupFlags_NoOpenOverExistingPopup); + e.value("ImGuiPopupFlags_NoOpenOverItems", ImGuiPopupFlags_NoOpenOverItems); m.attr("ImGuiPopupFlags_NoOpenOverItems") = static_cast(ImGuiPopupFlags_NoOpenOverItems); + e.value("ImGuiPopupFlags_AnyPopupId", ImGuiPopupFlags_AnyPopupId); m.attr("ImGuiPopupFlags_AnyPopupId") = static_cast(ImGuiPopupFlags_AnyPopupId); + e.value("ImGuiPopupFlags_AnyPopupLevel", ImGuiPopupFlags_AnyPopupLevel); m.attr("ImGuiPopupFlags_AnyPopupLevel") = static_cast(ImGuiPopupFlags_AnyPopupLevel); + e.value("ImGuiPopupFlags_AnyPopup", ImGuiPopupFlags_AnyPopup); m.attr("ImGuiPopupFlags_AnyPopup") = static_cast(ImGuiPopupFlags_AnyPopup); + ; + } + + { // ImGuiMultiSelectFlags ImGuiMultiSelectFlags_ + auto e = nb::enum_(m, "ImGuiMultiSelectFlags"); + e.value("ImGuiMultiSelectFlags_None", ImGuiMultiSelectFlags_None); m.attr("ImGuiMultiSelectFlags_None") = static_cast(ImGuiMultiSelectFlags_None); + e.value("ImGuiMultiSelectFlags_SingleSelect", ImGuiMultiSelectFlags_SingleSelect); m.attr("ImGuiMultiSelectFlags_SingleSelect") = static_cast(ImGuiMultiSelectFlags_SingleSelect); + e.value("ImGuiMultiSelectFlags_NoSelectAll", ImGuiMultiSelectFlags_NoSelectAll); m.attr("ImGuiMultiSelectFlags_NoSelectAll") = static_cast(ImGuiMultiSelectFlags_NoSelectAll); + e.value("ImGuiMultiSelectFlags_NoRangeSelect", ImGuiMultiSelectFlags_NoRangeSelect); m.attr("ImGuiMultiSelectFlags_NoRangeSelect") = static_cast(ImGuiMultiSelectFlags_NoRangeSelect); + e.value("ImGuiMultiSelectFlags_NoAutoSelect", ImGuiMultiSelectFlags_NoAutoSelect); m.attr("ImGuiMultiSelectFlags_NoAutoSelect") = static_cast(ImGuiMultiSelectFlags_NoAutoSelect); + e.value("ImGuiMultiSelectFlags_NoAutoClear", ImGuiMultiSelectFlags_NoAutoClear); m.attr("ImGuiMultiSelectFlags_NoAutoClear") = static_cast(ImGuiMultiSelectFlags_NoAutoClear); + e.value("ImGuiMultiSelectFlags_NoAutoClearOnReselect", ImGuiMultiSelectFlags_NoAutoClearOnReselect); m.attr("ImGuiMultiSelectFlags_NoAutoClearOnReselect") = static_cast(ImGuiMultiSelectFlags_NoAutoClearOnReselect); + e.value("ImGuiMultiSelectFlags_BoxSelect1d", ImGuiMultiSelectFlags_BoxSelect1d); m.attr("ImGuiMultiSelectFlags_BoxSelect1d") = static_cast(ImGuiMultiSelectFlags_BoxSelect1d); + e.value("ImGuiMultiSelectFlags_BoxSelect2d", ImGuiMultiSelectFlags_BoxSelect2d); m.attr("ImGuiMultiSelectFlags_BoxSelect2d") = static_cast(ImGuiMultiSelectFlags_BoxSelect2d); + e.value("ImGuiMultiSelectFlags_BoxSelectNoScroll", ImGuiMultiSelectFlags_BoxSelectNoScroll); m.attr("ImGuiMultiSelectFlags_BoxSelectNoScroll") = static_cast(ImGuiMultiSelectFlags_BoxSelectNoScroll); + e.value("ImGuiMultiSelectFlags_ClearOnEscape", ImGuiMultiSelectFlags_ClearOnEscape); m.attr("ImGuiMultiSelectFlags_ClearOnEscape") = static_cast(ImGuiMultiSelectFlags_ClearOnEscape); + e.value("ImGuiMultiSelectFlags_ClearOnClickVoid", ImGuiMultiSelectFlags_ClearOnClickVoid); m.attr("ImGuiMultiSelectFlags_ClearOnClickVoid") = static_cast(ImGuiMultiSelectFlags_ClearOnClickVoid); + e.value("ImGuiMultiSelectFlags_ScopeWindow", ImGuiMultiSelectFlags_ScopeWindow); m.attr("ImGuiMultiSelectFlags_ScopeWindow") = static_cast(ImGuiMultiSelectFlags_ScopeWindow); + e.value("ImGuiMultiSelectFlags_ScopeRect", ImGuiMultiSelectFlags_ScopeRect); m.attr("ImGuiMultiSelectFlags_ScopeRect") = static_cast(ImGuiMultiSelectFlags_ScopeRect); + e.value("ImGuiMultiSelectFlags_SelectOnClick", ImGuiMultiSelectFlags_SelectOnClick); m.attr("ImGuiMultiSelectFlags_SelectOnClick") = static_cast(ImGuiMultiSelectFlags_SelectOnClick); + e.value("ImGuiMultiSelectFlags_SelectOnClickRelease", ImGuiMultiSelectFlags_SelectOnClickRelease); m.attr("ImGuiMultiSelectFlags_SelectOnClickRelease") = static_cast(ImGuiMultiSelectFlags_SelectOnClickRelease); + e.value("ImGuiMultiSelectFlags_NavWrapX", ImGuiMultiSelectFlags_NavWrapX); m.attr("ImGuiMultiSelectFlags_NavWrapX") = static_cast(ImGuiMultiSelectFlags_NavWrapX); + e.value("ImGuiMultiSelectFlags_NoSelectOnRightClick", ImGuiMultiSelectFlags_NoSelectOnRightClick); m.attr("ImGuiMultiSelectFlags_NoSelectOnRightClick") = static_cast(ImGuiMultiSelectFlags_NoSelectOnRightClick); + ; + } + + { // ImGuiSelectableFlags ImGuiSelectableFlags_ + auto e = nb::enum_(m, "ImGuiSelectableFlags"); + e.value("ImGuiSelectableFlags_None", ImGuiSelectableFlags_None); m.attr("ImGuiSelectableFlags_None") = static_cast(ImGuiSelectableFlags_None); + e.value("ImGuiSelectableFlags_DontClosePopups", ImGuiSelectableFlags_DontClosePopups); m.attr("ImGuiSelectableFlags_DontClosePopups") = static_cast(ImGuiSelectableFlags_DontClosePopups); + e.value("ImGuiSelectableFlags_SpanAllColumns", ImGuiSelectableFlags_SpanAllColumns); m.attr("ImGuiSelectableFlags_SpanAllColumns") = static_cast(ImGuiSelectableFlags_SpanAllColumns); + e.value("ImGuiSelectableFlags_AllowDoubleClick", ImGuiSelectableFlags_AllowDoubleClick); m.attr("ImGuiSelectableFlags_AllowDoubleClick") = static_cast(ImGuiSelectableFlags_AllowDoubleClick); + e.value("ImGuiSelectableFlags_Disabled", ImGuiSelectableFlags_Disabled); m.attr("ImGuiSelectableFlags_Disabled") = static_cast(ImGuiSelectableFlags_Disabled); + e.value("ImGuiSelectableFlags_AllowOverlap", ImGuiSelectableFlags_AllowOverlap); m.attr("ImGuiSelectableFlags_AllowOverlap") = static_cast(ImGuiSelectableFlags_AllowOverlap); + ; + } + + { // ImGuiComboFlags ImGuiComboFlags_ + auto e = nb::enum_(m, "ImGuiComboFlags"); + e.value("ImGuiComboFlags_None", ImGuiComboFlags_None); m.attr("ImGuiComboFlags_None") = static_cast(ImGuiComboFlags_None); + e.value("ImGuiComboFlags_PopupAlignLeft", ImGuiComboFlags_PopupAlignLeft); m.attr("ImGuiComboFlags_PopupAlignLeft") = static_cast(ImGuiComboFlags_PopupAlignLeft); + e.value("ImGuiComboFlags_HeightSmall", ImGuiComboFlags_HeightSmall); m.attr("ImGuiComboFlags_HeightSmall") = static_cast(ImGuiComboFlags_HeightSmall); + e.value("ImGuiComboFlags_HeightRegular", ImGuiComboFlags_HeightRegular); m.attr("ImGuiComboFlags_HeightRegular") = static_cast(ImGuiComboFlags_HeightRegular); + e.value("ImGuiComboFlags_HeightLarge", ImGuiComboFlags_HeightLarge); m.attr("ImGuiComboFlags_HeightLarge") = static_cast(ImGuiComboFlags_HeightLarge); + e.value("ImGuiComboFlags_HeightLargest", ImGuiComboFlags_HeightLargest); m.attr("ImGuiComboFlags_HeightLargest") = static_cast(ImGuiComboFlags_HeightLargest); + e.value("ImGuiComboFlags_NoArrowButton", ImGuiComboFlags_NoArrowButton); m.attr("ImGuiComboFlags_NoArrowButton") = static_cast(ImGuiComboFlags_NoArrowButton); + e.value("ImGuiComboFlags_NoPreview", ImGuiComboFlags_NoPreview); m.attr("ImGuiComboFlags_NoPreview") = static_cast(ImGuiComboFlags_NoPreview); + e.value("ImGuiComboFlags_HeightMask_", ImGuiComboFlags_HeightMask_); m.attr("ImGuiComboFlags_HeightMask_") = static_cast(ImGuiComboFlags_HeightMask_); + ; + } + + { // ImGuiTabBarFlags ImGuiTabBarFlags_ + auto e = nb::enum_(m, "ImGuiTabBarFlags"); + e.value("ImGuiTabBarFlags_None", ImGuiTabBarFlags_None); m.attr("ImGuiTabBarFlags_None") = static_cast(ImGuiTabBarFlags_None); + e.value("ImGuiTabBarFlags_Reorderable", ImGuiTabBarFlags_Reorderable); m.attr("ImGuiTabBarFlags_Reorderable") = static_cast(ImGuiTabBarFlags_Reorderable); + e.value("ImGuiTabBarFlags_AutoSelectNewTabs", ImGuiTabBarFlags_AutoSelectNewTabs); m.attr("ImGuiTabBarFlags_AutoSelectNewTabs") = static_cast(ImGuiTabBarFlags_AutoSelectNewTabs); + e.value("ImGuiTabBarFlags_TabListPopupButton", ImGuiTabBarFlags_TabListPopupButton); m.attr("ImGuiTabBarFlags_TabListPopupButton") = static_cast(ImGuiTabBarFlags_TabListPopupButton); + e.value("ImGuiTabBarFlags_NoCloseWithMiddleMouseButton", ImGuiTabBarFlags_NoCloseWithMiddleMouseButton); m.attr("ImGuiTabBarFlags_NoCloseWithMiddleMouseButton") = static_cast(ImGuiTabBarFlags_NoCloseWithMiddleMouseButton); + e.value("ImGuiTabBarFlags_NoTabListScrollingButtons", ImGuiTabBarFlags_NoTabListScrollingButtons); m.attr("ImGuiTabBarFlags_NoTabListScrollingButtons") = static_cast(ImGuiTabBarFlags_NoTabListScrollingButtons); + e.value("ImGuiTabBarFlags_NoTooltip", ImGuiTabBarFlags_NoTooltip); m.attr("ImGuiTabBarFlags_NoTooltip") = static_cast(ImGuiTabBarFlags_NoTooltip); + e.value("ImGuiTabBarFlags_FittingPolicyMixed", ImGuiTabBarFlags_FittingPolicyMixed); m.attr("ImGuiTabBarFlags_FittingPolicyMixed") = static_cast(ImGuiTabBarFlags_FittingPolicyMixed); + e.value("ImGuiTabBarFlags_FittingPolicyShrink", ImGuiTabBarFlags_FittingPolicyShrink); m.attr("ImGuiTabBarFlags_FittingPolicyShrink") = static_cast(ImGuiTabBarFlags_FittingPolicyShrink); + e.value("ImGuiTabBarFlags_FittingPolicyScroll", ImGuiTabBarFlags_FittingPolicyScroll); m.attr("ImGuiTabBarFlags_FittingPolicyScroll") = static_cast(ImGuiTabBarFlags_FittingPolicyScroll); + e.value("ImGuiTabBarFlags_FittingPolicyMask_", ImGuiTabBarFlags_FittingPolicyMask_); m.attr("ImGuiTabBarFlags_FittingPolicyMask_") = static_cast(ImGuiTabBarFlags_FittingPolicyMask_); + e.value("ImGuiTabBarFlags_FittingPolicyDefault_", ImGuiTabBarFlags_FittingPolicyDefault_); m.attr("ImGuiTabBarFlags_FittingPolicyDefault_") = static_cast(ImGuiTabBarFlags_FittingPolicyDefault_); + ; + } + + { // ImGuiTabItemFlags ImGuiTabItemFlags_ + auto e = nb::enum_(m, "ImGuiTabItemFlags"); + e.value("ImGuiTabItemFlags_None", ImGuiTabItemFlags_None); m.attr("ImGuiTabItemFlags_None") = static_cast(ImGuiTabItemFlags_None); + e.value("ImGuiTabItemFlags_UnsavedDocument", ImGuiTabItemFlags_UnsavedDocument); m.attr("ImGuiTabItemFlags_UnsavedDocument") = static_cast(ImGuiTabItemFlags_UnsavedDocument); + e.value("ImGuiTabItemFlags_SetSelected", ImGuiTabItemFlags_SetSelected); m.attr("ImGuiTabItemFlags_SetSelected") = static_cast(ImGuiTabItemFlags_SetSelected); + e.value("ImGuiTabItemFlags_NoCloseWithMiddleMouseButton", ImGuiTabItemFlags_NoCloseWithMiddleMouseButton); m.attr("ImGuiTabItemFlags_NoCloseWithMiddleMouseButton") = static_cast(ImGuiTabItemFlags_NoCloseWithMiddleMouseButton); + e.value("ImGuiTabItemFlags_NoPushId", ImGuiTabItemFlags_NoPushId); m.attr("ImGuiTabItemFlags_NoPushId") = static_cast(ImGuiTabItemFlags_NoPushId); + ; + } + + { // ImGuiFocusedFlags ImGuiFocusedFlags_ + auto e = nb::enum_(m, "ImGuiFocusedFlags"); + e.value("ImGuiFocusedFlags_None", ImGuiFocusedFlags_None); m.attr("ImGuiFocusedFlags_None") = static_cast(ImGuiFocusedFlags_None); + e.value("ImGuiFocusedFlags_ChildWindows", ImGuiFocusedFlags_ChildWindows); m.attr("ImGuiFocusedFlags_ChildWindows") = static_cast(ImGuiFocusedFlags_ChildWindows); + e.value("ImGuiFocusedFlags_RootWindow", ImGuiFocusedFlags_RootWindow); m.attr("ImGuiFocusedFlags_RootWindow") = static_cast(ImGuiFocusedFlags_RootWindow); + e.value("ImGuiFocusedFlags_AnyWindow", ImGuiFocusedFlags_AnyWindow); m.attr("ImGuiFocusedFlags_AnyWindow") = static_cast(ImGuiFocusedFlags_AnyWindow); + e.value("ImGuiFocusedFlags_RootAndChildWindows", ImGuiFocusedFlags_RootAndChildWindows); m.attr("ImGuiFocusedFlags_RootAndChildWindows") = static_cast(ImGuiFocusedFlags_RootAndChildWindows); + ; + } + + { // ImGuiHoveredFlags ImGuiHoveredFlags_ + auto e = nb::enum_(m, "ImGuiHoveredFlags"); + e.value("ImGuiHoveredFlags_None", ImGuiHoveredFlags_None); m.attr("ImGuiHoveredFlags_None") = static_cast(ImGuiHoveredFlags_None); + e.value("ImGuiHoveredFlags_ChildWindows", ImGuiHoveredFlags_ChildWindows); m.attr("ImGuiHoveredFlags_ChildWindows") = static_cast(ImGuiHoveredFlags_ChildWindows); + e.value("ImGuiHoveredFlags_RootWindow", ImGuiHoveredFlags_RootWindow); m.attr("ImGuiHoveredFlags_RootWindow") = static_cast(ImGuiHoveredFlags_RootWindow); + e.value("ImGuiHoveredFlags_AnyWindow", ImGuiHoveredFlags_AnyWindow); m.attr("ImGuiHoveredFlags_AnyWindow") = static_cast(ImGuiHoveredFlags_AnyWindow); + e.value("ImGuiHoveredFlags_AllowWhenBlockedByPopup", ImGuiHoveredFlags_AllowWhenBlockedByPopup); m.attr("ImGuiHoveredFlags_AllowWhenBlockedByPopup") = static_cast(ImGuiHoveredFlags_AllowWhenBlockedByPopup); + e.value("ImGuiHoveredFlags_AllowWhenBlockedByActiveItem", ImGuiHoveredFlags_AllowWhenBlockedByActiveItem); m.attr("ImGuiHoveredFlags_AllowWhenBlockedByActiveItem") = static_cast(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem); + e.value("ImGuiHoveredFlags_AllowWhenOverlapped", ImGuiHoveredFlags_AllowWhenOverlapped); m.attr("ImGuiHoveredFlags_AllowWhenOverlapped") = static_cast(ImGuiHoveredFlags_AllowWhenOverlapped); + e.value("ImGuiHoveredFlags_AllowWhenDisabled", ImGuiHoveredFlags_AllowWhenDisabled); m.attr("ImGuiHoveredFlags_AllowWhenDisabled") = static_cast(ImGuiHoveredFlags_AllowWhenDisabled); + e.value("ImGuiHoveredFlags_RectOnly", ImGuiHoveredFlags_RectOnly); m.attr("ImGuiHoveredFlags_RectOnly") = static_cast(ImGuiHoveredFlags_RectOnly); + e.value("ImGuiHoveredFlags_RootAndChildWindows", ImGuiHoveredFlags_RootAndChildWindows); m.attr("ImGuiHoveredFlags_RootAndChildWindows") = static_cast(ImGuiHoveredFlags_RootAndChildWindows); + ; + } + + { // ImGuiDragDropFlags ImGuiDragDropFlags_ + auto e = nb::enum_(m, "ImGuiDragDropFlags"); + e.value("ImGuiDragDropFlags_None", ImGuiDragDropFlags_None); m.attr("ImGuiDragDropFlags_None") = static_cast(ImGuiDragDropFlags_None); + e.value("ImGuiDragDropFlags_SourceNoPreviewTooltip", ImGuiDragDropFlags_SourceNoPreviewTooltip); m.attr("ImGuiDragDropFlags_SourceNoPreviewTooltip") = static_cast(ImGuiDragDropFlags_SourceNoPreviewTooltip); + e.value("ImGuiDragDropFlags_SourceNoDisableHover", ImGuiDragDropFlags_SourceNoDisableHover); m.attr("ImGuiDragDropFlags_SourceNoDisableHover") = static_cast(ImGuiDragDropFlags_SourceNoDisableHover); + e.value("ImGuiDragDropFlags_SourceNoHoldToOpenOthers", ImGuiDragDropFlags_SourceNoHoldToOpenOthers); m.attr("ImGuiDragDropFlags_SourceNoHoldToOpenOthers") = static_cast(ImGuiDragDropFlags_SourceNoHoldToOpenOthers); + e.value("ImGuiDragDropFlags_SourceAllowNullID", ImGuiDragDropFlags_SourceAllowNullID); m.attr("ImGuiDragDropFlags_SourceAllowNullID") = static_cast(ImGuiDragDropFlags_SourceAllowNullID); + e.value("ImGuiDragDropFlags_SourceExtern", ImGuiDragDropFlags_SourceExtern); m.attr("ImGuiDragDropFlags_SourceExtern") = static_cast(ImGuiDragDropFlags_SourceExtern); + e.value("ImGuiDragDropFlags_SourceAutoExpirePayload", ImGuiDragDropFlags_SourceAutoExpirePayload); m.attr("ImGuiDragDropFlags_SourceAutoExpirePayload") = static_cast(ImGuiDragDropFlags_SourceAutoExpirePayload); + e.value("ImGuiDragDropFlags_AcceptBeforeDelivery", ImGuiDragDropFlags_AcceptBeforeDelivery); m.attr("ImGuiDragDropFlags_AcceptBeforeDelivery") = static_cast(ImGuiDragDropFlags_AcceptBeforeDelivery); + e.value("ImGuiDragDropFlags_AcceptNoDrawDefaultRect", ImGuiDragDropFlags_AcceptNoDrawDefaultRect); m.attr("ImGuiDragDropFlags_AcceptNoDrawDefaultRect") = static_cast(ImGuiDragDropFlags_AcceptNoDrawDefaultRect); + e.value("ImGuiDragDropFlags_AcceptNoPreviewTooltip", ImGuiDragDropFlags_AcceptNoPreviewTooltip); m.attr("ImGuiDragDropFlags_AcceptNoPreviewTooltip") = static_cast(ImGuiDragDropFlags_AcceptNoPreviewTooltip); + e.value("ImGuiDragDropFlags_AcceptDrawAsHovered", ImGuiDragDropFlags_AcceptDrawAsHovered); m.attr("ImGuiDragDropFlags_AcceptDrawAsHovered") = static_cast(ImGuiDragDropFlags_AcceptDrawAsHovered); + e.value("ImGuiDragDropFlags_AcceptPeekOnly", ImGuiDragDropFlags_AcceptPeekOnly); m.attr("ImGuiDragDropFlags_AcceptPeekOnly") = static_cast(ImGuiDragDropFlags_AcceptPeekOnly); + ; + } + + { // ImGuiDataType ImGuiDataType_ + auto e = nb::enum_(m, "ImGuiDataType"); + e.value("ImGuiDataType_S8", ImGuiDataType_S8); m.attr("ImGuiDataType_S8") = static_cast(ImGuiDataType_S8); + e.value("ImGuiDataType_U8", ImGuiDataType_U8); m.attr("ImGuiDataType_U8") = static_cast(ImGuiDataType_U8); + e.value("ImGuiDataType_S16", ImGuiDataType_S16); m.attr("ImGuiDataType_S16") = static_cast(ImGuiDataType_S16); + e.value("ImGuiDataType_U16", ImGuiDataType_U16); m.attr("ImGuiDataType_U16") = static_cast(ImGuiDataType_U16); + e.value("ImGuiDataType_S32", ImGuiDataType_S32); m.attr("ImGuiDataType_S32") = static_cast(ImGuiDataType_S32); + e.value("ImGuiDataType_U32", ImGuiDataType_U32); m.attr("ImGuiDataType_U32") = static_cast(ImGuiDataType_U32); + e.value("ImGuiDataType_S64", ImGuiDataType_S64); m.attr("ImGuiDataType_S64") = static_cast(ImGuiDataType_S64); + e.value("ImGuiDataType_U64", ImGuiDataType_U64); m.attr("ImGuiDataType_U64") = static_cast(ImGuiDataType_U64); + e.value("ImGuiDataType_Float", ImGuiDataType_Float); m.attr("ImGuiDataType_Float") = static_cast(ImGuiDataType_Float); + e.value("ImGuiDataType_Double", ImGuiDataType_Double); m.attr("ImGuiDataType_Double") = static_cast(ImGuiDataType_Double); + e.value("ImGuiDataType_COUNT", ImGuiDataType_COUNT); m.attr("ImGuiDataType_COUNT") = static_cast(ImGuiDataType_COUNT); + ; + } + + { // ImGuiInputFlags ImGuiInputFlags_ + auto e = nb::enum_(m, "ImGuiInputFlags"); + e.value("ImGuiInputFlags_None", ImGuiInputFlags_None); m.attr("ImGuiInputFlags_None") = static_cast(ImGuiInputFlags_None); + e.value("ImGuiInputFlags_Repeat", ImGuiInputFlags_Repeat); m.attr("ImGuiInputFlags_Repeat") = static_cast(ImGuiInputFlags_Repeat); + e.value("ImGuiInputFlags_RouteActive", ImGuiInputFlags_RouteActive); m.attr("ImGuiInputFlags_RouteActive") = static_cast(ImGuiInputFlags_RouteActive); + e.value("ImGuiInputFlags_RouteFocused", ImGuiInputFlags_RouteFocused); m.attr("ImGuiInputFlags_RouteFocused") = static_cast(ImGuiInputFlags_RouteFocused); + e.value("ImGuiInputFlags_RouteGlobal", ImGuiInputFlags_RouteGlobal); m.attr("ImGuiInputFlags_RouteGlobal") = static_cast(ImGuiInputFlags_RouteGlobal); + e.value("ImGuiInputFlags_RouteAlways", ImGuiInputFlags_RouteAlways); m.attr("ImGuiInputFlags_RouteAlways") = static_cast(ImGuiInputFlags_RouteAlways); + e.value("ImGuiInputFlags_RouteOverFocused", ImGuiInputFlags_RouteOverFocused); m.attr("ImGuiInputFlags_RouteOverFocused") = static_cast(ImGuiInputFlags_RouteOverFocused); + e.value("ImGuiInputFlags_RouteOverActive", ImGuiInputFlags_RouteOverActive); m.attr("ImGuiInputFlags_RouteOverActive") = static_cast(ImGuiInputFlags_RouteOverActive); + e.value("ImGuiInputFlags_RouteUnlessBgFocused", ImGuiInputFlags_RouteUnlessBgFocused); m.attr("ImGuiInputFlags_RouteUnlessBgFocused") = static_cast(ImGuiInputFlags_RouteUnlessBgFocused); + e.value("ImGuiInputFlags_RouteFromRootWindow", ImGuiInputFlags_RouteFromRootWindow); m.attr("ImGuiInputFlags_RouteFromRootWindow") = static_cast(ImGuiInputFlags_RouteFromRootWindow); + e.value("ImGuiInputFlags_Tooltip", ImGuiInputFlags_Tooltip); m.attr("ImGuiInputFlags_Tooltip") = static_cast(ImGuiInputFlags_Tooltip); + ; + } + + { // ImGuiConfigFlags ImGuiConfigFlags_ + auto e = nb::enum_(m, "ImGuiConfigFlags"); + e.value("ImGuiConfigFlags_None", ImGuiConfigFlags_None); m.attr("ImGuiConfigFlags_None") = static_cast(ImGuiConfigFlags_None); + e.value("ImGuiConfigFlags_NavEnableKeyboard", ImGuiConfigFlags_NavEnableKeyboard); m.attr("ImGuiConfigFlags_NavEnableKeyboard") = static_cast(ImGuiConfigFlags_NavEnableKeyboard); + e.value("ImGuiConfigFlags_NavEnableGamepad", ImGuiConfigFlags_NavEnableGamepad); m.attr("ImGuiConfigFlags_NavEnableGamepad") = static_cast(ImGuiConfigFlags_NavEnableGamepad); + e.value("ImGuiConfigFlags_NavEnableSetMousePos", ImGuiConfigFlags_NavEnableSetMousePos); m.attr("ImGuiConfigFlags_NavEnableSetMousePos") = static_cast(ImGuiConfigFlags_NavEnableSetMousePos); + e.value("ImGuiConfigFlags_NavNoCaptureKeyboard", ImGuiConfigFlags_NavNoCaptureKeyboard); m.attr("ImGuiConfigFlags_NavNoCaptureKeyboard") = static_cast(ImGuiConfigFlags_NavNoCaptureKeyboard); + e.value("ImGuiConfigFlags_NoMouse", ImGuiConfigFlags_NoMouse); m.attr("ImGuiConfigFlags_NoMouse") = static_cast(ImGuiConfigFlags_NoMouse); + e.value("ImGuiConfigFlags_NoMouseCursorChange", ImGuiConfigFlags_NoMouseCursorChange); m.attr("ImGuiConfigFlags_NoMouseCursorChange") = static_cast(ImGuiConfigFlags_NoMouseCursorChange); + e.value("ImGuiConfigFlags_IsSRGB", ImGuiConfigFlags_IsSRGB); m.attr("ImGuiConfigFlags_IsSRGB") = static_cast(ImGuiConfigFlags_IsSRGB); + e.value("ImGuiConfigFlags_IsTouchScreen", ImGuiConfigFlags_IsTouchScreen); m.attr("ImGuiConfigFlags_IsTouchScreen") = static_cast(ImGuiConfigFlags_IsTouchScreen); + ; + } + + { // ImGuiBackendFlags ImGuiBackendFlags_ + auto e = nb::enum_(m, "ImGuiBackendFlags"); + e.value("ImGuiBackendFlags_None", ImGuiBackendFlags_None); m.attr("ImGuiBackendFlags_None") = static_cast(ImGuiBackendFlags_None); + e.value("ImGuiBackendFlags_HasGamepad", ImGuiBackendFlags_HasGamepad); m.attr("ImGuiBackendFlags_HasGamepad") = static_cast(ImGuiBackendFlags_HasGamepad); + e.value("ImGuiBackendFlags_HasMouseCursors", ImGuiBackendFlags_HasMouseCursors); m.attr("ImGuiBackendFlags_HasMouseCursors") = static_cast(ImGuiBackendFlags_HasMouseCursors); + e.value("ImGuiBackendFlags_HasSetMousePos", ImGuiBackendFlags_HasSetMousePos); m.attr("ImGuiBackendFlags_HasSetMousePos") = static_cast(ImGuiBackendFlags_HasSetMousePos); + e.value("ImGuiBackendFlags_RendererHasVtxOffset", ImGuiBackendFlags_RendererHasVtxOffset); m.attr("ImGuiBackendFlags_RendererHasVtxOffset") = static_cast(ImGuiBackendFlags_RendererHasVtxOffset); + ; + } + + { // ImGuiCol ImGuiCol_ + auto e = nb::enum_(m, "ImGuiCol"); + e.value("ImGuiCol_Text", ImGuiCol_Text); m.attr("ImGuiCol_Text") = static_cast(ImGuiCol_Text); + e.value("ImGuiCol_TextDisabled", ImGuiCol_TextDisabled); m.attr("ImGuiCol_TextDisabled") = static_cast(ImGuiCol_TextDisabled); + e.value("ImGuiCol_WindowBg", ImGuiCol_WindowBg); m.attr("ImGuiCol_WindowBg") = static_cast(ImGuiCol_WindowBg); + e.value("ImGuiCol_ChildBg", ImGuiCol_ChildBg); m.attr("ImGuiCol_ChildBg") = static_cast(ImGuiCol_ChildBg); + e.value("ImGuiCol_PopupBg", ImGuiCol_PopupBg); m.attr("ImGuiCol_PopupBg") = static_cast(ImGuiCol_PopupBg); + e.value("ImGuiCol_Border", ImGuiCol_Border); m.attr("ImGuiCol_Border") = static_cast(ImGuiCol_Border); + e.value("ImGuiCol_BorderShadow", ImGuiCol_BorderShadow); m.attr("ImGuiCol_BorderShadow") = static_cast(ImGuiCol_BorderShadow); + e.value("ImGuiCol_FrameBg", ImGuiCol_FrameBg); m.attr("ImGuiCol_FrameBg") = static_cast(ImGuiCol_FrameBg); + e.value("ImGuiCol_FrameBgHovered", ImGuiCol_FrameBgHovered); m.attr("ImGuiCol_FrameBgHovered") = static_cast(ImGuiCol_FrameBgHovered); + e.value("ImGuiCol_FrameBgActive", ImGuiCol_FrameBgActive); m.attr("ImGuiCol_FrameBgActive") = static_cast(ImGuiCol_FrameBgActive); + e.value("ImGuiCol_TitleBg", ImGuiCol_TitleBg); m.attr("ImGuiCol_TitleBg") = static_cast(ImGuiCol_TitleBg); + e.value("ImGuiCol_TitleBgActive", ImGuiCol_TitleBgActive); m.attr("ImGuiCol_TitleBgActive") = static_cast(ImGuiCol_TitleBgActive); + e.value("ImGuiCol_TitleBgCollapsed", ImGuiCol_TitleBgCollapsed); m.attr("ImGuiCol_TitleBgCollapsed") = static_cast(ImGuiCol_TitleBgCollapsed); + e.value("ImGuiCol_MenuBarBg", ImGuiCol_MenuBarBg); m.attr("ImGuiCol_MenuBarBg") = static_cast(ImGuiCol_MenuBarBg); + e.value("ImGuiCol_ScrollbarBg", ImGuiCol_ScrollbarBg); m.attr("ImGuiCol_ScrollbarBg") = static_cast(ImGuiCol_ScrollbarBg); + e.value("ImGuiCol_ScrollbarGrab", ImGuiCol_ScrollbarGrab); m.attr("ImGuiCol_ScrollbarGrab") = static_cast(ImGuiCol_ScrollbarGrab); + e.value("ImGuiCol_ScrollbarGrabHovered", ImGuiCol_ScrollbarGrabHovered); m.attr("ImGuiCol_ScrollbarGrabHovered") = static_cast(ImGuiCol_ScrollbarGrabHovered); + e.value("ImGuiCol_ScrollbarGrabActive", ImGuiCol_ScrollbarGrabActive); m.attr("ImGuiCol_ScrollbarGrabActive") = static_cast(ImGuiCol_ScrollbarGrabActive); + e.value("ImGuiCol_CheckMark", ImGuiCol_CheckMark); m.attr("ImGuiCol_CheckMark") = static_cast(ImGuiCol_CheckMark); + e.value("ImGuiCol_SliderGrab", ImGuiCol_SliderGrab); m.attr("ImGuiCol_SliderGrab") = static_cast(ImGuiCol_SliderGrab); + e.value("ImGuiCol_SliderGrabActive", ImGuiCol_SliderGrabActive); m.attr("ImGuiCol_SliderGrabActive") = static_cast(ImGuiCol_SliderGrabActive); + e.value("ImGuiCol_Button", ImGuiCol_Button); m.attr("ImGuiCol_Button") = static_cast(ImGuiCol_Button); + e.value("ImGuiCol_ButtonHovered", ImGuiCol_ButtonHovered); m.attr("ImGuiCol_ButtonHovered") = static_cast(ImGuiCol_ButtonHovered); + e.value("ImGuiCol_ButtonActive", ImGuiCol_ButtonActive); m.attr("ImGuiCol_ButtonActive") = static_cast(ImGuiCol_ButtonActive); + e.value("ImGuiCol_Header", ImGuiCol_Header); m.attr("ImGuiCol_Header") = static_cast(ImGuiCol_Header); + e.value("ImGuiCol_HeaderHovered", ImGuiCol_HeaderHovered); m.attr("ImGuiCol_HeaderHovered") = static_cast(ImGuiCol_HeaderHovered); + e.value("ImGuiCol_HeaderActive", ImGuiCol_HeaderActive); m.attr("ImGuiCol_HeaderActive") = static_cast(ImGuiCol_HeaderActive); + e.value("ImGuiCol_Separator", ImGuiCol_Separator); m.attr("ImGuiCol_Separator") = static_cast(ImGuiCol_Separator); + e.value("ImGuiConl_SeparatorHovered", ImGuiCol_SeparatorHovered); m.attr("ImGuiCol_SeparatorHovered") = static_cast(ImGuiCol_SeparatorHovered); + e.value("ImGuiCol_SeparatorActive", ImGuiCol_SeparatorActive); m.attr("ImGuiCol_SeparatorActive") = static_cast(ImGuiCol_SeparatorActive); + e.value("ImGuiCol_ResizeGrip", ImGuiCol_ResizeGrip); m.attr("ImGuiCol_ResizeGrip") = static_cast(ImGuiCol_ResizeGrip); + e.value("ImGuiCol_ResizeGripHovered", ImGuiCol_ResizeGripHovered); m.attr("ImGuiCol_ResizeGripHovered") = static_cast(ImGuiCol_ResizeGripHovered); + e.value("ImGuiCol_ResizeGripActive", ImGuiCol_ResizeGripActive); m.attr("ImGuiCol_ResizeGripActive") = static_cast(ImGuiCol_ResizeGripActive); + e.value("ImGuiCol_InputTextCursor", ImGuiCol_InputTextCursor); m.attr("ImGuiCol_InputTextCursor") = static_cast(ImGuiCol_InputTextCursor); + e.value("ImGuiCol_TabHovered", ImGuiCol_TabHovered); m.attr("ImGuiCol_TabHovered") = static_cast(ImGuiCol_TabHovered); + e.value("ImGuiCol_Tab", ImGuiCol_Tab); m.attr("ImGuiCol_Tab") = static_cast(ImGuiCol_Tab); + e.value("ImGuiCol_TabSelected", ImGuiCol_TabSelected); m.attr("ImGuiCol_TabSelected") = static_cast(ImGuiCol_TabSelected); + e.value("ImGuiCol_TabSelectedOverline", ImGuiCol_TabSelectedOverline); m.attr("ImGuiCol_TabSelectedOverline") = static_cast(ImGuiCol_TabSelectedOverline); + e.value("ImGuiCol_TabDimmed", ImGuiCol_TabDimmed); m.attr("ImGuiCol_TabDimmed") = static_cast(ImGuiCol_TabDimmed); + e.value("ImGuiCol_TabDimmedSelected", ImGuiCol_TabDimmedSelected); m.attr("ImGuiCol_TabDimmedSelected") = static_cast(ImGuiCol_TabDimmedSelected); + e.value("ImGuiCol_TabDimmedSelectedOverline", ImGuiCol_TabDimmedSelectedOverline); m.attr("ImGuiCol_TabDimmedSelectedOverline") = static_cast(ImGuiCol_TabDimmedSelectedOverline); + e.value("ImGuiCol_TabUnfocused", ImGuiCol_TabUnfocused); m.attr("ImGuiCol_TabUnfocused") = static_cast(ImGuiCol_TabUnfocused); + e.value("ImGuiCol_TabUnfocusedActive", ImGuiCol_TabUnfocusedActive); m.attr("ImGuiCol_TabUnfocusedActive") = static_cast(ImGuiCol_TabUnfocusedActive); + e.value("ImGuiCol_PlotLines", ImGuiCol_PlotLines); m.attr("ImGuiCol_PlotLines") = static_cast(ImGuiCol_PlotLines); + e.value("ImGuiCol_PlotLinesHovered", ImGuiCol_PlotLinesHovered); m.attr("ImGuiCol_PlotLinesHovered") = static_cast(ImGuiCol_PlotLinesHovered); + e.value("ImGuiCol_PlotHistogram", ImGuiCol_PlotHistogram); m.attr("ImGuiCol_PlotHistogram") = static_cast(ImGuiCol_PlotHistogram); + e.value("ImGuiCol_PlotHistogramHovered", ImGuiCol_PlotHistogramHovered); m.attr("ImGuiCol_PlotHistogramHovered") = static_cast(ImGuiCol_PlotHistogramHovered); + e.value("ImGuiCol_TableHeaderBg", ImGuiCol_TableHeaderBg); m.attr("ImGuiCol_TableHeaderBg") = static_cast(ImGuiCol_TableHeaderBg); + e.value("ImGuiCol_TableBorderStrong", ImGuiCol_TableBorderStrong); m.attr("ImGuiCol_TableBorderStrong") = static_cast(ImGuiCol_TableBorderStrong); + e.value("ImGuiCol_TableBorderLight", ImGuiCol_TableBorderLight); m.attr("ImGuiCol_TableBorderLight") = static_cast(ImGuiCol_TableBorderLight); + e.value("ImGuiCol_TableRowBg", ImGuiCol_TableRowBg); m.attr("ImGuiCol_TableRowBg") = static_cast(ImGuiCol_TableRowBg); + e.value("ImGuiCol_TableRowBgAlt", ImGuiCol_TableRowBgAlt); m.attr("ImGuiCol_TableRowBgAlt") = static_cast(ImGuiCol_TableRowBgAlt); + e.value("ImGuiCol_TextLink", ImGuiCol_TextLink); m.attr("ImGuiCol_TextLink") = static_cast(ImGuiCol_TextLink); + e.value("ImGuiCol_TextSelectedBg", ImGuiCol_TextSelectedBg); m.attr("ImGuiCol_TextSelectedBg") = static_cast(ImGuiCol_TextSelectedBg); + e.value("ImGuiCol_DragDropTarget", ImGuiCol_DragDropTarget); m.attr("ImGuiCol_DragDropTarget") = static_cast(ImGuiCol_DragDropTarget); + e.value("ImGuiCol_NavCursor", ImGuiCol_NavCursor); m.attr("ImGuiCol_NavCursor") = static_cast(ImGuiCol_NavCursor); + e.value("ImGuiCol_NavWindowingHighlight", ImGuiCol_NavWindowingHighlight); m.attr("ImGuiCol_NavWindowingHighlight") = static_cast(ImGuiCol_NavWindowingHighlight); + e.value("ImGuiCol_NavWindowingDimBg", ImGuiCol_NavWindowingDimBg); m.attr("ImGuiCol_NavWindowingDimBg") = static_cast(ImGuiCol_NavWindowingDimBg); + e.value("ImGuiCol_ModalWindowDimBg", ImGuiCol_ModalWindowDimBg); m.attr("ImGuiCol_ModalWindowDimBg") = static_cast(ImGuiCol_ModalWindowDimBg); + e.value("ImGuiCol_COUNT", ImGuiCol_COUNT); m.attr("ImGuiCol_COUNT") = static_cast(ImGuiCol_COUNT); + ; + } + + { // ImGuiStyleVar ImGuiStyleVar_ + auto e = nb::enum_(m, "ImGuiStyleVar"); + e.value("ImGuiStyleVar_Alpha", ImGuiStyleVar_Alpha); m.attr("ImGuiStyleVar_Alpha") = static_cast(ImGuiStyleVar_Alpha); + e.value("ImGuiStyleVar_DisabledAlpha", ImGuiStyleVar_DisabledAlpha); m.attr("ImGuiStyleVar_DisabledAlpha") = static_cast(ImGuiStyleVar_DisabledAlpha); + e.value("ImGuiStyleVar_WindowPadding", ImGuiStyleVar_WindowPadding); m.attr("ImGuiStyleVar_WindowPadding") = static_cast(ImGuiStyleVar_WindowPadding); + e.value("ImGuiStyleVar_WindowRounding", ImGuiStyleVar_WindowRounding); m.attr("ImGuiStyleVar_WindowRounding") = static_cast(ImGuiStyleVar_WindowRounding); + e.value("ImGuiStyleVar_WindowBorderSize", ImGuiStyleVar_WindowBorderSize); m.attr("ImGuiStyleVar_WindowBorderSize") = static_cast(ImGuiStyleVar_WindowBorderSize); + e.value("ImGuiStyleVar_WindowMinSize", ImGuiStyleVar_WindowMinSize); m.attr("ImGuiStyleVar_WindowMinSize") = static_cast(ImGuiStyleVar_WindowMinSize); + e.value("ImGuiStyleVar_WindowTitleAlign", ImGuiStyleVar_WindowTitleAlign); m.attr("ImGuiStyleVar_WindowTitleAlign") = static_cast(ImGuiStyleVar_WindowTitleAlign); + e.value("ImGuiStyleVar_ChildRounding", ImGuiStyleVar_ChildRounding); m.attr("ImGuiStyleVar_ChildRounding") = static_cast(ImGuiStyleVar_ChildRounding); + e.value("ImGuiStyleVar_ChildBorderSize", ImGuiStyleVar_ChildBorderSize); m.attr("ImGuiStyleVar_ChildBorderSize") = static_cast(ImGuiStyleVar_ChildBorderSize); + e.value("ImGuiStyleVar_PopupRounding", ImGuiStyleVar_PopupRounding); m.attr("ImGuiStyleVar_PopupRounding") = static_cast(ImGuiStyleVar_PopupRounding); + e.value("ImGuiStyleVar_PopupBorderSize", ImGuiStyleVar_PopupBorderSize); m.attr("ImGuiStyleVar_PopupBorderSize") = static_cast(ImGuiStyleVar_PopupBorderSize); + e.value("ImGuiStyleVar_FramePadding", ImGuiStyleVar_FramePadding); m.attr("ImGuiStyleVar_FramePadding") = static_cast(ImGuiStyleVar_FramePadding); + e.value("ImGuiStyleVar_FrameRounding", ImGuiStyleVar_FrameRounding); m.attr("ImGuiStyleVar_FrameRounding") = static_cast(ImGuiStyleVar_FrameRounding); + e.value("ImGuiStyleVar_FrameBorderSize", ImGuiStyleVar_FrameBorderSize); m.attr("ImGuiStyleVar_FrameBorderSize") = static_cast(ImGuiStyleVar_FrameBorderSize); + e.value("ImGuiStyleVar_ItemSpacing", ImGuiStyleVar_ItemSpacing); m.attr("ImGuiStyleVar_ItemSpacing") = static_cast(ImGuiStyleVar_ItemSpacing); + e.value("ImGuiStyleVar_ItemInnerSpacing", ImGuiStyleVar_ItemInnerSpacing); m.attr("ImGuiStyleVar_ItemInnerSpacing") = static_cast(ImGuiStyleVar_ItemInnerSpacing); + e.value("ImGuiStyleVar_IndentSpacing", ImGuiStyleVar_IndentSpacing); m.attr("ImGuiStyleVar_IndentSpacing") = static_cast(ImGuiStyleVar_IndentSpacing); + e.value("ImGuiStyleVar_CellPadding", ImGuiStyleVar_CellPadding); m.attr("ImGuiStyleVar_CellPadding") = static_cast(ImGuiStyleVar_CellPadding); + e.value("ImGuiStyleVar_ScrollbarSize", ImGuiStyleVar_ScrollbarSize); m.attr("ImGuiStyleVar_ScrollbarSize") = static_cast(ImGuiStyleVar_ScrollbarSize); + e.value("ImGuiStyleVar_ScrollbarRounding", ImGuiStyleVar_ScrollbarRounding); m.attr("ImGuiStyleVar_ScrollbarRounding") = static_cast(ImGuiStyleVar_ScrollbarRounding); + e.value("ImGuiStyleVar_ScrollbarPadding", ImGuiStyleVar_ScrollbarPadding); m.attr("ImGuiStyleVar_ScrollbarPadding") = static_cast(ImGuiStyleVar_ScrollbarPadding); + e.value("ImGuiStyleVar_GrabMinSize", ImGuiStyleVar_GrabMinSize); m.attr("ImGuiStyleVar_GrabMinSize") = static_cast(ImGuiStyleVar_GrabMinSize); + e.value("ImGuiStyleVar_GrabRounding", ImGuiStyleVar_GrabRounding); m.attr("ImGuiStyleVar_GrabRounding") = static_cast(ImGuiStyleVar_GrabRounding); + e.value("ImGuiStyleVar_ImageBorderSize", ImGuiStyleVar_ImageBorderSize); m.attr("ImGuiStyleVar_ImageBorderSize") = static_cast(ImGuiStyleVar_ImageBorderSize); + e.value("ImGuiStyleVar_TabRounding", ImGuiStyleVar_TabRounding); m.attr("ImGuiStyleVar_TabRounding") = static_cast(ImGuiStyleVar_TabRounding); + e.value("ImGuiStyleVar_TabBorderSize", ImGuiStyleVar_TabBorderSize); m.attr("ImGuiStyleVar_TabBorderSize") = static_cast(ImGuiStyleVar_TabBorderSize); + e.value("ImGuiStyleVar_TabMinWidthBase", ImGuiStyleVar_TabMinWidthBase); m.attr("ImGuiStyleVar_TabMinWidthBase") = static_cast(ImGuiStyleVar_TabMinWidthBase); + e.value("ImGuiStyleVar_TabMinWidthShrink", ImGuiStyleVar_TabMinWidthShrink); m.attr("ImGuiStyleVar_TabMinWidthShrink") = static_cast(ImGuiStyleVar_TabMinWidthShrink); + e.value("ImGuiStyleVar_TabBarBorderSize", ImGuiStyleVar_TabBarBorderSize); m.attr("ImGuiStyleVar_TabBarBorderSize") = static_cast(ImGuiStyleVar_TabBarBorderSize); + e.value("ImGuiStyleVar_TabBarOverlineSize", ImGuiStyleVar_TabBarOverlineSize); m.attr("ImGuiStyleVar_TabBarOverlineSize") = static_cast(ImGuiStyleVar_TabBarOverlineSize); + e.value("ImGuiStyleVar_TableAngledHeadersAngle", ImGuiStyleVar_TableAngledHeadersAngle); m.attr("ImGuiStyleVar_TableAngledHeadersAngle") = static_cast(ImGuiStyleVar_TableAngledHeadersAngle); + e.value("ImGuiStyleVar_TableAngledHeadersTextAlign", ImGuiStyleVar_TableAngledHeadersTextAlign); m.attr("ImGuiStyleVar_TableAngledHeadersTextAlign") = static_cast(ImGuiStyleVar_TableAngledHeadersTextAlign); + e.value("ImGuiStyleVar_TreeLinesSize", ImGuiStyleVar_TreeLinesSize); m.attr("ImGuiStyleVar_TreeLinesSize") = static_cast(ImGuiStyleVar_TreeLinesSize); + e.value("ImGuiStyleVar_TreeLinesRounding", ImGuiStyleVar_TreeLinesRounding); m.attr("ImGuiStyleVar_TreeLinesRounding") = static_cast(ImGuiStyleVar_TreeLinesRounding); + e.value("ImGuiStyleVar_ButtonTextAlign", ImGuiStyleVar_ButtonTextAlign); m.attr("ImGuiStyleVar_ButtonTextAlign") = static_cast(ImGuiStyleVar_ButtonTextAlign); + e.value("ImGuiStyleVar_SelectableTextAlign", ImGuiStyleVar_SelectableTextAlign); m.attr("ImGuiStyleVar_SelectableTextAlign") = static_cast(ImGuiStyleVar_SelectableTextAlign); + e.value("ImGuiStyleVar_SeparatorTextBorderSize", ImGuiStyleVar_SeparatorTextBorderSize); m.attr("ImGuiStyleVar_SeparatorTextBorderSize") = static_cast(ImGuiStyleVar_SeparatorTextBorderSize); + e.value("ImGuiStyleVar_SeparatorTextAlign", ImGuiStyleVar_SeparatorTextAlign); m.attr("ImGuiStyleVar_SeparatorTextAlign") = static_cast(ImGuiStyleVar_SeparatorTextAlign); + e.value("ImGuiStyleVar_SeparatorTextPadding", ImGuiStyleVar_SeparatorTextPadding); m.attr("ImGuiStyleVar_SeparatorTextPadding") = static_cast(ImGuiStyleVar_SeparatorTextPadding); + ; + } + + { // ImGuiButtonFlags ImGuiButtonFlags_ + auto e = nb::enum_(m, "ImGuiButtonFlags"); + e.value("ImGuiButtonFlags_None", ImGuiButtonFlags_None); m.attr("ImGuiButtonFlags_None") = static_cast(ImGuiButtonFlags_None); + e.value("ImGuiButtonFlags_MouseButtonLeft", ImGuiButtonFlags_MouseButtonLeft); m.attr("ImGuiButtonFlags_MouseButtonLeft") = static_cast(ImGuiButtonFlags_MouseButtonLeft); + e.value("ImGuiButtonFlags_MouseButtonRight", ImGuiButtonFlags_MouseButtonRight); m.attr("ImGuiButtonFlags_MouseButtonRight") = static_cast(ImGuiButtonFlags_MouseButtonRight); + e.value("ImGuiButtonFlags_MouseButtonMiddle", ImGuiButtonFlags_MouseButtonMiddle); m.attr("ImGuiButtonFlags_MouseButtonMiddle") = static_cast(ImGuiButtonFlags_MouseButtonMiddle); + e.value("ImGuiButtonFlags_MouseButtonMask_", ImGuiButtonFlags_MouseButtonMask_); m.attr("ImGuiButtonFlags_MouseButtonMask_") = static_cast(ImGuiButtonFlags_MouseButtonMask_); + e.value("ImGuiButtonFlags_EnableNav", ImGuiButtonFlags_EnableNav); m.attr("ImGuiButtonFlags_EnableNav") = static_cast(ImGuiButtonFlags_EnableNav); + ; + } + + { // ImGuiColorEditFlags ImGuiColorEditFlags_ + auto e = nb::enum_(m, "ImGuiColorEditFlags"); + e.value("ImGuiColorEditFlags_None", ImGuiColorEditFlags_None); m.attr("ImGuiColorEditFlags_None") = static_cast(ImGuiColorEditFlags_None); + e.value("ImGuiColorEditFlags_NoAlpha", ImGuiColorEditFlags_NoAlpha); m.attr("ImGuiColorEditFlags_NoAlpha") = static_cast(ImGuiColorEditFlags_NoAlpha); + e.value("ImGuiColorEditFlags_NoPicker", ImGuiColorEditFlags_NoPicker); m.attr("ImGuiColorEditFlags_NoPicker") = static_cast(ImGuiColorEditFlags_NoPicker); + e.value("ImGuiColorEditFlags_NoOptions", ImGuiColorEditFlags_NoOptions); m.attr("ImGuiColorEditFlags_NoOptions") = static_cast(ImGuiColorEditFlags_NoOptions); + e.value("ImGuiColorEditFlags_NoSmallPreview", ImGuiColorEditFlags_NoSmallPreview); m.attr("ImGuiColorEditFlags_NoSmallPreview") = static_cast(ImGuiColorEditFlags_NoSmallPreview); + e.value("ImGuiColorEditFlags_NoInputs", ImGuiColorEditFlags_NoInputs); m.attr("ImGuiColorEditFlags_NoInputs") = static_cast(ImGuiColorEditFlags_NoInputs); + e.value("ImGuiColorEditFlags_NoTooltip", ImGuiColorEditFlags_NoTooltip); m.attr("ImGuiColorEditFlags_NoTooltip") = static_cast(ImGuiColorEditFlags_NoTooltip); + e.value("ImGuiColorEditFlags_NoLabel", ImGuiColorEditFlags_NoLabel); m.attr("ImGuiColorEditFlags_NoLabel") = static_cast(ImGuiColorEditFlags_NoLabel); + e.value("ImGuiColorEditFlags_NoSidePreview", ImGuiColorEditFlags_NoSidePreview); m.attr("ImGuiColorEditFlags_NoSidePreview") = static_cast(ImGuiColorEditFlags_NoSidePreview); + e.value("ImGuiColorEditFlags_NoDragDrop", ImGuiColorEditFlags_NoDragDrop); m.attr("ImGuiColorEditFlags_NoDragDrop") = static_cast(ImGuiColorEditFlags_NoDragDrop); + e.value("ImGuiColorEditFlags_NoBorder", ImGuiColorEditFlags_NoBorder); m.attr("ImGuiColorEditFlags_NoBorder") = static_cast(ImGuiColorEditFlags_NoBorder); + e.value("ImGuiColorEditFlags_AlphaBar", ImGuiColorEditFlags_AlphaBar); m.attr("ImGuiColorEditFlags_AlphaBar") = static_cast(ImGuiColorEditFlags_AlphaBar); + e.value("ImGuiColorEditFlags_AlphaPreview", ImGuiColorEditFlags_AlphaPreview); m.attr("ImGuiColorEditFlags_AlphaPreview") = static_cast(ImGuiColorEditFlags_AlphaPreview); + e.value("ImGuiColorEditFlags_AlphaPreviewHalf", ImGuiColorEditFlags_AlphaPreviewHalf); m.attr("ImGuiColorEditFlags_AlphaPreviewHalf") = static_cast(ImGuiColorEditFlags_AlphaPreviewHalf); + e.value("ImGuiColorEditFlags_HDR", ImGuiColorEditFlags_HDR); m.attr("ImGuiColorEditFlags_HDR") = static_cast(ImGuiColorEditFlags_HDR); + e.value("ImGuiColorEditFlags_DisplayRGB", ImGuiColorEditFlags_DisplayRGB); m.attr("ImGuiColorEditFlags_DisplayRGB") = static_cast(ImGuiColorEditFlags_DisplayRGB); + e.value("ImGuiColorEditFlags_DisplayHSV", ImGuiColorEditFlags_DisplayHSV); m.attr("ImGuiColorEditFlags_DisplayHSV") = static_cast(ImGuiColorEditFlags_DisplayHSV); + e.value("ImGuiColorEditFlags_DisplayHex", ImGuiColorEditFlags_DisplayHex); m.attr("ImGuiColorEditFlags_DisplayHex") = static_cast(ImGuiColorEditFlags_DisplayHex); + e.value("ImGuiColorEditFlags_Uint8", ImGuiColorEditFlags_Uint8); m.attr("ImGuiColorEditFlags_Uint8") = static_cast(ImGuiColorEditFlags_Uint8); + e.value("ImGuiColorEditFlags_Float", ImGuiColorEditFlags_Float); m.attr("ImGuiColorEditFlags_Float") = static_cast(ImGuiColorEditFlags_Float); + e.value("ImGuiColorEditFlags_PickerHueBar", ImGuiColorEditFlags_PickerHueBar); m.attr("ImGuiColorEditFlags_PickerHueBar") = static_cast(ImGuiColorEditFlags_PickerHueBar); + e.value("ImGuiColorEditFlags_PickerHueWheel", ImGuiColorEditFlags_PickerHueWheel); m.attr("ImGuiColorEditFlags_PickerHueWheel") = static_cast(ImGuiColorEditFlags_PickerHueWheel); + e.value("ImGuiColorEditFlags_InputRGB", ImGuiColorEditFlags_InputRGB); m.attr("ImGuiColorEditFlags_InputRGB") = static_cast(ImGuiColorEditFlags_InputRGB); + e.value("ImGuiColorEditFlags_InputHSV", ImGuiColorEditFlags_InputHSV); m.attr("ImGuiColorEditFlags_InputHSV") = static_cast(ImGuiColorEditFlags_InputHSV); + ; + } + + { // ImGuiSliderFlags ImGuiSliderFlags_ + auto e = nb::enum_(m, "ImGuiSliderFlags"); + e.value("ImGuiSliderFlags_None", ImGuiSliderFlags_None); m.attr("ImGuiSliderFlags_None") = static_cast(ImGuiSliderFlags_None); + e.value("ImGuiSliderFlags_Logarithmic", ImGuiSliderFlags_Logarithmic); m.attr("ImGuiSliderFlags_Logarithmic") = static_cast(ImGuiSliderFlags_Logarithmic); + e.value("ImGuiSliderFlags_NoRoundToFormat", ImGuiSliderFlags_NoRoundToFormat); m.attr("ImGuiSliderFlags_NoRoundToFormat") = static_cast(ImGuiSliderFlags_NoRoundToFormat); + e.value("ImGuiSliderFlags_NoInput", ImGuiSliderFlags_NoInput); m.attr("ImGuiSliderFlags_NoInput") = static_cast(ImGuiSliderFlags_NoInput); + e.value("ImGuiSliderFlags_WrapAround", ImGuiSliderFlags_WrapAround); m.attr("ImGuiSliderFlags_WrapAround") = static_cast(ImGuiSliderFlags_WrapAround); + e.value("ImGuiSliderFlags_ClampOnInput", ImGuiSliderFlags_ClampOnInput); m.attr("ImGuiSliderFlags_ClampOnInput") = static_cast(ImGuiSliderFlags_ClampOnInput); + e.value("ImGuiSliderFlags_ClampZeroRange", ImGuiSliderFlags_ClampZeroRange); m.attr("ImGuiSliderFlags_ClampZeroRange") = static_cast(ImGuiSliderFlags_ClampZeroRange); + e.value("ImGuiSliderFlags_NoSpeedTweaks", ImGuiSliderFlags_NoSpeedTweaks); m.attr("ImGuiSliderFlags_NoSpeedTweaks") = static_cast(ImGuiSliderFlags_NoSpeedTweaks); + e.value("ImGuiSliderFlags_AlwaysClamp", ImGuiSliderFlags_AlwaysClamp); m.attr("ImGuiSliderFlags_AlwaysClamp") = static_cast(ImGuiSliderFlags_AlwaysClamp); + e.value("ImGuiSliderFlags_InvalidMask_", ImGuiSliderFlags_InvalidMask_); m.attr("ImGuiSliderFlags_InvalidMask_") = static_cast(ImGuiSliderFlags_InvalidMask_); + ; + } + + { // ImGuiMouseButton ImGuiMouseButton_ + auto e = nb::enum_(m, "ImGuiMouseButton"); + e.value("ImGuiMouseButton_Left", ImGuiMouseButton_Left); m.attr("ImGuiMouseButton_Left") = static_cast(ImGuiMouseButton_Left); + e.value("ImGuiMouseButton_Right", ImGuiMouseButton_Right); m.attr("ImGuiMouseButton_Right") = static_cast(ImGuiMouseButton_Right); + e.value("ImGuiMouseButton_Middle", ImGuiMouseButton_Middle); m.attr("ImGuiMouseButton_Middle") = static_cast(ImGuiMouseButton_Middle); + e.value("ImGuiMouseButton_COUNT", ImGuiMouseButton_COUNT); m.attr("ImGuiMouseButton_COUNT") = static_cast(ImGuiMouseButton_COUNT); + ; + } + + { // ImGuiMouseCursor ImGuiMouseCursor_ + auto e = nb::enum_(m, "ImGuiMouseCursor"); + e.value("ImGuiMouseCursor_None", ImGuiMouseCursor_None); m.attr("ImGuiMouseCursor_None") = static_cast(ImGuiMouseCursor_None); + e.value("ImGuiMouseCursor_Arrow", ImGuiMouseCursor_Arrow); m.attr("ImGuiMouseCursor_Arrow") = static_cast(ImGuiMouseCursor_Arrow); + e.value("ImGuiMouseCursor_TextInput", ImGuiMouseCursor_TextInput); m.attr("ImGuiMouseCursor_TextInput") = static_cast(ImGuiMouseCursor_TextInput); + e.value("ImGuiMouseCursor_ResizeAll", ImGuiMouseCursor_ResizeAll); m.attr("ImGuiMouseCursor_ResizeAll") = static_cast(ImGuiMouseCursor_ResizeAll); + e.value("ImGuiMouseCursor_ResizeNS", ImGuiMouseCursor_ResizeNS); m.attr("ImGuiMouseCursor_ResizeNS") = static_cast(ImGuiMouseCursor_ResizeNS); + e.value("ImGuiMouseCursor_ResizeEW", ImGuiMouseCursor_ResizeEW); m.attr("ImGuiMouseCursor_ResizeEW") = static_cast(ImGuiMouseCursor_ResizeEW); + e.value("ImGuiMouseCursor_ResizeNESW", ImGuiMouseCursor_ResizeNESW); m.attr("ImGuiMouseCursor_ResizeNESW") = static_cast(ImGuiMouseCursor_ResizeNESW); + e.value("ImGuiMouseCursor_ResizeNWSE", ImGuiMouseCursor_ResizeNWSE); m.attr("ImGuiMouseCursor_ResizeNWSE") = static_cast(ImGuiMouseCursor_ResizeNWSE); + e.value("ImGuiMouseCursor_Hand", ImGuiMouseCursor_Hand); m.attr("ImGuiMouseCursor_Hand") = static_cast(ImGuiMouseCursor_Hand); + e.value("ImGuiMouseCursor_NotAllowed", ImGuiMouseCursor_NotAllowed); m.attr("ImGuiMouseCursor_NotAllowed") = static_cast(ImGuiMouseCursor_NotAllowed); + e.value("ImGuiMouseCursor_COUNT", ImGuiMouseCursor_COUNT); m.attr("ImGuiMouseCursor_COUNT") = static_cast(ImGuiMouseCursor_COUNT); + ; + } + + { // ImGuiMouseSource ImGuiMouseSource + auto e = nb::enum_(m, "ImGuiMouseSource"); + e.value("ImGuiMouseSource_Mouse", ImGuiMouseSource_Mouse); m.attr("ImGuiMouseSource_Mouse") = static_cast(ImGuiMouseSource_Mouse); + e.value("ImGuiMouseSource_TouchScreen", ImGuiMouseSource_TouchScreen); m.attr("ImGuiMouseSource_TouchScreen") = static_cast(ImGuiMouseSource_TouchScreen); + e.value("ImGuiMouseSource_Pen", ImGuiMouseSource_Pen); m.attr("ImGuiMouseSource_Pen") = static_cast(ImGuiMouseSource_Pen); + e.value("ImGuiMouseSource_COUNT", ImGuiMouseSource_COUNT); m.attr("ImGuiMouseSource_COUNT") = static_cast(ImGuiMouseSource_COUNT); + ; + } + + { // ImGuiCond ImGuiCond_ + auto e = nb::enum_(m, "ImGuiCond"); + e.value("ImGuiCond_Always", ImGuiCond_Always); m.attr("ImGuiCond_Always") = static_cast(ImGuiCond_Always); + e.value("ImGuiCond_Once", ImGuiCond_Once); m.attr("ImGuiCond_Once") = static_cast(ImGuiCond_Once); + e.value("ImGuiCond_FirstUseEver", ImGuiCond_FirstUseEver); m.attr("ImGuiCond_FirstUseEver") = static_cast(ImGuiCond_FirstUseEver); + e.value("ImGuiCond_Appearing", ImGuiCond_Appearing); m.attr("ImGuiCond_Appearing") = static_cast(ImGuiCond_Appearing); + ; + } + + { // ImGuiTableFlags ImGuiTableFlags_ + auto e = nb::enum_(m, "ImGuiTableFlags"); + e.value("ImGuiTableFlags_None", ImGuiTableFlags_None); m.attr("ImGuiTableFlags_None") = static_cast(ImGuiTableFlags_None); + e.value("ImGuiTableFlags_Resizable", ImGuiTableFlags_Resizable); m.attr("ImGuiTableFlags_Resizable") = static_cast(ImGuiTableFlags_Resizable); + e.value("ImGuiTableFlags_Reorderable", ImGuiTableFlags_Reorderable); m.attr("ImGuiTableFlags_Reorderable") = static_cast(ImGuiTableFlags_Reorderable); + e.value("ImGuiTableFlags_Hideable", ImGuiTableFlags_Hideable); m.attr("ImGuiTableFlags_Hideable") = static_cast(ImGuiTableFlags_Hideable); + e.value("ImGuiTableFlags_Sortable", ImGuiTableFlags_Sortable); m.attr("ImGuiTableFlags_Sortable") = static_cast(ImGuiTableFlags_Sortable); + e.value("ImGuiTableFlags_NoSavedSettings", ImGuiTableFlags_NoSavedSettings); m.attr("ImGuiTableFlags_NoSavedSettings") = static_cast(ImGuiTableFlags_NoSavedSettings); + e.value("ImGuiTableFlags_ContextMenuInBody", ImGuiTableFlags_ContextMenuInBody); m.attr("ImGuiTableFlags_ContextMenuInBody") = static_cast(ImGuiTableFlags_ContextMenuInBody); + e.value("ImGuiTableFlags_RowBg", ImGuiTableFlags_RowBg); m.attr("ImGuiTableFlags_RowBg") = static_cast(ImGuiTableFlags_RowBg); + e.value("ImGuiTableFlags_BordersInnerH", ImGuiTableFlags_BordersInnerH); m.attr("ImGuiTableFlags_BordersInnerH") = static_cast(ImGuiTableFlags_BordersInnerH); + e.value("ImGuiTableFlags_BordersOuterH", ImGuiTableFlags_BordersOuterH); m.attr("ImGuiTableFlags_BordersOuterH") = static_cast(ImGuiTableFlags_BordersOuterH); + e.value("ImGuiTableFlags_BordersInnerV", ImGuiTableFlags_BordersInnerV); m.attr("ImGuiTableFlags_BordersInnerV") = static_cast(ImGuiTableFlags_BordersInnerV); + e.value("ImGuiTableFlags_BordersOuterV", ImGuiTableFlags_BordersOuterV); m.attr("ImGuiTableFlags_BordersOuterV") = static_cast(ImGuiTableFlags_BordersOuterV); + e.value("ImGuiTableFlags_BordersH", ImGuiTableFlags_BordersH); m.attr("ImGuiTableFlags_BordersH") = static_cast(ImGuiTableFlags_BordersH); + e.value("ImGuiTableFlags_BordersV", ImGuiTableFlags_BordersV); m.attr("ImGuiTableFlags_BordersV") = static_cast(ImGuiTableFlags_BordersV); + e.value("ImGuiTableFlags_BordersInner", ImGuiTableFlags_BordersInner); m.attr("ImGuiTableFlags_BordersInner") = static_cast(ImGuiTableFlags_BordersInner); + e.value("ImGuiTableFlags_BordersOuter", ImGuiTableFlags_BordersOuter); m.attr("ImGuiTableFlags_BordersOuter") = static_cast(ImGuiTableFlags_BordersOuter); + e.value("ImGuiTableFlags_Borders", ImGuiTableFlags_Borders); m.attr("ImGuiTableFlags_Borders") = static_cast(ImGuiTableFlags_Borders); + e.value("ImGuiTableFlags_NoBordersInBody", ImGuiTableFlags_NoBordersInBody); m.attr("ImGuiTableFlags_NoBordersInBody") = static_cast(ImGuiTableFlags_NoBordersInBody); + e.value("ImGuiTableFlags_NoBordersInBodyUntilResize", ImGuiTableFlags_NoBordersInBodyUntilResize); m.attr("ImGuiTableFlags_NoBordersInBodyUntilResize") = static_cast(ImGuiTableFlags_NoBordersInBodyUntilResize); + e.value("ImGuiTableFlags_SizingFixedFit", ImGuiTableFlags_SizingFixedFit); m.attr("ImGuiTableFlags_SizingFixedFit") = static_cast(ImGuiTableFlags_SizingFixedFit); + e.value("ImGuiTableFlags_SizingFixedSame", ImGuiTableFlags_SizingFixedSame); m.attr("ImGuiTableFlags_SizingFixedSame") = static_cast(ImGuiTableFlags_SizingFixedSame); + e.value("ImGuiTableFlags_SizingStretchProp", ImGuiTableFlags_SizingStretchProp); m.attr("ImGuiTableFlags_SizingStretchProp") = static_cast(ImGuiTableFlags_SizingStretchProp); + e.value("ImGuiTableFlags_SizingStretchSame", ImGuiTableFlags_SizingStretchSame); m.attr("ImGuiTableFlags_SizingStretchSame") = static_cast(ImGuiTableFlags_SizingStretchSame); + e.value("ImGuiTableFlags_NoHostExtendX", ImGuiTableFlags_NoHostExtendX); m.attr("ImGuiTableFlags_NoHostExtendX") = static_cast(ImGuiTableFlags_NoHostExtendX); + e.value("ImGuiTableFlags_NoHostExtendY", ImGuiTableFlags_NoHostExtendY); m.attr("ImGuiTableFlags_NoHostExtendY") = static_cast(ImGuiTableFlags_NoHostExtendY); + e.value("ImGuiTableFlags_NoKeepColumnsVisible", ImGuiTableFlags_NoKeepColumnsVisible); m.attr("ImGuiTableFlags_NoKeepColumnsVisible") = static_cast(ImGuiTableFlags_NoKeepColumnsVisible); + e.value("ImGuiTableFlags_PreciseWidths", ImGuiTableFlags_PreciseWidths); m.attr("ImGuiTableFlags_PreciseWidths") = static_cast(ImGuiTableFlags_PreciseWidths); + e.value("ImGuiTableFlags_NoClip", ImGuiTableFlags_NoClip); m.attr("ImGuiTableFlags_NoClip") = static_cast(ImGuiTableFlags_NoClip); + e.value("ImGuiTableFlags_PadOuterX", ImGuiTableFlags_PadOuterX); m.attr("ImGuiTableFlags_PadOuterX") = static_cast(ImGuiTableFlags_PadOuterX); + e.value("ImGuiTableFlags_NoPadOuterX", ImGuiTableFlags_NoPadOuterX); m.attr("ImGuiTableFlags_NoPadOuterX") = static_cast(ImGuiTableFlags_NoPadOuterX); + e.value("ImGuiTableFlags_NoPadInnerX", ImGuiTableFlags_NoPadInnerX); m.attr("ImGuiTableFlags_NoPadInnerX") = static_cast(ImGuiTableFlags_NoPadInnerX); + e.value("ImGuiTableFlags_ScrollX", ImGuiTableFlags_ScrollX); m.attr("ImGuiTableFlags_ScrollX") = static_cast(ImGuiTableFlags_ScrollX); + e.value("ImGuiTableFlags_ScrollY", ImGuiTableFlags_ScrollY); m.attr("ImGuiTableFlags_ScrollY") = static_cast(ImGuiTableFlags_ScrollY); + e.value("ImGuiTableFlags_SortMulti", ImGuiTableFlags_SortMulti); m.attr("ImGuiTableFlags_SortMulti") = static_cast(ImGuiTableFlags_SortMulti); + e.value("ImGuiTableFlags_SortTristate", ImGuiTableFlags_SortTristate); m.attr("ImGuiTableFlags_SortTristate") = static_cast(ImGuiTableFlags_SortTristate); + e.value("ImGuiTableFlags_HighlightHoveredColumn", ImGuiTableFlags_HighlightHoveredColumn); m.attr("ImGuiTableFlags_HighlightHoveredColumn") = static_cast(ImGuiTableFlags_HighlightHoveredColumn); + ; + } + + { // ImGuiTableColumnFlags ImGuiTableColumnFlags_ + auto e = nb::enum_(m, "ImGuiTableColumnFlags"); + e.value("ImGuiTableColumnFlags_None", ImGuiTableColumnFlags_None); m.attr("ImGuiTableColumnFlags_None") = static_cast(ImGuiTableColumnFlags_None); + e.value("ImGuiTableColumnFlags_Disabled", ImGuiTableColumnFlags_Disabled); m.attr("ImGuiTableColumnFlags_Disabled") = static_cast(ImGuiTableColumnFlags_Disabled); + e.value("ImGuiTableColumnFlags_DefaultHide", ImGuiTableColumnFlags_DefaultHide); m.attr("ImGuiTableColumnFlags_DefaultHide") = static_cast(ImGuiTableColumnFlags_DefaultHide); + e.value("ImGuiTableColumnFlags_DefaultSort", ImGuiTableColumnFlags_DefaultSort); m.attr("ImGuiTableColumnFlags_DefaultSort") = static_cast(ImGuiTableColumnFlags_DefaultSort); + e.value("ImGuiTableColumnFlags_WidthStretch", ImGuiTableColumnFlags_WidthStretch); m.attr("ImGuiTableColumnFlags_WidthStretch") = static_cast(ImGuiTableColumnFlags_WidthStretch); + e.value("ImGuiTableColumnFlags_WidthFixed", ImGuiTableColumnFlags_WidthFixed); m.attr("ImGuiTableColumnFlags_WidthFixed") = static_cast(ImGuiTableColumnFlags_WidthFixed); + e.value("ImGuiTableColumnFlags_NoResize", ImGuiTableColumnFlags_NoResize); m.attr("ImGuiTableColumnFlags_NoResize") = static_cast(ImGuiTableColumnFlags_NoResize); + e.value("ImGuiTableColumnFlags_NoReorder", ImGuiTableColumnFlags_NoReorder); m.attr("ImGuiTableColumnFlags_NoReorder") = static_cast(ImGuiTableColumnFlags_NoReorder); + e.value("ImGuiTableColumnFlags_NoHide", ImGuiTableColumnFlags_NoHide); m.attr("ImGuiTableColumnFlags_NoHide") = static_cast(ImGuiTableColumnFlags_NoHide); + e.value("ImGuiTableColumnFlags_NoClip", ImGuiTableColumnFlags_NoClip); m.attr("ImGuiTableColumnFlags_NoClip") = static_cast(ImGuiTableColumnFlags_NoClip); + e.value("ImGuiTableColumnFlags_NoSort", ImGuiTableColumnFlags_NoSort); m.attr("ImGuiTableColumnFlags_NoSort") = static_cast(ImGuiTableColumnFlags_NoSort); + e.value("ImGuiTableColumnFlags_NoSortAscending", ImGuiTableColumnFlags_NoSortAscending); m.attr("ImGuiTableColumnFlags_NoSortAscending") = static_cast(ImGuiTableColumnFlags_NoSortAscending); + e.value("ImGuiTableColumnFlags_NoSortDescending", ImGuiTableColumnFlags_NoSortDescending); m.attr("ImGuiTableColumnFlags_NoSortDescending") = static_cast(ImGuiTableColumnFlags_NoSortDescending); + e.value("ImGuiTableColumnFlags_NoHeaderLabel", ImGuiTableColumnFlags_NoHeaderLabel); m.attr("ImGuiTableColumnFlags_NoHeaderLabel") = static_cast(ImGuiTableColumnFlags_NoHeaderLabel); + e.value("ImGuiTableColumnFlags_NoHeaderWidth", ImGuiTableColumnFlags_NoHeaderWidth); m.attr("ImGuiTableColumnFlags_NoHeaderWidth") = static_cast(ImGuiTableColumnFlags_NoHeaderWidth); + e.value("ImGuiTableColumnFlags_PreferSortAscending", ImGuiTableColumnFlags_PreferSortAscending); m.attr("ImGuiTableColumnFlags_PreferSortAscending") = static_cast(ImGuiTableColumnFlags_PreferSortAscending); + e.value("ImGuiTableColumnFlags_PreferSortDescending", ImGuiTableColumnFlags_PreferSortDescending); m.attr("ImGuiTableColumnFlags_PreferSortDescending") = static_cast(ImGuiTableColumnFlags_PreferSortDescending); + e.value("ImGuiTableColumnFlags_IndentEnable", ImGuiTableColumnFlags_IndentEnable); m.attr("ImGuiTableColumnFlags_IndentEnable") = static_cast(ImGuiTableColumnFlags_IndentEnable); + e.value("ImGuiTableColumnFlags_IndentDisable", ImGuiTableColumnFlags_IndentDisable); m.attr("ImGuiTableColumnFlags_IndentDisable") = static_cast(ImGuiTableColumnFlags_IndentDisable); + e.value("ImGuiTableColumnFlags_AngledHeader", ImGuiTableColumnFlags_AngledHeader); m.attr("ImGuiTableColumnFlags_AngledHeader") = static_cast(ImGuiTableColumnFlags_AngledHeader); + e.value("ImGuiTableColumnFlags_IsEnabled", ImGuiTableColumnFlags_IsEnabled); m.attr("ImGuiTableColumnFlags_IsEnabled") = static_cast(ImGuiTableColumnFlags_IsEnabled); + e.value("ImGuiTableColumnFlags_IsVisible", ImGuiTableColumnFlags_IsVisible); m.attr("ImGuiTableColumnFlags_IsVisible") = static_cast(ImGuiTableColumnFlags_IsVisible); + e.value("ImGuiTableColumnFlags_IsSorted", ImGuiTableColumnFlags_IsSorted); m.attr("ImGuiTableColumnFlags_IsSorted") = static_cast(ImGuiTableColumnFlags_IsSorted); + e.value("ImGuiTableColumnFlags_IsHovered", ImGuiTableColumnFlags_IsHovered); m.attr("ImGuiTableColumnFlags_IsHovered") = static_cast(ImGuiTableColumnFlags_IsHovered); + ; + } + + { // ImGuiTableRowFlags ImGuiTableRowFlags_ + auto e = nb::enum_(m, "ImGuiTableRowFlags"); + e.value("ImGuiTableRowFlags_None", ImGuiTableRowFlags_None); m.attr("ImGuiTableRowFlags_None") = static_cast(ImGuiTableRowFlags_None); + e.value("ImGuiTableRowFlags_Headers", ImGuiTableRowFlags_Headers); m.attr("ImGuiTableRowFlags_Headers") = static_cast(ImGuiTableRowFlags_Headers); + ; + } + + { // ImGuiTableBgTarget ImGuiTableBgTarget_ + auto e = nb::enum_(m, "ImGuiTableBgTarget"); + e.value("ImGuiTableBgTarget_None", ImGuiTableBgTarget_None); m.attr("ImGuiTableBgTarget_None") = static_cast(ImGuiTableBgTarget_None); + e.value("ImGuiTableBgTarget_RowBg0", ImGuiTableBgTarget_RowBg0); m.attr("ImGuiTableBgTarget_RowBg0") = static_cast(ImGuiTableBgTarget_RowBg0); + e.value("ImGuiTableBgTarget_RowBg1", ImGuiTableBgTarget_RowBg1); m.attr("ImGuiTableBgTarget_RowBg1") = static_cast(ImGuiTableBgTarget_RowBg1); + e.value("ImGuiTableBgTarget_CellBg", ImGuiTableBgTarget_CellBg); m.attr("ImGuiTableBgTarget_CellBg") = static_cast(ImGuiTableBgTarget_CellBg); + ; + } + + { // ImDrawFlags ImDrawFlags_ + auto e = nb::enum_(m, "ImDrawFlags"); + e.value("ImDrawFlags_None", ImDrawFlags_None); m.attr("ImDrawFlags_None") = static_cast(ImDrawFlags_None); + e.value("ImDrawFlags_Closed", ImDrawFlags_Closed); m.attr("ImDrawFlags_Closed") = static_cast(ImDrawFlags_Closed); + e.value("ImDrawFlags_RoundCornersTopLeft", ImDrawFlags_RoundCornersTopLeft); m.attr("ImDrawFlags_RoundCornersTopLeft") = static_cast(ImDrawFlags_RoundCornersTopLeft); + e.value("ImDrawFlags_RoundCornersTopRight", ImDrawFlags_RoundCornersTopRight); m.attr("ImDrawFlags_RoundCornersTopRight") = static_cast(ImDrawFlags_RoundCornersTopRight); + e.value("ImDrawFlags_RoundCornersBottomLeft", ImDrawFlags_RoundCornersBottomLeft); m.attr("ImDrawFlags_RoundCornersBottomLeft") = static_cast(ImDrawFlags_RoundCornersBottomLeft); + e.value("ImDrawFlags_RoundCornersBottomRight", ImDrawFlags_RoundCornersBottomRight); m.attr("ImDrawFlags_RoundCornersBottomRight") = static_cast(ImDrawFlags_RoundCornersBottomRight); + e.value("ImDrawFlags_RoundCornersNone", ImDrawFlags_RoundCornersNone); m.attr("ImDrawFlags_RoundCornersNone") = static_cast(ImDrawFlags_RoundCornersNone); + e.value("ImDrawFlags_RoundCornersTop", ImDrawFlags_RoundCornersTop); m.attr("ImDrawFlags_RoundCornersTop") = static_cast(ImDrawFlags_RoundCornersTop); + e.value("ImDrawFlags_RoundCornersBottom", ImDrawFlags_RoundCornersBottom); m.attr("ImDrawFlags_RoundCornersBottom") = static_cast(ImDrawFlags_RoundCornersBottom); + e.value("ImDrawFlags_RoundCornersLeft", ImDrawFlags_RoundCornersLeft); m.attr("ImDrawFlags_RoundCornersLeft") = static_cast(ImDrawFlags_RoundCornersLeft); + e.value("ImDrawFlags_RoundCornersRight", ImDrawFlags_RoundCornersRight); m.attr("ImDrawFlags_RoundCornersRight") = static_cast(ImDrawFlags_RoundCornersRight); + e.value("ImDrawFlags_RoundCornersAll", ImDrawFlags_RoundCornersAll); m.attr("ImDrawFlags_RoundCornersAll") = static_cast(ImDrawFlags_RoundCornersAll); + ; + } + + { // ImGuiKey ImGuiKey + auto e = nb::enum_(m, "ImGuiKey"); + e.value("ImGuiKey_None", ImGuiKey_None); m.attr("ImGuiKey_None") = static_cast(ImGuiKey_None); + e.value("ImGuiKey_Tab", ImGuiKey_Tab); m.attr("ImGuiKey_Tab") = static_cast(ImGuiKey_Tab); + e.value("ImGuiKey_LeftArrow", ImGuiKey_LeftArrow); m.attr("ImGuiKey_LeftArrow") = static_cast(ImGuiKey_LeftArrow); + e.value("ImGuiKey_RightArrow", ImGuiKey_RightArrow); m.attr("ImGuiKey_RightArrow") = static_cast(ImGuiKey_RightArrow); + e.value("ImGuiKey_UpArrow", ImGuiKey_UpArrow); m.attr("ImGuiKey_UpArrow") = static_cast(ImGuiKey_UpArrow); + e.value("ImGuiKey_DownArrow", ImGuiKey_DownArrow); m.attr("ImGuiKey_DownArrow") = static_cast(ImGuiKey_DownArrow); + e.value("ImGuiKey_PageUp", ImGuiKey_PageUp); m.attr("ImGuiKey_PageUp") = static_cast(ImGuiKey_PageUp); + e.value("ImGuiKey_PageDown", ImGuiKey_PageDown); m.attr("ImGuiKey_PageDown") = static_cast(ImGuiKey_PageDown); + e.value("ImGuiKey_Home", ImGuiKey_Home); m.attr("ImGuiKey_Home") = static_cast(ImGuiKey_Home); + e.value("ImGuiKey_End", ImGuiKey_End); m.attr("ImGuiKey_End") = static_cast(ImGuiKey_End); + e.value("ImGuiKey_Insert", ImGuiKey_Insert); m.attr("ImGuiKey_Insert") = static_cast(ImGuiKey_Insert); + e.value("ImGuiKey_Delete", ImGuiKey_Delete); m.attr("ImGuiKey_Delete") = static_cast(ImGuiKey_Delete); + e.value("ImGuiKey_Backspace", ImGuiKey_Backspace); m.attr("ImGuiKey_Backspace") = static_cast(ImGuiKey_Backspace); + e.value("ImGuiKey_Space", ImGuiKey_Space); m.attr("ImGuiKey_Space") = static_cast(ImGuiKey_Space); + e.value("ImGuiKey_Enter", ImGuiKey_Enter); m.attr("ImGuiKey_Enter") = static_cast(ImGuiKey_Enter); + e.value("ImGuiKey_Escape", ImGuiKey_Escape); m.attr("ImGuiKey_Escape") = static_cast(ImGuiKey_Escape); + e.value("ImGuiKey_LeftCtrl", ImGuiKey_LeftCtrl); m.attr("ImGuiKey_LeftCtrl") = static_cast(ImGuiKey_LeftCtrl); + e.value("ImGuiKey_LeftShift", ImGuiKey_LeftShift); m.attr("ImGuiKey_LeftShift") = static_cast(ImGuiKey_LeftShift); + e.value("ImGuiKey_LeftAlt", ImGuiKey_LeftAlt); m.attr("ImGuiKey_LeftAlt") = static_cast(ImGuiKey_LeftAlt); + e.value("ImGuiKey_LeftSuper", ImGuiKey_LeftSuper); m.attr("ImGuiKey_LeftSuper") = static_cast(ImGuiKey_LeftSuper); + e.value("ImGuiKey_RightCtrl", ImGuiKey_RightCtrl); m.attr("ImGuiKey_RightCtrl") = static_cast(ImGuiKey_RightCtrl); + e.value("ImGuiKey_RightShift", ImGuiKey_RightShift); m.attr("ImGuiKey_RightShift") = static_cast(ImGuiKey_RightShift); + e.value("ImGuiKey_RightAlt", ImGuiKey_RightAlt); m.attr("ImGuiKey_RightAlt") = static_cast(ImGuiKey_RightAlt); + e.value("ImGuiKey_RightSuper", ImGuiKey_RightSuper); m.attr("ImGuiKey_RightSuper") = static_cast(ImGuiKey_RightSuper); + e.value("ImGuiKey_Menu", ImGuiKey_Menu); m.attr("ImGuiKey_Menu") = static_cast(ImGuiKey_Menu); + e.value("ImGuiKey_0", ImGuiKey_0); m.attr("ImGuiKey_0") = static_cast(ImGuiKey_0); + e.value("ImGuiKey_1", ImGuiKey_1); m.attr("ImGuiKey_1") = static_cast(ImGuiKey_1); + e.value("ImGuiKey_2", ImGuiKey_2); m.attr("ImGuiKey_2") = static_cast(ImGuiKey_2); + e.value("ImGuiKey_3", ImGuiKey_3); m.attr("ImGuiKey_3") = static_cast(ImGuiKey_3); + e.value("ImGuiKey_4", ImGuiKey_4); m.attr("ImGuiKey_4") = static_cast(ImGuiKey_4); + e.value("ImGuiKey_5", ImGuiKey_5); m.attr("ImGuiKey_5") = static_cast(ImGuiKey_5); + e.value("ImGuiKey_6", ImGuiKey_6); m.attr("ImGuiKey_6") = static_cast(ImGuiKey_6); + e.value("ImGuiKey_7", ImGuiKey_7); m.attr("ImGuiKey_7") = static_cast(ImGuiKey_7); + e.value("ImGuiKey_8", ImGuiKey_8); m.attr("ImGuiKey_8") = static_cast(ImGuiKey_8); + e.value("ImGuiKey_9", ImGuiKey_9); m.attr("ImGuiKey_9") = static_cast(ImGuiKey_9); + e.value("ImGuiKey_A", ImGuiKey_A); m.attr("ImGuiKey_A") = static_cast(ImGuiKey_A); + e.value("ImGuiKey_B", ImGuiKey_B); m.attr("ImGuiKey_B") = static_cast(ImGuiKey_B); + e.value("ImGuiKey_C", ImGuiKey_C); m.attr("ImGuiKey_C") = static_cast(ImGuiKey_C); + e.value("ImGuiKey_D", ImGuiKey_D); m.attr("ImGuiKey_D") = static_cast(ImGuiKey_D); + e.value("ImGuiKey_E", ImGuiKey_E); m.attr("ImGuiKey_E") = static_cast(ImGuiKey_E); + e.value("ImGuiKey_F", ImGuiKey_F); m.attr("ImGuiKey_F") = static_cast(ImGuiKey_F); + e.value("ImGuiKey_G", ImGuiKey_G); m.attr("ImGuiKey_G") = static_cast(ImGuiKey_G); + e.value("ImGuiKey_H", ImGuiKey_H); m.attr("ImGuiKey_H") = static_cast(ImGuiKey_H); + e.value("ImGuiKey_I", ImGuiKey_I); m.attr("ImGuiKey_I") = static_cast(ImGuiKey_I); + e.value("ImGuiKey_J", ImGuiKey_J); m.attr("ImGuiKey_J") = static_cast(ImGuiKey_J); + e.value("ImGuiKey_K", ImGuiKey_K); m.attr("ImGuiKey_K") = static_cast(ImGuiKey_K); + e.value("ImGuiKey_L", ImGuiKey_L); m.attr("ImGuiKey_L") = static_cast(ImGuiKey_L); + e.value("ImGuiKey_M", ImGuiKey_M); m.attr("ImGuiKey_M") = static_cast(ImGuiKey_M); + e.value("ImGuiKey_N", ImGuiKey_N); m.attr("ImGuiKey_N") = static_cast(ImGuiKey_N); + e.value("ImGuiKey_O", ImGuiKey_O); m.attr("ImGuiKey_O") = static_cast(ImGuiKey_O); + e.value("ImGuiKey_P", ImGuiKey_P); m.attr("ImGuiKey_P") = static_cast(ImGuiKey_P); + e.value("ImGuiKey_Q", ImGuiKey_Q); m.attr("ImGuiKey_Q") = static_cast(ImGuiKey_Q); + e.value("ImGuiKey_R", ImGuiKey_R); m.attr("ImGuiKey_R") = static_cast(ImGuiKey_R); + e.value("ImGuiKey_S", ImGuiKey_S); m.attr("ImGuiKey_S") = static_cast(ImGuiKey_S); + e.value("ImGuiKey_T", ImGuiKey_T); m.attr("ImGuiKey_T") = static_cast(ImGuiKey_T); + e.value("ImGuiKey_U", ImGuiKey_U); m.attr("ImGuiKey_U") = static_cast(ImGuiKey_U); + e.value("ImGuiKey_V", ImGuiKey_V); m.attr("ImGuiKey_V") = static_cast(ImGuiKey_V); + e.value("ImGuiKey_W", ImGuiKey_W); m.attr("ImGuiKey_W") = static_cast(ImGuiKey_W); + e.value("ImGuiKey_X", ImGuiKey_X); m.attr("ImGuiKey_X") = static_cast(ImGuiKey_X); + e.value("ImGuiKey_Y", ImGuiKey_Y); m.attr("ImGuiKey_Y") = static_cast(ImGuiKey_Y); + e.value("ImGuiKey_Z", ImGuiKey_Z); m.attr("ImGuiKey_Z") = static_cast(ImGuiKey_Z); + e.value("ImGuiKey_F1", ImGuiKey_F1); m.attr("ImGuiKey_F1") = static_cast(ImGuiKey_F1); + e.value("ImGuiKey_F2", ImGuiKey_F2); m.attr("ImGuiKey_F2") = static_cast(ImGuiKey_F2); + e.value("ImGuiKey_F3", ImGuiKey_F3); m.attr("ImGuiKey_F3") = static_cast(ImGuiKey_F3); + e.value("ImGuiKey_F4", ImGuiKey_F4); m.attr("ImGuiKey_F4") = static_cast(ImGuiKey_F4); + e.value("ImGuiKey_F5", ImGuiKey_F5); m.attr("ImGuiKey_F5") = static_cast(ImGuiKey_F5); + e.value("ImGuiKey_F6", ImGuiKey_F6); m.attr("ImGuiKey_F6") = static_cast(ImGuiKey_F6); + e.value("ImGuiKey_F7", ImGuiKey_F7); m.attr("ImGuiKey_F7") = static_cast(ImGuiKey_F7); + e.value("ImGuiKey_F8", ImGuiKey_F8); m.attr("ImGuiKey_F8") = static_cast(ImGuiKey_F8); + e.value("ImGuiKey_F9", ImGuiKey_F9); m.attr("ImGuiKey_F9") = static_cast(ImGuiKey_F9); + e.value("ImGuiKey_F10", ImGuiKey_F10); m.attr("ImGuiKey_F10") = static_cast(ImGuiKey_F10); + e.value("ImGuiKey_F11", ImGuiKey_F11); m.attr("ImGuiKey_F11") = static_cast(ImGuiKey_F11); + e.value("ImGuiKey_F12", ImGuiKey_F12); m.attr("ImGuiKey_F12") = static_cast(ImGuiKey_F12); + e.value("ImGuiKey_F13", ImGuiKey_F13); m.attr("ImGuiKey_F13") = static_cast(ImGuiKey_F13); + e.value("ImGuiKey_F14", ImGuiKey_F14); m.attr("ImGuiKey_F14") = static_cast(ImGuiKey_F14); + e.value("ImGuiKey_F15", ImGuiKey_F15); m.attr("ImGuiKey_F15") = static_cast(ImGuiKey_F15); + e.value("ImGuiKey_F16", ImGuiKey_F16); m.attr("ImGuiKey_F16") = static_cast(ImGuiKey_F16); + e.value("ImGuiKey_F17", ImGuiKey_F17); m.attr("ImGuiKey_F17") = static_cast(ImGuiKey_F17); + e.value("ImGuiKey_F18", ImGuiKey_F18); m.attr("ImGuiKey_F18") = static_cast(ImGuiKey_F18); + e.value("ImGuiKey_F19", ImGuiKey_F19); m.attr("ImGuiKey_F19") = static_cast(ImGuiKey_F19); + e.value("ImGuiKey_F20", ImGuiKey_F20); m.attr("ImGuiKey_F20") = static_cast(ImGuiKey_F20); + e.value("ImGuiKey_F21", ImGuiKey_F21); m.attr("ImGuiKey_F21") = static_cast(ImGuiKey_F21); + e.value("ImGuiKey_F22", ImGuiKey_F22); m.attr("ImGuiKey_F22") = static_cast(ImGuiKey_F22); + e.value("ImGuiKey_F23", ImGuiKey_F23); m.attr("ImGuiKey_F23") = static_cast(ImGuiKey_F23); + e.value("ImGuiKey_F24", ImGuiKey_F24); m.attr("ImGuiKey_F24") = static_cast(ImGuiKey_F24); + e.value("ImGuiKey_Apostrophe", ImGuiKey_Apostrophe); m.attr("ImGuiKey_Apostrophe") = static_cast(ImGuiKey_Apostrophe); + e.value("ImGuiKey_Comma", ImGuiKey_Comma); m.attr("ImGuiKey_Comma") = static_cast(ImGuiKey_Comma); + e.value("ImGuiKey_Minus", ImGuiKey_Minus); m.attr("ImGuiKey_Minus") = static_cast(ImGuiKey_Minus); + e.value("ImGuiKey_Period", ImGuiKey_Period); m.attr("ImGuiKey_Period") = static_cast(ImGuiKey_Period); + e.value("ImGuiKey_Slash", ImGuiKey_Slash); m.attr("ImGuiKey_Slash") = static_cast(ImGuiKey_Slash); + e.value("ImGuiKey_Semicolon", ImGuiKey_Semicolon); m.attr("ImGuiKey_Semicolon") = static_cast(ImGuiKey_Semicolon); + e.value("ImGuiKey_Equal", ImGuiKey_Equal); m.attr("ImGuiKey_Equal") = static_cast(ImGuiKey_Equal); + e.value("ImGuiKey_LeftBracket", ImGuiKey_LeftBracket); m.attr("ImGuiKey_LeftBracket") = static_cast(ImGuiKey_LeftBracket); + e.value("ImGuiKey_Backslash", ImGuiKey_Backslash); m.attr("ImGuiKey_Backslash") = static_cast(ImGuiKey_Backslash); + e.value("ImGuiKey_RightBracket", ImGuiKey_RightBracket); m.attr("ImGuiKey_RightBracket") = static_cast(ImGuiKey_RightBracket); + e.value("ImGuiKey_GraveAccent", ImGuiKey_GraveAccent); m.attr("ImGuiKey_GraveAccent") = static_cast(ImGuiKey_GraveAccent); + e.value("ImGuiKey_CapsLock", ImGuiKey_CapsLock); m.attr("ImGuiKey_CapsLock") = static_cast(ImGuiKey_CapsLock); + e.value("ImGuiKey_ScrollLock", ImGuiKey_ScrollLock); m.attr("ImGuiKey_ScrollLock") = static_cast(ImGuiKey_ScrollLock); + e.value("ImGuiKey_NumLock", ImGuiKey_NumLock); m.attr("ImGuiKey_NumLock") = static_cast(ImGuiKey_NumLock); + e.value("ImGuiKey_PrintScreen", ImGuiKey_PrintScreen); m.attr("ImGuiKey_PrintScreen") = static_cast(ImGuiKey_PrintScreen); + e.value("ImGuiKey_Pause", ImGuiKey_Pause); m.attr("ImGuiKey_Pause") = static_cast(ImGuiKey_Pause); + e.value("ImGuiKey_Keypad0", ImGuiKey_Keypad0); m.attr("ImGuiKey_Keypad0") = static_cast(ImGuiKey_Keypad0); + e.value("ImGuiKey_Keypad1", ImGuiKey_Keypad1); m.attr("ImGuiKey_Keypad1") = static_cast(ImGuiKey_Keypad1); + e.value("ImGuiKey_Keypad2", ImGuiKey_Keypad2); m.attr("ImGuiKey_Keypad2") = static_cast(ImGuiKey_Keypad2); + e.value("ImGuiKey_Keypad3", ImGuiKey_Keypad3); m.attr("ImGuiKey_Keypad3") = static_cast(ImGuiKey_Keypad3); + e.value("ImGuiKey_Keypad4", ImGuiKey_Keypad4); m.attr("ImGuiKey_Keypad4") = static_cast(ImGuiKey_Keypad4); + e.value("ImGuiKey_Keypad5", ImGuiKey_Keypad5); m.attr("ImGuiKey_Keypad5") = static_cast(ImGuiKey_Keypad5); + e.value("ImGuiKey_Keypad6", ImGuiKey_Keypad6); m.attr("ImGuiKey_Keypad6") = static_cast(ImGuiKey_Keypad6); + e.value("ImGuiKey_Keypad7", ImGuiKey_Keypad7); m.attr("ImGuiKey_Keypad7") = static_cast(ImGuiKey_Keypad7); + e.value("ImGuiKey_Keypad8", ImGuiKey_Keypad8); m.attr("ImGuiKey_Keypad8") = static_cast(ImGuiKey_Keypad8); + e.value("ImGuiKey_Keypad9", ImGuiKey_Keypad9); m.attr("ImGuiKey_Keypad9") = static_cast(ImGuiKey_Keypad9); + e.value("ImGuiKey_KeypadDecimal", ImGuiKey_KeypadDecimal); m.attr("ImGuiKey_KeypadDecimal") = static_cast(ImGuiKey_KeypadDecimal); + e.value("ImGuiKey_KeypadDivide", ImGuiKey_KeypadDivide); m.attr("ImGuiKey_KeypadDivide") = static_cast(ImGuiKey_KeypadDivide); + e.value("ImGuiKey_KeypadMultiply", ImGuiKey_KeypadMultiply); m.attr("ImGuiKey_KeypadMultiply") = static_cast(ImGuiKey_KeypadMultiply); + e.value("ImGuiKey_KeypadSubtract", ImGuiKey_KeypadSubtract); m.attr("ImGuiKey_KeypadSubtract") = static_cast(ImGuiKey_KeypadSubtract); + e.value("ImGuiKey_KeypadAdd", ImGuiKey_KeypadAdd); m.attr("ImGuiKey_KeypadAdd") = static_cast(ImGuiKey_KeypadAdd); + e.value("ImGuiKey_KeypadEnter", ImGuiKey_KeypadEnter); m.attr("ImGuiKey_KeypadEnter") = static_cast(ImGuiKey_KeypadEnter); + e.value("ImGuiKey_KeypadEqual", ImGuiKey_KeypadEqual); m.attr("ImGuiKey_KeypadEqual") = static_cast(ImGuiKey_KeypadEqual); + e.value("ImGuiKey_AppBack", ImGuiKey_AppBack); m.attr("ImGuiKey_AppBack") = static_cast(ImGuiKey_AppBack); + e.value("ImGuiKey_AppForward", ImGuiKey_AppForward); m.attr("ImGuiKey_AppForward") = static_cast(ImGuiKey_AppForward); + e.value("ImGuiKey_GamepadStart", ImGuiKey_GamepadStart); m.attr("ImGuiKey_GamepadStart") = static_cast(ImGuiKey_GamepadStart); + e.value("ImGuiKey_GamepadBack", ImGuiKey_GamepadBack); m.attr("ImGuiKey_GamepadBack") = static_cast(ImGuiKey_GamepadBack); + e.value("ImGuiKey_GamepadFaceUp", ImGuiKey_GamepadFaceUp); m.attr("ImGuiKey_GamepadFaceUp") = static_cast(ImGuiKey_GamepadFaceUp); + e.value("ImGuiKey_GamepadFaceDown", ImGuiKey_GamepadFaceDown); m.attr("ImGuiKey_GamepadFaceDown") = static_cast(ImGuiKey_GamepadFaceDown); + e.value("ImGuiKey_GamepadFaceLeft", ImGuiKey_GamepadFaceLeft); m.attr("ImGuiKey_GamepadFaceLeft") = static_cast(ImGuiKey_GamepadFaceLeft); + e.value("ImGuiKey_GamepadFaceRight", ImGuiKey_GamepadFaceRight); m.attr("ImGuiKey_GamepadFaceRight") = static_cast(ImGuiKey_GamepadFaceRight); + e.value("ImGuiKey_GamepadDpadUp", ImGuiKey_GamepadDpadUp); m.attr("ImGuiKey_GamepadDpadUp") = static_cast(ImGuiKey_GamepadDpadUp); + e.value("ImGuiKey_GamepadDpadDown", ImGuiKey_GamepadDpadDown); m.attr("ImGuiKey_GamepadDpadDown") = static_cast(ImGuiKey_GamepadDpadDown); + e.value("ImGuiKey_GamepadDpadLeft", ImGuiKey_GamepadDpadLeft); m.attr("ImGuiKey_GamepadDpadLeft") = static_cast(ImGuiKey_GamepadDpadLeft); + e.value("ImGuiKey_GamepadDpadRight", ImGuiKey_GamepadDpadRight); m.attr("ImGuiKey_GamepadDpadRight") = static_cast(ImGuiKey_GamepadDpadRight); + e.value("ImGuiKey_GamepadL1", ImGuiKey_GamepadL1); m.attr("ImGuiKey_GamepadL1") = static_cast(ImGuiKey_GamepadL1); + e.value("ImGuiKey_GamepadR1", ImGuiKey_GamepadR1); m.attr("ImGuiKey_GamepadR1") = static_cast(ImGuiKey_GamepadR1); + e.value("ImGuiKey_GamepadL2", ImGuiKey_GamepadL2); m.attr("ImGuiKey_GamepadL2") = static_cast(ImGuiKey_GamepadL2); + e.value("ImGuiKey_GamepadR2", ImGuiKey_GamepadR2); m.attr("ImGuiKey_GamepadR2") = static_cast(ImGuiKey_GamepadR2); + e.value("ImGuiKey_GamepadL3", ImGuiKey_GamepadL3); m.attr("ImGuiKey_GamepadL3") = static_cast(ImGuiKey_GamepadL3); + e.value("ImGuiKey_GamepadR3", ImGuiKey_GamepadR3); m.attr("ImGuiKey_GamepadR3") = static_cast(ImGuiKey_GamepadR3); + e.value("ImGuiKey_GamepadLStickUp", ImGuiKey_GamepadLStickUp); m.attr("ImGuiKey_GamepadLStickUp") = static_cast(ImGuiKey_GamepadLStickUp); + e.value("ImGuiKey_GamepadLStickDown", ImGuiKey_GamepadLStickDown); m.attr("ImGuiKey_GamepadLStickDown") = static_cast(ImGuiKey_GamepadLStickDown); + e.value("ImGuiKey_GamepadLStickLeft", ImGuiKey_GamepadLStickLeft); m.attr("ImGuiKey_GamepadLStickLeft") = static_cast(ImGuiKey_GamepadLStickLeft); + e.value("ImGuiKey_GamepadLStickRight", ImGuiKey_GamepadLStickRight); m.attr("ImGuiKey_GamepadLStickRight") = static_cast(ImGuiKey_GamepadLStickRight); + e.value("ImGuiKey_GamepadRStickUp", ImGuiKey_GamepadRStickUp); m.attr("ImGuiKey_GamepadRStickUp") = static_cast(ImGuiKey_GamepadRStickUp); + e.value("ImGuiKey_GamepadRStickDown", ImGuiKey_GamepadRStickDown); m.attr("ImGuiKey_GamepadRStickDown") = static_cast(ImGuiKey_GamepadRStickDown); + e.value("ImGuiKey_GamepadRStickLeft", ImGuiKey_GamepadRStickLeft); m.attr("ImGuiKey_GamepadRStickLeft") = static_cast(ImGuiKey_GamepadRStickLeft); + e.value("ImGuiKey_GamepadRStickRight", ImGuiKey_GamepadRStickRight); m.attr("ImGuiKey_GamepadRStickRight") = static_cast(ImGuiKey_GamepadRStickRight); + e.value("ImGuiMod_None", ImGuiMod_None); m.attr("ImGuiMod_None") = static_cast(ImGuiMod_None); + e.value("ImGuiMod_Ctrl", ImGuiMod_Ctrl); m.attr("ImGuiMod_Ctrl") = static_cast(ImGuiMod_Ctrl); + e.value("ImGuiMod_Shift", ImGuiMod_Shift); m.attr("ImGuiMod_Shift") = static_cast(ImGuiMod_Shift); + e.value("ImGuiMod_Alt", ImGuiMod_Alt); m.attr("ImGuiMod_Alt") = static_cast(ImGuiMod_Alt); + e.value("ImGuiMod_Super", ImGuiMod_Super); m.attr("ImGuiMod_Super") = static_cast(ImGuiMod_Super); + e.value("ImGuiMod_Mask_", ImGuiMod_Mask_); m.attr("ImGuiMod_Mask_") = static_cast(ImGuiMod_Mask_); + ; + } + + { // ImTextureFormat + auto e = nb::enum_(m, "ImTextureFormat"); + e.value("ImTextureFormat_RGBA32", ImTextureFormat_RGBA32); m.attr("ImTextureFormat_RGBA32") = static_cast(ImTextureFormat_RGBA32); + e.value("ImTextureFormat_Alpha8", ImTextureFormat_Alpha8); m.attr("ImTextureFormat_Alpha8") = static_cast(ImTextureFormat_Alpha8); + ; + } + + { // ImTextureStatus + auto e = nb::enum_(m, "ImTextureStatus"); + e.value("ImTextureStatus_OK", ImTextureStatus_OK); m.attr("ImTextureStatus_OK") = static_cast(ImTextureStatus_OK); + e.value("ImTextureStatus_Destroyed", ImTextureStatus_Destroyed); m.attr("ImTextureStatus_Destroyed") = static_cast(ImTextureStatus_Destroyed); + e.value("ImTextureStatus_WantCreate", ImTextureStatus_WantCreate); m.attr("ImTextureStatus_WantCreate") = static_cast(ImTextureStatus_WantCreate); + e.value("ImTextureStatus_WantUpdates", ImTextureStatus_WantUpdates); m.attr("ImTextureStatus_WantUpdates") = static_cast(ImTextureStatus_WantUpdates); + e.value("ImTextureStatus_WantDestroy", ImTextureStatus_WantDestroy); m.attr("ImTextureStatus_WantDestroy") = static_cast(ImTextureStatus_WantDestroy); + ; + } + + { // ImFontAtlasFlags ImFontAtlasFlags_ + auto e = nb::enum_(m, "ImFontAtlasFlags"); + e.value("ImFontAtlasFlags_None", ImFontAtlasFlags_None); m.attr("ImFontAtlasFlags_None") = static_cast(ImFontAtlasFlags_None); + e.value("ImFontAtlasFlags_NoPowerOfTwoHeight", ImFontAtlasFlags_NoPowerOfTwoHeight); m.attr("ImFontAtlasFlags_NoPowerOfTwoHeight") = static_cast(ImFontAtlasFlags_NoPowerOfTwoHeight); + e.value("ImFontAtlasFlags_NoMouseCursors", ImFontAtlasFlags_NoMouseCursors); m.attr("ImFontAtlasFlags_NoMouseCursors") = static_cast(ImFontAtlasFlags_NoMouseCursors); + e.value("ImFontAtlasFlags_NoBakedLines", ImFontAtlasFlags_NoBakedLines); m.attr("ImFontAtlasFlags_NoBakedLines") = static_cast(ImFontAtlasFlags_NoBakedLines); + ; + } + + { // ImFontFlags ImFontFlags_ + auto e = nb::enum_(m, "ImFontFlags"); + e.value("ImFontFlags_None", ImFontFlags_None); m.attr("ImFontFlags_None") = static_cast(ImFontFlags_None); + e.value("ImFontFlags_NoLoadError", ImFontFlags_NoLoadError); m.attr("ImFontFlags_NoLoadError") = static_cast(ImFontFlags_NoLoadError); + e.value("ImFontFlags_NoLoadGlyphs", ImFontFlags_NoLoadGlyphs); m.attr("ImFontFlags_NoLoadGlyphs") = static_cast(ImFontFlags_NoLoadGlyphs); + e.value("ImFontFlags_LockBakedSizes", ImFontFlags_LockBakedSizes); m.attr("ImFontFlags_LockBakedSizes") = static_cast(ImFontFlags_LockBakedSizes); + ; + } + + { // ImGuiViewportFlags ImGuiViewportFlags_ + auto e = nb::enum_(m, "ImGuiViewportFlags"); + e.value("ImGuiViewportFlags_None", ImGuiViewportFlags_None); m.attr("ImGuiViewportFlags_None") = static_cast(ImGuiViewportFlags_None); + e.value("ImGuiViewportFlags_IsPlatformWindow", ImGuiViewportFlags_IsPlatformWindow); m.attr("ImGuiViewportFlags_IsPlatformWindow") = static_cast(ImGuiViewportFlags_IsPlatformWindow); + e.value("ImGuiViewportFlags_IsPlatformMonitor", ImGuiViewportFlags_IsPlatformMonitor); m.attr("ImGuiViewportFlags_IsPlatformMonitor") = static_cast(ImGuiViewportFlags_IsPlatformMonitor); + e.value("ImGuiViewportFlags_OwnedByApp", ImGuiViewportFlags_OwnedByApp); m.attr("ImGuiViewportFlags_OwnedByApp") = static_cast(ImGuiViewportFlags_OwnedByApp); + ; + } +} diff --git a/src/cpp/imgui/imgui_macros.cpp b/src/cpp/imgui/imgui_macros.cpp new file mode 100644 index 0000000..38401b2 --- /dev/null +++ b/src/cpp/imgui/imgui_macros.cpp @@ -0,0 +1,19 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include +#include +#include + +// clang-format off +void bind_imgui_macros(nb::module_& m) { + + m.def("IM_COL32", [](uint8_t R, uint8_t G, uint8_t B, uint8_t A) { return IM_COL32(R,G,B,A); }); + +} +// clang-format on diff --git a/src/cpp/imgui/imgui_obsolete.cpp b/src/cpp/imgui/imgui_obsolete.cpp new file mode 100644 index 0000000..c719fe5 --- /dev/null +++ b/src/cpp/imgui/imgui_obsolete.cpp @@ -0,0 +1,41 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include + +// clang-format off +void bind_imgui_obsolete(nb::module_& m) { + + // OBSOLETED in 1.91.9 (from February 2025) + // IMGUI_API void Image(ImTextureID user_texture_id, const ImVec2& image_size, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& tint_col, const ImVec4& border_col); + // TODO + + // OBSOLETED in 1.91.0 (from July 2024) + + // static inline void PushButtonRepeat(bool repeat) + // TODO + // static inline void PopButtonRepeat() + // TODO + // static inline void PushTabStop(bool tab_stop) + // TODO + // static inline void PopTabStop() + + // IMGUI_API ImVec2 GetContentRegionMax(); + m.def("GetContentRegionMax", []() { + return from_vec2(ImGui::GetContentRegionMax()); }); + + // IMGUI_API ImVec2 GetWindowContentRegionMin(); + m.def("GetWindowContentRegionMin", []() { + return from_vec2(ImGui::GetWindowContentRegionMin()); }); + + // IMGUI_API ImVec2 GetWindowContentRegionMax(); + m.def("GetWindowContentRegionMax", []() { + return from_vec2(ImGui::GetWindowContentRegionMax()); }); + +} +// clang-format on diff --git a/src/cpp/imgui/imgui_structs.cpp b/src/cpp/imgui/imgui_structs.cpp new file mode 100644 index 0000000..5c7ec26 --- /dev/null +++ b/src/cpp/imgui/imgui_structs.cpp @@ -0,0 +1,86 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +#include + + +// clang-format off +void bind_imgui_structs(nb::module_& m) { + + // NOTE: opaque structs like ImGuiContext are not bound here. + // We pass them using nb::capsule, see + // imgui_api_context_creation.cpp for an example. + + // ImTextureRef + nb::class_(m, "ImTextureRef") + .def(nb::init<>()) + .def(nb::init(), nb::arg("tex_id")) + .def(nb::init(), nb::arg("tex_ptr")) + .def("GetTexID", &ImTextureRef::GetTexID) + ; + + // Table sorting + nb::class_(m, "ImGuiTableSortSpecs") + .def("Specs", [](ImGuiTableSortSpecs& o) { + std::vector specs; + for (int i = 0; i < o.SpecsCount; i++) { + specs.push_back(o.Specs[i]); + } + return specs;} + ) + .def_ro("SpecsCount", &ImGuiTableSortSpecs::SpecsCount) + .def_rw("SpecsDirty", &ImGuiTableSortSpecs::SpecsDirty) + ; + + nb::class_(m, "ImGuiTableColumnSortSpecs") + .def_ro("ColumnUserID", &ImGuiTableColumnSortSpecs::ColumnUserID) + .def_ro("ColumnIndex", &ImGuiTableColumnSortSpecs::ColumnIndex) + .def_ro("SortOrder", &ImGuiTableColumnSortSpecs::SortOrder) + .def_ro("SortDirection", &ImGuiTableColumnSortSpecs::SortDirection) + ; + + // Drag and drop payload + nb::class_(m, "ImGuiPayload") + .def_ro("DataSize", &ImGuiPayload::DataSize) + .def("IsDataType", &ImGuiPayload::IsDataType, nb::arg("type")) + .def("IsPreview", &ImGuiPayload::IsPreview) + .def("IsDelivery", &ImGuiPayload::IsDelivery) + // Note: Data field not bound (void* pointer) + ; + + // Draw data + nb::class_(m, "ImDrawData") + .def_ro("Valid", &ImDrawData::Valid) + .def_ro("CmdListsCount", &ImDrawData::CmdListsCount) + .def_ro("TotalIdxCount", &ImDrawData::TotalIdxCount) + .def_ro("TotalVtxCount", &ImDrawData::TotalVtxCount) + .def_prop_ro("DisplayPos", [](const ImDrawData& o) { return from_vec2(o.DisplayPos); }) + .def_prop_ro("DisplaySize", [](const ImDrawData& o) { return from_vec2(o.DisplaySize); }) + .def_prop_ro("FramebufferScale", [](const ImDrawData& o) { return from_vec2(o.FramebufferScale); }) + .def("ScaleClipRects", [](ImDrawData& o, const Vec2T& fb_scale) { + o.ScaleClipRects(to_vec2(fb_scale)); + }, nb::arg("fb_scale")) + // Note: CmdLists and OwnerViewport not bound (internal pointers) + ; + + // Viewport + nb::class_(m, "ImGuiViewport") + .def_ro("ID", &ImGuiViewport::ID) + .def_ro("Flags", &ImGuiViewport::Flags) + .def_prop_ro("Pos", [](const ImGuiViewport& o) { return from_vec2(o.Pos); }) + .def_prop_ro("Size", [](const ImGuiViewport& o) { return from_vec2(o.Size); }) + .def_prop_ro("WorkPos", [](const ImGuiViewport& o) { return from_vec2(o.WorkPos); }) + .def_prop_ro("WorkSize", [](const ImGuiViewport& o) { return from_vec2(o.WorkSize); }) + .def("GetCenter", [](const ImGuiViewport& o) { return from_vec2(o.GetCenter()); }) + .def("GetWorkCenter", [](const ImGuiViewport& o) { return from_vec2(o.GetWorkCenter()); }) + // Note: PlatformHandle and PlatformHandleRaw not bound (void* pointers) + ; + +} + +// clang-format on \ No newline at end of file diff --git a/src/cpp/imgui/imgui_structs_drawlist.cpp b/src/cpp/imgui/imgui_structs_drawlist.cpp new file mode 100644 index 0000000..7ef2dc2 --- /dev/null +++ b/src/cpp/imgui/imgui_structs_drawlist.cpp @@ -0,0 +1,412 @@ +// ImDrawList struct bindings + +#include "imgui_utils.h" +#include + +// clang-format off + +void bind_imgui_drawlist(nb::module_& m) { + + nb::class_(m, "ImDrawList") + + // Clip Rect + .def( + "PushClipRect", + [](ImDrawList& self, const Vec2T& clip_rect_min, const Vec2T& clip_rect_max, bool intersect_with_current_clip_rect) { + self.PushClipRect(to_vec2(clip_rect_min), to_vec2(clip_rect_max), intersect_with_current_clip_rect); + }, + nb::arg("clip_rect_min"), + nb::arg("clip_rect_max"), + nb::arg("intersect_with_current_clip_rect") = false + ) + .def("PushClipRectFullScreen", &ImDrawList::PushClipRectFullScreen) + .def("PopClipRect", &ImDrawList::PopClipRect) + .def("GetClipRectMin", [](ImDrawList& self) { return from_vec2(self.GetClipRectMin()); }) + .def("GetClipRectMax", [](ImDrawList& self) { return from_vec2(self.GetClipRectMax()); }) + + // Primitives - Lines and Shapes + .def( + "AddLine", + [](ImDrawList& draw_list, const Vec2T& p1, const Vec2T& p2, ImU32 col, float thickness) { + draw_list.AddLine(to_vec2(p1), to_vec2(p2), col, thickness); + }, + nb::arg("p1"), + nb::arg("p2"), + nb::arg("col"), + nb::arg("thickness") = 1.0f + ) + .def( + "AddRect", + [](ImDrawList& self, const Vec2T& p_min, const Vec2T& p_max, ImU32 col, float rounding, ImDrawFlags flags, float thickness) { + self.AddRect(to_vec2(p_min), to_vec2(p_max), col, rounding, flags, thickness); + }, + nb::arg("p_min"), + nb::arg("p_max"), + nb::arg("col"), + nb::arg("rounding") = 0.0f, + nb::arg("flags") = 0, + nb::arg("thickness") = 1.0f + ) + .def( + "AddRectFilled", + [](ImDrawList& self, const Vec2T& p_min, const Vec2T& p_max, ImU32 col, float rounding, ImDrawFlags flags) { + self.AddRectFilled(to_vec2(p_min), to_vec2(p_max), col, rounding, flags); + }, + nb::arg("p_min"), + nb::arg("p_max"), + nb::arg("col"), + nb::arg("rounding") = 0.0f, + nb::arg("flags") = 0 + ) + .def( + "AddRectFilledMultiColor", + [](ImDrawList& self, const Vec2T& p_min, const Vec2T& p_max, ImU32 col_upr_left, ImU32 col_upr_right, ImU32 col_bot_right, ImU32 col_bot_left) { + self.AddRectFilledMultiColor(to_vec2(p_min), to_vec2(p_max), col_upr_left, col_upr_right, col_bot_right, col_bot_left); + }, + nb::arg("p_min"), + nb::arg("p_max"), + nb::arg("col_upr_left"), + nb::arg("col_upr_right"), + nb::arg("col_bot_right"), + nb::arg("col_bot_left") + ) + .def( + "AddQuad", + [](ImDrawList& self, const Vec2T& p1, const Vec2T& p2, const Vec2T& p3, const Vec2T& p4, ImU32 col, float thickness) { + self.AddQuad(to_vec2(p1), to_vec2(p2), to_vec2(p3), to_vec2(p4), col, thickness); + }, + nb::arg("p1"), + nb::arg("p2"), + nb::arg("p3"), + nb::arg("p4"), + nb::arg("col"), + nb::arg("thickness") = 1.0f + ) + .def( + "AddQuadFilled", + [](ImDrawList& self, const Vec2T& p1, const Vec2T& p2, const Vec2T& p3, const Vec2T& p4, ImU32 col) { + self.AddQuadFilled(to_vec2(p1), to_vec2(p2), to_vec2(p3), to_vec2(p4), col); + }, + nb::arg("p1"), + nb::arg("p2"), + nb::arg("p3"), + nb::arg("p4"), + nb::arg("col") + ) + .def( + "AddTriangle", + [](ImDrawList& self, const Vec2T& p1, const Vec2T& p2, const Vec2T& p3, ImU32 col, float thickness) { + self.AddTriangle(to_vec2(p1), to_vec2(p2), to_vec2(p3), col, thickness); + }, + nb::arg("p1"), + nb::arg("p2"), + nb::arg("p3"), + nb::arg("col"), + nb::arg("thickness") = 1.0f + ) + .def( + "AddTriangleFilled", + [](ImDrawList& self, const Vec2T& p1, const Vec2T& p2, const Vec2T& p3, ImU32 col) { + self.AddTriangleFilled(to_vec2(p1), to_vec2(p2), to_vec2(p3), col); + }, + nb::arg("p1"), + nb::arg("p2"), + nb::arg("p3"), + nb::arg("col") + ) + .def( + "AddCircle", + [](ImDrawList& self, const Vec2T& center, const float radius, ImU32 col, int num_segments, float thickness) { + self.AddCircle(to_vec2(center), radius, col, num_segments, thickness); + }, + nb::arg("center"), + nb::arg("radius"), + nb::arg("col"), + nb::arg("num_segments") = 0, + nb::arg("thickness") = 1.0f + ) + .def( + "AddCircleFilled", + [](ImDrawList& self, const Vec2T& center, const float radius, ImU32 col, int num_segments) { + self.AddCircleFilled(to_vec2(center), radius, col, num_segments); + }, + nb::arg("center"), + nb::arg("radius"), + nb::arg("col"), + nb::arg("num_segments") = 0 + ) + .def( + "AddNgon", + [](ImDrawList& self, const Vec2T& center, const float radius, ImU32 col, int num_segments, float thickness) { + self.AddNgon(to_vec2(center), radius, col, num_segments, thickness); + }, + nb::arg("center"), + nb::arg("radius"), + nb::arg("col"), + nb::arg("num_segments"), + nb::arg("thickness") = 1.0f + ) + .def( + "AddNgonFilled", + [](ImDrawList& self, const Vec2T& center, const float radius, ImU32 col, int num_segments) { + self.AddNgonFilled(to_vec2(center), radius, col, num_segments); + }, + nb::arg("center"), + nb::arg("radius"), + nb::arg("col"), + nb::arg("num_segments") + ) + .def( + "AddEllipse", + [](ImDrawList& self, const Vec2T& center, const Vec2T& radius, ImU32 col, float rot, int num_segments, float thickness) { + self.AddEllipse(to_vec2(center), to_vec2(radius), col, rot, num_segments, thickness); + }, + nb::arg("center"), + nb::arg("radius"), + nb::arg("col"), + nb::arg("rot") = 0.0f, + nb::arg("num_segments") = 0, + nb::arg("thickness") = 1.0f + ) + .def( + "AddEllipseFilled", + [](ImDrawList& self, const Vec2T& center, const Vec2T& radius, ImU32 col, float rot, int num_segments) { + self.AddEllipseFilled(to_vec2(center), to_vec2(radius), col, rot, num_segments); + }, + nb::arg("center"), + nb::arg("radius"), + nb::arg("col"), + nb::arg("rot") = 0.0f, + nb::arg("num_segments") = 0 + ) + + // Text + .def( + "AddText", + [](ImDrawList& self, const Vec2T& pos, ImU32 col, std::string text) { + self.AddText(to_vec2(pos), col, text.c_str()); + }, + nb::arg("pos"), + nb::arg("col"), + nb::arg("text") + ) + + .def( + "AddText", + [](ImDrawList& self, ImFont* font, float font_size, const Vec2T& pos, ImU32 col, std::string text, float wrap_width) { + self.AddText(font, font_size, to_vec2(pos), col, text.c_str(), nullptr, wrap_width); + }, + nb::arg("font"), + nb::arg("font_size"), + nb::arg("pos"), + nb::arg("col"), + nb::arg("text_begin"), + nb::arg("wrap_width") = 0.0f + ) + + // Bezier curves + .def( + "AddBezierCubic", + [](ImDrawList& self, const Vec2T& p1, const Vec2T& p2, const Vec2T& p3, const Vec2T& p4, ImU32 col, float thickness, int num_segments) { + self.AddBezierCubic(to_vec2(p1), to_vec2(p2), to_vec2(p3), to_vec2(p4), col, thickness, num_segments); + }, + nb::arg("p1"), + nb::arg("p2"), + nb::arg("p3"), + nb::arg("p4"), + nb::arg("col"), + nb::arg("thickness"), + nb::arg("num_segments") = 0 + ) + .def( + "AddBezierQuadratic", + [](ImDrawList& self, const Vec2T& p1, const Vec2T& p2, const Vec2T& p3, ImU32 col, float thickness, int num_segments) { + self.AddBezierQuadratic(to_vec2(p1), to_vec2(p2), to_vec2(p3), col, thickness, num_segments); + }, + nb::arg("p1"), + nb::arg("p2"), + nb::arg("p3"), + nb::arg("col"), + nb::arg("thickness"), + nb::arg("num_segments") = 0 + ) + + // General Polygon + .def( + "AddPolyline", + [](ImDrawList& self, const Eigen::MatrixXf& points, ImU32 col, ImDrawFlags flags, float thickness) { + if(points.cols() != 2) throw std::runtime_error("Points array must have shape (N, 2)"); + std::vector points_vec2(points.rows()); + for (size_t i = 0; i < points.rows(); i++) { + points_vec2[i] = {points(i, 0), points(i, 1)}; + } + self.AddPolyline(points_vec2.data(), static_cast(points.rows()), col, flags, thickness); + }, + nb::arg("points"), + nb::arg("col"), + nb::arg("flags"), + nb::arg("thickness") + ) + .def( + "AddConvexPolyFilled", + [](ImDrawList& self, const Eigen::MatrixXf& points, ImU32 col) { + if(points.cols() != 2) throw std::runtime_error("Points array must have shape (N, 2)"); + std::vector points_vec2(points.rows()); + for (size_t i = 0; i < points.rows(); i++) { + points_vec2[i] = {points(i, 0), points(i, 1)}; + } + self.AddConvexPolyFilled(points_vec2.data(), static_cast(points.size()), col); + }, + nb::arg("points"), + nb::arg("col") + ) + .def( + "AddConcavePolyFilled", + [](ImDrawList& self, const Eigen::MatrixXf& points, ImU32 col) { + if(points.cols() != 2) throw std::runtime_error("Points array must have shape (N, 2)"); + std::vector points_vec2(points.rows()); + for (size_t i = 0; i < points.rows(); i++) { + points_vec2[i] = {points(i, 0), points(i, 1)}; + } + self.AddConcavePolyFilled(points_vec2.data(), static_cast(points.size()), col); + }, + nb::arg("points"), + nb::arg("col") + ) + + // Image primitives + // IMGUI_API void AddImage(ImTextureRef tex_ref, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min = ImVec2(0, 0), const ImVec2& uv_max = ImVec2(1, 1), ImU32 col = IM_COL32_WHITE); + .def( + "AddImage", + [](ImDrawList& self, ImTextureRef tex_ref, const Vec2T& p_min, const Vec2T& p_max, const Vec2T& uv_min, const Vec2T& uv_max, ImU32 col) { + self.AddImage(tex_ref, to_vec2(p_min), to_vec2(p_max), to_vec2(uv_min), to_vec2(uv_max), col); + }, + nb::arg("user_texture_ref"), + nb::arg("p_min"), + nb::arg("p_max"), + nb::arg("uv_min") = Vec2T{0, 0}, + nb::arg("uv_max") = Vec2T{1, 1}, + nb::arg("col") = IM_COL32_WHITE + ) + // IMGUI_API void AddImageQuad(ImTextureRef tex_ref, const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& uv1 = ImVec2(0, 0), const ImVec2& uv2 = ImVec2(1, 0), const ImVec2& uv3 = ImVec2(1, 1), const ImVec2& uv4 = ImVec2(0, 1), ImU32 col = IM_COL32_WHITE); + .def( + "AddImageQuad", + [](ImDrawList& self, ImTextureRef tex_ref, const Vec2T& p1, const Vec2T& p2, const Vec2T& p3, const Vec2T& p4, const Vec2T& uv1, const Vec2T& uv2, const Vec2T& uv3, const Vec2T& uv4, ImU32 col) { + self.AddImageQuad(tex_ref, to_vec2(p1), to_vec2(p2), to_vec2(p3), to_vec2(p4), to_vec2(uv1), to_vec2(uv2), to_vec2(uv3), to_vec2(uv4), col); + }, + nb::arg("user_texture_ref"), + nb::arg("p1"), + nb::arg("p2"), + nb::arg("p3"), + nb::arg("p4"), + nb::arg("uv1") = Vec2T{0, 0}, + nb::arg("uv2") = Vec2T{1, 0}, + nb::arg("uv3") = Vec2T{1, 1}, + nb::arg("uv4") = Vec2T{0, 1}, + nb::arg("col") = IM_COL32_WHITE + ) + // IMGUI_API void AddImageRounded(ImTextureRef tex_ref, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min, const ImVec2& uv_max, ImU32 col, float rounding, ImDrawFlags flags = 0); + .def( + "AddImageRounded", + [](ImDrawList& self, ImTextureRef tex_ref, const Vec2T& p_min, const Vec2T& p_max, const Vec2T& uv_min, const Vec2T& uv_max, ImU32 col, float rounding, ImDrawFlags flags) { + self.AddImageRounded(tex_ref, to_vec2(p_min), to_vec2(p_max), to_vec2(uv_min), to_vec2(uv_max), col, rounding, flags); + }, + nb::arg("user_texture_ref"), + nb::arg("p_min"), + nb::arg("p_max"), + nb::arg("uv_min"), + nb::arg("uv_max"), + nb::arg("col"), + nb::arg("rounding"), + nb::arg("flags") = 0 + ) + + // Stateful path API + .def("PathClear", [](ImDrawList& self) { self.PathClear(); }) + .def("PathLineTo", [](ImDrawList& self, const Vec2T& pos) { self.PathLineTo(to_vec2(pos)); }, nb::arg("pos")) + .def("PathLineToMergeDuplicate", [](ImDrawList& self, const Vec2T& pos) { self.PathLineToMergeDuplicate(to_vec2(pos)); }, nb::arg("pos")) + .def("PathFillConvex", [](ImDrawList& self, ImU32 col) { self.PathFillConvex(col); }, nb::arg("col")) + .def("PathFillConcave", [](ImDrawList& self, ImU32 col) { self.PathFillConcave(col); }, nb::arg("col")) + .def("PathStroke", [](ImDrawList& self, ImU32 col, ImDrawFlags flags, float thickness) { self.PathStroke(col, flags, thickness); }, + nb::arg("col"), nb::arg("flags") = 0, nb::arg("thickness") = 1.0f) + .def( + "PathArcTo", + [](ImDrawList& self, const Vec2T& center, float radius, float a_min, float a_max, int num_segments) { + self.PathArcTo(to_vec2(center), radius, a_min, a_max, num_segments); + }, + nb::arg("center"), + nb::arg("radius"), + nb::arg("a_min"), + nb::arg("a_max"), + nb::arg("num_segments") = 0 + ) + .def( + "PathArcToFast", + [](ImDrawList& self, const Vec2T& center, float radius, int a_min_of_12, int a_max_of_12) { + self.PathArcToFast(to_vec2(center), radius, a_min_of_12, a_max_of_12); + }, + nb::arg("center"), + nb::arg("radius"), + nb::arg("a_min_of_12"), + nb::arg("a_max_of_12") + ) + .def( + "PathEllipticalArcTo", + [](ImDrawList& self, const Vec2T& center, const Vec2T& radius, float rot, float a_min, float a_max, int num_segments) { + self.PathEllipticalArcTo(to_vec2(center), to_vec2(radius), rot, a_min, a_max, num_segments); + }, + nb::arg("center"), + nb::arg("radius"), + nb::arg("rot"), + nb::arg("a_min"), + nb::arg("a_max"), + nb::arg("num_segments") = 0 + ) + .def( + "PathBezierCubicCurveTo", + [](ImDrawList& self, const Vec2T& p2, const Vec2T& p3, const Vec2T& p4, int num_segments) { + self.PathBezierCubicCurveTo(to_vec2(p2), to_vec2(p3), to_vec2(p4), num_segments); + }, + nb::arg("p2"), + nb::arg("p3"), + nb::arg("p4"), + nb::arg("num_segments") = 0 + ) + .def( + "PathBezierQuadraticCurveTo", + [](ImDrawList& self, const Vec2T& p2, const Vec2T& p3, int num_segments) { + self.PathBezierQuadraticCurveTo(to_vec2(p2), to_vec2(p3), num_segments); + }, + nb::arg("p2"), + nb::arg("p3"), + nb::arg("num_segments") = 0 + ) + .def( + "PathRect", + [](ImDrawList& self, const Vec2T& rect_min, const Vec2T& rect_max, float rounding, ImDrawFlags flags) { + self.PathRect(to_vec2(rect_min), to_vec2(rect_max), rounding, flags); + }, + nb::arg("rect_min"), + nb::arg("rect_max"), + nb::arg("rounding") = 0.0f, + nb::arg("flags") = 0 + ) + + // Advanced: Channels + // Note: Prefer using your own persistent instance of ImDrawListSplitter + .def("ChannelsSplit", [](ImDrawList& self, int count) { self.ChannelsSplit(count); }, nb::arg("count")) + .def("ChannelsMerge", [](ImDrawList& self) { self.ChannelsMerge(); }) + .def("ChannelsSetCurrent", [](ImDrawList& self, int n) { self.ChannelsSetCurrent(n); }, nb::arg("n")) + + // Advanced: Miscellaneous + .def("AddDrawCmd", &ImDrawList::AddDrawCmd) + .def("CloneOutput", &ImDrawList::CloneOutput, nb::rv_policy::reference) + + // Note: The following are not bound as they are low-level or internal: + // - PushTextureID/PopTextureID (low-level texture state management) + // - AddCallback (requires C function pointers) + // - PrimReserve/PrimUnreserve/PrimRect/PrimRectUV/PrimQuadUV (low-level primitive allocation) + // - PrimWriteVtx/PrimWriteIdx/PrimVtx (low-level vertex writing) + // - All _Internal functions (prefixed with _) + ; +} diff --git a/src/cpp/imgui/imgui_structs_fonts.cpp b/src/cpp/imgui/imgui_structs_fonts.cpp new file mode 100644 index 0000000..b4fb738 --- /dev/null +++ b/src/cpp/imgui/imgui_structs_fonts.cpp @@ -0,0 +1,108 @@ +// Font structs: ImFontAtlas and ImFont + +#include "imgui_utils.h" + +// clang-format off + +void bind_imgui_fonts(nb::module_& m) { + + // ImFontBaked - Font runtime data for a given size + nb::class_(m, "ImFontBaked") + // IMGUI_API void ClearOutputData(); + .def("ClearOutputData", &ImFontBaked::ClearOutputData, "Clear output data") + + // IMGUI_API ImFontGlyph* FindGlyph(ImWchar c); + // Not bound - returns pointer to glyph data + + // IMGUI_API ImFontGlyph* FindGlyphNoFallback(ImWchar c); + // Not bound - returns pointer to glyph data + + // IMGUI_API float GetCharAdvance(ImWchar c); + .def("GetCharAdvance", &ImFontBaked::GetCharAdvance, nb::arg("c"), "Get character advance") + + // IMGUI_API bool IsGlyphLoaded(ImWchar c); + .def("IsGlyphLoaded", &ImFontBaked::IsGlyphLoaded, nb::arg("c"), "Check if glyph is loaded") + + // Properties + .def_ro("FallbackAdvanceX", &ImFontBaked::FallbackAdvanceX, "Fallback character advance") + .def_ro("Size", &ImFontBaked::Size, "Font size in pixels") + .def_ro("RasterizerDensity", &ImFontBaked::RasterizerDensity, "Density this is baked at") + .def_ro("Ascent", &ImFontBaked::Ascent, "Ascent: distance from top to bottom of e.g. 'A'") + .def_ro("Descent", &ImFontBaked::Descent, "Descent") + .def_ro("OwnerFont", &ImFontBaked::OwnerFont, nb::rv_policy::reference, "Parent font") + ; + + // ImFontAtlas - Font atlas for loading and building fonts + nb::class_(m, "ImFontAtlas") + // IMGUI_API ImFont* AddFont(const ImFontConfig* font_cfg); + // Not bound - requires ImFontConfig pointer management + + // IMGUI_API ImFont* AddFontDefault(const ImFontConfig* font_cfg = NULL); + .def("AddFontDefault", [](ImFontAtlas& atlas) { + return atlas.AddFontDefault(nullptr); + }, nb::rv_policy::reference, "Add default font") + + // IMGUI_API ImFont* AddFontFromFileTTF(const char* filename, float size_pixels, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL); + .def("AddFontFromFileTTF", [](ImFontAtlas& atlas, const std::string& filename, float size_pixels) { + return atlas.AddFontFromFileTTF(filename.c_str(), size_pixels, nullptr, nullptr); + }, nb::arg("filename"), nb::arg("size_pixels"), nb::rv_policy::reference, "Add font from TTF file") + + // IMGUI_API ImFont* AddFontFromMemoryCompressedBase85TTF(const char* compressed_font_data_base85, float size_pixels, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL); + .def("AddFontFromMemoryCompressedBase85TTF", [](ImFontAtlas& atlas, const char* compressed_font_data_base85, float size_pixels) { + return atlas.AddFontFromMemoryCompressedBase85TTF(compressed_font_data_base85, size_pixels, nullptr, nullptr); + }, nb::arg("compressed_font_data_base85"), nb::arg("size_pixels"), nb::rv_policy::reference, "Add font from compressed base85 data") + + // IMGUI_API void RemoveFont(ImFont* font); + .def("RemoveFont", &ImFontAtlas::RemoveFont, nb::arg("font"), "Remove font from atlas") + + // IMGUI_API void Clear(); // Clear all input and output. + .def("Clear", &ImFontAtlas::Clear, "Clear all") + + // IMGUI_API void CompactCache(); // Compact cached glyphs and texture. + .def("CompactCache", &ImFontAtlas::CompactCache, "Compact cache") + + // IMGUI_API bool Build(); // Build pixels data. This is called automatically for you by the GetTexData*** functions. + .def("Build", &ImFontAtlas::Build, "Build atlas") + + // Properties + .def_rw("Flags", &ImFontAtlas::Flags, "Build flags") + .def_rw("Flags", &ImFontAtlas::Flags, "Build flags") + .def_rw("TexGlyphPadding", &ImFontAtlas::TexGlyphPadding, "Padding between glyphs within texture in pixels") + .def_prop_ro("TexUvScale", [](const ImFontAtlas& atlas) { return from_vec2(atlas.TexUvScale); }, "Texture UV scale") + .def_prop_ro("TexUvWhitePixel", [](const ImFontAtlas& atlas) { return from_vec2(atlas.TexUvWhitePixel); }, "Texture coordinates to a white pixel") + ; + + // ImFont - Runtime data for a single font + nb::class_(m, "ImFont") + // IMGUI_API ImFontGlyph* FindGlyph(ImWchar c); + // Not bound - returns pointer to glyph data + + // IMGUI_API ImFontGlyph* FindGlyphNoFallback(ImWchar c); + // Not bound - returns pointer to glyph data + + // bool IsLoaded() const { return ContainerAtlas != NULL; } + .def("IsLoaded", &ImFont::IsLoaded, "Check if font is loaded") + + // const char* GetDebugName() const { return Sources ? Sources->Name : ""; } + .def("GetDebugName", &ImFont::GetDebugName, "Get debug name") + + // IMGUI_API ImVec2 CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end = NULL, const char** remaining = NULL); + .def("CalcTextSizeA", [](ImFont& font, float size, float max_width, float wrap_width, const char* text_begin) { + return from_vec2(font.CalcTextSizeA(size, max_width, wrap_width, text_begin, nullptr, nullptr)); + }, nb::arg("size"), nb::arg("max_width"), nb::arg("wrap_width"), nb::arg("text_begin"), "Calculate text size") + + // IMGUI_API const char* CalcWordWrapPosition(float size, const char* text, const char* text_end, float wrap_width); + .def("CalcWordWrapPosition", [](ImFont& font, float size, std::string text, float wrap_width) { + return font.CalcWordWrapPosition(size, text.c_str(), nullptr, wrap_width); + }, nb::arg("size"), nb::arg("text"), nb::arg("wrap_width"), "Calculate word wrap position") + + // IMGUI_API ImFontBaked* GetFontBaked(float font_size, float density = -1.0f); + .def("GetFontBaked", &ImFont::GetFontBaked, nb::arg("font_size"), nb::arg("density") = -1.0f, nb::rv_policy::reference, "Get or create baked data for given size") + + // Properties + .def_rw("Scale", &ImFont::Scale, "Base font scale, multiplied by the per-window font scale") + .def_ro("OwnerAtlas", &ImFont::OwnerAtlas, nb::rv_policy::reference, "What we have been loaded into") + ; +} + +// clang-format on diff --git a/src/cpp/imgui/imgui_structs_io.cpp b/src/cpp/imgui/imgui_structs_io.cpp new file mode 100644 index 0000000..c8ccc7a --- /dev/null +++ b/src/cpp/imgui/imgui_structs_io.cpp @@ -0,0 +1,156 @@ +// ImGuiIO struct bindings + +#include "imgui_utils.h" +#include + +// clang-format off + +void bind_imgui_io(nb::module_& m) { + + nb::class_(m, "ImGuiIO") + // Configuration + .def_rw("ConfigFlags", &ImGuiIO::ConfigFlags) + .def_rw("BackendFlags", &ImGuiIO::BackendFlags) + .def_prop_rw("DisplaySize", + [](ImGuiIO& o) { return from_vec2(o.DisplaySize); }, + [](ImGuiIO& o, const Vec2T& v) { o.DisplaySize = to_vec2(v); }) + .def_rw("DeltaTime", &ImGuiIO::DeltaTime) + .def_rw("IniSavingRate", &ImGuiIO::IniSavingRate) + .def_rw("IniFilename", &ImGuiIO::IniFilename) + .def_rw("LogFilename", &ImGuiIO::LogFilename) + + // Font system + .def_rw("Fonts", &ImGuiIO::Fonts) + .def_rw("FontDefault", &ImGuiIO::FontDefault, nb::arg().none()) + .def_rw("FontAllowUserScaling", &ImGuiIO::FontAllowUserScaling) + .def_rw("FontDefault", &ImGuiIO::FontDefault) + .def_prop_rw("DisplayFramebufferScale", + [](ImGuiIO& o) { return from_vec2(o.DisplayFramebufferScale); }, + [](ImGuiIO& o, const Vec2T& v) { o.DisplayFramebufferScale = to_vec2(v); }) + + // Keyboard/Gamepad Navigation options + .def_rw("ConfigNavSwapGamepadButtons", &ImGuiIO::ConfigNavSwapGamepadButtons) + .def_rw("ConfigNavMoveSetMousePos", &ImGuiIO::ConfigNavMoveSetMousePos) + .def_rw("ConfigNavCaptureKeyboard", &ImGuiIO::ConfigNavCaptureKeyboard) + .def_rw("ConfigNavEscapeClearFocusItem", &ImGuiIO::ConfigNavEscapeClearFocusItem) + .def_rw("ConfigNavEscapeClearFocusWindow", &ImGuiIO::ConfigNavEscapeClearFocusWindow) + .def_rw("ConfigNavCursorVisibleAuto", &ImGuiIO::ConfigNavCursorVisibleAuto) + .def_rw("ConfigNavCursorVisibleAlways", &ImGuiIO::ConfigNavCursorVisibleAlways) + + // Miscellaneous options + .def_rw("MouseDrawCursor", &ImGuiIO::MouseDrawCursor) + .def_rw("ConfigMacOSXBehaviors", &ImGuiIO::ConfigMacOSXBehaviors) + .def_rw("ConfigInputTrickleEventQueue", &ImGuiIO::ConfigInputTrickleEventQueue) + .def_rw("ConfigInputTextCursorBlink", &ImGuiIO::ConfigInputTextCursorBlink) + .def_rw("ConfigInputTextEnterKeepActive", &ImGuiIO::ConfigInputTextEnterKeepActive) + .def_rw("ConfigDragClickToInputText", &ImGuiIO::ConfigDragClickToInputText) + .def_rw("ConfigWindowsResizeFromEdges", &ImGuiIO::ConfigWindowsResizeFromEdges) + .def_rw("ConfigWindowsMoveFromTitleBarOnly", &ImGuiIO::ConfigWindowsMoveFromTitleBarOnly) + .def_rw("ConfigWindowsCopyContentsWithCtrlC", &ImGuiIO::ConfigWindowsCopyContentsWithCtrlC) + .def_rw("ConfigScrollbarScrollByPage", &ImGuiIO::ConfigScrollbarScrollByPage) + .def_rw("ConfigMemoryCompactTimer", &ImGuiIO::ConfigMemoryCompactTimer) + + // Input Behaviors + .def_rw("MouseDoubleClickTime", &ImGuiIO::MouseDoubleClickTime) + .def_rw("MouseDoubleClickMaxDist", &ImGuiIO::MouseDoubleClickMaxDist) + .def_rw("MouseDragThreshold", &ImGuiIO::MouseDragThreshold) + .def_rw("KeyRepeatDelay", &ImGuiIO::KeyRepeatDelay) + .def_rw("KeyRepeatRate", &ImGuiIO::KeyRepeatRate) + + // Debug options + .def_rw("ConfigErrorRecovery", &ImGuiIO::ConfigErrorRecovery) + .def_rw("ConfigErrorRecoveryEnableAssert", &ImGuiIO::ConfigErrorRecoveryEnableAssert) + .def_rw("ConfigErrorRecoveryEnableDebugLog", &ImGuiIO::ConfigErrorRecoveryEnableDebugLog) + .def_rw("ConfigErrorRecoveryEnableTooltip", &ImGuiIO::ConfigErrorRecoveryEnableTooltip) + .def_rw("ConfigDebugIsDebuggerPresent", &ImGuiIO::ConfigDebugIsDebuggerPresent) + .def_rw("ConfigDebugHighlightIdConflicts", &ImGuiIO::ConfigDebugHighlightIdConflicts) + .def_rw("ConfigDebugHighlightIdConflictsShowItemPicker", &ImGuiIO::ConfigDebugHighlightIdConflictsShowItemPicker) + .def_rw("ConfigDebugBeginReturnValueOnce", &ImGuiIO::ConfigDebugBeginReturnValueOnce) + .def_rw("ConfigDebugBeginReturnValueLoop", &ImGuiIO::ConfigDebugBeginReturnValueLoop) + .def_rw("ConfigDebugIgnoreFocusLoss", &ImGuiIO::ConfigDebugIgnoreFocusLoss) + .def_rw("ConfigDebugIniSettings", &ImGuiIO::ConfigDebugIniSettings) + + // Platform Identifiers + .def_rw("BackendPlatformName", &ImGuiIO::BackendPlatformName) + .def_rw("BackendRendererName", &ImGuiIO::BackendRendererName) + + // Input Functions + .def("AddKeyEvent", &ImGuiIO::AddKeyEvent, nb::arg("key"), nb::arg("down")) + .def("AddKeyAnalogEvent", &ImGuiIO::AddKeyAnalogEvent, nb::arg("key"), nb::arg("down"), nb::arg("v")) + .def("AddMousePosEvent", &ImGuiIO::AddMousePosEvent, nb::arg("x"), nb::arg("y")) + .def("AddMouseButtonEvent", &ImGuiIO::AddMouseButtonEvent, nb::arg("button"), nb::arg("down")) + .def("AddMouseWheelEvent", &ImGuiIO::AddMouseWheelEvent, nb::arg("wheel_x"), nb::arg("wheel_y")) + .def("AddMouseSourceEvent", &ImGuiIO::AddMouseSourceEvent, nb::arg("source")) + .def("AddFocusEvent", &ImGuiIO::AddFocusEvent, nb::arg("focused")) + .def("AddInputCharacter", &ImGuiIO::AddInputCharacter, nb::arg("c")) + .def("AddInputCharacterUTF16", &ImGuiIO::AddInputCharacterUTF16, nb::arg("c")) + .def("AddInputCharactersUTF8", &ImGuiIO::AddInputCharactersUTF8, nb::arg("str")) + .def("SetKeyEventNativeData", &ImGuiIO::SetKeyEventNativeData, + nb::arg("key"), nb::arg("native_keycode"), nb::arg("native_scancode"), nb::arg("native_legacy_index") = -1) + .def("SetAppAcceptingEvents", &ImGuiIO::SetAppAcceptingEvents, nb::arg("accepting_events")) + .def("ClearEventsQueue", &ImGuiIO::ClearEventsQueue) + .def("ClearInputKeys", &ImGuiIO::ClearInputKeys) + .def("ClearInputMouse", &ImGuiIO::ClearInputMouse) + + // Output - Updated by NewFrame() or EndFrame()/Render() + .def_rw("WantCaptureMouse", &ImGuiIO::WantCaptureMouse) + .def_rw("WantCaptureKeyboard", &ImGuiIO::WantCaptureKeyboard) + .def_rw("WantTextInput", &ImGuiIO::WantTextInput) + .def_rw("WantSetMousePos", &ImGuiIO::WantSetMousePos) + .def_rw("WantSaveIniSettings", &ImGuiIO::WantSaveIniSettings) + .def_rw("NavActive", &ImGuiIO::NavActive) + .def_rw("NavVisible", &ImGuiIO::NavVisible) + .def_rw("Framerate", &ImGuiIO::Framerate) + .def_rw("MetricsRenderVertices", &ImGuiIO::MetricsRenderVertices) + .def_rw("MetricsRenderIndices", &ImGuiIO::MetricsRenderIndices) + .def_rw("MetricsRenderWindows", &ImGuiIO::MetricsRenderWindows) + .def_rw("MetricsActiveWindows", &ImGuiIO::MetricsActiveWindows) + .def_prop_ro("MouseDelta", [](ImGuiIO& o) { return from_vec2(o.MouseDelta); }) + + // Main Input State (read-only from Python's perspective) + .def_prop_ro("MousePos", [](ImGuiIO& o) { return from_vec2(o.MousePos); }) + .def_prop_ro("MouseDown", [](ImGuiIO& o) { return std::to_array(o.MouseDown); }) + .def_rw("MouseWheel", &ImGuiIO::MouseWheel) + .def_rw("MouseWheelH", &ImGuiIO::MouseWheelH) + .def_rw("MouseSource", &ImGuiIO::MouseSource) + .def_rw("KeyCtrl", &ImGuiIO::KeyCtrl) + .def_rw("KeyShift", &ImGuiIO::KeyShift) + .def_rw("KeyAlt", &ImGuiIO::KeyAlt) + .def_rw("KeySuper", &ImGuiIO::KeySuper) + + // Other state + .def_rw("KeyMods", &ImGuiIO::KeyMods) + .def_rw("WantCaptureMouseUnlessPopupClose", &ImGuiIO::WantCaptureMouseUnlessPopupClose) + .def_prop_rw("MousePosPrev", + [](ImGuiIO& o) { return from_vec2(o.MousePosPrev); }, + [](ImGuiIO& o, const Vec2T& v) { o.MousePosPrev = to_vec2(v); }) + .def_prop_ro("MouseClickedPos", [](ImGuiIO& o) { + std::array result; + for (int i = 0; i < 5; i++) { + result[i] = from_vec2(o.MouseClickedPos[i]); + } + return result; + }) + .def_prop_ro("MouseClickedTime", [](ImGuiIO& o) { return std::to_array(o.MouseClickedTime); }) + .def_prop_ro("MouseClicked", [](ImGuiIO& o) { return std::to_array(o.MouseClicked); }) + .def_prop_ro("MouseDoubleClicked", [](ImGuiIO& o) { return std::to_array(o.MouseDoubleClicked); }) + .def_prop_ro("MouseClickedCount", [](ImGuiIO& o) { return std::to_array(o.MouseClickedCount); }) + .def_prop_ro("MouseClickedLastCount", [](ImGuiIO& o) { return std::to_array(o.MouseClickedLastCount); }) + .def_prop_ro("MouseReleased", [](ImGuiIO& o) { return std::to_array(o.MouseReleased); }) + .def_prop_ro("MouseDownOwned", [](ImGuiIO& o) { return std::to_array(o.MouseDownOwned); }) + .def_prop_ro("MouseDownOwnedUnlessPopupClose", [](ImGuiIO& o) { return std::to_array(o.MouseDownOwnedUnlessPopupClose); }) + .def_prop_ro("MouseDownDuration", [](ImGuiIO& o) { return std::to_array(o.MouseDownDuration); }) + .def_prop_ro("MouseDownDurationPrev", [](ImGuiIO& o) { return std::to_array(o.MouseDownDurationPrev); }) + .def_prop_ro("MouseDragMaxDistanceSqr", [](ImGuiIO& o) { return std::to_array(o.MouseDragMaxDistanceSqr); }) + .def_rw("PenPressure", &ImGuiIO::PenPressure) + .def_rw("AppFocusLost", &ImGuiIO::AppFocusLost) + .def_rw("InputQueueSurrogate", &ImGuiIO::InputQueueSurrogate) + .def_rw("InputQueueCharacters", &ImGuiIO::InputQueueCharacters) + + // Note: The following are intentionally not bound: + // - UserData, BackendPlatformUserData, BackendRendererUserData, BackendLanguageUserData (void* pointers) + // - Ctx (internal context pointer) + // - KeysData (low-level key state array, use IsKeyXXX functions instead) + // - Legacy/obsolete fields + ; +} diff --git a/src/cpp/imgui/imgui_structs_style.cpp b/src/cpp/imgui/imgui_structs_style.cpp new file mode 100644 index 0000000..0870667 --- /dev/null +++ b/src/cpp/imgui/imgui_structs_style.cpp @@ -0,0 +1,149 @@ +// ImGuiStyle struct bindings + +#include "imgui_utils.h" + +// clang-format off + +void bind_imgui_style(nb::module_& m) { + + #define VEC2_PROPERTY(name) \ + def_prop_rw(#name, [](const ImGuiStyle& style) { \ + return from_vec2(style.name); \ + }, [](ImGuiStyle& style, const Vec2T& value) { \ + style.name = to_vec2(value); \ + }) + + nb::class_(m, "ImGuiStyle") + + // Font scaling + .def_rw("FontSizeBase", &ImGuiStyle::FontSizeBase) + .def_rw("FontScaleMain", &ImGuiStyle::FontScaleMain) + .def_rw("FontScaleDpi", &ImGuiStyle::FontScaleDpi) + + // Main + .def_rw("Alpha", &ImGuiStyle::Alpha) + .def_rw("DisabledAlpha", &ImGuiStyle::DisabledAlpha) + + // Window + .VEC2_PROPERTY(WindowPadding) + .def_rw("WindowRounding", &ImGuiStyle::WindowRounding) + .def_rw("WindowBorderSize", &ImGuiStyle::WindowBorderSize) + .def_rw("WindowBorderHoverPadding", &ImGuiStyle::WindowBorderHoverPadding) + .VEC2_PROPERTY(WindowMinSize) + .VEC2_PROPERTY(WindowTitleAlign) + .def_rw("WindowMenuButtonPosition", &ImGuiStyle::WindowMenuButtonPosition) + + // Child windows + .def_rw("ChildRounding", &ImGuiStyle::ChildRounding) + .def_rw("ChildBorderSize", &ImGuiStyle::ChildBorderSize) + + // Popups + .def_rw("PopupRounding", &ImGuiStyle::PopupRounding) + .def_rw("PopupBorderSize", &ImGuiStyle::PopupBorderSize) + + // Frames + .VEC2_PROPERTY(FramePadding) + .def_rw("FrameRounding", &ImGuiStyle::FrameRounding) + .def_rw("FrameBorderSize", &ImGuiStyle::FrameBorderSize) + + // Spacing + .VEC2_PROPERTY(ItemSpacing) + .VEC2_PROPERTY(ItemInnerSpacing) + .VEC2_PROPERTY(CellPadding) + .VEC2_PROPERTY(TouchExtraPadding) + .def_rw("IndentSpacing", &ImGuiStyle::IndentSpacing) + .def_rw("ColumnsMinSpacing", &ImGuiStyle::ColumnsMinSpacing) + + // Scrollbars + .def_rw("ScrollbarSize", &ImGuiStyle::ScrollbarSize) + .def_rw("ScrollbarRounding", &ImGuiStyle::ScrollbarRounding) + .def_rw("ScrollbarPadding", &ImGuiStyle::ScrollbarPadding) + + // Grab handles + .def_rw("GrabMinSize", &ImGuiStyle::GrabMinSize) + .def_rw("GrabRounding", &ImGuiStyle::GrabRounding) + .def_rw("LogSliderDeadzone", &ImGuiStyle::LogSliderDeadzone) + + // Images + .def_rw("ImageBorderSize", &ImGuiStyle::ImageBorderSize) + + // Tabs + .def_rw("TabRounding", &ImGuiStyle::TabRounding) + .def_rw("TabBorderSize", &ImGuiStyle::TabBorderSize) + .def_rw("TabCloseButtonMinWidthSelected", &ImGuiStyle::TabCloseButtonMinWidthSelected) + .def_rw("TabCloseButtonMinWidthUnselected", &ImGuiStyle::TabCloseButtonMinWidthUnselected) + .def_rw("TabBarBorderSize", &ImGuiStyle::TabBarBorderSize) + .def_rw("TabBarOverlineSize", &ImGuiStyle::TabBarOverlineSize) + + // Tables + .def_rw("TableAngledHeadersAngle", &ImGuiStyle::TableAngledHeadersAngle) + .VEC2_PROPERTY(TableAngledHeadersTextAlign) + + // Tree Lines + .def_rw("TreeLinesFlags", &ImGuiStyle::TreeLinesFlags) + .def_rw("TreeLinesSize", &ImGuiStyle::TreeLinesSize) + .def_rw("TreeLinesRounding", &ImGuiStyle::TreeLinesRounding) + + // Drag and Drop + .def_rw("DragDropTargetRounding", &ImGuiStyle::DragDropTargetRounding) + .def_rw("DragDropTargetBorderSize", &ImGuiStyle::DragDropTargetBorderSize) + .def_rw("DragDropTargetPadding", &ImGuiStyle::DragDropTargetPadding) + + // Widgets + .def_rw("ColorButtonPosition", &ImGuiStyle::ColorButtonPosition) + .VEC2_PROPERTY(ButtonTextAlign) + .VEC2_PROPERTY(SelectableTextAlign) + + // Separators + .def_rw("SeparatorTextBorderSize", &ImGuiStyle::SeparatorTextBorderSize) + .VEC2_PROPERTY(SeparatorTextAlign) + .VEC2_PROPERTY(SeparatorTextPadding) + + // Display + .VEC2_PROPERTY(DisplayWindowPadding) + .VEC2_PROPERTY(DisplaySafeAreaPadding) + .def_rw("MouseCursorScale", &ImGuiStyle::MouseCursorScale) + + // Anti-aliasing + .def_rw("AntiAliasedLines", &ImGuiStyle::AntiAliasedLines) + .def_rw("AntiAliasedLinesUseTex", &ImGuiStyle::AntiAliasedLinesUseTex) + .def_rw("AntiAliasedFill", &ImGuiStyle::AntiAliasedFill) + + // Tessellation + .def_rw("CurveTessellationTol", &ImGuiStyle::CurveTessellationTol) + .def_rw("CircleTessellationMaxError", &ImGuiStyle::CircleTessellationMaxError) + + // Colors + // TODO think about making this more similar to the C++ style + // Provide indexed access to color array + .def("GetColor", [](const ImGuiStyle& style, int idx) { + if (idx < 0 || idx >= ImGuiCol_COUNT) { + throw std::out_of_range("Color index out of range: " + std::to_string(idx)); + } + return from_vec4(style.Colors[idx]); + }, nb::arg("idx"), "Get color by index") + + .def("SetColor", [](ImGuiStyle& style, int idx, const Vec4T& color) { + if (idx < 0 || idx >= ImGuiCol_COUNT) { + throw std::out_of_range("Color index out of range: " + std::to_string(idx)); + } + style.Colors[idx] = to_vec4(color); + }, nb::arg("idx"), nb::arg("color"), "Set color by index") + + .def("GetColorCount", [](ImGuiStyle& style) { + return static_cast(ImGuiCol_COUNT); + }, "Get total number of colors") + + // Behaviors + .def_rw("HoverStationaryDelay", &ImGuiStyle::HoverStationaryDelay) + .def_rw("HoverDelayShort", &ImGuiStyle::HoverDelayShort) + .def_rw("HoverDelayNormal", &ImGuiStyle::HoverDelayNormal) + .def_rw("HoverFlagsForTooltipMouse", &ImGuiStyle::HoverFlagsForTooltipMouse) + .def_rw("HoverFlagsForTooltipNav", &ImGuiStyle::HoverFlagsForTooltipNav) + + // Methods + .def("ScaleAllSizes", &ImGuiStyle::ScaleAllSizes, nb::arg("scale_factor")) + ; + + #undef VEC2_PROPERTY +} diff --git a/src/cpp/imgui_utils.h b/src/cpp/imgui/imgui_utils.h similarity index 62% rename from src/cpp/imgui_utils.h rename to src/cpp/imgui/imgui_utils.h index 67496ff..68e3df0 100644 --- a/src/cpp/imgui_utils.h +++ b/src/cpp/imgui/imgui_utils.h @@ -1,9 +1,34 @@ #pragma once -namespace ps = polyscope; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "imgui.h" +#include "implot.h" +// #include "imgui_internal.h" + +// Opaque types +// NB_MAKE_OPAQUE(ImGuiContext); +NB_MAKE_OPAQUE(ImPlotContext); +NB_MAKE_OPAQUE(ImDrawListSharedData); + + +#include "Eigen/Dense" + +// #include "../utils.h" + namespace nb = nanobind; using namespace nb::literals; + // Type translations between Python and ImGui. Prefer native Python types (tuples, arrays), translating into ImGui // equivalents. using Vec2T = std::tuple; diff --git a/src/cpp/imgui/implot.cpp b/src/cpp/imgui/implot.cpp new file mode 100644 index 0000000..97d7a8f --- /dev/null +++ b/src/cpp/imgui/implot.cpp @@ -0,0 +1,2038 @@ +#include "imgui.h" +#include "implot.h" + +#include "Eigen/Dense" + +#include "../utils.h" +#include "imgui_utils.h" + +void bind_implot_structs(nb::module_& m); +void bind_implot_methods(nb::module_& m); +void bind_implot_enums(nb::module_& m); + +void bind_implot(nb::module_& m) { + auto implot_module = m.def_submodule("implot", "ImPlot bindings"); + + bind_implot_structs(implot_module); + bind_implot_methods(implot_module); + bind_implot_enums(implot_module); +} + +// clang-format off + +void bind_implot_structs(nb::module_& m) { + + #define VEC2_PROPERTY(name) \ + def_prop_rw(#name, [](const ImPlotStyle& style) { \ + return from_vec2(style.name); \ + }, [](ImPlotStyle& style, const Vec2T& value) { \ + style.name = to_vec2(value); \ + }) + + nb::class_(m, "ImPlotStyle") + // Item styling variables + .def_rw("LineWeight", &ImPlotStyle::LineWeight) + .def_rw("Marker", &ImPlotStyle::Marker) + .def_rw("MarkerSize", &ImPlotStyle::MarkerSize) + .def_rw("MarkerWeight", &ImPlotStyle::MarkerWeight) + .def_rw("FillAlpha", &ImPlotStyle::FillAlpha) + .def_rw("ErrorBarSize", &ImPlotStyle::ErrorBarSize) + .def_rw("ErrorBarWeight", &ImPlotStyle::ErrorBarWeight) + .def_rw("DigitalBitHeight", &ImPlotStyle::DigitalBitHeight) + .def_rw("DigitalBitGap", &ImPlotStyle::DigitalBitGap) + + // Plot styling variables + .def_rw("PlotBorderSize", &ImPlotStyle::PlotBorderSize) + .def_rw("MinorAlpha", &ImPlotStyle::MinorAlpha) + .VEC2_PROPERTY(MajorTickLen) + .VEC2_PROPERTY(MinorTickLen) + .VEC2_PROPERTY(MajorTickSize) + .VEC2_PROPERTY(MinorTickSize) + .VEC2_PROPERTY(MajorGridSize) + .VEC2_PROPERTY(MinorGridSize) + .VEC2_PROPERTY(PlotPadding) + .VEC2_PROPERTY(LabelPadding) + .VEC2_PROPERTY(LegendPadding) + .VEC2_PROPERTY(LegendInnerPadding) + .VEC2_PROPERTY(LegendSpacing) + .VEC2_PROPERTY(MousePosPadding) + .VEC2_PROPERTY(AnnotationPadding) + .VEC2_PROPERTY(FitPadding) + .VEC2_PROPERTY(PlotDefaultSize) + .VEC2_PROPERTY(PlotMinSize) + + // Style colors + .def("GetColor", [](const ImPlotStyle& style, int idx) { + if (idx < 0 || idx >= ImPlotCol_COUNT) { + throw std::out_of_range("Color index out of range: " + std::to_string(idx)); + } + return from_vec4(style.Colors[idx]); + }, nb::arg("idx"), "Get color by index") + + .def("SetColor", [](ImPlotStyle& style, int idx, const Vec4T& color) { + if (idx < 0 || idx >= ImPlotCol_COUNT) { + throw std::out_of_range("Color index out of range: " + std::to_string(idx)); + } + style.Colors[idx] = to_vec4(color); + }, nb::arg("idx"), nb::arg("color"), "Set color by index") + + .def("GetColorCount", [](ImPlotStyle& style) { + return static_cast(ImPlotCol_COUNT); + }, "Get total number of colors") + + // Colormap + .def_rw("Colormap", &ImPlotStyle::Colormap) + + // Settings/flags + .def_rw("UseLocalTime", &ImPlotStyle::UseLocalTime) + .def_rw("UseISO8601", &ImPlotStyle::UseISO8601) + .def_rw("Use24HourClock", &ImPlotStyle::Use24HourClock) + ; + + #undef VEC2_PROPERTY + + nb::class_(m, "ImPlotInputMap") + .def_rw("Pan", &ImPlotInputMap::Pan) + .def_rw("PanMod", &ImPlotInputMap::PanMod) + .def_rw("Fit", &ImPlotInputMap::Fit) + .def_rw("Select", &ImPlotInputMap::Select) + .def_rw("SelectCancel", &ImPlotInputMap::SelectCancel) + .def_rw("SelectMod", &ImPlotInputMap::SelectMod) + .def_rw("SelectHorzMod", &ImPlotInputMap::SelectHorzMod) + .def_rw("SelectVertMod", &ImPlotInputMap::SelectVertMod) + .def_rw("Menu", &ImPlotInputMap::Menu) + .def_rw("OverrideMod", &ImPlotInputMap::OverrideMod) + .def_rw("ZoomMod", &ImPlotInputMap::ZoomMod) + .def_rw("ZoomRate", &ImPlotInputMap::ZoomRate) + ; + +} + +void bind_implot_methods(nb::module_& m) { + + //----------------------------------------------------------------------------- + // [SECTION] Begin/End Plot + //----------------------------------------------------------------------------- + + // IMPLOT_API bool BeginPlot(const char* title_id, const ImVec2& size=ImVec2(-1,0), ImPlotFlags flags=0); + m.def( + "BeginPlot", + [](const char* title_id, const Vec2T& size, ImPlotFlags flags) { + return ImPlot::BeginPlot(title_id, to_vec2(size), flags); + }, + nb::arg("title_id"), + nb::arg("size") = std::make_tuple(-1.f, 0.f), + nb::arg("flags") = 0 + ); + + // IMPLOT_API void EndPlot(); + m.def("EndPlot", []() { ImPlot::EndPlot(); }); + + /* + IMPLOT_API bool BeginSubplots(const char* title_id, + int rows, + int cols, + const ImVec2& size, + ImPlotSubplotFlags flags = 0, + float* row_ratios = nullptr, + float* col_ratios = nullptr); + */ + m.def( + "BeginSubplots", + [](const char* title_id, int rows, int cols, const Vec2T& size, ImPlotSubplotFlags flags, std::vector row_ratios, std::vector col_ratios) { + + float* row_ratios_ptr = nullptr; + float* col_ratios_ptr = nullptr; + if(row_ratios.size() > 0) { + if((int)row_ratios.size() != rows) throw std::runtime_error("invalid row_ratios size"); + row_ratios_ptr = row_ratios.data(); + } + if(col_ratios.size() > 0) { + if((int)col_ratios.size() != cols) throw std::runtime_error("invalid col_ratios size"); + col_ratios_ptr = col_ratios.data(); + } + + return ImPlot::BeginSubplots(title_id, rows, cols, to_vec2(size), flags, row_ratios_ptr, col_ratios_ptr); + }, + nb::arg("title_id"), + nb::arg("rows"), + nb::arg("cols"), + nb::arg("size") = std::make_tuple(-1.f, 0.f), + nb::arg("flags") = 0, + nb::arg("row_ratios") = std::vector(), + nb::arg("col_ratios") = std::vector() + ); + + // IMPLOT_API void EndSubplots(); + m.def("EndSubplots", []() { ImPlot::EndSubplots(); }); + + + //----------------------------------------------------------------------------- + // [SECTION] Setup + //----------------------------------------------------------------------------- + + // IMPLOT_API void SetupAxis(ImAxis axis, const char* label=nullptr, ImPlotAxisFlags flags=0); + m.def( + "SetupAxis", + [](ImAxis axis, const char* label, ImPlotAxisFlags flags) { + ImPlot::SetupAxis(axis, label, flags); + }, + nb::arg("axis"), + nb::arg("label") = "", + nb::arg("flags") = 0 + ); + + // IMPLOT_API void SetupAxisLimits(ImAxis axis, double v_min, double v_max, ImPlotCond cond = ImPlotCond_Once); + m.def( + "SetupAxisLimits", + [](ImAxis axis, double v_min, double v_max, ImPlotCond cond) { + ImPlot::SetupAxisLimits(axis, v_min, v_max, cond); + }, + nb::arg("axis"), + nb::arg("vmin"), + nb::arg("vmax"), + nb::arg("cond") = (int)ImPlotCond_Once + ); + + // IMPLOT_API void SetupAxisFormat(ImAxis axis, const char* fmt); + m.def( + "SetupAxisFormat", + [](ImAxis axis, const char* fmt) { + ImPlot::SetupAxisFormat(axis, fmt); + }, + nb::arg("axis"), + nb::arg("fmt") + ); + + + // IMPLOT_API void SetupAxisTicks(ImAxis axis, const double* values, int n_ticks, const char* const labels[]=nullptr, bool keep_default=false); + m.def( + "SetupAxisTicks", + [](ImAxis axis, const Eigen::VectorXd& values, const std::vector& labels, bool keep_default) { + if(labels.size() > 0 && (labels.size() != values.size())) throw std::runtime_error("input sizes don't match"); + const auto _labels = convert_string_items(labels); + ImPlot::SetupAxisTicks(axis, values.data(), values.size(), labels.size() == 0 ? nullptr : _labels.data(), keep_default); + }, + nb::arg("axis"), + nb::arg("values"), + nb::arg("labels") = std::vector(), + nb::arg("keep_default") = false + ); + + // IMPLOT_API void SetupAxisTicks(ImAxis axis, const double* values, int n_ticks, const char* const labels[]=nullptr, bool keep_default=false); + m.def( + "SetupAxisTicks", + [](ImAxis axis, double v_min, double v_max, int n_ticks, const std::vector& labels, bool keep_default) { + if(labels.size() > 0 && (labels.size() != n_ticks)) throw std::runtime_error("input sizes don't match"); + const auto _labels = convert_string_items(labels); + ImPlot::SetupAxisTicks(axis, v_min, v_max, n_ticks, labels.size() == 0 ? nullptr : _labels.data(), keep_default); + }, + nb::arg("axis"), + nb::arg("v_min"), + nb::arg("v_max"), + nb::arg("n_ticks"), + nb::arg("labels") = std::vector(), + nb::arg("keep_default") = false + ); + + + // IMPLOT_API void SetupAxisScale(ImAxis axis, ImPlotScale scale); + m.def( + "SetupAxisScale", + [](ImAxis axis, ImPlotScale scale) { + ImPlot::SetupAxisScale(axis, scale); + }, + nb::arg("axis"), + nb::arg("scale") + ); + + // IMPLOT_API void SetupAxisLimitsConstraints(ImAxis axis, double v_min, double v_max); + m.def( + "SetupAxisLimitsConstraints", + [](ImAxis axis, double v_min, double v_max) { + ImPlot::SetupAxisLimitsConstraints(axis, v_min, v_max); + }, + nb::arg("axis"), + nb::arg("v_min"), + nb::arg("v_max") + ); + + // IMPLOT_API void SetupAxisZoomConstraints(ImAxis axis, double z_min, double z_max); + m.def( + "SetupAxisZoomConstraints", + [](ImAxis axis, double z_min, double z_max) { + ImPlot::SetupAxisZoomConstraints(axis, z_min, z_max); + }, + nb::arg("axis"), + nb::arg("z_min"), + nb::arg("z_max") + ); + + // IMPLOT_API void SetupAxes(const char* x_label, const char* y_label, ImPlotAxisFlags x_flags=0, ImPlotAxisFlags y_flags=0); + m.def( + "SetupAxes", + [](const char* x_label, const char* y_label, ImPlotAxisFlags x_flags, ImPlotAxisFlags y_flags) { + ImPlot::SetupAxes(x_label, y_label, x_flags, y_flags); + }, + nb::arg("x_label"), + nb::arg("y_label"), + nb::arg("x_flags") = 0, + nb::arg("y_flags") = 0 + ); + + // IMPLOT_API void SetupAxesLimits(double x_min, double x_max, double y_min, double y_max, ImPlotCond cond = ImPlotCond_Once); + m.def( + "SetupAxesLimits", + [](double x_min, double x_max, double y_min, double y_max, ImPlotCond cond) { + ImPlot::SetupAxesLimits(x_min, x_max, y_min, y_max, cond); + }, + nb::arg("x_min"), + nb::arg("x_max"), + nb::arg("y_min"), + nb::arg("y_max"), + nb::arg("cond") = (int)ImPlotCond_Once + ); + + // IMPLOT_API void SetupLegend(ImPlotLocation location, ImPlotLegendFlags flags=0); + m.def( + "SetupLegend", + [](ImPlotLocation location, ImPlotLegendFlags flags) { + ImPlot::SetupLegend(location, flags); + }, + nb::arg("location"), + nb::arg("flags") = 0 + ); + + // IMPLOT_API void SetupMouseText(ImPlotLocation location, ImPlotMouseTextFlags flags=0); + m.def( + "SetupMouseText", + [](ImPlotLocation location, ImPlotMouseTextFlags flags) { + ImPlot::SetupMouseText(location, flags); + }, + nb::arg("location"), + nb::arg("flags") = 0 + ); + + // IMPLOT_API void SetupFinish(); + m.def( + "SetupFinish", + []() { + ImPlot::SetupFinish(); + } + ); + + + //----------------------------------------------------------------------------- + // [SECTION] Plot Items + //----------------------------------------------------------------------------- + + // PlotLine + + // IMPLOT_TMP void PlotLine(const char* label_id, const T* values, int count, double xscale=1, double xstart=0, ImPlotLineFlags flags=0, int offset=0, int stride=sizeof(T)); + m.def( + "PlotLine", + [](const char* label_id, const Eigen::VectorXd& values, double xscale, double xstart, ImPlotLineFlags flags) { + ImPlot::PlotLine(label_id, values.data(), values.size(), xscale, xstart, flags); + }, + nb::arg("label_id"), + nb::arg("values"), + nb::arg("xscale")=1., + nb::arg("xstart")=0., + nb::arg("flags")=0 + ); + + + // IMPLOT_TMP void PlotLine(const char* label_id, const T* xs, const T* ys, int count, ImPlotLineFlags flags=0, int offset=0, int stride=sizeof(T)); + m.def( + "PlotLine", + [](const char* label_id, const Eigen::VectorXd& xs, const Eigen::VectorXd& ys, ImPlotLineFlags flags) { + if(xs.size() != ys.size()) throw std::runtime_error("invalid input sizes"); + ImPlot::PlotLine(label_id, xs.data(), ys.data(), xs.size(), flags); + }, + nb::arg("label_id"), + nb::arg("xs"), + nb::arg("ys"), + nb::arg("flags") = 0 + ); + + // PlotScatter + + // IMPLOT_TMP void PlotScatter(const char* label_id, const T* values, int count, double xscale=1, double xstart=0, ImPlotScatterFlags flags=0, int offset=0, int stride=sizeof(T)); + m.def( + "PlotScatter", + [](const char* label_id, const Eigen::VectorXd& values, double xscale, double xstart, ImPlotScatterFlags flags) { + ImPlot::PlotScatter(label_id, values.data(), values.size(), xscale, xstart, flags); + }, + nb::arg("label_id"), + nb::arg("values"), + nb::arg("xscale")=1., + nb::arg("xstart")=0., + nb::arg("flags")=0 + ); + + // IMPLOT_TMP void PlotScatter(const char* label_id, const T* xs, const T* ys, int count, ImPlotScatterFlags flags=0, int offset=0, int stride=sizeof(T)); + m.def( + "PlotScatter", + [](const char* label_id, const Eigen::VectorXd& xs, const Eigen::VectorXd& ys, ImPlotScatterFlags flags) { + if(xs.size() != ys.size()) throw std::runtime_error("invalid input sizes"); + ImPlot::PlotScatter(label_id, xs.data(), ys.data(), xs.size(), flags); + }, + nb::arg("label_id"), + nb::arg("xs"), + nb::arg("ys"), + nb::arg("flags") = 0 + ); + + // PlotStairs + + // IMPLOT_TMP void PlotStairs(const char* label_id, const T* values, int count, double xscale=1, double xstart=0, ImPlotStairsFlags flags=0, int offset=0, int stride=sizeof(T)); + m.def( + "PlotStairs", + [](const char* label_id, const Eigen::VectorXd& values, double xscale, double xstart, ImPlotStairsFlags flags) { + ImPlot::PlotStairs(label_id, values.data(), values.size(), xscale, xstart, flags); + }, + nb::arg("label_id"), + nb::arg("values"), + nb::arg("xscale")=1., + nb::arg("xstart")=0., + nb::arg("flags")=0 + ); + + // IMPLOT_TMP void PlotStairs(const char* label_id, const T* xs, const T* ys, int count, ImPlotStairsFlags flags=0, int offset=0, int stride=sizeof(T)); + m.def( + "PlotStairs", + [](const char* label_id, const Eigen::VectorXd& xs, const Eigen::VectorXd& ys, ImPlotStairsFlags flags) { + if(xs.size() != ys.size()) throw std::runtime_error("invalid input sizes"); + ImPlot::PlotStairs(label_id, xs.data(), ys.data(), xs.size(), flags); + }, + nb::arg("label_id"), + nb::arg("xs"), + nb::arg("ys"), + nb::arg("flags") = 0 + ); + + // PlotShaded + + // IMPLOT_TMP void PlotShaded(const char* label_id, const T* values, int count, double yref=0, double xscale=1, double xstart=0, ImPlotShadedFlags flags=0, int offset=0, int stride=sizeof(T)); + m.def( + "PlotShaded", + [](const char* label_id, const Eigen::VectorXd& values, double yref, double xscale, double xstart, ImPlotShadedFlags flags) { + ImPlot::PlotShaded(label_id, values.data(), values.size(), yref, xscale, xstart, flags); + }, + nb::arg("label_id"), + nb::arg("values"), + nb::arg("yref")=0., + nb::arg("xscale")=1., + nb::arg("xstart")=0., + nb::arg("flags")=0 + ); + + // IMPLOT_TMP void PlotShaded(const char* label_id, const T* xs, const T* ys, int count, double yref=0, ImPlotShadedFlags flags=0, int offset=0, int stride=sizeof(T)); + m.def( + "PlotShaded", + [](const char* label_id, const Eigen::VectorXd& xs, const Eigen::VectorXd& ys, double yref, ImPlotShadedFlags flags) { + if(xs.size() != ys.size()) throw std::runtime_error("invalid input sizes"); + ImPlot::PlotShaded(label_id, xs.data(), ys.data(), xs.size(), yref, flags); + }, + nb::arg("label_id"), + nb::arg("xs"), + nb::arg("ys"), + nb::arg("yref")=0., + nb::arg("flags") = 0 + ); + + // IMPLOT_TMP void PlotShaded(const char* label_id, const T* xs, const T* ys1, const T* ys2, int count, ImPlotShadedFlags flags=0, int offset=0, int stride=sizeof(T)); + m.def( + "PlotShaded", + [](const char* label_id, const Eigen::VectorXd& xs, const Eigen::VectorXd& ys1, const Eigen::VectorXd& ys2, ImPlotShadedFlags flags) { + if(xs.size() != ys1.size()) throw std::runtime_error("invalid input sizes"); + if(xs.size() != ys2.size()) throw std::runtime_error("invalid input sizes"); + ImPlot::PlotShaded(label_id, xs.data(), ys1.data(), ys2.data(), xs.size(), flags); + }, + nb::arg("label_id"), + nb::arg("xs"), + nb::arg("ys1"), + nb::arg("ys2"), + nb::arg("flags") = 0 + ); + + // PlotBars + + // IMPLOT_TMP void PlotBars(const char* label_id, const T* values, int count, double bar_size=0.67, double shift=0, ImPlotBarsFlags flags=0, int offset=0, int stride=sizeof(T)); + m.def( + "PlotBars", + [](const char* label_id, const Eigen::VectorXd& values, double bar_size, double shift, ImPlotBarsFlags flags) { + ImPlot::PlotBars(label_id, values.data(), values.size(), bar_size, shift, flags); + }, + nb::arg("label_id"), + nb::arg("values"), + nb::arg("bar_size")=0.67, + nb::arg("shift")=0., + nb::arg("flags")=0 + ); + + // IMPLOT_TMP void PlotBars(const char* label_id, const T* xs, const T* ys, int count, double bar_size, ImPlotBarsFlags flags=0, int offset=0, int stride=sizeof(T)); + m.def( + "PlotBars", + [](const char* label_id, const Eigen::VectorXd& xs, const Eigen::VectorXd& ys, double bar_size, ImPlotBarsFlags flags) { + if(xs.size() != ys.size()) throw std::runtime_error("invalid input sizes"); + ImPlot::PlotBars(label_id, xs.data(), ys.data(), xs.size(), bar_size, flags); + }, + nb::arg("label_id"), + nb::arg("xs"), + nb::arg("ys"), + nb::arg("bar_size"), + nb::arg("flags") = 0 + ); + + // PlotBarGroups + + // IMPLOT_TMP void PlotBarGroups(const char* const label_ids[], const T* values, int item_count, int group_count, double group_size=0.67, double shift=0, ImPlotBarGroupsFlags flags=0); + m.def( + "PlotBarGroups", + [](const std::vector& label_ids, const Eigen::MatrixXd& values, double group_size, double shift, ImPlotBarGroupsFlags flags) { + if(label_ids.size() != values.rows()) throw std::runtime_error("label_ids size must match values rows"); + const auto _label_ids = convert_string_items(label_ids); + ImPlot::PlotBarGroups(_label_ids.data(), values.data(), values.rows(), values.cols(), group_size, shift, flags); + }, + nb::arg("label_ids"), + nb::arg("values"), + nb::arg("group_size")=0.67, + nb::arg("shift")=0., + nb::arg("flags")=0 + ); + + // PlotErrorBars + + // IMPLOT_TMP void PlotErrorBars(const char* label_id, const T* xs, const T* ys, const T* err, int count, ImPlotErrorBarsFlags flags=0, int offset=0, int stride=sizeof(T)); + m.def( + "PlotErrorBars", + [](const char* label_id, const Eigen::VectorXd& xs, const Eigen::VectorXd& ys, const Eigen::VectorXd& err, ImPlotErrorBarsFlags flags) { + if(xs.size() != ys.size()) throw std::runtime_error("invalid input sizes"); + if(xs.size() != err.size()) throw std::runtime_error("invalid input sizes"); + ImPlot::PlotErrorBars(label_id, xs.data(), ys.data(), err.data(), xs.size(), flags); + }, + nb::arg("label_id"), + nb::arg("xs"), + nb::arg("ys"), + nb::arg("err"), + nb::arg("flags") = 0 + ); + + // IMPLOT_TMP void PlotErrorBars(const char* label_id, const T* xs, const T* ys, const T* neg, const T* pos, int count, ImPlotErrorBarsFlags flags=0, int offset=0, int stride=sizeof(T)); + m.def( + "PlotErrorBars", + [](const char* label_id, const Eigen::VectorXd& xs, const Eigen::VectorXd& ys, const Eigen::VectorXd& neg, const Eigen::VectorXd& pos, ImPlotErrorBarsFlags flags) { + if(xs.size() != ys.size()) throw std::runtime_error("invalid input sizes"); + if(xs.size() != neg.size()) throw std::runtime_error("invalid input sizes"); + if(xs.size() != pos.size()) throw std::runtime_error("invalid input sizes"); + ImPlot::PlotErrorBars(label_id, xs.data(), ys.data(), neg.data(), pos.data(), xs.size(), flags); + }, + nb::arg("label_id"), + nb::arg("xs"), + nb::arg("ys"), + nb::arg("neg"), + nb::arg("pos"), + nb::arg("flags") = 0 + ); + + // PlotStems + + // IMPLOT_TMP void PlotStems(const char* label_id, const T* values, int count, double ref=0, double scale=1, double start=0, ImPlotStemsFlags flags=0, int offset=0, int stride=sizeof(T)); + m.def( + "PlotStems", + [](const char* label_id, const Eigen::VectorXd& values, double ref, double scale, double start, ImPlotStemsFlags flags) { + ImPlot::PlotStems(label_id, values.data(), values.size(), ref, scale, start, flags); + }, + nb::arg("label_id"), + nb::arg("values"), + nb::arg("ref")=0., + nb::arg("scale")=1., + nb::arg("start")=0., + nb::arg("flags")=0 + ); + + // IMPLOT_TMP void PlotStems(const char* label_id, const T* xs, const T* ys, int count, double ref=0, ImPlotStemsFlags flags=0, int offset=0, int stride=sizeof(T)); + m.def( + "PlotStems", + [](const char* label_id, const Eigen::VectorXd& xs, const Eigen::VectorXd& ys, double ref, ImPlotStemsFlags flags) { + if(xs.size() != ys.size()) throw std::runtime_error("invalid input sizes"); + ImPlot::PlotStems(label_id, xs.data(), ys.data(), xs.size(), ref, flags); + }, + nb::arg("label_id"), + nb::arg("xs"), + nb::arg("ys"), + nb::arg("ref")=0., + nb::arg("flags") = 0 + ); + + // PlotInfLines + + // IMPLOT_TMP void PlotInfLines(const char* label_id, const T* values, int count, ImPlotInfLinesFlags flags=0, int offset=0, int stride=sizeof(T)); + m.def( + "PlotInfLines", + [](const char* label_id, const Eigen::VectorXd& values, ImPlotInfLinesFlags flags) { + ImPlot::PlotInfLines(label_id, values.data(), values.size(), flags); + }, + nb::arg("label_id"), + nb::arg("values"), + nb::arg("flags")=0 + ); + + // PlotPieChart + + // IMPLOT_TMP void PlotPieChart(const char* const label_ids[], const T* values, int count, double x, double y, double radius, ImPlotFormatter fmt, void* fmt_data=nullptr, double angle0=90, ImPlotPieChartFlags flags=0); + m.def( + "PlotPieChart", + [](const std::vector& label_ids, const Eigen::VectorXd& values, double x, double y, double radius, const char* label_fmt, double angle0, ImPlotPieChartFlags flags) { + if(label_ids.size() != values.size()) throw std::runtime_error("input sizes don't match"); + const auto _label_ids = convert_string_items(label_ids); + ImPlot::PlotPieChart(_label_ids.data(), values.data(), values.size(), x, y, radius, label_fmt, angle0, flags); + }, + nb::arg("label_ids"), + nb::arg("values"), + nb::arg("x"), + nb::arg("y"), + nb::arg("radius"), + nb::arg("label_fmt") = "%.1f", + nb::arg("angle0") = 90, + nb::arg("flags") = 0 + ); + + + // PlotHeatmap + + // IMPLOT_TMP void PlotHeatmap(const char* label_id, const T* values, int rows, int cols, double scale_min=0, double scale_max=0, const char* label_fmt="%.1f", const ImPlotPoint& bounds_min=ImPlotPoint(0,0), const ImPlotPoint& bounds_max=ImPlotPoint(1,1), ImPlotHeatmapFlags flags=0); + m.def( + "PlotHeatmap", + [](const char* label_id, const Eigen::MatrixXd& values, double scale_min, double scale_max, const char* label_fmt, const Vec2T& bounds_min, const Vec2T& bounds_max, ImPlotHeatmapFlags flags) { + ImPlotPoint pt_min(std::get<0>(bounds_min), std::get<1>(bounds_min)); + ImPlotPoint pt_max(std::get<0>(bounds_max), std::get<1>(bounds_max)); + ImPlot::PlotHeatmap(label_id, values.data(), values.rows(), values.cols(), scale_min, scale_max, label_fmt, pt_min, pt_max, flags); + }, + nb::arg("label_id"), + nb::arg("values"), + nb::arg("scale_min") = 0., + nb::arg("scale_max") = 0., + nb::arg("label_fmt") = "%.1f", + nb::arg("bounds_min") = Vec2T(0., 0.), + nb::arg("bounds_max") = Vec2T(1., 1.), + nb::arg("flags") = 0 + ); + + // PlotHistogram + + // IMPLOT_TMP double PlotHistogram(const char* label_id, const T* values, int count, int bins=ImPlotBin_Sturges, double bar_scale=1.0, ImPlotRange range=ImPlotRange(), ImPlotHistogramFlags flags=0); + m.def( + "PlotHistogram", + [](const char* label_id, const Eigen::VectorXd& values, int bins, double bar_scale, const Vec2T& range, ImPlotHistogramFlags flags) { + ImPlotRange imrange(std::get<0>(range), std::get<1>(range)); + ImPlot::PlotHistogram(label_id, values.data(), values.size(), bins, bar_scale, imrange, flags); + }, + nb::arg("label_id"), + nb::arg("values"), + nb::arg("bins") = (int)ImPlotBin_Sturges, + nb::arg("bar_scale") = 1.0, + nb::arg("range") = std::make_tuple(0.f, 0.f), + nb::arg("flags") = 0 + ); + + // PlotHistogram2D + + // IMPLOT_TMP double PlotHistogram2D(const char* label_id, const T* xs, const T* ys, int count, int x_bins=ImPlotBin_Sturges, int y_bins=ImPlotBin_Sturges, ImPlotRect range=ImPlotRect(), ImPlotHistogramFlags flags=0); + m.def( + "PlotHistogram2D", + [](const char* label_id, const Eigen::VectorXd& xs, const Eigen::VectorXd& ys, int x_bins, int y_bins, const Vec4T& range, ImPlotHistogramFlags flags) { + if(xs.size() != ys.size()) throw std::runtime_error("invalid input sizes"); + ImPlotRect imrange(std::get<0>(range), std::get<1>(range), std::get<2>(range), std::get<3>(range)); + ImPlot::PlotHistogram2D(label_id, xs.data(), ys.data(), xs.size(), x_bins, y_bins, imrange, flags); + }, + nb::arg("label_id"), + nb::arg("xs"), + nb::arg("ys"), + nb::arg("x_bins") = (int)ImPlotBin_Sturges, + nb::arg("y_bins") = (int)ImPlotBin_Sturges, + nb::arg("range") = Vec4T(0., 0., 0., 0.), + nb::arg("flags") = 0 + ); + + // PlotDigital + + // IMPLOT_TMP void PlotDigital(const char* label_id, const T* xs, const T* ys, int count, ImPlotDigitalFlags flags=0, int offset=0, int stride=sizeof(T)); + m.def( + "PlotDigital", + [](const char* label_id, const Eigen::VectorXd& xs, const Eigen::VectorXd& ys, ImPlotDigitalFlags flags) { + if(xs.size() != ys.size()) throw std::runtime_error("invalid input sizes"); + ImPlot::PlotDigital(label_id, xs.data(), ys.data(), xs.size(), flags); + }, + nb::arg("label_id"), + nb::arg("xs"), + nb::arg("ys"), + nb::arg("flags") = 0 + ); + + // PlotImage + + // IMPLOT_API void PlotImage(const char* label_id, ImTextureID tex_ref, const ImPlotPoint& bounds_min, const ImPlotPoint& bounds_max, const ImVec2& uv0=ImVec2(0,0), const ImVec2& uv1=ImVec2(1,1), const ImVec4& tint_col=ImVec4(1,1,1,1), ImPlotImageFlags flags=0); + m.def( + "PlotImage", + [](const char* label_id, ImTextureID tex_ref, const Vec2T& bounds_min, const Vec2T& bounds_max, const Vec2T& uv0, const Vec2T& uv1, const Vec4T& tint_col, ImPlotImageFlags flags) { + ImPlotPoint pt_min(std::get<0>(bounds_min), std::get<1>(bounds_min)); + ImPlotPoint pt_max(std::get<0>(bounds_max), std::get<1>(bounds_max)); + ImPlot::PlotImage(label_id, tex_ref, pt_min, pt_max, to_vec2(uv0), to_vec2(uv1), to_vec4(tint_col), flags); + }, + nb::arg("label_id"), + nb::arg("tex_ref"), + nb::arg("bounds_min"), + nb::arg("bounds_max"), + nb::arg("uv0") = Vec2T(0.f, 0.f), + nb::arg("uv1") = Vec2T(1.f, 1.f), + nb::arg("tint_col") = Vec4T(1.f, 1.f, 1.f, 1.f), + nb::arg("flags") = 0 + ); + + // PlotText + + // IMPLOT_API void PlotText(const char* text, double x, double y, const ImVec2& pix_offset=ImVec2(0,0), ImPlotTextFlags flags=0); + m.def( + "PlotText", + [](const char* text, double x, double y, const Vec2T& pix_offset, ImPlotTextFlags flags) { + ImPlot::PlotText(text, x, y, to_vec2(pix_offset), flags); + }, + nb::arg("text"), + nb::arg("x"), + nb::arg("y"), + nb::arg("pix_offset") = Vec2T(0.f, 0.f), + nb::arg("flags") = 0 + ); + + // PlotDummy + + // IMPLOT_API void PlotDummy(const char* label_id, ImPlotDummyFlags flags=0); + m.def( + "PlotDummy", + [](const char* label_id, ImPlotDummyFlags flags) { + ImPlot::PlotDummy(label_id, flags); + }, + nb::arg("label_id"), + nb::arg("flags") = 0 + ); + + + //----------------------------------------------------------------------------- + // [SECTION] Plot Tools + //----------------------------------------------------------------------------- + + // IMPLOT_API bool DragPoint(int id, double* x, double* y, const ImVec4& col, float size = 4, ImPlotDragToolFlags flags = 0, bool* out_clicked = nullptr, bool* out_hovered = nullptr, bool* held = nullptr); + m.def( + "DragPoint", + [](int id, double x, double y, const Vec4T& col, float size, ImPlotDragToolFlags flags) { + bool result = ImPlot::DragPoint(id, &x, &y, to_vec4(col), size, flags); + return std::make_tuple(result, x, y); + }, + nb::arg("id"), + nb::arg("x"), + nb::arg("y"), + nb::arg("col"), + nb::arg("size") = 4.f, + nb::arg("flags") = 0 + ); + + // IMPLOT_API bool DragLineX(int id, double* x, const ImVec4& col, float thickness = 1, ImPlotDragToolFlags flags = 0, bool* out_clicked = nullptr, bool* out_hovered = nullptr, bool* held = nullptr); + m.def( + "DragLineX", + [](int id, double x, const Vec4T& col, float thickness, ImPlotDragToolFlags flags) { + bool result = ImPlot::DragLineX(id, &x, to_vec4(col), thickness, flags); + return std::make_tuple(result, x); + }, + nb::arg("id"), + nb::arg("x"), + nb::arg("col"), + nb::arg("thickness") = 1.f, + nb::arg("flags") = 0 + ); + + // IMPLOT_API bool DragLineY(int id, double* y, const ImVec4& col, float thickness = 1, ImPlotDragToolFlags flags = 0, bool* out_clicked = nullptr, bool* out_hovered = nullptr, bool* held = nullptr); + m.def( + "DragLineY", + [](int id, double y, const Vec4T& col, float thickness, ImPlotDragToolFlags flags) { + bool result = ImPlot::DragLineY(id, &y, to_vec4(col), thickness, flags); + return std::make_tuple(result, y); + }, + nb::arg("id"), + nb::arg("y"), + nb::arg("col"), + nb::arg("thickness") = 1.f, + nb::arg("flags") = 0 + ); + + // IMPLOT_API bool DragRect(int id, double* x1, double* y1, double* x2, double* y2, const ImVec4& col, ImPlotDragToolFlags flags = 0, bool* out_clicked = nullptr, bool* out_hovered = nullptr, bool* held = nullptr); + m.def( + "DragRect", + [](int id, double x1, double y1, double x2, double y2, const Vec4T& col, ImPlotDragToolFlags flags) { + bool result = ImPlot::DragRect(id, &x1, &y1, &x2, &y2, to_vec4(col), flags); + return std::make_tuple(result, x1, y1, x2, y2); + }, + nb::arg("id"), + nb::arg("x1"), + nb::arg("y1"), + nb::arg("x2"), + nb::arg("y2"), + nb::arg("col"), + nb::arg("flags") = 0 + ); + + // IMPLOT_API void Annotation(double x, double y, const ImVec4& col, const ImVec2& pix_offset, bool clamp, bool round = false); + m.def( + "Annotation", + [](double x, double y, const Vec4T& col, const Vec2T& pix_offset, bool clamp, bool round) { + ImPlot::Annotation(x, y, to_vec4(col), to_vec2(pix_offset), clamp, round); + }, + nb::arg("x"), + nb::arg("y"), + nb::arg("col"), + nb::arg("pix_offset"), + nb::arg("clamp"), + nb::arg("round") = false + ); + + // IMPLOT_API void Annotation(double x, double y, const ImVec4& col, const ImVec2& pix_offset, bool clamp, const char* fmt, ...) IM_FMTARGS(6); + m.def( + "Annotation", + [](double x, double y, const Vec4T& col, const Vec2T& pix_offset, bool clamp, const char* text) { + ImPlot::Annotation(x, y, to_vec4(col), to_vec2(pix_offset), clamp, "%s", text); + }, + nb::arg("x"), + nb::arg("y"), + nb::arg("col"), + nb::arg("pix_offset"), + nb::arg("clamp"), + nb::arg("text") + ); + + // IMPLOT_API void TagX(double x, const ImVec4& col, bool round = false); + m.def( + "TagX", + [](double x, const Vec4T& col, bool round) { + ImPlot::TagX(x, to_vec4(col), round); + }, + nb::arg("x"), + nb::arg("col"), + nb::arg("round") = false + ); + + // IMPLOT_API void TagX(double x, const ImVec4& col, const char* fmt, ...) IM_FMTARGS(3); + m.def( + "TagX", + [](double x, const Vec4T& col, const char* text) { + ImPlot::TagX(x, to_vec4(col), "%s", text); + }, + nb::arg("x"), + nb::arg("col"), + nb::arg("text") + ); + + // IMPLOT_API void TagY(double y, const ImVec4& col, bool round = false); + m.def( + "TagY", + [](double y, const Vec4T& col, bool round) { + ImPlot::TagY(y, to_vec4(col), round); + }, + nb::arg("y"), + nb::arg("col"), + nb::arg("round") = false + ); + + // IMPLOT_API void TagY(double y, const ImVec4& col, const char* fmt, ...) IM_FMTARGS(3); + m.def( + "TagY", + [](double y, const Vec4T& col, const char* text) { + ImPlot::TagY(y, to_vec4(col), "%s", text); + }, + nb::arg("y"), + nb::arg("col"), + nb::arg("text") + ); + + //----------------------------------------------------------------------------- + // [SECTION] Plot Utils + //----------------------------------------------------------------------------- + + // IMPLOT_API void SetAxis(ImAxis axis); + m.def( + "SetAxis", + [](ImAxis axis) { + ImPlot::SetAxis(axis); + }, + nb::arg("axis") + ); + + // IMPLOT_API void SetAxes(ImAxis x_axis, ImAxis y_axis); + m.def( + "SetAxes", + [](ImAxis x_axis, ImAxis y_axis) { + ImPlot::SetAxes(x_axis, y_axis); + }, + nb::arg("x_axis"), + nb::arg("y_axis") + ); + + // IMPLOT_API ImPlotPoint PixelsToPlot(const ImVec2& pix, ImAxis x_axis = IMPLOT_AUTO, ImAxis y_axis = IMPLOT_AUTO); + m.def( + "PixelsToPlot", + [](const Vec2T& pix, ImAxis x_axis, ImAxis y_axis) { + ImPlotPoint result = ImPlot::PixelsToPlot(to_vec2(pix), x_axis, y_axis); + return std::make_tuple(result.x, result.y); + }, + nb::arg("pix"), + nb::arg("x_axis") = IMPLOT_AUTO, + nb::arg("y_axis") = IMPLOT_AUTO + ); + + // IMPLOT_API ImPlotPoint PixelsToPlot(float x, float y, ImAxis x_axis = IMPLOT_AUTO, ImAxis y_axis = IMPLOT_AUTO); + m.def( + "PixelsToPlot", + [](float x, float y, ImAxis x_axis, ImAxis y_axis) { + ImPlotPoint result = ImPlot::PixelsToPlot(x, y, x_axis, y_axis); + return std::make_tuple(result.x, result.y); + }, + nb::arg("x"), + nb::arg("y"), + nb::arg("x_axis") = IMPLOT_AUTO, + nb::arg("y_axis") = IMPLOT_AUTO + ); + + // IMPLOT_API ImVec2 PlotToPixels(const ImPlotPoint& plt, ImAxis x_axis = IMPLOT_AUTO, ImAxis y_axis = IMPLOT_AUTO); + m.def( + "PlotToPixels", + [](const Vec2T& plt, ImAxis x_axis, ImAxis y_axis) { + ImPlotPoint pt(std::get<0>(plt), std::get<1>(plt)); + ImVec2 result = ImPlot::PlotToPixels(pt, x_axis, y_axis); + return std::make_tuple(result.x, result.y); + }, + nb::arg("plt"), + nb::arg("x_axis") = IMPLOT_AUTO, + nb::arg("y_axis") = IMPLOT_AUTO + ); + + // IMPLOT_API ImVec2 PlotToPixels(double x, double y, ImAxis x_axis = IMPLOT_AUTO, ImAxis y_axis = IMPLOT_AUTO); + m.def( + "PlotToPixels", + [](double x, double y, ImAxis x_axis, ImAxis y_axis) { + ImVec2 result = ImPlot::PlotToPixels(x, y, x_axis, y_axis); + return std::make_tuple(result.x, result.y); + }, + nb::arg("x"), + nb::arg("y"), + nb::arg("x_axis") = IMPLOT_AUTO, + nb::arg("y_axis") = IMPLOT_AUTO + ); + + // IMPLOT_API ImVec2 GetPlotPos(); + m.def( + "GetPlotPos", + []() { + ImVec2 result = ImPlot::GetPlotPos(); + return std::make_tuple(result.x, result.y); + } + ); + + // IMPLOT_API ImVec2 GetPlotSize(); + m.def( + "GetPlotSize", + []() { + ImVec2 result = ImPlot::GetPlotSize(); + return std::make_tuple(result.x, result.y); + } + ); + + // IMPLOT_API ImPlotPoint GetPlotMousePos(ImAxis x_axis = IMPLOT_AUTO, ImAxis y_axis = IMPLOT_AUTO); + m.def( + "GetPlotMousePos", + [](ImAxis x_axis, ImAxis y_axis) { + ImPlotPoint result = ImPlot::GetPlotMousePos(x_axis, y_axis); + return std::make_tuple(result.x, result.y); + }, + nb::arg("x_axis") = IMPLOT_AUTO, + nb::arg("y_axis") = IMPLOT_AUTO + ); + + // IMPLOT_API ImPlotRect GetPlotLimits(ImAxis x_axis = IMPLOT_AUTO, ImAxis y_axis = IMPLOT_AUTO); + m.def( + "GetPlotLimits", + [](ImAxis x_axis, ImAxis y_axis) { + ImPlotRect result = ImPlot::GetPlotLimits(x_axis, y_axis); + return std::make_tuple(result.X.Min, result.X.Max, result.Y.Min, result.Y.Max); + }, + nb::arg("x_axis") = IMPLOT_AUTO, + nb::arg("y_axis") = IMPLOT_AUTO + ); + + // IMPLOT_API bool IsPlotHovered(); + m.def( + "IsPlotHovered", + []() { + return ImPlot::IsPlotHovered(); + } + ); + + // IMPLOT_API bool IsAxisHovered(ImAxis axis); + m.def( + "IsAxisHovered", + [](ImAxis axis) { + return ImPlot::IsAxisHovered(axis); + }, + nb::arg("axis") + ); + + // IMPLOT_API bool IsSubplotsHovered(); + m.def( + "IsSubplotsHovered", + []() { + return ImPlot::IsSubplotsHovered(); + } + ); + + // IMPLOT_API bool IsPlotSelected(); + m.def( + "IsPlotSelected", + []() { + return ImPlot::IsPlotSelected(); + } + ); + + // IMPLOT_API ImPlotRect GetPlotSelection(ImAxis x_axis = IMPLOT_AUTO, ImAxis y_axis = IMPLOT_AUTO); + m.def( + "GetPlotSelection", + [](ImAxis x_axis, ImAxis y_axis) { + ImPlotRect result = ImPlot::GetPlotSelection(x_axis, y_axis); + return std::make_tuple(result.X.Min, result.X.Max, result.Y.Min, result.Y.Max); + }, + nb::arg("x_axis") = IMPLOT_AUTO, + nb::arg("y_axis") = IMPLOT_AUTO + ); + + // IMPLOT_API void CancelPlotSelection(); + m.def( + "CancelPlotSelection", + []() { + ImPlot::CancelPlotSelection(); + } + ); + + // IMPLOT_API void HideNextItem(bool hidden = true, ImPlotCond cond = ImPlotCond_Once); + m.def( + "HideNextItem", + [](bool hidden, ImPlotCond cond) { + ImPlot::HideNextItem(hidden, cond); + }, + nb::arg("hidden") = true, + nb::arg("cond") = static_cast(ImPlotCond_Once) + ); + + // IMPLOT_API bool BeginAlignedPlots(const char* group_id, bool vertical = true); + m.def( + "BeginAlignedPlots", + [](const char* group_id, bool vertical) { + return ImPlot::BeginAlignedPlots(group_id, vertical); + }, + nb::arg("group_id"), + nb::arg("vertical") = true + ); + + // IMPLOT_API void EndAlignedPlots(); + m.def( + "EndAlignedPlots", + []() { + ImPlot::EndAlignedPlots(); + } + ); + + //----------------------------------------------------------------------------- + // [SECTION] Legend Utils + //----------------------------------------------------------------------------- + + // IMPLOT_API bool BeginLegendPopup(const char* label_id, ImGuiMouseButton mouse_button=1); + m.def( + "BeginLegendPopup", + [](const char* label_id, ImGuiMouseButton mouse_button) { + return ImPlot::BeginLegendPopup(label_id, mouse_button); + }, + nb::arg("label_id"), + nb::arg("mouse_button") = 1 + ); + + // IMPLOT_API void EndLegendPopup(); + m.def( + "EndLegendPopup", + []() { + ImPlot::EndLegendPopup(); + } + ); + + // IMPLOT_API bool IsLegendEntryHovered(const char* label_id); + m.def( + "IsLegendEntryHovered", + [](const char* label_id) { + return ImPlot::IsLegendEntryHovered(label_id); + }, + nb::arg("label_id") + ); + + //----------------------------------------------------------------------------- + // [SECTION] Drag and Drop + //----------------------------------------------------------------------------- + + // IMPLOT_API bool BeginDragDropTargetPlot(); + m.def( + "BeginDragDropTargetPlot", + []() { + return ImPlot::BeginDragDropTargetPlot(); + } + ); + + // IMPLOT_API bool BeginDragDropTargetAxis(ImAxis axis); + m.def( + "BeginDragDropTargetAxis", + [](ImAxis axis) { + return ImPlot::BeginDragDropTargetAxis(axis); + }, + nb::arg("axis") + ); + + // IMPLOT_API bool BeginDragDropTargetLegend(); + m.def( + "BeginDragDropTargetLegend", + []() { + return ImPlot::BeginDragDropTargetLegend(); + } + ); + + // IMPLOT_API void EndDragDropTarget(); + m.def( + "EndDragDropTarget", + []() { + ImPlot::EndDragDropTarget(); + } + ); + + // IMPLOT_API bool BeginDragDropSourcePlot(ImGuiDragDropFlags flags=0); + m.def( + "BeginDragDropSourcePlot", + [](ImGuiDragDropFlags flags) { + return ImPlot::BeginDragDropSourcePlot(flags); + }, + nb::arg("flags") = 0 + ); + + // IMPLOT_API bool BeginDragDropSourceAxis(ImAxis axis, ImGuiDragDropFlags flags=0); + m.def( + "BeginDragDropSourceAxis", + [](ImAxis axis, ImGuiDragDropFlags flags) { + return ImPlot::BeginDragDropSourceAxis(axis, flags); + }, + nb::arg("axis"), + nb::arg("flags") = 0 + ); + + // IMPLOT_API bool BeginDragDropSourceItem(const char* label_id, ImGuiDragDropFlags flags=0); + m.def( + "BeginDragDropSourceItem", + [](const char* label_id, ImGuiDragDropFlags flags) { + return ImPlot::BeginDragDropSourceItem(label_id, flags); + }, + nb::arg("label_id"), + nb::arg("flags") = 0 + ); + + // IMPLOT_API void EndDragDropSource(); + m.def( + "EndDragDropSource", + []() { + ImPlot::EndDragDropSource(); + } + ); + + //----------------------------------------------------------------------------- + // [SECTION] Styling + //----------------------------------------------------------------------------- + + // IMPLOT_API ImPlotStyle& GetStyle(); + m.def( + "GetStyle", + []() -> ImPlotStyle& { + return ImPlot::GetStyle(); + }, + nb::rv_policy::reference + ); + + // IMPLOT_API void StyleColorsAuto(ImPlotStyle* dst = nullptr); + m.def( + "StyleColorsAuto", + [](ImPlotStyle* dst) { + ImPlot::StyleColorsAuto(dst); + }, + nb::arg("dst") = nullptr + ); + + // IMPLOT_API void StyleColorsClassic(ImPlotStyle* dst = nullptr); + m.def( + "StyleColorsClassic", + [](ImPlotStyle* dst) { + ImPlot::StyleColorsClassic(dst); + }, + nb::arg("dst") = nullptr + ); + + // IMPLOT_API void StyleColorsDark(ImPlotStyle* dst = nullptr); + m.def( + "StyleColorsDark", + [](ImPlotStyle* dst) { + ImPlot::StyleColorsDark(dst); + }, + nb::arg("dst") = nullptr + ); + + // IMPLOT_API void StyleColorsLight(ImPlotStyle* dst = nullptr); + m.def( + "StyleColorsLight", + [](ImPlotStyle* dst) { + ImPlot::StyleColorsLight(dst); + }, + nb::arg("dst") = nullptr + ); + + // IMPLOT_API void PushStyleColor(ImPlotCol idx, ImU32 col); + m.def( + "PushStyleColor", + [](ImPlotCol idx, ImU32 col) { + ImPlot::PushStyleColor(idx, col); + }, + nb::arg("idx"), + nb::arg("col") + ); + + // IMPLOT_API void PushStyleColor(ImPlotCol idx, const ImVec4& col); + m.def( + "PushStyleColor", + [](ImPlotCol idx, const Vec4T& col) { + ImPlot::PushStyleColor(idx, to_vec4(col)); + }, + nb::arg("idx"), + nb::arg("col") + ); + + // IMPLOT_API void PopStyleColor(int count = 1); + m.def( + "PopStyleColor", + [](int count) { + ImPlot::PopStyleColor(count); + }, + nb::arg("count") = 1 + ); + + // IMPLOT_API void PushStyleVar(ImPlotStyleVar idx, float val); + m.def( + "PushStyleVar", + [](ImPlotStyleVar idx, float val) { + ImPlot::PushStyleVar(idx, val); + }, + nb::arg("idx"), + nb::arg("val") + ); + + // IMPLOT_API void PushStyleVar(ImPlotStyleVar idx, int val); + m.def( + "PushStyleVar", + [](ImPlotStyleVar idx, int val) { + ImPlot::PushStyleVar(idx, val); + }, + nb::arg("idx"), + nb::arg("val") + ); + + // IMPLOT_API void PushStyleVar(ImPlotStyleVar idx, const ImVec2& val); + m.def( + "PushStyleVar", + [](ImPlotStyleVar idx, const Vec2T& val) { + ImPlot::PushStyleVar(idx, to_vec2(val)); + }, + nb::arg("idx"), + nb::arg("val") + ); + + // IMPLOT_API void PopStyleVar(int count = 1); + m.def( + "PopStyleVar", + [](int count) { + ImPlot::PopStyleVar(count); + }, + nb::arg("count") = 1 + ); + + // IMPLOT_API void SetNextLineStyle(const ImVec4& col = IMPLOT_AUTO_COL, float weight = IMPLOT_AUTO); + m.def( + "SetNextLineStyle", + [](const Vec4T& col, float weight) { + ImPlot::SetNextLineStyle(to_vec4(col), weight); + }, + nb::arg("col") = Vec4T(0.f, 0.f, 0.f, -1.f), // IMPLOT_AUTO_COL + nb::arg("weight") = -1.f // IMPLOT_AUTO + ); + + // IMPLOT_API void SetNextFillStyle(const ImVec4& col = IMPLOT_AUTO_COL, float alpha_mod = IMPLOT_AUTO); + m.def( + "SetNextFillStyle", + [](const Vec4T& col, float alpha_mod) { + ImPlot::SetNextFillStyle(to_vec4(col), alpha_mod); + }, + nb::arg("col") = Vec4T(0.f, 0.f, 0.f, -1.f), // IMPLOT_AUTO_COL + nb::arg("alpha_mod") = -1.f // IMPLOT_AUTO + ); + + // IMPLOT_API void SetNextMarkerStyle(ImPlotMarker marker = IMPLOT_AUTO, float size = IMPLOT_AUTO, const ImVec4& fill = IMPLOT_AUTO_COL, float weight = IMPLOT_AUTO, const ImVec4& outline = IMPLOT_AUTO_COL); + m.def( + "SetNextMarkerStyle", + [](ImPlotMarker marker, float size, const Vec4T& fill, float weight, const Vec4T& outline) { + ImPlot::SetNextMarkerStyle(marker, size, to_vec4(fill), weight, to_vec4(outline)); + }, + nb::arg("marker") = -1, // IMPLOT_AUTO + nb::arg("size") = -1.f, // IMPLOT_AUTO + nb::arg("fill") = Vec4T(0.f, 0.f, 0.f, -1.f), // IMPLOT_AUTO_COL + nb::arg("weight") = -1.f, // IMPLOT_AUTO + nb::arg("outline") = Vec4T(0.f, 0.f, 0.f, -1.f) // IMPLOT_AUTO_COL + ); + + // IMPLOT_API void SetNextErrorBarStyle(const ImVec4& col = IMPLOT_AUTO_COL, float size = IMPLOT_AUTO, float weight = IMPLOT_AUTO); + m.def( + "SetNextErrorBarStyle", + [](const Vec4T& col, float size, float weight) { + ImPlot::SetNextErrorBarStyle(to_vec4(col), size, weight); + }, + nb::arg("col") = Vec4T(0.f, 0.f, 0.f, -1.f), // IMPLOT_AUTO_COL + nb::arg("size") = -1.f, // IMPLOT_AUTO + nb::arg("weight") = -1.f // IMPLOT_AUTO + ); + + // IMPLOT_API ImVec4 GetLastItemColor(); + m.def( + "GetLastItemColor", + []() { + return from_vec4(ImPlot::GetLastItemColor()); + } + ); + + // IMPLOT_API const char* GetStyleColorName(ImPlotCol idx); + m.def( + "GetStyleColorName", + [](ImPlotCol idx) { + return ImPlot::GetStyleColorName(idx); + }, + nb::arg("idx") + ); + + // IMPLOT_API const char* GetMarkerName(ImPlotMarker idx); + m.def( + "GetMarkerName", + [](ImPlotMarker idx) { + return ImPlot::GetMarkerName(idx); + }, + nb::arg("idx") + ); + + //----------------------------------------------------------------------------- + // [SECTION] Colormaps + //----------------------------------------------------------------------------- + + // IMPLOT_API ImPlotColormap AddColormap(const char* name, const ImVec4* cols, int size, bool qual=true); + m.def( + "AddColormap", + [](const char* name, const std::vector& cols, bool qual) { + std::vector imcols; + imcols.reserve(cols.size()); + for(const auto& c : cols) { + imcols.push_back(to_vec4(c)); + } + return ImPlot::AddColormap(name, imcols.data(), imcols.size(), qual); + }, + nb::arg("name"), + nb::arg("cols"), + nb::arg("qual") = true + ); + + // IMPLOT_API int GetColormapCount(); + m.def( + "GetColormapCount", + []() { + return ImPlot::GetColormapCount(); + } + ); + + // IMPLOT_API const char* GetColormapName(ImPlotColormap cmap); + m.def( + "GetColormapName", + [](ImPlotColormap cmap) { + return ImPlot::GetColormapName(cmap); + }, + nb::arg("cmap") + ); + + // IMPLOT_API ImPlotColormap GetColormapIndex(const char* name); + m.def( + "GetColormapIndex", + [](const char* name) { + return ImPlot::GetColormapIndex(name); + }, + nb::arg("name") + ); + + // IMPLOT_API void PushColormap(ImPlotColormap cmap); + m.def( + "PushColormap", + [](ImPlotColormap cmap) { + ImPlot::PushColormap(cmap); + }, + nb::arg("cmap") + ); + + // IMPLOT_API void PushColormap(const char* name); + m.def( + "PushColormap", + [](const char* name) { + ImPlot::PushColormap(name); + }, + nb::arg("name") + ); + + // IMPLOT_API void PopColormap(int count = 1); + m.def( + "PopColormap", + [](int count) { + ImPlot::PopColormap(count); + }, + nb::arg("count") = 1 + ); + + // IMPLOT_API ImVec4 NextColormapColor(); + m.def( + "NextColormapColor", + []() { + return from_vec4(ImPlot::NextColormapColor()); + } + ); + + // IMPLOT_API int GetColormapSize(ImPlotColormap cmap = IMPLOT_AUTO); + m.def( + "GetColormapSize", + [](ImPlotColormap cmap) { + return ImPlot::GetColormapSize(cmap); + }, + nb::arg("cmap") = IMPLOT_AUTO + ); + + // IMPLOT_API ImVec4 GetColormapColor(int idx, ImPlotColormap cmap = IMPLOT_AUTO); + m.def( + "GetColormapColor", + [](int idx, ImPlotColormap cmap) { + return from_vec4(ImPlot::GetColormapColor(idx, cmap)); + }, + nb::arg("idx"), + nb::arg("cmap") = IMPLOT_AUTO + ); + + // IMPLOT_API ImVec4 SampleColormap(float t, ImPlotColormap cmap = IMPLOT_AUTO); + m.def( + "SampleColormap", + [](float t, ImPlotColormap cmap) { + return from_vec4(ImPlot::SampleColormap(t, cmap)); + }, + nb::arg("t"), + nb::arg("cmap") = IMPLOT_AUTO + ); + + // IMPLOT_API void ColormapScale(const char* label, double scale_min, double scale_max, const ImVec2& size = ImVec2(0,0), const char* format = "%g", ImPlotColormapScaleFlags flags = 0, ImPlotColormap cmap = IMPLOT_AUTO); + m.def( + "ColormapScale", + [](const char* label, double scale_min, double scale_max, const Vec2T& size, const char* format, ImPlotColormapScaleFlags flags, ImPlotColormap cmap) { + ImPlot::ColormapScale(label, scale_min, scale_max, to_vec2(size), format, flags, cmap); + }, + nb::arg("label"), + nb::arg("scale_min"), + nb::arg("scale_max"), + nb::arg("size") = Vec2T(0.f, 0.f), + nb::arg("format") = "%g", + nb::arg("flags") = 0, + nb::arg("cmap") = IMPLOT_AUTO + ); + + // IMPLOT_API bool ColormapSlider(const char* label, float* t, ImVec4* out = nullptr, const char* format = "", ImPlotColormap cmap = IMPLOT_AUTO); + m.def( + "ColormapSlider", + [](const char* label, float t, const char* format, ImPlotColormap cmap) { + ImVec4 out; + bool result = ImPlot::ColormapSlider(label, &t, &out, format, cmap); + return std::make_tuple(result, t, from_vec4(out)); + }, + nb::arg("label"), + nb::arg("t"), + nb::arg("format") = "", + nb::arg("cmap") = IMPLOT_AUTO + ); + + // IMPLOT_API bool ColormapButton(const char* label, const ImVec2& size = ImVec2(0,0), ImPlotColormap cmap = IMPLOT_AUTO); + m.def( + "ColormapButton", + [](const char* label, const Vec2T& size, ImPlotColormap cmap) { + return ImPlot::ColormapButton(label, to_vec2(size), cmap); + }, + nb::arg("label"), + nb::arg("size") = Vec2T(0.f, 0.f), + nb::arg("cmap") = IMPLOT_AUTO + ); + + // IMPLOT_API void BustColorCache(const char* plot_title_id = nullptr); + m.def( + "BustColorCache", + [](const char* plot_title_id) { + ImPlot::BustColorCache(plot_title_id); + }, + nb::arg("plot_title_id") = nullptr + ); + + //----------------------------------------------------------------------------- + // [SECTION] Input Mapping + //----------------------------------------------------------------------------- + + // IMPLOT_API ImPlotInputMap& GetInputMap(); + m.def( + "GetInputMap", + []() -> ImPlotInputMap& { + return ImPlot::GetInputMap(); + }, + nb::rv_policy::reference + ); + + // IMPLOT_API void MapInputDefault(ImPlotInputMap* dst = nullptr); + m.def( + "MapInputDefault", + [](ImPlotInputMap* dst) { + ImPlot::MapInputDefault(dst); + }, + nb::arg("dst") = nullptr + ); + + // IMPLOT_API void MapInputReverse(ImPlotInputMap* dst = nullptr); + m.def( + "MapInputReverse", + [](ImPlotInputMap* dst) { + ImPlot::MapInputReverse(dst); + }, + nb::arg("dst") = nullptr + ); + + //----------------------------------------------------------------------------- + // [SECTION] Miscellaneous + //----------------------------------------------------------------------------- + + // IMPLOT_API void ItemIcon(const ImVec4& col); + m.def( + "ItemIcon", + [](const Vec4T& col) { + ImPlot::ItemIcon(to_vec4(col)); + }, + nb::arg("col") + ); + + // IMPLOT_API void ItemIcon(ImU32 col); + m.def( + "ItemIcon", + [](ImU32 col) { + ImPlot::ItemIcon(col); + }, + nb::arg("col") + ); + + // IMPLOT_API void ColormapIcon(ImPlotColormap cmap); + m.def( + "ColormapIcon", + [](ImPlotColormap cmap) { + ImPlot::ColormapIcon(cmap); + }, + nb::arg("cmap") + ); + + // IMPLOT_API ImDrawList* GetPlotDrawList(); + m.def( + "GetPlotDrawList", + []() -> ImDrawList* { + return ImPlot::GetPlotDrawList(); + }, + nb::rv_policy::reference + ); + + // IMPLOT_API void PushPlotClipRect(float expand=0); + m.def( + "PushPlotClipRect", + [](float expand) { + ImPlot::PushPlotClipRect(expand); + }, + nb::arg("expand") = 0.f + ); + + // IMPLOT_API void PopPlotClipRect(); + m.def( + "PopPlotClipRect", + []() { + ImPlot::PopPlotClipRect(); + } + ); + + // IMPLOT_API bool ShowStyleSelector(const char* label); + m.def( + "ShowStyleSelector", + [](const char* label) { + return ImPlot::ShowStyleSelector(label); + }, + nb::arg("label") + ); + + // IMPLOT_API bool ShowColormapSelector(const char* label); + m.def( + "ShowColormapSelector", + [](const char* label) { + return ImPlot::ShowColormapSelector(label); + }, + nb::arg("label") + ); + + // IMPLOT_API bool ShowInputMapSelector(const char* label); + m.def( + "ShowInputMapSelector", + [](const char* label) { + return ImPlot::ShowInputMapSelector(label); + }, + nb::arg("label") + ); + + // IMPLOT_API void ShowStyleEditor(ImPlotStyle* ref = nullptr); + m.def( + "ShowStyleEditor", + [](ImPlotStyle* ref) { + ImPlot::ShowStyleEditor(ref); + }, + nb::arg("ref") = nullptr + ); + + // IMPLOT_API void ShowUserGuide(); + m.def( + "ShowUserGuide", + []() { + ImPlot::ShowUserGuide(); + } + ); + + // IMPLOT_API void ShowMetricsWindow(bool* p_popen = nullptr); + m.def( + "ShowMetricsWindow", + [](bool p_open) { + ImPlot::ShowMetricsWindow(&p_open); + return p_open; + }, + nb::arg("p_open") = true + ); + + // IMPLOT_API void ShowDemoWindow(bool* p_open = nullptr); + // (commented out because we don't currently compile the demo source file) + // m.def( + // "ShowDemoWindow", + // [](bool p_open) { + // ImPlot::ShowDemoWindow(&p_open); + // return p_open; + // }, + // nb::arg("p_open") = true + // ); + +} + +void bind_implot_enums(nb::module_& m) { + + { // ImAxis ImAxis + auto e = nb::enum_(m, "ImAxis"); + e.value("ImAxis_X1", ImAxis_X1); m.attr("ImAxis_X1") = static_cast(ImAxis_X1); + e.value("ImAxis_X2", ImAxis_X2); m.attr("ImAxis_X2") = static_cast(ImAxis_X2); + e.value("ImAxis_X3", ImAxis_X3); m.attr("ImAxis_X3") = static_cast(ImAxis_X3); + e.value("ImAxis_Y1", ImAxis_Y1); m.attr("ImAxis_Y1") = static_cast(ImAxis_Y1); + e.value("ImAxis_Y2", ImAxis_Y2); m.attr("ImAxis_Y2") = static_cast(ImAxis_Y2); + e.value("ImAxis_Y3", ImAxis_Y3); m.attr("ImAxis_Y3") = static_cast(ImAxis_Y3); + e.value("ImAxis_COUNT", ImAxis_COUNT); m.attr("ImAxis_COUNT") = static_cast(ImAxis_COUNT); + ; + } + + { // ImPlotFlags ImPlotFlags_ + auto e = nb::enum_(m, "ImPlotFlags"); + e.value("ImPlotFlags_None", ImPlotFlags_None); m.attr("ImPlotFlags_None") = static_cast(ImPlotFlags_None); + e.value("ImPlotFlags_NoTitle", ImPlotFlags_NoTitle); m.attr("ImPlotFlags_NoTitle") = static_cast(ImPlotFlags_NoTitle); + e.value("ImPlotFlags_NoLegend", ImPlotFlags_NoLegend); m.attr("ImPlotFlags_NoLegend") = static_cast(ImPlotFlags_NoLegend); + e.value("ImPlotFlags_NoMouseText", ImPlotFlags_NoMouseText); m.attr("ImPlotFlags_NoMouseText") = static_cast(ImPlotFlags_NoMouseText); + e.value("ImPlotFlags_NoInputs", ImPlotFlags_NoInputs); m.attr("ImPlotFlags_NoInputs") = static_cast(ImPlotFlags_NoInputs); + e.value("ImPlotFlags_NoMenus", ImPlotFlags_NoMenus); m.attr("ImPlotFlags_NoMenus") = static_cast(ImPlotFlags_NoMenus); + e.value("ImPlotFlags_NoBoxSelect", ImPlotFlags_NoBoxSelect); m.attr("ImPlotFlags_NoBoxSelect") = static_cast(ImPlotFlags_NoBoxSelect); + e.value("ImPlotFlags_NoFrame", ImPlotFlags_NoFrame); m.attr("ImPlotFlags_NoFrame") = static_cast(ImPlotFlags_NoFrame); + e.value("ImPlotFlags_Equal", ImPlotFlags_Equal); m.attr("ImPlotFlags_Equal") = static_cast(ImPlotFlags_Equal); + e.value("ImPlotFlags_Crosshairs", ImPlotFlags_Crosshairs); m.attr("ImPlotFlags_Crosshairs") = static_cast(ImPlotFlags_Crosshairs); + e.value("ImPlotFlags_CanvasOnly", ImPlotFlags_CanvasOnly); m.attr("ImPlotFlags_CanvasOnly") = static_cast(ImPlotFlags_CanvasOnly); + ; + } + + { // ImPlotAxisFlags ImPlotAxisFlags_ + auto e = nb::enum_(m, "ImPlotAxisFlags"); + e.value("ImPlotAxisFlags_None", ImPlotAxisFlags_None); m.attr("ImPlotAxisFlags_None") = static_cast(ImPlotAxisFlags_None); + e.value("ImPlotAxisFlags_NoLabel", ImPlotAxisFlags_NoLabel); m.attr("ImPlotAxisFlags_NoLabel") = static_cast(ImPlotAxisFlags_NoLabel); + e.value("ImPlotAxisFlags_NoGridLines", ImPlotAxisFlags_NoGridLines); m.attr("ImPlotAxisFlags_NoGridLines") = static_cast(ImPlotAxisFlags_NoGridLines); + e.value("ImPlotAxisFlags_NoTickMarks", ImPlotAxisFlags_NoTickMarks); m.attr("ImPlotAxisFlags_NoTickMarks") = static_cast(ImPlotAxisFlags_NoTickMarks); + e.value("ImPlotAxisFlags_NoTickLabels", ImPlotAxisFlags_NoTickLabels); m.attr("ImPlotAxisFlags_NoTickLabels") = static_cast(ImPlotAxisFlags_NoTickLabels); + e.value("ImPlotAxisFlags_NoInitialFit", ImPlotAxisFlags_NoInitialFit); m.attr("ImPlotAxisFlags_NoInitialFit") = static_cast(ImPlotAxisFlags_NoInitialFit); + e.value("ImPlotAxisFlags_NoMenus", ImPlotAxisFlags_NoMenus); m.attr("ImPlotAxisFlags_NoMenus") = static_cast(ImPlotAxisFlags_NoMenus); + e.value("ImPlotAxisFlags_NoSideSwitch", ImPlotAxisFlags_NoSideSwitch); m.attr("ImPlotAxisFlags_NoSideSwitch") = static_cast(ImPlotAxisFlags_NoSideSwitch); + e.value("ImPlotAxisFlags_NoHighlight", ImPlotAxisFlags_NoHighlight); m.attr("ImPlotAxisFlags_NoHighlight") = static_cast(ImPlotAxisFlags_NoHighlight); + e.value("ImPlotAxisFlags_Opposite", ImPlotAxisFlags_Opposite); m.attr("ImPlotAxisFlags_Opposite") = static_cast(ImPlotAxisFlags_Opposite); + e.value("ImPlotAxisFlags_Foreground", ImPlotAxisFlags_Foreground); m.attr("ImPlotAxisFlags_Foreground") = static_cast(ImPlotAxisFlags_Foreground); + e.value("ImPlotAxisFlags_Invert", ImPlotAxisFlags_Invert); m.attr("ImPlotAxisFlags_Invert") = static_cast(ImPlotAxisFlags_Invert); + e.value("ImPlotAxisFlags_AutoFit", ImPlotAxisFlags_AutoFit); m.attr("ImPlotAxisFlags_AutoFit") = static_cast(ImPlotAxisFlags_AutoFit); + e.value("ImPlotAxisFlags_RangeFit", ImPlotAxisFlags_RangeFit); m.attr("ImPlotAxisFlags_RangeFit") = static_cast(ImPlotAxisFlags_RangeFit); + e.value("ImPlotAxisFlags_PanStretch", ImPlotAxisFlags_PanStretch); m.attr("ImPlotAxisFlags_PanStretch") = static_cast(ImPlotAxisFlags_PanStretch); + e.value("ImPlotAxisFlags_LockMin", ImPlotAxisFlags_LockMin); m.attr("ImPlotAxisFlags_LockMin") = static_cast(ImPlotAxisFlags_LockMin); + e.value("ImPlotAxisFlags_LockMax", ImPlotAxisFlags_LockMax); m.attr("ImPlotAxisFlags_LockMax") = static_cast(ImPlotAxisFlags_LockMax); + e.value("ImPlotAxisFlags_Lock", ImPlotAxisFlags_Lock); m.attr("ImPlotAxisFlags_Lock") = static_cast(ImPlotAxisFlags_Lock); + e.value("ImPlotAxisFlags_NoDecorations", ImPlotAxisFlags_NoDecorations); m.attr("ImPlotAxisFlags_NoDecorations") = static_cast(ImPlotAxisFlags_NoDecorations); + e.value("ImPlotAxisFlags_AuxDefault", ImPlotAxisFlags_AuxDefault); m.attr("ImPlotAxisFlags_AuxDefault") = static_cast(ImPlotAxisFlags_AuxDefault); + ; + } + + { // ImPlotSubplotFlags ImPlotSubplotFlags_ + auto e = nb::enum_(m, "ImPlotSubplotFlags"); + e.value("ImPlotSubplotFlags_None", ImPlotSubplotFlags_None); m.attr("ImPlotSubplotFlags_None") = static_cast(ImPlotSubplotFlags_None); + e.value("ImPlotSubplotFlags_NoTitle", ImPlotSubplotFlags_NoTitle); m.attr("ImPlotSubplotFlags_NoTitle") = static_cast(ImPlotSubplotFlags_NoTitle); + e.value("ImPlotSubplotFlags_NoLegend", ImPlotSubplotFlags_NoLegend); m.attr("ImPlotSubplotFlags_NoLegend") = static_cast(ImPlotSubplotFlags_NoLegend); + e.value("ImPlotSubplotFlags_NoMenus", ImPlotSubplotFlags_NoMenus); m.attr("ImPlotSubplotFlags_NoMenus") = static_cast(ImPlotSubplotFlags_NoMenus); + e.value("ImPlotSubplotFlags_NoResize", ImPlotSubplotFlags_NoResize); m.attr("ImPlotSubplotFlags_NoResize") = static_cast(ImPlotSubplotFlags_NoResize); + e.value("ImPlotSubplotFlags_NoAlign", ImPlotSubplotFlags_NoAlign); m.attr("ImPlotSubplotFlags_NoAlign") = static_cast(ImPlotSubplotFlags_NoAlign); + e.value("ImPlotSubplotFlags_ShareItems", ImPlotSubplotFlags_ShareItems); m.attr("ImPlotSubplotFlags_ShareItems") = static_cast(ImPlotSubplotFlags_ShareItems); + e.value("ImPlotSubplotFlags_LinkRows", ImPlotSubplotFlags_LinkRows); m.attr("ImPlotSubplotFlags_LinkRows") = static_cast(ImPlotSubplotFlags_LinkRows); + e.value("ImPlotSubplotFlags_LinkCols", ImPlotSubplotFlags_LinkCols); m.attr("ImPlotSubplotFlags_LinkCols") = static_cast(ImPlotSubplotFlags_LinkCols); + e.value("ImPlotSubplotFlags_LinkAllX", ImPlotSubplotFlags_LinkAllX); m.attr("ImPlotSubplotFlags_LinkAllX") = static_cast(ImPlotSubplotFlags_LinkAllX); + e.value("ImPlotSubplotFlags_LinkAllY", ImPlotSubplotFlags_LinkAllY); m.attr("ImPlotSubplotFlags_LinkAllY") = static_cast(ImPlotSubplotFlags_LinkAllY); + e.value("ImPlotSubplotFlags_ColMajor", ImPlotSubplotFlags_ColMajor); m.attr("ImPlotSubplotFlags_ColMajor") = static_cast(ImPlotSubplotFlags_ColMajor); + ; + } + + { // ImPlotLegendFlags ImPlotLegendFlags_ + auto e = nb::enum_(m, "ImPlotLegendFlags"); + e.value("ImPlotLegendFlags_None", ImPlotLegendFlags_None); m.attr("ImPlotLegendFlags_None") = static_cast(ImPlotLegendFlags_None); + e.value("ImPlotLegendFlags_NoButtons", ImPlotLegendFlags_NoButtons); m.attr("ImPlotLegendFlags_NoButtons") = static_cast(ImPlotLegendFlags_NoButtons); + e.value("ImPlotLegendFlags_NoHighlightItem", ImPlotLegendFlags_NoHighlightItem); m.attr("ImPlotLegendFlags_NoHighlightItem") = static_cast(ImPlotLegendFlags_NoHighlightItem); + e.value("ImPlotLegendFlags_NoHighlightAxis", ImPlotLegendFlags_NoHighlightAxis); m.attr("ImPlotLegendFlags_NoHighlightAxis") = static_cast(ImPlotLegendFlags_NoHighlightAxis); + e.value("ImPlotLegendFlags_NoMenus", ImPlotLegendFlags_NoMenus); m.attr("ImPlotLegendFlags_NoMenus") = static_cast(ImPlotLegendFlags_NoMenus); + e.value("ImPlotLegendFlags_Outside", ImPlotLegendFlags_Outside); m.attr("ImPlotLegendFlags_Outside") = static_cast(ImPlotLegendFlags_Outside); + e.value("ImPlotLegendFlags_Horizontal", ImPlotLegendFlags_Horizontal); m.attr("ImPlotLegendFlags_Horizontal") = static_cast(ImPlotLegendFlags_Horizontal); + e.value("ImPlotLegendFlags_Sort", ImPlotLegendFlags_Sort); m.attr("ImPlotLegendFlags_Sort") = static_cast(ImPlotLegendFlags_Sort); + ; + } + + { // ImPlotMouseTextFlags ImPlotMouseTextFlags_ + auto e = nb::enum_(m, "ImPlotMouseTextFlags"); + e.value("ImPlotMouseTextFlags_None", ImPlotMouseTextFlags_None); m.attr("ImPlotMouseTextFlags_None") = static_cast(ImPlotMouseTextFlags_None); + e.value("ImPlotMouseTextFlags_NoAuxAxes", ImPlotMouseTextFlags_NoAuxAxes); m.attr("ImPlotMouseTextFlags_NoAuxAxes") = static_cast(ImPlotMouseTextFlags_NoAuxAxes); + e.value("ImPlotMouseTextFlags_NoFormat", ImPlotMouseTextFlags_NoFormat); m.attr("ImPlotMouseTextFlags_NoFormat") = static_cast(ImPlotMouseTextFlags_NoFormat); + e.value("ImPlotMouseTextFlags_ShowAlways", ImPlotMouseTextFlags_ShowAlways); m.attr("ImPlotMouseTextFlags_ShowAlways") = static_cast(ImPlotMouseTextFlags_ShowAlways); + ; + } + + { // ImPlotDragToolFlags ImPlotDragToolFlags_ + auto e = nb::enum_(m, "ImPlotDragToolFlags"); + e.value("ImPlotDragToolFlags_None", ImPlotDragToolFlags_None); m.attr("ImPlotDragToolFlags_None") = static_cast(ImPlotDragToolFlags_None); + e.value("ImPlotDragToolFlags_NoCursors", ImPlotDragToolFlags_NoCursors); m.attr("ImPlotDragToolFlags_NoCursors") = static_cast(ImPlotDragToolFlags_NoCursors); + e.value("ImPlotDragToolFlags_NoFit", ImPlotDragToolFlags_NoFit); m.attr("ImPlotDragToolFlags_NoFit") = static_cast(ImPlotDragToolFlags_NoFit); + e.value("ImPlotDragToolFlags_NoInputs", ImPlotDragToolFlags_NoInputs); m.attr("ImPlotDragToolFlags_NoInputs") = static_cast(ImPlotDragToolFlags_NoInputs); + e.value("ImPlotDragToolFlags_Delayed", ImPlotDragToolFlags_Delayed); m.attr("ImPlotDragToolFlags_Delayed") = static_cast(ImPlotDragToolFlags_Delayed); + ; + } + + { // ImPlotColormapScaleFlags ImPlotColormapScaleFlags_ + auto e = nb::enum_(m, "ImPlotColormapScaleFlags"); + e.value("ImPlotColormapScaleFlags_None", ImPlotColormapScaleFlags_None); m.attr("ImPlotColormapScaleFlags_None") = static_cast(ImPlotColormapScaleFlags_None); + e.value("ImPlotColormapScaleFlags_NoLabel", ImPlotColormapScaleFlags_NoLabel); m.attr("ImPlotColormapScaleFlags_NoLabel") = static_cast(ImPlotColormapScaleFlags_NoLabel); + e.value("ImPlotColormapScaleFlags_Opposite", ImPlotColormapScaleFlags_Opposite); m.attr("ImPlotColormapScaleFlags_Opposite") = static_cast(ImPlotColormapScaleFlags_Opposite); + e.value("ImPlotColormapScaleFlags_Invert", ImPlotColormapScaleFlags_Invert); m.attr("ImPlotColormapScaleFlags_Invert") = static_cast(ImPlotColormapScaleFlags_Invert); + ; + } + + { // ImPlotItemFlags ImPlotItemFlags_ + auto e = nb::enum_(m, "ImPlotItemFlags"); + e.value("ImPlotItemFlags_None", ImPlotItemFlags_None); m.attr("ImPlotItemFlags_None") = static_cast(ImPlotItemFlags_None); + e.value("ImPlotItemFlags_NoLegend", ImPlotItemFlags_NoLegend); m.attr("ImPlotItemFlags_NoLegend") = static_cast(ImPlotItemFlags_NoLegend); + e.value("ImPlotItemFlags_NoFit", ImPlotItemFlags_NoFit); m.attr("ImPlotItemFlags_NoFit") = static_cast(ImPlotItemFlags_NoFit); + ; + } + + { // ImPlotLineFlags ImPlotLineFlags_ + auto e = nb::enum_(m, "ImPlotLineFlags"); + e.value("ImPlotLineFlags_None", ImPlotLineFlags_None); m.attr("ImPlotLineFlags_None") = static_cast(ImPlotLineFlags_None); + e.value("ImPlotLineFlags_Segments", ImPlotLineFlags_Segments); m.attr("ImPlotLineFlags_Segments") = static_cast(ImPlotLineFlags_Segments); + e.value("ImPlotLineFlags_Loop", ImPlotLineFlags_Loop); m.attr("ImPlotLineFlags_Loop") = static_cast(ImPlotLineFlags_Loop); + e.value("ImPlotLineFlags_SkipNaN", ImPlotLineFlags_SkipNaN); m.attr("ImPlotLineFlags_SkipNaN") = static_cast(ImPlotLineFlags_SkipNaN); + e.value("ImPlotLineFlags_NoClip", ImPlotLineFlags_NoClip); m.attr("ImPlotLineFlags_NoClip") = static_cast(ImPlotLineFlags_NoClip); + e.value("ImPlotLineFlags_Shaded", ImPlotLineFlags_Shaded); m.attr("ImPlotLineFlags_Shaded") = static_cast(ImPlotLineFlags_Shaded); + ; + } + + { // ImPlotScatterFlags ImPlotScatterFlags_ + auto e = nb::enum_(m, "ImPlotScatterFlags"); + e.value("ImPlotScatterFlags_None", ImPlotScatterFlags_None); m.attr("ImPlotScatterFlags_None") = static_cast(ImPlotScatterFlags_None); + e.value("ImPlotScatterFlags_NoClip", ImPlotScatterFlags_NoClip); m.attr("ImPlotScatterFlags_NoClip") = static_cast(ImPlotScatterFlags_NoClip); + ; + } + + { // ImPlotStairsFlags ImPlotStairsFlags_ + auto e = nb::enum_(m, "ImPlotStairsFlags"); + e.value("ImPlotStairsFlags_None", ImPlotStairsFlags_None); m.attr("ImPlotStairsFlags_None") = static_cast(ImPlotStairsFlags_None); + e.value("ImPlotStairsFlags_PreStep", ImPlotStairsFlags_PreStep); m.attr("ImPlotStairsFlags_PreStep") = static_cast(ImPlotStairsFlags_PreStep); + e.value("ImPlotStairsFlags_Shaded", ImPlotStairsFlags_Shaded); m.attr("ImPlotStairsFlags_Shaded") = static_cast(ImPlotStairsFlags_Shaded); + ; + } + + { // ImPlotShadedFlags ImPlotShadedFlags_ + auto e = nb::enum_(m, "ImPlotShadedFlags"); + e.value("ImPlotShadedFlags_None", ImPlotShadedFlags_None); m.attr("ImPlotShadedFlags_None") = static_cast(ImPlotShadedFlags_None); + ; + } + + { // ImPlotBarsFlags ImPlotBarsFlags_ + auto e = nb::enum_(m, "ImPlotBarsFlags"); + e.value("ImPlotBarsFlags_None", ImPlotBarsFlags_None); m.attr("ImPlotBarsFlags_None") = static_cast(ImPlotBarsFlags_None); + e.value("ImPlotBarsFlags_Horizontal", ImPlotBarsFlags_Horizontal); m.attr("ImPlotBarsFlags_Horizontal") = static_cast(ImPlotBarsFlags_Horizontal); + ; + } + + { // ImPlotBarGroupsFlags ImPlotBarGroupsFlags_ + auto e = nb::enum_(m, "ImPlotBarGroupsFlags"); + e.value("ImPlotBarGroupsFlags_None", ImPlotBarGroupsFlags_None); m.attr("ImPlotBarGroupsFlags_None") = static_cast(ImPlotBarGroupsFlags_None); + e.value("ImPlotBarGroupsFlags_Horizontal", ImPlotBarGroupsFlags_Horizontal); m.attr("ImPlotBarGroupsFlags_Horizontal") = static_cast(ImPlotBarGroupsFlags_Horizontal); + e.value("ImPlotBarGroupsFlags_Stacked", ImPlotBarGroupsFlags_Stacked); m.attr("ImPlotBarGroupsFlags_Stacked") = static_cast(ImPlotBarGroupsFlags_Stacked); + ; + } + + { // ImPlotErrorBarsFlags ImPlotErrorBarsFlags_ + auto e = nb::enum_(m, "ImPlotErrorBarsFlags"); + e.value("ImPlotErrorBarsFlags_None", ImPlotErrorBarsFlags_None); m.attr("ImPlotErrorBarsFlags_None") = static_cast(ImPlotErrorBarsFlags_None); + e.value("ImPlotErrorBarsFlags_Horizontal", ImPlotErrorBarsFlags_Horizontal); m.attr("ImPlotErrorBarsFlags_Horizontal") = static_cast(ImPlotErrorBarsFlags_Horizontal); + ; + } + + { // ImPlotStemsFlags ImPlotStemsFlags_ + auto e = nb::enum_(m, "ImPlotStemsFlags"); + e.value("ImPlotStemsFlags_None", ImPlotStemsFlags_None); m.attr("ImPlotStemsFlags_None") = static_cast(ImPlotStemsFlags_None); + e.value("ImPlotStemsFlags_Horizontal", ImPlotStemsFlags_Horizontal); m.attr("ImPlotStemsFlags_Horizontal") = static_cast(ImPlotStemsFlags_Horizontal); + ; + } + + { // ImPlotInfLinesFlags ImPlotInfLinesFlags_ + auto e = nb::enum_(m, "ImPlotInfLinesFlags"); + e.value("ImPlotInfLinesFlags_None", ImPlotInfLinesFlags_None); m.attr("ImPlotInfLinesFlags_None") = static_cast(ImPlotInfLinesFlags_None); + e.value("ImPlotInfLinesFlags_Horizontal", ImPlotInfLinesFlags_Horizontal); m.attr("ImPlotInfLinesFlags_Horizontal") = static_cast(ImPlotInfLinesFlags_Horizontal); + ; + } + + { // ImPlotPieChartFlags ImPlotPieChartFlags_ + auto e = nb::enum_(m, "ImPlotPieChartFlags"); + e.value("ImPlotPieChartFlags_None", ImPlotPieChartFlags_None); m.attr("ImPlotPieChartFlags_None") = static_cast(ImPlotPieChartFlags_None); + e.value("ImPlotPieChartFlags_Normalize", ImPlotPieChartFlags_Normalize); m.attr("ImPlotPieChartFlags_Normalize") = static_cast(ImPlotPieChartFlags_Normalize); + e.value("ImPlotPieChartFlags_IgnoreHidden", ImPlotPieChartFlags_IgnoreHidden); m.attr("ImPlotPieChartFlags_IgnoreHidden") = static_cast(ImPlotPieChartFlags_IgnoreHidden); + e.value("ImPlotPieChartFlags_Exploding", ImPlotPieChartFlags_Exploding); m.attr("ImPlotPieChartFlags_Exploding") = static_cast(ImPlotPieChartFlags_Exploding); + ; + } + + { // ImPlotHeatmapFlags ImPlotHeatmapFlags_ + auto e = nb::enum_(m, "ImPlotHeatmapFlags"); + e.value("ImPlotHeatmapFlags_None", ImPlotHeatmapFlags_None); m.attr("ImPlotHeatmapFlags_None") = static_cast(ImPlotHeatmapFlags_None); + e.value("ImPlotHeatmapFlags_ColMajor", ImPlotHeatmapFlags_ColMajor); m.attr("ImPlotHeatmapFlags_ColMajor") = static_cast(ImPlotHeatmapFlags_ColMajor); + ; + } + + { // ImPlotHistogramFlags ImPlotHistogramFlags_ + auto e = nb::enum_(m, "ImPlotHistogramFlags"); + e.value("ImPlotHistogramFlags_None", ImPlotHistogramFlags_None); m.attr("ImPlotHistogramFlags_None") = static_cast(ImPlotHistogramFlags_None); + e.value("ImPlotHistogramFlags_Horizontal", ImPlotHistogramFlags_Horizontal); m.attr("ImPlotHistogramFlags_Horizontal") = static_cast(ImPlotHistogramFlags_Horizontal); + e.value("ImPlotHistogramFlags_Cumulative", ImPlotHistogramFlags_Cumulative); m.attr("ImPlotHistogramFlags_Cumulative") = static_cast(ImPlotHistogramFlags_Cumulative); + e.value("ImPlotHistogramFlags_Density", ImPlotHistogramFlags_Density); m.attr("ImPlotHistogramFlags_Density") = static_cast(ImPlotHistogramFlags_Density); + e.value("ImPlotHistogramFlags_NoOutliers", ImPlotHistogramFlags_NoOutliers); m.attr("ImPlotHistogramFlags_NoOutliers") = static_cast(ImPlotHistogramFlags_NoOutliers); + e.value("ImPlotHistogramFlags_ColMajor", ImPlotHistogramFlags_ColMajor); m.attr("ImPlotHistogramFlags_ColMajor") = static_cast(ImPlotHistogramFlags_ColMajor); + ; + } + + { // ImPlotDigitalFlags ImPlotDigitalFlags_ + auto e = nb::enum_(m, "ImPlotDigitalFlags"); + e.value("ImPlotDigitalFlags_None", ImPlotDigitalFlags_None); m.attr("ImPlotDigitalFlags_None") = static_cast(ImPlotDigitalFlags_None); + ; + } + + { // ImPlotImageFlags ImPlotImageFlags_ + auto e = nb::enum_(m, "ImPlotImageFlags"); + e.value("ImPlotImageFlags_None", ImPlotImageFlags_None); m.attr("ImPlotImageFlags_None") = static_cast(ImPlotImageFlags_None); + ; + } + + { // ImPlotTextFlags ImPlotTextFlags_ + auto e = nb::enum_(m, "ImPlotTextFlags"); + e.value("ImPlotTextFlags_None", ImPlotTextFlags_None); m.attr("ImPlotTextFlags_None") = static_cast(ImPlotTextFlags_None); + e.value("ImPlotTextFlags_Vertical", ImPlotTextFlags_Vertical); m.attr("ImPlotTextFlags_Vertical") = static_cast(ImPlotTextFlags_Vertical); + ; + } + + { // ImPlotDummyFlags ImPlotDummyFlags_ + auto e = nb::enum_(m, "ImPlotDummyFlags"); + e.value("ImPlotDummyFlags_None", ImPlotDummyFlags_None); m.attr("ImPlotDummyFlags_None") = static_cast(ImPlotDummyFlags_None); + ; + } + + { // ImPlotCond ImPlotCond_ + auto e = nb::enum_(m, "ImPlotCond"); + e.value("ImPlotCond_None", ImPlotCond_None); m.attr("ImPlotCond_None") = static_cast(ImPlotCond_None); + e.value("ImPlotCond_Always", ImPlotCond_Always); m.attr("ImPlotCond_Always") = static_cast(ImPlotCond_Always); + e.value("ImPlotCond_Once", ImPlotCond_Once); m.attr("ImPlotCond_Once") = static_cast(ImPlotCond_Once); + ; + } + + { // ImPlotCol ImPlotCol_ + auto e = nb::enum_(m, "ImPlotCol"); + e.value("ImPlotCol_Line", ImPlotCol_Line); m.attr("ImPlotCol_Line") = static_cast(ImPlotCol_Line); + e.value("ImPlotCol_Fill", ImPlotCol_Fill); m.attr("ImPlotCol_Fill") = static_cast(ImPlotCol_Fill); + e.value("ImPlotCol_MarkerOutline", ImPlotCol_MarkerOutline); m.attr("ImPlotCol_MarkerOutline") = static_cast(ImPlotCol_MarkerOutline); + e.value("ImPlotCol_MarkerFill", ImPlotCol_MarkerFill); m.attr("ImPlotCol_MarkerFill") = static_cast(ImPlotCol_MarkerFill); + e.value("ImPlotCol_ErrorBar", ImPlotCol_ErrorBar); m.attr("ImPlotCol_ErrorBar") = static_cast(ImPlotCol_ErrorBar); + e.value("ImPlotCol_FrameBg", ImPlotCol_FrameBg); m.attr("ImPlotCol_FrameBg") = static_cast(ImPlotCol_FrameBg); + e.value("ImPlotCol_PlotBg", ImPlotCol_PlotBg); m.attr("ImPlotCol_PlotBg") = static_cast(ImPlotCol_PlotBg); + e.value("ImPlotCol_PlotBorder", ImPlotCol_PlotBorder); m.attr("ImPlotCol_PlotBorder") = static_cast(ImPlotCol_PlotBorder); + e.value("ImPlotCol_LegendBg", ImPlotCol_LegendBg); m.attr("ImPlotCol_LegendBg") = static_cast(ImPlotCol_LegendBg); + e.value("ImPlotCol_LegendBorder", ImPlotCol_LegendBorder); m.attr("ImPlotCol_LegendBorder") = static_cast(ImPlotCol_LegendBorder); + e.value("ImPlotCol_LegendText", ImPlotCol_LegendText); m.attr("ImPlotCol_LegendText") = static_cast(ImPlotCol_LegendText); + e.value("ImPlotCol_TitleText", ImPlotCol_TitleText); m.attr("ImPlotCol_TitleText") = static_cast(ImPlotCol_TitleText); + e.value("ImPlotCol_InlayText", ImPlotCol_InlayText); m.attr("ImPlotCol_InlayText") = static_cast(ImPlotCol_InlayText); + e.value("ImPlotCol_AxisText", ImPlotCol_AxisText); m.attr("ImPlotCol_AxisText") = static_cast(ImPlotCol_AxisText); + e.value("ImPlotCol_AxisGrid", ImPlotCol_AxisGrid); m.attr("ImPlotCol_AxisGrid") = static_cast(ImPlotCol_AxisGrid); + e.value("ImPlotCol_AxisTick", ImPlotCol_AxisTick); m.attr("ImPlotCol_AxisTick") = static_cast(ImPlotCol_AxisTick); + e.value("ImPlotCol_AxisBg", ImPlotCol_AxisBg); m.attr("ImPlotCol_AxisBg") = static_cast(ImPlotCol_AxisBg); + e.value("ImPlotCol_AxisBgHovered", ImPlotCol_AxisBgHovered); m.attr("ImPlotCol_AxisBgHovered") = static_cast(ImPlotCol_AxisBgHovered); + e.value("ImPlotCol_AxisBgActive", ImPlotCol_AxisBgActive); m.attr("ImPlotCol_AxisBgActive") = static_cast(ImPlotCol_AxisBgActive); + e.value("ImPlotCol_Selection", ImPlotCol_Selection); m.attr("ImPlotCol_Selection") = static_cast(ImPlotCol_Selection); + e.value("ImPlotCol_Crosshairs", ImPlotCol_Crosshairs); m.attr("ImPlotCol_Crosshairs") = static_cast(ImPlotCol_Crosshairs); + e.value("ImPlotCol_COUNT", ImPlotCol_COUNT); m.attr("ImPlotCol_COUNT") = static_cast(ImPlotCol_COUNT); + ; + } + + { // ImPlotStyleVar ImPlotStyleVar_ + auto e = nb::enum_(m, "ImPlotStyleVar"); + e.value("ImPlotStyleVar_LineWeight", ImPlotStyleVar_LineWeight); m.attr("ImPlotStyleVar_LineWeight") = static_cast(ImPlotStyleVar_LineWeight); + e.value("ImPlotStyleVar_Marker", ImPlotStyleVar_Marker); m.attr("ImPlotStyleVar_Marker") = static_cast(ImPlotStyleVar_Marker); + e.value("ImPlotStyleVar_MarkerSize", ImPlotStyleVar_MarkerSize); m.attr("ImPlotStyleVar_MarkerSize") = static_cast(ImPlotStyleVar_MarkerSize); + e.value("ImPlotStyleVar_MarkerWeight", ImPlotStyleVar_MarkerWeight); m.attr("ImPlotStyleVar_MarkerWeight") = static_cast(ImPlotStyleVar_MarkerWeight); + e.value("ImPlotStyleVar_FillAlpha", ImPlotStyleVar_FillAlpha); m.attr("ImPlotStyleVar_FillAlpha") = static_cast(ImPlotStyleVar_FillAlpha); + e.value("ImPlotStyleVar_ErrorBarSize", ImPlotStyleVar_ErrorBarSize); m.attr("ImPlotStyleVar_ErrorBarSize") = static_cast(ImPlotStyleVar_ErrorBarSize); + e.value("ImPlotStyleVar_ErrorBarWeight", ImPlotStyleVar_ErrorBarWeight); m.attr("ImPlotStyleVar_ErrorBarWeight") = static_cast(ImPlotStyleVar_ErrorBarWeight); + e.value("ImPlotStyleVar_DigitalBitHeight", ImPlotStyleVar_DigitalBitHeight); m.attr("ImPlotStyleVar_DigitalBitHeight") = static_cast(ImPlotStyleVar_DigitalBitHeight); + e.value("ImPlotStyleVar_DigitalBitGap", ImPlotStyleVar_DigitalBitGap); m.attr("ImPlotStyleVar_DigitalBitGap") = static_cast(ImPlotStyleVar_DigitalBitGap); + e.value("ImPlotStyleVar_PlotBorderSize", ImPlotStyleVar_PlotBorderSize); m.attr("ImPlotStyleVar_PlotBorderSize") = static_cast(ImPlotStyleVar_PlotBorderSize); + e.value("ImPlotStyleVar_MinorAlpha", ImPlotStyleVar_MinorAlpha); m.attr("ImPlotStyleVar_MinorAlpha") = static_cast(ImPlotStyleVar_MinorAlpha); + e.value("ImPlotStyleVar_MajorTickLen", ImPlotStyleVar_MajorTickLen); m.attr("ImPlotStyleVar_MajorTickLen") = static_cast(ImPlotStyleVar_MajorTickLen); + e.value("ImPlotStyleVar_MinorTickLen", ImPlotStyleVar_MinorTickLen); m.attr("ImPlotStyleVar_MinorTickLen") = static_cast(ImPlotStyleVar_MinorTickLen); + e.value("ImPlotStyleVar_MajorTickSize", ImPlotStyleVar_MajorTickSize); m.attr("ImPlotStyleVar_MajorTickSize") = static_cast(ImPlotStyleVar_MajorTickSize); + e.value("ImPlotStyleVar_MinorTickSize", ImPlotStyleVar_MinorTickSize); m.attr("ImPlotStyleVar_MinorTickSize") = static_cast(ImPlotStyleVar_MinorTickSize); + e.value("ImPlotStyleVar_MajorGridSize", ImPlotStyleVar_MajorGridSize); m.attr("ImPlotStyleVar_MajorGridSize") = static_cast(ImPlotStyleVar_MajorGridSize); + e.value("ImPlotStyleVar_MinorGridSize", ImPlotStyleVar_MinorGridSize); m.attr("ImPlotStyleVar_MinorGridSize") = static_cast(ImPlotStyleVar_MinorGridSize); + e.value("ImPlotStyleVar_PlotPadding", ImPlotStyleVar_PlotPadding); m.attr("ImPlotStyleVar_PlotPadding") = static_cast(ImPlotStyleVar_PlotPadding); + e.value("ImPlotStyleVar_LabelPadding", ImPlotStyleVar_LabelPadding); m.attr("ImPlotStyleVar_LabelPadding") = static_cast(ImPlotStyleVar_LabelPadding); + e.value("ImPlotStyleVar_LegendPadding", ImPlotStyleVar_LegendPadding); m.attr("ImPlotStyleVar_LegendPadding") = static_cast(ImPlotStyleVar_LegendPadding); + e.value("ImPlotStyleVar_LegendInnerPadding", ImPlotStyleVar_LegendInnerPadding); m.attr("ImPlotStyleVar_LegendInnerPadding") = static_cast(ImPlotStyleVar_LegendInnerPadding); + e.value("ImPlotStyleVar_LegendSpacing", ImPlotStyleVar_LegendSpacing); m.attr("ImPlotStyleVar_LegendSpacing") = static_cast(ImPlotStyleVar_LegendSpacing); + e.value("ImPlotStyleVar_MousePosPadding", ImPlotStyleVar_MousePosPadding); m.attr("ImPlotStyleVar_MousePosPadding") = static_cast(ImPlotStyleVar_MousePosPadding); + e.value("ImPlotStyleVar_AnnotationPadding", ImPlotStyleVar_AnnotationPadding); m.attr("ImPlotStyleVar_AnnotationPadding") = static_cast(ImPlotStyleVar_AnnotationPadding); + e.value("ImPlotStyleVar_FitPadding", ImPlotStyleVar_FitPadding); m.attr("ImPlotStyleVar_FitPadding") = static_cast(ImPlotStyleVar_FitPadding); + e.value("ImPlotStyleVar_PlotDefaultSize", ImPlotStyleVar_PlotDefaultSize); m.attr("ImPlotStyleVar_PlotDefaultSize") = static_cast(ImPlotStyleVar_PlotDefaultSize); + e.value("ImPlotStyleVar_PlotMinSize", ImPlotStyleVar_PlotMinSize); m.attr("ImPlotStyleVar_PlotMinSize") = static_cast(ImPlotStyleVar_PlotMinSize); + e.value("ImPlotStyleVar_COUNT", ImPlotStyleVar_COUNT); m.attr("ImPlotStyleVar_COUNT") = static_cast(ImPlotStyleVar_COUNT); + ; + } + + { // ImPlotScale ImPlotScale_ + auto e = nb::enum_(m, "ImPlotScale"); + e.value("ImPlotScale_Linear", ImPlotScale_Linear); m.attr("ImPlotScale_Linear") = static_cast(ImPlotScale_Linear); + e.value("ImPlotScale_Time", ImPlotScale_Time); m.attr("ImPlotScale_Time") = static_cast(ImPlotScale_Time); + e.value("ImPlotScale_Log10", ImPlotScale_Log10); m.attr("ImPlotScale_Log10") = static_cast(ImPlotScale_Log10); + e.value("ImPlotScale_SymLog", ImPlotScale_SymLog); m.attr("ImPlotScale_SymLog") = static_cast(ImPlotScale_SymLog); + ; + } + + { // ImPlotMarker ImPlotMarker_ + auto e = nb::enum_(m, "ImPlotMarker"); + e.value("ImPlotMarker_None", ImPlotMarker_None); m.attr("ImPlotMarker_None") = static_cast(ImPlotMarker_None); + e.value("ImPlotMarker_Circle", ImPlotMarker_Circle); m.attr("ImPlotMarker_Circle") = static_cast(ImPlotMarker_Circle); + e.value("ImPlotMarker_Square", ImPlotMarker_Square); m.attr("ImPlotMarker_Square") = static_cast(ImPlotMarker_Square); + e.value("ImPlotMarker_Diamond", ImPlotMarker_Diamond); m.attr("ImPlotMarker_Diamond") = static_cast(ImPlotMarker_Diamond); + e.value("ImPlotMarker_Up", ImPlotMarker_Up); m.attr("ImPlotMarker_Up") = static_cast(ImPlotMarker_Up); + e.value("ImPlotMarker_Down", ImPlotMarker_Down); m.attr("ImPlotMarker_Down") = static_cast(ImPlotMarker_Down); + e.value("ImPlotMarker_Left", ImPlotMarker_Left); m.attr("ImPlotMarker_Left") = static_cast(ImPlotMarker_Left); + e.value("ImPlotMarker_Right", ImPlotMarker_Right); m.attr("ImPlotMarker_Right") = static_cast(ImPlotMarker_Right); + e.value("ImPlotMarker_Cross", ImPlotMarker_Cross); m.attr("ImPlotMarker_Cross") = static_cast(ImPlotMarker_Cross); + e.value("ImPlotMarker_Plus", ImPlotMarker_Plus); m.attr("ImPlotMarker_Plus") = static_cast(ImPlotMarker_Plus); + e.value("ImPlotMarker_Asterisk", ImPlotMarker_Asterisk); m.attr("ImPlotMarker_Asterisk") = static_cast(ImPlotMarker_Asterisk); + e.value("ImPlotMarker_COUNT", ImPlotMarker_COUNT); m.attr("ImPlotMarker_COUNT") = static_cast(ImPlotMarker_COUNT); + ; + } + + { // ImPlotColormap ImPlotColormap_ + auto e = nb::enum_(m, "ImPlotColormap"); + e.value("ImPlotColormap_Deep", ImPlotColormap_Deep); m.attr("ImPlotColormap_Deep") = static_cast(ImPlotColormap_Deep); + e.value("ImPlotColormap_Dark", ImPlotColormap_Dark); m.attr("ImPlotColormap_Dark") = static_cast(ImPlotColormap_Dark); + e.value("ImPlotColormap_Pastel", ImPlotColormap_Pastel); m.attr("ImPlotColormap_Pastel") = static_cast(ImPlotColormap_Pastel); + e.value("ImPlotColormap_Paired", ImPlotColormap_Paired); m.attr("ImPlotColormap_Paired") = static_cast(ImPlotColormap_Paired); + e.value("ImPlotColormap_Viridis", ImPlotColormap_Viridis); m.attr("ImPlotColormap_Viridis") = static_cast(ImPlotColormap_Viridis); + e.value("ImPlotColormap_Plasma", ImPlotColormap_Plasma); m.attr("ImPlotColormap_Plasma") = static_cast(ImPlotColormap_Plasma); + e.value("ImPlotColormap_Hot", ImPlotColormap_Hot); m.attr("ImPlotColormap_Hot") = static_cast(ImPlotColormap_Hot); + e.value("ImPlotColormap_Cool", ImPlotColormap_Cool); m.attr("ImPlotColormap_Cool") = static_cast(ImPlotColormap_Cool); + e.value("ImPlotColormap_Pink", ImPlotColormap_Pink); m.attr("ImPlotColormap_Pink") = static_cast(ImPlotColormap_Pink); + e.value("ImPlotColormap_Jet", ImPlotColormap_Jet); m.attr("ImPlotColormap_Jet") = static_cast(ImPlotColormap_Jet); + e.value("ImPlotColormap_Twilight", ImPlotColormap_Twilight); m.attr("ImPlotColormap_Twilight") = static_cast(ImPlotColormap_Twilight); + e.value("ImPlotColormap_RdBu", ImPlotColormap_RdBu); m.attr("ImPlotColormap_RdBu") = static_cast(ImPlotColormap_RdBu); + e.value("ImPlotColormap_BrBG", ImPlotColormap_BrBG); m.attr("ImPlotColormap_BrBG") = static_cast(ImPlotColormap_BrBG); + e.value("ImPlotColormap_PiYG", ImPlotColormap_PiYG); m.attr("ImPlotColormap_PiYG") = static_cast(ImPlotColormap_PiYG); + e.value("ImPlotColormap_Spectral", ImPlotColormap_Spectral); m.attr("ImPlotColormap_Spectral") = static_cast(ImPlotColormap_Spectral); + e.value("ImPlotColormap_Greys", ImPlotColormap_Greys); m.attr("ImPlotColormap_Greys") = static_cast(ImPlotColormap_Greys); + ; + } + + { // ImPlotLocation ImPlotLocation_ + auto e = nb::enum_(m, "ImPlotLocation"); + e.value("ImPlotLocation_Center", ImPlotLocation_Center); m.attr("ImPlotLocation_Center") = static_cast(ImPlotLocation_Center); + e.value("ImPlotLocation_North", ImPlotLocation_North); m.attr("ImPlotLocation_North") = static_cast(ImPlotLocation_North); + e.value("ImPlotLocation_South", ImPlotLocation_South); m.attr("ImPlotLocation_South") = static_cast(ImPlotLocation_South); + e.value("ImPlotLocation_West", ImPlotLocation_West); m.attr("ImPlotLocation_West") = static_cast(ImPlotLocation_West); + e.value("ImPlotLocation_East", ImPlotLocation_East); m.attr("ImPlotLocation_East") = static_cast(ImPlotLocation_East); + e.value("ImPlotLocation_NorthWest", ImPlotLocation_NorthWest); m.attr("ImPlotLocation_NorthWest") = static_cast(ImPlotLocation_NorthWest); + e.value("ImPlotLocation_NorthEast", ImPlotLocation_NorthEast); m.attr("ImPlotLocation_NorthEast") = static_cast(ImPlotLocation_NorthEast); + e.value("ImPlotLocation_SouthWest", ImPlotLocation_SouthWest); m.attr("ImPlotLocation_SouthWest") = static_cast(ImPlotLocation_SouthWest); + e.value("ImPlotLocation_SouthEast", ImPlotLocation_SouthEast); m.attr("ImPlotLocation_SouthEast") = static_cast(ImPlotLocation_SouthEast); + ; + } + + { // ImPlotBin ImPlotBin_ + auto e = nb::enum_(m, "ImPlotBin"); + e.value("ImPlotBin_Sqrt", ImPlotBin_Sqrt); m.attr("ImPlotBin_Sqrt") = static_cast(ImPlotBin_Sqrt); + e.value("ImPlotBin_Sturges", ImPlotBin_Sturges); m.attr("ImPlotBin_Sturges") = static_cast(ImPlotBin_Sturges); + e.value("ImPlotBin_Rice", ImPlotBin_Rice); m.attr("ImPlotBin_Rice") = static_cast(ImPlotBin_Rice); + e.value("ImPlotBin_Scott", ImPlotBin_Scott); m.attr("ImPlotBin_Scott") = static_cast(ImPlotBin_Scott); + ; + } + +} + +// clang-format on diff --git a/src/cpp/implot.cpp b/src/cpp/implot.cpp deleted file mode 100644 index bb66671..0000000 --- a/src/cpp/implot.cpp +++ /dev/null @@ -1,722 +0,0 @@ -#include "imgui.h" -#include "implot.h" - -#include "Eigen/Dense" - -#include "utils.h" -#include "imgui_utils.h" - -void bind_implot_structs(nb::module_& m); -void bind_implot_methods(nb::module_& m); -void bind_implot_enums(nb::module_& m); - -void bind_implot(nb::module_& m) { - auto implot_module = m.def_submodule("implot", "ImPlot bindings"); - - bind_implot_structs(implot_module); - bind_implot_methods(implot_module); - bind_implot_enums(implot_module); -} - -// clang-format off - -void bind_implot_structs(nb::module_& m) { - - - -} - -void bind_implot_methods(nb::module_& m) { - - //----------------------------------------------------------------------------- - // [SECTION] Begin/End Plot - //----------------------------------------------------------------------------- - - m.def( - "BeginPlot", - [](const char* title_id, const Vec2T& size, ImPlotFlags flags) { - return ImPlot::BeginPlot(title_id, to_vec2(size), flags); - }, - nb::arg("title_id"), - nb::arg("size") = std::make_tuple(-1.f, 0.f), - nb::arg("flags") = 0 - ); - - m.def("EndPlot", []() { ImPlot::EndPlot(); }); - - m.def( - "BeginSubplots", - [](const char* title_id, int rows, int cols, const Vec2T& size, ImPlotSubplotFlags flags, std::vector row_ratios, std::vector col_ratios) { - - float* row_ratios_ptr = nullptr; - float* col_ratios_ptr = nullptr; - if(row_ratios.size() > 0) { - if((int)row_ratios.size() != rows) throw std::runtime_error("invalid row_ratios size"); - row_ratios_ptr = row_ratios.data(); - } - if(col_ratios.size() > 0) { - if((int)col_ratios.size() != cols) throw std::runtime_error("invalid col_ratios size"); - col_ratios_ptr = col_ratios.data(); - } - - return ImPlot::BeginSubplots(title_id, rows, cols, to_vec2(size), flags, row_ratios_ptr, col_ratios_ptr); - }, - nb::arg("title_id"), - nb::arg("rows"), - nb::arg("cols"), - nb::arg("size") = std::make_tuple(-1.f, 0.f), - nb::arg("flags") = 0, - nb::arg("row_ratios") = std::vector(), - nb::arg("col_ratios") = std::vector() - ); - - m.def("EndSubplots", []() { ImPlot::EndSubplots(); }); - - - //----------------------------------------------------------------------------- - // [SECTION] Setup - //----------------------------------------------------------------------------- - - m.def( - "SetupAxis", - [](ImAxis axis, const char* label, ImPlotAxisFlags flags) { - ImPlot::SetupAxis(axis, label, flags); - }, - nb::arg("axis"), - nb::arg("label") = "", - nb::arg("flags") = 0 - ); - - m.def( - "SetupAxisLimits", - [](ImAxis axis, double v_min, double v_max, ImPlotCond cond) { - ImPlot::SetupAxisLimits(axis, v_min, v_max, cond); - }, - nb::arg("axis"), - nb::arg("vmin"), - nb::arg("vmax"), - nb::arg("cond") = (int)ImPlotCond_Once - ); - - m.def( - "SetupAxisFormat", - [](ImAxis axis, const char* fmt) { - ImPlot::SetupAxisFormat(axis, fmt); - }, - nb::arg("axis"), - nb::arg("fmt") - ); - - m.def( - "SetupAxisTicks", - [](ImAxis axis, const Eigen::VectorXd& values, const std::vector& labels, bool keep_default) { - if(labels.size() > 0 && (labels.size() != values.size())) throw std::runtime_error("input sizes don't match"); - const auto _labels = convert_string_items(labels); - ImPlot::SetupAxisTicks(axis, values.data(), values.size(), labels.size() == 0 ? nullptr : _labels.data(), keep_default); - }, - nb::arg("axis"), - nb::arg("values"), - nb::arg("labels") = std::vector(), - nb::arg("keep_default") = false - ); - - m.def( - "SetupAxisTicks", - [](ImAxis axis, double v_min, double v_max, int n_ticks, const std::vector& labels, bool keep_default) { - if(labels.size() > 0 && (labels.size() != n_ticks)) throw std::runtime_error("input sizes don't match"); - const auto _labels = convert_string_items(labels); - ImPlot::SetupAxisTicks(axis, v_min, v_max, n_ticks, labels.size() == 0 ? nullptr : _labels.data(), keep_default); - }, - nb::arg("axis"), - nb::arg("v_min"), - nb::arg("v_max"), - nb::arg("n_ticks"), - nb::arg("labels") = std::vector(), - nb::arg("keep_default") = false - ); - - m.def( - "SetupAxisScale", - [](ImAxis axis, ImPlotScale scale) { - ImPlot::SetupAxisScale(axis, scale); - }, - nb::arg("axis"), - nb::arg("scale") - ); - - m.def( - "SetupAxisLimitsConstraints", - [](ImAxis axis, double v_min, double v_max) { - ImPlot::SetupAxisLimitsConstraints(axis, v_min, v_max); - }, - nb::arg("axis"), - nb::arg("v_min"), - nb::arg("v_max") - ); - - m.def( - "SetupAxisZoomConstraints", - [](ImAxis axis, double z_min, double z_max) { - ImPlot::SetupAxisZoomConstraints(axis, z_min, z_max); - }, - nb::arg("axis"), - nb::arg("z_min"), - nb::arg("z_max") - ); - - m.def( - "SetupAxes", - [](const char* x_label, const char* y_label, ImPlotAxisFlags x_flags, ImPlotAxisFlags y_flags) { - ImPlot::SetupAxes(x_label, y_label, x_flags, y_flags); - }, - nb::arg("x_label"), - nb::arg("y_label"), - nb::arg("x_flags") = 0, - nb::arg("y_flags") = 0 - ); - - m.def( - "SetupAxesLimits", - [](double x_min, double x_max, double y_min, double y_max, ImPlotCond cond) { - ImPlot::SetupAxesLimits(x_min, x_max, y_min, y_max, cond); - }, - nb::arg("x_min"), - nb::arg("x_max"), - nb::arg("y_min"), - nb::arg("y_max"), - nb::arg("cond") = (int)ImPlotCond_Once - ); - - m.def( - "SetupLegend", - [](ImPlotLocation location, ImPlotLegendFlags flags) { - ImPlot::SetupLegend(location, flags); - }, - nb::arg("location"), - nb::arg("flags") = 0 - ); - - m.def( - "SetupMouseText", - [](ImPlotLocation location, ImPlotMouseTextFlags flags) { - ImPlot::SetupMouseText(location, flags); - }, - nb::arg("location"), - nb::arg("flags") = 0 - ); - - - m.def( - "SetupFinish", - []() { - ImPlot::SetupFinish(); - } - ); - - - //----------------------------------------------------------------------------- - // [SECTION] Plot Items - //----------------------------------------------------------------------------- - - // PlotLine - - m.def( - "PlotLine", - [](const char* label_id, const Eigen::VectorXd& values, double xscale, double xstart, ImPlotLineFlags flags) { - ImPlot::PlotLine(label_id, values.data(), values.size(), xscale, xstart, flags); - }, - nb::arg("label_id"), - nb::arg("values"), - nb::arg("xscale")=1., - nb::arg("xstart")=0., - nb::arg("flags")=0 - ); - - m.def( - "PlotLine", - [](const char* label_id, const Eigen::VectorXd& xs, const Eigen::VectorXd& ys, ImPlotLineFlags flags) { - if(xs.size() != ys.size()) throw std::runtime_error("invalid input sizes"); - ImPlot::PlotLine(label_id, xs.data(), ys.data(), xs.size(), flags); - }, - nb::arg("label_id"), - nb::arg("xs"), - nb::arg("ys"), - nb::arg("flags") = 0 - ); - - // PlotScatter - - m.def( - "PlotScatter", - [](const char* label_id, const Eigen::VectorXd& values, double xscale, double xstart, ImPlotScatterFlags flags) { - ImPlot::PlotScatter(label_id, values.data(), values.size(), xscale, xstart, flags); - }, - nb::arg("label_id"), - nb::arg("values"), - nb::arg("xscale")=1., - nb::arg("xstart")=0., - nb::arg("flags")=0 - ); - - m.def( - "PlotScatter", - [](const char* label_id, const Eigen::VectorXd& xs, const Eigen::VectorXd& ys, ImPlotScatterFlags flags) { - if(xs.size() != ys.size()) throw std::runtime_error("invalid input sizes"); - ImPlot::PlotScatter(label_id, xs.data(), ys.data(), xs.size(), flags); - }, - nb::arg("label_id"), - nb::arg("xs"), - nb::arg("ys"), - nb::arg("flags") = 0 - ); - - // PlotStairs - - m.def( - "PlotStairs", - [](const char* label_id, const Eigen::VectorXd& values, double xscale, double xstart, ImPlotStairsFlags flags) { - ImPlot::PlotStairs(label_id, values.data(), values.size(), xscale, xstart, flags); - }, - nb::arg("label_id"), - nb::arg("values"), - nb::arg("xscale")=1., - nb::arg("xstart")=0., - nb::arg("flags")=0 - ); - - m.def( - "PlotStairs", - [](const char* label_id, const Eigen::VectorXd& xs, const Eigen::VectorXd& ys, ImPlotStairsFlags flags) { - if(xs.size() != ys.size()) throw std::runtime_error("invalid input sizes"); - ImPlot::PlotStairs(label_id, xs.data(), ys.data(), xs.size(), flags); - }, - nb::arg("label_id"), - nb::arg("xs"), - nb::arg("ys"), - nb::arg("flags") = 0 - ); - - // PlotShaded TODO - - m.def( - "PlotShaded", - [](const char* label_id, const Eigen::VectorXd& values, double yref, double xscale, double xstart, ImPlotShadedFlags flags) { - ImPlot::PlotShaded(label_id, values.data(), values.size(), yref, xscale, xstart, flags); - }, - nb::arg("label_id"), - nb::arg("values"), - nb::arg("yref")=0., - nb::arg("xscale")=1., - nb::arg("xstart")=0., - nb::arg("flags")=0 - ); - - m.def( - "PlotShaded", - [](const char* label_id, const Eigen::VectorXd& xs, const Eigen::VectorXd& ys, double yref, ImPlotShadedFlags flags) { - if(xs.size() != ys.size()) throw std::runtime_error("invalid input sizes"); - ImPlot::PlotShaded(label_id, xs.data(), ys.data(), xs.size(), yref, flags); - }, - nb::arg("label_id"), - nb::arg("xs"), - nb::arg("ys"), - nb::arg("yref")=0., - nb::arg("flags") = 0 - ); - - m.def( - "PlotShaded", - [](const char* label_id, const Eigen::VectorXd& xs, const Eigen::VectorXd& ys1, const Eigen::VectorXd& ys2, ImPlotShadedFlags flags) { - if(xs.size() != ys1.size()) throw std::runtime_error("invalid input sizes"); - if(xs.size() != ys2.size()) throw std::runtime_error("invalid input sizes"); - ImPlot::PlotShaded(label_id, xs.data(), ys1.data(), ys2.data(), xs.size(), flags); - }, - nb::arg("label_id"), - nb::arg("xs"), - nb::arg("ys1"), - nb::arg("ys2"), - nb::arg("flags") = 0 - ); - - // PlotBars TODO - - // PlotBarGroups TODO - - // PlotErrorBars TODO - - // PlotStems TODO - - // PlotInfLines - - m.def( - "PlotInfLines", - [](const char* label_id, const Eigen::VectorXd& values, ImPlotInfLinesFlags flags) { - ImPlot::PlotInfLines(label_id, values.data(), values.size(), flags); - }, - nb::arg("label_id"), - nb::arg("values"), - nb::arg("flags")=0 - ); - - // PlotPieChart - m.def( - "PlotPieChart", - [](const std::vector& label_ids, const Eigen::VectorXd& values, double x, double y, double radius, const char* label_fmt, double angle0, ImPlotPieChartFlags flags) { - if(label_ids.size() != values.size()) throw std::runtime_error("input sizes don't match"); - const auto _label_ids = convert_string_items(label_ids); - ImPlot::PlotPieChart(_label_ids.data(), values.data(), values.size(), x, y, radius, label_fmt, angle0, flags); - }, - nb::arg("label_ids"), - nb::arg("values"), - nb::arg("x"), - nb::arg("y"), - nb::arg("radius"), - nb::arg("label_fmt") = "%.1f", - nb::arg("angle0") = 90, - nb::arg("flags") = 0 - ); - - - // PlotHeatMap TODO - - // PlotHistogram - - m.def( - "PlotHistogram", - [](const char* label_id, const Eigen::VectorXd& values, int bins, double bar_scale, const Vec2T& range, ImPlotHistogramFlags flags) { - ImPlotRange imrange(std::get<0>(range), std::get<1>(range)); - ImPlot::PlotHistogram(label_id, values.data(), values.size(), bins, bar_scale, imrange, flags); - }, - nb::arg("label_id"), - nb::arg("values"), - nb::arg("bins") = (int)ImPlotBin_Sturges, - nb::arg("bar_scale") = 1.0, - nb::arg("range") = std::make_tuple(0.f, 0.f), - nb::arg("flags") = 0 - ); - - // PlotHistogram2D TODO - - // PlotDigital TODO - - // PlotImage TODO - - // PlotText TODO - - // PlotDummy TODO - - - //----------------------------------------------------------------------------- - // [SECTION] Plot Tools - //----------------------------------------------------------------------------- - - //----------------------------------------------------------------------------- - // [SECTION] Plot Utils - //----------------------------------------------------------------------------- - - //----------------------------------------------------------------------------- - // [SECTION] Legend Utils - //----------------------------------------------------------------------------- - - //----------------------------------------------------------------------------- - // [SECTION] Drag and Drop - //----------------------------------------------------------------------------- - - //----------------------------------------------------------------------------- - // [SECTION] Styling - //----------------------------------------------------------------------------- - - //----------------------------------------------------------------------------- - // [SECTION] Colormaps - //----------------------------------------------------------------------------- - - //----------------------------------------------------------------------------- - // [SECTION] Miscellaneous - //----------------------------------------------------------------------------- -} - -void bind_implot_enums(nb::module_& m) { - - // ImAxis - m.attr("ImAxis_X1") = static_cast(ImAxis_X1); - m.attr("ImAxis_X2") = static_cast(ImAxis_X2); - m.attr("ImAxis_X3") = static_cast(ImAxis_X3); - m.attr("ImAxis_Y1") = static_cast(ImAxis_Y1); - m.attr("ImAxis_Y2") = static_cast(ImAxis_Y2); - m.attr("ImAxis_Y3") = static_cast(ImAxis_Y3); - m.attr("ImAxis_COUNT") = static_cast(ImAxis_COUNT); - - // ImPlotFlags - m.attr("ImPlotLineFlags_None") = static_cast(ImPlotLineFlags_None); - m.attr("ImPlotFlags_None") = static_cast(ImPlotFlags_None); - m.attr("ImPlotFlags_NoTitle") = static_cast(ImPlotFlags_NoTitle); - m.attr("ImPlotFlags_NoLegend") = static_cast(ImPlotFlags_NoLegend); - m.attr("ImPlotFlags_NoMouseText") = static_cast(ImPlotFlags_NoMouseText); - m.attr("ImPlotFlags_NoInputs") = static_cast(ImPlotFlags_NoInputs); - m.attr("ImPlotFlags_NoMenus") = static_cast(ImPlotFlags_NoMenus); - m.attr("ImPlotFlags_NoBoxSelect") = static_cast(ImPlotFlags_NoBoxSelect); - m.attr("ImPlotFlags_NoFrame") = static_cast(ImPlotFlags_NoFrame); - m.attr("ImPlotFlags_Equal") = static_cast(ImPlotFlags_Equal); - m.attr("ImPlotFlags_Crosshairs") = static_cast(ImPlotFlags_Crosshairs); - m.attr("ImPlotFlags_CanvasOnly") = static_cast(ImPlotFlags_CanvasOnly); - - // ImPlotAxisFlags - m.attr("ImPlotAxisFlags_None") = static_cast(ImPlotAxisFlags_None); - m.attr("ImPlotAxisFlags_NoLabel") = static_cast(ImPlotAxisFlags_NoLabel); - m.attr("ImPlotAxisFlags_NoGridLines") = static_cast(ImPlotAxisFlags_NoGridLines); - m.attr("ImPlotAxisFlags_NoTickMarks") = static_cast(ImPlotAxisFlags_NoTickMarks); - m.attr("ImPlotAxisFlags_NoTickLabels") = static_cast(ImPlotAxisFlags_NoTickLabels); - m.attr("ImPlotAxisFlags_NoInitialFit") = static_cast(ImPlotAxisFlags_NoInitialFit); - m.attr("ImPlotAxisFlags_NoMenus") = static_cast(ImPlotAxisFlags_NoMenus); - m.attr("ImPlotAxisFlags_NoSideSwitch") = static_cast(ImPlotAxisFlags_NoSideSwitch); - m.attr("ImPlotAxisFlags_NoHighlight") = static_cast(ImPlotAxisFlags_NoHighlight); - m.attr("ImPlotAxisFlags_Opposite") = static_cast(ImPlotAxisFlags_Opposite); - m.attr("ImPlotAxisFlags_Foreground") = static_cast(ImPlotAxisFlags_Foreground); - m.attr("ImPlotAxisFlags_Invert") = static_cast(ImPlotAxisFlags_Invert); - m.attr("ImPlotAxisFlags_AutoFit") = static_cast(ImPlotAxisFlags_AutoFit); - m.attr("ImPlotAxisFlags_RangeFit") = static_cast(ImPlotAxisFlags_RangeFit); - m.attr("ImPlotAxisFlags_PanStretch") = static_cast(ImPlotAxisFlags_PanStretch); - m.attr("ImPlotAxisFlags_LockMin") = static_cast(ImPlotAxisFlags_LockMin); - m.attr("ImPlotAxisFlags_LockMax") = static_cast(ImPlotAxisFlags_LockMax); - m.attr("ImPlotAxisFlags_Lock") = static_cast(ImPlotAxisFlags_Lock); - m.attr("ImPlotAxisFlags_NoDecorations") = static_cast(ImPlotAxisFlags_NoDecorations); - m.attr("ImPlotAxisFlags_AuxDefault") = static_cast(ImPlotAxisFlags_AuxDefault); - - // ImPlotSubplotFlags - m.attr("ImPlotSubplotFlags_None") = static_cast(ImPlotSubplotFlags_None); - m.attr("ImPlotSubplotFlags_NoTitle") = static_cast(ImPlotSubplotFlags_NoTitle); - m.attr("ImPlotSubplotFlags_NoLegend") = static_cast(ImPlotSubplotFlags_NoLegend); - m.attr("ImPlotSubplotFlags_NoMenus") = static_cast(ImPlotSubplotFlags_NoMenus); - m.attr("ImPlotSubplotFlags_NoResize") = static_cast(ImPlotSubplotFlags_NoResize); - m.attr("ImPlotSubplotFlags_NoAlign") = static_cast(ImPlotSubplotFlags_NoAlign); - m.attr("ImPlotSubplotFlags_ShareItems") = static_cast(ImPlotSubplotFlags_ShareItems); - m.attr("ImPlotSubplotFlags_LinkRows") = static_cast(ImPlotSubplotFlags_LinkRows); - m.attr("ImPlotSubplotFlags_LinkCols") = static_cast(ImPlotSubplotFlags_LinkCols); - m.attr("ImPlotSubplotFlags_LinkAllX") = static_cast(ImPlotSubplotFlags_LinkAllX); - m.attr("ImPlotSubplotFlags_LinkAllY") = static_cast(ImPlotSubplotFlags_LinkAllY); - m.attr("ImPlotSubplotFlags_ColMajor") = static_cast(ImPlotSubplotFlags_ColMajor); - - // ImPlotLegendFlags - m.attr("ImPlotLegendFlags_None") = static_cast(ImPlotLegendFlags_None); - m.attr("ImPlotLegendFlags_NoButtons") = static_cast(ImPlotLegendFlags_NoButtons); - m.attr("ImPlotLegendFlags_NoHighlightItem") = static_cast(ImPlotLegendFlags_NoHighlightItem); - m.attr("ImPlotLegendFlags_NoHighlightAxis") = static_cast(ImPlotLegendFlags_NoHighlightAxis); - m.attr("ImPlotLegendFlags_NoMenus") = static_cast(ImPlotLegendFlags_NoMenus); - m.attr("ImPlotLegendFlags_Outside") = static_cast(ImPlotLegendFlags_Outside); - m.attr("ImPlotLegendFlags_Horizontal") = static_cast(ImPlotLegendFlags_Horizontal); - m.attr("ImPlotLegendFlags_Sort") = static_cast(ImPlotLegendFlags_Sort); - - // ImPlotMouseTextFlags - m.attr("ImPlotMouseTextFlags_None") = static_cast(ImPlotMouseTextFlags_None); - m.attr("ImPlotMouseTextFlags_NoAuxAxes") = static_cast(ImPlotMouseTextFlags_NoAuxAxes); - m.attr("ImPlotMouseTextFlags_NoFormat") = static_cast(ImPlotMouseTextFlags_NoFormat); - m.attr("ImPlotMouseTextFlags_ShowAlways") = static_cast(ImPlotMouseTextFlags_ShowAlways); - - // ImPlotDragToolFlags - m.attr("ImPlotDragToolFlags_None") = static_cast(ImPlotDragToolFlags_None); - m.attr("ImPlotDragToolFlags_NoCursors") = static_cast(ImPlotDragToolFlags_NoCursors); - m.attr("ImPlotDragToolFlags_NoFit") = static_cast(ImPlotDragToolFlags_NoFit); - m.attr("ImPlotDragToolFlags_NoInputs") = static_cast(ImPlotDragToolFlags_NoInputs); - m.attr("ImPlotDragToolFlags_Delayed") = static_cast(ImPlotDragToolFlags_Delayed); - - // ImPlotColormapScaleFlags - m.attr("ImPlotColormapScaleFlags_None") = static_cast(ImPlotColormapScaleFlags_None); - m.attr("ImPlotColormapScaleFlags_NoLabel") = static_cast(ImPlotColormapScaleFlags_NoLabel); - m.attr("ImPlotColormapScaleFlags_Opposite") = static_cast(ImPlotColormapScaleFlags_Opposite); - m.attr("ImPlotColormapScaleFlags_Invert") = static_cast(ImPlotColormapScaleFlags_Invert); - - // ImPlotItemFlags - m.attr("ImPlotItemFlags_None") = static_cast(ImPlotItemFlags_None); - m.attr("ImPlotItemFlags_NoLegend") = static_cast(ImPlotItemFlags_NoLegend); - m.attr("ImPlotItemFlags_NoFit") = static_cast(ImPlotItemFlags_NoFit); - - // ImPlotLineFlags - m.attr("ImPlotLineFlags_None") = static_cast(ImPlotLineFlags_None); - m.attr("ImPlotLineFlags_Segments") = static_cast(ImPlotLineFlags_Segments); - m.attr("ImPlotLineFlags_Loop") = static_cast(ImPlotLineFlags_Loop); - m.attr("ImPlotLineFlags_SkipNaN") = static_cast(ImPlotLineFlags_SkipNaN); - m.attr("ImPlotLineFlags_NoClip") = static_cast(ImPlotLineFlags_NoClip); - m.attr("ImPlotLineFlags_Shaded") = static_cast(ImPlotLineFlags_Shaded); - - // ImPlotScatterFlags - m.attr("ImPlotScatterFlags_None") = static_cast(ImPlotScatterFlags_None); - m.attr("ImPlotScatterFlags_NoClip") = static_cast(ImPlotScatterFlags_NoClip); - - // ImPlotStairsFlags - m.attr("ImPlotStairsFlags_None") = static_cast(ImPlotStairsFlags_None); - m.attr("ImPlotStairsFlags_PreStep") = static_cast(ImPlotStairsFlags_PreStep); - m.attr("ImPlotStairsFlags_Shaded") = static_cast(ImPlotStairsFlags_Shaded); - - // ImPlotShadedFlags - m.attr("ImPlotShadedFlags_None") = static_cast(ImPlotShadedFlags_None); - - // ImPlotBarsFlags - m.attr("ImPlotBarsFlags_None") = static_cast(ImPlotBarsFlags_None); - m.attr("ImPlotBarsFlags_Horizontal") = static_cast(ImPlotBarsFlags_Horizontal); - - // ImPlotBarGroupsFlags - m.attr("ImPlotBarGroupsFlags_None") = static_cast(ImPlotBarGroupsFlags_None); - m.attr("ImPlotBarGroupsFlags_Horizontal") = static_cast(ImPlotBarGroupsFlags_Horizontal); - m.attr("ImPlotBarGroupsFlags_Stacked") = static_cast(ImPlotBarGroupsFlags_Stacked); - - // ImPlotErrorBarsFlags - m.attr("ImPlotErrorBarsFlags_None") = static_cast(ImPlotErrorBarsFlags_None); - m.attr("ImPlotErrorBarsFlags_Horizontal") = static_cast(ImPlotErrorBarsFlags_Horizontal); - - // ImPlotStemsFlags - m.attr("ImPlotStemsFlags_None") = static_cast(ImPlotStemsFlags_None); - m.attr("ImPlotStemsFlags_Horizontal") = static_cast(ImPlotStemsFlags_Horizontal); - - // ImPlotInfLinesFlags - m.attr("ImPlotInfLinesFlags_None") = static_cast(ImPlotInfLinesFlags_None); - m.attr("ImPlotInfLinesFlags_Horizontal") = static_cast(ImPlotInfLinesFlags_Horizontal); - - // ImPlotPieChartFlags - m.attr("ImPlotPieChartFlags_None") = static_cast(ImPlotPieChartFlags_None); - m.attr("ImPlotPieChartFlags_Normalize") = static_cast(ImPlotPieChartFlags_Normalize); - m.attr("ImPlotPieChartFlags_IgnoreHidden") = static_cast(ImPlotPieChartFlags_IgnoreHidden); - m.attr("ImPlotPieChartFlags_Exploding") = static_cast(ImPlotPieChartFlags_Exploding); - - // ImPlotHeatmapFlags - m.attr("ImPlotHeatmapFlags_None") = static_cast(ImPlotHeatmapFlags_None); - m.attr("ImPlotHeatmapFlags_ColMajor") = static_cast(ImPlotHeatmapFlags_ColMajor); - - // ImPlotHistogramFlags - m.attr("ImPlotHistogramFlags_None") = static_cast(ImPlotHistogramFlags_None); - m.attr("ImPlotHistogramFlags_Horizontal") = static_cast(ImPlotHistogramFlags_Horizontal); - m.attr("ImPlotHistogramFlags_Cumulative") = static_cast(ImPlotHistogramFlags_Cumulative); - m.attr("ImPlotHistogramFlags_Density") = static_cast(ImPlotHistogramFlags_Density); - m.attr("ImPlotHistogramFlags_NoOutliers") = static_cast(ImPlotHistogramFlags_NoOutliers); - m.attr("ImPlotHistogramFlags_ColMajor") = static_cast(ImPlotHistogramFlags_ColMajor); - - // ImPlotDigitalFlags - m.attr("ImPlotDigitalFlags_None") = static_cast(ImPlotDigitalFlags_None); - - // ImPlotImageFlags - m.attr("ImPlotImageFlags_None") = static_cast(ImPlotImageFlags_None); - - // ImPlotTextFlags - m.attr("ImPlotTextFlags_None") = static_cast(ImPlotTextFlags_None); - m.attr("ImPlotTextFlags_Vertical") = static_cast(ImPlotTextFlags_Vertical); - - // ImPlotDummyFlags - m.attr("ImPlotDummyFlags_None") = static_cast(ImPlotDummyFlags_None); - - // ImPlotCond - m.attr("ImPlotCond_None") = static_cast(ImPlotCond_None); - m.attr("ImPlotCond_Always") = static_cast(ImPlotCond_Always); - m.attr("ImPlotCond_Once") = static_cast(ImPlotCond_Once); - - // ImPlotCol - m.attr("ImPlotCol_Line") = static_cast(ImPlotCol_Line); - m.attr("ImPlotCol_Fill") = static_cast(ImPlotCol_Fill); - m.attr("ImPlotCol_MarkerOutline") = static_cast(ImPlotCol_MarkerOutline); - m.attr("ImPlotCol_MarkerFill") = static_cast(ImPlotCol_MarkerFill); - m.attr("ImPlotCol_ErrorBar") = static_cast(ImPlotCol_ErrorBar); - m.attr("ImPlotCol_FrameBg") = static_cast(ImPlotCol_FrameBg); - m.attr("ImPlotCol_PlotBg") = static_cast(ImPlotCol_PlotBg); - m.attr("ImPlotCol_PlotBorder") = static_cast(ImPlotCol_PlotBorder); - m.attr("ImPlotCol_LegendBg") = static_cast(ImPlotCol_LegendBg); - m.attr("ImPlotCol_LegendBorder") = static_cast(ImPlotCol_LegendBorder); - m.attr("ImPlotCol_LegendText") = static_cast(ImPlotCol_LegendText); - m.attr("ImPlotCol_TitleText") = static_cast(ImPlotCol_TitleText); - m.attr("ImPlotCol_InlayText") = static_cast(ImPlotCol_InlayText); - m.attr("ImPlotCol_AxisText") = static_cast(ImPlotCol_AxisText); - m.attr("ImPlotCol_AxisGrid") = static_cast(ImPlotCol_AxisGrid); - m.attr("ImPlotCol_AxisTick") = static_cast(ImPlotCol_AxisTick); - m.attr("ImPlotCol_AxisBg") = static_cast(ImPlotCol_AxisBg); - m.attr("ImPlotCol_AxisBgHovered") = static_cast(ImPlotCol_AxisBgHovered); - m.attr("ImPlotCol_AxisBgActive") = static_cast(ImPlotCol_AxisBgActive); - m.attr("ImPlotCol_Selection") = static_cast(ImPlotCol_Selection); - m.attr("ImPlotCol_Crosshairs") = static_cast(ImPlotCol_Crosshairs); - m.attr("ImPlotCol_COUNT") = static_cast(ImPlotCol_COUNT); - - // ImPlotStyleVar - m.attr("ImPlotStyleVar_LineWeight") = static_cast(ImPlotStyleVar_LineWeight); - m.attr("ImPlotStyleVar_Marker") = static_cast(ImPlotStyleVar_Marker); - m.attr("ImPlotStyleVar_MarkerSize") = static_cast(ImPlotStyleVar_MarkerSize); - m.attr("ImPlotStyleVar_MarkerWeight") = static_cast(ImPlotStyleVar_MarkerWeight); - m.attr("ImPlotStyleVar_FillAlpha") = static_cast(ImPlotStyleVar_FillAlpha); - m.attr("ImPlotStyleVar_ErrorBarSize") = static_cast(ImPlotStyleVar_ErrorBarSize); - m.attr("ImPlotStyleVar_ErrorBarWeight") = static_cast(ImPlotStyleVar_ErrorBarWeight); - m.attr("ImPlotStyleVar_DigitalBitHeight") = static_cast(ImPlotStyleVar_DigitalBitHeight); - m.attr("ImPlotStyleVar_DigitalBitGap") = static_cast(ImPlotStyleVar_DigitalBitGap); - m.attr("ImPlotStyleVar_PlotBorderSize") = static_cast(ImPlotStyleVar_PlotBorderSize); - m.attr("ImPlotStyleVar_MinorAlpha") = static_cast(ImPlotStyleVar_MinorAlpha); - m.attr("ImPlotStyleVar_MajorTickLen") = static_cast(ImPlotStyleVar_MajorTickLen); - m.attr("ImPlotStyleVar_MinorTickLen") = static_cast(ImPlotStyleVar_MinorTickLen); - m.attr("ImPlotStyleVar_MajorTickSize") = static_cast(ImPlotStyleVar_MajorTickSize); - m.attr("ImPlotStyleVar_MinorTickSize") = static_cast(ImPlotStyleVar_MinorTickSize); - m.attr("ImPlotStyleVar_MajorGridSize") = static_cast(ImPlotStyleVar_MajorGridSize); - m.attr("ImPlotStyleVar_MinorGridSize") = static_cast(ImPlotStyleVar_MinorGridSize); - m.attr("ImPlotStyleVar_PlotPadding") = static_cast(ImPlotStyleVar_PlotPadding); - m.attr("ImPlotStyleVar_LabelPadding") = static_cast(ImPlotStyleVar_LabelPadding); - m.attr("ImPlotStyleVar_LegendPadding") = static_cast(ImPlotStyleVar_LegendPadding); - m.attr("ImPlotStyleVar_LegendInnerPadding") = static_cast(ImPlotStyleVar_LegendInnerPadding); - m.attr("ImPlotStyleVar_LegendSpacing") = static_cast(ImPlotStyleVar_LegendSpacing); - m.attr("ImPlotStyleVar_MousePosPadding") = static_cast(ImPlotStyleVar_MousePosPadding); - m.attr("ImPlotStyleVar_AnnotationPadding") = static_cast(ImPlotStyleVar_AnnotationPadding); - m.attr("ImPlotStyleVar_FitPadding") = static_cast(ImPlotStyleVar_FitPadding); - m.attr("ImPlotStyleVar_PlotDefaultSize") = static_cast(ImPlotStyleVar_PlotDefaultSize); - m.attr("ImPlotStyleVar_PlotMinSize") = static_cast(ImPlotStyleVar_PlotMinSize); - m.attr("ImPlotStyleVar_COUNT") = static_cast(ImPlotStyleVar_COUNT); - - // ImPlotScale - m.attr("ImPlotScale_Linear") = static_cast(ImPlotScale_Linear); - m.attr("ImPlotScale_Time") = static_cast(ImPlotScale_Time); - m.attr("ImPlotScale_Log10") = static_cast(ImPlotScale_Log10); - m.attr("ImPlotScale_SymLog") = static_cast(ImPlotScale_SymLog); - - // ImPlotMarker - m.attr("ImPlotMarker_None") = static_cast(ImPlotMarker_None); - m.attr("ImPlotMarker_Circle") = static_cast(ImPlotMarker_Circle); - m.attr("ImPlotMarker_Square") = static_cast(ImPlotMarker_Square); - m.attr("ImPlotMarker_Diamond") = static_cast(ImPlotMarker_Diamond); - m.attr("ImPlotMarker_Up") = static_cast(ImPlotMarker_Up); - m.attr("ImPlotMarker_Down") = static_cast(ImPlotMarker_Down); - m.attr("ImPlotMarker_Left") = static_cast(ImPlotMarker_Left); - m.attr("ImPlotMarker_Right") = static_cast(ImPlotMarker_Right); - m.attr("ImPlotMarker_Cross") = static_cast(ImPlotMarker_Cross); - m.attr("ImPlotMarker_Plus") = static_cast(ImPlotMarker_Plus); - m.attr("ImPlotMarker_Asterisk") = static_cast(ImPlotMarker_Asterisk); - m.attr("ImPlotMarker_COUNT") = static_cast(ImPlotMarker_COUNT); - - - // ImPlotColormap - m.attr("ImPlotColormap_Deep") = static_cast(ImPlotColormap_Deep); - m.attr("ImPlotColormap_Dark") = static_cast(ImPlotColormap_Dark); - m.attr("ImPlotColormap_Pastel") = static_cast(ImPlotColormap_Pastel); - m.attr("ImPlotColormap_Paired") = static_cast(ImPlotColormap_Paired); - m.attr("ImPlotColormap_Viridis") = static_cast(ImPlotColormap_Viridis); - m.attr("ImPlotColormap_Plasma") = static_cast(ImPlotColormap_Plasma); - m.attr("ImPlotColormap_Hot") = static_cast(ImPlotColormap_Hot); - m.attr("ImPlotColormap_Cool") = static_cast(ImPlotColormap_Cool); - m.attr("ImPlotColormap_Pink") = static_cast(ImPlotColormap_Pink); - m.attr("ImPlotColormap_Jet") = static_cast(ImPlotColormap_Jet); - m.attr("ImPlotColormap_Twilight") = static_cast(ImPlotColormap_Twilight); - m.attr("ImPlotColormap_RdBu") = static_cast(ImPlotColormap_RdBu); - m.attr("ImPlotColormap_BrBG") = static_cast(ImPlotColormap_BrBG); - m.attr("ImPlotColormap_PiYG") = static_cast(ImPlotColormap_PiYG); - m.attr("ImPlotColormap_Spectral") = static_cast(ImPlotColormap_Spectral); - m.attr("ImPlotColormap_Greys") = static_cast(ImPlotColormap_Greys); - - // ImPlotLocation - m.attr("ImPlotLocation_Center") = static_cast(ImPlotLocation_Center); - m.attr("ImPlotLocation_North") = static_cast(ImPlotLocation_North); - m.attr("ImPlotLocation_South") = static_cast(ImPlotLocation_South); - m.attr("ImPlotLocation_West") = static_cast(ImPlotLocation_West); - m.attr("ImPlotLocation_East") = static_cast(ImPlotLocation_East); - m.attr("ImPlotLocation_NorthWest") = static_cast(ImPlotLocation_NorthWest); - m.attr("ImPlotLocation_NorthEast") = static_cast(ImPlotLocation_NorthEast); - m.attr("ImPlotLocation_SouthWest") = static_cast(ImPlotLocation_SouthWest); - m.attr("ImPlotLocation_SouthEast") = static_cast(ImPlotLocation_SouthEast); - - // ImPlotBin - m.attr("ImPlotBin_Sqrt") = static_cast(ImPlotBin_Sqrt); - m.attr("ImPlotBin_Sturges") = static_cast(ImPlotBin_Sturges); - m.attr("ImPlotBin_Rice") = static_cast(ImPlotBin_Rice); - m.attr("ImPlotBin_Scott") = static_cast(ImPlotBin_Scott); - -} - -// clang-format on diff --git a/src/polyscope_bindings/__init__.pyi b/src/polyscope/py.typed similarity index 100% rename from src/polyscope_bindings/__init__.pyi rename to src/polyscope/py.typed diff --git a/src/polyscope_bindings/imgui.pyi b/src/polyscope_bindings/imgui.pyi deleted file mode 100644 index b574241..0000000 --- a/src/polyscope_bindings/imgui.pyi +++ /dev/null @@ -1,1274 +0,0 @@ -from typing import List, NewType, Optional, Tuple, Union, overload -import numpy as np - -# Basic Types -ImU32 = NewType("ImU32", int) -ImVec2 = Tuple[float, float] -ImVec4 = Tuple[float, float, float, float] - -# Enum Types -ImGuiCol = NewType("ImGuiCol", int) -ImGuiColorEditFlags = NewType("ImGuiColorEditFlags", int) -ImGuiComboFlags = NewType("ImGuiComboFlags", int) -ImGuiCond = NewType("ImGuiCond", int) -ImGuiDataType = NewType("ImGuiDataType", int) -ImGuiDir = NewType("ImGuiDir", int) -ImGuiFocusedFlags = NewType("ImGuiFocusedFlags", int) -ImGuiHoveredFlags = NewType("ImGuiHoveredFlags", int) -ImGuiID = NewType("ImGuiID", int) -ImGuiInputTextFlags = NewType("ImGuiInputTextFlags", int) -ImGuiKey = NewType("ImGuiKey", int) -ImGuiMouseButton = NewType("ImGuiMouseButton", int) -ImGuiMouseCursor = NewType("ImGuiMouseCursor", int) -ImGuiSelectableFlags = NewType("ImGuiSelectableFlags", int) -ImGuiStyleVar = NewType("ImGuiStyleVar", int) -ImGuiTabBarFlags = NewType("ImGuiTabBarFlags", int) -ImGuiTabItemFlags = NewType("ImGuiTabItemFlags", int) -ImGuiTableBgTarget = NewType("ImGuiTableBgTarget", int) -ImGuiTableColumnFlags = NewType("ImGuiTableColumnFlags", int) -ImGuiTableRowFlags = NewType("ImGuiTableRowFlags", int) -ImGuiTreeNodeFlags = NewType("ImGuiTreeNodeFlags", int) -ImGuiWindowFlags = NewType("ImGuiWindowFlags", int) - -# Draw Types -ImDrawFlags = NewType("ImDrawFlags", int) -ImDrawListFlags = NewType("ImDrawListFlags", int) - -# Windows - - -def Begin( - name: str, open: Optional[bool] = None, flags: ImGuiWindowFlags = ImGuiWindowFlags(0) -) -> bool: ... -def End() -> None: ... - -# Child Windows - - -def BeginChild( - id: Union[str, ImGuiID], - size: ImVec2 = (0, 0), - border: bool = False, - flags: ImGuiWindowFlags = ImGuiWindowFlags(0), -) -> bool: ... -def Endchild() -> None: ... - -# Windows Utilities - - -def IsWindowAppearing() -> bool: ... -def IsWindowCollapsed() -> bool: ... - - -def IsWindowFocused( - flags: ImGuiFocusedFlags = ImGuiFocusedFlags(0)) -> bool: ... - - -def IsWindowHovered( - flags: ImGuiFocusedFlags = ImGuiFocusedFlags(0)) -> bool: ... - - -def GetWindowPos() -> ImVec2: ... -def GetWindowSize() -> ImVec2: ... -def GetWindowWidth() -> float: ... -def GetWindowHeight() -> float: ... - - -def SetNextWindowPos( - pos: ImVec2, cone: ImGuiCond = ImGuiCond(0), pivot: ImVec2 = (0, 0) -) -> None: ... - - -def SetNextWindowSize( - size: ImVec2, cond: ImGuiCond = ImGuiCond(0)) -> None: ... -def SetNextWindowSizeConstraints( - size_min: ImVec2, size_max: ImVec2) -> None: ... - - -def SetNextWindowContentSize(size: ImVec2) -> None: ... -def SetNextWindowCollapsed( - collapsed: bool, cond: ImGuiCond = ImGuiCond(0)) -> None: ... - - -def SetNextWindowFocus() -> None: ... -def SetNextWindowBgAlpha(alpha: float) -> None: ... -@overload -def SetWindowPos(pos: ImVec2, cond: ImGuiCond = ImGuiCond(0)) -> None: ... - - -@overload -def SetWindowPos(name: str, pos: ImVec2, - cond: ImGuiCond = ImGuiCond(0)) -> None: ... - - -@overload -def SetWindowSize(size: ImVec2, cond: ImGuiCond = ImGuiCond(0)) -> None: ... - - -@overload -def SetWindowSize(name: str, size: ImVec2, - cond: ImGuiCond = ImGuiCond(0)) -> None: ... - - -@overload -def SetWindowCollapsed( - collapsed: bool, cond: ImGuiCond = ImGuiCond(0)) -> None: ... - - -@overload -def SetWindowCollapsed(name: str, collapsed: bool, - cond: ImGuiCond = ImGuiCond(0)) -> None: ... - - -def SetWindowFontScale(scale: float) -> None: ... - - -def SetWindowFocus( - name: Optional[str] = None, -) -> None: ... - -# Content region - - -def GetContentRegionMax() -> ImVec2: ... -def GetContentRegionAvail() -> ImVec2: ... -def GetWindowContentRegionMin() -> ImVec2: ... -def GetWindowContentRegionMax() -> ImVec2: ... -def GetWindowContentRegionWidth() -> float: ... - -# Windows Scrolling - - -def GetScrollX() -> float: ... -def GetScrollY() -> float: ... -def GetScrollMaxX() -> float: ... -def GetScrollMaxY() -> float: ... -def SetScrollX(scroll_x: float) -> None: ... -def SetScrollY(scroll_y: float) -> None: ... -def SetScrollHereX(center_x_ratio: float = 0.5) -> None: ... -def SetScrollHereY(center_y_ratio: float = 0.5) -> None: ... -def SetScrollFromPosX(local_x: float, center_x_ratio: float = 0.5) -> None: ... -def SetScrollFromPosY(local_y: float, center_y_ratio: float = 0.5) -> None: ... - -# Parameters stacks (shared) - - -def PushStyleColor(idx: ImGuiCol, col: Union[ImU32, ImVec4]) -> None: ... -def PopStyleColor(count: int = 1) -> None: ... -def PushStyleVar(idx: ImGuiStyleVar, val: Union[float, ImVec2]) -> None: ... -def PopStyleVar(count: int = 1) -> None: ... -def GetStyleColorVec4(idx: ImGuiCol) -> ImVec4: ... -def GetFontSize() -> float: ... -def GetFontTexUvWhitePixel() -> ImVec2: ... -@overload -def GetColorU32(idx: ImGuiCol, alpha_mul: float = 1.0) -> ImU32: ... -@overload -def GetColorU32(col: ImVec4) -> ImU32: ... -@overload -def GetColorU32(col: ImU32) -> ImU32: ... - -# Parameters stacks (current window) - - -def PushItemWidth(item_width) -> float: ... -def PopItemWidth() -> None: ... -def SetNextItemWidth(item_width) -> float: ... -def CalcItemWidth() -> float: ... -def PushTextWrapPos(wrap_local_pos_x: float = 0.0) -> None: ... -def PopTextWrapPos() -> None: ... -def PushAllowKeyboardFocus(allow_keyboard_focus: bool) -> None: ... -def PopAllowKeyboardFocus() -> None: ... -def PushButtonRepeat(repeat: bool) -> None: ... -def PopButtonRepeat() -> None: ... - -# Cursor / Layout - - -def Separator() -> None: ... -def SameLine(offset_from_start_x: float = 0.0, - spacing: float = -1.0) -> None: ... - - -def NewLine() -> None: ... -def Spacing() -> None: ... -def Dummy(size: ImVec2) -> None: ... -def Indent(intent_w: float = 0.0) -> None: ... -def Unindent(intent_w: float = 0.0) -> None: ... -def BeginGroup() -> None: ... -def EndGroup() -> None: ... -def GetCursorPos() -> ImVec2: ... -def GetCursorPosX() -> float: ... -def SetCursorPos(local_pos: ImVec2) -> None: ... -def SetCursorPosX(locol_x: float) -> None: ... -def SetCursorPosY(locol_y: float) -> None: ... -def GetCursorStartPos() -> ImVec2: ... -def GetCursorScreenPos() -> ImVec2: ... -def SetCursorScreenPos(pos: ImVec2) -> None: ... -def AlignTextToFramePadding() -> None: ... -def GetTextLineHeight() -> float: ... -def GetTextLineHeightWithSpacing() -> float: ... -def GetFrameHeight() -> float: ... -def GetFrameHeightWithSpacing() -> float: ... - -# ID stack/scopes - - -def PushID(str_id: Union[str, int]) -> None: ... -def PopID() -> None: ... -def GetID(str_id: str) -> ImGuiID: ... - -# Widgets: Text - - -def TextUnformatted(text: str) -> None: ... -def Text(text: str) -> None: ... -def TextColored(col: ImVec4, text: str) -> None: ... -def TextDisabled(text: str) -> None: ... -def TextWrapped(text: str) -> None: ... -def LabelText(label: str, text: str) -> None: ... -def BulletText(text: str) -> None: ... - -# Widgets: Main - - -def Button(label: str, size: ImVec2 = (0, 0)) -> bool: ... -def SmallButton(label: str) -> bool: ... -def InvisibleButton(str_id: str, size: ImVec2) -> bool: ... -def ArrowButton(str_id: str, dir: ImGuiDir) -> bool: ... -def Checkbox(label: str, v: bool) -> Tuple[bool, bool]: ... -def CheckboxFlags(label: str, flags: int, - flags_value: int) -> Tuple[bool, int]: ... - - -@overload -def RadioButton(label: str, active: bool) -> bool: ... -@overload -def RadioButton(label: str, v: int, v_button: int) -> Tuple[bool, int]: ... - - -def ProgressBar(fraction: float, size_arg: ImVec2 = (-1, 0)) -> None: ... -def Bullet() -> None: ... - -# Widgets: Combo Box - - -def BeginCombo(label: str, preview_value: str, - flags: ImGuiComboFlags = ImGuiComboFlags(0)) -> bool: ... - - -def EndCombo() -> None: ... - - -def Combo( - label: str, - current_item: int, - items: Union[str, List[str]], - popup_max_height_in_items: int = -1, -) -> Tuple[bool, int]: ... - -# Widgets: Drags - - -def DragFloat( - label: str, - v: float, - v_speed: float = 1.0, - v_min: float = 0.0, - v_max: float = 0.0, - format: str = "%.3f", - power: float = 1.0, -) -> Tuple[bool, float]: ... - - -def DragFloat2( - label: str, - v: List[float], - v_speed: float = 1.0, - v_min: float = 0.0, - v_max: float = 0.0, - format: str = "%.3f", - power: float = 1.0, -) -> Tuple[bool, List[float]]: ... - - -def DragFloat3( - label: str, - v: List[float], - v_speed: float = 1.0, - v_min: float = 0.0, - v_max: float = 0.0, - format: str = "%.3f", - power: float = 1.0, -) -> Tuple[bool, List[float]]: ... - - -def DragFloat4( - label: str, - v: List[float], - v_speed: float = 1.0, - v_min: float = 0.0, - v_max: float = 0.0, - format: str = "%.3f", - power: float = 1.0, -) -> Tuple[bool, List[float]]: ... - - -def DragFloatRange2( - label: str, - v_current_min: List[float], - v_current_max: List[float], - v_speed: float = 1.0, - v_min: float = 0.0, - v_max: float = 0.0, - format: str = "%.3f", - format_max: Optional[str] = None, - power: float = 1.0, -) -> Tuple[bool, List[float], List[float]]: ... - - -def DragInt( - label: str, - v: int, - v_speed: float = 1.0, - v_min: int = 0, - v_max: int = 0, - format: str = "%d", -) -> Tuple[bool, float]: ... - - -def DragInt2( - label: str, - v: List[int], - v_speed: float = 1.0, - v_min: int = 0, - v_max: int = 0, - format: str = "%d", -) -> Tuple[bool, List[float]]: ... - - -def DragInt3( - label: str, - v: List[int], - v_speed: float = 1.0, - v_min: int = 0, - v_max: int = 0, - format: str = "%d", -) -> Tuple[bool, List[float]]: ... - - -def DragInt4( - label: str, - v: List[int], - v_speed: float = 1.0, - v_min: int = 0, - v_max: int = 0, - format: str = "%d", -) -> Tuple[bool, List[float]]: ... - - -def DragIntRange2( - label: str, - v_current_min: List[int], - v_current_max: List[int], - v_speed: float = 1.0, - v_min: int = 0, - v_max: int = 0, - format: str = "%d", - format_max: Optional[str] = None, -) -> Tuple[bool, List[int], List[int]]: ... - -# Widgets: Sliders - - -def SliderFloat( - label: str, - v: float, - v_speed: float = 1.0, - v_min: float = 0.0, - v_max: float = 0.0, - format: str = "%.3f", - power: float = 1.0, -) -> Tuple[bool, float]: ... - - -def SliderFloat2( - label: str, - v: List[float], - v_speed: float = 1.0, - v_min: float = 0.0, - v_max: float = 0.0, - format: str = "%.3f", - power: float = 1.0, -) -> Tuple[bool, List[float]]: ... - - -def SliderFloat3( - label: str, - v: List[float], - v_speed: float = 1.0, - v_min: float = 0.0, - v_max: float = 0.0, - format: str = "%.3f", - power: float = 1.0, -) -> Tuple[bool, List[float]]: ... - - -def SliderFloat4( - label: str, - v: List[float], - v_speed: float = 1.0, - v_min: float = 0.0, - v_max: float = 0.0, - format: str = "%.3f", - power: float = 1.0, -) -> Tuple[bool, List[float]]: ... - - -def SliderAngle( - label: str, v_rad: int, v_degrees_min: float, v_degrees_max: float, format: str -) -> Tuple[bool, float]: ... - - -def SliderInt( - label: str, - v: int, - v_speed: float = 1.0, - v_min: int = 0, - v_max: int = 0, - format: str = "%d", -) -> Tuple[bool, float]: ... - - -def SliderInt2( - label: str, - v: List[int], - v_speed: float = 1.0, - v_min: int = 0, - v_max: int = 0, - format: str = "%d", -) -> Tuple[bool, List[float]]: ... - - -def SliderInt3( - label: str, - v: List[int], - v_speed: float = 1.0, - v_min: int = 0, - v_max: int = 0, - format: str = "%d", -) -> Tuple[bool, List[float]]: ... - - -def SliderInt4( - label: str, - v: List[int], - v_speed: float = 1.0, - v_min: int = 0, - v_max: int = 0, - format: str = "%d", -) -> Tuple[bool, List[float]]: ... - -# Widgets: Input with Keyboard - - -def InputText( - label: str, buf: str, flags: ImGuiInputTextFlags = ImGuiInputTextFlags(0) -) -> Tuple[bool, str]: ... - - -def InputTextMultiline( - label: str, buf: str, size: ImVec2 = (0.0, 0.0), flags: ImGuiInputTextFlags = ImGuiInputTextFlags(0) -) -> Tuple[bool, ImVec2]: ... - - -def InputTextWithHint( - label: str, hint: str, buf: str, flags: ImGuiInputTextFlags = ImGuiInputTextFlags(0) -) -> Tuple[bool, ImVec2]: ... - - -def InputFloat( - label: str, - v: float, - step: float = 0.0, - step_fast: float = 0.0, - format: str = "%.3f", - flags: ImGuiInputTextFlags = ImGuiInputTextFlags(0), -) -> Tuple[bool, float]: ... - - -def InputFloat2( - label: str, - v: List[float], - format: str = "%.3f", - flags: ImGuiInputTextFlags = ImGuiInputTextFlags(0), -) -> Tuple[bool, List[float]]: ... - - -def InputFloat3( - label: str, - v: List[float], - format: str = "%.3f", - flags: ImGuiInputTextFlags = ImGuiInputTextFlags(0), -) -> Tuple[bool, List[float]]: ... - - -def InputFloat4( - label: str, - v: List[float], - format: str = "%.3f", - flags: ImGuiInputTextFlags = ImGuiInputTextFlags(0), -) -> Tuple[bool, List[float]]: ... - - -def InputInt( - label: str, - v: int, - step: int = 1, - step_fast: int = 100, - flags: ImGuiInputTextFlags = ImGuiInputTextFlags(0), -) -> Tuple[bool, float]: ... - - -def InputInt2( - label: str, - v: List[int], - flags: ImGuiInputTextFlags = ImGuiInputTextFlags(0), -) -> Tuple[bool, List[int]]: ... - - -def InputInt3( - label: str, - v: List[int], - flags: ImGuiInputTextFlags = ImGuiInputTextFlags(0), -) -> Tuple[bool, List[int]]: ... - - -def InputInt4( - label: str, - v: List[int], - flags: ImGuiInputTextFlags = ImGuiInputTextFlags(0), -) -> Tuple[bool, List[int]]: ... - - -def InputDouble( - label: str, - v: float, - step: float = 0.0, - step_fast: float = 0.0, - format: str = "%.6f", - flags: ImGuiInputTextFlags = ImGuiInputTextFlags(0), -) -> Tuple[bool, float]: ... - -# Widgets: Color Editor/Picker - - -def ColorEdit3( - label: str, col: List[float], flags: ImGuiColorEditFlags = ImGuiColorEditFlags(0) -) -> Tuple[bool, List[float]]: ... - - -def ColorEdit4( - label: str, col: List[float], flags: ImGuiColorEditFlags = ImGuiColorEditFlags(0) -) -> Tuple[bool, List[float]]: ... - - -def ColorPicker3( - label: str, col: List[float], flags: ImGuiColorEditFlags = ImGuiColorEditFlags(0) -) -> Tuple[bool, List[float]]: ... - - -def ColorPicker4( - label: str, - col: List[float], - flags: ImGuiColorEditFlags = ImGuiColorEditFlags(0), - ref_col: Optional[List[float]] = None, -) -> Tuple[bool, List[float]]: ... - - -def ColorButton( - desc_id: str, col: ImVec4, flags: ImGuiColorEditFlags = ImGuiColorEditFlags(0), size: ImVec2 = (0, 0) -) -> bool: ... -def SetColorEditOptions(flags: ImGuiColorEditFlags) -> None: ... - -# Widgets: Trees - - -def TreeNode(label: str) -> bool: ... -def TreeNodeEx( - label: str, flags: ImGuiTreeNodeFlags = ImGuiTreeNodeFlags(0)) -> bool: ... - - -def TreePush(str_id: str) -> None: ... -def TreePop() -> None: ... -def GetTreeNodeToLabelSpacing() -> float: ... - - -@overload -def CollapsingHeader( - label: str, flags: ImGuiTreeNodeFlags = ImGuiTreeNodeFlags(0)) -> bool: ... - - -@overload -def CollapsingHeader( - label: str, open: bool, flags: ImGuiTreeNodeFlags = ImGuiTreeNodeFlags(0) -) -> Tuple[bool, bool]: ... - -# Widgets: Selectables - - -def Selectable( - label: str, - selected: bool = False, - flags: ImGuiSelectableFlags = ImGuiSelectableFlags(0), - size: ImVec2 = (0, 0), -) -> Tuple[bool, bool]: ... - -# Widgets: List Boxes - - -def ListBox( - label: str, current_item: int, items: List[str], height_in_items: int = -1 -) -> Tuple[bool, int]: ... -def ListBoxHeader(label: str, size: ImVec2 = (0, 0)) -> bool: ... -def ListBoxFooter() -> None: ... - -# Widgets: Data Plotting - - -def PlotLines( - label: str, - values: List[float], - values_offset: int = 0, - overlay_text: Optional[str] = None, - scale_min: float = np.finfo(np.float32).max, - scale_max: float = np.finfo(np.float32).max, - graph_size: ImVec2 = (0, 0), -) -> None: ... - - -def PlotHistogram( - label: str, - values: List[float], - values_offset: int = 0, - overlay_text: Optional[str] = None, - scale_min: float = np.finfo(np.float32).max, - scale_max: float = np.finfo(np.float32).max, - graph_size: ImVec2 = (0, 0), -) -> None: ... - -# Widgets: Value() Helpers. - - -def Value( - prefix: str, v: Union[bool, int, float], float_format: Optional[str] = None -) -> None: ... - -# Widgets: Menus - - -def BeginMenuBar() -> bool: ... -def EndMenuBar() -> None: ... -def BeginMainMenuBar() -> bool: ... -def EndMainMenuBar() -> None: ... -def BeginMenu(label: str, enabled: bool = True) -> bool: ... -def EndMenu() -> None: ... - - -def MenuItem( - label: str, shortcut: Optional[str], selected: bool = False, enabled: bool = False -) -> Tuple[bool, bool]: ... - -# Tooltips - - -def BeginTooltip() -> None: ... -def EndTooltip() -> None: ... -def SetTooltip(value: str) -> None: ... - -# Popups, Modals - - -def OpenPopup(str_id: str) -> None: ... - - -def BeginPopUp( - str_id: str, flags: ImGuiWindowFlags = ImGuiWindowFlags(0)) -> bool: ... - - -def BeginPopupContextItem( - str_id: Optional[str], mouse_button: ImGuiMouseButton = ImGuiMouseButton(1) -) -> bool: ... - - -def BeginPopupContextWindow( - str_id: Optional[str], - mouse_button: ImGuiMouseButton = ImGuiMouseButton(1), - also_over_items: bool = True, -) -> bool: ... - - -def BeginPopupContextVoid( - str_id: Optional[str], mouse_button: ImGuiMouseButton = ImGuiMouseButton(1) -) -> bool: ... - - -def BeginPopupModal( - name: str, open: bool, flags: ImGuiWindowFlags = ImGuiWindowFlags(0) -) -> Tuple[bool, bool]: ... -def EndPopup() -> None: ... - - -def OpenPopupOnItemClick( - str_id: Optional[str], mouse_button: ImGuiMouseButton = ImGuiMouseButton(1) -) -> bool: ... -def IsPopupOpen(str_id: str) -> bool: ... -def CloseCurrentPopup() -> None: ... - - -# Tables - -def BeginTable(str_id: str, columns: int, flags: int - = 0, size: ImVec2 = (0,0), - innerwidth: float = 0.) -> bool: ... -def EndTable() -> None: ... -def TableNextRow(flags: ImGuiTableRowFlags = 0, - min_row_height: float = 0) -> None:... -def TableNextColumn() -> bool: ... -def TableSetColumnIndex(column_n: int) -> None:... - -def TableSetupColumn(label: str, flags: ImGuiTableColumnFlags - = 0, init_width_or_height: float = 0, - user_id: ImGuiID = 0) -> None: -def TableSetupScrollFreeze(cols: int, rows: int) -> None:... -def TableHeader(label: str) -> None:... -def TableHeadersRow() -> None:... -def TableAngledHeadersRow() -> None:... - -def TableGetColumnCount() -> int:... -def TableGetColumnIndex() -> int:... -def TableGetRowIndex() -> int:... -def TableGetColumnName() -> str:... -def TableSetColumnEnabled(column_n: int, v: bool) -> None:... -def TableGetHoveredColumn() -> int:... -def TableSetBgColor(target: ImGuiTableBgTarget, color: ImU32, - column_n: int = -1) -> None:... - -# Columns - - -def Columns(count: int = 1, id: Optional[str] - = None, border: bool = True) -> None: ... - - -def NextColumn() -> None: ... -def GetColumnIndex() -> int: ... -def GetColumnWidth(column_index: int = -1) -> float: ... -def SetColumnWidth(column_index: int, width: float) -> None: ... -def GetColumnOffset(column_index: int = -1) -> float: ... -def SetColumnOffset(column_index: int, offset_x: float) -> None: ... -def GetColumnsCount() -> int: ... - -# Tab Bars, Tabs - - -def BeginTabBar( - str_id: str, flags: ImGuiTabBarFlags = ImGuiTabBarFlags(0)) -> bool: ... - - -def EndTabBar() -> None: ... - - -def BeginTabItem( - label: str, open: bool, flags: ImGuiTabItemFlags = ImGuiTabItemFlags(0) -) -> Tuple[bool, bool]: ... -def EndTabItem() -> None: ... -def SetTabItemClosed(tab_or_docked_window_label: str) -> None: ... - -# Logging/Capture - - -def LogToTTY(auto_open_depth: int = -1) -> None: ... -def LogToFile(auto_open_depth: int = -1, - filename: Optional[str] = None) -> None: ... - - -def LogToClipboard(auto_open_depth: int = -1) -> None: ... -def LogFinish() -> None: ... -def LogButtons() -> None: ... - -# Clipping - - -def PushClipRect( - clip_rect_min: ImVec2, clip_rect_max: ImVec2, intersect_with_current_clip_rect: bool -) -> None: ... -def PopClipRect() -> None: ... - -# Focus, Activation - - -def SetItemDefaultFocus() -> None: ... -def SetKeyboardFocusHere(offset: int = 0) -> None: ... - -# Item/Widgets Utilities - - -def IsItemHovered(flags: ImGuiHoveredFlags = ImGuiHoveredFlags(0)) -> bool: ... -def IsItemActive() -> bool: ... -def IsItemFocused() -> bool: ... -def IsItemClicked( - mouse_button: ImGuiMouseButton = ImGuiMouseButton(0)) -> bool: ... - - -def IsItemVisible() -> bool: ... -def IsItemEdited() -> bool: ... -def IsItemActivated() -> bool: ... -def IsItemDeactivated() -> bool: ... -def IsItemDeactivatedAfterEdit() -> bool: ... -def IsItemToggledOpen() -> bool: ... -def IsAnyItemHovered() -> bool: ... -def IsAnyItemActive() -> bool: ... -def IsAnyItemFocused() -> bool: ... -def GetItemRectMin() -> ImVec2: ... -def GetItemRectMax() -> ImVec2: ... -def GetItemRectSize() -> ImVec2: ... -def SetItemAllowOverlap() -> None: ... - -# Miscellaneous Utilities - - -@overload -def IsRectVisible(size: ImVec2) -> bool: ... -@overload -def IsRectVisible(rect_min: ImVec2, rect_max: ImVec2) -> bool: ... - -def GetTime() -> float: ... -def GetFrameCount() -> int: ... -def GetStyleColorName(idx: ImGuiCol) -> str: ... - - -def CalcListClipping( - items_count: int, items_height: float) -> Tuple[int, int]: ... -def BeginChildFrame(id: ImGuiID, size: ImVec2, - flags: ImGuiWindowFlags = ImGuiWindowFlags(0)) -> bool: ... - - -def EndChildFrame() -> None: ... - -# Text Utilities - - -def CalcTextSize( - text: str, - text_end: Optional[str] = None, - hide_text_after_double_hash: bool = False, - wrap_width: float = -1.0, -) -> ImVec2: ... - -# Inputs Utilities: Keyboard - - -def GetKeyIndex(imgui_key: ImGuiKey) -> int: ... -def IsKeyDown(user_key_index: int) -> bool: ... -def IsKeyPressed(user_key_index: int, repeat: bool = True) -> bool: ... -def IsKeyReleased(user_key_index: int) -> bool: ... - - -def GetKeyPressedAmount( - key_index: int, repeat_delay: float, rate: float) -> int: ... -def CaptureKeyboardFromApp( - want_capture_keyboard_value: bool = True) -> None: ... - -# Inputs Utilities: Mouse - - -def IsMouseDown(button: ImGuiMouseButton) -> bool: ... -def IsMouseClicked(button: ImGuiMouseButton, repeat: bool = False) -> bool: ... -def IsMouseReleased(button: ImGuiMouseButton) -> bool: ... -def IsMouseDoubleClicked(button: ImGuiMouseButton) -> bool: ... -def IsMouseHoveringRect(r_min: ImVec2, r_max: ImVec2, - clip: bool = True) -> bool: ... - - -def IsMousePosValid(mouse_pos: Optional[ImVec2]) -> bool: ... -def IsAnyMouseDown() -> bool: ... -def GetMousePos() -> ImVec2: ... -def GetMousePosOnOpeningCurrentPopup() -> ImVec2: ... - - -def IsMouseDragging(button: ImGuiMouseButton, - lock_threshold: float = -1.0) -> bool: ... - - -def GetMouseDragDelta( - button: ImGuiMouseButton, lock_threshold: float = -1.0 -) -> bool: ... -def ResetMouseDragDelta(button: ImGuiMouseButton) -> None: ... -def GetMouseCursor() -> ImGuiMouseCursor: ... -def SetMouseCursor(cursor_type: ImGuiMouseCursor) -> None: ... -def CaptureMouseFromApp(want_capture_mouse_value: bool = True) -> None: ... - -# Clipboard Utilities - - -def GetClipboardText() -> str: ... -def SetClipboardText(text: str) -> None: ... - -# Settings/.Ini Utilities - - -def LoadIniSettingsFromDisk(ini_filename: str) -> None: ... -def LoadIniSettingsFromMemory(ini_data: str) -> None: ... -def SaveIniSettingsToDisk(ini_filename: str) -> None: ... -def SaveIniSettingsToMemory() -> str: ... - - -# Draw Commands - -def AddLine(p1: ImVec2, p2: ImVec2, col: ImU32, thickness: float = 1.) -> None: ... -def AddRect(p_min: ImVec2, p_max: ImVec2, col: ImU32, rounding: float = 0., flags: ImDrawFlags = 0, thickness: float = 1.) -> None: ... -def AddRectFilled(p_min: ImVec2, p_max: ImVec2, col: ImU32, rounding: float = 0., flags: ImDrawFlags = 0) -> None: ... -def AddAddRectFilledMultiColor(p_min: ImVec2, p_max: ImVec2, col_upr_left: ImU32, col_upr_right: ImU32, col_bot_right: ImU32, col_bot_left: ImU32) -> None: ... -def AddQuad(p1: ImVec2, p2: ImVec2, p3: ImVec2, p4: ImVec2, col: ImU32, thickness: float = 1.) -> None: ... -def AddQuadFilled(p1: ImVec2, p2: ImVec2, p3: ImVec2, p4: ImVec2, col: ImU32) -> None: ... -def AddTriangle(p1: ImVec2, p2: ImVec2, p3: ImVec2, col: ImU32, thickness: float = 1.) -> None: ... -def AddTriangleFilled(p1: ImVec2, p2: ImVec2, p3: ImVec2, col: ImU32) -> None: ... -def AddCircle(center: ImVec2, radius: float, col: ImU32, num_segments: int = 0, thickness: float = 1.) -> None: ... -def AddCircleFilled(center: ImVec2, radius: float, col: ImU32, num_segments: int = 0) -> None: ... -def AddNgon(center: ImVec2, radius: float, col: ImU32, num_segments: int, thickness: float = 1.) -> None: ... -def AddNgonFilled(center: ImVec2, radius: float, col: ImU32, num_segments: int) -> None: ... -def AddText(pos: ImVec2, col: ImU32, text: str, text_end: Optional[str] = None) -> None: ... -def AddPolyline(points: List[ImVec2], num_points: int, col: ImU32, flags: ImDrawFlags, thickness) -> None: ... -def AddConvexPolyFilled(points: List[ImVec2], num_points: int, col: ImU32) -> None: ... -def AddBezierCubic(p1: ImVec2, p2: ImVec2, p3: ImVec2, p4: ImVec2, col: ImU32, thickness: float, num_segments: int = 0) -> None: ... -def AddBezierQuadratic(p1: ImVec2, p2: ImVec2, p3: ImVec2, col: ImU32, thickness: float, num_segments: int = 0) -> None: ... - - -ImGuiWindowFlags_None: int -ImGuiWindowFlags_NoTitleBar: int -ImGuiWindowFlags_NoResize: int -ImGuiWindowFlags_NoMove: int -ImGuiWindowFlags_NoScrollbar: int -ImGuiWindowFlags_NoScrollWithMouse: int -ImGuiWindowFlags_NoCollapse: int -ImGuiWindowFlags_AlwaysAutoResize: int -ImGuiWindowFlags_NoBackground: int -ImGuiWindowFlags_NoSavedSettings: int -ImGuiWindowFlags_NoMouseInputs: int -ImGuiWindowFlags_MenuBar: int -ImGuiWindowFlags_HorizontalScrollbar: int -ImGuiWindowFlags_NoFocusOnAppearing: int -ImGuiWindowFlags_NoBringToFrontOnFocus: int -ImGuiWindowFlags_AlwaysVerticalScrollbar: int -ImGuiWindowFlags_AlwaysHorizontalScrollbar: int -ImGuiWindowFlags_AlwaysUseWindowPadding: int -ImGuiWindowFlags_NoNavInputs: int -ImGuiWindowFlags_NoNavFocus: int -ImGuiWindowFlags_UnsavedDocument: int -ImGuiWindowFlags_NoNav: int -ImGuiWindowFlags_NoDecoration: int -ImGuiWindowFlags_NoInputs: int -ImGuiWindowFlags_NavFlattened: int -ImGuiWindowFlags_ChildWindow: int -ImGuiWindowFlags_Tooltip: int -ImGuiWindowFlags_Popup: int -ImGuiWindowFlags_Modal: int -ImGuiWindowFlags_ChildMenu: int -ImGuiInputTextFlags_None: int -ImGuiInputTextFlags_CharsDecimal: int -ImGuiInputTextFlags_CharsHexadecimal: int -ImGuiInputTextFlags_CharsUppercase: int -ImGuiInputTextFlags_CharsNoBlank: int -ImGuiInputTextFlags_AutoSelectAll: int -ImGuiInputTextFlags_EnterReturnsTrue: int -ImGuiInputTextFlags_CallbackCompletion: int -ImGuiInputTextFlags_CallbackHistory: int -ImGuiInputTextFlags_CallbackAlways: int -ImGuiInputTextFlags_CallbackCharFilter: int -ImGuiInputTextFlags_AllowTabInput: int -ImGuiInputTextFlags_CtrlEnterForNewLine: int -ImGuiInputTextFlags_NoHorizontalScroll: int -ImGuiInputTextFlags_AlwaysInsertMode: int -ImGuiInputTextFlags_ReadOnly: int -ImGuiInputTextFlags_Password: int -ImGuiInputTextFlags_NoUndoRedo: int -ImGuiInputTextFlags_CharsScientific: int -ImGuiInputTextFlags_CallbackResize: int -ImGuiInputTextFlags_Multiline: int -ImGuiInputTextFlags_NoMarkEdited: int -ImGuiTreeNodeFlags_None: int -ImGuiTreeNodeFlags_Selected: int -ImGuiTreeNodeFlags_Framed: int -ImGuiTreeNodeFlags_AllowItemOverlap: int -ImGuiTreeNodeFlags_NoTreePushOnOpen: int -ImGuiTreeNodeFlags_NoAutoOpenOnLog: int -ImGuiTreeNodeFlags_DefaultOpen: int -ImGuiTreeNodeFlags_OpenOnDoubleClick: int -ImGuiTreeNodeFlags_OpenOnArrow: int -ImGuiTreeNodeFlags_Leaf: int -ImGuiTreeNodeFlags_Bullet: int -ImGuiTreeNodeFlags_FramePadding: int -ImGuiTreeNodeFlags_SpanAvailWidth: int -ImGuiTreeNodeFlags_SpanFullWidth: int -ImGuiTreeNodeFlags_NavLeftJumpsBackHere: int -ImGuiTreeNodeFlags_CollapsingHeader: int -ImGuiSelectableFlags_None: int -ImGuiSelectableFlags_DontClosePopups: int -ImGuiSelectableFlags_SpanAllColumns: int -ImGuiSelectableFlags_AllowDoubleClick: int -ImGuiSelectableFlags_Disabled: int -ImGuiSelectableFlags_AllowItemOverlap: int -ImGuiComboFlags_None: int -ImGuiComboFlags_PopupAlignLeft: int -ImGuiComboFlags_HeightSmall: int -ImGuiComboFlags_HeightRegular: int -ImGuiComboFlags_HeightLarge: int -ImGuiComboFlags_HeightLargest: int -ImGuiComboFlags_NoArrowButton: int -ImGuiComboFlags_NoPreview: int -ImGuiComboFlags_HeightMask_: int -ImGuiTabBarFlags_None: int -ImGuiTabBarFlags_Reorderable: int -ImGuiTabBarFlags_AutoSelectNewTabs: int -ImGuiTabBarFlags_TabListPopupButton: int -ImGuiTabBarFlags_NoCloseWithMiddleMouseButton: int -ImGuiTabBarFlags_NoTabListScrollingButtons: int -ImGuiTabBarFlags_NoTooltip: int -ImGuiTabBarFlags_FittingPolicyResizeDown: int -ImGuiTabBarFlags_FittingPolicyScroll: int -ImGuiTabBarFlags_FittingPolicyMask_: int -ImGuiTabBarFlags_FittingPolicyDefault_: int -ImGuiTabItemFlags_None: int -ImGuiTabItemFlags_UnsavedDocument: int -ImGuiTabItemFlags_SetSelected: int -ImGuiTabItemFlags_NoCloseWithMiddleMouseButton: int -ImGuiTabItemFlags_NoPushId: int -ImGuiFocusedFlags_None: int -ImGuiFocusedFlags_ChildWindows: int -ImGuiFocusedFlags_RootWindow: int -ImGuiFocusedFlags_AnyWindow: int -ImGuiFocusedFlags_RootAndChildWindows: int -ImGuiHoveredFlags_None: int -ImGuiHoveredFlags_ChildWindows: int -ImGuiHoveredFlags_RootWindow: int -ImGuiHoveredFlags_AnyWindow: int -ImGuiHoveredFlags_AllowWhenBlockedByPopup: int -ImGuiHoveredFlags_AllowWhenBlockedByActiveItem: int -ImGuiHoveredFlags_AllowWhenOverlapped: int -ImGuiHoveredFlags_AllowWhenDisabled: int -ImGuiHoveredFlags_RectOnly: int -ImGuiHoveredFlags_RootAndChildWindows: int -ImGuiDragDropFlags_None: int -ImGuiDragDropFlags_SourceNoPreviewTooltip: int -ImGuiDragDropFlags_SourceNoDisableHover: int -ImGuiDragDropFlags_SourceNoHoldToOpenOthers: int -ImGuiDragDropFlags_SourceAllowNullID: int -ImGuiDragDropFlags_SourceExtern: int -ImGuiDragDropFlags_SourceAutoExpirePayload: int -ImGuiDragDropFlags_AcceptBeforeDelivery: int -ImGuiDragDropFlags_AcceptNoDrawDefaultRect: int -ImGuiDragDropFlags_AcceptNoPreviewTooltip: int -ImGuiDragDropFlags_AcceptPeekOnly: int -ImGuiDataType_S8: int -ImGuiDataType_U8: int -ImGuiDataType_S16: int -ImGuiDataType_U16: int -ImGuiDataType_S32: int -ImGuiDataType_U32: int -ImGuiDataType_S64: int -ImGuiDataType_U64: int -ImGuiDataType_Float: int -ImGuiDataType_Double: int -ImGuiDataType_COUN: int -ImGuiDir_None: int -ImGuiDir_Left: int -ImGuiDir_Right: int -ImGuiDir_Up: int -ImGuiDir_Down: int -ImGuiDir_COUNT: int -ImGuiKey_Tab: int -ImGuiKey_LeftArrow: int -ImGuiKey_RightArrow: int -ImGuiKey_UpArrow: int -ImGuiKey_DownArrow: int -ImGuiKey_PageUp: int -ImGuiKey_PageDown: int -ImGuiKey_Home: int -ImGuiKey_End: int -ImGuiKey_Insert: int -ImGuiKey_Delete: int -ImGuiKey_Backspace: int -ImGuiKey_Space: int -ImGuiKey_Enter: int -ImGuiKey_Escape: int -ImGuiKey_KeyPadEnter: int -ImGuiKey_A: int -ImGuiKey_C: int -ImGuiKey_V: int -ImGuiKey_X: int -ImGuiKey_Y: int -ImGuiKey_Z: int -ImGuiKey_COUNT: int -ImGuiKeyModFlags_None: int -ImGuiKeyModFlags_Ctrl: int -ImGuiKeyModFlags_Shift: int -ImGuiKeyModFlags_Alt: int -ImGuiKeyModFlags_Super: int -ImGuiNavInput_Activate: int -ImGuiNavInput_Cancel: int -ImGuiNavInput_Input: int -ImGuiNavInput_Menu: int -ImGuiNavInput_DpadLeft: int -ImGuiNavInput_DpadRight: int -ImGuiNavInput_DpadUp: int -ImGuiNavInput_DpadDown: int -ImGuiNavInput_LStickLeft: int -ImGuiNavInput_LStickRight: int -ImGuiNavInput_LStickUp: int -ImGuiNavInput_LStickDown: int -ImGuiNavInput_FocusPrev: int -ImGuiNavInput_FocusNext: int -ImGuiNavInput_TweakSlow: int -ImGuiNavInput_TweakFast: int -ImGuiNavInput_KeyMenu_: int -ImGuiNavInput_KeyLeft_: int -ImGuiNavInput_KeyRight_: int -ImGuiNavInput_KeyUp_: int -ImGuiNavInput_KeyDown_: int -ImGuiNavInput_COUNT: int -ImGuiNavInput_InternalStart_: int -ImGuiConfigFlags_None: int -ImGuiConfigFlags_NavEnableKeyboard: int -ImGuiConfigFlags_NavEnableGamepad: int -ImGuiConfigFlags_NavEnableSetMousePos: int -ImGuiConfigFlags_NavNoCaptureKeyboard: int -ImGuiConfigFlags_NoMouse: int -ImGuiConfigFlags_NoMouseCursorChange: int -ImGuiConfigFlags_IsSRGB: int -ImGuiConfigFlags_IsTouchScreen: int -ImGuiBackendFlags_None: int -ImGuiBackendFlags_HasGamepad: int -ImGuiBackendFlags_HasMouseCursors: int -ImGuiBackendFlags_HasSetMousePos: int -ImGuiBackendFlags_RendererHasVtxOffset: int -ImGuiCol_Text: int -ImGuiCol_TextDisabled: int -ImGuiCol_WindowBg: int -ImGuiCol_ChildBg: int -ImGuiCol_PopupBg: int -ImGuiCol_Border: int -ImGuiCol_BorderShadow: int -ImGuiCol_FrameBg: int -ImGuiCol_FrameBgHovered: int -ImGuiCol_FrameBgActive: int -ImGuiCol_TitleBg: int -ImGuiCol_TitleBgActive: int -ImGuiCol_TitleBgCollapsed: int -ImGuiCol_MenuBarBg: int -ImGuiCol_ScrollbarBg: int -ImGuiCol_ScrollbarGrab: int -ImGuiCol_ScrollbarGrabHovered: int -ImGuiCol_ScrollbarGrabActive: int -ImGuiCol_CheckMark: int -ImGuiCol_SliderGrab: int -ImGuiCol_SliderGrabActive: int -ImGuiCol_Button: int -ImGuiCol_ButtonHovered: int -ImGuiCol_ButtonActive: int -ImGuiCol_Header: int -ImGuiCol_HeaderHovered: int -ImGuiCol_HeaderActive: int -ImGuiCol_Separator: int -ImGuiCol_SeparatorHovered: int -ImGuiCol_SeparatorActive: int -ImGuiCol_ResizeGrip: int -ImGuiCol_ResizeGripHovered: int -ImGuiCol_ResizeGripActive: int -ImGuiCol_Tab: int -ImGuiCol_TabHovered: int -ImGuiCol_TabActive: int -ImGuiCol_TabUnfocused: int -ImGuiCol_TabUnfocusedActive: int -ImGuiCol_PlotLines: int -ImGuiCol_PlotLinesHovered: int -ImGuiCol_PlotHistogram: int -ImGuiCol_PlotHistogramHovered: int -ImGuiCol_TextSelectedBg: int -ImGuiCol_DragDropTarget: int -ImGuiCol_NavHighlight: int -ImGuiCol_NavWindowingHighlight: int -ImGuiCol_NavWindowingDimBg: int -ImGuiCol_ModalWindowDimBg: int -ImGuiCol_COUNT: int -ImGuiStyleVar_Alpha: int -ImGuiStyleVar_WindowPadding: int -ImGuiStyleVar_WindowRounding: int -ImGuiStyleVar_WindowBorderSize: int -ImGuiStyleVar_WindowMinSize: int -ImGuiStyleVar_WindowTitleAlign: int -ImGuiStyleVar_ChildRounding: int -ImGuiStyleVar_ChildBorderSize: int -ImGuiStyleVar_PopupRounding: int -ImGuiStyleVar_PopupBorderSize: int -ImGuiStyleVar_FramePadding: int -ImGuiStyleVar_FrameRounding: int -ImGuiStyleVar_FrameBorderSize: int -ImGuiStyleVar_ItemSpacing: int -ImGuiStyleVar_ItemInnerSpacing: int -ImGuiStyleVar_IndentSpacing: int -ImGuiStyleVar_ScrollbarSize: int -ImGuiStyleVar_ScrollbarRounding: int -ImGuiStyleVar_GrabMinSize: int -ImGuiStyleVar_GrabRounding: int -ImGuiStyleVar_TabRounding: int -ImGuiStyleVar_ButtonTextAlign: int -ImGuiStyleVar_SelectableTextAlign: int -ImGuiStyleVar_COUNT: int -ImGuiColorEditFlags_None: int -ImGuiColorEditFlags_NoAlpha: int -ImGuiColorEditFlags_NoPicker: int -ImGuiColorEditFlags_NoOptions: int -ImGuiColorEditFlags_NoSmallPreview: int -ImGuiColorEditFlags_NoInputs: int -ImGuiColorEditFlags_NoTooltip: int -ImGuiColorEditFlags_NoLabel: int -ImGuiColorEditFlags_NoSidePreview: int -ImGuiColorEditFlags_NoDragDrop: int -ImGuiColorEditFlags_NoBorder: int -ImGuiColorEditFlags_AlphaBar: int -ImGuiColorEditFlags_AlphaPreview: int -ImGuiColorEditFlags_AlphaPreviewHalf: int -ImGuiColorEditFlags_HDR: int -ImGuiColorEditFlags_DisplayRGB: int -ImGuiColorEditFlags_DisplayHSV: int -ImGuiColorEditFlags_DisplayHex: int -ImGuiColorEditFlags_Uint8: int -ImGuiColorEditFlags_Float: int -ImGuiColorEditFlags_PickerHueBar: int -ImGuiColorEditFlags_PickerHueWheel: int -ImGuiColorEditFlags_InputRGB: int -ImGuiColorEditFlags_InputHSV: int -ImGuiColorEditFlags__OptionsDefault: int -ImGuiColorEditFlags__DisplayMask: int -ImGuiColorEditFlags__DataTypeMask: int -ImGuiColorEditFlags__PickerMask: int -ImGuiColorEditFlags__InputMask: int -ImGuiMouseButton_Left: int -ImGuiMouseButton_Right: int -ImGuiMouseButton_Middle: int -ImGuiMouseButton_COUNT: int -ImGuiMouseCursor_None: int -ImGuiMouseCursor_Arrow: int -ImGuiMouseCursor_TextInput: int -ImGuiMouseCursor_ResizeAll: int -ImGuiMouseCursor_ResizeNS: int -ImGuiMouseCursor_ResizeEW: int -ImGuiMouseCursor_ResizeNESW: int -ImGuiMouseCursor_ResizeNWSE: int -ImGuiMouseCursor_Hand: int -ImGuiMouseCursor_NotAllowed: int -ImGuiMouseCursor_COUNT: int -ImGuiCond_Always: int -ImGuiCond_Once: int -ImGuiCond_FirstUseEver: int -ImGuiCond_Appearing: int diff --git a/test/polyscope_test.py b/test/polyscope_test.py index 6a79952..54e0177 100644 --- a/test/polyscope_test.py +++ b/test/polyscope_test.py @@ -2,9 +2,9 @@ import os import sys import os.path as path -import numpy as np from os import listdir from os.path import isfile, join +from collections import defaultdict # Path to where the bindings live sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "src"))) @@ -15,2764 +15,38 @@ # normal / unix case sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "build"))) +import polyscope as ps +import polyscope.imgui as psim +import polyscope.implot as psimplot -import polyscope as ps -import polyscope.imgui as psim -import polyscope.implot as psimplot - -# Path to test assets -assets_prefix = path.join(path.dirname(__file__), "assets/") - -def assertArrayWithShape(self, arr, shape): - self.assertTrue(isinstance(arr, np.ndarray)) - self.assertEqual(tuple(arr.shape), tuple(shape)) - -class TestCore(unittest.TestCase): - - - def test_show(self): - ps.show(forFrames=3) - - def test_frame_tick(self): - for i in range(4): - ps.frame_tick() - - def test_frame_tick_imgui(self): - def callback(): - psim.Button("test button") - ps.set_user_callback(callback) - for i in range(4): - ps.frame_tick() - - def test_unshow(self): - counts = [0] - def callback(): - counts[0] = counts[0] + 1 - if(counts[0] > 2): - ps.unshow() - - ps.set_user_callback(callback) - ps.show(10) - - self.assertLess(counts[0], 4) - - - def test_options(self): - - # Remember, polyscope has global state, so we're actually setting these for the remainder of the tests (lol) - - ps.set_program_name("polyscope test prog") - ps.set_verbosity(2) - ps.set_print_prefix("[polyscope test] ") - ps.set_errors_throw_exceptions(True) - ps.set_max_fps(60) - ps.set_enable_vsync(True) - ps.set_use_prefs_file(True) - ps.set_do_default_mouse_interaction(True) - ps.set_always_redraw(False) - - self.assertTrue(ps.is_headless() in [True, False]) - ps.set_allow_headless_backends(True) - ps.set_egl_device_index(-1) - - ps.set_enable_render_error_checks(True) - ps.set_enable_render_error_checks(True) - ps.set_warn_for_invalid_values(True) - ps.set_warn_for_invalid_values(False) - ps.set_display_message_popups(False) - ps.set_autocenter_structures(False) - ps.set_autoscale_structures(False) - - ps.request_redraw() - self.assertTrue(ps.get_redraw_requested()) - ps.set_always_redraw(False) - ps.set_frame_tick_limit_fps_mode('ignore_limits') - ps.set_frame_tick_limit_fps_mode('block_to_hit_target') - ps.set_frame_tick_limit_fps_mode('skip_frames_to_hit_target') - - ps.set_ui_scale(0.8) - self.assertAlmostEqual(ps.get_ui_scale(), 0.8) - - ps.set_build_gui(True) - ps.set_render_scene(True) - ps.set_open_imgui_window_for_user_callback(True) - ps.set_invoke_user_callback_for_nested_show(False) - ps.set_give_focus_on_show(True) - - ps.set_background_color((0.7, 0.8, 0.9)) - ps.set_background_color((0.7, 0.8, 0.9, 0.9)) - ps.get_background_color() - - ps.get_final_scene_color_texture_native_handle() - - ps.show(3) - - # these makes tests run a little faster - ps.set_max_fps(-1) - ps.set_enable_vsync(False) - - def test_callbacks(self): - - # Simple callback function - # (we use 'counts' to ensure it gets called) - counts = [0] - def sample_callback(): - counts[0] = counts[0] + 1 - - ps.set_user_callback(sample_callback) - ps.show(3) - self.assertEqual(3, counts[0]) # Make sure the callback got called - ps.clear_user_callback() - ps.show(3) - 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): - - ps.set_navigation_style("turntable") - ps.set_navigation_style("free") - ps.set_navigation_style("planar") - ps.set_navigation_style("none") - ps.set_navigation_style("first_person") - ps.set_navigation_style(ps.get_navigation_style()) - - ps.set_up_dir("x_up") - ps.set_up_dir("neg_x_up") - ps.set_up_dir("y_up") - ps.set_up_dir("neg_y_up") - ps.set_up_dir("z_up") - ps.set_up_dir("neg_z_up") - ps.set_up_dir(ps.get_up_dir()) - - ps.set_front_dir("x_front") - ps.set_front_dir("neg_x_front") - ps.set_front_dir("y_front") - ps.set_front_dir("neg_y_front") - ps.set_front_dir("z_front") - ps.set_front_dir("neg_z_front") - ps.set_front_dir(ps.get_front_dir()) - - ps.set_vertical_fov_degrees(50.) - self.assertEqual(ps.get_vertical_fov_degrees(), 50.) - self.assertGreater(ps.get_aspect_ratio_width_over_height(), 0.01) - - ps.set_view_projection_mode("orthographic") - ps.set_view_projection_mode("perspective") - - ps.set_camera_view_matrix(ps.get_camera_view_matrix()) - - ps.set_view_center((0.1, 0.1, 0.2)) - ps.set_view_center(ps.get_view_center(), fly_to=True) - - ps.set_window_size(800, 600) - self.assertEqual(ps.get_window_size(), (800,600)) - - tup = ps.get_buffer_size() - w, h = int(tup[0]), int(tup[1]) - - ps.set_window_resizable(True) - self.assertEqual(ps.get_window_resizable(), True) - - ps.show(3) - - ps.set_up_dir("y_up") - - def test_camera_movement(self): - - ps.reset_camera_to_home_view() - - ps.look_at((0., 0., 5.), (1., 1., 1.)) - ps.look_at(np.array((0., 0., 5.)), (1., 1., 1.), fly_to=True) - - ps.look_at_dir((0., 0., 5.), (1., 1., 1.), (-1., -1., 0.)) - ps.look_at_dir((0., 0., 5.), (1., 1., 1.), np.array((-1., -1., 0.)), fly_to=True) - - ps.show(3) - - def test_view_json(self): - ps.set_view_from_json(ps.get_view_as_json()) - - def test_screen_coords(self): - io = psim.GetIO() - screen_coords = io.MousePos - world_ray = ps.screen_coords_to_world_ray(screen_coords) - world_pos = ps.screen_coords_to_world_position(screen_coords) - - def test_ground_options(self): - - ps.set_ground_plane_mode("none") - ps.set_ground_plane_mode("tile") - ps.set_ground_plane_mode("tile_reflection") - ps.set_ground_plane_mode("shadow_only") - - ps.set_ground_plane_height_factor(1.5, is_relative=False) - ps.set_ground_plane_height_factor(0.) - - ps.set_ground_plane_height(0.) - ps.set_ground_plane_height_mode('automatic') - ps.set_ground_plane_height_mode('manual') - - ps.set_shadow_blur_iters(3) - ps.set_shadow_darkness(0.1) - - ps.show(3) - - def test_transparency_options(self): - - ps.set_transparency_mode('none') - ps.set_transparency_mode('simple') - ps.set_transparency_mode('pretty') - - ps.set_transparency_render_passes(6) - - ps.show(3) - - ps.set_transparency_mode('none') - - def test_render_options(self): - - ps.set_SSAA_factor(2) - ps.show(3) - ps.set_SSAA_factor(1) - - def test_screenshot(self): - - ps.screenshot() - ps.screenshot(transparent_bg=False) - ps.screenshot(include_UI=True) - ps.screenshot("test_shot.png", transparent_bg=True) - - ps.set_screenshot_extension(".jpg") - ps.set_screenshot_extension(".png") - - buff = ps.screenshot_to_buffer(False) - w, h = ps.get_buffer_size() - self.assertEqual(buff.shape, (h,w,4)) - - buff = ps.screenshot_to_buffer(False, include_UI=True) - - ps.show(3) - - - def test_picking(self): - - res = ps.pick(buffer_inds=(77,88)) - res = ps.pick(screen_coords=(0.78,.96)) - - ps.show(3) - - def test_slice_plane(self): - - # Test deprecated add_scene_slice_plane() function - plane1 = ps.add_scene_slice_plane() - plane2 = ps.add_scene_slice_plane() - - # Test set_enabled / get_enabled - plane2.set_enabled(True) - self.assertEqual(True, plane2.get_enabled()) - plane2.set_enabled(False) - self.assertEqual(False, plane2.get_enabled()) - - # Test set_pose with tuple - plane1.set_pose((-.5, 0., 0.), (1., 1., 1.)) - - # Test set_active / get_active - plane1.set_active(False) - self.assertEqual(False, plane1.get_active()) - plane1.set_active(True) - self.assertEqual(True, plane1.get_active()) - - # Test set_draw_plane / get_draw_plane - plane1.set_draw_plane(False) - self.assertEqual(False, plane1.get_draw_plane()) - plane1.set_draw_plane(True) - self.assertEqual(True, plane1.get_draw_plane()) - - # Test set_draw_widget / get_draw_widget - plane1.set_draw_widget(False) - self.assertEqual(False, plane1.get_draw_widget()) - plane1.set_draw_widget(True) - self.assertEqual(True, plane1.get_draw_widget()) - - ps.show(3) - - ps.remove_last_scene_slice_plane() - ps.remove_last_scene_slice_plane() - - # add with custom names - plane3 = ps.add_slice_plane("custom_plane_1") - self.assertEqual(plane3.get_name(), "custom_plane_1") - - plane4 = ps.add_slice_plane("custom_plane_2") - self.assertEqual(plane4.get_name(), "custom_plane_2") - - # Test get_slice_plane - retrieved_plane = ps.get_slice_plane("custom_plane_1") - self.assertEqual(retrieved_plane.get_name(), "custom_plane_1") - - # Test set_color / get_color - plane3.set_color((0.5, 0.6, 0.7)) - color = plane3.get_color() - for i in range(3): - self.assertAlmostEqual(color[i], [0.5, 0.6, 0.7][i], places=5) - - # Test set_grid_line_color / get_grid_line_color - plane3.set_grid_line_color((0.1, 0.2, 0.3)) - grid_color = plane3.get_grid_line_color() - for i in range(3): - self.assertAlmostEqual(grid_color[i], [0.1, 0.2, 0.3][i], places=5) - - # Test set_transparency / get_transparency - plane3.set_transparency(0.5) - self.assertAlmostEqual(0.5, plane3.get_transparency()) - plane3.set_transparency(0.0) - self.assertAlmostEqual(0.0, plane3.get_transparency()) - plane3.set_transparency(1.0) - self.assertAlmostEqual(1.0, plane3.get_transparency()) - - # Test set_pose with numpy array - plane4.set_pose(np.array([0.5, 0.5, 0.5]), np.array([0.0, 0.0, 1.0])) - - # Test get_center and get_normal - center = plane4.get_center() - self.assertIsNotNone(center) - self.assertEqual(len(center), 3) - - normal = plane4.get_normal() - self.assertIsNotNone(normal) - self.assertEqual(len(normal), 3) - - ps.show(3) - - # Test remove_slice_plane - ps.remove_slice_plane("custom_plane_1") - - # Test plane.remove() method - plane4.remove() - - # Test remove_all_slice_planes - ps.add_slice_plane("test1") - ps.add_slice_plane("test2") - ps.remove_all_slice_planes() - - def test_transformation_gizmo(self): - - # Create a gizmo - g1 = ps.add_transformation_gizmo("gizmo_1") - self.assertEqual(g1.get_name(), "gizmo_1") - - # Enable/disable - g1.set_enabled(True) - self.assertEqual(True, g1.get_enabled()) - g1.set_enabled(False) - self.assertEqual(False, g1.get_enabled()) - - # Set/get transform - T_I = np.eye(4) - g1.set_transform(T_I) - T_ret = g1.get_transform() - self.assertTrue(isinstance(T_ret, np.ndarray)) - self.assertEqual(T_ret.shape, (4,4)) - self.assertTrue(np.allclose(T_ret, T_I)) - - T2 = np.array([ - [1., 0., 0., 3.], - [0., 0., -1., -2.], - [0., 1., 0., 5.], - [0., 0., 0., 1.] - ]) - g1.set_transform(T2) - self.assertTrue(np.allclose(g1.get_transform(), T2)) - - # Get/set position - g1.set_position(np.array((1.0, 2.0, 3.0))) - self.assertTrue(np.allclose(g1.get_position(), np.array((1.0, 2.0, 3.0)))) - - # Allow toggles - g1.set_allow_translation(True) - self.assertEqual(True, g1.get_allow_translation()) - g1.set_allow_translation(False) - self.assertEqual(False, g1.get_allow_translation()) - - g1.set_allow_rotation(True) - self.assertEqual(True, g1.get_allow_rotation()) - g1.set_allow_rotation(False) - self.assertEqual(False, g1.get_allow_rotation()) - - g1.set_allow_scaling(True) - self.assertEqual(True, g1.get_allow_scaling()) - g1.set_allow_scaling(False) - self.assertEqual(False, g1.get_allow_scaling()) - - g1.set_allow_nonuniform_scaling(True) - self.assertEqual(True, g1.get_allow_nonuniform_scaling()) - g1.set_allow_nonuniform_scaling(False) - self.assertEqual(False, g1.get_allow_nonuniform_scaling()) - - # Local-space interaction toggle - g1.set_interact_in_local_space(True) - self.assertEqual(True, g1.get_interact_in_local_space()) - g1.set_interact_in_local_space(False) - self.assertEqual(False, g1.get_interact_in_local_space()) - - # Gizmo size (scale) getter/setter - g1.set_gizmo_scale(0.75) - self.assertAlmostEqual(0.75, g1.get_gizmo_scale()) - - # Retrieve by name - g1b = ps.get_transformation_gizmo("gizmo_1") - self.assertEqual(g1b.get_name(), "gizmo_1") - - ps.show(3) - - # Remove by name - ps.remove_transformation_gizmo("gizmo_1") - - # Create another and remove via instance method - g2 = ps.add_transformation_gizmo("gizmo_2") - self.assertEqual(g2.get_name(), "gizmo_2") - g2.remove() - - # Add with auto-naming - ps.add_transformation_gizmo() - ps.add_transformation_gizmo() - - # Add a couple and clear all - ps.add_transformation_gizmo("gizmo_B") - ps.remove_all_transformation_gizmos() - - # Get the reference for a structure - pt_cloud_0 = ps.register_point_cloud("cloud0", np.zeros((10,3))) - gizmo = pt_cloud_0.get_transformation_gizmo() - self.assertIsInstance(gizmo, ps.TransformationGizmo) - gizmo.set_allow_rotation(False) - ps.remove_all_structures() - - def test_load_material(self): - - ps.load_static_material("test_static", path.join(assets_prefix, "testwax_b.jpg")) - ps.load_blendable_material("test_blend1", filenames=( - path.join(assets_prefix, "testwax_r.jpg"), - path.join(assets_prefix, "testwax_b.jpg"), - path.join(assets_prefix, "testwax_g.jpg"), - path.join(assets_prefix, "testwax_k.jpg") - )) - - ps.load_blendable_material("test_blend2", - filename_base=path.join(assets_prefix, "testwax"), - filename_ext=".jpg") - - def test_load_cmap(self): - ps.load_color_map("test_cmap", path.join(assets_prefix, "test_colormap.png")) - - - def test_scene_extents(self): - - ps.set_automatically_compute_scene_extents(False) - - ps.set_length_scale(3.) - self.assertAlmostEqual(ps.get_length_scale(), 3.) - - low = np.array((-1, -2., -3.)) - high = np.array((1., 2., 3.)) - ps.set_bounding_box(low, high) - plow, phigh = ps.get_bounding_box() - self.assertTrue(np.abs(plow-low).sum() < 0.0001) - self.assertTrue(np.abs(phigh-high).sum() < 0.0001) - - ps.set_automatically_compute_scene_extents(True) - - - def test_groups(self): - - pts = np.zeros((10,3)) - pt_cloud_0 = ps.register_point_cloud("cloud0", pts) - pt_cloud_1 = ps.register_point_cloud("cloud1", pts) - pt_cloud_2 = ps.register_point_cloud("cloud2", pts) - - groupA = ps.create_group("group_A") - groupB = ps.create_group("group_B") - groupC = ps.create_group("group_C") - - groupA.add_child_group(groupB) - groupA.add_child_group("group_C") - self.assertTrue(set(groupA.get_child_group_names()) == set(["group_B", "group_C"])) - - pt_cloud_0.add_to_group(groupA) - pt_cloud_1.add_to_group("group_A") - groupA.add_child_structure(pt_cloud_2) - self.assertTrue(set(groupA.get_child_structure_names()) == set(["cloud0", "cloud1", "cloud2"])) - - groupA.set_enabled(False) - groupB.set_show_child_details(True) - groupC.set_hide_descendants_from_structure_lists(True) - - ps.show(3) - - groupA.remove_child_group(groupB) - groupA.remove_child_group("group_C") - groupA.remove_child_structure(pt_cloud_0) - - ps.remove_group(groupB, True) - ps.remove_group("group_C", False) - - ps.show(3) - - ps.remove_all_groups() - - ps.remove_all_structures() - - - def test_groups_demo_example(self): - - # make a point cloud - pts = np.zeros((300,3)) - psCloud = ps.register_point_cloud("my cloud", pts) - - # make a curve network - nodes = np.zeros((4,3)) - edges = np.array([[1, 3], [3, 0], [1, 0], [0, 2]]) - psCurve = ps.register_curve_network("my network", nodes, edges) - - # create a group for these two objects - group = ps.create_group("my group") - psCurve.add_to_group(group) # you also say psCurve.add_to_group("my group") - psCloud.add_to_group(group) - - # toggle the enabled state for everything in the group - group.set_enabled(False) - - # hide items in group from displaying in the UI - # (useful if you are registering huge numbers of structures you don't always need to see) - group.set_hide_descendants_from_structure_lists(True) - group.set_show_child_details(False) - - # nest groups inside of other groups - super_group = ps.create_group("py parent group") - super_group.add_child_group(group) - - ps.show(3) - - ps.remove_all_groups() - ps.remove_all_structures() - - def test_ui_advanced_custom_build(self): - - def manual_build_callback(): - ps.build_polyscope_gui() - ps.build_structure_gui() - ps.build_pick_gui() - - - # disable the standard function - ps.set_build_gui(False) - ps.set_user_callback(manual_build_callback) - ps.show(3) # smoke test - - # unset - ps.set_user_callback(None) - ps.set_build_gui(True) - -class TestImGuiBindings(unittest.TestCase): - - def test_ui_calls(self): - - # (this is the example from the demo and the docs) - - # A bunch of parameters which we will maniuplate via the UI defined below. - # There is nothing special about these variables, you could manipulate any other - # kind of Python values the same way, such as entries in a dict, or class members. - is_true1 = False - is_true2 = True - ui_int = 7 - ui_float1 = -3.2 - ui_float2 = 0.8 - ui_color3 = (1., 0.5, 0.5) - ui_color4 = (0.3, 0.5, 0.5, 0.8) - ui_angle_rad = 0.2 - ui_text = "some input text" - ui_options = ["option A", "option B", "option C"] - ui_options_selected = ui_options[1] - - def my_function(): - # ... do something important here ... - pass - - # Define our callback function, which Polyscope will repeatedly execute while running the UI. - # We can write any code we want here, but in particular it is an opportunity to create ImGui - # interface elements and define a custom UI. - def imgui_callback(): - - # If we want to use local variables & assign to them in the UI code below, we need to mark them as nonlocal. This is because of how Python scoping rules work, not anything particular about Polyscope or ImGui. - # Of course, you can also use any other kind of python variable as a controllable value in the UI, such as a value from a dictionary, or a class member. Just be sure to assign the result of the ImGui call to the value, as in the examples below. - nonlocal is_true1, is_true2, ui_int, ui_float1, ui_float2, ui_color3, ui_color4, ui_text, ui_options_selected, ui_angle_rad - - - # == Settings - - # Use settings like this to change the UI appearance. - # Note that it is a push/pop pair, with the matching pop() below. - psim.PushItemWidth(150) - - - # == Show text in the UI - - psim.TextUnformatted("Some sample text") - psim.TextUnformatted("An important value: {}".format(42)) - psim.Separator() - - - # == Buttons - - if(psim.Button("A button")): - # This code is executed when the button is pressed - print("Hello") - - # By default, each element goes on a new line. Use this - # to put the next element on the _same_ line. - psim.SameLine() - - if(psim.Button("Another button")): - # This code is executed when the button is pressed - my_function() - - - # == Set parameters - - # These commands allow the user to adjust the value of variables. - # It is important that we assign the return result to the variable to - # update it. - # For most elements, the return is actually a tuple `(changed, newval)`, - # where `changed` indicates whether the setting was modified on this - # frame, and `newval` gives the new value of the variable (or the same - # old value if unchanged). - # - # For numeric inputs, ctrl-click on the box to type in a value. - - # Checkbox - changed, is_true1 = psim.Checkbox("flag1", is_true1) - if(changed): # optionally, use this conditional to take action on the new value - pass - psim.SameLine() - changed, is_true2 = psim.Checkbox("flag2", is_true2) - - # Input ints - changed, ui_int = psim.InputInt("ui_int", ui_int, step=1, step_fast=10) - - # Input floats using two different styles of widget - changed, ui_float1 = psim.InputFloat("ui_float1", ui_float1) - psim.SameLine() - changed, ui_float2 = psim.SliderFloat("ui_float2", ui_float2, v_min=-5, v_max=5) - - # Input colors - changed, ui_color3 = psim.ColorEdit3("ui_color3", ui_color3) - psim.SameLine() - changed, ui_color4 = psim.ColorEdit4("ui_color4", ui_color4) - - # Input text - changed, ui_text = psim.InputText("enter text", ui_text) - - # Combo box to choose from options - # There, the options are a list of strings in `ui_options`, - # and the currently selected element is stored in `ui_options_selected`. - psim.PushItemWidth(200) - changed = psim.BeginCombo("Pick one", ui_options_selected) - if changed: - for val in ui_options: - if psim.Selectable(val, ui_options_selected==val): - ui_options_selected = val - psim.EndCombo() - psim.PopItemWidth() - - - # Use tree headers to logically group options - - # This a stateful option to set the tree node below to be open initially. - # The second argument is a flag, which works like a bitmask. - # Many ImGui elements accept flags to modify their behavior. - psim.SetNextItemOpen(True, psim.ImGuiCond_FirstUseEver) - - # The body is executed only when the sub-menu is open. Note the push/pop pair! - if(psim.TreeNode("Collapsible sub-menu")): - - psim.TextUnformatted("Detailed information") - - if(psim.Button("sub-button")): - print("hello") - - # There are many different UI elements offered by ImGui, many of which - # are bound in python by Polyscope. See ImGui's documentation in `imgui.h`, - # or the polyscope bindings in `polyscope/src/cpp/imgui.cpp`. - changed, ui_angle_rad = psim.SliderAngle("ui_float2", ui_angle_rad, - v_degrees_min=-90, v_degrees_max=90) - - psim.TreePop() - - psim.PopItemWidth() - - - ps.set_user_callback(imgui_callback) - ps.show(3) - - ps.clear_user_callback() - - def test_implot(self): - - # smoke tests for implot - def imgui_callback(): - - # PlotLine - psim.SetCursorPos((0,0)) # these calls ensure it's not clipped out and disabled - if psimplot.BeginPlot("test line plot"): - psimplot.PlotLine("line plot1", np.random.rand(10)) - psimplot.PlotLine("line plot2", np.random.rand(10), np.random.rand(10)) - psimplot.PlotLine("line plot3", np.random.rand(10), psimplot.ImPlotLineFlags_Shaded + psimplot.ImPlotLineFlags_Loop) - - # test inf lines while we're at it - psimplot.PlotInfLines("inf line v", np.random.rand(3)) - psimplot.PlotInfLines("inf line h", np.random.rand(3), psimplot.ImPlotInfLinesFlags_Horizontal) - - psimplot.EndPlot() - - # PlotScatter - psim.SetCursorPos((0,0)) - if psimplot.BeginPlot("test scatter plot"): - psimplot.PlotScatter("scatter plot1", np.random.rand(10)) - psimplot.PlotScatter("scatter plot2", np.random.rand(10), np.random.rand(10)) - psimplot.PlotScatter("scatter plot3", np.random.rand(10), psimplot.ImPlotScatterFlags_NoClip) - psimplot.EndPlot() - - # PlotStairs - psim.SetCursorPos((0,0)) - if psimplot.BeginPlot("test stairs plot"): - psimplot.PlotStairs("stairs plot1", np.random.rand(10)) - psimplot.PlotStairs("stairs plot2", np.random.rand(10), np.random.rand(10)) - psimplot.PlotStairs("stairs plot3", np.random.rand(10), psimplot.ImPlotStairsFlags_Shaded) - psimplot.EndPlot() - - # PlotShaded - psim.SetCursorPos((0,0)) - if psimplot.BeginPlot("test shaded plot"): - psimplot.PlotShaded("shaded plot1", np.random.rand(10)) - psimplot.PlotShaded("shaded plot1", np.random.rand(10), yref=1.0) - psimplot.PlotShaded("shaded plot2", np.random.rand(10), np.random.rand(10), psimplot.ImPlotShadedFlags_None) - psimplot.PlotShaded("shaded plot3", np.random.rand(10), np.random.rand(10), np.random.rand(10)) - psimplot.EndPlot() - - # PlotBars TODO - - # PlotBarGroups TODO - - # PlotErrorBars TODO - - # PlotStems TODO - - # PlotPieChart - psim.SetCursorPos((0,0)) - if psimplot.BeginPlot("test pie chart plot"): - psimplot.PlotPieChart(["cat1", "cat2"], np.random.rand(2), 0.5, 0.5, 0.5) - psimplot.PlotPieChart(["cat1", "cat2"], np.random.rand(2), x=2., y=3., radius=4.) - psimplot.PlotPieChart(["cat1", "cat2"], np.random.rand(2), 2., 3., 4., flags=psimplot.ImPlotPieChartFlags_Exploding) - psimplot.EndPlot() - - # PlotHeatMap TODO - - # PlotHistorgram - psim.SetCursorPos((0,0)) - if psimplot.BeginPlot("test historgram plot"): - psimplot.PlotHistogram("hist", np.random.rand(10)) - psimplot.PlotHistogram("hist2", np.random.rand(10), 3, range=(-2., 2.), flags=psimplot.ImPlotHistogramFlags_NoOutliers) - psimplot.EndPlot() - - # Subplots - psim.SetCursorPos((0,0)) - if psimplot.BeginSubplots("test subplot", 2, 3, (800,400)): - for i in range(6): - if psimplot.BeginPlot(f"test subplot_{i}"): - psimplot.PlotLine("line plot", np.random.rand(10)) - - psimplot.EndPlot() - - psimplot.EndSubplots() - - ps.set_user_callback(imgui_callback) - ps.show(3) - ps.clear_user_callback() - -class TestStructureManagement(unittest.TestCase): - - def test_remove_all(self): - pass - -def test_transforms(t,s): - - T = np.array([ - [1., 0., 0., 3.], - [0., 0., -1., -2.], - [0., 1., 0., 5.], - [0., 0., 0., 1.] - ]) - v = np.array([1., 2., 3.]) - - s.get_transform() - s.get_position() - s.center_bounding_box() - s.rescale_to_unit() - - s.reset_transform() - t.assertTrue(np.abs(s.get_transform()-np.eye(4)).sum() < 1e-4) - t.assertTrue(np.abs(s.get_position()).sum() < 1e-4) - - s.set_transform(T) - t.assertTrue(np.abs(s.get_transform()-T).sum() < 1e-4) - - s.reset_transform() - s.set_position(v) - t.assertTrue(np.abs(s.get_position()-v).sum() < 1e-4) - - s.translate(v) - t.assertTrue(np.abs(s.get_position()-2.*v).sum() < 1e-4) - - s.set_transform_gizmo_enabled(True) - t.assertTrue(s.get_transform_gizmo_enabled()) - s.set_transform_gizmo_enabled(False) - - -class TestPointCloud(unittest.TestCase): - - def generate_points(self, n_pts=10): - np.random.seed(777) - return np.random.rand(n_pts, 3) - - def test_add_remove(self): - - # add - p = ps.register_point_cloud("test_cloud", self.generate_points()) - self.assertTrue(ps.has_point_cloud("test_cloud")) - self.assertFalse(ps.has_point_cloud("nope")) - self.assertEqual(p.n_points(), 10) - - # remove by name - ps.register_point_cloud("test_cloud2", self.generate_points()) - ps.remove_point_cloud("test_cloud2") - self.assertTrue(ps.has_point_cloud("test_cloud")) - self.assertFalse(ps.has_point_cloud("test_cloud2")) - - # remove by ref - c = ps.register_point_cloud("test_cloud2", self.generate_points()) - c.remove() - self.assertTrue(ps.has_point_cloud("test_cloud")) - self.assertFalse(ps.has_point_cloud("test_cloud2")) - - # get by name - ps.register_point_cloud("test_cloud3", self.generate_points(n_pts=10)) - p = ps.get_point_cloud("test_cloud3") # should be wrapped instance, not underlying PSB instance - self.assertTrue(isinstance(p, ps.PointCloud)) - - ps.remove_all_structures() - - def test_render(self): - - ps.register_point_cloud("test_cloud", self.generate_points()) - ps.show(3) - ps.remove_all_structures() - - def test_options(self): - - p = ps.register_point_cloud("test_cloud", self.generate_points()) - - # Set enabled - p.set_enabled() - p.set_enabled(False) - p.set_enabled(True) - self.assertTrue(p.is_enabled()) - - # Radius - p.set_radius(0.01) - p.set_radius(0.1, relative=False) - self.assertAlmostEqual(0.1, p.get_radius()) - - # Render mode - p.set_point_render_mode("sphere") - self.assertEqual("sphere", p.get_point_render_mode()) - p.set_point_render_mode("quad") - self.assertEqual("quad", p.get_point_render_mode()) - - # Color - color = (0.3, 0.3, 0.5) - p.set_color(color) - ret_color = p.get_color() - for i in range(3): - self.assertAlmostEqual(ret_color[i], color[i]) - - # Material - p.set_material("candy") - self.assertEqual("candy", p.get_material()) - p.set_material("clay") - - # Transparency - p.set_transparency(0.8) - self.assertAlmostEqual(0.8, p.get_transparency()) - - p2 = ps.register_point_cloud("test_cloud2", self.generate_points(), - enabled=True, material='wax', radius=0.03, color=(1., 0., 0.), transparency=0.7) - - - ps.show(3) - ps.remove_all_structures() - ps.set_transparency_mode('none') - - def test_transform(self): - - ps_cloud = ps.register_point_cloud("test_cloud", self.generate_points()) - test_transforms(self,ps_cloud) - ps.remove_all_structures() - - def test_update(self): - - p = ps.register_point_cloud("test_cloud", self.generate_points()) - ps.show(3) - - newPos = self.generate_points() - 0.5 - p.update_point_positions(newPos) - - ps.show(3) - ps.remove_all_structures() - - - def test_2D(self): - np.random.seed(777) - points2D = np.random.rand(12, 2) - - p = ps.register_point_cloud("test_cloud", points2D) - ps.show(3) - - newPos = points2D - 0.5 - p.update_point_positions(newPos) - - ps.show(3) - ps.remove_all_structures() - - def test_transparent_rendering(self): - - p = ps.register_point_cloud("test_cloud", self.generate_points(), - transparency=0.5) - - ps.set_transparency_mode('none') - ps.show(3) - ps.set_transparency_mode('simple') - ps.show(3) - ps.set_transparency_mode('pretty') - ps.show(3) - - ps.set_transparency_mode('none') - ps.remove_all_structures() - - def test_slice_plane(self): - - p = ps.register_point_cloud("test_cloud", self.generate_points()) - - - - plane = ps.add_scene_slice_plane() - p.set_cull_whole_elements(True) - ps.show(3) - p.set_cull_whole_elements(False) - ps.show(3) - - p.set_ignore_slice_plane(plane, True) - self.assertEqual(True, p.get_ignore_slice_plane(plane)) - p.set_ignore_slice_plane(plane.get_name(), False) - self.assertEqual(False, p.get_ignore_slice_plane(plane.get_name())) - - ps.remove_all_structures() - ps.remove_last_scene_slice_plane() - - def test_scalar(self): - pts = self.generate_points() - N = pts.shape[0] - ps.register_point_cloud("test_cloud", pts) - p = ps.get_point_cloud("test_cloud") - vals = np.random.rand(N) - - p.add_scalar_quantity("test_vals", vals) - p.add_scalar_quantity("test_vals", vals, enabled=True) - p.add_scalar_quantity("test_vals_with_range", vals, vminmax=(-5., 5.), enabled=True) - p.add_scalar_quantity("test_vals_with_datatype", vals, enabled=True, datatype='symmetric') - p.add_scalar_quantity("test_vals_with_categorical", vals, enabled=True, datatype='categorical') - p.add_scalar_quantity("test_vals_with_cmap", vals, enabled=True, cmap='blues') - p.add_scalar_quantity("test_vals_with_cmap_onscreen_colorbar", vals, enabled=True, cmap='blues', onscreen_colorbar_enabled=True, onscreen_colorbar_location=(400., 400.)) - p.add_scalar_quantity("test_vals_with_iso", vals, enabled=True, cmap='blues', - isolines_enabled=True, isoline_width=0.1, isoline_darkness=0.5) - p.add_scalar_quantity("test_vals_with_iso_rel", vals, enabled=True, cmap='blues', - isolines_enabled=True, isoline_width=0.1, isoline_width_relative=True, isoline_darkness=0.5) - ps.show(3) - - # test some additions/removal while we're at it - p.remove_quantity("test_vals") - p.remove_quantity("not_here") # should not error - p.remove_all_quantities() - p.remove_all_quantities() - ps.remove_all_structures() - - def test_color(self): - pts = self.generate_points() - N = pts.shape[0] - p = ps.register_point_cloud("test_cloud", pts) - vals = np.random.rand(N,3) - - p.add_color_quantity("test_vals", vals) - p.add_color_quantity("test_vals", vals, enabled=True) - ps.show(3) - - p.remove_all_quantities() - ps.remove_all_structures() - - def test_vector(self): - pts = self.generate_points() - N = pts.shape[0] - p = ps.register_point_cloud("test_cloud", pts) - vals = np.random.rand(N,3) - - p.add_vector_quantity("test_vals1", vals) - p.add_vector_quantity("test_vals2", vals, enabled=True) - p.add_vector_quantity("test_vals3", vals, enabled=True, vectortype='ambient') - p.add_vector_quantity("test_vals4", vals, enabled=True, length=0.005) - p.add_vector_quantity("test_vals5", vals, enabled=True, radius=0.001) - p.add_vector_quantity("test_vals6", vals, enabled=True, color=(0.2, 0.5, 0.5)) - - # 2D - p.add_vector_quantity("test_vals7", vals[:,:2], enabled=True, radius=0.001) - - ps.show(3) - - p.remove_all_quantities() - ps.remove_all_structures() - - def test_parameterization(self): - - pts = self.generate_points() - N = pts.shape[0] - p = ps.register_point_cloud("test_cloud", pts) - vals = np.random.rand(N,2) - - - cA = (0.1, 0.2, 0.3) - cB = (0.4, 0.5, 0.6) - - p.add_parameterization_quantity("test_vals1", vals, enabled=True) - - p.add_parameterization_quantity("test_vals2", vals, coords_type='world') - p.add_parameterization_quantity("test_vals3", vals, coords_type='unit') - - p.add_parameterization_quantity("test_vals4", vals, viz_style='checker') - p.add_parameterization_quantity("test_vals5", vals, viz_style='grid') - p.add_parameterization_quantity("test_vals6", vals, viz_style='local_check') - p.add_parameterization_quantity("test_vals7", vals, viz_style='local_rad') - - p.add_parameterization_quantity("test_vals8", vals, grid_colors=(cA, cB)) - p.add_parameterization_quantity("test_vals9", vals, checker_colors=(cA, cB)) - p.add_parameterization_quantity("test_vals10", vals, checker_size=0.1) - p.add_parameterization_quantity("test_vals11", vals, cmap='blues') - - ps.show(3) - - p.remove_all_quantities() - - - def test_variable_radius(self): - pts = self.generate_points() - N = pts.shape[0] - ps.register_point_cloud("test_cloud", pts) - p = ps.get_point_cloud("test_cloud") - vals = np.random.rand(N) - - p.add_scalar_quantity("test_vals", vals) - - p.set_point_radius_quantity("test_vals") - ps.show(3) - p.clear_point_radius_quantity() - ps.show(3) - p.set_point_radius_quantity("test_vals", False) - ps.show(3) - - ps.remove_all_structures() - - - def test_scalar_transparency(self): - pts = self.generate_points() - N = pts.shape[0] - ps.register_point_cloud("test_cloud", pts) - p = ps.get_point_cloud("test_cloud") - vals = np.random.rand(N) - - p.add_scalar_quantity("test_vals", vals) - - p.set_transparency_quantity("test_vals") - ps.show(3) - p.clear_transparency_quantity() - ps.show(3) - - ps.remove_all_structures() - -class TestCurveNetwork(unittest.TestCase): - - def generate_points(self, n_pts=10): - np.random.seed(777) - return np.random.rand(n_pts, 3) - - def generate_edges(self, n_pts=10): - np.random.seed(777) - return np.random.randint(0, n_pts, size=(2*n_pts,2)) - - def test_add_remove(self): - - # add - n = ps.register_curve_network("test_network", self.generate_points(), self.generate_edges()) - self.assertTrue(ps.has_curve_network("test_network")) - self.assertFalse(ps.has_curve_network("nope")) - self.assertEqual(n.n_nodes(), 10) - self.assertEqual(n.n_edges(), 20) - - # remove by name - ps.register_curve_network("test_network2", self.generate_points(), self.generate_edges()) - ps.remove_curve_network("test_network2") - self.assertTrue(ps.has_curve_network("test_network")) - self.assertFalse(ps.has_curve_network("test_network2")) - - # remove by ref - c = ps.register_curve_network("test_network2", self.generate_points(), self.generate_edges()) - c.remove() - self.assertTrue(ps.has_curve_network("test_network")) - self.assertFalse(ps.has_curve_network("test_network2")) - - # get by name - ps.register_curve_network("test_network3", self.generate_points(), self.generate_edges()) - p = ps.get_curve_network("test_network3") # should be wrapped instance, not underlying PSB instance - self.assertTrue(isinstance(p, ps.CurveNetwork)) - - ps.remove_all_structures() - - def test_convenience_add(self): - ps.register_curve_network("test_network_line", self.generate_points(), 'line') - ps.register_curve_network("test_network_line2D", self.generate_points()[:,:2], 'line') - ps.register_curve_network("test_network_loop", self.generate_points(), 'loop') - ps.register_curve_network("test_network_loop2D", self.generate_points()[:,:2], 'loop') - ps.register_curve_network("test_network_line", self.generate_points(), 'segments') - ps.register_curve_network("test_network_line2D", self.generate_points()[:,:2], 'segments') - - ps.show(3) - ps.remove_all_structures(); - - def test_render(self): - - ps.register_curve_network("test_network", self.generate_points(), self.generate_edges()) - ps.show(3) - ps.remove_all_structures() - - def test_options(self): - - p = ps.register_curve_network("test_network", self.generate_points(), self.generate_edges()) - - # Set enabled - p.set_enabled() - p.set_enabled(False) - p.set_enabled(True) - self.assertTrue(p.is_enabled()) - - # Radius - p.set_radius(0.01) - p.set_radius(0.1, relative=False) - self.assertAlmostEqual(0.1, p.get_radius()) - - # Color - color = (0.3, 0.3, 0.5) - p.set_color(color) - ret_color = p.get_color() - for i in range(3): - self.assertAlmostEqual(ret_color[i], color[i]) - - # Material - p.set_material("candy") - self.assertEqual("candy", p.get_material()) - p.set_material("clay") - - # Transparency - p.set_transparency(0.8) - self.assertAlmostEqual(0.8, p.get_transparency()) - - p2 = ps.register_curve_network("test_network2", self.generate_points(), self.generate_edges(), - enabled=False, material='wax', radius=0.03, color=(1., 0., 0.), transparency=0.9) - - ps.show(3) - ps.remove_all_structures() - ps.set_transparency_mode('none') - - def test_variable_render(self): - - p = ps.register_curve_network("test_network", self.generate_points(), self.generate_edges()) - - p.add_scalar_quantity("test_vals_nodes", np.random.rand(p.n_nodes()), defined_on='nodes') - p.add_scalar_quantity("test_vals_edges", np.random.rand(p.n_edges()), defined_on='edges', enabled=True) - - # node only - p.set_node_radius_quantity('test_vals_nodes') - ps.show(3) - p.set_node_radius_quantity('test_vals_nodes', autoscale=False) - ps.show(3) - p.clear_node_radius_quantity() - - # edge only - p.set_edge_radius_quantity('test_vals_edges') - ps.show(3) - p.set_edge_radius_quantity('test_vals_edges', autoscale=False) - ps.show(3) - p.clear_edge_radius_quantity() - - # both - p.set_node_radius_quantity('test_vals_nodes') - p.set_edge_radius_quantity('test_vals_edges') - ps.show(3) - p.clear_edge_radius_quantity() - - ps.remove_all_structures() - - def test_transform(self): - - p = ps.register_curve_network("test_network", self.generate_points(), self.generate_edges()) - test_transforms(self,p) - ps.remove_all_structures() - - def test_slice_plane(self): - - p = ps.register_curve_network("test_network", self.generate_points(), self.generate_edges()) - - plane = ps.add_scene_slice_plane() - p.set_cull_whole_elements(True) - ps.show(3) - p.set_cull_whole_elements(False) - ps.show(3) - - p.set_ignore_slice_plane(plane, True) - self.assertEqual(True, p.get_ignore_slice_plane(plane)) - p.set_ignore_slice_plane(plane.get_name(), False) - self.assertEqual(False, p.get_ignore_slice_plane(plane.get_name())) - - ps.remove_all_structures() - ps.remove_last_scene_slice_plane() - - - def test_update(self): - - p = ps.register_curve_network("test_network", self.generate_points(), self.generate_edges()) - ps.show(3) - - newPos = self.generate_points() - 0.5 - p.update_node_positions(newPos) - - ps.show(3) - ps.remove_all_structures() - - def test_2D(self): - np.random.seed(777) - points2D = np.random.rand(10, 2) - - p = ps.register_curve_network("test_network", points2D, self.generate_edges()) - ps.show(3) - - newPos = points2D - 0.5 - p.update_node_positions(newPos) - - ps.show(3) - ps.remove_all_structures() - - def test_scalar(self): - pts = self.generate_points() - N = pts.shape[0] - ps.register_curve_network("test_network", pts, self.generate_edges()) - p = ps.get_curve_network("test_network") - - for on in ['nodes', 'edges']: - - if on == 'nodes': - vals = np.random.rand(N) - elif on == 'edges': - vals = np.random.rand(2*N) - - p.add_scalar_quantity("test_vals", vals, defined_on=on) - p.add_scalar_quantity("test_vals2", vals, defined_on=on, enabled=True) - p.add_scalar_quantity("test_vals_with_range", vals, defined_on=on, vminmax=(-5., 5.), enabled=True) - p.add_scalar_quantity("test_vals_with_datatype", vals, defined_on=on, enabled=True, datatype='symmetric') - p.add_scalar_quantity("test_vals_with_cmap", vals, defined_on=on, enabled=True, cmap='blues') - p.add_scalar_quantity("test_vals_with_iso", vals, defined_on=on, enabled=True, cmap='blues', - isolines_enabled=True, isoline_width=0.1, isoline_darkness=0.5) - - ps.show(3) - - # test some additions/removal while we're at it - p.remove_quantity("test_vals") - p.remove_quantity("not_here") # should not error - p.remove_all_quantities() - p.remove_all_quantities() - - ps.remove_all_structures() - - def test_color(self): - pts = self.generate_points() - N = pts.shape[0] - p = ps.register_curve_network("test_network", pts, self.generate_edges()) - - for on in ['nodes', 'edges']: - - if on == 'nodes': - vals = np.random.rand(N,3) - elif on == 'edges': - vals = np.random.rand(2*N, 3) - - p.add_color_quantity("test_vals", vals, defined_on=on) - p.add_color_quantity("test_vals", vals, defined_on=on, enabled=True) - - ps.show(3) - p.remove_all_quantities() - - ps.remove_all_structures() - - def test_vector(self): - pts = self.generate_points() - N = pts.shape[0] - p = ps.register_curve_network("test_network", pts, self.generate_edges()) - vals = np.random.rand(N,3) - - for on in ['nodes', 'edges']: - - if on == 'nodes': - vals = np.random.rand(N,3) - elif on == 'edges': - vals = np.random.rand(2*N, 3) - - p.add_vector_quantity("test_vals1", vals, defined_on=on) - p.add_vector_quantity("test_vals2", vals, defined_on=on, enabled=True) - p.add_vector_quantity("test_vals3", vals, defined_on=on, enabled=True, vectortype='ambient') - p.add_vector_quantity("test_vals4", vals, defined_on=on, enabled=True, length=0.005) - p.add_vector_quantity("test_vals5", vals, defined_on=on, enabled=True, radius=0.001) - p.add_vector_quantity("test_vals6", vals, defined_on=on, enabled=True, color=(0.2, 0.5, 0.5)) - - # 2D - p.add_vector_quantity("test_vals7", vals[:,:2], defined_on=on, enabled=True, radius=0.001) - - ps.show(3) - p.remove_all_quantities() - - ps.remove_all_structures() - - -class TestSurfaceMesh(unittest.TestCase): - - def generate_verts(self, n_pts=10): - np.random.seed(777) - return np.random.rand(n_pts, 3) - - def generate_faces(self, n_pts=10): - np.random.seed(777) - return np.random.randint(0, n_pts, size=(2*n_pts,3)) - - def test_add_remove(self): - - # add - n = ps.register_surface_mesh("test_mesh", self.generate_verts(), self.generate_faces()) - self.assertTrue(ps.has_surface_mesh("test_mesh")) - self.assertFalse(ps.has_surface_mesh("nope")) - self.assertEqual(n.n_vertices(), 10) - self.assertEqual(n.n_faces(), 20) - self.assertGreater(n.n_edges(), 1) - self.assertEqual(n.n_corners(), 3*20) - self.assertEqual(n.n_halfedges(), 3*20) - - # remove by name - ps.register_surface_mesh("test_mesh2", self.generate_verts(), self.generate_faces()) - ps.remove_surface_mesh("test_mesh2") - self.assertTrue(ps.has_surface_mesh("test_mesh")) - self.assertFalse(ps.has_surface_mesh("test_mesh2")) - - # remove by ref - c = ps.register_surface_mesh("test_mesh2", self.generate_verts(), self.generate_faces()) - c.remove() - self.assertTrue(ps.has_surface_mesh("test_mesh")) - self.assertFalse(ps.has_surface_mesh("test_mesh2")) - - # get by name - ps.register_surface_mesh("test_mesh3", self.generate_verts(), self.generate_faces()) - p = ps.get_surface_mesh("test_mesh3") # should be wrapped instance, not underlying PSB instance - self.assertTrue(isinstance(p, ps.SurfaceMesh)) - - ps.remove_all_structures() - - - def test_add_quad(self): - - n_pts=10 - faces = np.random.randint(0, n_pts, size=(2*n_pts,4)) - ps.register_surface_mesh("test_mesh", self.generate_verts(), faces) - ps.show(3) - ps.remove_all_structures() - - def test_add_varied_degree(self): - - n_pts = 10 - n_face = 20 - faces = [] - for i in range(n_face): - faces.append([0,1,2,]) - faces.append([0,1,2,4]) - faces.append([0,1,2,4,5]) - - ps.register_surface_mesh("test_mesh", self.generate_verts(), faces) - ps.show(3) - ps.remove_all_structures() - - def test_render(self): - - ps.register_surface_mesh("test_mesh", self.generate_verts(), self.generate_faces()) - ps.show(3) - ps.remove_all_structures() - - - def test_options(self): - - p = ps.register_surface_mesh("test_mesh", self.generate_verts(), self.generate_faces()) - - # Set enabled - p.set_enabled() - p.set_enabled(False) - p.set_enabled(True) - self.assertTrue(p.is_enabled()) - - # Color - color = (0.3, 0.3, 0.5) - p.set_color(color) - ret_color = p.get_color() - for i in range(3): - self.assertAlmostEqual(ret_color[i], color[i]) - - # Edge color - color = (0.1, 0.5, 0.5) - p.set_edge_color(color) - ret_color = p.get_edge_color() - for i in range(3): - self.assertAlmostEqual(ret_color[i], color[i]) - - ps.show(3) - - # Smooth shade - p.set_smooth_shade(True) - ps.show(3) - self.assertTrue(p.get_smooth_shade()) - p.set_smooth_shade(False) - ps.show(3) - - # Edge width - p.set_edge_width(1.5) - ps.show(3) - self.assertAlmostEqual(p.get_edge_width(), 1.5) - - # Selection mode - p.set_selection_mode('auto') - p.set_selection_mode('vertices_only') - p.set_selection_mode('faces_only') - ps.show(3) - - # Material - p.set_material("candy") - self.assertEqual("candy", p.get_material()) - p.set_material("clay") - - # Back face - p.set_back_face_policy("different") - self.assertEqual("different", p.get_back_face_policy()) - p.set_back_face_policy("custom") - self.assertEqual("custom", p.get_back_face_policy()) - p.set_back_face_color((0.25, 0.25, 0.25)) - self.assertEqual((0.25, 0.25, 0.25), p.get_back_face_color()) - p.set_back_face_policy("cull") - - # Transparency - p.set_transparency(0.8) - self.assertAlmostEqual(0.8, p.get_transparency()) - - # Mark elements as used - # p.set_corner_permutation(np.random.permutation(p.n_corners())) # not required - p.mark_corners_as_used() - p.set_edge_permutation(np.random.permutation(p.n_edges())) - p.mark_edges_as_used() - p.set_halfedge_permutation(np.random.permutation(p.n_halfedges())) - p.mark_halfedges_as_used() - - - # Set with optional arguments - p2 = ps.register_surface_mesh("test_mesh", self.generate_verts(), self.generate_faces(), - enabled=True, material='wax', color=(1., 0., 0.), edge_color=(0.5, 0.5, 0.5), - smooth_shade=True, edge_width=0.5, back_face_policy="cull", back_face_color=(0.1, 0.1, 0.1), transparency=0.9) - - # Make sure shadows work - ps.set_ground_plane_mode("shadow_only") - - ps.show(3) - ps.remove_all_structures() - ps.set_transparency_mode('none') - - def test_transform(self): - - p = ps.register_surface_mesh("test_mesh", self.generate_verts(), self.generate_faces()) - test_transforms(self,p) - ps.remove_all_structures() - - def test_slice_plane(self): - - p = ps.register_surface_mesh("test_mesh", self.generate_verts(), self.generate_faces()) - - plane = ps.add_scene_slice_plane() - p.set_cull_whole_elements(True) - ps.show(3) - p.set_cull_whole_elements(False) - ps.show(3) - - p.set_ignore_slice_plane(plane, True) - self.assertEqual(True, p.get_ignore_slice_plane(plane)) - p.set_ignore_slice_plane(plane.get_name(), False) - self.assertEqual(False, p.get_ignore_slice_plane(plane.get_name())) - - ps.remove_all_structures() - ps.remove_last_scene_slice_plane() - - def test_update(self): - - p = ps.register_surface_mesh("test_mesh", self.generate_verts(), self.generate_faces()) - ps.show(3) - - newPos = self.generate_verts() - 0.5 - p.update_vertex_positions(newPos) - - ps.show(3) - ps.remove_all_structures() - - def test_2D(self): - np.random.seed(777) - points2D = self.generate_verts()[:,:2] - - p = ps.register_surface_mesh("test_mesh", points2D, self.generate_faces()) - ps.show(3) - - newPos = points2D - 0.5 - p.update_vertex_positions(newPos) - - ps.show(3) - ps.remove_all_structures() - - - def test_permutation(self): - - p = ps.register_surface_mesh("test_mesh", self.generate_verts(), self.generate_faces()) - - p.set_edge_permutation(np.random.permutation(p.n_edges())) - - p.set_corner_permutation(np.random.permutation(p.n_corners())) - - p.set_halfedge_permutation(np.random.permutation(p.n_halfedges())) - - p = ps.register_surface_mesh("test_mesh2", self.generate_verts(), self.generate_faces()) - - p.set_all_permutations( - edge_perm=np.random.permutation(p.n_edges()), - corner_perm=np.random.permutation(p.n_corners()), - halfedge_perm=np.random.permutation(p.n_halfedges()), - ) - - ps.show(3) - ps.remove_all_structures() - - def test_permutation_with_size(self): - - p = ps.register_surface_mesh("test_mesh", self.generate_verts(), self.generate_faces()) - - p.set_edge_permutation(np.random.permutation(p.n_edges()), 3*p.n_edges()) - - p.set_corner_permutation(np.random.permutation(p.n_corners()), 3*p.n_corners()) - - p.set_halfedge_permutation(np.random.permutation(p.n_halfedges()), 3*p.n_halfedges()) - - p = ps.register_surface_mesh("test_mesh2", self.generate_verts(), self.generate_faces()) - - p.set_all_permutations( - edge_perm=np.random.permutation(p.n_edges()), - edge_perm_size=3*p.n_edges(), - corner_perm=np.random.permutation(p.n_corners()), - corner_perm_size=3*p.n_corners(), - halfedge_perm=np.random.permutation(p.n_halfedges()), - halfedge_perm_size=p.n_halfedges(), - ) - - ps.show(3) - ps.remove_all_structures() - - - def test_scalar(self): - - for on in ['vertices', 'faces', 'edges', 'halfedges', 'corners', 'texture']: - - ps.register_surface_mesh("test_mesh", self.generate_verts(), self.generate_faces()) - p = ps.get_surface_mesh("test_mesh") - - param_name = None # used for texture case only - - extra_args = {} - if on == 'vertices': - vals = np.random.rand(p.n_vertices()) - elif on == 'faces': - vals = np.random.rand(p.n_faces()) - elif on == 'edges': - vals = np.random.rand(p.n_edges()) - p.set_edge_permutation(np.random.permutation(p.n_edges())) - elif on == 'halfedges': - vals = np.random.rand(p.n_halfedges()) - elif on == 'corners': - vals = np.random.rand(p.n_corners()) - elif on == 'texture': - param_vals = np.random.rand(p.n_vertices(), 2) - param_name = "test_param" - p.add_parameterization_quantity(param_name, param_vals, defined_on='vertices', enabled=True) - vals = np.random.rand(20,30) - extra_args['filter_mode'] = 'nearest' - - - p.add_scalar_quantity("test_vals", vals, defined_on=on, param_name=param_name) - p.add_scalar_quantity("test_vals2", vals, defined_on=on, param_name=param_name, enabled=True) - p.add_scalar_quantity("test_vals_with_range", vals, defined_on=on, param_name=param_name, vminmax=(-5., 5.), enabled=True) - p.add_scalar_quantity("test_vals_with_datatype", vals, defined_on=on, param_name=param_name, enabled=True, datatype='symmetric') - p.add_scalar_quantity("test_vals_with_cmap", vals, defined_on=on, param_name=param_name, enabled=True, cmap='blues') - p.add_scalar_quantity("test_vals_with_iso_old", vals, defined_on=on, param_name=param_name, cmap='blues', isolines_enabled=True, isoline_width=0.1, isoline_darkness=0.5, enabled=True) - p.add_scalar_quantity("test_vals_with_iso2", vals, defined_on=on, param_name=param_name, cmap='blues', isolines_enabled=True, isoline_style='stripe', isoline_period=0.1, isoline_darkness=0.5, enabled=True) - p.add_scalar_quantity("test_vals_with_iso_contour", vals, defined_on=on, param_name=param_name, cmap='blues', isolines_enabled=True, isoline_style='contour', isoline_period=0.1, isoline_contour_thickness =0.4, enabled=True) - p.add_scalar_quantity("test_vals_with_extra", vals, defined_on=on, param_name=param_name, enabled=True, **extra_args) - - ps.show(3) - - # test some additions/removal while we're at it - p.remove_quantity("test_vals") - p.remove_quantity("not_here") # should not error - p.remove_all_quantities() - p.remove_all_quantities() - - ps.remove_all_structures() - - def test_color(self): - ps.register_surface_mesh("test_mesh", self.generate_verts(), self.generate_faces()) - p = ps.get_surface_mesh("test_mesh") - - for on in ['vertices', 'faces', 'texture']: - - param_name = None # used for texture case only - - extra_args = {} - if on == 'vertices': - vals = np.random.rand(p.n_vertices(), 3) - elif on == 'faces': - vals = np.random.rand(p.n_faces(), 3) - elif on == 'texture': - param_vals = np.random.rand(p.n_vertices(), 2) - param_name = "test_param" - p.add_parameterization_quantity(param_name, param_vals, defined_on='vertices', enabled=True) - vals = np.random.rand(20,30,3) - extra_args['filter_mode'] = 'linear' - - - p.add_color_quantity("test_vals", vals, defined_on=on, param_name=param_name) - p.add_color_quantity("test_vals", vals, defined_on=on, param_name=param_name, enabled=True, **extra_args) - - ps.show(3) - p.remove_all_quantities() - - ps.remove_all_structures() - - - def test_distance(self): - ps.register_surface_mesh("test_mesh", self.generate_verts(), self.generate_faces()) - p = ps.get_surface_mesh("test_mesh") - - for on in ['vertices']: - - if on == 'vertices': - vals = np.random.rand(p.n_vertices()) - - p.add_distance_quantity("test_vals", vals, defined_on=on) - p.add_distance_quantity("test_vals2", vals, defined_on=on, enabled=True) - p.add_distance_quantity("test_vals_with_range", vals, defined_on=on, vminmax=(-5., 5.), enabled=True) - p.add_distance_quantity("test_vals_with_signed", vals, defined_on=on, enabled=True, signed=True) - p.add_distance_quantity("test_vals_with_unsigned", vals, defined_on=on, enabled=True, signed=False) - p.add_distance_quantity("test_vals_with_stripe", vals, defined_on=on, enabled=True, stripe_size=0.01) - p.add_distance_quantity("test_vals_with_stripe_reltrue", vals, defined_on=on, enabled=True, stripe_size=0.01, stripe_size_relative=True) - p.add_distance_quantity("test_vals_with_stripe_relfalse", vals, defined_on=on, enabled=True, stripe_size=0.01, stripe_size_relative=False) - - ps.show(3) - - p.remove_all_quantities() - - ps.remove_all_structures() - - def test_parameterization(self): - - ps.register_surface_mesh("test_mesh", self.generate_verts(), self.generate_faces()) - p = ps.get_surface_mesh("test_mesh") - - for on in ['vertices', 'corners']: - - if on == 'vertices': - vals = np.random.rand(p.n_vertices(), 2) - elif on == 'corners': - vals = np.random.rand(p.n_corners(), 2) - - cA = (0.1, 0.2, 0.3) - cB = (0.4, 0.5, 0.6) - - p.add_parameterization_quantity("test_vals1", vals, defined_on=on, enabled=True) - - p.add_parameterization_quantity("test_vals2", vals, defined_on=on, coords_type='world') - p.add_parameterization_quantity("test_vals3", vals, defined_on=on, coords_type='unit') - - p.add_parameterization_quantity("test_vals4", vals, defined_on=on, viz_style='checker') - p.add_parameterization_quantity("test_vals5", vals, defined_on=on, viz_style='grid') - p.add_parameterization_quantity("test_vals6", vals, defined_on=on, viz_style='local_check') - p.add_parameterization_quantity("test_vals7", vals, defined_on=on, viz_style='local_rad') - - p.add_parameterization_quantity("test_vals8", vals, defined_on=on, grid_colors=(cA, cB)) - p.add_parameterization_quantity("test_vals9", vals, defined_on=on, checker_colors=(cA, cB)) - p.add_parameterization_quantity("test_vals10", vals, defined_on=on, checker_size=0.1) - p.add_parameterization_quantity("test_vals11", vals, defined_on=on, cmap='blues') - - ps.show(3) - - # Test island labels - island_labels = np.random.randint(0, 10, size=p.n_faces()) - p.add_parameterization_quantity("test_vals_check_islands",vals, defined_on=on, enabled=True, - viz_style='checker_islands', island_labels=island_labels) - ps.show(3) - - # Test curve network from seams - p.add_parameterization_quantity("test_vals_curve_network", vals, defined_on=on, enabled=True, - create_curve_network_from_seams="") - p.add_parameterization_quantity("test_vals_curve_network", vals, defined_on=on, enabled=True, - create_curve_network_from_seams="my network") - ps.show(3) - - p.remove_all_quantities() - - ps.remove_all_structures() - - def test_vector(self): - - ps.register_surface_mesh("test_mesh", self.generate_verts(), self.generate_faces()) - p = ps.get_surface_mesh("test_mesh") - - for on in ['vertices', 'faces']: - - if on == 'vertices': - vals = np.random.rand(p.n_vertices(),3) - elif on == 'faces': - vals = np.random.rand(p.n_faces(), 3) - - p.add_vector_quantity("test_vals1", vals, defined_on=on) - p.add_vector_quantity("test_vals2", vals, defined_on=on, enabled=True) - p.add_vector_quantity("test_vals3", vals, defined_on=on, enabled=True, vectortype='ambient') - p.add_vector_quantity("test_vals4", vals, defined_on=on, enabled=True, length=0.005) - p.add_vector_quantity("test_vals5", vals, defined_on=on, enabled=True, radius=0.001) - p.add_vector_quantity("test_vals5", vals, defined_on=on, enabled=True, material="candy") - p.add_vector_quantity("test_vals6", vals, defined_on=on, enabled=True, color=(0.2, 0.5, 0.5)) - - # 2D - p.add_vector_quantity("test_vals7", vals[:,:2], defined_on=on, enabled=True, radius=0.001) - - ps.show(3) - p.remove_all_quantities() - - ps.remove_all_structures() - - - def test_tangent_vector(self): - - ps.register_surface_mesh("test_mesh", self.generate_verts(), self.generate_faces()) - p = ps.get_surface_mesh("test_mesh") - - for on in ['vertices', 'faces']: - - if on == 'vertices': - vals = np.random.rand(p.n_vertices(), 2) - basisX = np.random.rand(p.n_vertices(), 3) - basisY = np.random.rand(p.n_vertices(), 3) - elif on == 'faces': - vals = np.random.rand(p.n_faces(), 2) - basisX = np.random.rand(p.n_faces(), 3) - basisY = np.random.rand(p.n_faces(), 3) - - p.add_tangent_vector_quantity("test_vals1", vals, basisX, basisY, defined_on=on) - p.add_tangent_vector_quantity("test_vals2", vals, basisX, basisY, defined_on=on, enabled=True) - p.add_tangent_vector_quantity("test_vals3", vals, basisX, basisY, defined_on=on, enabled=True, vectortype='ambient') - p.add_tangent_vector_quantity("test_vals4", vals, basisX, basisY, defined_on=on, enabled=True, length=0.005) - p.add_tangent_vector_quantity("test_vals5", vals, basisX, basisY, defined_on=on, enabled=True, radius=0.001) - p.add_tangent_vector_quantity("test_vals6", vals, basisX, basisY, defined_on=on, enabled=True, color=(0.2, 0.5, 0.5)) - p.add_tangent_vector_quantity("test_vals7", vals, basisX, basisY, defined_on=on, enabled=True, radius=0.001) - p.add_tangent_vector_quantity("test_vals8", vals, basisX, basisY, n_sym=4, defined_on=on, enabled=True) - - ps.show(3) - p.remove_all_quantities() - - ps.remove_all_structures() - - def test_one_form_tangent_vector(self): - - ps.register_surface_mesh("test_mesh", self.generate_verts(), self.generate_faces()) - p = ps.get_surface_mesh("test_mesh") - - p.set_edge_permutation(np.random.permutation(p.n_edges())) - - vals = np.random.rand(p.n_edges()) - orients = np.random.rand(p.n_edges()) > 0.5 - - p.add_one_form_vector_quantity("test_vals1", vals, orients) - p.add_one_form_vector_quantity("test_vals2", vals, orients, enabled=True) - p.add_one_form_vector_quantity("test_vals3", vals, orients, enabled=True) - p.add_one_form_vector_quantity("test_vals4", vals, orients, enabled=True, length=0.005) - p.add_one_form_vector_quantity("test_vals5", vals, orients, enabled=True, radius=0.001) - p.add_one_form_vector_quantity("test_vals6", vals, orients, enabled=True, color=(0.2, 0.5, 0.5)) - p.add_one_form_vector_quantity("test_vals7", vals, orients, enabled=True, radius=0.001) - - ps.show(3) - p.remove_all_quantities() - - ps.remove_all_structures() - - def test_variable_radius(self): - - for on in ['vertices', 'faces', 'corners']: - - ps.register_surface_mesh("test_mesh", self.generate_verts(), self.generate_faces()) - p = ps.get_surface_mesh("test_mesh") - - if on == 'vertices': - vals = np.random.rand(p.n_vertices()) - elif on == 'faces': - vals = np.random.rand(p.n_faces()) - elif on == 'corners': - vals = np.random.rand(p.n_corners()) - - p.add_scalar_quantity("test_vals", vals, defined_on=on) - - p.set_transparency_quantity("test_vals") - ps.show(3) - p.clear_transparency_quantity() - ps.show(3) - - ps.remove_all_structures() - - -class TestVolumeMesh(unittest.TestCase): - - def generate_verts(self, n_pts=10): - np.random.seed(777) - return np.random.rand(n_pts, 3) - - def generate_tets(self, n_pts=10): - np.random.seed(777) - return np.random.randint(0, n_pts, size=(2*n_pts,4)) - - def test_add_remove(self): - - # add - n = ps.register_volume_mesh("test_mesh", self.generate_verts(), self.generate_tets()) - self.assertTrue(ps.has_volume_mesh("test_mesh")) - self.assertFalse(ps.has_volume_mesh("nope")) - self.assertEqual(n.n_vertices(), 10) - self.assertEqual(n.n_cells(), 20) - - # remove by name - ps.register_volume_mesh("test_mesh2", self.generate_verts(), self.generate_tets()) - ps.remove_volume_mesh("test_mesh2") - self.assertTrue(ps.has_volume_mesh("test_mesh")) - self.assertFalse(ps.has_volume_mesh("test_mesh2")) - - # remove by ref - c = ps.register_volume_mesh("test_mesh2", self.generate_verts(), self.generate_tets()) - c.remove() - self.assertTrue(ps.has_volume_mesh("test_mesh")) - self.assertFalse(ps.has_volume_mesh("test_mesh2")) - - # get by name - ps.register_volume_mesh("test_mesh3", self.generate_verts(), self.generate_tets()) - p = ps.get_volume_mesh("test_mesh3") # should be wrapped instance, not underlying PSB instance - self.assertTrue(isinstance(p, ps.VolumeMesh)) - - ps.remove_all_structures() - - def test_render(self): - - ps.register_volume_mesh("test_mesh", self.generate_verts(), self.generate_tets()) - ps.show(3) - ps.remove_all_structures() - - def test_add_tet(self): - ps.register_volume_mesh("test_mesh3", self.generate_verts(), tets=self.generate_tets()) - ps.show(3) - ps.remove_all_structures() - - def test_add_hex(self): - np.random.seed(777) - n_pts = 10 - cells = np.random.randint(0, n_pts, size=(2*n_pts,8)) - ps.register_volume_mesh("test_mesh3", self.generate_verts(), hexes=cells) - ps.show(3) - ps.remove_all_structures() - - def test_add_combined(self): - np.random.seed(777) - n_pts = 10 - cells = np.random.randint(0, n_pts, size=(2*n_pts,8)) - ps.register_volume_mesh("test_mesh3", self.generate_verts(), tets=self.generate_tets(), hexes=cells) - ps.show(3) - ps.remove_all_structures() - - def test_add_mixed(self): - np.random.seed(777) - n_pts = 10 - cells = np.random.randint(0, n_pts, size=(2*n_pts,8)) - cells[-5:,4:] = -1 # clear out some rows at end - ps.register_volume_mesh("test_mesh3", self.generate_verts(), mixed_cells=cells) - ps.show(3) - ps.remove_all_structures() - - # test a few error cases - # cells = np.random.randint(0, n_pts, size=(2*n_pts,8)) - # cells[-5:,4:] = -1 # clear out some rows at end - # ps.register_volume_mesh("test_mesh3", self.generate_verts(), hexes=self.generate_tets()) - - def test_options(self): - - p = ps.register_volume_mesh("test_mesh", self.generate_verts(), self.generate_tets()) - - # Set enabled - p.set_enabled() - p.set_enabled(False) - p.set_enabled(True) - self.assertTrue(p.is_enabled()) - - # Color - color = (0.3, 0.3, 0.5) - p.set_color(color) - ret_color = p.get_color() - for i in range(3): - self.assertAlmostEqual(ret_color[i], color[i]) - - # Interior Color - color = (0.45, 0.85, 0.2) - p.set_interior_color(color) - ret_color = p.get_interior_color() - for i in range(3): - self.assertAlmostEqual(ret_color[i], color[i]) - - # Edge color - color = (0.1, 0.5, 0.5) - p.set_edge_color(color) - ret_color = p.get_edge_color() - for i in range(3): - self.assertAlmostEqual(ret_color[i], color[i]) - - ps.show(3) - - # Edge width - p.set_edge_width(1.5) - ps.show(3) - self.assertAlmostEqual(p.get_edge_width(), 1.5) - - # Material - p.set_material("candy") - self.assertEqual("candy", p.get_material()) - p.set_material("clay") - - # Transparency - p.set_transparency(0.8) - self.assertAlmostEqual(0.8, p.get_transparency()) - - # Set with optional arguments - p2 = ps.register_volume_mesh("test_mesh", self.generate_verts(), self.generate_tets(), - enabled=True, material='wax', color=(1., 0., 0.), edge_color=(0.5, 0.5, 0.5), - interior_color=(0.2, 0.2, 0.2), edge_width=0.5, - transparency=0.9) - - ps.show(3) - ps.remove_all_structures() - ps.set_transparency_mode('none') - - def test_transform(self): - - p = ps.register_volume_mesh("test_mesh", self.generate_verts(), self.generate_tets()) - test_transforms(self,p) - ps.remove_all_structures() - - def test_slice_plane(self): - - p = ps.register_volume_mesh("test_mesh", self.generate_verts(), self.generate_tets()) - - plane = ps.add_scene_slice_plane() - p.set_cull_whole_elements(True) - ps.show(3) - p.set_cull_whole_elements(False) - ps.show(3) - - p.set_ignore_slice_plane(plane, True) - self.assertEqual(True, p.get_ignore_slice_plane(plane)) - p.set_ignore_slice_plane(plane.get_name(), False) - self.assertEqual(False, p.get_ignore_slice_plane(plane.get_name())) - - plane.set_volume_mesh_to_inspect("test_mesh") - self.assertEqual("test_mesh", plane.get_volume_mesh_to_inspect()) - - ps.show(3) - - ps.remove_all_structures() - ps.remove_last_scene_slice_plane() - - def test_update(self): - - p = ps.register_volume_mesh("test_mesh", self.generate_verts(), self.generate_tets()) - ps.show(3) - - newPos = self.generate_verts() - 0.5 - p.update_vertex_positions(newPos) - - ps.show(3) - ps.remove_all_structures() - - def test_scalar(self): - ps.register_volume_mesh("test_mesh", self.generate_verts(), self.generate_tets()) - p = ps.get_volume_mesh("test_mesh") - - for on in ['vertices', 'cells']: - - if on == 'vertices': - vals = np.random.rand(p.n_vertices()) - elif on == 'cells': - vals = np.random.rand(p.n_cells()) - - p.add_scalar_quantity("test_vals", vals, defined_on=on) - p.add_scalar_quantity("test_vals2", vals, defined_on=on, enabled=True) - p.add_scalar_quantity("test_vals_with_range", vals, defined_on=on, vminmax=(-5., 5.), enabled=True) - p.add_scalar_quantity("test_vals_with_datatype", vals, defined_on=on, enabled=True, datatype='symmetric') - p.add_scalar_quantity("test_vals_with_iso2", vals, defined_on=on, cmap='reds', enabled=True) - p.add_scalar_quantity("test_vals_with_iso2", vals, defined_on=on, cmap='blues', isolines_enabled=True, isoline_style='stripe', isoline_period=0.1, isoline_darkness=0.5, enabled=True) - p.add_scalar_quantity("test_vals_with_iso_contour", vals, defined_on=on, cmap='blues', isolines_enabled=True, isoline_style='contour', isoline_period=0.1, isoline_contour_thickness=0.4, enabled=True) - p.add_scalar_quantity("test_vals_with_cmap", vals, defined_on=on, enabled=True, cmap='blues') - - ps.show(3) - - # test some additions/removal while we're at it - p.remove_quantity("test_vals") - p.remove_quantity("not_here") # should not error - p.remove_all_quantities() - p.remove_all_quantities() - - ps.remove_all_structures() - - - def test_color(self): - ps.register_volume_mesh("test_mesh", self.generate_verts(), self.generate_tets()) - p = ps.get_volume_mesh("test_mesh") - - for on in ['vertices', 'cells']: - - if on == 'vertices': - vals = np.random.rand(p.n_vertices(), 3) - elif on == 'cells': - vals = np.random.rand(p.n_cells(), 3) - - - p.add_color_quantity("test_vals", vals, defined_on=on) - p.add_color_quantity("test_vals", vals, defined_on=on, enabled=True) - - ps.show(3) - p.remove_all_quantities() - - ps.remove_all_structures() - - - def test_vector(self): - - ps.register_volume_mesh("test_mesh", self.generate_verts(), self.generate_tets()) - p = ps.get_volume_mesh("test_mesh") - - for on in ['vertices', 'cells']: - - if on == 'vertices': - vals = np.random.rand(p.n_vertices(),3) - elif on == 'cells': - vals = np.random.rand(p.n_cells(), 3) - - p.add_vector_quantity("test_vals1", vals, defined_on=on) - p.add_vector_quantity("test_vals2", vals, defined_on=on, enabled=True) - p.add_vector_quantity("test_vals3", vals, defined_on=on, enabled=True, vectortype='ambient') - p.add_vector_quantity("test_vals4", vals, defined_on=on, enabled=True, length=0.005) - p.add_vector_quantity("test_vals5", vals, defined_on=on, enabled=True, radius=0.001) - p.add_vector_quantity("test_vals6", vals, defined_on=on, enabled=True, color=(0.2, 0.5, 0.5)) - - ps.show(3) - p.remove_all_quantities() - - ps.remove_all_structures() - -class TestVolumeGrid(unittest.TestCase): - - def test_add_remove(self): - - # add - n = ps.register_volume_grid("test_grid", (10,12,14), (0.,0.,0,), (1., 1., 1.)) - self.assertTrue(ps.has_volume_grid("test_grid")) - self.assertFalse(ps.has_volume_grid("nope")) - self.assertEqual(n.n_nodes(), 10*12*14) - self.assertEqual(n.n_cells(), (10-1)*(12-1)*(14-1)) - - # remove by name - ps.register_volume_grid("test_grid2", (10,12,14), (0.,0.,0,), (1., 1., 1.)) - ps.remove_volume_grid("test_grid2") - self.assertTrue(ps.has_volume_grid("test_grid")) - self.assertFalse(ps.has_volume_grid("test_grid2")) - - # remove by ref - c = ps.register_volume_grid("test_grid2", (10,12,14), (0.,0.,0,), (1., 1., 1.)) - c.remove() - self.assertTrue(ps.has_volume_grid("test_grid")) - self.assertFalse(ps.has_volume_grid("test_grid2")) - - # get by name - ps.register_volume_grid("test_grid3", (10,12,14), (0.,0.,0,), (1., 1., 1.)) - p = ps.get_volume_grid("test_grid3") # should be wrapped instance, not underlying PSB instance - self.assertTrue(isinstance(p, ps.VolumeGrid)) - - ps.remove_all_structures() - - def test_render(self): - - ps.register_volume_grid("test_grid", (10,12,14), (0.,0.,0,), (1., 1., 1.)) - ps.show(3) - ps.remove_all_structures() - - def test_options(self): - - p = ps.register_volume_grid("test_grid", (10,12,14), (0.,0.,0,), (1., 1., 1.)) - - # misc getters - p.n_nodes() - p.n_cells() - p.grid_spacing() - self.assertTrue((p.get_grid_node_dim() == (10,12,14))) - self.assertTrue((p.get_grid_cell_dim() == ((10-1),(12-1),(14-1)))) - self.assertTrue((p.get_bound_min() == np.array((0., 0., 0.))).all()) - self.assertTrue((p.get_bound_max() == np.array((1., 1., 1.))).all()) - - # Set enabled - p.set_enabled() - p.set_enabled(False) - p.set_enabled(True) - self.assertTrue(p.is_enabled()) - - # Color - color = (0.3, 0.3, 0.5) - p.set_color(color) - ret_color = p.get_color() - for i in range(3): - self.assertAlmostEqual(ret_color[i], color[i]) - - # Edge color - color = (0.1, 0.5, 0.5) - p.set_edge_color(color) - ret_color = p.get_edge_color() - for i in range(3): - self.assertAlmostEqual(ret_color[i], color[i]) - - ps.show(3) - - # Edge width - p.set_edge_width(1.5) - ps.show(3) - self.assertAlmostEqual(p.get_edge_width(), 1.5) - - # Cube size factor - p.set_cube_size_factor(0.5) - ps.show(3) - self.assertAlmostEqual(p.get_cube_size_factor(), 0.5) - - # Material - p.set_material("candy") - self.assertEqual("candy", p.get_material()) - p.set_material("clay") - - # Transparency - p.set_transparency(0.8) - self.assertAlmostEqual(0.8, p.get_transparency()) - - # Set with optional arguments - p2 = ps.register_volume_grid("test_grid", (10,12,14), (0.,0.,0,), (1., 1., 1.), - enabled=True, material='wax', color=(1., 0., 0.), edge_color=(0.5, 0.5, 0.5), edge_width=0.5, cube_size_factor=0.5, transparency=0.9) - - ps.show(3) - - ps.remove_all_structures() - ps.set_transparency_mode('none') - - def test_transform(self): - - p = ps.register_volume_grid("test_grid", (10,12,14), (0.,0.,0,), (1., 1., 1.)) - test_transforms(self,p) - ps.remove_all_structures() - - def test_slice_plane(self): - - p = ps.register_volume_grid("test_grid", (10,12,14), (0.,0.,0,), (1., 1., 1.)) - - plane = ps.add_scene_slice_plane() - p.set_cull_whole_elements(True) - ps.show(3) - p.set_cull_whole_elements(False) - ps.show(3) - - p.set_ignore_slice_plane(plane, True) - self.assertEqual(True, p.get_ignore_slice_plane(plane)) - p.set_ignore_slice_plane(plane.get_name(), False) - self.assertEqual(False, p.get_ignore_slice_plane(plane.get_name())) - - ps.show(3) - - ps.remove_all_structures() - ps.remove_last_scene_slice_plane() - - - def test_scalar(self): - node_dim = (10,12,14) - cell_dim = (10-1,12-1,14-1) - p = ps.register_volume_grid("test_grid", node_dim, (0.,0.,0,), (1., 1., 1.)) - - for on in ['nodes', 'cells']: - - if on == 'nodes': - vals = np.random.rand(*node_dim) - elif on == 'cells': - vals = np.random.rand(*cell_dim) - - p.add_scalar_quantity("test_vals", vals, defined_on=on) - p.add_scalar_quantity("test_vals2", vals, defined_on=on, enabled=True) - p.add_scalar_quantity("test_vals_with_range", vals, defined_on=on, vminmax=(-5., 5.), enabled=True) - p.add_scalar_quantity("test_vals_with_datatype", vals, defined_on=on, enabled=True, datatype='symmetric') - p.add_scalar_quantity("test_vals_with_cmap", vals, defined_on=on, enabled=True, cmap='blues', enable_gridcube_viz=False) - - ps.show(3) - - # test some additions/removal while we're at it - p.remove_quantity("test_vals") - p.remove_quantity("not_here") # should not error - p.remove_all_quantities() - p.remove_all_quantities() - - ps.remove_all_structures() - - def test_scalar_from_callable(self): - node_dim = (10,12,14) - cell_dim = (10-1,12-1,14-1) - p = ps.register_volume_grid("test_grid", node_dim, (0.,0.,0,), (1., 1., 1.)) - - def sphere_sdf(pts): return np.linalg.norm(pts, axis=-1) - 1. - - for on in ['nodes', 'cells']: - - p.add_scalar_quantity_from_callable("test_vals", sphere_sdf, defined_on=on) - p.add_scalar_quantity_from_callable("test_vals2", sphere_sdf, defined_on=on, enabled=True) - p.add_scalar_quantity_from_callable("test_vals_with_range", sphere_sdf, defined_on=on, vminmax=(-5., 5.), enabled=True) - p.add_scalar_quantity_from_callable("test_vals_with_datatype", sphere_sdf, defined_on=on, enabled=True, datatype='symmetric') - p.add_scalar_quantity_from_callable("test_vals_with_cmap", sphere_sdf, defined_on=on, enabled=True, cmap='blues', enable_gridcube_viz=False) - - ps.show(3) - - # test some additions/removal while we're at it - p.remove_quantity("test_vals") - p.remove_quantity("not_here") # should not error - p.remove_all_quantities() - p.remove_all_quantities() - - ps.remove_all_structures() - - def test_scalar_isosurface_array(self): - node_dim = (10,12,14) - - p = ps.register_volume_grid("test_grid", node_dim, (0.,0.,0,), (1., 1., 1.)) - vals = np.random.rand(*node_dim) - - p.add_scalar_quantity("test_vals", vals, defined_on='nodes', enabled=True, - enable_gridcube_viz=False, enable_isosurface_viz=True, - isosurface_level=-0.2, isosurface_color=(0.5,0.6,0.7), - slice_planes_affect_isosurface=False, - register_isosurface_as_mesh_with_name="isomesh") - - ps.remove_all_structures() - - def test_scalar_isosurface_callable(self): - node_dim = (10,12,14) - - p = ps.register_volume_grid("test_grid", node_dim, (0.,0.,0,), (1., 1., 1.)) - def sphere_sdf(pts): return np.linalg.norm(pts, axis=-1) - 1. - - p.add_scalar_quantity_from_callable("test_vals", sphere_sdf, defined_on='nodes', enabled=True, - enable_gridcube_viz=False, enable_isosurface_viz=True, - isosurface_level=-0.2, isosurface_color=(0.5,0.6,0.7), - slice_planes_affect_isosurface=False, - register_isosurface_as_mesh_with_name="isomesh") - - ps.remove_all_structures() - - - -class TestCameraView(unittest.TestCase): - - def generate_parameters(self): - intrinsics = ps.CameraIntrinsics(fov_vertical_deg=60, aspect=2) - extrinsics = ps.CameraExtrinsics(root=(2., 2., 2.), look_dir=(-1., -1.,-1.), up_dir=(0.,1.,0.)) - return ps.CameraParameters(intrinsics, extrinsics) - - def test_add_remove(self): - - # add - cam = ps.register_camera_view("cam1", self.generate_parameters()) - self.assertTrue(ps.has_camera_view("cam1")) - self.assertFalse(ps.has_camera_view("nope")) - - # remove by name - ps.register_camera_view("cam2", self.generate_parameters()) - ps.remove_camera_view("cam2") - self.assertTrue(ps.has_camera_view("cam1")) - self.assertFalse(ps.has_camera_view("cam2")) - - # remove by ref - c = ps.register_camera_view("cam3", self.generate_parameters()) - c.remove() - self.assertTrue(ps.has_camera_view("cam1")) - self.assertFalse(ps.has_camera_view("cam3")) - - # get by name - ps.register_camera_view("cam3", self.generate_parameters()) - p = ps.get_camera_view("cam3") # should be wrapped instance, not underlying PSB instance - self.assertTrue(isinstance(p, ps.CameraView)) - - ps.remove_all_structures() - - def test_render(self): - - cam = ps.register_camera_view("cam1", self.generate_parameters()) - ps.show(3) - ps.remove_all_structures() - - def test_transform(self): - - cam = ps.register_camera_view("cam1", self.generate_parameters()) - test_transforms(self, cam) - ps.remove_all_structures() - - def test_options(self): - - cam = ps.register_camera_view("cam1", self.generate_parameters()) - - # widget color - color = (0.3, 0.3, 0.5) - cam.set_widget_color(color) - ret_color = cam.get_widget_color() - for i in range(3): - self.assertAlmostEqual(ret_color[i], color[i]) - - # widget thickness - cam.set_widget_thickness(0.03) - self.assertAlmostEqual(0.03, cam.get_widget_thickness()) - - # widget focal length - cam.set_widget_focal_length(0.03, False) - self.assertAlmostEqual(0.03, cam.get_widget_focal_length()) - - ps.show(3) - ps.remove_all_structures() - - def test_update(self): - - cam = ps.register_camera_view("cam1", self.generate_parameters()) - cam.update_camera_parameters(self.generate_parameters()) - - ps.show(3) - ps.remove_all_structures() - - def test_camera_things(self): - - cam = ps.register_camera_view("cam1", self.generate_parameters()) - cam.set_view_to_this_camera() - ps.show(3) - cam.set_view_to_this_camera(with_flight=True) - ps.show(3) - - ps.remove_all_structures() - - def test_camera_parameters(self): - - cam = ps.register_camera_view("cam1", self.generate_parameters()) - params = cam.get_camera_parameters() - - self.assertTrue(isinstance(params.get_intrinsics(), ps.CameraIntrinsics)) - self.assertTrue(isinstance(params.get_extrinsics(), ps.CameraExtrinsics)) - - assertArrayWithShape(self, params.get_R(), [3,3]) - assertArrayWithShape(self, params.get_T(), [3]) - assertArrayWithShape(self, params.get_view_mat(), [4,4]) - assertArrayWithShape(self, params.get_E(), [4,4]) - assertArrayWithShape(self, params.get_position(), [3]) - assertArrayWithShape(self, params.get_look_dir(), [3]) - assertArrayWithShape(self, params.get_up_dir(), [3]) - assertArrayWithShape(self, params.get_right_dir(), [3]) - assertArrayWithShape(self, params.get_camera_frame()[0], [3]) - assertArrayWithShape(self, params.get_camera_frame()[1], [3]) - assertArrayWithShape(self, params.get_camera_frame()[2], [3]) - - self.assertTrue(isinstance(params.get_fov_vertical_deg(), float)) - self.assertTrue(isinstance(params.get_aspect(), float)) - - dimX = 300 - dimY = 200 - rays = params.generate_camera_rays((dimX,dimY)) - assertArrayWithShape(self, rays, [dimY,dimX,3]) - ray_corners = params.generate_camera_ray_corners() - - def test_floating_scalar_images(self): - - # technically these can be added to any structure, but we will test them here - - cam = ps.register_camera_view("cam1", self.generate_parameters()) - - dimX = 300 - dimY = 600 - - cam.add_scalar_image_quantity("scalar_img", np.zeros((dimY, dimX))) - cam.add_scalar_image_quantity("scalar_img2", np.zeros((dimY, dimX)), enabled=True, image_origin='lower_left', datatype='symmetric', vminmax=(-3.,.3), cmap='reds', show_in_camera_billboard=True) - cam.add_scalar_image_quantity("scalar_img3", np.zeros((dimY, dimX)), enabled=True, show_in_imgui_window=True, show_in_camera_billboard=False) - cam.add_scalar_image_quantity("scalar_img4", np.zeros((dimY, dimX)), enabled=True, show_fullscreen=True, show_in_camera_billboard=False, transparency=0.5) - - # true floating adder - ps.add_scalar_image_quantity("scalar_img2", np.zeros((dimY, dimX)), enabled=True, image_origin='lower_left', datatype='symmetric', vminmax=(-3.,.3), cmap='reds') - - ps.show(3) - ps.remove_all_structures() - - def test_floating_color_images(self): - - # technically these can be added to any structure, but we will test them here - - cam = ps.register_camera_view("cam1", self.generate_parameters()) - - dimX = 300 - dimY = 600 - - cam.add_color_image_quantity("color_img", np.zeros((dimY, dimX, 3))) - cam.add_color_image_quantity("color_img2", np.zeros((dimY, dimX, 3)), enabled=True, image_origin='lower_left', show_in_camera_billboard=True) - cam.add_color_image_quantity("color_img3", np.zeros((dimY, dimX, 3)), enabled=True, show_in_imgui_window=True, show_in_camera_billboard=False) - cam.add_color_image_quantity("color_img4", np.zeros((dimY, dimX, 3)), enabled=True, show_fullscreen=True, show_in_camera_billboard=False, transparency=0.5) - - # true floating adder - ps.add_color_image_quantity("color_img2", np.zeros((dimY, dimX, 3)), enabled=True, image_origin='lower_left', show_in_camera_billboard=False) - - ps.show(3) - ps.remove_all_structures() - - def test_floating_color_alpha_images(self): - - # technically these can be added to any structure, but we will test them here - - cam = ps.register_camera_view("cam1", self.generate_parameters()) - - dimX = 300 - dimY = 600 - - cam.add_color_alpha_image_quantity("color_alpha_img", np.zeros((dimY, dimX, 4))) - cam.add_color_alpha_image_quantity("color_alpha_img2", np.zeros((dimY, dimX, 4)), enabled=True, image_origin='lower_left', show_in_camera_billboard=True) - cam.add_color_alpha_image_quantity("color_alpha_img3", np.zeros((dimY, dimX, 4)), enabled=True, show_in_imgui_window=True, show_in_camera_billboard=False, is_premultiplied=True) - cam.add_color_alpha_image_quantity("color_alpha_img4", np.zeros((dimY, dimX, 4)), enabled=True, show_fullscreen=True, show_in_camera_billboard=False) - - # true floating adder - ps.add_color_alpha_image_quantity("color_alpha_img3", np.zeros((dimY, dimX, 4)), enabled=True, show_in_imgui_window=True, show_in_camera_billboard=False) - - ps.show(3) - ps.remove_all_structures() - - def test_floating_depth_render_images(self): - - # technically these can be added to any structure, but we will test them here - - cam = ps.register_camera_view("cam1", self.generate_parameters()) - - dimX = 300 - dimY = 600 - - depths = np.zeros((dimY, dimX)) - normals = np.ones((dimY, dimX, 3)) - - cam.add_depth_render_image_quantity("render_img", depths, normals) - cam.add_depth_render_image_quantity("render_img2", depths, normals, enabled=True, image_origin='lower_left', color=(0., 1., 0.), material='wax', transparency=0.7) - - # true floating adder - ps.add_depth_render_image_quantity("render_img3", depths, normals, enabled=True, image_origin='lower_left', color=(0., 1., 0.), material='wax', transparency=0.7, allow_fullscreen_compositing=True) - - ps.show(3) - ps.remove_all_structures() - - def test_floating_color_render_images(self): - - # technically these can be added to any structure, but we will test them here - - cam = ps.register_camera_view("cam1", self.generate_parameters()) - - dimX = 300 - dimY = 600 - - depths = np.zeros((dimY, dimX)) - normals = np.ones((dimY, dimX, 3)) - colors = np.ones((dimY, dimX, 3)) - - cam.add_color_render_image_quantity("render_img", depths, normals, colors) - cam.add_color_render_image_quantity("render_img2", depths, normals, colors, enabled=True, image_origin='lower_left', material='wax', transparency=0.7) - - # true floating adder - ps.add_color_render_image_quantity("render_img3", depths, normals, colors, enabled=True, image_origin='lower_left', material='wax', transparency=0.7, allow_fullscreen_compositing=True) - - ps.show(3) - ps.remove_all_structures() - - def test_floating_scalar_render_images(self): - - # technically these can be added to any structure, but we will test them here - - cam = ps.register_camera_view("cam1", self.generate_parameters()) - - dimX = 300 - dimY = 600 - - depths = np.zeros((dimY, dimX)) - normals = np.ones((dimY, dimX, 3)) - scalars = np.ones((dimY, dimX)) - - cam.add_scalar_render_image_quantity("render_img", depths, normals, scalars) - cam.add_scalar_render_image_quantity("render_img2", depths, normals, scalars, enabled=True, image_origin='lower_left', material='wax', transparency=0.7) - - # true floating adder - ps.add_scalar_render_image_quantity("render_img3", depths, normals, scalars, enabled=True, image_origin='lower_left', material='wax', transparency=0.7, allow_fullscreen_compositing=True) - - ps.show(3) - ps.remove_all_structures() - - def test_floating_raw_color_render_images(self): - - # technically these can be added to any structure, but we will test them here - - cam = ps.register_camera_view("cam1", self.generate_parameters()) - - dimX = 300 - dimY = 600 - - depths = np.zeros((dimY, dimX)) - colors = np.ones((dimY, dimX, 3)) - - cam.add_raw_color_render_image_quantity("render_img", depths, colors) - cam.add_raw_color_render_image_quantity("render_img2", depths, colors, enabled=True, image_origin='lower_left', transparency=0.7) - - # true floating adder - ps.add_raw_color_render_image_quantity("render_img3", depths, colors, enabled=True, image_origin='lower_left', transparency=0.7, allow_fullscreen_compositing=True) - - ps.show(3) - ps.remove_all_structures() - - def test_floating_raw_color_alpha_render_images(self): - - # technically these can be added to any structure, but we will test them here - - cam = ps.register_camera_view("cam1", self.generate_parameters()) - - dimX = 300 - dimY = 600 - depths = np.zeros((dimY, dimX)) - colors = np.ones((dimY, dimX, 4)) +def print_discovered_tests_summary(suite, full_listing=False): - cam.add_raw_color_alpha_render_image_quantity("render_img", depths, colors) - cam.add_raw_color_alpha_render_image_quantity("render_img2", depths, colors, enabled=True, image_origin='lower_left', transparency=0.7, is_premultiplied=True) - - # true floating adder - ps.add_raw_color_alpha_render_image_quantity("render_img3", depths, colors, enabled=True, image_origin='lower_left', transparency=0.7, allow_fullscreen_compositing=True) + def summarize_tests(suite): + summary = defaultdict(list) - ps.show(3) - ps.remove_all_structures() - - def test_floating_implicit_surface_render(self): - - # this can be called free-floating or on a camera view, but we will test them here - - def sphere_sdf(pts): return np.linalg.norm(pts, axis=-1) - 1. - - # basic - ps.render_implicit_surface("sphere sdf", sphere_sdf, 'fixed_step', subsample_factor=10, n_max_steps=10, enabled=True) - - # with some args - ps.render_implicit_surface("sphere sdf", sphere_sdf, 'sphere_march', enabled=True, - camera_parameters=self.generate_parameters(), - dim=(50,75), - miss_dist=20.5, miss_dist_relative=True, - hit_dist=0.001, hit_dist_relative=False, - step_factor=0.98, - normal_sample_eps=0.02, - step_size=0.01, step_size_relative=True, - n_max_steps=50, - material='wax', - color=(0.5,0.5,0.5) - ) - - # from this camera view - cam = ps.register_camera_view("cam1", self.generate_parameters()) - ps.render_implicit_surface("sphere sdf", sphere_sdf, 'sphere_march', dim=(50,75), n_max_steps=10, camera_view=cam, enabled=True) - - ps.show(3) - ps.remove_all_structures() - - def test_floating_implicit_surface_color_render(self): - - # this can be called free-floating or on a camera view, but we will test them here - - def sphere_sdf(pts): return np.linalg.norm(pts, axis=-1) - 1. - def color_func(pts): return np.zeros_like(pts) - - # basic - ps.render_implicit_surface_color("sphere sdf", sphere_sdf, color_func, 'fixed_step', subsample_factor=10, n_max_steps=10, enabled=True) - - # with some args - ps.render_implicit_surface_color("sphere sdf", sphere_sdf, color_func, 'sphere_march', enabled=True, - camera_parameters=self.generate_parameters(), - dim=(50,75), - miss_dist=20.5, miss_dist_relative=True, - hit_dist=0.001, hit_dist_relative=False, - step_factor=0.98, - normal_sample_eps=0.02, - step_size=0.01, step_size_relative=True, - n_max_steps=50, - material='wax', - ) - - # from this camera view - cam = ps.register_camera_view("cam1", self.generate_parameters()) - ps.render_implicit_surface_color("sphere sdf", sphere_sdf, color_func, 'sphere_march', dim=(50,75), n_max_steps=10, camera_view=cam, enabled=True) - - ps.show(3) - ps.remove_all_structures() - - - def test_floating_implicit_surface_scalar_render(self): - - # this can be called free-floating or on a camera view, but we will test them here - - def sphere_sdf(pts): return np.linalg.norm(pts, axis=-1) - 1. - def scalar_func(pts): return np.ones_like(pts[:,0]) - - # basic - ps.render_implicit_surface_scalar("sphere sdf", sphere_sdf, scalar_func, 'fixed_step', subsample_factor=10, n_max_steps=10, enabled=True) - - # with some args - ps.render_implicit_surface_scalar("sphere sdf", sphere_sdf, scalar_func, 'sphere_march', enabled=True, - camera_parameters=self.generate_parameters(), - dim=(50,75), - miss_dist=20.5, miss_dist_relative=True, - hit_dist=0.001, hit_dist_relative=False, - step_factor=0.98, - normal_sample_eps=0.02, - step_size=0.01, step_size_relative=True, - n_max_steps=50, - material='wax', - cmap='blues', - vminmax=(0.,1.) - ) - - # from this camera view - cam = ps.register_camera_view("cam1", self.generate_parameters()) - ps.render_implicit_surface_scalar("sphere sdf", sphere_sdf, scalar_func, 'sphere_march', dim=(50,75), n_max_steps=10, camera_view=cam, enabled=True) - - ps.show(3) - ps.remove_all_structures() - -class TestManagedBuffers(unittest.TestCase): - - def test_managed_buffer_basics(self): - - # NOTE: this only tests the float & vec3 versions, really there are variant methods for each type - - def generate_points(n_pts=10): - np.random.seed(777) - return np.random.rand(n_pts, 3) - - def generate_scalar(n_pts=10): - np.random.seed(777) - return np.random.rand(n_pts) - - - # create a dummy point cloud; - ps_cloud = ps.register_point_cloud("test_cloud", generate_points()) - ps_scalar = ps_cloud.add_scalar_quantity("test_vals", generate_scalar()) - ps.show(3) - - # test a quantity buffer of float - scalar_buf = ps_cloud.get_quantity_buffer("test_vals", "values") - self.assertEqual(scalar_buf.size(), 10) - self.assertTrue(scalar_buf.has_data()) - scalar_buf.get_value(3) - scalar_buf.update_data(generate_scalar()) + def collect_tests(suite): + for test in suite: + if isinstance(test, unittest.TestSuite): + collect_tests(test) + else: + test_id = test.id() + class_name = '.'.join(test_id.split('.')[:-1]) + method_name = test_id.split('.')[-1] + summary[class_name].append(method_name) - # test a structure buffer of vec3 - pos_buf = ps_cloud.get_buffer("points") - self.assertEqual(pos_buf.size(), 10) - self.assertTrue(pos_buf.has_data()) - pos_buf.summary_string() - pos_buf.get_value(3) - pos_buf.update_data(generate_points()) - - ps.show(3) + collect_tests(suite) + return summary - # test a free-floating quantity buffer - dimX = 200 - dimY = 300 - ps.add_scalar_image_quantity("test_float_img", np.zeros((dimY, dimX))) - img_buf = ps.get_quantity_buffer("test_float_img", "values") - self.assertEqual(img_buf.size(), dimX*dimY) - self.assertTrue(img_buf.has_data()) - img_buf.summary_string() - img_buf.get_value(3) - img_buf.update_data(np.zeros(dimX*dimY)) + summary = summarize_tests(suite) - # test key presses - if(psim.IsKeyPressed(psim.ImGuiKey_A)): - pass - - ps.show(3) + print(f"Found {sum(len(tests) for tests in summary.values())} tests in {len(summary)} test classes.") + if full_listing: + for class_name, methods in sorted(summary.items()): + print(f"{class_name} ({len(methods)} tests)") + for method in sorted(methods): + print(f" - {method}") if __name__ == '__main__': @@ -2792,6 +66,15 @@ def generate_scalar(n_pts=10): ps.set_errors_throw_exceptions(True) ps.set_display_message_popups(False) ps.set_warn_for_invalid_values(False) + ps.set_use_prefs_file(False) ps.init(ps_backend) - unittest.main() + # Discover tests in the default 'tests' folder + tests_folder_path = path.join(path.dirname(__file__), 'tests') + loader = unittest.TestLoader() + suite = loader.discover(start_dir=tests_folder_path, pattern='test*.py') + print_discovered_tests_summary(suite, full_listing=False) + + # unittest.main()# Run the discovered tests + runner = unittest.TextTestRunner(verbosity=2) + runner.run(suite) diff --git a/test/ps_test.py b/test/ps_test.py deleted file mode 100644 index 30cd9d1..0000000 --- a/test/ps_test.py +++ /dev/null @@ -1,30 +0,0 @@ -import sys, os - -# Path to where the bindings live -sys.path.append(os.path.join(os.path.dirname(__file__), "../build/")) -sys.path.append(os.path.join(os.path.dirname(__file__), "../src/")) - -import numpy as np -import polyscope as ps - - -ps.set_use_prefs_file(False) -ps.set_always_redraw(True) -ps.init() - - -np.random.seed(1) -points = np.random.rand(4, 3) -vals = np.random.rand(4, 3) - - -ps_cloud = ps.register_point_cloud('points', 5*points, enabled=True, radius=0.08) -ps_cloud.add_color_quantity("rand colors", vals, enabled=True) -ps.screenshot(filename='points_z.png') -ps.show() - -ps_cloud = ps.register_point_cloud('points', points, enabled=True, radius=0.08) -ps_cloud.add_color_quantity("rand colors", vals, enabled=True) -ps.reset_camera_to_home_view() -ps.screenshot(filename='points_y.png') -ps.show() diff --git a/test/fast_update_demo.py b/test/scripts/fast_update_demo.py similarity index 100% rename from test/fast_update_demo.py rename to test/scripts/fast_update_demo.py diff --git a/test/imgui_demo.py b/test/scripts/imgui_demo.py similarity index 100% rename from test/imgui_demo.py rename to test/scripts/imgui_demo.py diff --git a/test/polyscope_demo.py b/test/scripts/polyscope_demo.py similarity index 100% rename from test/polyscope_demo.py rename to test/scripts/polyscope_demo.py diff --git a/test/tests/test_all.py b/test/tests/test_all.py new file mode 100644 index 0000000..f0f61e7 --- /dev/null +++ b/test/tests/test_all.py @@ -0,0 +1,2548 @@ +import os +from os import listdir +import os.path as path +from os.path import isfile, join +import unittest + +import numpy as np + +import polyscope as ps +import polyscope.imgui as psim +import polyscope.implot as psimplot + +# Path to test assets +assets_prefix = path.join(path.dirname(__file__), "..", "assets") + +def assertArrayWithShape(self, arr, shape): + self.assertTrue(isinstance(arr, np.ndarray)) + self.assertEqual(tuple(arr.shape), tuple(shape)) + +class TestCore(unittest.TestCase): + + + def test_show(self): + ps.show(forFrames=3) + + def test_frame_tick(self): + for i in range(4): + ps.frame_tick() + + def test_frame_tick_imgui(self): + def callback(): + psim.Button("test button") + ps.set_user_callback(callback) + for i in range(4): + ps.frame_tick() + + def test_unshow(self): + counts = [0] + def callback(): + counts[0] = counts[0] + 1 + if(counts[0] > 2): + ps.unshow() + + ps.set_user_callback(callback) + ps.show(10) + + self.assertLess(counts[0], 4) + + + def test_options(self): + + # Remember, polyscope has global state, so we're actually setting these for the remainder of the tests (lol) + + ps.set_program_name("polyscope test prog") + ps.set_verbosity(2) + ps.set_print_prefix("[polyscope test] ") + ps.set_errors_throw_exceptions(True) + ps.set_max_fps(60) + ps.set_enable_vsync(True) + ps.set_use_prefs_file(False) + ps.set_do_default_mouse_interaction(True) + ps.set_always_redraw(False) + + self.assertTrue(ps.is_headless() in [True, False]) + ps.set_allow_headless_backends(True) + ps.set_egl_device_index(-1) + + ps.set_enable_render_error_checks(True) + ps.set_enable_render_error_checks(True) + ps.set_warn_for_invalid_values(True) + ps.set_warn_for_invalid_values(False) + ps.set_display_message_popups(False) + ps.set_autocenter_structures(False) + ps.set_autoscale_structures(False) + + ps.request_redraw() + self.assertTrue(ps.get_redraw_requested()) + ps.set_always_redraw(False) + ps.set_frame_tick_limit_fps_mode('ignore_limits') + ps.set_frame_tick_limit_fps_mode('block_to_hit_target') + ps.set_frame_tick_limit_fps_mode('skip_frames_to_hit_target') + + ps.set_ui_scale(0.8) + self.assertAlmostEqual(ps.get_ui_scale(), 0.8) + + ps.set_build_gui(True) + ps.set_render_scene(True) + ps.set_open_imgui_window_for_user_callback(True) + ps.set_invoke_user_callback_for_nested_show(False) + ps.set_give_focus_on_show(True) + + ps.set_background_color((0.7, 0.8, 0.9)) + ps.set_background_color((0.7, 0.8, 0.9, 0.9)) + ps.get_background_color() + + ps.get_final_scene_color_texture_native_handle() + + ps.show(3) + + # these makes tests run a little faster + ps.set_max_fps(-1) + ps.set_enable_vsync(False) + + def test_callbacks(self): + + # Simple callback function + # (we use 'counts' to ensure it gets called) + counts = [0] + def sample_callback(): + counts[0] = counts[0] + 1 + + ps.set_user_callback(sample_callback) + ps.show(3) + self.assertEqual(3, counts[0]) # Make sure the callback got called + ps.clear_user_callback() + ps.show(3) + 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): + + ps.set_navigation_style("turntable") + ps.set_navigation_style("free") + ps.set_navigation_style("planar") + ps.set_navigation_style("none") + ps.set_navigation_style("first_person") + ps.set_navigation_style(ps.get_navigation_style()) + + ps.set_up_dir("x_up") + ps.set_up_dir("neg_x_up") + ps.set_up_dir("y_up") + ps.set_up_dir("neg_y_up") + ps.set_up_dir("z_up") + ps.set_up_dir("neg_z_up") + ps.set_up_dir(ps.get_up_dir()) + + ps.set_front_dir("x_front") + ps.set_front_dir("neg_x_front") + ps.set_front_dir("y_front") + ps.set_front_dir("neg_y_front") + ps.set_front_dir("z_front") + ps.set_front_dir("neg_z_front") + ps.set_front_dir(ps.get_front_dir()) + + ps.set_vertical_fov_degrees(50.) + self.assertEqual(ps.get_vertical_fov_degrees(), 50.) + self.assertGreater(ps.get_aspect_ratio_width_over_height(), 0.01) + + ps.set_view_projection_mode("orthographic") + ps.set_view_projection_mode("perspective") + + ps.set_camera_view_matrix(ps.get_camera_view_matrix()) + + ps.set_view_center((0.1, 0.1, 0.2)) + ps.set_view_center(ps.get_view_center(), fly_to=True) + + ps.set_window_size(800, 600) + self.assertEqual(ps.get_window_size(), (800,600)) + + tup = ps.get_buffer_size() + w, h = int(tup[0]), int(tup[1]) + + ps.set_window_resizable(True) + self.assertEqual(ps.get_window_resizable(), True) + + ps.show(3) + + ps.set_up_dir("y_up") + + def test_camera_movement(self): + + ps.reset_camera_to_home_view() + + ps.look_at((0., 0., 5.), (1., 1., 1.)) + ps.look_at(np.array((0., 0., 5.)), (1., 1., 1.), fly_to=True) + + ps.look_at_dir((0., 0., 5.), (1., 1., 1.), (-1., -1., 0.)) + ps.look_at_dir((0., 0., 5.), (1., 1., 1.), np.array((-1., -1., 0.)), fly_to=True) + + ps.show(3) + + def test_view_json(self): + ps.set_view_from_json(ps.get_view_as_json()) + + def test_screen_coords(self): + io = psim.GetIO() + screen_coords = io.MousePos + world_ray = ps.screen_coords_to_world_ray(screen_coords) + world_pos = ps.screen_coords_to_world_position(screen_coords) + + def test_ground_options(self): + + ps.set_ground_plane_mode("none") + ps.set_ground_plane_mode("tile") + ps.set_ground_plane_mode("tile_reflection") + ps.set_ground_plane_mode("shadow_only") + + ps.set_ground_plane_height_factor(1.5, is_relative=False) + ps.set_ground_plane_height_factor(0.) + + ps.set_ground_plane_height(0.) + ps.set_ground_plane_height_mode('automatic') + ps.set_ground_plane_height_mode('manual') + + ps.set_shadow_blur_iters(3) + ps.set_shadow_darkness(0.1) + + ps.show(3) + + def test_transparency_options(self): + + ps.set_transparency_mode('none') + ps.set_transparency_mode('simple') + ps.set_transparency_mode('pretty') + + ps.set_transparency_render_passes(6) + + ps.show(3) + + ps.set_transparency_mode('none') + + def test_render_options(self): + + ps.set_SSAA_factor(2) + ps.show(3) + ps.set_SSAA_factor(1) + + def test_screenshot(self): + + ps.screenshot() + ps.screenshot(transparent_bg=False) + ps.screenshot(include_UI=True) + ps.screenshot("test_shot.png", transparent_bg=True) + + ps.set_screenshot_extension(".jpg") + ps.set_screenshot_extension(".png") + + buff = ps.screenshot_to_buffer(False) + w, h = ps.get_buffer_size() + self.assertEqual(buff.shape, (h,w,4)) + + buff = ps.screenshot_to_buffer(False, include_UI=True) + + ps.show(3) + + # Delete the files which are created + try: + os.remove("screenshot_000000.png") + os.remove("screenshot_000001.png") + os.remove("screenshot_000002.png") + os.remove("test_shot.png") + except: + pass + + + def test_picking(self): + + res = ps.pick(buffer_inds=(77,88)) + res = ps.pick(screen_coords=(0.78,.96)) + + ps.show(3) + + def test_slice_plane(self): + + # Test deprecated add_scene_slice_plane() function + plane1 = ps.add_scene_slice_plane() + plane2 = ps.add_scene_slice_plane() + + # Test set_enabled / get_enabled + plane2.set_enabled(True) + self.assertEqual(True, plane2.get_enabled()) + plane2.set_enabled(False) + self.assertEqual(False, plane2.get_enabled()) + + # Test set_pose with tuple + plane1.set_pose((-.5, 0., 0.), (1., 1., 1.)) + + # Test set_active / get_active + plane1.set_active(False) + self.assertEqual(False, plane1.get_active()) + plane1.set_active(True) + self.assertEqual(True, plane1.get_active()) + + # Test set_draw_plane / get_draw_plane + plane1.set_draw_plane(False) + self.assertEqual(False, plane1.get_draw_plane()) + plane1.set_draw_plane(True) + self.assertEqual(True, plane1.get_draw_plane()) + + # Test set_draw_widget / get_draw_widget + plane1.set_draw_widget(False) + self.assertEqual(False, plane1.get_draw_widget()) + plane1.set_draw_widget(True) + self.assertEqual(True, plane1.get_draw_widget()) + + ps.show(3) + + ps.remove_last_scene_slice_plane() + ps.remove_last_scene_slice_plane() + + # add with custom names + plane3 = ps.add_slice_plane("custom_plane_1") + self.assertEqual(plane3.get_name(), "custom_plane_1") + + plane4 = ps.add_slice_plane("custom_plane_2") + self.assertEqual(plane4.get_name(), "custom_plane_2") + + # Test get_slice_plane + retrieved_plane = ps.get_slice_plane("custom_plane_1") + self.assertEqual(retrieved_plane.get_name(), "custom_plane_1") + + # Test set_color / get_color + plane3.set_color((0.5, 0.6, 0.7)) + color = plane3.get_color() + for i in range(3): + self.assertAlmostEqual(color[i], [0.5, 0.6, 0.7][i], places=5) + + # Test set_grid_line_color / get_grid_line_color + plane3.set_grid_line_color((0.1, 0.2, 0.3)) + grid_color = plane3.get_grid_line_color() + for i in range(3): + self.assertAlmostEqual(grid_color[i], [0.1, 0.2, 0.3][i], places=5) + + # Test set_transparency / get_transparency + plane3.set_transparency(0.5) + self.assertAlmostEqual(0.5, plane3.get_transparency()) + plane3.set_transparency(0.0) + self.assertAlmostEqual(0.0, plane3.get_transparency()) + plane3.set_transparency(1.0) + self.assertAlmostEqual(1.0, plane3.get_transparency()) + + # Test set_pose with numpy array + plane4.set_pose(np.array([0.5, 0.5, 0.5]), np.array([0.0, 0.0, 1.0])) + + # Test get_center and get_normal + center = plane4.get_center() + self.assertIsNotNone(center) + self.assertEqual(len(center), 3) + + normal = plane4.get_normal() + self.assertIsNotNone(normal) + self.assertEqual(len(normal), 3) + + ps.show(3) + + # Test remove_slice_plane + ps.remove_slice_plane("custom_plane_1") + + # Test plane.remove() method + plane4.remove() + + # Test remove_all_slice_planes + ps.add_slice_plane("test1") + ps.add_slice_plane("test2") + ps.remove_all_slice_planes() + + def test_transformation_gizmo(self): + + # Create a gizmo + g1 = ps.add_transformation_gizmo("gizmo_1") + self.assertEqual(g1.get_name(), "gizmo_1") + + # Enable/disable + g1.set_enabled(True) + self.assertEqual(True, g1.get_enabled()) + g1.set_enabled(False) + self.assertEqual(False, g1.get_enabled()) + + # Set/get transform + T_I = np.eye(4) + g1.set_transform(T_I) + T_ret = g1.get_transform() + self.assertTrue(isinstance(T_ret, np.ndarray)) + self.assertEqual(T_ret.shape, (4,4)) + self.assertTrue(np.allclose(T_ret, T_I)) + + T2 = np.array([ + [1., 0., 0., 3.], + [0., 0., -1., -2.], + [0., 1., 0., 5.], + [0., 0., 0., 1.] + ]) + g1.set_transform(T2) + self.assertTrue(np.allclose(g1.get_transform(), T2)) + + # Get/set position + g1.set_position(np.array((1.0, 2.0, 3.0))) + self.assertTrue(np.allclose(g1.get_position(), np.array((1.0, 2.0, 3.0)))) + + # Allow toggles + g1.set_allow_translation(True) + self.assertEqual(True, g1.get_allow_translation()) + g1.set_allow_translation(False) + self.assertEqual(False, g1.get_allow_translation()) + + g1.set_allow_rotation(True) + self.assertEqual(True, g1.get_allow_rotation()) + g1.set_allow_rotation(False) + self.assertEqual(False, g1.get_allow_rotation()) + + g1.set_allow_scaling(True) + self.assertEqual(True, g1.get_allow_scaling()) + g1.set_allow_scaling(False) + self.assertEqual(False, g1.get_allow_scaling()) + + g1.set_allow_nonuniform_scaling(True) + self.assertEqual(True, g1.get_allow_nonuniform_scaling()) + g1.set_allow_nonuniform_scaling(False) + self.assertEqual(False, g1.get_allow_nonuniform_scaling()) + + # Local-space interaction toggle + g1.set_interact_in_local_space(True) + self.assertEqual(True, g1.get_interact_in_local_space()) + g1.set_interact_in_local_space(False) + self.assertEqual(False, g1.get_interact_in_local_space()) + + # Gizmo size (scale) getter/setter + g1.set_gizmo_scale(0.75) + self.assertAlmostEqual(0.75, g1.get_gizmo_scale()) + + # Retrieve by name + g1b = ps.get_transformation_gizmo("gizmo_1") + self.assertEqual(g1b.get_name(), "gizmo_1") + + ps.show(3) + + # Remove by name + ps.remove_transformation_gizmo("gizmo_1") + + # Create another and remove via instance method + g2 = ps.add_transformation_gizmo("gizmo_2") + self.assertEqual(g2.get_name(), "gizmo_2") + g2.remove() + + # Add with auto-naming + ps.add_transformation_gizmo() + ps.add_transformation_gizmo() + + # Add a couple and clear all + ps.add_transformation_gizmo("gizmo_B") + ps.remove_all_transformation_gizmos() + + # Get the reference for a structure + pt_cloud_0 = ps.register_point_cloud("cloud0", np.zeros((10,3))) + gizmo = pt_cloud_0.get_transformation_gizmo() + self.assertIsInstance(gizmo, ps.TransformationGizmo) + gizmo.set_allow_rotation(False) + ps.remove_all_structures() + + def test_load_material(self): + + ps.load_static_material("test_static", path.join(assets_prefix, "testwax_b.jpg")) + ps.load_blendable_material("test_blend1", filenames=( + path.join(assets_prefix, "testwax_r.jpg"), + path.join(assets_prefix, "testwax_b.jpg"), + path.join(assets_prefix, "testwax_g.jpg"), + path.join(assets_prefix, "testwax_k.jpg") + )) + + ps.load_blendable_material("test_blend2", + filename_base=path.join(assets_prefix, "testwax"), + filename_ext=".jpg") + + def test_load_cmap(self): + ps.load_color_map("test_cmap", path.join(assets_prefix, "test_colormap.png")) + + + def test_scene_extents(self): + + ps.set_automatically_compute_scene_extents(False) + + ps.set_length_scale(3.) + self.assertAlmostEqual(ps.get_length_scale(), 3.) + + low = np.array((-1, -2., -3.)) + high = np.array((1., 2., 3.)) + ps.set_bounding_box(low, high) + plow, phigh = ps.get_bounding_box() + self.assertTrue(np.abs(plow-low).sum() < 0.0001) + self.assertTrue(np.abs(phigh-high).sum() < 0.0001) + + ps.set_automatically_compute_scene_extents(True) + + + def test_groups(self): + + pts = np.zeros((10,3)) + pt_cloud_0 = ps.register_point_cloud("cloud0", pts) + pt_cloud_1 = ps.register_point_cloud("cloud1", pts) + pt_cloud_2 = ps.register_point_cloud("cloud2", pts) + + groupA = ps.create_group("group_A") + groupB = ps.create_group("group_B") + groupC = ps.create_group("group_C") + + groupA.add_child_group(groupB) + groupA.add_child_group("group_C") + self.assertTrue(set(groupA.get_child_group_names()) == set(["group_B", "group_C"])) + + pt_cloud_0.add_to_group(groupA) + pt_cloud_1.add_to_group("group_A") + groupA.add_child_structure(pt_cloud_2) + self.assertTrue(set(groupA.get_child_structure_names()) == set(["cloud0", "cloud1", "cloud2"])) + + groupA.set_enabled(False) + groupB.set_show_child_details(True) + groupC.set_hide_descendants_from_structure_lists(True) + + ps.show(3) + + groupA.remove_child_group(groupB) + groupA.remove_child_group("group_C") + groupA.remove_child_structure(pt_cloud_0) + + ps.remove_group(groupB, True) + ps.remove_group("group_C", False) + + ps.show(3) + + ps.remove_all_groups() + + ps.remove_all_structures() + + + def test_groups_demo_example(self): + + # make a point cloud + pts = np.zeros((300,3)) + psCloud = ps.register_point_cloud("my cloud", pts) + + # make a curve network + nodes = np.zeros((4,3)) + edges = np.array([[1, 3], [3, 0], [1, 0], [0, 2]]) + psCurve = ps.register_curve_network("my network", nodes, edges) + + # create a group for these two objects + group = ps.create_group("my group") + psCurve.add_to_group(group) # you also say psCurve.add_to_group("my group") + psCloud.add_to_group(group) + + # toggle the enabled state for everything in the group + group.set_enabled(False) + + # hide items in group from displaying in the UI + # (useful if you are registering huge numbers of structures you don't always need to see) + group.set_hide_descendants_from_structure_lists(True) + group.set_show_child_details(False) + + # nest groups inside of other groups + super_group = ps.create_group("py parent group") + super_group.add_child_group(group) + + ps.show(3) + + ps.remove_all_groups() + ps.remove_all_structures() + + def test_ui_advanced_custom_build(self): + + def manual_build_callback(): + ps.build_polyscope_gui() + ps.build_structure_gui() + ps.build_pick_gui() + + + # disable the standard function + ps.set_build_gui(False) + ps.set_user_callback(manual_build_callback) + ps.show(3) # smoke test + + # unset + ps.set_user_callback(None) + ps.set_build_gui(True) + + +class TestStructureManagement(unittest.TestCase): + + def test_remove_all(self): + pass + +def test_transforms(t,s): + + T = np.array([ + [1., 0., 0., 3.], + [0., 0., -1., -2.], + [0., 1., 0., 5.], + [0., 0., 0., 1.] + ]) + v = np.array([1., 2., 3.]) + + s.get_transform() + s.get_position() + s.center_bounding_box() + s.rescale_to_unit() + + s.reset_transform() + t.assertTrue(np.abs(s.get_transform()-np.eye(4)).sum() < 1e-4) + t.assertTrue(np.abs(s.get_position()).sum() < 1e-4) + + s.set_transform(T) + t.assertTrue(np.abs(s.get_transform()-T).sum() < 1e-4) + + s.reset_transform() + s.set_position(v) + t.assertTrue(np.abs(s.get_position()-v).sum() < 1e-4) + + s.translate(v) + t.assertTrue(np.abs(s.get_position()-2.*v).sum() < 1e-4) + + s.set_transform_gizmo_enabled(True) + t.assertTrue(s.get_transform_gizmo_enabled()) + s.set_transform_gizmo_enabled(False) + + +class TestPointCloud(unittest.TestCase): + + def generate_points(self, n_pts=10): + np.random.seed(777) + return np.random.rand(n_pts, 3) + + def test_add_remove(self): + + # add + p = ps.register_point_cloud("test_cloud", self.generate_points()) + self.assertTrue(ps.has_point_cloud("test_cloud")) + self.assertFalse(ps.has_point_cloud("nope")) + self.assertEqual(p.n_points(), 10) + + # remove by name + ps.register_point_cloud("test_cloud2", self.generate_points()) + ps.remove_point_cloud("test_cloud2") + self.assertTrue(ps.has_point_cloud("test_cloud")) + self.assertFalse(ps.has_point_cloud("test_cloud2")) + + # remove by ref + c = ps.register_point_cloud("test_cloud2", self.generate_points()) + c.remove() + self.assertTrue(ps.has_point_cloud("test_cloud")) + self.assertFalse(ps.has_point_cloud("test_cloud2")) + + # get by name + ps.register_point_cloud("test_cloud3", self.generate_points(n_pts=10)) + p = ps.get_point_cloud("test_cloud3") # should be wrapped instance, not underlying PSB instance + self.assertTrue(isinstance(p, ps.PointCloud)) + + ps.remove_all_structures() + + def test_render(self): + + ps.register_point_cloud("test_cloud", self.generate_points()) + ps.show(3) + ps.remove_all_structures() + + def test_options(self): + + p = ps.register_point_cloud("test_cloud", self.generate_points()) + + # Set enabled + p.set_enabled() + p.set_enabled(False) + p.set_enabled(True) + self.assertTrue(p.is_enabled()) + + # Radius + p.set_radius(0.01) + p.set_radius(0.1, relative=False) + self.assertAlmostEqual(0.1, p.get_radius()) + + # Render mode + p.set_point_render_mode("sphere") + self.assertEqual("sphere", p.get_point_render_mode()) + p.set_point_render_mode("quad") + self.assertEqual("quad", p.get_point_render_mode()) + + # Color + color = (0.3, 0.3, 0.5) + p.set_color(color) + ret_color = p.get_color() + for i in range(3): + self.assertAlmostEqual(ret_color[i], color[i]) + + # Material + p.set_material("candy") + self.assertEqual("candy", p.get_material()) + p.set_material("clay") + + # Transparency + p.set_transparency(0.8) + self.assertAlmostEqual(0.8, p.get_transparency()) + + p2 = ps.register_point_cloud("test_cloud2", self.generate_points(), + enabled=True, material='wax', radius=0.03, color=(1., 0., 0.), transparency=0.7) + + + ps.show(3) + ps.remove_all_structures() + ps.set_transparency_mode('none') + + def test_transform(self): + + ps_cloud = ps.register_point_cloud("test_cloud", self.generate_points()) + test_transforms(self,ps_cloud) + ps.remove_all_structures() + + def test_update(self): + + p = ps.register_point_cloud("test_cloud", self.generate_points()) + ps.show(3) + + newPos = self.generate_points() - 0.5 + p.update_point_positions(newPos) + + ps.show(3) + ps.remove_all_structures() + + + def test_2D(self): + np.random.seed(777) + points2D = np.random.rand(12, 2) + + p = ps.register_point_cloud("test_cloud", points2D) + ps.show(3) + + newPos = points2D - 0.5 + p.update_point_positions(newPos) + + ps.show(3) + ps.remove_all_structures() + + def test_transparent_rendering(self): + + p = ps.register_point_cloud("test_cloud", self.generate_points(), + transparency=0.5) + + ps.set_transparency_mode('none') + ps.show(3) + ps.set_transparency_mode('simple') + ps.show(3) + ps.set_transparency_mode('pretty') + ps.show(3) + + ps.set_transparency_mode('none') + ps.remove_all_structures() + + def test_slice_plane(self): + + p = ps.register_point_cloud("test_cloud", self.generate_points()) + + + + plane = ps.add_scene_slice_plane() + p.set_cull_whole_elements(True) + ps.show(3) + p.set_cull_whole_elements(False) + ps.show(3) + + p.set_ignore_slice_plane(plane, True) + self.assertEqual(True, p.get_ignore_slice_plane(plane)) + p.set_ignore_slice_plane(plane.get_name(), False) + self.assertEqual(False, p.get_ignore_slice_plane(plane.get_name())) + + ps.remove_all_structures() + ps.remove_last_scene_slice_plane() + + def test_scalar(self): + pts = self.generate_points() + N = pts.shape[0] + ps.register_point_cloud("test_cloud", pts) + p = ps.get_point_cloud("test_cloud") + vals = np.random.rand(N) + + p.add_scalar_quantity("test_vals", vals) + p.add_scalar_quantity("test_vals", vals, enabled=True) + p.add_scalar_quantity("test_vals_with_range", vals, vminmax=(-5., 5.), enabled=True) + p.add_scalar_quantity("test_vals_with_datatype", vals, enabled=True, datatype='symmetric') + p.add_scalar_quantity("test_vals_with_categorical", vals, enabled=True, datatype='categorical') + p.add_scalar_quantity("test_vals_with_cmap", vals, enabled=True, cmap='blues') + p.add_scalar_quantity("test_vals_with_cmap_onscreen_colorbar", vals, enabled=True, cmap='blues', onscreen_colorbar_enabled=True, onscreen_colorbar_location=(400., 400.)) + p.add_scalar_quantity("test_vals_with_iso", vals, enabled=True, cmap='blues', + isolines_enabled=True, isoline_width=0.1, isoline_darkness=0.5) + p.add_scalar_quantity("test_vals_with_iso_rel", vals, enabled=True, cmap='blues', + isolines_enabled=True, isoline_width=0.1, isoline_width_relative=True, isoline_darkness=0.5) + ps.show(3) + + # test some additions/removal while we're at it + p.remove_quantity("test_vals") + p.remove_quantity("not_here") # should not error + p.remove_all_quantities() + p.remove_all_quantities() + ps.remove_all_structures() + + def test_color(self): + pts = self.generate_points() + N = pts.shape[0] + p = ps.register_point_cloud("test_cloud", pts) + vals = np.random.rand(N,3) + + p.add_color_quantity("test_vals", vals) + p.add_color_quantity("test_vals", vals, enabled=True) + ps.show(3) + + p.remove_all_quantities() + ps.remove_all_structures() + + def test_vector(self): + pts = self.generate_points() + N = pts.shape[0] + p = ps.register_point_cloud("test_cloud", pts) + vals = np.random.rand(N,3) + + p.add_vector_quantity("test_vals1", vals) + p.add_vector_quantity("test_vals2", vals, enabled=True) + p.add_vector_quantity("test_vals3", vals, enabled=True, vectortype='ambient') + p.add_vector_quantity("test_vals4", vals, enabled=True, length=0.005) + p.add_vector_quantity("test_vals5", vals, enabled=True, radius=0.001) + p.add_vector_quantity("test_vals6", vals, enabled=True, color=(0.2, 0.5, 0.5)) + + # 2D + p.add_vector_quantity("test_vals7", vals[:,:2], enabled=True, radius=0.001) + + ps.show(3) + + p.remove_all_quantities() + ps.remove_all_structures() + + def test_parameterization(self): + + pts = self.generate_points() + N = pts.shape[0] + p = ps.register_point_cloud("test_cloud", pts) + vals = np.random.rand(N,2) + + + cA = (0.1, 0.2, 0.3) + cB = (0.4, 0.5, 0.6) + + p.add_parameterization_quantity("test_vals1", vals, enabled=True) + + p.add_parameterization_quantity("test_vals2", vals, coords_type='world') + p.add_parameterization_quantity("test_vals3", vals, coords_type='unit') + + p.add_parameterization_quantity("test_vals4", vals, viz_style='checker') + p.add_parameterization_quantity("test_vals5", vals, viz_style='grid') + p.add_parameterization_quantity("test_vals6", vals, viz_style='local_check') + p.add_parameterization_quantity("test_vals7", vals, viz_style='local_rad') + + p.add_parameterization_quantity("test_vals8", vals, grid_colors=(cA, cB)) + p.add_parameterization_quantity("test_vals9", vals, checker_colors=(cA, cB)) + p.add_parameterization_quantity("test_vals10", vals, checker_size=0.1) + p.add_parameterization_quantity("test_vals11", vals, cmap='blues') + + ps.show(3) + + p.remove_all_quantities() + + + def test_variable_radius(self): + pts = self.generate_points() + N = pts.shape[0] + ps.register_point_cloud("test_cloud", pts) + p = ps.get_point_cloud("test_cloud") + vals = np.random.rand(N) + + p.add_scalar_quantity("test_vals", vals) + + p.set_point_radius_quantity("test_vals") + ps.show(3) + p.clear_point_radius_quantity() + ps.show(3) + p.set_point_radius_quantity("test_vals", False) + ps.show(3) + + ps.remove_all_structures() + + + def test_scalar_transparency(self): + pts = self.generate_points() + N = pts.shape[0] + ps.register_point_cloud("test_cloud", pts) + p = ps.get_point_cloud("test_cloud") + vals = np.random.rand(N) + + p.add_scalar_quantity("test_vals", vals) + + p.set_transparency_quantity("test_vals") + ps.show(3) + p.clear_transparency_quantity() + ps.show(3) + + ps.remove_all_structures() + +class TestCurveNetwork(unittest.TestCase): + + def generate_points(self, n_pts=10): + np.random.seed(777) + return np.random.rand(n_pts, 3) + + def generate_edges(self, n_pts=10): + np.random.seed(777) + return np.random.randint(0, n_pts, size=(2*n_pts,2)) + + def test_add_remove(self): + + # add + n = ps.register_curve_network("test_network", self.generate_points(), self.generate_edges()) + self.assertTrue(ps.has_curve_network("test_network")) + self.assertFalse(ps.has_curve_network("nope")) + self.assertEqual(n.n_nodes(), 10) + self.assertEqual(n.n_edges(), 20) + + # remove by name + ps.register_curve_network("test_network2", self.generate_points(), self.generate_edges()) + ps.remove_curve_network("test_network2") + self.assertTrue(ps.has_curve_network("test_network")) + self.assertFalse(ps.has_curve_network("test_network2")) + + # remove by ref + c = ps.register_curve_network("test_network2", self.generate_points(), self.generate_edges()) + c.remove() + self.assertTrue(ps.has_curve_network("test_network")) + self.assertFalse(ps.has_curve_network("test_network2")) + + # get by name + ps.register_curve_network("test_network3", self.generate_points(), self.generate_edges()) + p = ps.get_curve_network("test_network3") # should be wrapped instance, not underlying PSB instance + self.assertTrue(isinstance(p, ps.CurveNetwork)) + + ps.remove_all_structures() + + def test_convenience_add(self): + ps.register_curve_network("test_network_line", self.generate_points(), 'line') + ps.register_curve_network("test_network_line2D", self.generate_points()[:,:2], 'line') + ps.register_curve_network("test_network_loop", self.generate_points(), 'loop') + ps.register_curve_network("test_network_loop2D", self.generate_points()[:,:2], 'loop') + ps.register_curve_network("test_network_line", self.generate_points(), 'segments') + ps.register_curve_network("test_network_line2D", self.generate_points()[:,:2], 'segments') + + ps.show(3) + ps.remove_all_structures(); + + def test_render(self): + + ps.register_curve_network("test_network", self.generate_points(), self.generate_edges()) + ps.show(3) + ps.remove_all_structures() + + def test_options(self): + + p = ps.register_curve_network("test_network", self.generate_points(), self.generate_edges()) + + # Set enabled + p.set_enabled() + p.set_enabled(False) + p.set_enabled(True) + self.assertTrue(p.is_enabled()) + + # Radius + p.set_radius(0.01) + p.set_radius(0.1, relative=False) + self.assertAlmostEqual(0.1, p.get_radius()) + + # Color + color = (0.3, 0.3, 0.5) + p.set_color(color) + ret_color = p.get_color() + for i in range(3): + self.assertAlmostEqual(ret_color[i], color[i]) + + # Material + p.set_material("candy") + self.assertEqual("candy", p.get_material()) + p.set_material("clay") + + # Transparency + p.set_transparency(0.8) + self.assertAlmostEqual(0.8, p.get_transparency()) + + p2 = ps.register_curve_network("test_network2", self.generate_points(), self.generate_edges(), + enabled=False, material='wax', radius=0.03, color=(1., 0., 0.), transparency=0.9) + + ps.show(3) + ps.remove_all_structures() + ps.set_transparency_mode('none') + + def test_variable_render(self): + + p = ps.register_curve_network("test_network", self.generate_points(), self.generate_edges()) + + p.add_scalar_quantity("test_vals_nodes", np.random.rand(p.n_nodes()), defined_on='nodes') + p.add_scalar_quantity("test_vals_edges", np.random.rand(p.n_edges()), defined_on='edges', enabled=True) + + # node only + p.set_node_radius_quantity('test_vals_nodes') + ps.show(3) + p.set_node_radius_quantity('test_vals_nodes', autoscale=False) + ps.show(3) + p.clear_node_radius_quantity() + + # edge only + p.set_edge_radius_quantity('test_vals_edges') + ps.show(3) + p.set_edge_radius_quantity('test_vals_edges', autoscale=False) + ps.show(3) + p.clear_edge_radius_quantity() + + # both + p.set_node_radius_quantity('test_vals_nodes') + p.set_edge_radius_quantity('test_vals_edges') + ps.show(3) + p.clear_edge_radius_quantity() + + ps.remove_all_structures() + + def test_transform(self): + + p = ps.register_curve_network("test_network", self.generate_points(), self.generate_edges()) + test_transforms(self,p) + ps.remove_all_structures() + + def test_slice_plane(self): + + p = ps.register_curve_network("test_network", self.generate_points(), self.generate_edges()) + + plane = ps.add_scene_slice_plane() + p.set_cull_whole_elements(True) + ps.show(3) + p.set_cull_whole_elements(False) + ps.show(3) + + p.set_ignore_slice_plane(plane, True) + self.assertEqual(True, p.get_ignore_slice_plane(plane)) + p.set_ignore_slice_plane(plane.get_name(), False) + self.assertEqual(False, p.get_ignore_slice_plane(plane.get_name())) + + ps.remove_all_structures() + ps.remove_last_scene_slice_plane() + + + def test_update(self): + + p = ps.register_curve_network("test_network", self.generate_points(), self.generate_edges()) + ps.show(3) + + newPos = self.generate_points() - 0.5 + p.update_node_positions(newPos) + + ps.show(3) + ps.remove_all_structures() + + def test_2D(self): + np.random.seed(777) + points2D = np.random.rand(10, 2) + + p = ps.register_curve_network("test_network", points2D, self.generate_edges()) + ps.show(3) + + newPos = points2D - 0.5 + p.update_node_positions(newPos) + + ps.show(3) + ps.remove_all_structures() + + def test_scalar(self): + pts = self.generate_points() + N = pts.shape[0] + ps.register_curve_network("test_network", pts, self.generate_edges()) + p = ps.get_curve_network("test_network") + + for on in ['nodes', 'edges']: + + if on == 'nodes': + vals = np.random.rand(N) + elif on == 'edges': + vals = np.random.rand(2*N) + + p.add_scalar_quantity("test_vals", vals, defined_on=on) + p.add_scalar_quantity("test_vals2", vals, defined_on=on, enabled=True) + p.add_scalar_quantity("test_vals_with_range", vals, defined_on=on, vminmax=(-5., 5.), enabled=True) + p.add_scalar_quantity("test_vals_with_datatype", vals, defined_on=on, enabled=True, datatype='symmetric') + p.add_scalar_quantity("test_vals_with_cmap", vals, defined_on=on, enabled=True, cmap='blues') + p.add_scalar_quantity("test_vals_with_iso", vals, defined_on=on, enabled=True, cmap='blues', + isolines_enabled=True, isoline_width=0.1, isoline_darkness=0.5) + + ps.show(3) + + # test some additions/removal while we're at it + p.remove_quantity("test_vals") + p.remove_quantity("not_here") # should not error + p.remove_all_quantities() + p.remove_all_quantities() + + ps.remove_all_structures() + + def test_color(self): + pts = self.generate_points() + N = pts.shape[0] + p = ps.register_curve_network("test_network", pts, self.generate_edges()) + + for on in ['nodes', 'edges']: + + if on == 'nodes': + vals = np.random.rand(N,3) + elif on == 'edges': + vals = np.random.rand(2*N, 3) + + p.add_color_quantity("test_vals", vals, defined_on=on) + p.add_color_quantity("test_vals", vals, defined_on=on, enabled=True) + + ps.show(3) + p.remove_all_quantities() + + ps.remove_all_structures() + + def test_vector(self): + pts = self.generate_points() + N = pts.shape[0] + p = ps.register_curve_network("test_network", pts, self.generate_edges()) + vals = np.random.rand(N,3) + + for on in ['nodes', 'edges']: + + if on == 'nodes': + vals = np.random.rand(N,3) + elif on == 'edges': + vals = np.random.rand(2*N, 3) + + p.add_vector_quantity("test_vals1", vals, defined_on=on) + p.add_vector_quantity("test_vals2", vals, defined_on=on, enabled=True) + p.add_vector_quantity("test_vals3", vals, defined_on=on, enabled=True, vectortype='ambient') + p.add_vector_quantity("test_vals4", vals, defined_on=on, enabled=True, length=0.005) + p.add_vector_quantity("test_vals5", vals, defined_on=on, enabled=True, radius=0.001) + p.add_vector_quantity("test_vals6", vals, defined_on=on, enabled=True, color=(0.2, 0.5, 0.5)) + + # 2D + p.add_vector_quantity("test_vals7", vals[:,:2], defined_on=on, enabled=True, radius=0.001) + + ps.show(3) + p.remove_all_quantities() + + ps.remove_all_structures() + + +class TestSurfaceMesh(unittest.TestCase): + + def generate_verts(self, n_pts=10): + np.random.seed(777) + return np.random.rand(n_pts, 3) + + def generate_faces(self, n_pts=10): + np.random.seed(777) + return np.random.randint(0, n_pts, size=(2*n_pts,3)) + + def test_add_remove(self): + + # add + n = ps.register_surface_mesh("test_mesh", self.generate_verts(), self.generate_faces()) + self.assertTrue(ps.has_surface_mesh("test_mesh")) + self.assertFalse(ps.has_surface_mesh("nope")) + self.assertEqual(n.n_vertices(), 10) + self.assertEqual(n.n_faces(), 20) + self.assertGreater(n.n_edges(), 1) + self.assertEqual(n.n_corners(), 3*20) + self.assertEqual(n.n_halfedges(), 3*20) + + # remove by name + ps.register_surface_mesh("test_mesh2", self.generate_verts(), self.generate_faces()) + ps.remove_surface_mesh("test_mesh2") + self.assertTrue(ps.has_surface_mesh("test_mesh")) + self.assertFalse(ps.has_surface_mesh("test_mesh2")) + + # remove by ref + c = ps.register_surface_mesh("test_mesh2", self.generate_verts(), self.generate_faces()) + c.remove() + self.assertTrue(ps.has_surface_mesh("test_mesh")) + self.assertFalse(ps.has_surface_mesh("test_mesh2")) + + # get by name + ps.register_surface_mesh("test_mesh3", self.generate_verts(), self.generate_faces()) + p = ps.get_surface_mesh("test_mesh3") # should be wrapped instance, not underlying PSB instance + self.assertTrue(isinstance(p, ps.SurfaceMesh)) + + ps.remove_all_structures() + + + def test_add_quad(self): + + n_pts=10 + faces = np.random.randint(0, n_pts, size=(2*n_pts,4)) + ps.register_surface_mesh("test_mesh", self.generate_verts(), faces) + ps.show(3) + ps.remove_all_structures() + + def test_add_varied_degree(self): + + n_pts = 10 + n_face = 20 + faces = [] + for i in range(n_face): + faces.append([0,1,2,]) + faces.append([0,1,2,4]) + faces.append([0,1,2,4,5]) + + ps.register_surface_mesh("test_mesh", self.generate_verts(), faces) + ps.show(3) + ps.remove_all_structures() + + def test_render(self): + + ps.register_surface_mesh("test_mesh", self.generate_verts(), self.generate_faces()) + ps.show(3) + ps.remove_all_structures() + + + def test_options(self): + + p = ps.register_surface_mesh("test_mesh", self.generate_verts(), self.generate_faces()) + + # Set enabled + p.set_enabled() + p.set_enabled(False) + p.set_enabled(True) + self.assertTrue(p.is_enabled()) + + # Color + color = (0.3, 0.3, 0.5) + p.set_color(color) + ret_color = p.get_color() + for i in range(3): + self.assertAlmostEqual(ret_color[i], color[i]) + + # Edge color + color = (0.1, 0.5, 0.5) + p.set_edge_color(color) + ret_color = p.get_edge_color() + for i in range(3): + self.assertAlmostEqual(ret_color[i], color[i]) + + ps.show(3) + + # Smooth shade + p.set_smooth_shade(True) + ps.show(3) + self.assertTrue(p.get_smooth_shade()) + p.set_smooth_shade(False) + ps.show(3) + + # Edge width + p.set_edge_width(1.5) + ps.show(3) + self.assertAlmostEqual(p.get_edge_width(), 1.5) + + # Selection mode + p.set_selection_mode('auto') + p.set_selection_mode('vertices_only') + p.set_selection_mode('faces_only') + ps.show(3) + + # Material + p.set_material("candy") + self.assertEqual("candy", p.get_material()) + p.set_material("clay") + + # Back face + p.set_back_face_policy("different") + self.assertEqual("different", p.get_back_face_policy()) + p.set_back_face_policy("custom") + self.assertEqual("custom", p.get_back_face_policy()) + p.set_back_face_color((0.25, 0.25, 0.25)) + self.assertEqual((0.25, 0.25, 0.25), p.get_back_face_color()) + p.set_back_face_policy("cull") + + # Transparency + p.set_transparency(0.8) + self.assertAlmostEqual(0.8, p.get_transparency()) + + # Mark elements as used + # p.set_corner_permutation(np.random.permutation(p.n_corners())) # not required + p.mark_corners_as_used() + p.set_edge_permutation(np.random.permutation(p.n_edges())) + p.mark_edges_as_used() + p.set_halfedge_permutation(np.random.permutation(p.n_halfedges())) + p.mark_halfedges_as_used() + + + # Set with optional arguments + p2 = ps.register_surface_mesh("test_mesh", self.generate_verts(), self.generate_faces(), + enabled=True, material='wax', color=(1., 0., 0.), edge_color=(0.5, 0.5, 0.5), + smooth_shade=True, edge_width=0.5, back_face_policy="cull", back_face_color=(0.1, 0.1, 0.1), transparency=0.9) + + # Make sure shadows work + ps.set_ground_plane_mode("shadow_only") + + ps.show(3) + ps.remove_all_structures() + ps.set_transparency_mode('none') + + def test_transform(self): + + p = ps.register_surface_mesh("test_mesh", self.generate_verts(), self.generate_faces()) + test_transforms(self,p) + ps.remove_all_structures() + + def test_slice_plane(self): + + p = ps.register_surface_mesh("test_mesh", self.generate_verts(), self.generate_faces()) + + plane = ps.add_scene_slice_plane() + p.set_cull_whole_elements(True) + ps.show(3) + p.set_cull_whole_elements(False) + ps.show(3) + + p.set_ignore_slice_plane(plane, True) + self.assertEqual(True, p.get_ignore_slice_plane(plane)) + p.set_ignore_slice_plane(plane.get_name(), False) + self.assertEqual(False, p.get_ignore_slice_plane(plane.get_name())) + + ps.remove_all_structures() + ps.remove_last_scene_slice_plane() + + def test_update(self): + + p = ps.register_surface_mesh("test_mesh", self.generate_verts(), self.generate_faces()) + ps.show(3) + + newPos = self.generate_verts() - 0.5 + p.update_vertex_positions(newPos) + + ps.show(3) + ps.remove_all_structures() + + def test_2D(self): + np.random.seed(777) + points2D = self.generate_verts()[:,:2] + + p = ps.register_surface_mesh("test_mesh", points2D, self.generate_faces()) + ps.show(3) + + newPos = points2D - 0.5 + p.update_vertex_positions(newPos) + + ps.show(3) + ps.remove_all_structures() + + + def test_permutation(self): + + p = ps.register_surface_mesh("test_mesh", self.generate_verts(), self.generate_faces()) + + p.set_edge_permutation(np.random.permutation(p.n_edges())) + + p.set_corner_permutation(np.random.permutation(p.n_corners())) + + p.set_halfedge_permutation(np.random.permutation(p.n_halfedges())) + + p = ps.register_surface_mesh("test_mesh2", self.generate_verts(), self.generate_faces()) + + p.set_all_permutations( + edge_perm=np.random.permutation(p.n_edges()), + corner_perm=np.random.permutation(p.n_corners()), + halfedge_perm=np.random.permutation(p.n_halfedges()), + ) + + ps.show(3) + ps.remove_all_structures() + + def test_permutation_with_size(self): + + p = ps.register_surface_mesh("test_mesh", self.generate_verts(), self.generate_faces()) + + p.set_edge_permutation(np.random.permutation(p.n_edges()), 3*p.n_edges()) + + p.set_corner_permutation(np.random.permutation(p.n_corners()), 3*p.n_corners()) + + p.set_halfedge_permutation(np.random.permutation(p.n_halfedges()), 3*p.n_halfedges()) + + p = ps.register_surface_mesh("test_mesh2", self.generate_verts(), self.generate_faces()) + + p.set_all_permutations( + edge_perm=np.random.permutation(p.n_edges()), + edge_perm_size=3*p.n_edges(), + corner_perm=np.random.permutation(p.n_corners()), + corner_perm_size=3*p.n_corners(), + halfedge_perm=np.random.permutation(p.n_halfedges()), + halfedge_perm_size=p.n_halfedges(), + ) + + ps.show(3) + ps.remove_all_structures() + + + def test_scalar(self): + + for on in ['vertices', 'faces', 'edges', 'halfedges', 'corners', 'texture']: + + ps.register_surface_mesh("test_mesh", self.generate_verts(), self.generate_faces()) + p = ps.get_surface_mesh("test_mesh") + + param_name = None # used for texture case only + + extra_args = {} + if on == 'vertices': + vals = np.random.rand(p.n_vertices()) + elif on == 'faces': + vals = np.random.rand(p.n_faces()) + elif on == 'edges': + vals = np.random.rand(p.n_edges()) + p.set_edge_permutation(np.random.permutation(p.n_edges())) + elif on == 'halfedges': + vals = np.random.rand(p.n_halfedges()) + elif on == 'corners': + vals = np.random.rand(p.n_corners()) + elif on == 'texture': + param_vals = np.random.rand(p.n_vertices(), 2) + param_name = "test_param" + p.add_parameterization_quantity(param_name, param_vals, defined_on='vertices', enabled=True) + vals = np.random.rand(20,30) + extra_args['filter_mode'] = 'nearest' + + + p.add_scalar_quantity("test_vals", vals, defined_on=on, param_name=param_name) + p.add_scalar_quantity("test_vals2", vals, defined_on=on, param_name=param_name, enabled=True) + p.add_scalar_quantity("test_vals_with_range", vals, defined_on=on, param_name=param_name, vminmax=(-5., 5.), enabled=True) + p.add_scalar_quantity("test_vals_with_datatype", vals, defined_on=on, param_name=param_name, enabled=True, datatype='symmetric') + p.add_scalar_quantity("test_vals_with_cmap", vals, defined_on=on, param_name=param_name, enabled=True, cmap='blues') + p.add_scalar_quantity("test_vals_with_iso_old", vals, defined_on=on, param_name=param_name, cmap='blues', isolines_enabled=True, isoline_width=0.1, isoline_darkness=0.5, enabled=True) + p.add_scalar_quantity("test_vals_with_iso2", vals, defined_on=on, param_name=param_name, cmap='blues', isolines_enabled=True, isoline_style='stripe', isoline_period=0.1, isoline_darkness=0.5, enabled=True) + p.add_scalar_quantity("test_vals_with_iso_contour", vals, defined_on=on, param_name=param_name, cmap='blues', isolines_enabled=True, isoline_style='contour', isoline_period=0.1, isoline_contour_thickness =0.4, enabled=True) + p.add_scalar_quantity("test_vals_with_extra", vals, defined_on=on, param_name=param_name, enabled=True, **extra_args) + + ps.show(3) + + # test some additions/removal while we're at it + p.remove_quantity("test_vals") + p.remove_quantity("not_here") # should not error + p.remove_all_quantities() + p.remove_all_quantities() + + ps.remove_all_structures() + + def test_color(self): + ps.register_surface_mesh("test_mesh", self.generate_verts(), self.generate_faces()) + p = ps.get_surface_mesh("test_mesh") + + for on in ['vertices', 'faces', 'texture']: + + param_name = None # used for texture case only + + extra_args = {} + if on == 'vertices': + vals = np.random.rand(p.n_vertices(), 3) + elif on == 'faces': + vals = np.random.rand(p.n_faces(), 3) + elif on == 'texture': + param_vals = np.random.rand(p.n_vertices(), 2) + param_name = "test_param" + p.add_parameterization_quantity(param_name, param_vals, defined_on='vertices', enabled=True) + vals = np.random.rand(20,30,3) + extra_args['filter_mode'] = 'linear' + + + p.add_color_quantity("test_vals", vals, defined_on=on, param_name=param_name) + p.add_color_quantity("test_vals", vals, defined_on=on, param_name=param_name, enabled=True, **extra_args) + + ps.show(3) + p.remove_all_quantities() + + ps.remove_all_structures() + + + def test_distance(self): + ps.register_surface_mesh("test_mesh", self.generate_verts(), self.generate_faces()) + p = ps.get_surface_mesh("test_mesh") + + for on in ['vertices']: + + if on == 'vertices': + vals = np.random.rand(p.n_vertices()) + + p.add_distance_quantity("test_vals", vals, defined_on=on) + p.add_distance_quantity("test_vals2", vals, defined_on=on, enabled=True) + p.add_distance_quantity("test_vals_with_range", vals, defined_on=on, vminmax=(-5., 5.), enabled=True) + p.add_distance_quantity("test_vals_with_signed", vals, defined_on=on, enabled=True, signed=True) + p.add_distance_quantity("test_vals_with_unsigned", vals, defined_on=on, enabled=True, signed=False) + p.add_distance_quantity("test_vals_with_stripe", vals, defined_on=on, enabled=True, stripe_size=0.01) + p.add_distance_quantity("test_vals_with_stripe_reltrue", vals, defined_on=on, enabled=True, stripe_size=0.01, stripe_size_relative=True) + p.add_distance_quantity("test_vals_with_stripe_relfalse", vals, defined_on=on, enabled=True, stripe_size=0.01, stripe_size_relative=False) + + ps.show(3) + + p.remove_all_quantities() + + ps.remove_all_structures() + + def test_parameterization(self): + + ps.register_surface_mesh("test_mesh", self.generate_verts(), self.generate_faces()) + p = ps.get_surface_mesh("test_mesh") + + for on in ['vertices', 'corners']: + + if on == 'vertices': + vals = np.random.rand(p.n_vertices(), 2) + elif on == 'corners': + vals = np.random.rand(p.n_corners(), 2) + + cA = (0.1, 0.2, 0.3) + cB = (0.4, 0.5, 0.6) + + p.add_parameterization_quantity("test_vals1", vals, defined_on=on, enabled=True) + + p.add_parameterization_quantity("test_vals2", vals, defined_on=on, coords_type='world') + p.add_parameterization_quantity("test_vals3", vals, defined_on=on, coords_type='unit') + + p.add_parameterization_quantity("test_vals4", vals, defined_on=on, viz_style='checker') + p.add_parameterization_quantity("test_vals5", vals, defined_on=on, viz_style='grid') + p.add_parameterization_quantity("test_vals6", vals, defined_on=on, viz_style='local_check') + p.add_parameterization_quantity("test_vals7", vals, defined_on=on, viz_style='local_rad') + + p.add_parameterization_quantity("test_vals8", vals, defined_on=on, grid_colors=(cA, cB)) + p.add_parameterization_quantity("test_vals9", vals, defined_on=on, checker_colors=(cA, cB)) + p.add_parameterization_quantity("test_vals10", vals, defined_on=on, checker_size=0.1) + p.add_parameterization_quantity("test_vals11", vals, defined_on=on, cmap='blues') + + ps.show(3) + + # Test island labels + island_labels = np.random.randint(0, 10, size=p.n_faces()) + p.add_parameterization_quantity("test_vals_check_islands",vals, defined_on=on, enabled=True, + viz_style='checker_islands', island_labels=island_labels) + ps.show(3) + + # Test curve network from seams + p.add_parameterization_quantity("test_vals_curve_network", vals, defined_on=on, enabled=True, + create_curve_network_from_seams="") + p.add_parameterization_quantity("test_vals_curve_network", vals, defined_on=on, enabled=True, + create_curve_network_from_seams="my network") + ps.show(3) + + p.remove_all_quantities() + + ps.remove_all_structures() + + def test_vector(self): + + ps.register_surface_mesh("test_mesh", self.generate_verts(), self.generate_faces()) + p = ps.get_surface_mesh("test_mesh") + + for on in ['vertices', 'faces']: + + if on == 'vertices': + vals = np.random.rand(p.n_vertices(),3) + elif on == 'faces': + vals = np.random.rand(p.n_faces(), 3) + + p.add_vector_quantity("test_vals1", vals, defined_on=on) + p.add_vector_quantity("test_vals2", vals, defined_on=on, enabled=True) + p.add_vector_quantity("test_vals3", vals, defined_on=on, enabled=True, vectortype='ambient') + p.add_vector_quantity("test_vals4", vals, defined_on=on, enabled=True, length=0.005) + p.add_vector_quantity("test_vals5", vals, defined_on=on, enabled=True, radius=0.001) + p.add_vector_quantity("test_vals5", vals, defined_on=on, enabled=True, material="candy") + p.add_vector_quantity("test_vals6", vals, defined_on=on, enabled=True, color=(0.2, 0.5, 0.5)) + + # 2D + p.add_vector_quantity("test_vals7", vals[:,:2], defined_on=on, enabled=True, radius=0.001) + + ps.show(3) + p.remove_all_quantities() + + ps.remove_all_structures() + + + def test_tangent_vector(self): + + ps.register_surface_mesh("test_mesh", self.generate_verts(), self.generate_faces()) + p = ps.get_surface_mesh("test_mesh") + + for on in ['vertices', 'faces']: + + if on == 'vertices': + vals = np.random.rand(p.n_vertices(), 2) + basisX = np.random.rand(p.n_vertices(), 3) + basisY = np.random.rand(p.n_vertices(), 3) + elif on == 'faces': + vals = np.random.rand(p.n_faces(), 2) + basisX = np.random.rand(p.n_faces(), 3) + basisY = np.random.rand(p.n_faces(), 3) + + p.add_tangent_vector_quantity("test_vals1", vals, basisX, basisY, defined_on=on) + p.add_tangent_vector_quantity("test_vals2", vals, basisX, basisY, defined_on=on, enabled=True) + p.add_tangent_vector_quantity("test_vals3", vals, basisX, basisY, defined_on=on, enabled=True, vectortype='ambient') + p.add_tangent_vector_quantity("test_vals4", vals, basisX, basisY, defined_on=on, enabled=True, length=0.005) + p.add_tangent_vector_quantity("test_vals5", vals, basisX, basisY, defined_on=on, enabled=True, radius=0.001) + p.add_tangent_vector_quantity("test_vals6", vals, basisX, basisY, defined_on=on, enabled=True, color=(0.2, 0.5, 0.5)) + p.add_tangent_vector_quantity("test_vals7", vals, basisX, basisY, defined_on=on, enabled=True, radius=0.001) + p.add_tangent_vector_quantity("test_vals8", vals, basisX, basisY, n_sym=4, defined_on=on, enabled=True) + + ps.show(3) + p.remove_all_quantities() + + ps.remove_all_structures() + + def test_one_form_tangent_vector(self): + + ps.register_surface_mesh("test_mesh", self.generate_verts(), self.generate_faces()) + p = ps.get_surface_mesh("test_mesh") + + p.set_edge_permutation(np.random.permutation(p.n_edges())) + + vals = np.random.rand(p.n_edges()) + orients = np.random.rand(p.n_edges()) > 0.5 + + p.add_one_form_vector_quantity("test_vals1", vals, orients) + p.add_one_form_vector_quantity("test_vals2", vals, orients, enabled=True) + p.add_one_form_vector_quantity("test_vals3", vals, orients, enabled=True) + p.add_one_form_vector_quantity("test_vals4", vals, orients, enabled=True, length=0.005) + p.add_one_form_vector_quantity("test_vals5", vals, orients, enabled=True, radius=0.001) + p.add_one_form_vector_quantity("test_vals6", vals, orients, enabled=True, color=(0.2, 0.5, 0.5)) + p.add_one_form_vector_quantity("test_vals7", vals, orients, enabled=True, radius=0.001) + + ps.show(3) + p.remove_all_quantities() + + ps.remove_all_structures() + + def test_variable_radius(self): + + for on in ['vertices', 'faces', 'corners']: + + ps.register_surface_mesh("test_mesh", self.generate_verts(), self.generate_faces()) + p = ps.get_surface_mesh("test_mesh") + + if on == 'vertices': + vals = np.random.rand(p.n_vertices()) + elif on == 'faces': + vals = np.random.rand(p.n_faces()) + elif on == 'corners': + vals = np.random.rand(p.n_corners()) + + p.add_scalar_quantity("test_vals", vals, defined_on=on) + + p.set_transparency_quantity("test_vals") + ps.show(3) + p.clear_transparency_quantity() + ps.show(3) + + ps.remove_all_structures() + + +class TestVolumeMesh(unittest.TestCase): + + def generate_verts(self, n_pts=10): + np.random.seed(777) + return np.random.rand(n_pts, 3) + + def generate_tets(self, n_pts=10): + np.random.seed(777) + return np.random.randint(0, n_pts, size=(2*n_pts,4)) + + def test_add_remove(self): + + # add + n = ps.register_volume_mesh("test_mesh", self.generate_verts(), self.generate_tets()) + self.assertTrue(ps.has_volume_mesh("test_mesh")) + self.assertFalse(ps.has_volume_mesh("nope")) + self.assertEqual(n.n_vertices(), 10) + self.assertEqual(n.n_cells(), 20) + + # remove by name + ps.register_volume_mesh("test_mesh2", self.generate_verts(), self.generate_tets()) + ps.remove_volume_mesh("test_mesh2") + self.assertTrue(ps.has_volume_mesh("test_mesh")) + self.assertFalse(ps.has_volume_mesh("test_mesh2")) + + # remove by ref + c = ps.register_volume_mesh("test_mesh2", self.generate_verts(), self.generate_tets()) + c.remove() + self.assertTrue(ps.has_volume_mesh("test_mesh")) + self.assertFalse(ps.has_volume_mesh("test_mesh2")) + + # get by name + ps.register_volume_mesh("test_mesh3", self.generate_verts(), self.generate_tets()) + p = ps.get_volume_mesh("test_mesh3") # should be wrapped instance, not underlying PSB instance + self.assertTrue(isinstance(p, ps.VolumeMesh)) + + ps.remove_all_structures() + + def test_render(self): + + ps.register_volume_mesh("test_mesh", self.generate_verts(), self.generate_tets()) + ps.show(3) + ps.remove_all_structures() + + def test_add_tet(self): + ps.register_volume_mesh("test_mesh3", self.generate_verts(), tets=self.generate_tets()) + ps.show(3) + ps.remove_all_structures() + + def test_add_hex(self): + np.random.seed(777) + n_pts = 10 + cells = np.random.randint(0, n_pts, size=(2*n_pts,8)) + ps.register_volume_mesh("test_mesh3", self.generate_verts(), hexes=cells) + ps.show(3) + ps.remove_all_structures() + + def test_add_combined(self): + np.random.seed(777) + n_pts = 10 + cells = np.random.randint(0, n_pts, size=(2*n_pts,8)) + ps.register_volume_mesh("test_mesh3", self.generate_verts(), tets=self.generate_tets(), hexes=cells) + ps.show(3) + ps.remove_all_structures() + + def test_add_mixed(self): + np.random.seed(777) + n_pts = 10 + cells = np.random.randint(0, n_pts, size=(2*n_pts,8)) + cells[-5:,4:] = -1 # clear out some rows at end + ps.register_volume_mesh("test_mesh3", self.generate_verts(), mixed_cells=cells) + ps.show(3) + ps.remove_all_structures() + + # test a few error cases + # cells = np.random.randint(0, n_pts, size=(2*n_pts,8)) + # cells[-5:,4:] = -1 # clear out some rows at end + # ps.register_volume_mesh("test_mesh3", self.generate_verts(), hexes=self.generate_tets()) + + def test_options(self): + + p = ps.register_volume_mesh("test_mesh", self.generate_verts(), self.generate_tets()) + + # Set enabled + p.set_enabled() + p.set_enabled(False) + p.set_enabled(True) + self.assertTrue(p.is_enabled()) + + # Color + color = (0.3, 0.3, 0.5) + p.set_color(color) + ret_color = p.get_color() + for i in range(3): + self.assertAlmostEqual(ret_color[i], color[i]) + + # Interior Color + color = (0.45, 0.85, 0.2) + p.set_interior_color(color) + ret_color = p.get_interior_color() + for i in range(3): + self.assertAlmostEqual(ret_color[i], color[i]) + + # Edge color + color = (0.1, 0.5, 0.5) + p.set_edge_color(color) + ret_color = p.get_edge_color() + for i in range(3): + self.assertAlmostEqual(ret_color[i], color[i]) + + ps.show(3) + + # Edge width + p.set_edge_width(1.5) + ps.show(3) + self.assertAlmostEqual(p.get_edge_width(), 1.5) + + # Material + p.set_material("candy") + self.assertEqual("candy", p.get_material()) + p.set_material("clay") + + # Transparency + p.set_transparency(0.8) + self.assertAlmostEqual(0.8, p.get_transparency()) + + # Set with optional arguments + p2 = ps.register_volume_mesh("test_mesh", self.generate_verts(), self.generate_tets(), + enabled=True, material='wax', color=(1., 0., 0.), edge_color=(0.5, 0.5, 0.5), + interior_color=(0.2, 0.2, 0.2), edge_width=0.5, + transparency=0.9) + + ps.show(3) + ps.remove_all_structures() + ps.set_transparency_mode('none') + + def test_transform(self): + + p = ps.register_volume_mesh("test_mesh", self.generate_verts(), self.generate_tets()) + test_transforms(self,p) + ps.remove_all_structures() + + def test_slice_plane(self): + + p = ps.register_volume_mesh("test_mesh", self.generate_verts(), self.generate_tets()) + + plane = ps.add_scene_slice_plane() + p.set_cull_whole_elements(True) + ps.show(3) + p.set_cull_whole_elements(False) + ps.show(3) + + p.set_ignore_slice_plane(plane, True) + self.assertEqual(True, p.get_ignore_slice_plane(plane)) + p.set_ignore_slice_plane(plane.get_name(), False) + self.assertEqual(False, p.get_ignore_slice_plane(plane.get_name())) + + plane.set_volume_mesh_to_inspect("test_mesh") + self.assertEqual("test_mesh", plane.get_volume_mesh_to_inspect()) + + ps.show(3) + + ps.remove_all_structures() + ps.remove_last_scene_slice_plane() + + def test_update(self): + + p = ps.register_volume_mesh("test_mesh", self.generate_verts(), self.generate_tets()) + ps.show(3) + + newPos = self.generate_verts() - 0.5 + p.update_vertex_positions(newPos) + + ps.show(3) + ps.remove_all_structures() + + def test_scalar(self): + ps.register_volume_mesh("test_mesh", self.generate_verts(), self.generate_tets()) + p = ps.get_volume_mesh("test_mesh") + + for on in ['vertices', 'cells']: + + if on == 'vertices': + vals = np.random.rand(p.n_vertices()) + elif on == 'cells': + vals = np.random.rand(p.n_cells()) + + p.add_scalar_quantity("test_vals", vals, defined_on=on) + p.add_scalar_quantity("test_vals2", vals, defined_on=on, enabled=True) + p.add_scalar_quantity("test_vals_with_range", vals, defined_on=on, vminmax=(-5., 5.), enabled=True) + p.add_scalar_quantity("test_vals_with_datatype", vals, defined_on=on, enabled=True, datatype='symmetric') + p.add_scalar_quantity("test_vals_with_iso2", vals, defined_on=on, cmap='reds', enabled=True) + p.add_scalar_quantity("test_vals_with_iso2", vals, defined_on=on, cmap='blues', isolines_enabled=True, isoline_style='stripe', isoline_period=0.1, isoline_darkness=0.5, enabled=True) + p.add_scalar_quantity("test_vals_with_iso_contour", vals, defined_on=on, cmap='blues', isolines_enabled=True, isoline_style='contour', isoline_period=0.1, isoline_contour_thickness=0.4, enabled=True) + p.add_scalar_quantity("test_vals_with_cmap", vals, defined_on=on, enabled=True, cmap='blues') + + ps.show(3) + + # test some additions/removal while we're at it + p.remove_quantity("test_vals") + p.remove_quantity("not_here") # should not error + p.remove_all_quantities() + p.remove_all_quantities() + + ps.remove_all_structures() + + + def test_color(self): + ps.register_volume_mesh("test_mesh", self.generate_verts(), self.generate_tets()) + p = ps.get_volume_mesh("test_mesh") + + for on in ['vertices', 'cells']: + + if on == 'vertices': + vals = np.random.rand(p.n_vertices(), 3) + elif on == 'cells': + vals = np.random.rand(p.n_cells(), 3) + + + p.add_color_quantity("test_vals", vals, defined_on=on) + p.add_color_quantity("test_vals", vals, defined_on=on, enabled=True) + + ps.show(3) + p.remove_all_quantities() + + ps.remove_all_structures() + + + def test_vector(self): + + ps.register_volume_mesh("test_mesh", self.generate_verts(), self.generate_tets()) + p = ps.get_volume_mesh("test_mesh") + + for on in ['vertices', 'cells']: + + if on == 'vertices': + vals = np.random.rand(p.n_vertices(),3) + elif on == 'cells': + vals = np.random.rand(p.n_cells(), 3) + + p.add_vector_quantity("test_vals1", vals, defined_on=on) + p.add_vector_quantity("test_vals2", vals, defined_on=on, enabled=True) + p.add_vector_quantity("test_vals3", vals, defined_on=on, enabled=True, vectortype='ambient') + p.add_vector_quantity("test_vals4", vals, defined_on=on, enabled=True, length=0.005) + p.add_vector_quantity("test_vals5", vals, defined_on=on, enabled=True, radius=0.001) + p.add_vector_quantity("test_vals6", vals, defined_on=on, enabled=True, color=(0.2, 0.5, 0.5)) + + ps.show(3) + p.remove_all_quantities() + + ps.remove_all_structures() + +class TestVolumeGrid(unittest.TestCase): + + def test_add_remove(self): + + # add + n = ps.register_volume_grid("test_grid", (10,12,14), (0.,0.,0,), (1., 1., 1.)) + self.assertTrue(ps.has_volume_grid("test_grid")) + self.assertFalse(ps.has_volume_grid("nope")) + self.assertEqual(n.n_nodes(), 10*12*14) + self.assertEqual(n.n_cells(), (10-1)*(12-1)*(14-1)) + + # remove by name + ps.register_volume_grid("test_grid2", (10,12,14), (0.,0.,0,), (1., 1., 1.)) + ps.remove_volume_grid("test_grid2") + self.assertTrue(ps.has_volume_grid("test_grid")) + self.assertFalse(ps.has_volume_grid("test_grid2")) + + # remove by ref + c = ps.register_volume_grid("test_grid2", (10,12,14), (0.,0.,0,), (1., 1., 1.)) + c.remove() + self.assertTrue(ps.has_volume_grid("test_grid")) + self.assertFalse(ps.has_volume_grid("test_grid2")) + + # get by name + ps.register_volume_grid("test_grid3", (10,12,14), (0.,0.,0,), (1., 1., 1.)) + p = ps.get_volume_grid("test_grid3") # should be wrapped instance, not underlying PSB instance + self.assertTrue(isinstance(p, ps.VolumeGrid)) + + ps.remove_all_structures() + + def test_render(self): + + ps.register_volume_grid("test_grid", (10,12,14), (0.,0.,0,), (1., 1., 1.)) + ps.show(3) + ps.remove_all_structures() + + def test_options(self): + + p = ps.register_volume_grid("test_grid", (10,12,14), (0.,0.,0,), (1., 1., 1.)) + + # misc getters + p.n_nodes() + p.n_cells() + p.grid_spacing() + self.assertTrue((p.get_grid_node_dim() == (10,12,14))) + self.assertTrue((p.get_grid_cell_dim() == ((10-1),(12-1),(14-1)))) + self.assertTrue((p.get_bound_min() == np.array((0., 0., 0.))).all()) + self.assertTrue((p.get_bound_max() == np.array((1., 1., 1.))).all()) + + # Set enabled + p.set_enabled() + p.set_enabled(False) + p.set_enabled(True) + self.assertTrue(p.is_enabled()) + + # Color + color = (0.3, 0.3, 0.5) + p.set_color(color) + ret_color = p.get_color() + for i in range(3): + self.assertAlmostEqual(ret_color[i], color[i]) + + # Edge color + color = (0.1, 0.5, 0.5) + p.set_edge_color(color) + ret_color = p.get_edge_color() + for i in range(3): + self.assertAlmostEqual(ret_color[i], color[i]) + + ps.show(3) + + # Edge width + p.set_edge_width(1.5) + ps.show(3) + self.assertAlmostEqual(p.get_edge_width(), 1.5) + + # Cube size factor + p.set_cube_size_factor(0.5) + ps.show(3) + self.assertAlmostEqual(p.get_cube_size_factor(), 0.5) + + # Material + p.set_material("candy") + self.assertEqual("candy", p.get_material()) + p.set_material("clay") + + # Transparency + p.set_transparency(0.8) + self.assertAlmostEqual(0.8, p.get_transparency()) + + # Set with optional arguments + p2 = ps.register_volume_grid("test_grid", (10,12,14), (0.,0.,0,), (1., 1., 1.), + enabled=True, material='wax', color=(1., 0., 0.), edge_color=(0.5, 0.5, 0.5), edge_width=0.5, cube_size_factor=0.5, transparency=0.9) + + ps.show(3) + + ps.remove_all_structures() + ps.set_transparency_mode('none') + + def test_transform(self): + + p = ps.register_volume_grid("test_grid", (10,12,14), (0.,0.,0,), (1., 1., 1.)) + test_transforms(self,p) + ps.remove_all_structures() + + def test_slice_plane(self): + + p = ps.register_volume_grid("test_grid", (10,12,14), (0.,0.,0,), (1., 1., 1.)) + + plane = ps.add_scene_slice_plane() + p.set_cull_whole_elements(True) + ps.show(3) + p.set_cull_whole_elements(False) + ps.show(3) + + p.set_ignore_slice_plane(plane, True) + self.assertEqual(True, p.get_ignore_slice_plane(plane)) + p.set_ignore_slice_plane(plane.get_name(), False) + self.assertEqual(False, p.get_ignore_slice_plane(plane.get_name())) + + ps.show(3) + + ps.remove_all_structures() + ps.remove_last_scene_slice_plane() + + + def test_scalar(self): + node_dim = (10,12,14) + cell_dim = (10-1,12-1,14-1) + p = ps.register_volume_grid("test_grid", node_dim, (0.,0.,0,), (1., 1., 1.)) + + for on in ['nodes', 'cells']: + + if on == 'nodes': + vals = np.random.rand(*node_dim) + elif on == 'cells': + vals = np.random.rand(*cell_dim) + + p.add_scalar_quantity("test_vals", vals, defined_on=on) + p.add_scalar_quantity("test_vals2", vals, defined_on=on, enabled=True) + p.add_scalar_quantity("test_vals_with_range", vals, defined_on=on, vminmax=(-5., 5.), enabled=True) + p.add_scalar_quantity("test_vals_with_datatype", vals, defined_on=on, enabled=True, datatype='symmetric') + p.add_scalar_quantity("test_vals_with_cmap", vals, defined_on=on, enabled=True, cmap='blues', enable_gridcube_viz=False) + + ps.show(3) + + # test some additions/removal while we're at it + p.remove_quantity("test_vals") + p.remove_quantity("not_here") # should not error + p.remove_all_quantities() + p.remove_all_quantities() + + ps.remove_all_structures() + + def test_scalar_from_callable(self): + node_dim = (10,12,14) + cell_dim = (10-1,12-1,14-1) + p = ps.register_volume_grid("test_grid", node_dim, (0.,0.,0,), (1., 1., 1.)) + + def sphere_sdf(pts): return np.linalg.norm(pts, axis=-1) - 1. + + for on in ['nodes', 'cells']: + + p.add_scalar_quantity_from_callable("test_vals", sphere_sdf, defined_on=on) + p.add_scalar_quantity_from_callable("test_vals2", sphere_sdf, defined_on=on, enabled=True) + p.add_scalar_quantity_from_callable("test_vals_with_range", sphere_sdf, defined_on=on, vminmax=(-5., 5.), enabled=True) + p.add_scalar_quantity_from_callable("test_vals_with_datatype", sphere_sdf, defined_on=on, enabled=True, datatype='symmetric') + p.add_scalar_quantity_from_callable("test_vals_with_cmap", sphere_sdf, defined_on=on, enabled=True, cmap='blues', enable_gridcube_viz=False) + + ps.show(3) + + # test some additions/removal while we're at it + p.remove_quantity("test_vals") + p.remove_quantity("not_here") # should not error + p.remove_all_quantities() + p.remove_all_quantities() + + ps.remove_all_structures() + + def test_scalar_isosurface_array(self): + node_dim = (10,12,14) + + p = ps.register_volume_grid("test_grid", node_dim, (0.,0.,0,), (1., 1., 1.)) + vals = np.random.rand(*node_dim) + + p.add_scalar_quantity("test_vals", vals, defined_on='nodes', enabled=True, + enable_gridcube_viz=False, enable_isosurface_viz=True, + isosurface_level=-0.2, isosurface_color=(0.5,0.6,0.7), + slice_planes_affect_isosurface=False, + register_isosurface_as_mesh_with_name="isomesh") + + ps.remove_all_structures() + + def test_scalar_isosurface_callable(self): + node_dim = (10,12,14) + + p = ps.register_volume_grid("test_grid", node_dim, (0.,0.,0,), (1., 1., 1.)) + def sphere_sdf(pts): return np.linalg.norm(pts, axis=-1) - 1. + + p.add_scalar_quantity_from_callable("test_vals", sphere_sdf, defined_on='nodes', enabled=True, + enable_gridcube_viz=False, enable_isosurface_viz=True, + isosurface_level=-0.2, isosurface_color=(0.5,0.6,0.7), + slice_planes_affect_isosurface=False, + register_isosurface_as_mesh_with_name="isomesh") + + ps.remove_all_structures() + + + +class TestCameraView(unittest.TestCase): + + def generate_parameters(self): + intrinsics = ps.CameraIntrinsics(fov_vertical_deg=60, aspect=2) + extrinsics = ps.CameraExtrinsics(root=(2., 2., 2.), look_dir=(-1., -1.,-1.), up_dir=(0.,1.,0.)) + return ps.CameraParameters(intrinsics, extrinsics) + + def test_add_remove(self): + + # add + cam = ps.register_camera_view("cam1", self.generate_parameters()) + self.assertTrue(ps.has_camera_view("cam1")) + self.assertFalse(ps.has_camera_view("nope")) + + # remove by name + ps.register_camera_view("cam2", self.generate_parameters()) + ps.remove_camera_view("cam2") + self.assertTrue(ps.has_camera_view("cam1")) + self.assertFalse(ps.has_camera_view("cam2")) + + # remove by ref + c = ps.register_camera_view("cam3", self.generate_parameters()) + c.remove() + self.assertTrue(ps.has_camera_view("cam1")) + self.assertFalse(ps.has_camera_view("cam3")) + + # get by name + ps.register_camera_view("cam3", self.generate_parameters()) + p = ps.get_camera_view("cam3") # should be wrapped instance, not underlying PSB instance + self.assertTrue(isinstance(p, ps.CameraView)) + + ps.remove_all_structures() + + def test_render(self): + + cam = ps.register_camera_view("cam1", self.generate_parameters()) + ps.show(3) + ps.remove_all_structures() + + def test_transform(self): + + cam = ps.register_camera_view("cam1", self.generate_parameters()) + test_transforms(self, cam) + ps.remove_all_structures() + + def test_options(self): + + cam = ps.register_camera_view("cam1", self.generate_parameters()) + + # widget color + color = (0.3, 0.3, 0.5) + cam.set_widget_color(color) + ret_color = cam.get_widget_color() + for i in range(3): + self.assertAlmostEqual(ret_color[i], color[i]) + + # widget thickness + cam.set_widget_thickness(0.03) + self.assertAlmostEqual(0.03, cam.get_widget_thickness()) + + # widget focal length + cam.set_widget_focal_length(0.03, False) + self.assertAlmostEqual(0.03, cam.get_widget_focal_length()) + + ps.show(3) + ps.remove_all_structures() + + def test_update(self): + + cam = ps.register_camera_view("cam1", self.generate_parameters()) + cam.update_camera_parameters(self.generate_parameters()) + + ps.show(3) + ps.remove_all_structures() + + def test_camera_things(self): + + cam = ps.register_camera_view("cam1", self.generate_parameters()) + cam.set_view_to_this_camera() + ps.show(3) + cam.set_view_to_this_camera(with_flight=True) + ps.show(3) + + ps.remove_all_structures() + + def test_camera_parameters(self): + + cam = ps.register_camera_view("cam1", self.generate_parameters()) + params = cam.get_camera_parameters() + + self.assertTrue(isinstance(params.get_intrinsics(), ps.CameraIntrinsics)) + self.assertTrue(isinstance(params.get_extrinsics(), ps.CameraExtrinsics)) + + assertArrayWithShape(self, params.get_R(), [3,3]) + assertArrayWithShape(self, params.get_T(), [3]) + assertArrayWithShape(self, params.get_view_mat(), [4,4]) + assertArrayWithShape(self, params.get_E(), [4,4]) + assertArrayWithShape(self, params.get_position(), [3]) + assertArrayWithShape(self, params.get_look_dir(), [3]) + assertArrayWithShape(self, params.get_up_dir(), [3]) + assertArrayWithShape(self, params.get_right_dir(), [3]) + assertArrayWithShape(self, params.get_camera_frame()[0], [3]) + assertArrayWithShape(self, params.get_camera_frame()[1], [3]) + assertArrayWithShape(self, params.get_camera_frame()[2], [3]) + + self.assertTrue(isinstance(params.get_fov_vertical_deg(), float)) + self.assertTrue(isinstance(params.get_aspect(), float)) + + dimX = 300 + dimY = 200 + rays = params.generate_camera_rays((dimX,dimY)) + assertArrayWithShape(self, rays, [dimY,dimX,3]) + ray_corners = params.generate_camera_ray_corners() + + def test_floating_scalar_images(self): + + # technically these can be added to any structure, but we will test them here + + cam = ps.register_camera_view("cam1", self.generate_parameters()) + + dimX = 300 + dimY = 600 + + cam.add_scalar_image_quantity("scalar_img", np.zeros((dimY, dimX))) + cam.add_scalar_image_quantity("scalar_img2", np.zeros((dimY, dimX)), enabled=True, image_origin='lower_left', datatype='symmetric', vminmax=(-3.,.3), cmap='reds', show_in_camera_billboard=True) + cam.add_scalar_image_quantity("scalar_img3", np.zeros((dimY, dimX)), enabled=True, show_in_imgui_window=True, show_in_camera_billboard=False) + cam.add_scalar_image_quantity("scalar_img4", np.zeros((dimY, dimX)), enabled=True, show_fullscreen=True, show_in_camera_billboard=False, transparency=0.5) + + # true floating adder + ps.add_scalar_image_quantity("scalar_img2", np.zeros((dimY, dimX)), enabled=True, image_origin='lower_left', datatype='symmetric', vminmax=(-3.,.3), cmap='reds') + + ps.show(3) + ps.remove_all_structures() + + def test_floating_color_images(self): + + # technically these can be added to any structure, but we will test them here + + cam = ps.register_camera_view("cam1", self.generate_parameters()) + + dimX = 300 + dimY = 600 + + cam.add_color_image_quantity("color_img", np.zeros((dimY, dimX, 3))) + cam.add_color_image_quantity("color_img2", np.zeros((dimY, dimX, 3)), enabled=True, image_origin='lower_left', show_in_camera_billboard=True) + cam.add_color_image_quantity("color_img3", np.zeros((dimY, dimX, 3)), enabled=True, show_in_imgui_window=True, show_in_camera_billboard=False) + cam.add_color_image_quantity("color_img4", np.zeros((dimY, dimX, 3)), enabled=True, show_fullscreen=True, show_in_camera_billboard=False, transparency=0.5) + + # true floating adder + ps.add_color_image_quantity("color_img2", np.zeros((dimY, dimX, 3)), enabled=True, image_origin='lower_left', show_in_camera_billboard=False) + + ps.show(3) + ps.remove_all_structures() + + def test_floating_color_alpha_images(self): + + # technically these can be added to any structure, but we will test them here + + cam = ps.register_camera_view("cam1", self.generate_parameters()) + + dimX = 300 + dimY = 600 + + cam.add_color_alpha_image_quantity("color_alpha_img", np.zeros((dimY, dimX, 4))) + cam.add_color_alpha_image_quantity("color_alpha_img2", np.zeros((dimY, dimX, 4)), enabled=True, image_origin='lower_left', show_in_camera_billboard=True) + cam.add_color_alpha_image_quantity("color_alpha_img3", np.zeros((dimY, dimX, 4)), enabled=True, show_in_imgui_window=True, show_in_camera_billboard=False, is_premultiplied=True) + cam.add_color_alpha_image_quantity("color_alpha_img4", np.zeros((dimY, dimX, 4)), enabled=True, show_fullscreen=True, show_in_camera_billboard=False) + + # true floating adder + ps.add_color_alpha_image_quantity("color_alpha_img3", np.zeros((dimY, dimX, 4)), enabled=True, show_in_imgui_window=True, show_in_camera_billboard=False) + + ps.show(3) + ps.remove_all_structures() + + def test_floating_depth_render_images(self): + + # technically these can be added to any structure, but we will test them here + + cam = ps.register_camera_view("cam1", self.generate_parameters()) + + dimX = 300 + dimY = 600 + + depths = np.zeros((dimY, dimX)) + normals = np.ones((dimY, dimX, 3)) + + cam.add_depth_render_image_quantity("render_img", depths, normals) + cam.add_depth_render_image_quantity("render_img2", depths, normals, enabled=True, image_origin='lower_left', color=(0., 1., 0.), material='wax', transparency=0.7) + + # true floating adder + ps.add_depth_render_image_quantity("render_img3", depths, normals, enabled=True, image_origin='lower_left', color=(0., 1., 0.), material='wax', transparency=0.7, allow_fullscreen_compositing=True) + + ps.show(3) + ps.remove_all_structures() + + def test_floating_color_render_images(self): + + # technically these can be added to any structure, but we will test them here + + cam = ps.register_camera_view("cam1", self.generate_parameters()) + + dimX = 300 + dimY = 600 + + depths = np.zeros((dimY, dimX)) + normals = np.ones((dimY, dimX, 3)) + colors = np.ones((dimY, dimX, 3)) + + cam.add_color_render_image_quantity("render_img", depths, normals, colors) + cam.add_color_render_image_quantity("render_img2", depths, normals, colors, enabled=True, image_origin='lower_left', material='wax', transparency=0.7) + + # true floating adder + ps.add_color_render_image_quantity("render_img3", depths, normals, colors, enabled=True, image_origin='lower_left', material='wax', transparency=0.7, allow_fullscreen_compositing=True) + + ps.show(3) + ps.remove_all_structures() + + def test_floating_scalar_render_images(self): + + # technically these can be added to any structure, but we will test them here + + cam = ps.register_camera_view("cam1", self.generate_parameters()) + + dimX = 300 + dimY = 600 + + depths = np.zeros((dimY, dimX)) + normals = np.ones((dimY, dimX, 3)) + scalars = np.ones((dimY, dimX)) + + cam.add_scalar_render_image_quantity("render_img", depths, normals, scalars) + cam.add_scalar_render_image_quantity("render_img2", depths, normals, scalars, enabled=True, image_origin='lower_left', material='wax', transparency=0.7) + + # true floating adder + ps.add_scalar_render_image_quantity("render_img3", depths, normals, scalars, enabled=True, image_origin='lower_left', material='wax', transparency=0.7, allow_fullscreen_compositing=True) + + ps.show(3) + ps.remove_all_structures() + + def test_floating_raw_color_render_images(self): + + # technically these can be added to any structure, but we will test them here + + cam = ps.register_camera_view("cam1", self.generate_parameters()) + + dimX = 300 + dimY = 600 + + depths = np.zeros((dimY, dimX)) + colors = np.ones((dimY, dimX, 3)) + + cam.add_raw_color_render_image_quantity("render_img", depths, colors) + cam.add_raw_color_render_image_quantity("render_img2", depths, colors, enabled=True, image_origin='lower_left', transparency=0.7) + + # true floating adder + ps.add_raw_color_render_image_quantity("render_img3", depths, colors, enabled=True, image_origin='lower_left', transparency=0.7, allow_fullscreen_compositing=True) + + ps.show(3) + ps.remove_all_structures() + + def test_floating_raw_color_alpha_render_images(self): + + # technically these can be added to any structure, but we will test them here + + cam = ps.register_camera_view("cam1", self.generate_parameters()) + + dimX = 300 + dimY = 600 + + depths = np.zeros((dimY, dimX)) + colors = np.ones((dimY, dimX, 4)) + + cam.add_raw_color_alpha_render_image_quantity("render_img", depths, colors) + cam.add_raw_color_alpha_render_image_quantity("render_img2", depths, colors, enabled=True, image_origin='lower_left', transparency=0.7, is_premultiplied=True) + + # true floating adder + ps.add_raw_color_alpha_render_image_quantity("render_img3", depths, colors, enabled=True, image_origin='lower_left', transparency=0.7, allow_fullscreen_compositing=True) + + ps.show(3) + ps.remove_all_structures() + + def test_floating_implicit_surface_render(self): + + # this can be called free-floating or on a camera view, but we will test them here + + def sphere_sdf(pts): return np.linalg.norm(pts, axis=-1) - 1. + + # basic + ps.render_implicit_surface("sphere sdf", sphere_sdf, 'fixed_step', subsample_factor=10, n_max_steps=10, enabled=True) + + # with some args + ps.render_implicit_surface("sphere sdf", sphere_sdf, 'sphere_march', enabled=True, + camera_parameters=self.generate_parameters(), + dim=(50,75), + miss_dist=20.5, miss_dist_relative=True, + hit_dist=0.001, hit_dist_relative=False, + step_factor=0.98, + normal_sample_eps=0.02, + step_size=0.01, step_size_relative=True, + n_max_steps=50, + material='wax', + color=(0.5,0.5,0.5) + ) + + # from this camera view + cam = ps.register_camera_view("cam1", self.generate_parameters()) + ps.render_implicit_surface("sphere sdf", sphere_sdf, 'sphere_march', dim=(50,75), n_max_steps=10, camera_view=cam, enabled=True) + + ps.show(3) + ps.remove_all_structures() + + def test_floating_implicit_surface_color_render(self): + + # this can be called free-floating or on a camera view, but we will test them here + + def sphere_sdf(pts): return np.linalg.norm(pts, axis=-1) - 1. + def color_func(pts): return np.zeros_like(pts) + + # basic + ps.render_implicit_surface_color("sphere sdf", sphere_sdf, color_func, 'fixed_step', subsample_factor=10, n_max_steps=10, enabled=True) + + # with some args + ps.render_implicit_surface_color("sphere sdf", sphere_sdf, color_func, 'sphere_march', enabled=True, + camera_parameters=self.generate_parameters(), + dim=(50,75), + miss_dist=20.5, miss_dist_relative=True, + hit_dist=0.001, hit_dist_relative=False, + step_factor=0.98, + normal_sample_eps=0.02, + step_size=0.01, step_size_relative=True, + n_max_steps=50, + material='wax', + ) + + # from this camera view + cam = ps.register_camera_view("cam1", self.generate_parameters()) + ps.render_implicit_surface_color("sphere sdf", sphere_sdf, color_func, 'sphere_march', dim=(50,75), n_max_steps=10, camera_view=cam, enabled=True) + + ps.show(3) + ps.remove_all_structures() + + + def test_floating_implicit_surface_scalar_render(self): + + # this can be called free-floating or on a camera view, but we will test them here + + def sphere_sdf(pts): return np.linalg.norm(pts, axis=-1) - 1. + def scalar_func(pts): return np.ones_like(pts[:,0]) + + # basic + ps.render_implicit_surface_scalar("sphere sdf", sphere_sdf, scalar_func, 'fixed_step', subsample_factor=10, n_max_steps=10, enabled=True) + + # with some args + ps.render_implicit_surface_scalar("sphere sdf", sphere_sdf, scalar_func, 'sphere_march', enabled=True, + camera_parameters=self.generate_parameters(), + dim=(50,75), + miss_dist=20.5, miss_dist_relative=True, + hit_dist=0.001, hit_dist_relative=False, + step_factor=0.98, + normal_sample_eps=0.02, + step_size=0.01, step_size_relative=True, + n_max_steps=50, + material='wax', + cmap='blues', + vminmax=(0.,1.) + ) + + # from this camera view + cam = ps.register_camera_view("cam1", self.generate_parameters()) + ps.render_implicit_surface_scalar("sphere sdf", sphere_sdf, scalar_func, 'sphere_march', dim=(50,75), n_max_steps=10, camera_view=cam, enabled=True) + + ps.show(3) + ps.remove_all_structures() + +class TestManagedBuffers(unittest.TestCase): + + def test_managed_buffer_basics(self): + + # NOTE: this only tests the float & vec3 versions, really there are variant methods for each type + + def generate_points(n_pts=10): + np.random.seed(777) + return np.random.rand(n_pts, 3) + + def generate_scalar(n_pts=10): + np.random.seed(777) + return np.random.rand(n_pts) + + + # create a dummy point cloud; + ps_cloud = ps.register_point_cloud("test_cloud", generate_points()) + ps_scalar = ps_cloud.add_scalar_quantity("test_vals", generate_scalar()) + ps.show(3) + + # test a quantity buffer of float + scalar_buf = ps_cloud.get_quantity_buffer("test_vals", "values") + self.assertEqual(scalar_buf.size(), 10) + self.assertTrue(scalar_buf.has_data()) + scalar_buf.get_value(3) + scalar_buf.update_data(generate_scalar()) + + # test a structure buffer of vec3 + pos_buf = ps_cloud.get_buffer("points") + self.assertEqual(pos_buf.size(), 10) + self.assertTrue(pos_buf.has_data()) + pos_buf.summary_string() + pos_buf.get_value(3) + pos_buf.update_data(generate_points()) + + ps.show(3) + + # test a free-floating quantity buffer + dimX = 200 + dimY = 300 + ps.add_scalar_image_quantity("test_float_img", np.zeros((dimY, dimX))) + img_buf = ps.get_quantity_buffer("test_float_img", "values") + self.assertEqual(img_buf.size(), dimX*dimY) + self.assertTrue(img_buf.has_data()) + img_buf.summary_string() + img_buf.get_value(3) + img_buf.update_data(np.zeros(dimX*dimY)) + + # test key presses + if(psim.IsKeyPressed(psim.ImGuiKey_A)): + pass + + ps.show(3) diff --git a/test/tests/test_imgui.py b/test/tests/test_imgui.py new file mode 100644 index 0000000..f32c14e --- /dev/null +++ b/test/tests/test_imgui.py @@ -0,0 +1,1054 @@ +from os import listdir +import os.path as path +from os.path import isfile, join +import unittest + +import numpy as np + +import polyscope as ps +import polyscope.imgui as psim +import polyscope.implot as psimplot + +class TestImGuiBindings(unittest.TestCase): + + def test_context_creation(self): + # Test context creation functions using capsules + # Note: We don't actually switch contexts in this test, just verify the bindings work + + def imgui_callback(): + # Get current context (should exist since Polyscope created one) + ctx = psim.GetCurrentContext() + self.assertIsNotNone(ctx) + + # We don't test CreateContext/DestroyContext/SetCurrentContext here + # because Polyscope manages the context and we don't want to interfere + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_draw_lists(self): + # Test background and foreground draw list access + + def imgui_callback(): + # Get draw lists + bg_list = psim.GetBackgroundDrawList() + fg_list = psim.GetForegroundDrawList() + + self.assertIsNotNone(bg_list) + self.assertIsNotNone(fg_list) + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_misc_utils(self): + # Test miscellaneous utility functions + + def imgui_callback(): + # Test time and frame count + time_val = psim.GetTime() + self.assertIsInstance(time_val, float) + self.assertGreaterEqual(time_val, 0.0) + + frame_count = psim.GetFrameCount() + self.assertIsInstance(frame_count, int) + self.assertGreaterEqual(frame_count, 0) + + # Test rectangle visibility + visible1 = psim.IsRectVisible((100.0, 100.0)) + self.assertIsInstance(visible1, bool) + + visible2 = psim.IsRectVisible((0.0, 0.0), (100.0, 100.0)) + self.assertIsInstance(visible2, bool) + + # Test style color name + color_name = psim.GetStyleColorName(0) + self.assertIsInstance(color_name, str) + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_text_utils(self): + # Test text utility functions + + def imgui_callback(): + # Test text size calculation + text_size = psim.CalcTextSize("Hello World") + self.assertIsInstance(text_size, tuple) + self.assertEqual(len(text_size), 2) + self.assertGreater(text_size[0], 0.0) # width should be positive + self.assertGreater(text_size[1], 0.0) # height should be positive + + # Test with wrap width + text_size_wrapped = psim.CalcTextSize("Hello World", wrap_width=100.0) + self.assertIsInstance(text_size_wrapped, tuple) + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_color_utils(self): + # Test color conversion utilities + + def imgui_callback(): + # Test U32 to Float4 conversion + color_u32 = 0xFF8080FF # RGBA + color_float4 = psim.ColorConvertU32ToFloat4(color_u32) + self.assertIsInstance(color_float4, tuple) + self.assertEqual(len(color_float4), 4) + + # Test Float4 to U32 conversion + color_back = psim.ColorConvertFloat4ToU32(color_float4) + self.assertIsInstance(color_back, int) + + # Test RGB to HSV conversion + hsv = psim.ColorConvertRGBtoHSV(1.0, 0.5, 0.25) + self.assertIsInstance(hsv, tuple) + self.assertEqual(len(hsv), 3) + + # Test HSV to RGB conversion + rgb = psim.ColorConvertHSVtoRGB(hsv[0], hsv[1], hsv[2]) + self.assertIsInstance(rgb, tuple) + self.assertEqual(len(rgb), 3) + # Values should be close to original + self.assertAlmostEqual(rgb[0], 1.0, places=5) + self.assertAlmostEqual(rgb[1], 0.5, places=5) + self.assertAlmostEqual(rgb[2], 0.25, places=5) + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_inputs_keyboard(self): + # Test keyboard input functions + + def imgui_callback(): + # Test key state queries (won't be pressed, but should return valid bools) + is_down = psim.IsKeyDown(psim.ImGuiKey_A) + self.assertIsInstance(is_down, bool) + + is_pressed = psim.IsKeyPressed(psim.ImGuiKey_Space) + self.assertIsInstance(is_pressed, bool) + + is_released = psim.IsKeyReleased(psim.ImGuiKey_Enter) + self.assertIsInstance(is_released, bool) + + # Test key name + key_name = psim.GetKeyName(psim.ImGuiKey_A) + self.assertIsInstance(key_name, str) + + # Test key chord + is_chord = psim.IsKeyChordPressed(psim.ImGuiMod_Ctrl | psim.ImGuiKey_S) + self.assertIsInstance(is_chord, bool) + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_inputs_mouse(self): + # Test mouse input functions + + def imgui_callback(): + # Test mouse button states + is_down = psim.IsMouseDown(psim.ImGuiMouseButton_Left) + self.assertIsInstance(is_down, bool) + + is_clicked = psim.IsMouseClicked(psim.ImGuiMouseButton_Left) + self.assertIsInstance(is_clicked, bool) + + is_released = psim.IsMouseReleased(psim.ImGuiMouseButton_Left) + self.assertIsInstance(is_released, bool) + + is_double_clicked = psim.IsMouseDoubleClicked(psim.ImGuiMouseButton_Left) + self.assertIsInstance(is_double_clicked, bool) + + # Test mouse position + mouse_pos = psim.GetMousePos() + self.assertIsInstance(mouse_pos, tuple) + self.assertEqual(len(mouse_pos), 2) + + # Test mouse position validity + is_valid = psim.IsMousePosValid() + self.assertIsInstance(is_valid, bool) + + # Test mouse dragging + is_dragging = psim.IsMouseDragging(psim.ImGuiMouseButton_Left) + self.assertIsInstance(is_dragging, bool) + + drag_delta = psim.GetMouseDragDelta() + self.assertIsInstance(drag_delta, tuple) + self.assertEqual(len(drag_delta), 2) + + # Test mouse cursor + cursor = psim.GetMouseCursor() + self.assertIsInstance(cursor, int) + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_clipboard(self): + # Test clipboard functions + + def imgui_callback(): + # Set clipboard text + test_text = "Test clipboard content" + psim.SetClipboardText(test_text) + + # Get clipboard text + clipboard_text = psim.GetClipboardText() + self.assertIsInstance(clipboard_text, str) + self.assertEqual(clipboard_text, test_text) + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_io_struct(self): + # Test ImGuiIO struct bindings + + def imgui_callback(): + io = psim.GetIO() + self.assertIsNotNone(io) + + # Test reading some properties + display_size = io.DisplaySize + self.assertIsInstance(display_size, tuple) + self.assertEqual(len(display_size), 2) + + delta_time = io.DeltaTime + self.assertIsInstance(delta_time, float) + self.assertGreater(delta_time, 0.0) + + # Test output state flags + want_capture_mouse = io.WantCaptureMouse + self.assertIsInstance(want_capture_mouse, bool) + + want_capture_keyboard = io.WantCaptureKeyboard + self.assertIsInstance(want_capture_keyboard, bool) + + # Test framerate + framerate = io.Framerate + self.assertIsInstance(framerate, float) + self.assertGreater(framerate, 0.0) + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_style_struct(self): + # Test ImGuiStyle struct bindings + + def imgui_callback(): + style = psim.GetStyle() + self.assertIsNotNone(style) + + # Test reading some properties + alpha = style.Alpha + self.assertIsInstance(alpha, float) + + window_padding = style.WindowPadding + self.assertIsInstance(window_padding, tuple) + self.assertEqual(len(window_padding), 2) + + # Test color access + color_count = style.GetColorCount() + self.assertIsInstance(color_count, int) + self.assertGreater(color_count, 0) + + # Get a color + text_color = style.GetColor(psim.ImGuiCol_Text) + self.assertIsInstance(text_color, tuple) + self.assertEqual(len(text_color), 4) + + # Set a color and get it back + test_color = (0.1, 0.2, 0.3, 0.4) + style.SetColor(psim.ImGuiCol_Text, test_color) + retrieved_color = style.GetColor(psim.ImGuiCol_Text) + for i in range(4): + self.assertAlmostEqual(retrieved_color[i], test_color[i], places=5) + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_fonts(self): + # Test font bindings + + def imgui_callback(): + io = psim.GetIO() + + # Get font atlas + font_atlas = io.Fonts + self.assertIsNotNone(font_atlas) + + # Get default font + font = io.FontDefault + if font is not None: + # Test font properties + is_loaded = font.IsLoaded() + self.assertIsInstance(is_loaded, bool) + + font_size = font.FontSize + self.assertIsInstance(font_size, float) + self.assertGreater(font_size, 0.0) + + # Test text size calculation + text_size = font.CalcTextSizeA(font_size, 1000.0, 0.0, "Test") + self.assertIsInstance(text_size, tuple) + self.assertEqual(len(text_size), 2) + + # Test char advance + advance = font.GetCharAdvance(ord('A')) + self.assertIsInstance(advance, float) + self.assertGreater(advance, 0.0) + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_drawlist_struct(self): + # Test ImDrawList bindings with actual drawing + + def imgui_callback(): + # Get draw lists + bg_list = psim.GetBackgroundDrawList() + fg_list = psim.GetForegroundDrawList() + self.assertIsNotNone(bg_list) + self.assertIsNotNone(fg_list) + + # Test adding various primitives to background + bg_list.AddLine((10.0, 10.0), (100.0, 100.0), 0xFFFFFFFF, thickness=2.0) + bg_list.AddRect((20.0, 20.0), (120.0, 120.0), 0xFF00FFFF, rounding=5.0, thickness=1.0) + bg_list.AddRectFilled((30.0, 30.0), (130.0, 130.0), 0xFF00FF00, rounding=3.0) + bg_list.AddCircle((200.0, 200.0), 50.0, 0xFFFF0000, num_segments=32, thickness=2.0) + bg_list.AddCircleFilled((300.0, 300.0), 30.0, 0xFF0000FF) + bg_list.AddTriangle((400.0, 400.0), (450.0, 400.0), (425.0, 450.0), 0xFFFFFF00, thickness=1.5) + bg_list.AddTriangleFilled((500.0, 500.0), (550.0, 500.0), (525.0, 550.0), 0xFF00FFFF) + bg_list.AddQuad((150.0, 150.0), (180.0, 150.0), (180.0, 180.0), (150.0, 180.0), 0xFFFF00FF, thickness=1.0) + bg_list.AddQuadFilled((160.0, 160.0), (190.0, 160.0), (190.0, 190.0), (160.0, 190.0), 0xFF00FF00) + + # Test text rendering + bg_list.AddText((50.0, 50.0), psim.IM_COL32(255, 255, 255, 255), "Test Text") + + # Test bezier curves + bg_list.AddBezierCubic((600.0, 400.0), (650.0, 350.0), (700.0, 450.0), (750.0, 400.0), 0xFFFFFFFF, thickness=2.0) + bg_list.AddBezierQuadratic((600.0, 500.0), (650.0, 450.0), (700.0, 500.0), 0xFFFF00FF, thickness=2.0) + + # Test polylines + points = np.array([(800.0, 400.0), (850.0, 420.0), (830.0, 460.0), (870.0, 480.0)]) + bg_list.AddPolyline(points, psim.IM_COL32(255, 255, 255, 255), flags=psim.ImDrawFlags_RoundCornersAll, thickness=2.0) + bg_list.AddConvexPolyFilled(points, psim.IM_COL32(0, 255, 255, 255)) + + # Test path API (for custom shapes) + fg_list.PathClear() + fg_list.PathLineTo((100.0, 600.0)) + fg_list.PathLineTo((150.0, 650.0)) + fg_list.PathLineTo((200.0, 600.0)) + fg_list.PathStroke(psim.IM_COL32(255, 0, 0, 255), flags=psim.ImDrawFlags_Closed, thickness=2.0) + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_widgets_basic(self): + # Test basic widget functionality + + def imgui_callback(): + # Test button + if psim.Button("Test Button"): + pass # Button was clicked + + # Test button with size + if psim.Button("Sized Button", (100, 30)): + pass + + # Test small button + if psim.SmallButton("Small"): + pass + + # Test invisible button + if psim.InvisibleButton("invisible", (50, 50)): + pass + + # Test arrow button + if psim.ArrowButton("arrow_left", psim.ImGuiDir_Left): + pass + + # Test checkbox + changed, value = psim.Checkbox("Test Checkbox", True) + self.assertIsInstance(changed, bool) + self.assertIsInstance(value, bool) + + # Test radio button + if psim.RadioButton("Radio A", True): + pass + if psim.RadioButton("Radio B", False): + pass + + # Test progress bar + psim.ProgressBar(0.5) + psim.ProgressBar(0.75, (200, 0), "75%") + + # Test bullet + psim.Bullet() + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_widgets_input(self): + # Test input widgets + + def imgui_callback(): + # Test InputText + changed, text = psim.InputText("Text Input", "initial text") + self.assertIsInstance(changed, bool) + self.assertIsInstance(text, str) + + # Test InputTextMultiline + changed, text = psim.InputTextMultiline("Multiline", "line1\nline2", (200, 100)) + self.assertIsInstance(changed, bool) + self.assertIsInstance(text, str) + + # Test InputTextWithHint + changed, text = psim.InputTextWithHint("With Hint", "enter text here...", "") + self.assertIsInstance(changed, bool) + self.assertIsInstance(text, str) + + # Test InputInt + changed, value = psim.InputInt("Int Input", 42) + self.assertIsInstance(changed, bool) + self.assertIsInstance(value, int) + + # Test InputFloat + changed, value = psim.InputFloat("Float Input", 3.14) + self.assertIsInstance(changed, bool) + self.assertIsInstance(value, float) + + # Test InputFloat2 + changed, values = psim.InputFloat2("Float2", (1.0, 2.0)) + self.assertIsInstance(changed, bool) + self.assertIsInstance(values, tuple) + self.assertEqual(len(values), 2) + + # Test InputFloat3 + changed, values = psim.InputFloat3("Float3", (1.0, 2.0, 3.0)) + self.assertIsInstance(changed, bool) + self.assertIsInstance(values, tuple) + self.assertEqual(len(values), 3) + + # Test InputFloat4 + changed, values = psim.InputFloat4("Float4", (1.0, 2.0, 3.0, 4.0)) + self.assertIsInstance(changed, bool) + self.assertIsInstance(values, tuple) + self.assertEqual(len(values), 4) + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_widgets_sliders(self): + # Test slider widgets + + def imgui_callback(): + # Test SliderFloat + changed, value = psim.SliderFloat("Slider", 0.5, v_min=0.0, v_max=1.0) + self.assertIsInstance(changed, bool) + self.assertIsInstance(value, float) + + # Test SliderFloat with format + changed, value = psim.SliderFloat("Slider %.3f", 0.5, v_min=0.0, v_max=1.0, format="%.3f") + self.assertIsInstance(changed, bool) + + # Test SliderFloat2 + changed, values = psim.SliderFloat2("Slider2", (0.3, 0.7), v_min=0.0, v_max=1.0) + self.assertIsInstance(changed, bool) + self.assertIsInstance(values, tuple) + self.assertEqual(len(values), 2) + + # Test SliderFloat3 + changed, values = psim.SliderFloat3("Slider3", (0.2, 0.5, 0.8), v_min=0.0, v_max=1.0) + self.assertIsInstance(changed, bool) + self.assertEqual(len(values), 3) + + # Test SliderFloat4 + changed, values = psim.SliderFloat4("Slider4", (0.1, 0.3, 0.6, 0.9), v_min=0.0, v_max=1.0) + self.assertIsInstance(changed, bool) + self.assertEqual(len(values), 4) + + # Test SliderInt + changed, value = psim.SliderInt("SliderInt", 50, v_min=0, v_max=100) + self.assertIsInstance(changed, bool) + self.assertIsInstance(value, int) + + # Test SliderAngle + changed, value = psim.SliderAngle("Angle", 0.0) + self.assertIsInstance(changed, bool) + self.assertIsInstance(value, float) + + # Test VSliderFloat + changed, value = psim.VSliderFloat("VSlider", (30, 100), 0.5, v_min=0.0, v_max=1.0) + self.assertIsInstance(changed, bool) + self.assertIsInstance(value, float) + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_widgets_drag(self): + # Test drag widgets + + def imgui_callback(): + # Test DragFloat + changed, value = psim.DragFloat("Drag", 1.0, v_speed=0.1) + self.assertIsInstance(changed, bool) + self.assertIsInstance(value, float) + + # Test DragFloat with range + changed, value = psim.DragFloat("Drag Range", 1.0, v_speed=0.1, v_min=0.0, v_max=10.0) + self.assertIsInstance(changed, bool) + + # Test DragFloat2 + changed, values = psim.DragFloat2("Drag2", (1.0, 2.0)) + self.assertIsInstance(changed, bool) + self.assertEqual(len(values), 2) + + # Test DragFloat3 + changed, values = psim.DragFloat3("Drag3", (1.0, 2.0, 3.0)) + self.assertIsInstance(changed, bool) + self.assertEqual(len(values), 3) + + # Test DragFloat4 + changed, values = psim.DragFloat4("Drag4", (1.0, 2.0, 3.0, 4.0)) + self.assertIsInstance(changed, bool) + self.assertEqual(len(values), 4) + + # Test DragInt + changed, value = psim.DragInt("DragInt", 5, v_speed=1) + self.assertIsInstance(changed, bool) + self.assertIsInstance(value, int) + + # Test DragFloatRange2 + changed, v_min, v_max = psim.DragFloatRange2("Range", 1.0, 5.0) + self.assertIsInstance(changed, bool) + self.assertIsInstance(v_min, float) + self.assertIsInstance(v_max, float) + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_widgets_color(self): + # Test color widgets + + def imgui_callback(): + # Test ColorEdit3 + target_color = (1.0, 0.5, 0.25) + changed, color = psim.ColorEdit3("Color3", target_color) + self.assertIsInstance(changed, bool) + self.assertEqual(len(color), 3) + for i in range(3): + self.assertAlmostEqual(color[i], target_color[i], places=3) + + # Test ColorEdit4 + target_color4 = (1.0, 0.5, 0.25, 0.8) + changed, color = psim.ColorEdit4("Color4", target_color4) + self.assertIsInstance(changed, bool) + self.assertEqual(len(color), 4) + for i in range(4): + self.assertAlmostEqual(color[i], target_color4[i], places=3) + + # Test ColorPicker3 + changed, color = psim.ColorPicker3("Picker3", target_color) + self.assertIsInstance(changed, bool) + self.assertEqual(len(color), 3) + for i in range(3): + self.assertAlmostEqual(color[i], target_color[i], places=3) + + # Test ColorPicker4 + target_color4_picker = (0.5, 0.5, 1.0, 1.0) + changed, color = psim.ColorPicker4("Picker4", target_color4_picker) + self.assertIsInstance(changed, bool) + self.assertEqual(len(color), 4) + for i in range(4): + self.assertAlmostEqual(color[i], target_color4_picker[i], places=3) + + # Test ColorButton + if psim.ColorButton("color_btn", (1.0, 0.0, 0.0, 1.0)): + pass + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_widgets_combo(self): + # Test combo box widgets + + def imgui_callback(): + # Test BeginCombo/EndCombo + if psim.BeginCombo("Combo", "Preview"): + if psim.Selectable("Option 1", False): + pass + if psim.Selectable("Option 2", True): + pass + if psim.Selectable("Option 3", False): + pass + psim.EndCombo() + + # Test ListBox + if psim.BeginListBox("ListBox"): + if psim.Selectable("Item 1", False): + pass + if psim.Selectable("Item 2", True): + pass + if psim.Selectable("Item 3", False): + pass + psim.EndListBox() + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_widgets_trees(self): + # Test tree widgets + + def imgui_callback(): + # Test TreeNode + if psim.TreeNode("Tree Node"): + psim.TextUnformatted("Child content") + if psim.TreeNode("Nested Node"): + psim.TextUnformatted("Nested content") + psim.TreePop() + psim.TreePop() + + # Test CollapsingHeader + if psim.CollapsingHeader("Collapsing Header"): + psim.TextUnformatted("Header content") + + # Test with flags + if psim.CollapsingHeader("Header with Flags", psim.ImGuiTreeNodeFlags_DefaultOpen): + psim.TextUnformatted("Content") + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_layout_and_cursor(self): + # Test layout and cursor positioning + + def imgui_callback(): + # Test SameLine + psim.TextUnformatted("Text1") + psim.SameLine() + psim.TextUnformatted("Text2") + + # Test NewLine + psim.NewLine() + + # Test Spacing + psim.Spacing() + + # Test Separator + psim.Separator() + + # Test Indent/Unindent + psim.Indent() + psim.TextUnformatted("Indented text") + psim.Unindent() + + # Test cursor position + psim.SetCursorPos((100.0, 100.0)) + psim.Dummy((5,5)) + pos = psim.GetCursorPos() + self.assertIsInstance(pos, tuple) + self.assertEqual(len(pos), 2) + + # Test cursor screen position + screen_pos = psim.GetCursorScreenPos() + self.assertIsInstance(screen_pos, tuple) + self.assertEqual(len(screen_pos), 2) + + # Test content region + avail = psim.GetContentRegionAvail() + self.assertIsInstance(avail, tuple) + self.assertEqual(len(avail), 2) + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_windows(self): + # Test window functions + + def imgui_callback(): + # Test Begin/End + if psim.Begin("Test Window"): + psim.TextUnformatted("Window content") + psim.End() + + # Test Begin with close button + opened, should_close = psim.Begin("Window with Close", True) + if opened: + psim.TextUnformatted("Content") + psim.End() + + # Test window with flags + if psim.Begin("Window with Flags", flags=psim.ImGuiWindowFlags_NoResize): + psim.TextUnformatted("No resize") + psim.End() + + # Test child window + if psim.BeginChild("ChildWindow", (200, 100)): + psim.TextUnformatted("Child content") + psim.EndChild() + + # Test window queries + is_focused = psim.IsWindowFocused() + self.assertIsInstance(is_focused, bool) + + is_hovered = psim.IsWindowHovered() + self.assertIsInstance(is_hovered, bool) + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_tooltips_and_popups(self): + # Test tooltips and popups + + def imgui_callback(): + # Test tooltip + psim.TextUnformatted("Hover me") + if psim.IsItemHovered(): + psim.BeginTooltip() + psim.TextUnformatted("This is a tooltip") + psim.EndTooltip() + + # Test SetTooltip + psim.TextUnformatted("Hover me too") + if psim.IsItemHovered(): + psim.SetTooltip("Simple tooltip") + + # Test popup + if psim.Button("Open Popup"): + psim.OpenPopup("test_popup") + + if psim.BeginPopup("test_popup"): + psim.TextUnformatted("Popup content") + if psim.Button("Close"): + psim.CloseCurrentPopup() + psim.EndPopup() + + # Test modal popup + if psim.Button("Open Modal"): + psim.OpenPopup("modal_popup") + + if psim.BeginPopupModal("modal_popup"): + psim.TextUnformatted("Modal content") + if psim.Button("OK"): + psim.CloseCurrentPopup() + psim.EndPopup() + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_menus(self): + # Test menu functions + + def imgui_callback(): + if psim.BeginMenuBar(): + if psim.BeginMenu("File"): + if psim.MenuItem("New"): + pass + if psim.MenuItem("Open"): + pass + psim.Separator() + if psim.MenuItem("Exit"): + pass + psim.EndMenu() + + if psim.BeginMenu("Edit"): + if psim.MenuItem("Undo"): + pass + if psim.MenuItem("Redo"): + pass + psim.EndMenu() + + psim.EndMenuBar() + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_payload_struct(self): + # Test ImGuiPayload bindings + + def imgui_callback(): + # Create a simple drag/drop scenario + if psim.BeginDragDropSource(): + # In a real scenario, you'd set payload data here + # We just test that the structure exists + psim.EndDragDropSource() + + # Test getting payload during drag/drop + if psim.BeginDragDropTarget(): + payload = psim.AcceptDragDropPayload("TEST_TYPE") + if payload is not None: + # Test payload methods + data_size = payload.DataSize + self.assertIsInstance(data_size, int) + + is_preview = payload.IsPreview() + self.assertIsInstance(is_preview, bool) + + is_delivery = payload.IsDelivery() + self.assertIsInstance(is_delivery, bool) + + psim.EndDragDropTarget() + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_viewport_struct(self): + # Test ImGuiViewport bindings + + def imgui_callback(): + # Get main viewport + viewport = psim.GetMainViewport() + self.assertIsNotNone(viewport) + + # Test viewport properties + viewport_id = viewport.ID + self.assertIsInstance(viewport_id, int) + + flags = viewport.Flags + self.assertIsInstance(flags, int) + + pos = viewport.Pos + self.assertIsInstance(pos, tuple) + self.assertEqual(len(pos), 2) + + size = viewport.Size + self.assertIsInstance(size, tuple) + self.assertEqual(len(size), 2) + + work_pos = viewport.WorkPos + self.assertIsInstance(work_pos, tuple) + self.assertEqual(len(work_pos), 2) + + work_size = viewport.WorkSize + self.assertIsInstance(work_size, tuple) + self.assertEqual(len(work_size), 2) + + # Test helper methods + center = viewport.GetCenter() + self.assertIsInstance(center, tuple) + self.assertEqual(len(center), 2) + + work_center = viewport.GetWorkCenter() + self.assertIsInstance(work_center, tuple) + self.assertEqual(len(work_center), 2) + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_table_sorting(self): + # Test table sorting specs + + def imgui_callback(): + if psim.BeginTable("test_table", 3, psim.ImGuiTableFlags_Sortable): + psim.TableSetupColumn("Column A", psim.ImGuiTableColumnFlags_DefaultSort) + psim.TableSetupColumn("Column B") + psim.TableSetupColumn("Column C") + psim.TableHeadersRow() + + # Get sort specs + sort_specs = psim.TableGetSortSpecs() + if sort_specs is not None: + # Test sort specs properties + specs_count = sort_specs.SpecsCount + self.assertIsInstance(specs_count, int) + + specs_dirty = sort_specs.SpecsDirty + self.assertIsInstance(specs_dirty, bool) + + # Get specs list + specs_list = sort_specs.Specs() + self.assertIsInstance(specs_list, list) + + if len(specs_list) > 0: + spec = specs_list[0] + # Test column sort spec properties + col_id = spec.ColumnUserID + self.assertIsInstance(col_id, int) + + col_index = spec.ColumnIndex + self.assertIsInstance(col_index, int) + + sort_order = spec.SortOrder + self.assertIsInstance(sort_order, int) + + sort_direction = spec.SortDirection + + # Add some dummy rows + for i in range(3): + psim.TableNextRow() + psim.TableNextColumn() + psim.TextUnformatted(f"A{i}") + psim.TableNextColumn() + psim.TextUnformatted(f"B{i}") + psim.TableNextColumn() + psim.TextUnformatted(f"C{i}") + + psim.EndTable() + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + + def test_combined_1(self): + + # (this is the example from the demo and the docs) + + # A bunch of parameters which we will maniuplate via the UI defined below. + # There is nothing special about these variables, you could manipulate any other + # kind of Python values the same way, such as entries in a dict, or class members. + is_true1 = False + is_true2 = True + ui_int = 7 + ui_float1 = -3.2 + ui_float2 = 0.8 + ui_color3 = (1., 0.5, 0.5) + ui_color4 = (0.3, 0.5, 0.5, 0.8) + ui_angle_rad = 0.2 + ui_text = "some input text" + ui_options = ["option A", "option B", "option C"] + ui_options_selected = ui_options[1] + + def my_function(): + # ... do something important here ... + pass + + # Define our callback function, which Polyscope will repeatedly execute while running the UI. + # We can write any code we want here, but in particular it is an opportunity to create ImGui + # interface elements and define a custom UI. + def imgui_callback(): + + # If we want to use local variables & assign to them in the UI code below, we need to mark them as nonlocal. This is because of how Python scoping rules work, not anything particular about Polyscope or ImGui. + # Of course, you can also use any other kind of python variable as a controllable value in the UI, such as a value from a dictionary, or a class member. Just be sure to assign the result of the ImGui call to the value, as in the examples below. + nonlocal is_true1, is_true2, ui_int, ui_float1, ui_float2, ui_color3, ui_color4, ui_text, ui_options_selected, ui_angle_rad + + + # == Settings + + # Use settings like this to change the UI appearance. + # Note that it is a push/pop pair, with the matching pop() below. + psim.PushItemWidth(150) + + # == Show text in the UI + + psim.TextUnformatted("Some sample text") + psim.TextUnformatted("An important value: {}".format(42)) + psim.Separator() + + # == Buttons + + if(psim.Button("A button")): + # This code is executed when the button is pressed + print("Hello") + + # By default, each element goes on a new line. Use this + # to put the next element on the _same_ line. + psim.SameLine() + + if(psim.Button("Another button")): + # This code is executed when the button is pressed + my_function() + + + # == Set parameters + + # These commands allow the user to adjust the value of variables. + # It is important that we assign the return result to the variable to + # update it. + # For most elements, the return is actually a tuple `(changed, newval)`, + # where `changed` indicates whether the setting was modified on this + # frame, and `newval` gives the new value of the variable (or the same + # old value if unchanged). + # + # For numeric inputs, ctrl-click on the box to type in a value. + + # Checkbox + changed, is_true1 = psim.Checkbox("flag1", is_true1) + if(changed): # optionally, use this conditional to take action on the new value + pass + psim.SameLine() + changed, is_true2 = psim.Checkbox("flag2", is_true2) + + # Input ints + changed, ui_int = psim.InputInt("ui_int", ui_int, step=1, step_fast=10) + + # Input floats using two different styles of widget + changed, ui_float1 = psim.InputFloat("ui_float1", ui_float1) + psim.SameLine() + changed, ui_float2 = psim.SliderFloat("ui_float2", ui_float2, v_min=-5, v_max=5) + + # Input colors + changed, ui_color3 = psim.ColorEdit3("ui_color3", ui_color3) + psim.SameLine() + changed, ui_color4 = psim.ColorEdit4("ui_color4", ui_color4) + + # Input text + changed, ui_text = psim.InputText("enter text", ui_text) + + # Combo box to choose from options + # There, the options are a list of strings in `ui_options`, + # and the currently selected element is stored in `ui_options_selected`. + psim.PushItemWidth(200) + changed = psim.BeginCombo("Pick one", ui_options_selected) + if changed: + for val in ui_options: + if psim.Selectable(val, ui_options_selected==val): + ui_options_selected = val + psim.EndCombo() + psim.PopItemWidth() + + + # Use tree headers to logically group options + + # This a stateful option to set the tree node below to be open initially. + # The second argument is a flag, which works like a bitmask. + # Many ImGui elements accept flags to modify their behavior. + psim.SetNextItemOpen(True, psim.ImGuiCond_FirstUseEver) + + # The body is executed only when the sub-menu is open. Note the push/pop pair! + if(psim.TreeNode("Collapsible sub-menu")): + + psim.TextUnformatted("Detailed information") + + if(psim.Button("sub-button")): + print("hello") + + # There are many different UI elements offered by ImGui, many of which + # are bound in python by Polyscope. See ImGui's documentation in `imgui.h`, + # or the polyscope bindings in `polyscope/src/cpp/imgui.cpp`. + changed, ui_angle_rad = psim.SliderAngle("ui_float2", ui_angle_rad, + v_degrees_min=-90, v_degrees_max=90) + + psim.TreePop() + + psim.PopItemWidth() + + + ps.set_user_callback(imgui_callback) + ps.show(3) + + ps.clear_user_callback() + \ No newline at end of file diff --git a/test/tests/test_implot.py b/test/tests/test_implot.py new file mode 100644 index 0000000..bf3bd25 --- /dev/null +++ b/test/tests/test_implot.py @@ -0,0 +1,450 @@ +from os import listdir +import os.path as path +from os.path import isfile, join +import unittest + +import numpy as np + +import polyscope as ps +import polyscope.imgui as psim +import polyscope.implot as psimplot + +class TestImPlotBindings(unittest.TestCase): + + def test_plot_line(self): + def imgui_callback(): + psim.SetCursorPos((0,0)) + psim.Dummy((5,5)) + if psimplot.BeginPlot("line plot"): + psimplot.PlotLine("line1", np.random.rand(10)) + psimplot.PlotLine("line2", np.random.rand(10), np.random.rand(10)) + psimplot.PlotLine("line3", np.random.rand(10), psimplot.ImPlotLineFlags_Shaded) + psimplot.EndPlot() + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_plot_scatter(self): + def imgui_callback(): + psim.SetCursorPos((0,0)) + psim.Dummy((5,5)) + if psimplot.BeginPlot("scatter plot"): + psimplot.PlotScatter("scatter1", np.random.rand(10)) + psimplot.PlotScatter("scatter2", np.random.rand(10), np.random.rand(10)) + psimplot.PlotScatter("scatter3", np.random.rand(10), psimplot.ImPlotScatterFlags_NoClip) + psimplot.EndPlot() + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_plot_stairs(self): + def imgui_callback(): + psim.SetCursorPos((0,0)) + psim.Dummy((5,5)) + if psimplot.BeginPlot("stairs plot"): + psimplot.PlotStairs("stairs1", np.random.rand(10)) + psimplot.PlotStairs("stairs2", np.random.rand(10), np.random.rand(10)) + psimplot.PlotStairs("stairs3", np.random.rand(10), psimplot.ImPlotStairsFlags_Shaded) + psimplot.EndPlot() + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_plot_shaded(self): + def imgui_callback(): + psim.SetCursorPos((0,0)) + psim.Dummy((5,5)) + if psimplot.BeginPlot("shaded plot"): + psimplot.PlotShaded("shaded1", np.random.rand(10)) + psimplot.PlotShaded("shaded2", np.random.rand(10), yref=1.0) + psimplot.PlotShaded("shaded3", np.random.rand(10), np.random.rand(10)) + psimplot.PlotShaded("shaded4", np.random.rand(10), np.random.rand(10), np.random.rand(10)) + psimplot.EndPlot() + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_plot_bars(self): + def imgui_callback(): + psim.SetCursorPos((0,0)) + psim.Dummy((5,5)) + if psimplot.BeginPlot("bars plot"): + psimplot.PlotBars("bars1", np.random.rand(10)) + psimplot.PlotBars("bars2", np.random.rand(10), np.random.rand(10), 0.67) + psimplot.EndPlot() + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_plot_bar_groups(self): + def imgui_callback(): + psim.SetCursorPos((0,0)) + psim.Dummy((5,5)) + if psimplot.BeginPlot("bar groups plot"): + data = np.random.rand(3, 5) + psimplot.PlotBarGroups(["A", "B", "C"], data) + psimplot.EndPlot() + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_plot_error_bars(self): + def imgui_callback(): + psim.SetCursorPos((0,0)) + psim.Dummy((5,5)) + if psimplot.BeginPlot("error bars plot"): + xs = np.random.rand(10) + ys = np.random.rand(10) + err = np.random.rand(10) * 0.1 + psimplot.PlotErrorBars("error1", xs, ys, err) + psimplot.PlotErrorBars("error2", xs, ys, err, err) + psimplot.EndPlot() + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_plot_stems(self): + def imgui_callback(): + psim.SetCursorPos((0,0)) + psim.Dummy((5,5)) + if psimplot.BeginPlot("stems plot"): + psimplot.PlotStems("stems1", np.random.rand(10)) + psimplot.PlotStems("stems2", np.random.rand(10), np.random.rand(10)) + psimplot.EndPlot() + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_plot_inf_lines(self): + def imgui_callback(): + psim.SetCursorPos((0,0)) + psim.Dummy((5,5)) + if psimplot.BeginPlot("inf lines plot"): + psimplot.PlotInfLines("vlines", np.random.rand(3)) + psimplot.PlotInfLines("hlines", np.random.rand(3), psimplot.ImPlotInfLinesFlags_Horizontal) + psimplot.EndPlot() + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_plot_pie_chart(self): + def imgui_callback(): + psim.SetCursorPos((0,0)) + psim.Dummy((5,5)) + if psimplot.BeginPlot("pie chart plot"): + psimplot.PlotPieChart(["cat1", "cat2", "cat3"], np.random.rand(3), 0.5, 0.5, 0.5) + psimplot.PlotPieChart(["A", "B"], np.random.rand(2), x=2., y=3., radius=4.) + psimplot.EndPlot() + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_plot_heatmap(self): + def imgui_callback(): + psim.SetCursorPos((0,0)) + psim.Dummy((5,5)) + if psimplot.BeginPlot("heatmap plot"): + data = np.random.rand(5, 10) + psimplot.PlotHeatmap("heatmap", data) + psimplot.EndPlot() + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_plot_histogram(self): + def imgui_callback(): + psim.SetCursorPos((0,0)) + psim.Dummy((5,5)) + if psimplot.BeginPlot("histogram plot"): + psimplot.PlotHistogram("hist1", np.random.rand(100)) + psimplot.PlotHistogram("hist2", np.random.rand(100), bins=20) + psimplot.EndPlot() + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_plot_histogram_2d(self): + def imgui_callback(): + psim.SetCursorPos((0,0)) + psim.Dummy((5,5)) + if psimplot.BeginPlot("histogram 2d plot"): + psimplot.PlotHistogram2D("hist2d", np.random.rand(100), np.random.rand(100)) + psimplot.EndPlot() + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_plot_digital(self): + def imgui_callback(): + psim.SetCursorPos((0,0)) + psim.Dummy((5,5)) + if psimplot.BeginPlot("digital plot"): + xs = np.linspace(0, 10, 100) + ys = (np.sin(xs) > 0).astype(float) + psimplot.PlotDigital("digital", xs, ys) + psimplot.EndPlot() + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_plot_text(self): + def imgui_callback(): + psim.SetCursorPos((0,0)) + psim.Dummy((5,5)) + if psimplot.BeginPlot("text plot"): + psimplot.PlotText("Hello", 0.5, 0.5) + psimplot.EndPlot() + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_plot_dummy(self): + def imgui_callback(): + psim.SetCursorPos((0,0)) + psim.Dummy((5,5)) + if psimplot.BeginPlot("dummy plot"): + psimplot.PlotDummy("dummy") + psimplot.EndPlot() + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_plot_tools(self): + def imgui_callback(): + psim.SetCursorPos((0,0)) + psim.Dummy((5,5)) + if psimplot.BeginPlot("tools plot"): + result, x, y = psimplot.DragPoint(0, 0.5, 0.5, (1, 0, 0, 1)) + result, x = psimplot.DragLineX(1, 0.3, (0, 1, 0, 1)) + result, y = psimplot.DragLineY(2, 0.7, (0, 0, 1, 1)) + result, x1, y1, x2, y2 = psimplot.DragRect(3, 0.2, 0.2, 0.8, 0.8, (1, 1, 0, 1)) + + psimplot.Annotation(0.5, 0.5, (1, 0, 1, 1), (0, 0), True) + psimplot.Annotation(0.3, 0.7, (0, 1, 1, 1), (10, 10), True, "Note") + + psimplot.TagX(0.5, (1, 0, 0, 1)) + psimplot.TagY(0.5, (0, 1, 0, 1)) + + psimplot.EndPlot() + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_plot_utils(self): + def imgui_callback(): + psim.SetCursorPos((0,0)) + psim.Dummy((5,5)) + if psimplot.BeginPlot("utils plot"): + psimplot.SetAxis(psimplot.ImAxis_X1) + psimplot.SetAxes(psimplot.ImAxis_X1, psimplot.ImAxis_Y1) + + px, py = psimplot.PixelsToPlot((100, 100)) + px, py = psimplot.PixelsToPlot(100, 100) + + px, py = psimplot.PlotToPixels((0.5, 0.5)) + px, py = psimplot.PlotToPixels(0.5, 0.5) + + pos = psimplot.GetPlotPos() + size = psimplot.GetPlotSize() + mouse_pos = psimplot.GetPlotMousePos() + xmin, xmax, ymin, ymax = psimplot.GetPlotLimits() + + is_hovered = psimplot.IsPlotHovered() + is_axis_hovered = psimplot.IsAxisHovered(psimplot.ImAxis_X1) + + psimplot.EndPlot() + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_legend_utils(self): + def imgui_callback(): + psim.SetCursorPos((0,0)) + psim.Dummy((5,5)) + if psimplot.BeginPlot("legend plot"): + psimplot.PlotLine("line", np.random.rand(10)) + + if psimplot.BeginLegendPopup("line"): + psim.Text("Legend popup") + psimplot.EndLegendPopup() + + is_hovered = psimplot.IsLegendEntryHovered("line") + + psimplot.EndPlot() + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_styling(self): + def imgui_callback(): + # Get and modify style + style = psimplot.GetStyle() + style.LineWeight = 2.0 + style.MarkerSize = 5.0 + + # Style colors + psimplot.StyleColorsDark() + + # Push/pop style colors + psimplot.PushStyleColor(psimplot.ImPlotCol_Line, (1, 0, 0, 1)) + psim.SetCursorPos((0,0)) + psim.Dummy((5,5)) + if psimplot.BeginPlot("styled plot"): + psimplot.PlotLine("red line", np.random.rand(10)) + psimplot.EndPlot() + psimplot.PopStyleColor() + + # Push/pop style vars + psimplot.PushStyleVar(psimplot.ImPlotStyleVar_LineWeight, 3.0) + psim.SetCursorPos((0,0)) + psim.Dummy((5,5)) + if psimplot.BeginPlot("thick plot"): + psimplot.PlotLine("thick line", np.random.rand(10)) + psimplot.EndPlot() + psimplot.PopStyleVar() + + # Set next item styles + psimplot.SetNextLineStyle((0, 1, 0, 1), 2.0) + psimplot.SetNextFillStyle((0, 0, 1, 0.5)) + psimplot.SetNextMarkerStyle(psimplot.ImPlotMarker_Circle, 8.0) + + psim.SetCursorPos((0,0)) + psim.Dummy((5,5)) + if psimplot.BeginPlot("next style plot"): + psimplot.PlotLine("styled line", np.random.rand(10)) + psimplot.EndPlot() + + # Color names + name = psimplot.GetStyleColorName(psimplot.ImPlotCol_Line) + marker_name = psimplot.GetMarkerName(psimplot.ImPlotMarker_Circle) + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_colormaps(self): + + # Add custom colormap + colors = [(1, 0, 0, 1), (0, 1, 0, 1), (0, 0, 1, 1)] + cmap = psimplot.AddColormap("custom", colors) + + def imgui_callback(): + + # Colormap info + count = psimplot.GetColormapCount() + name = psimplot.GetColormapName(psimplot.ImPlotColormap_Deep) + idx = psimplot.GetColormapIndex("Deep") + + # Push/pop colormap + psimplot.PushColormap(psimplot.ImPlotColormap_Viridis) + psim.SetCursorPos((0,0)) + psim.Dummy((5,5)) + if psimplot.BeginPlot("colormap plot"): + for i in range(5): + color = psimplot.NextColormapColor() + psimplot.PlotLine(f"line{i}", np.random.rand(10)) + psimplot.EndPlot() + psimplot.PopColormap() + + # Colormap utils + size = psimplot.GetColormapSize() + color = psimplot.GetColormapColor(0) + sampled = psimplot.SampleColormap(0.5) + + # Colormap widgets + psim.SetCursorPos((0,0)) + psim.Dummy((5,5)) + if psimplot.BeginPlot("colormap widgets"): + psimplot.ColormapScale("scale", 0.0, 1.0, (60, 200)) + psimplot.EndPlot() + + result, t, color = psimplot.ColormapSlider("slider", 0.5) + button_pressed = psimplot.ColormapButton("button") + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_input_mapping(self): + def imgui_callback(): + # Get and modify input map + input_map = psimplot.GetInputMap() + input_map.ZoomRate = 0.2 + + # Map defaults + psimplot.MapInputDefault() + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_misc(self): + def imgui_callback(): + # Item icons + psimplot.ItemIcon((1, 0, 0, 1)) + psimplot.ColormapIcon(psimplot.ImPlotColormap_Viridis) + + # Selectors + psimplot.ShowStyleSelector("Style") + psimplot.ShowColormapSelector("Colormap") + psimplot.ShowInputMapSelector("Input Map") + + # User guide + if psim.CollapsingHeader("User Guide"): + psimplot.ShowUserGuide() + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_subplots(self): + def imgui_callback(): + psim.SetCursorPos((0,0)) + psim.Dummy((5,5)) + if psimplot.BeginSubplots("subplots", 2, 3, (800, 400)): + for i in range(6): + if psimplot.BeginPlot(f"subplot_{i}"): + psimplot.PlotLine("line", np.random.rand(10)) + psimplot.EndPlot() + psimplot.EndSubplots() + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback() + + def test_setup_axes(self): + def imgui_callback(): + psim.SetCursorPos((0,0)) + psim.Dummy((5,5)) + if psimplot.BeginPlot("setup plot"): + psimplot.SetupAxes("X Axis", "Y Axis") + psimplot.SetupAxis(psimplot.ImAxis_X1, "Time") + psimplot.SetupAxisLimits(psimplot.ImAxis_X1, 0, 10) + psimplot.SetupAxisFormat(psimplot.ImAxis_Y1, "%.2f") + psimplot.SetupAxisTicks(psimplot.ImAxis_X1, 0, 10, 11) + + psimplot.PlotLine("data", np.random.rand(10)) + psimplot.EndPlot() + + ps.set_user_callback(imgui_callback) + ps.show(3) + ps.clear_user_callback()