mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-21 20:25:20 +00:00
Update eigen to v5.0.1 and libigl to v2.6.0. (#11311)
* Update eigen from v3.3.7 to v5.0.1. This updates eigen from v3.3.7 released on December 11, 2018-12-11 to v5.0.1 released on 2025-11-11. There have be a large number of bug-fixes, optimizations, and improvements between these releases. See the details at; https://gitlab.com/libeigen/eigen/-/releases It retains the previous custom minimal `CMakeLists.txt`, and adds a README-OrcaSlicer.md that explains what version and parts of the upstream eigen release have been included, and where the full release can be found. * Update libigl from v2.0.0 (or older) to v2.6.0. This updates libigl from what was probably v2.0.0 released on 2018-10-16 to v2.6.0 released on 2025-05-15. It's possible the old version was even older than that but there is no version indicators in the code and I ran out of patience identifying missing changes and only went back as far as v2.0.0. There have been a large number of bug-fixes, optimizations, and improvements between these versions. See the following for details; https://github.com/libigl/libigl/releases I retained the minimal custom `CMakeLists.txt`, added `README.md` from the libigl distribution which identifies the version, and added a README-OrcaSlicer.md that details the version and parts that have been included. * Update libslic3r for libigl v2.6.0 changes. This updates libslic3r for all changes moving to eigen v5.0.1 and libigl v2.6.0. Despite the large number of updates to both dependencies, no changes were required for the eigen update, and only one change was required for the libigl update. For libigl, `igl::Hit` was changed to a template taking the Scalar type to use. Previously it was hard-coded to `float`, so to minimize possible impact I've updated all places it is used from `igl::Hit` to `igl::Hit<float>`. * Add compiler option `-DNOMINMAX` for libigl with MSVC. MSVC by default defines `min(()` and `max()` macros that break `std::numeric_limits<>::max()`. The upstream cmake that we don't include adds `-DNOMINMAX` for the libigl module when compiling with MSVC, so we need to add the same thing here. * Fix src/libslic3r/TriangleMeshDeal.cpp for the unmodified upstream libigl. This fixes `TriangleMeshDeal.cpp` to work with the unmodified upstream libigl v2.6.0. loop.{h,cpp} implementation. This file and feature was added in PR "BBS Port: Mesh Subdivision" (#12150) which included changes to `loop.{h,cpp}` in the old version of libigl. This PR avoids modifying the included dependencies, and uses the updated upstream versions of those files without any modifications, which requires fixing TriangleMeshDeal.cpp to work with them. In particular, the modifications made to `loop.{h,cpp}` included changing the return type from void to bool, adding additional validation checking of the input meshes, and returning false if they failed validation. These added checks looked unnecessary and would only have caught problems if the input mesh was very corrupt. To make `TriangleMeshDeal.cpp` work without this built-in checking functionality, I removed checking/handling of any `false` return value. There was also a hell of a lot of redundant copying and casting back and forth between float and double, so I cleaned that up. The input and output meshs use floats for the vertexes, and there would be no accuracy benefits from casting to and from doubles for the simple weighted average operations done by igl::loop(). So this just uses `Eigen:Map` to use the original input mesh vertex data directly without requiring any copy or casting. * Move eigen from included `deps_src` to externaly fetched `deps`. This copys what PrusaSlicer did and moved it from an included dependency under `deps_src` to an externaly fetched dependency under `deps`. This requires updating some `CMakeList.txt` configs and removing the old and obsolete `cmake/modules/FindEigen3.cmake`. The details of when this was done in PrusaSlicer and the followup fixes are at; *21116995d7* https://github.com/prusa3d/PrusaSlicer/issues/13608 * https://github.com/prusa3d/PrusaSlicer/pull/13609 *e3c277b9eeFor some reason I don't fully understand this also required fixing `src/slic3r/GUI/GUI_App.cpp` by adding `#include <boost/nowide/cstdio.hpp>` to fix an `error: ‘remove’ is not a member of ‘boost::nowide'`. The main thing I don't understand is how it worked before. Note that this include is in the PrusaSlicer version of this file, but it also significantly deviates from what is currently in OrcaSlicer in many other ways. * Whups... I missed adding the deps/Eigen/Eigen.cmake file... * Tidy some whitespace indenting in CMakeLists.txt. * Ugh... tabs indenting needing fixes. * Change the include order of deps/Eigen. It turns out that although Boost includes some references to Eigen, Eigen also includes some references to Boost for supporting some of it's additional numeric types. I don't think it matters much since we are not using these features, but I think technically its more correct to say Eigen depends on Boost than the other way around, so I've re-ordered them. * Add source for Eigen 5.0.1 download to flatpak yml config. * Add explicit `DEPENDS dep_Boost to deps/Eigen. I missed this before. This ensures we don't rely on include orders to make sure Boost is installed before we configure Eigen. * Add `DEPENDS dep_Boost dep_GMP dep_MPFR` to deps/Eigen. It turns out Eigen can also use GMP and MPFR for multi-precision and multi-precision-rounded numeric types if they are available. Again, I don't think we are using these so it doesn't really matter, but it is technically correct and ensures they are there if we ever do need them. * Fix deps DEPENDENCY ordering for GMP, MPFR, Eigen, and CGAL. I think this is finally correct. Apparently CGAL also optionally depends on Eigen, so the correct dependency order from lowest to highest is GMP, MPFR, Eigen, and CGAL. --------- Co-authored-by: Donovan Baarda <dbaarda@google.com> Co-authored-by: Noisyfox <timemanager.rick@gmail.com>
This commit is contained in:
@@ -9,11 +9,13 @@
|
||||
#define IGL_OPENGL_GLFW_IMGUI_IMGUIHELPERS_H
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include <imgui/imgui.h>
|
||||
#include "ImGuiTraits.h"
|
||||
#include <imgui.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <cstddef>
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Extend ImGui by populating its namespace directly
|
||||
@@ -25,38 +27,38 @@ namespace ImGui
|
||||
|
||||
static auto vector_getter = [](void* vec, int idx, const char** out_text)
|
||||
{
|
||||
auto& vector = *static_cast<std::vector<std::string>*>(vec);
|
||||
if (idx < 0 || idx >= static_cast<int>(vector.size())) { return false; }
|
||||
*out_text = vector.at(idx).c_str();
|
||||
return true;
|
||||
auto& vector = *static_cast<std::vector<std::string>*>(vec);
|
||||
if (idx < 0 || idx >= static_cast<int>(vector.size())) { return false; }
|
||||
*out_text = vector.at(idx).c_str();
|
||||
return true;
|
||||
};
|
||||
|
||||
inline bool Combo(const char* label, int* idx, std::vector<std::string>& values)
|
||||
{
|
||||
if (values.empty()) { return false; }
|
||||
return Combo(label, idx, vector_getter,
|
||||
static_cast<void*>(&values), values.size());
|
||||
if (values.empty()) { return false; }
|
||||
return Combo(label, idx, vector_getter,
|
||||
static_cast<void*>(&values), values.size());
|
||||
}
|
||||
|
||||
inline bool Combo(const char* label, int* idx, std::function<const char *(int)> getter, int items_count)
|
||||
{
|
||||
auto func = [](void* data, int i, const char** out_text) {
|
||||
auto &getter = *reinterpret_cast<std::function<const char *(int)> *>(data);
|
||||
const char *s = getter(i);
|
||||
if (s) { *out_text = s; return true; }
|
||||
else { return false; }
|
||||
};
|
||||
return Combo(label, idx, func, reinterpret_cast<void *>(&getter), items_count);
|
||||
auto func = [](void* data, int i, const char** out_text) {
|
||||
auto &getter = *reinterpret_cast<std::function<const char *(int)> *>(data);
|
||||
const char *s = getter(i);
|
||||
if (s) { *out_text = s; return true; }
|
||||
else { return false; }
|
||||
};
|
||||
return Combo(label, idx, func, reinterpret_cast<void *>(&getter), items_count);
|
||||
}
|
||||
|
||||
inline bool ListBox(const char* label, int* idx, std::vector<std::string>& values)
|
||||
{
|
||||
if (values.empty()) { return false; }
|
||||
return ListBox(label, idx, vector_getter,
|
||||
static_cast<void*>(&values), values.size());
|
||||
if (values.empty()) { return false; }
|
||||
return ListBox(label, idx, vector_getter,
|
||||
static_cast<void*>(&values), values.size());
|
||||
}
|
||||
|
||||
inline bool InputText(const char* label, std::string &str, ImGuiInputTextFlags flags = 0, ImGuiTextEditCallback callback = NULL, void* user_data = NULL)
|
||||
inline bool InputText(const char* label, std::string &str, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL)
|
||||
{
|
||||
char buf[1024];
|
||||
std::fill_n(buf, 1024, 0);
|
||||
@@ -69,6 +71,45 @@ inline bool InputText(const char* label, std::string &str, ImGuiInputTextFlags f
|
||||
return false;
|
||||
}
|
||||
|
||||
// template<typename T>
|
||||
// inline bool DragScalar(const char *label, T* value, void* v, float v_speed, const void* v_min = NULL, const void* v_max = NULL, const char* format = NULL, float power = 1.0f)
|
||||
// {
|
||||
// const char *fmt = format;
|
||||
// if (format == nullptr) {
|
||||
// fmt = ImGuiDataTypeTraits<T>::format;
|
||||
// }
|
||||
// return DragScalar(label, ImGuiDataTypeTraits<T>::value, value, &min, &max, fmt);
|
||||
// }
|
||||
|
||||
// template<typename T>
|
||||
// inline bool InputScalar(const char *label, T* value, T min = 0, T max = 0, const char* format = nulltptr)
|
||||
// {
|
||||
// const char *fmt = format;
|
||||
// if (format == nullptr) {
|
||||
// fmt = ImGuiDataTypeTraits<T>::format;
|
||||
// }
|
||||
// return InputScalar(label, ImGuiDataTypeTraits<T>::value, value, &min, &max, fmt);
|
||||
// }
|
||||
|
||||
template<typename T>
|
||||
inline bool SliderScalar(const char *label, T* value, T min = 0, T max = 0, const char* format = "")
|
||||
{
|
||||
const char *fmt = format;
|
||||
if (format == nullptr) {
|
||||
fmt = ImGuiDataTypeTraits<T>::format;
|
||||
}
|
||||
return SliderScalar(label, ImGuiDataTypeTraits<T>::value, value, &min, &max, fmt);
|
||||
}
|
||||
|
||||
template<typename Getter, typename Setter>
|
||||
inline bool Checkbox(const char* label, Getter get, Setter set)
|
||||
{
|
||||
bool value = get();
|
||||
bool ret = ImGui::Checkbox(label, &value);
|
||||
set(value);
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace ImGui
|
||||
|
||||
#endif // IGL_OPENGL_GLFW_IMGUI_IMGUIHELPERS_H
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2022 Alec Jacobson <alecjacobson@gmail.com>
|
||||
// Copyright (C) 2018 Jérémie Dumas <jeremie.dumas@ens-lyon.org>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
@@ -7,13 +8,9 @@
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include "ImGuiMenu.h"
|
||||
#include <igl/project.h>
|
||||
#include <imgui/imgui.h>
|
||||
#include <imgui_impl_glfw_gl3.h>
|
||||
#include <imgui_fonts_droid_sans.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
#include "ImGuiHelpers.h"
|
||||
#include <imgui.h>
|
||||
#include <iostream>
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace igl
|
||||
{
|
||||
@@ -24,124 +21,14 @@ namespace glfw
|
||||
namespace imgui
|
||||
{
|
||||
|
||||
IGL_INLINE void ImGuiMenu::init(igl::opengl::glfw::Viewer *_viewer)
|
||||
// Is this needed?
|
||||
IGL_INLINE void ImGuiMenu::init( Viewer *_viewer, ImGuiPlugin *_plugin)
|
||||
{ viewer = _viewer; plugin = _plugin; }
|
||||
|
||||
IGL_INLINE void ImGuiMenu::shutdown() { }
|
||||
|
||||
IGL_INLINE void ImGuiMenu::draw()
|
||||
{
|
||||
ViewerPlugin::init(_viewer);
|
||||
// Setup ImGui binding
|
||||
if (_viewer)
|
||||
{
|
||||
if (context_ == nullptr)
|
||||
{
|
||||
context_ = ImGui::CreateContext();
|
||||
}
|
||||
ImGui_ImplGlfwGL3_Init(viewer->window, false);
|
||||
ImGui::GetIO().IniFilename = nullptr;
|
||||
ImGui::StyleColorsDark();
|
||||
ImGuiStyle& style = ImGui::GetStyle();
|
||||
style.FrameRounding = 5.0f;
|
||||
reload_font();
|
||||
}
|
||||
}
|
||||
|
||||
IGL_INLINE void ImGuiMenu::reload_font(int font_size)
|
||||
{
|
||||
hidpi_scaling_ = hidpi_scaling();
|
||||
pixel_ratio_ = pixel_ratio();
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.Fonts->Clear();
|
||||
io.Fonts->AddFontFromMemoryCompressedTTF(droid_sans_compressed_data,
|
||||
droid_sans_compressed_size, font_size * hidpi_scaling_);
|
||||
io.FontGlobalScale = 1.0 / pixel_ratio_;
|
||||
}
|
||||
|
||||
IGL_INLINE void ImGuiMenu::shutdown()
|
||||
{
|
||||
// Cleanup
|
||||
ImGui_ImplGlfwGL3_Shutdown();
|
||||
ImGui::DestroyContext(context_);
|
||||
context_ = nullptr;
|
||||
}
|
||||
|
||||
IGL_INLINE bool ImGuiMenu::pre_draw()
|
||||
{
|
||||
glfwPollEvents();
|
||||
|
||||
// Check whether window dpi has changed
|
||||
float scaling = hidpi_scaling();
|
||||
if (std::abs(scaling - hidpi_scaling_) > 1e-5)
|
||||
{
|
||||
reload_font();
|
||||
ImGui_ImplGlfwGL3_InvalidateDeviceObjects();
|
||||
}
|
||||
|
||||
ImGui_ImplGlfwGL3_NewFrame();
|
||||
return false;
|
||||
}
|
||||
|
||||
IGL_INLINE bool ImGuiMenu::post_draw()
|
||||
{
|
||||
draw_menu();
|
||||
ImGui::Render();
|
||||
return false;
|
||||
}
|
||||
|
||||
IGL_INLINE void ImGuiMenu::post_resize(int width, int height)
|
||||
{
|
||||
if (context_)
|
||||
{
|
||||
ImGui::GetIO().DisplaySize.x = float(width);
|
||||
ImGui::GetIO().DisplaySize.y = float(height);
|
||||
}
|
||||
}
|
||||
|
||||
// Mouse IO
|
||||
IGL_INLINE bool ImGuiMenu::mouse_down(int button, int modifier)
|
||||
{
|
||||
ImGui_ImplGlfwGL3_MouseButtonCallback(viewer->window, button, GLFW_PRESS, modifier);
|
||||
return ImGui::GetIO().WantCaptureMouse;
|
||||
}
|
||||
|
||||
IGL_INLINE bool ImGuiMenu::mouse_up(int button, int modifier)
|
||||
{
|
||||
return ImGui::GetIO().WantCaptureMouse;
|
||||
}
|
||||
|
||||
IGL_INLINE bool ImGuiMenu::mouse_move(int mouse_x, int mouse_y)
|
||||
{
|
||||
return ImGui::GetIO().WantCaptureMouse;
|
||||
}
|
||||
|
||||
IGL_INLINE bool ImGuiMenu::mouse_scroll(float delta_y)
|
||||
{
|
||||
ImGui_ImplGlfwGL3_ScrollCallback(viewer->window, 0.f, delta_y);
|
||||
return ImGui::GetIO().WantCaptureMouse;
|
||||
}
|
||||
|
||||
// Keyboard IO
|
||||
IGL_INLINE bool ImGuiMenu::key_pressed(unsigned int key, int modifiers)
|
||||
{
|
||||
ImGui_ImplGlfwGL3_CharCallback(nullptr, key);
|
||||
return ImGui::GetIO().WantCaptureKeyboard;
|
||||
}
|
||||
|
||||
IGL_INLINE bool ImGuiMenu::key_down(int key, int modifiers)
|
||||
{
|
||||
ImGui_ImplGlfwGL3_KeyCallback(viewer->window, key, 0, GLFW_PRESS, modifiers);
|
||||
return ImGui::GetIO().WantCaptureKeyboard;
|
||||
}
|
||||
|
||||
IGL_INLINE bool ImGuiMenu::key_up(int key, int modifiers)
|
||||
{
|
||||
ImGui_ImplGlfwGL3_KeyCallback(viewer->window, key, 0, GLFW_RELEASE, modifiers);
|
||||
return ImGui::GetIO().WantCaptureKeyboard;
|
||||
}
|
||||
|
||||
// Draw menu
|
||||
IGL_INLINE void ImGuiMenu::draw_menu()
|
||||
{
|
||||
// Text labels
|
||||
draw_labels_window();
|
||||
|
||||
// Viewer settings
|
||||
if (callback_draw_viewer_window) { callback_draw_viewer_window(); }
|
||||
else { draw_viewer_window(); }
|
||||
@@ -153,10 +40,8 @@ IGL_INLINE void ImGuiMenu::draw_menu()
|
||||
|
||||
IGL_INLINE void ImGuiMenu::draw_viewer_window()
|
||||
{
|
||||
float menu_width = 180.f * menu_scaling();
|
||||
ImGui::SetNextWindowPos(ImVec2(0.0f, 0.0f), ImGuiSetCond_FirstUseEver);
|
||||
ImGui::SetNextWindowSize(ImVec2(0.0f, 0.0f), ImGuiSetCond_FirstUseEver);
|
||||
ImGui::SetNextWindowSizeConstraints(ImVec2(menu_width, -1.0f), ImVec2(menu_width, -1.0f));
|
||||
ImGui::SetNextWindowPos(ImVec2(0.0f, 0.0f), ImGuiCond_FirstUseEver);
|
||||
ImGui::SetNextWindowSize(ImVec2(0.0f, 0.0f), ImGuiCond_FirstUseEver);
|
||||
bool _viewer_menu_visible = true;
|
||||
ImGui::Begin(
|
||||
"Viewer", &_viewer_menu_visible,
|
||||
@@ -175,7 +60,7 @@ IGL_INLINE void ImGuiMenu::draw_viewer_menu()
|
||||
// Workspace
|
||||
if (ImGui::CollapsingHeader("Workspace", ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
float w = ImGui::GetContentRegionAvailWidth();
|
||||
float w = ImGui::GetContentRegionAvail().x;
|
||||
float p = ImGui::GetStyle().FramePadding.x;
|
||||
if (ImGui::Button("Load##Workspace", ImVec2((w-p)/2.f, 0)))
|
||||
{
|
||||
@@ -191,7 +76,7 @@ IGL_INLINE void ImGuiMenu::draw_viewer_menu()
|
||||
// Mesh
|
||||
if (ImGui::CollapsingHeader("Mesh", ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
float w = ImGui::GetContentRegionAvailWidth();
|
||||
float w = ImGui::GetContentRegionAvail().x;
|
||||
float p = ImGui::GetStyle().FramePadding.x;
|
||||
if (ImGui::Button("Load##Mesh", ImVec2((w-p)/2.f, 0)))
|
||||
{
|
||||
@@ -209,7 +94,7 @@ IGL_INLINE void ImGuiMenu::draw_viewer_menu()
|
||||
{
|
||||
if (ImGui::Button("Center object", ImVec2(-1, 0)))
|
||||
{
|
||||
viewer->core.align_camera_center(viewer->data().V, viewer->data().F);
|
||||
viewer->core().align_camera_center(viewer->data().V, viewer->data().F);
|
||||
}
|
||||
if (ImGui::Button("Snap canonical view", ImVec2(-1, 0)))
|
||||
{
|
||||
@@ -218,54 +103,63 @@ IGL_INLINE void ImGuiMenu::draw_viewer_menu()
|
||||
|
||||
// Zoom
|
||||
ImGui::PushItemWidth(80 * menu_scaling());
|
||||
ImGui::DragFloat("Zoom", &(viewer->core.camera_zoom), 0.05f, 0.1f, 20.0f);
|
||||
ImGui::DragFloat("Zoom", &(viewer->core().camera_zoom), 0.05f, 0.1f, 20.0f);
|
||||
|
||||
// Select rotation type
|
||||
int rotation_type = static_cast<int>(viewer->core.rotation_type);
|
||||
int rotation_type = static_cast<int>(viewer->core().rotation_type);
|
||||
static Eigen::Quaternionf trackball_angle = Eigen::Quaternionf::Identity();
|
||||
static bool orthographic = true;
|
||||
if (ImGui::Combo("Camera Type", &rotation_type, "Trackball\0Two Axes\0002D Mode\0\0"))
|
||||
{
|
||||
using RT = igl::opengl::ViewerCore::RotationType;
|
||||
auto new_type = static_cast<RT>(rotation_type);
|
||||
if (new_type != viewer->core.rotation_type)
|
||||
if (new_type != viewer->core().rotation_type)
|
||||
{
|
||||
if (new_type == RT::ROTATION_TYPE_NO_ROTATION)
|
||||
{
|
||||
trackball_angle = viewer->core.trackball_angle;
|
||||
orthographic = viewer->core.orthographic;
|
||||
viewer->core.trackball_angle = Eigen::Quaternionf::Identity();
|
||||
viewer->core.orthographic = true;
|
||||
trackball_angle = viewer->core().trackball_angle;
|
||||
orthographic = viewer->core().orthographic;
|
||||
viewer->core().trackball_angle = Eigen::Quaternionf::Identity();
|
||||
viewer->core().orthographic = true;
|
||||
}
|
||||
else if (viewer->core.rotation_type == RT::ROTATION_TYPE_NO_ROTATION)
|
||||
else if (viewer->core().rotation_type == RT::ROTATION_TYPE_NO_ROTATION)
|
||||
{
|
||||
viewer->core.trackball_angle = trackball_angle;
|
||||
viewer->core.orthographic = orthographic;
|
||||
viewer->core().trackball_angle = trackball_angle;
|
||||
viewer->core().orthographic = orthographic;
|
||||
}
|
||||
viewer->core.set_rotation_type(new_type);
|
||||
viewer->core().set_rotation_type(new_type);
|
||||
}
|
||||
}
|
||||
|
||||
// Orthographic view
|
||||
ImGui::Checkbox("Orthographic view", &(viewer->core.orthographic));
|
||||
ImGui::Checkbox("Orthographic view", &(viewer->core().orthographic));
|
||||
ImGui::PopItemWidth();
|
||||
}
|
||||
|
||||
// Helper for setting viewport specific mesh options
|
||||
auto make_checkbox = [&](const char *label, unsigned int &option)
|
||||
{
|
||||
return ImGui::Checkbox(label,
|
||||
[&]() { return viewer->core().is_set(option); },
|
||||
[&](bool value) { return viewer->core().set(option, value); }
|
||||
);
|
||||
};
|
||||
|
||||
// Draw options
|
||||
if (ImGui::CollapsingHeader("Draw Options", ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
if (ImGui::Checkbox("Face-based", &(viewer->data().face_based)))
|
||||
{
|
||||
viewer->data().set_face_based(viewer->data().face_based);
|
||||
viewer->data().dirty = MeshGL::DIRTY_ALL;
|
||||
}
|
||||
ImGui::Checkbox("Show texture", &(viewer->data().show_texture));
|
||||
make_checkbox("Show texture", viewer->data().show_texture);
|
||||
if (ImGui::Checkbox("Invert normals", &(viewer->data().invert_normals)))
|
||||
{
|
||||
viewer->data().dirty |= igl::opengl::MeshGL::DIRTY_NORMAL;
|
||||
}
|
||||
ImGui::Checkbox("Show overlay", &(viewer->data().show_overlay));
|
||||
ImGui::Checkbox("Show overlay depth", &(viewer->data().show_overlay_depth));
|
||||
ImGui::ColorEdit4("Background", viewer->core.background_color.data(),
|
||||
make_checkbox("Show overlay", viewer->data().show_overlay);
|
||||
make_checkbox("Show overlay depth", viewer->data().show_overlay_depth);
|
||||
ImGui::ColorEdit4("Background", viewer->core().background_color.data(),
|
||||
ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_PickerHueWheel);
|
||||
ImGui::ColorEdit4("Line color", viewer->data().line_color.data(),
|
||||
ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_PickerHueWheel);
|
||||
@@ -277,107 +171,14 @@ IGL_INLINE void ImGuiMenu::draw_viewer_menu()
|
||||
// Overlays
|
||||
if (ImGui::CollapsingHeader("Overlays", ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
ImGui::Checkbox("Wireframe", &(viewer->data().show_lines));
|
||||
ImGui::Checkbox("Fill", &(viewer->data().show_faces));
|
||||
ImGui::Checkbox("Show vertex labels", &(viewer->data().show_vertid));
|
||||
ImGui::Checkbox("Show faces labels", &(viewer->data().show_faceid));
|
||||
make_checkbox("Wireframe", viewer->data().show_lines);
|
||||
make_checkbox("Fill", viewer->data().show_faces);
|
||||
make_checkbox("Show vertex labels", viewer->data().show_vertex_labels);
|
||||
make_checkbox("Show faces labels", viewer->data().show_face_labels);
|
||||
make_checkbox("Show extra labels", viewer->data().show_custom_labels);
|
||||
}
|
||||
}
|
||||
|
||||
IGL_INLINE void ImGuiMenu::draw_labels_window()
|
||||
{
|
||||
// Text labels
|
||||
ImGui::SetNextWindowPos(ImVec2(0,0), ImGuiSetCond_Always);
|
||||
ImGui::SetNextWindowSize(ImGui::GetIO().DisplaySize, ImGuiSetCond_Always);
|
||||
bool visible = true;
|
||||
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0,0,0,0));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0);
|
||||
ImGui::Begin("ViewerLabels", &visible,
|
||||
ImGuiWindowFlags_NoTitleBar
|
||||
| ImGuiWindowFlags_NoResize
|
||||
| ImGuiWindowFlags_NoMove
|
||||
| ImGuiWindowFlags_NoScrollbar
|
||||
| ImGuiWindowFlags_NoScrollWithMouse
|
||||
| ImGuiWindowFlags_NoCollapse
|
||||
| ImGuiWindowFlags_NoSavedSettings
|
||||
| ImGuiWindowFlags_NoInputs);
|
||||
for (const auto & data : viewer->data_list)
|
||||
{
|
||||
draw_labels(data);
|
||||
}
|
||||
ImGui::End();
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
IGL_INLINE void ImGuiMenu::draw_labels(const igl::opengl::ViewerData &data)
|
||||
{
|
||||
if (data.show_vertid)
|
||||
{
|
||||
for (int i = 0; i < data.V.rows(); ++i)
|
||||
{
|
||||
draw_text(data.V.row(i), data.V_normals.row(i), std::to_string(i));
|
||||
}
|
||||
}
|
||||
|
||||
if (data.show_faceid)
|
||||
{
|
||||
for (int i = 0; i < data.F.rows(); ++i)
|
||||
{
|
||||
Eigen::RowVector3d p = Eigen::RowVector3d::Zero();
|
||||
for (int j = 0; j < data.F.cols(); ++j)
|
||||
{
|
||||
p += data.V.row(data.F(i,j));
|
||||
}
|
||||
p /= (double) data.F.cols();
|
||||
|
||||
draw_text(p, data.F_normals.row(i), std::to_string(i));
|
||||
}
|
||||
}
|
||||
|
||||
if (data.labels_positions.rows() > 0)
|
||||
{
|
||||
for (int i = 0; i < data.labels_positions.rows(); ++i)
|
||||
{
|
||||
draw_text(data.labels_positions.row(i), Eigen::Vector3d(0.0,0.0,0.0),
|
||||
data.labels_strings[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IGL_INLINE void ImGuiMenu::draw_text(Eigen::Vector3d pos, Eigen::Vector3d normal, const std::string &text)
|
||||
{
|
||||
pos += normal * 0.005f * viewer->core.object_scale;
|
||||
Eigen::Vector3f coord = igl::project(Eigen::Vector3f(pos.cast<float>()),
|
||||
viewer->core.view, viewer->core.proj, viewer->core.viewport);
|
||||
|
||||
// Draw text labels slightly bigger than normal text
|
||||
ImDrawList* drawList = ImGui::GetWindowDrawList();
|
||||
drawList->AddText(ImGui::GetFont(), ImGui::GetFontSize() * 1.2,
|
||||
ImVec2(coord[0]/pixel_ratio_, (viewer->core.viewport[3] - coord[1])/pixel_ratio_),
|
||||
ImGui::GetColorU32(ImVec4(0, 0, 10, 255)),
|
||||
&text[0], &text[0] + text.size());
|
||||
}
|
||||
|
||||
IGL_INLINE float ImGuiMenu::pixel_ratio()
|
||||
{
|
||||
// Computes pixel ratio for hidpi devices
|
||||
int buf_size[2];
|
||||
int win_size[2];
|
||||
GLFWwindow* window = glfwGetCurrentContext();
|
||||
glfwGetFramebufferSize(window, &buf_size[0], &buf_size[1]);
|
||||
glfwGetWindowSize(window, &win_size[0], &win_size[1]);
|
||||
return (float) buf_size[0] / (float) win_size[0];
|
||||
}
|
||||
|
||||
IGL_INLINE float ImGuiMenu::hidpi_scaling()
|
||||
{
|
||||
// Computes scaling factor for hidpi devices
|
||||
float xscale, yscale;
|
||||
GLFWwindow* window = glfwGetCurrentContext();
|
||||
glfwGetWindowContentScale(window, &xscale, &yscale);
|
||||
return 0.5 * (xscale + yscale);
|
||||
}
|
||||
|
||||
} // end namespace
|
||||
} // end namespace
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2022 Alec Jacobson <alecjacobson@gmail.com>
|
||||
// Copyright (C) 2018 Jérémie Dumas <jeremie.dumas@ens-lyon.org>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
@@ -8,103 +9,47 @@
|
||||
#ifndef IGL_OPENGL_GLFW_IMGUI_IMGUIMENU_H
|
||||
#define IGL_OPENGL_GLFW_IMGUI_IMGUIMENU_H
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include <igl/opengl/glfw/Viewer.h>
|
||||
#include <igl/opengl/glfw/ViewerPlugin.h>
|
||||
#include <igl/igl_inline.h>
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Forward declarations
|
||||
struct ImGuiContext;
|
||||
#include "ImGuiPlugin.h"
|
||||
#include "ImGuiWidget.h"
|
||||
#include "../../../igl_inline.h"
|
||||
#include <memory>
|
||||
|
||||
namespace igl
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
namespace glfw
|
||||
{
|
||||
namespace imgui
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
namespace glfw
|
||||
{
|
||||
namespace imgui
|
||||
{
|
||||
/// Widget for a menu bar and a viewer window.
|
||||
class ImGuiMenu : public ImGuiWidget
|
||||
{
|
||||
public:
|
||||
IGL_INLINE virtual void init(Viewer *_viewer, ImGuiPlugin *_plugin) override;
|
||||
IGL_INLINE virtual void shutdown() override;
|
||||
IGL_INLINE virtual void draw() override;
|
||||
// Can be overwritten by `callback_draw_viewer_window`
|
||||
IGL_INLINE virtual void draw_viewer_window();
|
||||
// Can be overwritten by `callback_draw_viewer_menu`
|
||||
IGL_INLINE virtual void draw_viewer_menu();
|
||||
// Can be overwritten by `callback_draw_custom_window`
|
||||
IGL_INLINE virtual void draw_custom_window() { }
|
||||
// Customizable callbacks
|
||||
std::function<void(void)> callback_draw_viewer_window;
|
||||
std::function<void(void)> callback_draw_viewer_menu;
|
||||
std::function<void(void)> callback_draw_custom_window;
|
||||
float menu_scaling()
|
||||
{ return plugin->hidpi_scaling() / plugin->pixel_ratio(); }
|
||||
};
|
||||
|
||||
class ImGuiMenu : public igl::opengl::glfw::ViewerPlugin
|
||||
{
|
||||
protected:
|
||||
// Hidpi scaling to be used for text rendering.
|
||||
float hidpi_scaling_;
|
||||
|
||||
// Ratio between the framebuffer size and the window size.
|
||||
// May be different from the hipdi scaling!
|
||||
float pixel_ratio_;
|
||||
|
||||
// ImGui Context
|
||||
ImGuiContext * context_ = nullptr;
|
||||
|
||||
public:
|
||||
IGL_INLINE virtual void init(igl::opengl::glfw::Viewer *_viewer) override;
|
||||
|
||||
IGL_INLINE virtual void reload_font(int font_size = 13);
|
||||
|
||||
IGL_INLINE virtual void shutdown() override;
|
||||
|
||||
IGL_INLINE virtual bool pre_draw() override;
|
||||
|
||||
IGL_INLINE virtual bool post_draw() override;
|
||||
|
||||
IGL_INLINE virtual void post_resize(int width, int height) override;
|
||||
|
||||
// Mouse IO
|
||||
IGL_INLINE virtual bool mouse_down(int button, int modifier) override;
|
||||
|
||||
IGL_INLINE virtual bool mouse_up(int button, int modifier) override;
|
||||
|
||||
IGL_INLINE virtual bool mouse_move(int mouse_x, int mouse_y) override;
|
||||
|
||||
IGL_INLINE virtual bool mouse_scroll(float delta_y) override;
|
||||
|
||||
// Keyboard IO
|
||||
IGL_INLINE virtual bool key_pressed(unsigned int key, int modifiers) override;
|
||||
|
||||
IGL_INLINE virtual bool key_down(int key, int modifiers) override;
|
||||
|
||||
IGL_INLINE virtual bool key_up(int key, int modifiers) override;
|
||||
|
||||
// Draw menu
|
||||
IGL_INLINE virtual void draw_menu();
|
||||
|
||||
// Can be overwritten by `callback_draw_viewer_window`
|
||||
IGL_INLINE virtual void draw_viewer_window();
|
||||
|
||||
// Can be overwritten by `callback_draw_viewer_menu`
|
||||
IGL_INLINE virtual void draw_viewer_menu();
|
||||
|
||||
// Can be overwritten by `callback_draw_custom_window`
|
||||
IGL_INLINE virtual void draw_custom_window() { }
|
||||
|
||||
// Easy-to-customize callbacks
|
||||
std::function<void(void)> callback_draw_viewer_window;
|
||||
std::function<void(void)> callback_draw_viewer_menu;
|
||||
std::function<void(void)> callback_draw_custom_window;
|
||||
|
||||
IGL_INLINE void draw_labels_window();
|
||||
|
||||
IGL_INLINE void draw_labels(const igl::opengl::ViewerData &data);
|
||||
|
||||
IGL_INLINE void draw_text(Eigen::Vector3d pos, Eigen::Vector3d normal, const std::string &text);
|
||||
|
||||
IGL_INLINE float pixel_ratio();
|
||||
|
||||
IGL_INLINE float hidpi_scaling();
|
||||
|
||||
float menu_scaling() { return hidpi_scaling_ / pixel_ratio_; }
|
||||
};
|
||||
|
||||
} // end namespace
|
||||
} // end namespace
|
||||
} // end namespace
|
||||
} // end namespace
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
# include "ImGuiMenu.cpp"
|
||||
#endif
|
||||
|
||||
#endif // IGL_OPENGL_GLFW_IMGUI_IMGUIMENU_H
|
||||
#endif
|
||||
|
||||
211
deps_src/libigl/igl/opengl/glfw/imgui/ImGuiPlugin.cpp
Normal file
211
deps_src/libigl/igl/opengl/glfw/imgui/ImGuiPlugin.cpp
Normal file
@@ -0,0 +1,211 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2022 Alec Jacobson <alecjacobson@gmail.com>
|
||||
// Copyright (C) 2018 Jérémie Dumas <jeremie.dumas@ens-lyon.org>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include "ImGuiPlugin.h"
|
||||
#include "ImGuiHelpers.h"
|
||||
#include "../../../project.h"
|
||||
#include <backends/imgui_impl_glfw.h>
|
||||
#include <backends/imgui_impl_opengl3.h>
|
||||
#include <imgui.h>
|
||||
#include <imgui_fonts_droid_sans.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <iostream>
|
||||
|
||||
namespace igl
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
namespace glfw
|
||||
{
|
||||
namespace imgui
|
||||
{
|
||||
|
||||
IGL_INLINE void ImGuiPlugin::init(igl::opengl::glfw::Viewer *_viewer)
|
||||
{
|
||||
ViewerPlugin::init(_viewer);
|
||||
// Setup ImGui binding
|
||||
if (_viewer)
|
||||
{
|
||||
IMGUI_CHECKVERSION();
|
||||
if (!context_)
|
||||
{
|
||||
// Single global context by default, but can be overridden by the user
|
||||
static ImGuiContext * __global_context = ImGui::CreateContext();
|
||||
context_ = __global_context;
|
||||
}
|
||||
const char* glsl_version = "#version 150";
|
||||
ImGui_ImplGlfw_InitForOpenGL(viewer->window, false);
|
||||
ImGui_ImplOpenGL3_Init(glsl_version);
|
||||
ImGui::GetIO().IniFilename = nullptr;
|
||||
ImGui::StyleColorsDark();
|
||||
ImGuiStyle& style = ImGui::GetStyle();
|
||||
style.FrameRounding = 5.0f;
|
||||
reload_font();
|
||||
}
|
||||
init_widgets();
|
||||
}
|
||||
|
||||
IGL_INLINE void ImGuiPlugin::init_widgets()
|
||||
{
|
||||
// Init all widgets
|
||||
for(auto & widget : widgets) { widget->init(viewer, this); }
|
||||
}
|
||||
IGL_INLINE void ImGuiPlugin::reload_font(int font_size)
|
||||
{
|
||||
hidpi_scaling_ = hidpi_scaling();
|
||||
pixel_ratio_ = pixel_ratio();
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.Fonts->Clear();
|
||||
io.Fonts->AddFontFromMemoryCompressedTTF(droid_sans_compressed_data,
|
||||
droid_sans_compressed_size, font_size * hidpi_scaling_);
|
||||
io.FontGlobalScale = 1.0 / pixel_ratio_;
|
||||
}
|
||||
|
||||
IGL_INLINE void ImGuiPlugin::shutdown()
|
||||
{
|
||||
// Cleanup
|
||||
ImGui_ImplOpenGL3_Shutdown();
|
||||
ImGui_ImplGlfw_Shutdown();
|
||||
// User is responsible for destroying context if a custom context is given
|
||||
// ImGui::DestroyContext(*context_);
|
||||
}
|
||||
|
||||
IGL_INLINE bool ImGuiPlugin::pre_draw()
|
||||
{
|
||||
glfwPollEvents();
|
||||
|
||||
// Check whether window dpi has changed
|
||||
float scaling = hidpi_scaling();
|
||||
if (std::abs(scaling - hidpi_scaling_) > 1e-5)
|
||||
{
|
||||
reload_font();
|
||||
ImGui_ImplOpenGL3_DestroyDeviceObjects();
|
||||
}
|
||||
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
ImGui_ImplGlfw_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
return false;
|
||||
}
|
||||
|
||||
IGL_INLINE bool ImGuiPlugin::post_draw()
|
||||
{
|
||||
for(auto & widget : widgets){ widget->draw(); }
|
||||
ImGui::Render();
|
||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||
return false;
|
||||
}
|
||||
|
||||
IGL_INLINE void ImGuiPlugin::post_resize(int width, int height)
|
||||
{
|
||||
if (context_)
|
||||
{
|
||||
ImGui::GetIO().DisplaySize.x = float(width);
|
||||
ImGui::GetIO().DisplaySize.y = float(height);
|
||||
}
|
||||
}
|
||||
|
||||
// Mouse IO
|
||||
IGL_INLINE bool ImGuiPlugin::mouse_down(int button, int modifier)
|
||||
{
|
||||
ImGui_ImplGlfw_MouseButtonCallback(viewer->window, button, GLFW_PRESS, modifier);
|
||||
if(ImGui::GetIO().WantCaptureMouse){ return true; }
|
||||
for( auto & widget : widgets)
|
||||
{
|
||||
if(widget->mouse_down(button, modifier)) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
IGL_INLINE bool ImGuiPlugin::mouse_up(int button, int modifier)
|
||||
{
|
||||
//return ImGui::GetIO().WantCaptureMouse;
|
||||
// !! Should not steal mouse up
|
||||
for( auto & widget : widgets)
|
||||
{
|
||||
widget->mouse_up(button, modifier);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
IGL_INLINE bool ImGuiPlugin::mouse_move(int mouse_x, int mouse_y)
|
||||
{
|
||||
if(ImGui::GetIO().WantCaptureMouse){ return true; }
|
||||
for( auto & widget : widgets)
|
||||
{
|
||||
if(widget->mouse_move(mouse_x, mouse_y)) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
IGL_INLINE bool ImGuiPlugin::mouse_scroll(float delta_y)
|
||||
{
|
||||
ImGui_ImplGlfw_ScrollCallback(viewer->window, 0.f, delta_y);
|
||||
return ImGui::GetIO().WantCaptureMouse;
|
||||
}
|
||||
|
||||
// Keyboard IO
|
||||
IGL_INLINE bool ImGuiPlugin::key_pressed(unsigned int key, int modifiers)
|
||||
{
|
||||
ImGui_ImplGlfw_CharCallback(nullptr, key);
|
||||
if(ImGui::GetIO().WantCaptureKeyboard) { return true; }
|
||||
for(auto & widget : widgets)
|
||||
{
|
||||
if(widget->key_pressed(key,modifiers)) {return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
IGL_INLINE bool ImGuiPlugin::key_down(int key, int modifiers)
|
||||
{
|
||||
ImGui_ImplGlfw_KeyCallback(viewer->window, key, 0, GLFW_PRESS, modifiers);
|
||||
if(ImGui::GetIO().WantCaptureKeyboard) { return true; }
|
||||
for(auto & widget : widgets)
|
||||
{
|
||||
if(widget->key_down(key,modifiers)) {return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
IGL_INLINE bool ImGuiPlugin::key_up(int key, int modifiers)
|
||||
{
|
||||
ImGui_ImplGlfw_KeyCallback(viewer->window, key, 0, GLFW_RELEASE, modifiers);
|
||||
if(ImGui::GetIO().WantCaptureKeyboard) { return true; }
|
||||
for(auto & widget : widgets)
|
||||
{
|
||||
if(widget->key_up(key,modifiers)) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
IGL_INLINE float ImGuiPlugin::pixel_ratio()
|
||||
{
|
||||
// Computes pixel ratio for hidpi devices
|
||||
int buf_size[2];
|
||||
int win_size[2];
|
||||
GLFWwindow* window = glfwGetCurrentContext();
|
||||
glfwGetFramebufferSize(window, &buf_size[0], &buf_size[1]);
|
||||
glfwGetWindowSize(window, &win_size[0], &win_size[1]);
|
||||
return (float) buf_size[0] / (float) win_size[0];
|
||||
}
|
||||
|
||||
IGL_INLINE float ImGuiPlugin::hidpi_scaling()
|
||||
{
|
||||
// Computes scaling factor for hidpi devices
|
||||
float xscale, yscale;
|
||||
GLFWwindow* window = glfwGetCurrentContext();
|
||||
glfwGetWindowContentScale(window, &xscale, &yscale);
|
||||
return 0.5 * (xscale + yscale);
|
||||
}
|
||||
|
||||
} // end namespace
|
||||
} // end namespace
|
||||
} // end namespace
|
||||
} // end namespace
|
||||
|
||||
78
deps_src/libigl/igl/opengl/glfw/imgui/ImGuiPlugin.h
Normal file
78
deps_src/libigl/igl/opengl/glfw/imgui/ImGuiPlugin.h
Normal file
@@ -0,0 +1,78 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2022 Alec Jacobson <alecjacobson@gmail.com>
|
||||
// Copyright (C) 2018 Jérémie Dumas <jeremie.dumas@ens-lyon.org>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_OPENGL_GLFW_IMGUI_IMGUIPLUGIN_H
|
||||
#define IGL_OPENGL_GLFW_IMGUI_IMGUIPLUGIN_H
|
||||
|
||||
#include "../Viewer.h"
|
||||
#include "../ViewerPlugin.h"
|
||||
#include "../../../igl_inline.h"
|
||||
#include "ImGuiWidget.h"
|
||||
|
||||
// Forward declarations
|
||||
struct ImGuiContext;
|
||||
|
||||
namespace igl
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
namespace glfw
|
||||
{
|
||||
namespace imgui
|
||||
{
|
||||
// Forward declaration of child widget abstract type
|
||||
class ImGuiWidget;
|
||||
/// Plugin for the viewer to enable imgui widgets
|
||||
class ImGuiPlugin : public igl::opengl::glfw::ViewerPlugin
|
||||
{
|
||||
protected:
|
||||
// Hidpi scaling to be used for text rendering.
|
||||
float hidpi_scaling_;
|
||||
// Ratio between the framebuffer size and the window size.
|
||||
// May be different from the hipdi scaling!
|
||||
float pixel_ratio_;
|
||||
// ImGui Context
|
||||
ImGuiContext * context_ = nullptr;
|
||||
public:
|
||||
// List of registered widgets
|
||||
std::vector<ImGuiWidget*> widgets;
|
||||
public:
|
||||
IGL_INLINE virtual void init(igl::opengl::glfw::Viewer *_viewer) override;
|
||||
IGL_INLINE void init_widgets();
|
||||
IGL_INLINE virtual void reload_font(int font_size = 13);
|
||||
IGL_INLINE virtual void shutdown() override;
|
||||
IGL_INLINE virtual bool pre_draw() override;
|
||||
IGL_INLINE virtual bool post_draw() override;
|
||||
IGL_INLINE virtual void post_resize(int width, int height) override;
|
||||
IGL_INLINE virtual bool mouse_down(int button, int modifier) override;
|
||||
IGL_INLINE virtual bool mouse_up(int button, int modifier) override;
|
||||
IGL_INLINE virtual bool mouse_move(int mouse_x, int mouse_y) override;
|
||||
IGL_INLINE virtual bool mouse_scroll(float delta_y) override;
|
||||
// Keyboard IO
|
||||
IGL_INLINE virtual bool key_pressed(unsigned int key, int modifiers) override;
|
||||
IGL_INLINE virtual bool key_down(int key, int modifiers) override;
|
||||
IGL_INLINE virtual bool key_up(int key, int modifiers) override;
|
||||
IGL_INLINE void draw_text(
|
||||
const Eigen::Vector3d pos,
|
||||
const Eigen::Vector3d normal,
|
||||
const std::string &text,
|
||||
const Eigen::Vector4f color = Eigen::Vector4f(0,0,0.04,1)); // old default color
|
||||
IGL_INLINE float pixel_ratio();
|
||||
IGL_INLINE float hidpi_scaling();
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
# include "ImGuiPlugin.cpp"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
69
deps_src/libigl/igl/opengl/glfw/imgui/ImGuiTraits.h
Normal file
69
deps_src/libigl/igl/opengl/glfw/imgui/ImGuiTraits.h
Normal file
@@ -0,0 +1,69 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2018 Jérémie Dumas <jeremie.dumas@ens-lyon.org>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_OPENGL_GLFW_IMGUI_IMGUITRAITS_H
|
||||
#define IGL_OPENGL_GLFW_IMGUI_IMGUITRAITS_H
|
||||
|
||||
#include <imgui.h>
|
||||
|
||||
// Extend ImGui by populating its namespace directly
|
||||
namespace ImGui
|
||||
{
|
||||
|
||||
// Infer ImGuiDataType enum based on actual type
|
||||
template<typename T>
|
||||
class ImGuiDataTypeTraits
|
||||
{
|
||||
static const ImGuiDataType value; // link error
|
||||
static const char * format;
|
||||
};
|
||||
|
||||
template<>
|
||||
class ImGuiDataTypeTraits<int>
|
||||
{
|
||||
static constexpr ImGuiDataType value = ImGuiDataType_S32;
|
||||
static constexpr const char *format = "%d";
|
||||
};
|
||||
|
||||
template<>
|
||||
class ImGuiDataTypeTraits<unsigned int>
|
||||
{
|
||||
static constexpr ImGuiDataType value = ImGuiDataType_U32;
|
||||
static constexpr const char *format = "%u";
|
||||
};
|
||||
|
||||
template<>
|
||||
class ImGuiDataTypeTraits<long long>
|
||||
{
|
||||
static constexpr ImGuiDataType value = ImGuiDataType_S64;
|
||||
static constexpr const char *format = "%lld";
|
||||
};
|
||||
|
||||
template<>
|
||||
class ImGuiDataTypeTraits<unsigned long long>
|
||||
{
|
||||
static constexpr ImGuiDataType value = ImGuiDataType_U64;
|
||||
static constexpr const char *format = "%llu";
|
||||
};
|
||||
|
||||
template<>
|
||||
class ImGuiDataTypeTraits<float>
|
||||
{
|
||||
static constexpr ImGuiDataType value = ImGuiDataType_Float;
|
||||
static constexpr const char *format = "%.3f";
|
||||
};
|
||||
|
||||
template<>
|
||||
class ImGuiDataTypeTraits<double>
|
||||
{
|
||||
static constexpr ImGuiDataType value = ImGuiDataType_Double;
|
||||
static constexpr const char *format = "%.6f";
|
||||
};
|
||||
|
||||
} // namespace ImGui
|
||||
|
||||
#endif // IGL_OPENGL_GLFW_IMGUI_IMGUIHELPERS_H
|
||||
65
deps_src/libigl/igl/opengl/glfw/imgui/ImGuiWidget.h
Normal file
65
deps_src/libigl/igl/opengl/glfw/imgui/ImGuiWidget.h
Normal file
@@ -0,0 +1,65 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2022 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_OPENGL_GLFW_IMGUI_IMGUIWIDGET_H
|
||||
#define IGL_OPENGL_GLFW_IMGUI_IMGUIWIDGET_H
|
||||
|
||||
#include "ImGuiPlugin.h"
|
||||
#include "ImGuiWidget.h"
|
||||
#include "../../../igl_inline.h"
|
||||
#include <memory>
|
||||
|
||||
namespace igl
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
namespace glfw
|
||||
{
|
||||
class Viewer;
|
||||
namespace imgui
|
||||
{
|
||||
// Forward declaration of the parent plugin
|
||||
class ImGuiPlugin;
|
||||
/// Abstract class for imgui "widgets". A widget is something that uses
|
||||
/// imgui, but doesn't own the entire imgui IO stack: the single
|
||||
/// ImGuiPlugin owns that and widgets are registered with it.
|
||||
class ImGuiWidget
|
||||
{
|
||||
public:
|
||||
IGL_INLINE ImGuiWidget(){ name = "dummy"; }
|
||||
virtual ~ImGuiWidget(){}
|
||||
IGL_INLINE virtual void init(Viewer *_viewer, ImGuiPlugin *_plugin)
|
||||
{ viewer = _viewer; plugin = _plugin; }
|
||||
IGL_INLINE virtual void shutdown() {}
|
||||
IGL_INLINE virtual void draw() {}
|
||||
IGL_INLINE virtual bool mouse_down(int /*button*/, int /*modifier*/)
|
||||
{ return false;}
|
||||
IGL_INLINE virtual bool mouse_up(int /*button*/, int /*modifier*/)
|
||||
{ return false;}
|
||||
IGL_INLINE virtual bool mouse_move(int /*mouse_x*/, int /*mouse_y*/)
|
||||
{ return false;}
|
||||
IGL_INLINE virtual bool key_pressed(unsigned int /*key*/, int /*modifiers*/)
|
||||
{ return false;}
|
||||
IGL_INLINE virtual bool key_down(int /*key*/, int /*modifiers*/)
|
||||
{ return false;}
|
||||
IGL_INLINE virtual bool key_up(int /*key*/, int /*modifiers*/)
|
||||
{ return false;}
|
||||
std::string name;
|
||||
protected:
|
||||
// Pointer to ImGuiPlugin's parent viewer
|
||||
Viewer *viewer;
|
||||
// Pointer to parent ImGuiPlugin class
|
||||
ImGuiPlugin *plugin;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
43
deps_src/libigl/igl/opengl/glfw/imgui/ImGuizmoWidget.cpp
Normal file
43
deps_src/libigl/igl/opengl/glfw/imgui/ImGuizmoWidget.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
#include "ImGuizmoWidget.h"
|
||||
#include <imgui.h>
|
||||
#include <backends/imgui_impl_glfw.h>
|
||||
#include <backends/imgui_impl_opengl3.h>
|
||||
#include <imgui_fonts_droid_sans.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
namespace igl{ namespace opengl{ namespace glfw{ namespace imgui{
|
||||
|
||||
IGL_INLINE void ImGuizmoWidget::init(Viewer *_viewer, ImGuiPlugin *_plugin)
|
||||
{
|
||||
ImGuiWidget::init(_viewer,_plugin);
|
||||
}
|
||||
|
||||
IGL_INLINE void ImGuizmoWidget::draw()
|
||||
{
|
||||
if(!visible){ return; }
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0);
|
||||
ImGuizmo::BeginFrame();
|
||||
ImGui::PopStyleVar();
|
||||
// Don't draw the Viewer's default menu: draw just the ImGuizmo
|
||||
Eigen::Matrix4f view = (viewer->core().view / viewer->core().camera_zoom);
|
||||
Eigen::Matrix4f proj = viewer->core().proj;
|
||||
if(viewer->core().orthographic){ view(2,3) -= 1000;/* Hack depth */ }
|
||||
// ImGuizmo doesn't like a lot of scaling in view, shift it to T
|
||||
const float z = viewer->core().camera_base_zoom;
|
||||
const Eigen::Matrix4f S =
|
||||
(Eigen::Matrix4f()<< z,0,0,0, 0,z,0,0, 0,0,z,0, 0,0,0,1).finished();
|
||||
view = (view * S.inverse()).eval();
|
||||
const Eigen::Matrix4f T0 = T;
|
||||
T = (S * T).eval();
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
ImGuizmo::SetRect(0, 0, io.DisplaySize.x, io.DisplaySize.y);
|
||||
ImGuizmo::Manipulate(
|
||||
view.data(),proj.data(),operation,ImGuizmo::LOCAL,T.data(),NULL,NULL);
|
||||
// invert scaling that was shifted onto T
|
||||
T = (S.inverse() * T).eval();
|
||||
const float diff = (T-T0).array().abs().maxCoeff();
|
||||
// Only call if actually changed; otherwise, triggers on all mouse events
|
||||
if( diff > 1e-7) { callback(T); }
|
||||
}
|
||||
|
||||
}}}}
|
||||
36
deps_src/libigl/igl/opengl/glfw/imgui/ImGuizmoWidget.h
Normal file
36
deps_src/libigl/igl/opengl/glfw/imgui/ImGuizmoWidget.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#ifndef IGL_OPENGL_GFLW_IMGUI_IMGUIZMOPLUGIN_H
|
||||
#define IGL_OPENGL_GFLW_IMGUI_IMGUIZMOPLUGIN_H
|
||||
#include "../../../igl_inline.h"
|
||||
#include "ImGuiMenu.h"
|
||||
#include <imgui.h>
|
||||
#include <imgui_internal.h>
|
||||
#include <ImGuizmo.h>
|
||||
#include <Eigen/Dense>
|
||||
|
||||
namespace igl{ namespace opengl{ namespace glfw{ namespace imgui{
|
||||
|
||||
/// Widget for a guizmo (3D transform manipulator)
|
||||
class ImGuizmoWidget : public ImGuiWidget
|
||||
{
|
||||
public:
|
||||
// callback(T) called when the stored transform T changes
|
||||
std::function<void(const Eigen::Matrix4f &)> callback;
|
||||
// Whether to display
|
||||
bool visible = true;
|
||||
// whether rotating, translating or scaling
|
||||
ImGuizmo::OPERATION operation;
|
||||
// stored transformation
|
||||
Eigen::Matrix4f T;
|
||||
// Initilize with rotate operation on an identity transform (at origin)
|
||||
ImGuizmoWidget():operation(ImGuizmo::ROTATE),T(Eigen::Matrix4f::Identity()){};
|
||||
IGL_INLINE virtual void init(Viewer *_viewer, ImGuiPlugin *_plugin) override;
|
||||
IGL_INLINE virtual void draw() override;
|
||||
};
|
||||
|
||||
}}}}
|
||||
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
# include "ImGuizmoWidget.cpp"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
215
deps_src/libigl/igl/opengl/glfw/imgui/SelectionWidget.cpp
Normal file
215
deps_src/libigl/igl/opengl/glfw/imgui/SelectionWidget.cpp
Normal file
@@ -0,0 +1,215 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2022 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#include "SelectionWidget.h"
|
||||
|
||||
#include <imgui.h>
|
||||
#include <backends/imgui_impl_glfw.h>
|
||||
#include <backends/imgui_impl_opengl3.h>
|
||||
#include <imgui_fonts_droid_sans.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
#include "../../../PI.h"
|
||||
|
||||
namespace igl{ namespace opengl{ namespace glfw{ namespace imgui{
|
||||
|
||||
IGL_INLINE void SelectionWidget::init(Viewer *_viewer, ImGuiPlugin *_plugin)
|
||||
{
|
||||
ImGuiWidget::init(_viewer,_plugin);
|
||||
std::cout<<R"(
|
||||
igl::opengl::glfw::imgui::SelectionWidget usage:
|
||||
[drag] Draw a 2D selection
|
||||
l Turn on and toggle between lasso and polygonal lasso tool
|
||||
M,m Turn on and toggle between rectangular and circular marquee tool
|
||||
V,v Turn off interactive selection
|
||||
)";
|
||||
}
|
||||
IGL_INLINE void SelectionWidget::draw()
|
||||
{
|
||||
if(mode == OFF){ return; }
|
||||
// Is this call necessary?
|
||||
ImGui::GetIO();
|
||||
|
||||
float width, height;
|
||||
float highdpi = 1.0;
|
||||
{
|
||||
int fwidth, fheight;
|
||||
glfwGetFramebufferSize(viewer->window, &fwidth, &fheight);
|
||||
int iwidth, iheight;
|
||||
glfwGetWindowSize(viewer->window, &iwidth, &iheight);
|
||||
highdpi = float(iwidth)/float(fwidth);
|
||||
// highdpi
|
||||
width = (float)iwidth;
|
||||
height = (float)iheight;
|
||||
}
|
||||
|
||||
ImGui::SetNextWindowPos( ImVec2(0,0) );
|
||||
ImGui::SetNextWindowSize(ImVec2(width,height), ImGuiCond_Always);
|
||||
|
||||
ImGui::Begin("testing", nullptr,
|
||||
ImGuiWindowFlags_NoBackground
|
||||
| ImGuiWindowFlags_NoTitleBar
|
||||
| ImGuiWindowFlags_NoResize
|
||||
| ImGuiWindowFlags_NoMove
|
||||
| ImGuiWindowFlags_NoScrollbar
|
||||
| ImGuiWindowFlags_NoSavedSettings
|
||||
| ImGuiWindowFlags_NoInputs);
|
||||
|
||||
ImDrawList* list = ImGui::GetWindowDrawList();
|
||||
for(int pass = 0;pass<2;pass++)
|
||||
{
|
||||
for(auto & p : L)
|
||||
{
|
||||
list->PathLineTo({ highdpi*p(0),height-highdpi*p(1) });
|
||||
}
|
||||
const bool closed = !(mode==LASSO || mode==POLYGONAL_LASSO) || !(is_down || is_drawing);
|
||||
if(pass == 0)
|
||||
{
|
||||
list->PathStroke(IM_COL32(255, 255, 255, 255), closed, 2);
|
||||
}else
|
||||
{
|
||||
list->PathStroke(IM_COL32(0, 0, 0, 255), closed, 1);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
|
||||
ImGui::Render();
|
||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||
|
||||
}
|
||||
|
||||
IGL_INLINE bool SelectionWidget::mouse_down(int /*button*/, int modifier)
|
||||
{
|
||||
if(mode == OFF || (modifier & IGL_MOD_ALT) ){ return false;}
|
||||
is_down = true;
|
||||
has_moved_since_down = false;
|
||||
if(!is_drawing)
|
||||
{
|
||||
L.clear();
|
||||
is_drawing = true;
|
||||
}
|
||||
M.row(0) = xy(viewer);
|
||||
M.row(1) = M.row(0);
|
||||
L.emplace_back(M.row(0));
|
||||
return true;
|
||||
}
|
||||
|
||||
IGL_INLINE bool SelectionWidget::mouse_up(int /*button*/, int /*modifier*/)
|
||||
{
|
||||
is_down = false;
|
||||
// are we done? Check first and last lasso point (need at least 3 (2 real
|
||||
// points + 1 mouse-mouse point))
|
||||
if(is_drawing &&
|
||||
(mode!=POLYGONAL_LASSO ||(L.size()>=3&&(L[0]-L[L.size()-1]).norm()<=10.0)))
|
||||
{
|
||||
if(callback){ callback();}
|
||||
is_drawing = false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
IGL_INLINE bool SelectionWidget::mouse_move(int /*mouse_x*/, int /*mouse_y*/)
|
||||
{
|
||||
if(!is_drawing){ return false; }
|
||||
if(!has_moved_since_down)
|
||||
{
|
||||
if(mode == POLYGONAL_LASSO) { L.emplace_back(L[L.size()-1]); }
|
||||
has_moved_since_down = true;
|
||||
}
|
||||
M.row(1) = xy(viewer);
|
||||
switch(mode)
|
||||
{
|
||||
case RECTANGULAR_MARQUEE:
|
||||
rect(M,L);
|
||||
break;
|
||||
case ELLIPTICAL_MARQUEE:
|
||||
circle(M,L);
|
||||
break;
|
||||
case POLYGONAL_LASSO:
|
||||
// Over write last point
|
||||
L[L.size()-1] = xy(viewer);
|
||||
break;
|
||||
case LASSO:
|
||||
L.emplace_back(xy(viewer));
|
||||
break;
|
||||
default: assert(false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
IGL_INLINE bool SelectionWidget::key_pressed(unsigned int key, int /*modifiers*/)
|
||||
{
|
||||
Mode old = mode;
|
||||
if(OFF_KEY.find(char(key)) != std::string::npos)
|
||||
{
|
||||
mode = OFF;
|
||||
}else if(LASSO_KEY.find(char(key)) != std::string::npos)
|
||||
{
|
||||
if(mode == LASSO)
|
||||
{
|
||||
mode = POLYGONAL_LASSO;
|
||||
}else/*if(mode == POLYGONAL_LASSO)*/
|
||||
{
|
||||
mode = LASSO;
|
||||
}
|
||||
}else if(MARQUEE_KEY.find(char(key)) != std::string::npos)
|
||||
{
|
||||
if(mode == RECTANGULAR_MARQUEE)
|
||||
{
|
||||
mode = ELLIPTICAL_MARQUEE;
|
||||
}else/*if(mode == ELLIPTICAL_MARQUEE)*/
|
||||
{
|
||||
mode = RECTANGULAR_MARQUEE;
|
||||
}
|
||||
}
|
||||
if(old != mode)
|
||||
{
|
||||
clear();
|
||||
if(callback_post_mode_change){ callback_post_mode_change(old); }
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
IGL_INLINE void SelectionWidget::clear()
|
||||
{
|
||||
M.setZero();
|
||||
L.clear();
|
||||
is_drawing = false;
|
||||
is_down = false;
|
||||
};
|
||||
|
||||
IGL_INLINE void SelectionWidget::circle(const Eigen::Matrix<float,2,2> & M, std::vector<Eigen::RowVector2f> & L)
|
||||
{
|
||||
L.clear();
|
||||
L.reserve(64);
|
||||
const float r = (M.row(1)-M.row(0)).norm();
|
||||
for(float th = 0;th<2.*igl::PI;th+=0.1)
|
||||
{
|
||||
L.emplace_back(M(0,0)+r*cos(th),M(0,1)+r*sin(th));
|
||||
}
|
||||
}
|
||||
|
||||
IGL_INLINE void SelectionWidget::rect(const Eigen::Matrix<float,2,2> & M, std::vector<Eigen::RowVector2f> & L)
|
||||
{
|
||||
L.resize(4);
|
||||
L[0] = Eigen::RowVector2f(M(0,0),M(0,1));
|
||||
L[1] = Eigen::RowVector2f(M(1,0),M(0,1));
|
||||
L[2] = Eigen::RowVector2f(M(1,0),M(1,1));
|
||||
L[3] = Eigen::RowVector2f(M(0,0),M(1,1));
|
||||
}
|
||||
|
||||
IGL_INLINE Eigen::RowVector2f SelectionWidget::xy(const Viewer * vr)
|
||||
{
|
||||
return Eigen::RowVector2f(
|
||||
vr->current_mouse_x,
|
||||
vr->core().viewport(3) - vr->current_mouse_y);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}}}}
|
||||
65
deps_src/libigl/igl/opengl/glfw/imgui/SelectionWidget.h
Normal file
65
deps_src/libigl/igl/opengl/glfw/imgui/SelectionWidget.h
Normal file
@@ -0,0 +1,65 @@
|
||||
#ifndef IGL_OPENGL_GFLW_IMGUI_SELECTIONWIDGET_H
|
||||
#define IGL_OPENGL_GFLW_IMGUI_SELECTIONWIDGET_H
|
||||
#include "../../../igl_inline.h"
|
||||
#include "ImGuiWidget.h"
|
||||
#include <Eigen/Dense>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <functional>
|
||||
|
||||
namespace igl{ namespace opengl{ namespace glfw{ namespace imgui{
|
||||
|
||||
/// Widget for selecting a region of the screen
|
||||
class SelectionWidget: public ImGuiWidget
|
||||
{
|
||||
public:
|
||||
// customizable hotkeys
|
||||
/// Hot key to start marquee
|
||||
std::string MARQUEE_KEY = "Mm";
|
||||
// leave 'L' for show_lines in viewer
|
||||
/// Hot key to start lasso
|
||||
std::string LASSO_KEY = "l";
|
||||
/// Hot key to stop selection
|
||||
std::string OFF_KEY = "Vv";
|
||||
/// Selection modes
|
||||
enum Mode
|
||||
{
|
||||
OFF = 0,
|
||||
RECTANGULAR_MARQUEE = 1,
|
||||
ELLIPTICAL_MARQUEE = 2,
|
||||
POLYGONAL_LASSO = 3,
|
||||
LASSO = 4,
|
||||
NUM_MODES = 5
|
||||
} mode = RECTANGULAR_MARQUEE;
|
||||
bool is_down = false;
|
||||
bool has_moved_since_down = false;
|
||||
bool is_drawing = false;
|
||||
// min and max corners of 2D rectangular marquee
|
||||
Eigen::Matrix<float,2,2> M = Eigen::Matrix<float,2,2>::Zero();
|
||||
// list of points of 2D lasso marquee
|
||||
std::vector<Eigen::RowVector2f> L;
|
||||
// callback called when slection is completed (usually on mouse_up)
|
||||
std::function<void(void)> callback;
|
||||
// callback called after mode is changed
|
||||
std::function<void(Mode)> callback_post_mode_change;
|
||||
IGL_INLINE virtual void init(Viewer *_viewer, ImGuiPlugin *_plugin) override;
|
||||
IGL_INLINE virtual void draw() override;
|
||||
IGL_INLINE virtual bool mouse_down(int button, int modifier) override;
|
||||
IGL_INLINE virtual bool mouse_up(int button, int modifier) override;
|
||||
IGL_INLINE virtual bool mouse_move(int mouse_x, int mouse_y) override;
|
||||
IGL_INLINE virtual bool key_pressed(unsigned int key, int modifiers) override;
|
||||
IGL_INLINE void clear();
|
||||
// helpers
|
||||
IGL_INLINE static void circle(const Eigen::Matrix<float,2,2> & M, std::vector<Eigen::RowVector2f> & L);
|
||||
IGL_INLINE static void rect(const Eigen::Matrix<float,2,2> & M, std::vector<Eigen::RowVector2f> & L);
|
||||
IGL_INLINE static Eigen::RowVector2f xy(const Viewer * v);
|
||||
public:
|
||||
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
|
||||
};
|
||||
|
||||
}}}}
|
||||
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
#include "SelectionWidget.cpp"
|
||||
#endif
|
||||
#endif
|
||||
Reference in New Issue
Block a user