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 <[email protected]>
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

+12
View File
@@ -775,6 +775,8 @@ impl OpenCADStudio {
annotation_auto_scale: self.annotation_auto_scale,
ribbon: crate::app::config::RibbonConfig {
collapse: self.ribbon.collapse_mode(),
label_font_size: self.ribbon.label_font_size(),
group_title_font_size: self.ribbon.group_title_font_size(),
},
plot: self.plot_dialog.clone(),
shortcuts: crate::app::config::ShortcutConfig {
@@ -832,6 +834,9 @@ impl OpenCADStudio {
self.dock = dock;
self.annotation_auto_scale = cfg.annotation_auto_scale.clamp(-4, 4);
self.ribbon.set_collapse_mode(cfg.ribbon.collapse);
self.ribbon.set_label_font_size(cfg.ribbon.label_font_size);
self.ribbon
.set_group_title_font_size(cfg.ribbon.group_title_font_size);
self.plot_dialog = cfg.plot;
self.shortcut_bindings = cfg.shortcuts.bindings.into_iter().collect();
self.shortcut_bindings
@@ -1383,6 +1388,9 @@ pub(super) fn on_open_file(&mut self) -> Task<Message> {
self.tabs[i].scene.material_base_dir =
path.parent().map(std::path::Path::to_path_buf);
self.tabs[i].scene.document = doc;
// Design doc §8 stage 4: read back any persisted sketch
// constraint sets right after the document is installed.
self.tabs[i].scene.load_sketch_constraints_from_document();
self.tabs[i].active_layer = self.tabs[i]
.scene
.document
@@ -1646,6 +1654,9 @@ pub(super) fn on_open_file(&mut self) -> Task<Message> {
self.tabs[i].scene.document.header.user_real1 =
self.tabs[i].scene.annotation_scale as f64;
self.sync_solid_models_for_save(i);
// Design doc §8 stage 4: write any sketch constraint sets into the
// document right before it's serialized.
self.tabs[i].scene.materialize_sketch_constraints_for_save();
}
#[cfg(not(target_arch = "wasm32"))]
@@ -2596,6 +2607,7 @@ pub(super) fn on_open_file(&mut self) -> Task<Message> {
sync_annotation_scale_header(&mut self.tabs[i].scene);
self.stamp_header_sysvars(i);
self.sync_solid_models_for_save(i);
self.tabs[i].scene.materialize_sketch_constraints_for_save();
let tab_id = self.tabs[i].id;
let bounds = crate::ui::wrap_bar::dropdown_bounds(
crate::app::view::VIEWPORT_CAPTURE_BOUNDS_ID,
+16
View File
@@ -3292,6 +3292,10 @@ impl OpenCADStudio {
}
Task::none()
}
Message::ResolveOneSketchConflict => {
self.resolve_one_sketch_conflict();
Task::none()
}
Message::TogglePolar => {
self.polar_mode ^= true;
if self.polar_mode {
@@ -5872,6 +5876,18 @@ impl OpenCADStudio {
Task::none()
}
Message::RibbonLabelFontSizeChanged(value) => {
self.ribbon.set_label_font_size(value);
self.save_config();
Task::none()
}
Message::RibbonGroupTitleFontSizeChanged(value) => {
self.ribbon.set_group_title_font_size(value);
self.save_config();
Task::none()
}
Message::CrosshairColorChanged(value) => {
self.crosshair_color_input = value.clone();
if value.trim().is_empty() {
+32 -1
View File
@@ -1246,7 +1246,7 @@ impl OpenCADStudio {
};
let mut seen_handles = rustc_hash::FxHashSet::default();
let edited_handles: Vec<_> = grip
let mut edited_handles: Vec<_> = grip
.targets
.iter()
.map(|target| target.handle)
@@ -1681,6 +1681,37 @@ impl OpenCADStudio {
);
}
}
// Live sketch-constraint re-solve (design doc §7 open question
// 6): previously constrained neighbors only snapped into place
// on grip release — this runs the same rebuild-and-solve every
// frame so they track the drag live. First touch this gesture
// captures the neighbor's original state into the grip's own
// undo tracking (mirroring how `edited_handles` itself is
// captured above) and hides it from the resident tessellation;
// every frame folds it into this frame's `edited_handles` so the
// existing mesh/hatch/wire-preview refresh below already covers
// it for free.
let solved_by_constraints = self.tabs[i].scene.solve_sketch_constraints_preview(&edited_handles);
for (handle, _) in &solved_by_constraints {
let handle = *handle;
if !self.grip_preview_handles.contains(&handle) {
if let Some(original) = self.tabs[i].scene.document.get_entity(handle).cloned() {
self.grip_originals.push((handle, original));
}
self.grip_preview_handles.push(handle);
if !self.tabs[i].scene.meshes.contains_key(&handle) {
self.tabs[i].scene.preview_hidden.insert(handle);
}
}
if !edited_handles.contains(&handle) {
edited_handles.push(handle);
}
}
for (handle, new_entity) in solved_by_constraints {
if let Some(slot) = self.tabs[i].scene.document.get_entity_mut(handle) {
*slot = new_entity;
}
}
let mesh_changes: Vec<_> = edited_handles
.iter()
.copied()