Add persistent sketch-constraint system (ocs_gcs port) and named-parameters handoff docs

Ports FreeCAD's planegcs 2D geometric constraint solver to Rust as a new
crates/ocs_gcs workspace member, and wires it into the document/scene model
as a persistent SketchConstraintSet: Coincident, Horizontal/Vertical,
Parallel/Perpendicular, Equal, Tangent, Distance, Angle and Radius
constraints that re-solve live (including mid-drag, not just on release),
render glyphs and a DOF badge, flag conflicts with a one-click resolver
pill, and round-trip through save/load via an XRecord blob.

Also includes docs/command_reference.md (a statically generated reference
of every registered command and its prompt sequence) and
docs/named_parameters_design.md + docs/backlog.md, which hand off the next
queued feature (a named-parameter/expression table) and consolidate every
deliberate scope-down and open gap found along the way, so a fresh session
has a complete starting point.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Felix RiestraandClaude Sonnet 5 committed 2026-09-08 22:19:23 +02:00
1 parent a39c7b8f71
commit 63a74b19a9
63 files changed
+12193 -49

No files matched your search

+50 -2
View File
@@ -1,11 +1,11 @@
use super::{
document::{
DeltaSnapshot, HistorySnapshot, ObjectEntryDelta, ObjectVisibilitySnapshot,
PendingHistorySnapshot, StructureSnapshot, TableEntryDelta,
PendingHistorySnapshot, SketchConstraintsSnapshot, StructureSnapshot, TableEntryDelta,
},
OpenCADStudio,
};
use crate::scene::ObjectIsolationState;
use crate::scene::{ChangeKind, ObjectIsolationState};
use acadrust::{EntityType, Handle};
use rustc_hash::{FxHashMap, FxHashSet as HashSet};
use std::sync::Arc;
@@ -184,6 +184,40 @@ impl OpenCADStudio {
);
}
/// Design doc §5.1/§9: makes a persistent-constraint add/remove
/// undoable. `before` is the scope's constraint set captured *before*
/// the caller's edit (by the caller, since this fn only sees "now");
/// `after` is read fresh here, so call this once the edit is done.
pub(super) fn push_sketch_constraints_history(
&mut self,
i: usize,
label: impl Into<String>,
scope: crate::scene::sketch_constraints::SketchScope,
before: Option<crate::scene::sketch_constraints::SketchConstraintSet>,
) {
self.finish_pending_history(i);
let after = self.tabs[i].scene.sketch_constraint_set(scope).cloned();
self.push_undo_entry(
i,
HistorySnapshot::SketchConstraints(SketchConstraintsSnapshot { scope, before, after, label: label.into() }),
);
}
fn apply_sketch_constraints_state(&mut self, i: usize, snapshot: &SketchConstraintsSnapshot, undo: bool) {
let state = if undo { snapshot.before.clone() } else { snapshot.after.clone() };
let scene = &mut self.tabs[i].scene;
let set = state.unwrap_or_else(|| crate::scene::sketch_constraints::SketchConstraintSet::new(snapshot.scope));
// The restored set's geometry may be stale (e.g. redo re-adds a
// constraint whose entities moved via other edits since) — resolve
// every entity it references, same as a fresh add would.
let touched: Vec<Handle> = set.constraints.iter().flat_map(|c| c.refs.iter().map(|r| r.entity)).collect();
*scene.sketch_constraint_set_mut(snapshot.scope) = set;
if !touched.is_empty() {
let changes: Vec<(Handle, ChangeKind)> = touched.into_iter().map(|h| (h, ChangeKind::Modified)).collect();
scene.bump_entities(&changes);
}
}
pub(super) fn push_entity_group_history(
&mut self,
i: usize,
@@ -1102,6 +1136,13 @@ impl OpenCADStudio {
.redo_stack
.push(HistorySnapshot::ObjectVisibility(v));
}
HistorySnapshot::SketchConstraints(s) => {
self.apply_sketch_constraints_state(i, &s, true);
self.tabs[i]
.history
.redo_stack
.push(HistorySnapshot::SketchConstraints(s));
}
}
}
self.finish_history_apply(i, had_full, layer_panel_changed, &changes);
@@ -1157,6 +1198,13 @@ impl OpenCADStudio {
.undo_stack
.push(HistorySnapshot::ObjectVisibility(v));
}
HistorySnapshot::SketchConstraints(s) => {
self.apply_sketch_constraints_state(i, &s, false);
self.tabs[i]
.history
.undo_stack
.push(HistorySnapshot::SketchConstraints(s));
}
}
}
self.finish_history_apply(i, had_full, layer_panel_changed, &changes);