Harden parametric sketch constraints

This commit is contained in:
Hakan Seven committed 2026-09-11 09:45:57 +03:00
1 parent 41c07e9858
commit 9b58ca8a93
101 files changed
+3128 -13767

No files matched your search

+3 -14
View File
@@ -407,7 +407,6 @@ impl OpenCADStudio {
cursor_type: self.cursor_type,
crosshair_color: self.crosshair_color,
lineweight_display_scale: self.lineweight_display_scale,
ui_scale: self.ui_scale,
isometric_drafting: self.isometric_drafting,
iso_plane: self.iso_plane,
snap_angle_deg: self.snap_angle_deg,
@@ -477,7 +476,6 @@ impl OpenCADStudio {
.map(crate::app::config::rgb_to_hex)
.unwrap_or_default();
self.lineweight_display_scale = s.lineweight_display_scale.clamp(25, 200);
self.ui_scale = s.ui_scale.clamp(50, 200);
self.isometric_drafting = s.isometric_drafting;
self.iso_plane = s.iso_plane;
self.snap_angle_deg = if s.snap_angle_deg.is_finite() {
@@ -836,8 +834,6 @@ 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 {
@@ -895,9 +891,6 @@ 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
@@ -1449,8 +1442,7 @@ 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.
// Load persisted constraints after installing the document.
self.tabs[i].scene.load_sketch_constraints_from_document();
// named_parameters_design.md stage 2: same load-time hook,
// for the document-wide parameter table.
@@ -1718,15 +1710,12 @@ 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.
// Materialize constraints immediately before serialization.
self.tabs[i].scene.materialize_sketch_constraints_for_save();
// named_parameters_design.md stage 2: same save-time hook, for the
// document-wide parameter table.
self.tabs[i].scene.materialize_named_parameters_for_save();
// docs/dwg_constraint_compatibility_design.md: additive DWG/DXF-
// native constraint graph, alongside (not instead of) the XRecord
// above — same save-time hook.
// Keep the optional native constraint graph synchronized on save.
self.tabs[i].scene.materialize_dwg_native_constraints_for_save(self.write_dwg_native_constraints);
}
-18
View File
@@ -6040,24 +6040,6 @@ impl OpenCADStudio {
Task::none()
}
Message::UiScaleChanged(value) => {
self.ui_scale = value.clamp(50, 200);
self.persist_settings_if_changed();
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() {
+2 -10
View File
@@ -1706,16 +1706,8 @@ 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.
// Re-solve constrained neighbors on each drag frame and include
// their original state in the gesture's undo record.
let solved_by_constraints = self.tabs[i].scene.solve_sketch_constraints_preview(&edited_handles);
for (handle, _) in &solved_by_constraints {
let handle = *handle;