mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-12-04 10:48:00 -05:00
Take one undo snapshot per groove count edit, and restore grooves across modes
The groove count took an undo snapshot on every step: each keystroke and each auto-repeat tick of a held +/- button, up to 99 for one edit. Take one when the edit starts, and the next once the field is no longer active. Undo restored the groove values only when the cut mode was the same before and after, so an undo that also changed the mode kept the current depth, width, angles, tolerances, count and gap. Restore them before the mode switch, which rebuilds the groove anyway.
This commit is contained in:
1 parent
ae92e7d071
commit
80ddae6d3b
2 files changed
+31
-20
No files matched your search
@@ -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();
|
||||
|
||||
@@ -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 };
|
||||
|
||||
|
||||
Reference in new issue
Block a user