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

+11 -46
View File
@@ -524,12 +524,6 @@ pub(super) struct OpenCADStudio {
snap_angle_input: String,
/// Model-space lineweight preview scale, in percent (25..=200).
lineweight_display_scale: i32,
/// Whole-interface scale, in percent (50..=200) — drives iced's own
/// per-window `scale_factor` (`run`'s `.scale_factor(...)` hook), so it
/// resizes every panel, dialog, the ribbon, and their text uniformly
/// rather than needing a separate font-size knob threaded through each
/// panel's own view code.
ui_scale: i32,
/// Isometric drafting state and active axis pair.
isometric_drafting: bool,
iso_plane: settings::IsoPlane,
@@ -553,25 +547,13 @@ pub(super) struct OpenCADStudio {
/// When true (default), the app registers itself as a .dwg/.dxf/.bak file
/// handler on each launch. Toggle with the FILEASSOC command.
pub file_assoc_enabled: bool,
/// When true, saving a drawing with sketch constraints also materializes
/// them as AutoCAD's own native `AssocNetwork`/`Assoc2dConstraintGroup`
/// object graph (`scene::dwg_native_constraints`), so AutoCAD/BricsCAD
/// recognize them as real constraints rather than an opaque OCS-only
/// XRecord. Off by default (#opt-in — adds objects/file weight every
/// user pays for save-after-save, whether or not they need AutoCAD
/// interop). A drawing that already carries this native graph (from a
/// prior save with this on, or from real AutoCAD) keeps it synced on
/// every save regardless of this setting — see
/// `Scene::materialize_dwg_native_constraints_for_save`'s doc comment;
/// this only governs whether the graph is *created* in a scope that
/// doesn't have one yet.
/// When true, saving creates native constraint objects alongside the
/// application's own persistence record. Existing native objects remain
/// synchronized regardless of this setting.
pub write_dwg_native_constraints: bool,
/// When true (default), a sketch constraint's viewport pill shows its
/// glyph plus a driven value or named-parameter name (e.g. "⌀ 5.000" or
/// "⌀ hole_dia"). When false, every pill shows just the bare glyph — the
/// value/name text can cover important canvas detail on a dense sketch,
/// and the glyph alone is already enough to see *that* a constraint is
/// present (`docs/parametric_system_design.md` §6.3/§7).
/// glyph plus a driven value or named-parameter name. When false, every
/// pill shows only the glyph.
pub show_constraint_values: bool,
/// Minutes between autosaves to a `.sv$` recovery file (SAVETIME command);
/// 0 disables autosave.
@@ -1066,7 +1048,7 @@ pub(super) struct OpenCADStudio {
/// edited. Seeded from `command_aliases` on open, committed back on close.
alias_editor_rows: Vec<(String, String)>,
// ── Named Parameters (docs/named_parameters_design.md, stage 4) ────────
// ── Named Parameters ──────────────────────────────────────────────────
/// Working buffer for the PARAMETERS modal. Unlike `alias_editor_rows`,
/// this isn't a copy of a separate app-level store — the real state
/// lives per-document at `Scene::named_parameters`; this buffer is
@@ -1999,12 +1981,6 @@ pub enum Message {
CursorTypeChanged(settings::CursorType),
/// Set the model-space lineweight preview scale from Options.
LineweightDisplayScaleChanged(i32),
/// Set the whole-interface scale (`ui_scale`) from Options.
UiScaleChanged(i32),
/// Set the ribbon's large-button icon-label font size from Options.
RibbonLabelFontSizeChanged(i32),
/// Set the ribbon's panel-title ("Draw", "Modify", …) font size from Options.
RibbonGroupTitleFontSizeChanged(i32),
/// Edit the optional crosshair RGB value; blank restores automatic contrast.
CrosshairColorChanged(String),
/// Set the default type/version used when first saving a new drawing.
@@ -2113,8 +2089,7 @@ pub enum Message {
/// Register or unregister as the .dwg/.dxf handler, from Options. Same
/// setting the FILEASSOC command carries.
FileAssocChanged(bool),
/// Toggle writing AutoCAD-native constraint objects on save, from
/// Options. See `write_dwg_native_constraints`'s doc comment.
/// Toggle writing native constraint objects on save.
WriteDwgNativeConstraintsChanged(bool),
/// Toggle showing driven values/named-parameter names on constraint
/// pills, from Options. See `show_constraint_values`'s doc comment.
@@ -2542,12 +2517,8 @@ pub enum Message {
CloseLayoutList,
/// Cycle the coordinate readout mode ($COORDS): static → live → polar.
CycleCoordsMode,
/// Design doc §6.4, stage 11: removes one flagged redundant/conflicting
/// constraint from the current sketch scope (a bounded v1 of the
/// "SketchXpert-style" resolver — one guided removal per click rather
/// than a candidate-list panel with a cyclable preview; see the status
/// bar's `ResolveOneSketchConflict` pill and
/// `OpenCADStudio::resolve_one_sketch_conflict` for the full rationale).
/// Removes one flagged redundant or conflicting constraint from the
/// current sketch scope.
/// No-op if the scope currently has no flagged conflict.
ResolveOneSketchConflict,
/// Toggle the status-bar customization menu open/closed.
@@ -2863,9 +2834,7 @@ pub enum Message {
/// and re-solve every constraint that reads a named parameter; stays
/// open.
NamedParametersApply,
// ── Parameters / Constraints sections embedded in the Properties panel
// (AutoCAD-style: a live section instead of the modal above, per-row
// commit-on-submit instead of a whole-table Apply) ─────────────────────
// ── Parameters / Constraints sections embedded in Properties ──────────
/// Live text of one column of parameter row `index`, keyed by its
/// `ParameterTable::iter()` position — see `PropValue::ParamRow`.
PropParamInput {
@@ -2880,8 +2849,7 @@ pub enum Message {
index: usize,
field: crate::ui::window::named_parameters::ParamField,
},
/// Remove parameter row `index` immediately (no confirmation, matching
/// AutoCAD's own Parameters Manager delete button).
/// Remove parameter row `index` immediately.
PropParamDelete(usize),
/// Append a fresh, uniquely-named parameter to `Scene::named_parameters`.
PropParamAddNew,
@@ -3566,7 +3534,6 @@ impl OpenCADStudio {
isolines_awaiting_regen: false,
snap_angle_input: "0".to_string(),
lineweight_display_scale: 100,
ui_scale: 100,
isometric_drafting: false,
iso_plane: settings::IsoPlane::Left,
snap_angle_deg: 0.0,
@@ -4180,7 +4147,6 @@ pub fn run() -> iced::Result {
..iced::Settings::default()
})
.subscription(OpenCADStudio::subscription)
.scale_factor(|state: &OpenCADStudio, _window: window::Id| state.ui_scale as f32 / 100.0)
.title(|state: &OpenCADStudio, window_id: window::Id| {
let _ = window_id; // all dialogs are in-canvas modals now
if let Some(tab) = state.tabs.get(state.active_tab) {
@@ -4225,7 +4191,6 @@ pub fn run_web() -> iced::Result {
OpenCADStudio::view_main,
)
.subscription(OpenCADStudio::subscription)
.scale_factor(|state: &OpenCADStudio| state.ui_scale as f32 / 100.0)
.title(|_state: &OpenCADStudio| {
concat!("Open CAD Studio ", env!("OCS_APP_VERSION")).to_string()
})