Added tech ENABLE_MEASURE_GIZMO_DEBUG to embed debug code related to GLGizmoMeasure
This commit is contained in:
parent
86b390e237
commit
7b43786124
@ -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<SurfaceFeature> Measuring::get_all_features() const
|
||||
{
|
||||
return priv->get_all_features();
|
||||
}
|
||||
#endif // ENABLE_MEASURE_GIZMO_DEBUG
|
||||
|
||||
|
||||
std::optional<SurfaceFeature> Measuring::get_feature(size_t face_idx, const Vec3d& point) const
|
||||
|
@ -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<SurfaceFeature> get_all_features() const;
|
||||
std::vector<SurfaceFeature> 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).
|
||||
|
@ -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_
|
||||
|
@ -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<Measure::SurfaceFeature> features;
|
||||
#if ENABLE_DEBUG_DIALOG
|
||||
if (m_show_all) {
|
||||
features = m_measuring->get_all_features(); // EXPENSIVE - debugging only.
|
||||
#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<Measure::SurfaceFeature> feat = m_measuring->get_feature(facet_idx, pos.cast<double>());
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -11,8 +11,6 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user