diff --git a/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp b/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp index 90680a1605..c5a10db667 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp @@ -1439,28 +1439,31 @@ void GLGizmoCut3D::on_load(cereal::BinaryInputArchive& ar) m_transformed_bounding_box = transformed_bounding_box(m_ar_plane_center, m_rotation_m); set_center_pos(m_ar_plane_center); + // Restored in every mode, so an undo that also changes the mode brings them back too. + const bool groove_changed = !is_approx(m_groove.depth , groove_depth) || + !is_approx(m_groove.width , groove_width) || + !is_approx(m_groove.flaps_angle , groove_flaps_angle) || + !is_approx(m_groove.angle , groove_angle) || + !is_approx(m_groove.depth_tolerance, groove_depth_tolerance) || + !is_approx(m_groove.width_tolerance, groove_width_tolerance) || + m_groove_count != groove_count || + !is_approx(m_groove_gap, groove_gap); + if (groove_changed) { + m_groove.depth = groove_depth; + m_groove.width = groove_width; + m_groove.flaps_angle = groove_flaps_angle; + m_groove.angle = groove_angle; + m_groove.depth_tolerance= groove_depth_tolerance; + m_groove.width_tolerance= groove_width_tolerance; + m_groove_count = groove_count; + m_groove_gap = groove_gap; + } + if (m_mode != mode) switch_to_mode(mode); else if (CutMode(m_mode) == CutMode::cutTongueAndGroove) { - if (!is_approx(m_groove.depth , groove_depth) || - !is_approx(m_groove.width , groove_width) || - !is_approx(m_groove.flaps_angle , groove_flaps_angle) || - !is_approx(m_groove.angle , groove_angle) || - !is_approx(m_groove.depth_tolerance, groove_depth_tolerance) || - !is_approx(m_groove.width_tolerance, groove_width_tolerance) || - m_groove_count != groove_count || - !is_approx(m_groove_gap, groove_gap) ) - { - m_groove.depth = groove_depth; - m_groove.width = groove_width; - m_groove.flaps_angle = groove_flaps_angle; - m_groove.angle = groove_angle; - m_groove.depth_tolerance= groove_depth_tolerance; - m_groove.width_tolerance= groove_width_tolerance; - m_groove_count = groove_count; - m_groove_gap = groove_gap; + if (groove_changed) update_plane_model(); - } reset_cut_by_contours(); } @@ -2806,12 +2809,18 @@ void GLGizmoCut3D::render_groove_int_input(const std::string& label, int& in_val val = std::clamp(val, min_val, max_val); // ORCA Holding +/- at the limit clamps back to the same value, don't rebuild for that. if (val != in_val) { - Plater::TakeSnapshot snapshot(wxGetApp().plater(), GUI::format("%1%: %2%", _u8L("Groove change"), label), - UndoRedo::SnapshotType::GizmoAction); + // One snapshot per edit, not per keystroke or auto-repeat step. + if (!m_int_input_snapshot_taken) { + Plater::TakeSnapshot snapshot(wxGetApp().plater(), GUI::format("%1%: %2%", _u8L("Groove change"), label), + UndoRedo::SnapshotType::GizmoAction); + m_int_input_snapshot_taken = true; + } in_val = val; is_changed = true; } } + if (!ImGui::IsItemActive()) + m_int_input_snapshot_taken = false; m_imgui->request_frames_while_held(); // ORCA auto-repeat of the +/- buttons ImGui::SameLine(); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoCut.hpp b/src/slic3r/GUI/Gizmos/GLGizmoCut.hpp index 6148f8a4ad..1eca065a73 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoCut.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoCut.hpp @@ -140,6 +140,8 @@ class GLGizmoCut3D : public GLGizmoBase // Multiple Dovetail cuts int m_groove_count_init { 1 }; int m_groove_count { 1 }; + // The active edit of an integer groove field already has its undo snapshot. + bool m_int_input_snapshot_taken { false }; float m_groove_gap { 10.f }; // distance between multiple dovetail cuts float m_groove_gap_init { 10.f };