FDM supports - setting by angle highlight the facets in real time (experiment)
This commit is contained in:
parent
d24a3453af
commit
d90cea7aad
@ -1454,7 +1454,7 @@ void GLCanvas3D::Tooltip::render(const Vec2d& mouse_position, GLCanvas3D& canvas
|
||||
#if ENABLE_SLOPE_RENDERING
|
||||
void GLCanvas3D::Slope::render() const
|
||||
{
|
||||
if (is_shown())
|
||||
if (m_dialog_shown)
|
||||
{
|
||||
const std::array<float, 2>& z_range = m_volumes.get_slope_z_range();
|
||||
std::array<float, 2> angle_range = { Geometry::rad2deg(::acos(z_range[0])) - 90.0f, Geometry::rad2deg(::acos(z_range[1])) - 90.0f };
|
||||
@ -1502,7 +1502,7 @@ void GLCanvas3D::Slope::render() const
|
||||
imgui.end();
|
||||
|
||||
if (modified)
|
||||
m_volumes.set_slope_z_range({ -::cos(Geometry::deg2rad(90.0f - angle_range[0])), -::cos(Geometry::deg2rad(90.0f - angle_range[1])) });
|
||||
set_range(angle_range);
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_SLOPE_RENDERING
|
||||
@ -1911,8 +1911,8 @@ bool GLCanvas3D::is_reload_delayed() const
|
||||
void GLCanvas3D::enable_layers_editing(bool enable)
|
||||
{
|
||||
#if ENABLE_SLOPE_RENDERING
|
||||
if (enable && m_slope.is_shown())
|
||||
m_slope.show(false);
|
||||
if (enable && m_slope.is_dialog_shown())
|
||||
m_slope.show_dialog(false);
|
||||
#endif // ENABLE_SLOPE_RENDERING
|
||||
|
||||
m_layers_editing.set_enabled(enable);
|
||||
@ -3123,7 +3123,7 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
|
||||
case 'd': {
|
||||
if (!is_layers_editing_enabled())
|
||||
{
|
||||
m_slope.show(!m_slope.is_shown());
|
||||
m_slope.show_dialog(!m_slope.is_dialog_shown());
|
||||
m_dirty = true;
|
||||
}
|
||||
break;
|
||||
|
@ -414,6 +414,7 @@ private:
|
||||
class Slope
|
||||
{
|
||||
bool m_enabled{ false };
|
||||
bool m_dialog_shown{ false };
|
||||
GLCanvas3D& m_canvas;
|
||||
GLVolumeCollection& m_volumes;
|
||||
|
||||
@ -422,9 +423,14 @@ private:
|
||||
|
||||
void enable(bool enable) { m_enabled = enable; }
|
||||
bool is_enabled() const { return m_enabled; }
|
||||
void show(bool show) { m_volumes.set_slope_active(m_enabled ? show : false); }
|
||||
bool is_shown() const { return m_volumes.is_slope_active(); }
|
||||
void use(bool use) { m_volumes.set_slope_active(m_enabled ? use : false); }
|
||||
bool is_used() const { return m_volumes.is_slope_active(); }
|
||||
void show_dialog(bool show) { if (show && is_used()) return; use(show); m_dialog_shown = show; }
|
||||
bool is_dialog_shown() const { return m_dialog_shown; }
|
||||
void render() const;
|
||||
void set_range(const std::array<float, 2>& range) const {
|
||||
m_volumes.set_slope_z_range({ -::cos(Geometry::deg2rad(90.0f - range[0])), -::cos(Geometry::deg2rad(90.0f - range[1])) });
|
||||
}
|
||||
};
|
||||
#endif // ENABLE_SLOPE_RENDERING
|
||||
|
||||
@ -734,8 +740,10 @@ public:
|
||||
void show_labels(bool show) { m_labels.show(show); }
|
||||
|
||||
#if ENABLE_SLOPE_RENDERING
|
||||
bool is_slope_shown() const { return m_slope.is_shown(); }
|
||||
void show_slope(bool show) { m_slope.show(show); }
|
||||
bool is_slope_shown() const { return m_slope.is_dialog_shown(); }
|
||||
void use_slope(bool use) { m_slope.use(use); }
|
||||
void show_slope(bool show) { m_slope.show_dialog(show); }
|
||||
void set_slope_range(const std::array<float, 2>& range) { m_slope.set_range(range); }
|
||||
#endif // ENABLE_SLOPE_RENDERING
|
||||
|
||||
private:
|
||||
|
@ -84,6 +84,9 @@ void GLGizmoFdmSupports::on_render() const
|
||||
|
||||
void GLGizmoFdmSupports::render_triangles(const Selection& selection) const
|
||||
{
|
||||
if (m_setting_angle)
|
||||
return;
|
||||
|
||||
const ModelObject* mo = m_c->selection_info()->model_object();
|
||||
|
||||
glsafe(::glEnable(GL_POLYGON_OFFSET_FILL));
|
||||
@ -667,27 +670,34 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l
|
||||
}
|
||||
|
||||
m_imgui->end();
|
||||
if (m_setting_angle)
|
||||
if (m_setting_angle) {
|
||||
m_parent.show_slope(false);
|
||||
m_parent.set_slope_range({m_angle_threshold_deg, m_angle_threshold_deg});
|
||||
m_parent.use_slope(true);
|
||||
m_parent.set_as_dirty();
|
||||
}
|
||||
}
|
||||
else {
|
||||
std::string name = "Autoset custom supports";
|
||||
m_imgui->begin(wxString(name), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse);
|
||||
m_imgui->text("Threshold:");
|
||||
ImGui::SameLine();
|
||||
m_imgui->slider_float("", &m_angle_threshold_deg, 0.f, 90.f, "%.f");
|
||||
if (m_imgui->slider_float("", &m_angle_threshold_deg, 0.f, 90.f, "%.f"))
|
||||
m_parent.set_slope_range({m_angle_threshold_deg, m_angle_threshold_deg});
|
||||
m_imgui->checkbox(wxString("Overwrite already selected facets"), m_overwrite_selected);
|
||||
if (m_imgui->button("Enforce"))
|
||||
select_facets_by_angle(m_angle_threshold_deg, m_overwrite_selected, false);
|
||||
select_facets_by_angle(90.f - m_angle_threshold_deg, m_overwrite_selected, false);
|
||||
ImGui::SameLine();
|
||||
if (m_imgui->button("Block"))
|
||||
select_facets_by_angle(m_angle_threshold_deg, m_overwrite_selected, true);
|
||||
select_facets_by_angle(90.f - m_angle_threshold_deg, m_overwrite_selected, true);
|
||||
ImGui::SameLine();
|
||||
if (m_imgui->button("Cancel"))
|
||||
m_setting_angle = false;
|
||||
m_imgui->end();
|
||||
if (! m_setting_angle)
|
||||
if (! m_setting_angle) {
|
||||
m_parent.use_slope(false);
|
||||
m_parent.set_as_dirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user