Skip to content

SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.

Sketch: a preference to project references as construction geometry (#13142) (#13166)

0rdnungsamt3c4b33608028
diff --git a/assets/locales/pending/project-references-construction.json b/assets/locales/pending/project-references-construction.json
new file mode 100644
index 0000000000..7d9b7c377e
--- /dev/null
+++ b/assets/locales/pending/project-references-construction.json
@@ -0,0 +1,34 @@
+{
+ "en": {
+ "ui.project_references_construction": "Project references as construction geometry",
+ "ui.project_references_construction_note": "Project, Intersect, Include 3D Geometry and the face edges of a new sketch on a face make construction geometry: references to draw against, left out of profiles. They stay linked to the model."
+ },
+ "de": {
+ "ui.project_references_construction": "Referenzen als Konstruktionsgeometrie projizieren",
+ "ui.project_references_construction_note": "Projizieren, Schneiden, 3D-Geometrie einbeziehen und die Flächenkanten einer neuen Skizze auf einer Fläche erzeugen Konstruktionsgeometrie: Bezüge zum Zeichnen, die nicht zu Profilen gehören. Sie bleiben mit dem Modell verknüpft."
+ },
+ "ko": {
+ "ui.project_references_construction": "참조를 구성선으로 투영",
+ "ui.project_references_construction_note": "투영, 교차, 3D 형상 포함과 면 위 새 스케치의 면 모서리가 구성선으로 만들어집니다. 프로파일에 포함되지 않는 그리기용 참조이며, 모델과의 연결은 유지됩니다."
+ },
+ "ar": {
+ "ui.project_references_construction": "إسقاط المراجع كهندسة مساعدة",
+ "ui.project_references_construction_note": "ينشئ الإسقاط والتقاطع وتضمين الهندسة ثلاثية الأبعاد وحواف الوجه لرسم جديد على وجه هندسةً مساعدة: مراجع للرسم عليها لا تدخل في المقاطع. وتبقى مرتبطة بالنموذج."
+ },
+ "he": {
+ "ui.project_references_construction": "הטלת הפניות כגאומטריית עזר",
+ "ui.project_references_construction_note": "הטלה, חיתוך, הכללת גאומטריה תלת־ממדית ומקצועות הפאה של סקיצה חדשה על פאה יוצרים גאומטריית עזר: הפניות לשרטוט שאינן נכללות בפרופילים. הן נשארות מקושרות למודל."
+ },
+ "ja": {
+ "ui.project_references_construction": "参照をコンストラクションジオメトリとして投影",
+ "ui.project_references_construction_note": "投影、交差、3D ジオメトリを含める、および面上の新規スケッチの面のエッジは、コンストラクションジオメトリになります。描画の参照用で、プロファイルには含まれません。モデルとのリンクは保たれます。"
+ },
+ "vi": {
+ "ui.project_references_construction": "Chiếu tham chiếu thành đường dựng hình",
+ "ui.project_references_construction_note": "Chiếu, Giao, Đưa vào hình học 3D và các cạnh bề mặt của phác thảo mới trên một bề mặt tạo ra đường dựng hình: tham chiếu để vẽ theo, không thuộc biên dạng. Chúng vẫn liên kết với mô hình."
+ },
+ "zh": {
+ "ui.project_references_construction": "将参考投影为构造几何",
+ "ui.project_references_construction_note": "投影、相交、包含三维几何以及在面上新建草图时投影的面边,都会生成构造几何:用于绘图参考,不计入轮廓。它们仍与模型保持关联。"
+ }
+}
diff --git a/crates/engine/src/cmd/sketch.rs b/crates/engine/src/cmd/sketch.rs
index 144eb0901f..69dcec9b55 100644
--- a/crates/engine/src/cmd/sketch.rs
+++ b/crates/engine/src/cmd/sketch.rs
@@ -1148,6 +1148,11 @@ fn sketch_on_plane(s: &mut Session, p: &Value, plane: PlaneRef, internal_body: O
{
link = Some(super::sketch_project::project_internal_face(s, id, body, index)?);
}
+ if s.project_construction
+ && let Some(link) = &link
+ {
+ super::sketch_project::construct_link(s, id, link)?;
+ }
}
let attachment = s.doc.feature(id).and_then(|feature| match &feature.kind {
FeatureKind::Sketch { plane, .. } => Some(if face::anchor(plane).is_some() {
diff --git a/crates/engine/src/cmd/sketch_project.rs b/crates/engine/src/cmd/sketch_project.rs
index 0b1de8ec77..c641e8a176 100644
--- a/crates/engine/src/cmd/sketch_project.rs
+++ b/crates/engine/src/cmd/sketch_project.rs
@@ -40,16 +40,16 @@ const AUTO_PROJECT_CONTRACT: TypedContract<AutoProjectParams> = TypedContract::n
pub static COMMANDS: &[CommandSpec] = &[
CommandSpec::new("sketch.project", "Project", crate::checked!("sketch.project", project_cmd)).at("SKETCH", "CREATE").icon("project").key("P").enabled(in_sketch).contract(&PROJECT_CONTRACT).output(output_schema_for::<ProjectResult>).params(
- concat!(refs_doc!(), "; projection_link?: bool (default true)", created_doc!()),
+ concat!(refs_doc!(), "; projection_link?: bool (default true); construction?: bool (default the session's preference, off: the created curves are construction geometry)", created_doc!()),
),
CommandSpec::new("sketch.intersect", "Intersect", crate::checked!("sketch.intersect", intersect_cmd)).at("SKETCH", "CREATE").icon("intersect").enabled(in_sketch).contract(&INTERSECT_CONTRACT).output(output_schema_for::<ProjectResult>).params(
- concat!("refs: [{body}, {face: [x,y,z], body?}, {edge: [x,y,z], body?}, {sketch, curve}]: section curves (or points) with the sketch plane; projection_link?: bool (default true)", created_doc!()),
+ concat!("refs: [{body}, {face: [x,y,z], body?}, {edge: [x,y,z], body?}, {sketch, curve}]: section curves (or points) with the sketch plane; projection_link?: bool (default true); construction?: bool (default the session's preference, off: the created curves are construction geometry)", created_doc!()),
),
CommandSpec::new("sketch.include_3d", "Include 3D Geometry", crate::checked!("sketch.include_3d", include_cmd))
.at("SKETCH", "CREATE")
.icon("include")
.enabled(in_sketch)
- .contract(&INCLUDE_3D_CONTRACT).output(output_schema_for::<ProjectResult>).params(concat!("refs: like Project (edges, vertices, sketch curves and points); curves out of the sketch plane are flattened onto it", created_doc!())),
+ .contract(&INCLUDE_3D_CONTRACT).output(output_schema_for::<ProjectResult>).params(concat!("refs: like Project (edges, vertices, sketch curves and points); curves out of the sketch plane are flattened onto it; construction?: bool (default the session's preference, off: the created curves are construction geometry)", created_doc!())),
CommandSpec::new("sketch.project_to_surface", "Project To Surface", crate::checked!("sketch.project_to_surface", project_to_surface))
.at("SKETCH", "CREATE")
.icon("project_surface")
@@ -452,6 +452,26 @@ fn add_link_unless_present(
Ok(Some(link))
}
+/// Make the curves of `link` construction geometry: references to draw against, left out of
+/// profiles (#13142). They stay linked; a link rebuilt because its shape changed comes back as
+/// normal geometry, as curves switched to construction by hand do.
+fn mark_construction(sk: &mut Sketch, link: &str) {
+ for c in sk.link_curves(link) {
+ if let Some(curve) = sk.curves.get_mut(c) {
+ curve.construction = true;
+ }
+ }
+}
+
+/// [`mark_construction`] for `link` in sketch `id`, as the session's preference asks of the face
+/// edges a new sketch projects (#13142).
+pub(super) fn construct_link(s: &mut Session, id: u64, link: &str) -> Result<()> {
+ sketch_store::update(s, id, |_, _, sk| {
+ mark_construction(sk, link);
+ Ok(())
+ })
+}
+
/// A command's reply as JSON: they build their replies from the types their output schemas
/// describe, so the two can't drift apart.
fn reply(cmd: &str, reply: impl serde::Serialize) -> Result<Value> {
@@ -474,6 +494,11 @@ fn run_links(s: &mut Session, p: &Value, cmd: &str, kind: LinkKind, projection_l
if refs.is_empty() {
return Err(bad(cmd, "`refs` is empty"));
}
+ let construction = match p.get("construction") {
+ None => s.project_construction,
+ Some(Value::Bool(value)) => *value,
+ Some(_) => return Err(bad(cmd, "`construction` must be a boolean")),
+ };
let id = sketch_store::active(s).ok_or_else(|| EngineError::Other("no sketch is being edited".into()))?;
let sources: Vec<LinkSource> = refs.iter().map(|v| source(s, v, cmd)).collect::<Result<_>>()?;
let (out, present) = sketch_store::update(s, id, |s, doc, sk| {
@@ -487,6 +512,9 @@ fn run_links(s: &mut Session, p: &Value, cmd: &str, kind: LinkKind, projection_l
match add_link_unless_present(s, doc, id, sk, kind, src, kind == LinkKind::Project) {
Ok(Some(l)) => {
let (curves, points) = link_parts(sk, &l);
+ if construction {
+ mark_construction(sk, &l);
+ }
let mut result = ProjectedLink { link: Some(l.clone()), curves, points };
if !projection_link {
result.link = None;
diff --git a/crates/engine/src/cmd/sketch_project_tests.rs b/crates/engine/src/cmd/sketch_project_tests.rs
index 3e19f6b59a..168fc3667e 100644
--- a/crates/engine/src/cmd/sketch_project_tests.rs
+++ b/crates/engine/src/cmd/sketch_project_tests.rs
@@ -1763,3 +1763,43 @@ fn a_second_placements_face_and_edge_project_where_it_is_placed() {
check(&s, 15.0);
check(&Session::new(solidcraft_doc::Document::from_json(&s.doc.to_json()).unwrap()), 15.0);
}
+
+/// #13142: projected references can start as construction geometry, asked for per call or for
+/// the whole session (a preference, kept for designs started and opened like `auto_project`).
+#[test]
+fn projected_references_can_start_as_construction() {
+ let flags = |s: &mut Session| linked_curves(&inspect(s)).iter().map(|c| c["construction"] == true).collect::<Vec<_>>();
+ let mut s = Session::default();
+ box_part(&mut s);
+ // Off (the default): the face loop is normal geometry and closes a profile.
+ run(&mut s, "sketch.create", json!({"plane": {"face": [20, 15, 20]}}));
+ let on_face = flags(&mut s);
+ assert!(on_face.len() == 4 && on_face.iter().all(|c| !c), "{on_face:?}");
+ assert_eq!(inspect(&mut s)["profiles"].as_array().map(Vec::len), Some(1));
+ run(&mut s, "sketch.finish", json!({}));
+ // Asked for in the call, and not.
+ run(&mut s, "sketch.create", json!({"plane": "XY"}));
+ run(&mut s, "sketch.project", json!({"refs": [{"edge": [20, 0, 20]}], "construction": true}));
+ assert_eq!(flags(&mut s), vec![true]);
+ run(&mut s, "sketch.project", json!({"refs": [{"edge": [40, 15, 20]}]}));
+ assert_eq!(flags(&mut s), vec![true, false]);
+ run(&mut s, "sketch.intersect", json!({"refs": [{"edge": [0, 0, 10]}], "construction": true}));
+ let e = s.execute("sketch.project", &json!({"refs": [{"edge": [20, 30, 20]}], "construction": 1}));
+ assert!(e.is_err(), "construction must be a boolean");
+ run(&mut s, "sketch.finish", json!({}));
+ // The session's preference: a sketch on a face starts with a construction loop and no
+ // profile, and it holds for the next design; `construction: false` still asks for normal.
+ s.project_construction = true;
+ run(&mut s, "file.new", json!({}));
+ assert!(s.project_construction, "file.new");
+ box_part(&mut s);
+ run(&mut s, "sketch.create", json!({"plane": {"face": [20, 15, 20]}}));
+ let on_face = flags(&mut s);
+ assert!(on_face.len() == 4 && on_face.iter().all(|c| *c), "{on_face:?}");
+ assert_eq!(inspect(&mut s)["profiles"].as_array().map(Vec::len), Some(0));
+ run(&mut s, "sketch.finish", json!({}));
+ run(&mut s, "sketch.create", json!({"plane": "XY"}));
+ run(&mut s, "sketch.project", json!({"refs": [{"edge": [20, 0, 20]}]}));
+ run(&mut s, "sketch.project", json!({"refs": [{"edge": [40, 15, 20]}], "construction": false}));
+ assert_eq!(flags(&mut s), vec![true, false]);
+}
diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs
index a4ab21616a..3c83c8900a 100644
--- a/crates/engine/src/lib.rs
+++ b/crates/engine/src/lib.rs
@@ -519,6 +519,10 @@ pub struct Session {
pub(crate) followed: Option<cmd::inspect::Followed>,
/// Project a face's edges into a sketch created on it (the default; `sketch.auto_project`).
pub auto_project: bool,
+ /// Project, Intersect, Include 3D Geometry and the face edges projected into a new sketch
+ /// make construction geometry rather than normal geometry (off by default; #13142). A
+ /// preference, kept like `auto_project` when another design is opened or started.
+ pub project_construction: bool,
/// How calls that break a command's parameter contract are treated (off by default). It
/// belongs to the session, not the design, so it survives opening and starting designs.
pub param_check: schema::ParamCheck,
@@ -827,6 +831,7 @@ impl Session {
document_id: cmd::inspect::new_document_id(),
followed: None,
auto_project: true,
+ project_construction: false,
param_check: schema::ParamCheck::Off,
easyprint_upload: None,
live_links: None,
@@ -890,6 +895,7 @@ impl Session {
self.stop_computing();
}
let auto_project = self.auto_project;
+ let project_construction = self.project_construction;
let validation = self.validation();
let single_surface_analysis = self.single_surface_analysis;
let param_check = self.param_check;
@@ -907,6 +913,7 @@ impl Session {
self.crash_journal = crash_journal;
self.command_check = command_check;
self.auto_project = auto_project;
+ self.project_construction = project_construction;
// The user's, like `auto_project`: the commands that open a design evaluate it under it
// already (`Session::opened_validating`).
self.set_validation(validation);
@@ -1945,6 +1952,7 @@ impl Session {
document_id: self.document_id.clone(),
followed: None,
auto_project: self.auto_project,
+ project_construction: self.project_construction,
param_check: self.param_check,
easyprint_upload: self.easyprint_upload.clone(),
live_links: None,
diff --git a/crates/engine/src/schema/sketch_project.rs b/crates/engine/src/schema/sketch_project.rs
index 761f2c07e8..67425589ea 100644
--- a/crates/engine/src/schema/sketch_project.rs
+++ b/crates/engine/src/schema/sketch_project.rs
@@ -154,6 +154,15 @@ fn read_link_flag(o: &Map<String, Value>) -> Result<Option<bool>, String> {
}
}
+/// `construction`: a boolean (`null` is refused too); left out, the session's preference decides.
+fn read_construction(o: &Map<String, Value>) -> Result<Option<bool>, String> {
+ match o.get("construction") {
+ None => Ok(None),
+ Some(Value::Bool(b)) => Ok(Some(*b)),
+ Some(_) => Err("`construction` must be a boolean".into()),
+ }
+}
+
/// `refs` and `ref` are one of them required: left out, the handler refuses with its own message.
fn refs_required(schema: &mut Schema) {
schema.insert("anyOf".into(), json!([{"required": ["refs"]}, {"required": ["ref"]}]));
@@ -180,6 +189,11 @@ pub struct ProjectParams {
#[serde(default, skip_serializing_if = "Option::is_none")]
#[schemars(with = "bool")]
pub projection_link: Option<bool>,
+ /// Make the created curves construction geometry (dashed, left out of profiles; they stay
+ /// linked). Default: the "Project references as construction geometry" preference, off.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ #[schemars(with = "bool")]
+ pub construction: Option<bool>,
}
impl<'de> Deserialize<'de> for ProjectParams {
@@ -188,7 +202,8 @@ impl<'de> Deserialize<'de> for ProjectParams {
// The handler reads `projection_link` before the references.
let projection_link = read_link_flag(&o).map_err(|why| D::Error::custom(whole(why)))?;
let (refs, reference) = read_refs(&o).map_err(|why| D::Error::custom(whole(why)))?;
- Ok(ProjectParams { refs, reference, projection_link })
+ let construction = read_construction(&o).map_err(|why| D::Error::custom(whole(why)))?;
+ Ok(ProjectParams { refs, reference, projection_link, construction })
}
}
@@ -212,6 +227,11 @@ pub struct IntersectParams {
#[serde(default, skip_serializing_if = "Option::is_none")]
#[schemars(with = "bool")]
pub projection_link: Option<bool>,
+ /// Make the created curves construction geometry (dashed, left out of profiles; they stay
+ /// linked). Default: the "Project references as construction geometry" preference, off.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ #[schemars(with = "bool")]
+ pub construction: Option<bool>,
}
impl<'de> Deserialize<'de> for IntersectParams {
@@ -219,7 +239,8 @@ impl<'de> Deserialize<'de> for IntersectParams {
let o = Map::<String, Value>::deserialize(d)?;
let projection_link = read_link_flag(&o).map_err(|why| D::Error::custom(whole(why)))?;
let (refs, reference) = read_refs(&o).map_err(|why| D::Error::custom(whole(why)))?;
- Ok(IntersectParams { refs, reference, projection_link })
+ let construction = read_construction(&o).map_err(|why| D::Error::custom(whole(why)))?;
+ Ok(IntersectParams { refs, reference, projection_link, construction })
}
}
@@ -237,13 +258,19 @@ pub struct Include3dParams {
#[serde(default, skip_serializing_if = "Option::is_none")]
#[schemars(rename = "ref", with = "ProjectRefs")]
pub reference: Option<ProjectRefs>,
+ /// Make the created curves construction geometry (dashed, left out of profiles; they stay
+ /// linked). Default: the "Project references as construction geometry" preference, off.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ #[schemars(with = "bool")]
+ pub construction: Option<bool>,
}
impl<'de> Deserialize<'de> for Include3dParams {
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
let o = Map::<String, Value>::deserialize(d)?;
let (refs, reference) = read_refs(&o).map_err(|why| D::Error::custom(whole(why)))?;
- Ok(Include3dParams { refs, reference })
+ let construction = read_construction(&o).map_err(|why| D::Error::custom(whole(why)))?;
+ Ok(Include3dParams { refs, reference, construction })
}
}
diff --git a/crates/engine/src/schema/sketch_project_tests.rs b/crates/engine/src/schema/sketch_project_tests.rs
index a7cf8ebe9f..79de2a1f1a 100644
--- a/crates/engine/src/schema/sketch_project_tests.rs
+++ b/crates/engine/src/schema/sketch_project_tests.rs
@@ -40,9 +40,9 @@ fn error(level: ParamCheck, id: &str, p: &Value) -> Option<String> {
#[test]
fn schemas_and_the_key_check_agree() {
- assert_keys(input_schema_for::<ProjectParams>(), &["projection_link", "ref", "refs"]);
- assert_keys(input_schema_for::<IntersectParams>(), &["projection_link", "ref", "refs"]);
- assert_keys(input_schema_for::<Include3dParams>(), &["ref", "refs"]);
+ assert_keys(input_schema_for::<ProjectParams>(), &["construction", "projection_link", "ref", "refs"]);
+ assert_keys(input_schema_for::<IntersectParams>(), &["construction", "projection_link", "ref", "refs"]);
+ assert_keys(input_schema_for::<Include3dParams>(), &["construction", "ref", "refs"]);
assert_keys(input_schema_for::<ProjectToSurfaceParams>(), &["body", "curves", "face"]);
assert_keys(input_schema_for::<IntersectionCurveParams>(), &["a", "b"]);
assert_keys(input_schema_for::<SpunProfileParams>(), &["axis", "body"]);
diff --git a/crates/ui-egui/src/documents.rs b/crates/ui-egui/src/documents.rs
index dba1ca5690..46ad343fb2 100644
--- a/crates/ui-egui/src/documents.rs
+++ b/crates/ui-egui/src/documents.rs
@@ -309,6 +309,7 @@ fn swap_in(app: &mut SolveApp, mut slot: DocSlot) -> DocSlot {
app.tree.picked_components.clear();
// Preferences the session holds go with the user, not the tab (#680).
app.session.auto_project = out.session.auto_project;
+ app.session.project_construction = out.session.project_construction;
app.session.set_validation(out.session.validation());
// So does the host's pre-command check: every tab is held to it.
app.session.set_command_check(out.session.command_check());
@@ -2195,6 +2196,28 @@ mod tests {
assert!(!a.session.auto_project, "a design adopted over a blank one");
}
+ /// Projecting references as construction geometry is the user's too (#13142), like
+ /// auto-projection: it holds in new tabs, the tab switched to, after the last tab closes and
+ /// in a design adopted over a blank one, and the preferences file keeps it.
+ #[test]
+ fn project_construction_follows_the_user_across_tabs() {
+ let mut a = app();
+ a.run("solid.box", json!({"length": 10, "width": 10, "height": 10})).unwrap();
+ a.session.project_construction = true;
+ new_design(&mut a);
+ assert!(a.session.project_construction, "a new tab");
+ a.run("solid.box", json!({"length": 5, "width": 5, "height": 5})).unwrap();
+ switch(&mut a, 0);
+ assert!(a.session.project_construction, "the tab switched to");
+ let prefs: Value = serde_json::from_str(&a.prefs()).unwrap();
+ assert_eq!(prefs["project_construction"], true);
+ close(&mut a, 1, true);
+ close(&mut a, 0, true);
+ assert!(active_is_blank(&a) && a.session.project_construction, "after the last tab closes");
+ adopt(&mut a, Session::default());
+ assert!(a.session.project_construction, "a design adopted over a blank one");
+ }
+
/// The host's pre-command check holds in every tab: new ones, the one switched to, a design
/// adopted over a blank one and after the last tab closes.
#[test]
diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs
index f80b5ef2c5..34eff50242 100644
--- a/crates/ui-egui/src/lib.rs
+++ b/crates/ui-egui/src/lib.rs
@@ -1146,6 +1146,7 @@ impl SolveApp {
"auto_ortho_faces": self.ui.auto_ortho_faces,
"pick_bodies": self.ui.pick_bodies,
"auto_project": self.session.auto_project,
+ "project_construction": self.session.project_construction,
"visual_style": self.ui.visual_style,
"browser_collapsed": self.tree.collapsed,
"browser_expanded": self.tree.expanded,
@@ -1216,6 +1217,9 @@ impl SolveApp {
if let Some(a) = flag("auto_project") {
self.session.auto_project = a;
}
+ if let Some(c) = flag("project_construction") {
+ self.session.project_construction = c;
+ }
if let Some(m) = v.get("autosave_minutes").and_then(Value::as_f64).filter(|m| m.is_finite()) {
self.autosave_minutes = m.clamp(0.0, 600.0);
}
diff --git a/crates/ui-egui/src/prefs.rs b/crates/ui-egui/src/prefs.rs
index 319aff9824..e879cdb19a 100644
--- a/crates/ui-egui/src/prefs.rs
+++ b/crates/ui-egui/src/prefs.rs
@@ -1915,6 +1915,7 @@ struct Snapshot {
agent: crate::agent_cursor::Settings,
autosave: f64,
auto_project: bool,
+ project_construction: bool,
keys: std::collections::BTreeMap<String, Vec<String>>,
/// What a settings profile also switches: the toolbar, the S box favourites and which profile is active.
toolbar: serde_json::Value,
@@ -1943,6 +1944,7 @@ impl Snapshot {
agent: app.ui.agent_cursor,
autosave: app.autosave_minutes,
auto_project: app.session.auto_project,
+ project_construction: app.session.project_construction,
keys: app.keymap.custom.clone(),
toolbar: app.toolbar_custom.prefs(),
favourites: app.sbox.pinned.clone(),
@@ -1974,6 +1976,7 @@ impl Snapshot {
app.autosave_minutes = self.autosave;
set_autosave(app);
app.session.auto_project = self.auto_project;
+ app.session.project_construction = self.project_construction;
app.keymap.custom = self.keys;
app.toolbar_custom.load(&self.toolbar);
app.sbox.pinned = self.favourites;
@@ -2003,6 +2006,7 @@ impl Snapshot {
agent,
autosave,
auto_project,
+ project_construction,
keys,
toolbar,
favourites,
@@ -2023,6 +2027,7 @@ impl Snapshot {
&& *agent == app.ui.agent_cursor
&& *autosave == app.autosave_minutes
&& *auto_project == app.session.auto_project
+ && *project_construction == app.session.project_construction
&& *keys == app.keymap.custom
&& *toolbar == app.toolbar_custom.prefs()
&& *favourites == app.sbox.pinned
@@ -2074,6 +2079,7 @@ pub(crate) fn held_overlay(app: &SolveApp) -> Option<serde_json::Map<String, ser
("perspective", serde_json::json!(s.perspective)),
("pick_bodies", serde_json::json!(s.pick_bodies)),
("auto_project", serde_json::json!(s.auto_project)),
+ ("project_construction", serde_json::json!(s.project_construction)),
("visual_style", serde_json::json!(s.style)),
("shortcut_box", shortcut_box),
("shortcuts", serde_json::Value::Object(shortcuts)),
@@ -2267,6 +2273,7 @@ fn defaults(app: &mut SolveApp, page: usize) {
}
PAGE_SKETCH => {
app.session.auto_project = true;
+ app.session.project_construction = false;
app.ui.pick_bodies = false;
}
_ => {}
@@ -6511,16 +6518,19 @@ mod tests {
app.ui.agent_cursor.show = false;
app.ui.pick_bodies = true;
app.session.auto_project = false;
+ app.session.project_construction = true;
defaults(&mut app, PAGE_GENERAL);
assert!(!app.ui.agent_cursor.show);
assert!(app.ui.pick_bodies);
assert!(!app.session.auto_project);
+ assert!(app.session.project_construction);
defaults(&mut app, PAGE_ASSISTANT);
let expected = SolveApp::new(Default::default(), Default::default()).ui.agent_cursor.show;
assert_eq!(app.ui.agent_cursor.show, expected);
defaults(&mut app, PAGE_SKETCH);
assert!(!app.ui.pick_bodies);
assert!(app.session.auto_project);
+ assert!(!app.session.project_construction, "off by default (#13142)");
}
#[test]
diff --git a/crates/ui-egui/src/prefs/sketch.rs b/crates/ui-egui/src/prefs/sketch.rs
index 9d5f9b2673..3418a8f964 100644
--- a/crates/ui-egui/src/prefs/sketch.rs
+++ b/crates/ui-egui/src/prefs/sketch.rs
@@ -96,8 +96,13 @@ fn drawing(app: &mut SolveApp, ui: &mut egui::Ui) {
"prefs.sketch.auto_locate",
"ui.first_dimension_scales",
];
- let right_labels =
- ["prefs.sketch.shortcut_cycles_modes", "prefs.ribbon_click_ends_tool", "ui.project_face_edges_sketch", "prefs.sketch.project_options"];
+ let right_labels = [
+ "prefs.sketch.shortcut_cycles_modes",
+ "prefs.ribbon_click_ends_tool",
+ "ui.project_face_edges_sketch",
+ "ui.project_references_construction",
+ "prefs.sketch.project_options",
+ ];
let natural = [left_labels.as_slice(), right_labels.as_slice()]
.map(|labels| labels.iter().map(|id| check_width(ui, app.tr(id), true)).fold(0.0, f32::max));
let available = ui.available_width();
@@ -175,6 +180,13 @@ fn drawing(app: &mut SolveApp, ui: &mut egui::Ui) {
if check(ui, "auto_project", "ui.project_face_edges_sketch", None, &mut auto).changed() {
let _ = app.run("sketch.auto_project", json!({"value": auto}));
}
+ check(
+ ui,
+ "project_construction",
+ "ui.project_references_construction",
+ Some("ui.project_references_construction_note"),
+ &mut app.session.project_construction,
+ );
check(
ui,
"project_options_dialog",