Undo changes to the dovetail count and gap

The cut tool's undo state held the dovetail shape but not the number of
dovetails or the gap between them, so undo left both as they were.
Changing the count with its buttons did not take a snapshot either.
Save both in the state and take a snapshot when the count changes.

Ported from Snapmaker/OrcaSlicer@b070bcfaff

Co-authored-by: mwz-iot <mawenzhi@snapmaker>
This commit is contained in:
Ian Bassiandmwz-iot committed 2026-11-30 17:03:38 -03:00
1 parent d929ad71b0
commit fd9f2d8450
1 file changed
+13 -3
+13 -3
View File
@@ -1426,10 +1426,13 @@ void GLGizmoCut3D::on_load(cereal::BinaryInputArchive& ar)
float groove_angle;
float groove_depth_tolerance;
float groove_width_tolerance;
int groove_count;
float groove_gap;
ar( m_keep_upper, m_keep_lower, m_rotate_lower, m_rotate_upper, m_hide_cut_plane, mode, m_connectors_editing,
m_ar_plane_center, m_rotation_m,
groove_depth, groove_width, groove_flaps_angle, groove_angle, groove_depth_tolerance, groove_width_tolerance);
groove_depth, groove_width, groove_flaps_angle, groove_angle, groove_depth_tolerance, groove_width_tolerance,
groove_count, groove_gap);
m_start_dragging_m = m_rotation_m;
@@ -1444,7 +1447,9 @@ void GLGizmoCut3D::on_load(cereal::BinaryInputArchive& ar)
!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) )
!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;
@@ -1452,6 +1457,8 @@ void GLGizmoCut3D::on_load(cereal::BinaryInputArchive& ar)
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;
update_plane_model();
}
reset_cut_by_contours();
@@ -1464,7 +1471,8 @@ void GLGizmoCut3D::on_save(cereal::BinaryOutputArchive& ar) const
{
ar( m_keep_upper, m_keep_lower, m_rotate_lower, m_rotate_upper, m_hide_cut_plane, m_mode, m_connectors_editing,
m_ar_plane_center, m_start_dragging_m,
m_groove.depth, m_groove.width, m_groove.flaps_angle, m_groove.angle, m_groove.depth_tolerance, m_groove.width_tolerance);
m_groove.depth, m_groove.width, m_groove.flaps_angle, m_groove.angle, m_groove.depth_tolerance, m_groove.width_tolerance,
m_groove_count, m_groove_gap);
}
std::string GLGizmoCut3D::on_get_name() const
@@ -2798,6 +2806,8 @@ 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);
in_val = val;
is_changed = true;
}