diff --git a/src/libslic3r/Measure.cpp b/src/libslic3r/Measure.cpp index 8c7254f85..9cb46edfc 100644 --- a/src/libslic3r/Measure.cpp +++ b/src/libslic3r/Measure.cpp @@ -1,3 +1,4 @@ +#include "libslic3r/libslic3r.h" #include "Measure.hpp" #include "libslic3r/Geometry/Circle.hpp" @@ -407,10 +408,12 @@ Measuring::Measuring(const indexed_triangle_set& its) Measuring::~Measuring() {} +#if ENABLE_MEASURE_GIZMO_DEBUG std::vector Measuring::get_all_features() const { return priv->get_all_features(); } +#endif // ENABLE_MEASURE_GIZMO_DEBUG std::optional Measuring::get_feature(size_t face_idx, const Vec3d& point) const diff --git a/src/libslic3r/Measure.hpp b/src/libslic3r/Measure.hpp index fe0b1687a..98517b991 100644 --- a/src/libslic3r/Measure.hpp +++ b/src/libslic3r/Measure.hpp @@ -69,9 +69,11 @@ public: explicit Measuring(const indexed_triangle_set& its); ~Measuring(); +#if ENABLE_MEASURE_GIZMO_DEBUG // Return a reference to a list of all features identified on the its. // Use only for debugging. Expensive, do not call often. - [[deprecated]] std::vector get_all_features() const; + std::vector get_all_features() const; +#endif // ENABLE_MEASURE_GIZMO_DEBUG // Given a face_idx where the mouse cursor points, return a feature that // should be highlighted (if any). diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index ad23b4cbe..d5d2542cc 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -66,6 +66,8 @@ // Enable picking using raytracing #define ENABLE_RAYCAST_PICKING (1 && ENABLE_LEGACY_OPENGL_REMOVAL) #define ENABLE_RAYCAST_PICKING_DEBUG (0 && ENABLE_RAYCAST_PICKING) +// Enable debug code for Measure Gizmo +#define ENABLE_MEASURE_GIZMO_DEBUG (0 && ENABLE_2_5_0_ALPHA1) #endif // _prusaslicer_technologies_h_ diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp b/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp index dd562a649..d7a8f53f4 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp @@ -114,11 +114,11 @@ bool GLGizmoMeasure::on_is_activable() const void GLGizmoMeasure::on_render() { -#if !ENABLE_DEBUG_DIALOG +#if !ENABLE_MEASURE_GIZMO_DEBUG // do not render if the user is panning/rotating the 3d scene if (m_parent.is_mouse_dragging()) return; -#endif // !ENABLE_DEBUG_DIALOG +#endif // !ENABLE_MEASURE_GIZMO_DEBUG const Selection& selection = m_parent.get_selection(); @@ -134,7 +134,7 @@ void GLGizmoMeasure::on_render() size_t facet_idx; m_c->raycaster()->raycasters().front()->unproject_on_mesh(Vec2d(m_mouse_pos_x, m_mouse_pos_y), model_matrix, camera, pos, normal, nullptr, &facet_idx); -#if ENABLE_DEBUG_DIALOG +#if ENABLE_MEASURE_GIZMO_DEBUG m_imgui->begin(std::string("DEBUG")); m_imgui->checkbox(wxString("Show all features"), m_show_all); m_imgui->checkbox(wxString("Show all planes"), m_show_planes); @@ -144,33 +144,35 @@ void GLGizmoMeasure::on_render() m_imgui->text(std::string("pos_y: ") + std::to_string(pos.y())); m_imgui->text(std::string("pos_z: ") + std::to_string(pos.z())); m_imgui->end(); -#endif // ENABLE_DEBUG_DIALOG +#endif // ENABLE_MEASURE_GIZMO_DEBUG std::vector features; -#if ENABLE_DEBUG_DIALOG - if (m_show_all) { - features = m_measuring->get_all_features(); // EXPENSIVE - debugging only. - features.erase(std::remove_if(features.begin(), features.end(), - [](const Measure::SurfaceFeature& f) { - return f.get_type() == Measure::SurfaceFeatureType::Plane; - }), features.end()); +#if ENABLE_MEASURE_GIZMO_DEBUG + if (m_show_all || m_show_planes) { + features = m_measuring->get_all_features(); + if (!m_show_planes) + features.erase(std::remove_if(features.begin(), features.end(), + [](const Measure::SurfaceFeature& f) { + return f.get_type() == Measure::SurfaceFeatureType::Plane; + }), features.end()); + if (!m_show_all) + features.erase(std::remove_if(features.begin(), features.end(), + [](const Measure::SurfaceFeature& f) { + return f.get_type() != Measure::SurfaceFeatureType::Plane; + }), features.end()); } else { if (!m_parent.is_mouse_dragging()) { -#endif // ENABLE_DEBUG_DIALOG +#endif // ENABLE_MEASURE_GIZMO_DEBUG std::optional feat = m_measuring->get_feature(facet_idx, pos.cast()); if (feat.has_value()) features.emplace_back(*feat); -#if ENABLE_DEBUG_DIALOG +#if ENABLE_MEASURE_GIZMO_DEBUG } } -#endif // ENABLE_DEBUG_DIALOG +#endif // ENABLE_MEASURE_GIZMO_DEBUG -#if ENABLE_DEBUG_DIALOG - if (features.empty() && !m_show_planes) -#else if (features.empty()) -#endif // ENABLE_DEBUG_DIALOG return; GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light"); @@ -253,18 +255,6 @@ void GLGizmoMeasure::on_render() } } } -#if ENABLE_DEBUG_DIALOG - if (m_show_planes) { - const Transform3d view_model_matrix = view_matrix * model_matrix; - shader->set_uniform("view_model_matrix", view_model_matrix); - const Matrix3d view_normal_matrix = view_matrix.matrix().block(0, 0, 3, 3) * model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose(); - shader->set_uniform("view_normal_matrix", view_normal_matrix); - for (GLModel& glmodel : m_plane_models_cache) { - glmodel.set_color(HOVER_COLOR); - glmodel.render(); - } - } -#endif // ENABLE_DEBUG_DIALOG shader->stop_using(); } } diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMeasure.hpp b/src/slic3r/GUI/Gizmos/GLGizmoMeasure.hpp index 2cbdd1506..129175f15 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMeasure.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMeasure.hpp @@ -11,8 +11,6 @@ #include -#define ENABLE_DEBUG_DIALOG 0 - namespace Slic3r { class ModelVolume; @@ -51,10 +49,10 @@ private: int m_mouse_pos_x; int m_mouse_pos_y; -#if ENABLE_DEBUG_DIALOG +#if ENABLE_MEASURE_GIZMO_DEBUG bool m_show_all = false; bool m_show_planes = false; -#endif // ENABLE_DEBUG_DIALOG +#endif // ENABLE_MEASURE_GIZMO_DEBUG void update_if_needed();