Repository navigation
Drawings: a balloon, dimension or note attaches only to a part its view draws (#4896) - #12394
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
c54df03 to
c406d80
Compare
theironchef
left a comment
There was a problem hiding this comment.
Read at c406d80b0 (source only, not built locally).
CI's red is a semantic conflict with drawings, not this change's logic. "Quick compile" fails with E0004 at crates/engine/src/cmd/drawing_view.rs:334: SetBy::Sheet and SetBy::Drawing aren't covered. #12516 (ecf75d908) added those two variants after this branch was cut. GitHub still shows the PR as mergeable because the merge has no textual conflict. The other failing jobs ("Build the CLI", "kernel-rig", "ci") look like the same compile error.
Today only line_group resolves to those two (doc/src/drawing/view.rs:287-288); source and hide never do. So the fix after rebasing is just to cover them in set_on, for example:
let set_on = |set_by: SetBy| match set_by {
SetBy::Parent(parent) => format!(" (set on view {})", ids::encode(parent)),
SetBy::Sheet => " (set on its sheet)".to_string(),
SetBy::Drawing => " (set on the drawing)".to_string(),
SetBy::This | SetBy::Default => String::new(),
};(Or leave those two out of the words with the empty string, since source and hide can't come from them yet. Either way, naming every variant keeps the next one from slipping through as _.)
On the change itself:
- The refusal only needs to sit on
add. I checked thatdrawing.dimension.edit(DimensionSet),drawing.balloon.editanddrawing.note.editcan't point an annotation at a different reference ("to measure/point at something else, add a new one"), so editing can't get round the check. DimensionKind::pathscovers every kind, and a chain checks each of its points, which the test pins with the hidden last point.- An unresolvable view gives no refusal from
not_drawnand leaves it to the view's own reply. That seems right, and it's documented.
…ew draws (tangency-labs#4896) Adding one on a part the view's saved settings leave out (its hide, or a source that doesn't choose it) is refused, naming the view and the setting, and the parent view when it set it. One added before a later view edit stays, and its inspect reply warns until the edit is undone. The rule stays the view's own (`chosen`): `left_out` asks it about one occurrence path and says why; `check_drawn`, `not_drawn` and `drawn_warning` beside the view commands use it for the three annotations. `DimensionKind::paths` and `Anchor::path` list what each points at, so every kind of dimension is checked. No model is evaluated. On drawings a7c0310, tangency-labs#12516 (line groups) gave a resolved setting two more setters, the view's sheet and the drawing. The words for where a setting was set are one function, set_on, with an arm for each: a parent names its view, a sheet and a drawing say so, and a view's own setting and the default add nothing. Hide and the chosen occurrences come only from a view's chain today, so no refusal says "its sheet" yet; the match keeps the compiler checking each new setter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
c406d80 to
1872f09
Compare
Change
A drawing view can leave parts of an assembly out: its saved settings choose which occurrences it draws (
source) and which it hides (hide). In the app you can only pick what a view draws. Through a command (a script, the control channel or MCP), though,drawing.balloon.addaccepts a balloon on a part the view hides. @Benny1496 found this on #11881.drawing.dimension.addanddrawing.note.add(a leader on an edge or a corner) have the same gap: each one makes its model reference without asking whether the view draws that part.This makes the view's rule the one door:
chosenindrawing_view.rs). A newleft_out(view, path)asks that same rule about one path and says why. One shared check (check_drawnincmd/drawing_view.rs) calls it for all three commands, after their references are made (so a bad path still gets its own error first). It resolves the view once per command, however many points a chain has. No model is evaluated, and the commands stay as cheap as they are.inspectreply gets a warning ("view V doesn't draw this part now: …"). The view edit is never refused for it.addis the only way in.set_on. Ondrawings, Drawings: a drawing, a sheet or a view saves the line group its lines are drawn in (#4890) #12516 (line groups) gave a resolved setting two more setters: the view's sheet and the drawing.set_onhas an arm for each. A parent names its view, and a sheet and a drawing say so. A view's own setting and the default add nothing. Today hide and the chosen occurrences come only from a view's chain, so no refusal says "its sheet" yet. The match makes the compiler check each new setter.Part of #4896 (dimensions and notes) and #3874 (balloons), into
drawings. Drawing data only, no kernel geometry.Changes a default: no
Only calls that attach to a part the view leaves out are refused; the app's own picks never do, and no setting changes.
Validation
Local, Windows,
--profile ci, ondrawingsa7c0310 (one commit,1872f0943):cargo fmt --checkand clippy with warnings denied (geom, sketch, doc, io, engine).a_balloon_is_refused_on_a_part_its_view_leaves_out: a hidden occurrence is refused with the view and the setting named; a projected view that inherits the hide names its parent; a view whosesourcechose another occurrence refuses; shown again, it is added.a_balloon_warns_when_its_view_leaves_its_part_out_later: inspect warns after the hide, and not after undo.a_dimension_is_refused_on_a_part_its_view_leaves_out: a linear dimension, and a chain whose last point is on the hidden part, are refused with the drawing left as it was; added before the hide, it warns until undo.a_notes_leader_is_refused_on_a_part_its_view_leaves_out: an edge and a corner leader on the hidden copy are refused; on the other copy, on the view and on the sheet, notes are added.a_left_out_part_says_where_each_kind_of_setter_set_it(in the view tests): the wordsset_ongives for a parent, a sheet, a drawing, the view itself and the default.drawing_balloon,drawing_dimension,drawing_noteanddrawing_viewon a7c0310: 178 pass. Earlier, on 855ce28:schema190 and docdrawing90 passed.hostile_params_never_panic(72) passed on the commit before the last two changes (resolving the view once per command, and the command descriptions); it takes 35 minutes, so I didn't repeat it for those.left_outignoringhide, orsource; the view's own settings read instead of the resolved ones; the parent view not named; a sheet's setting, or a drawing's, not said; a chain checking only its first point; inspect without the warning. One more (a balloon checked after it is added instead of before) can't be caught, and needs no test: a refused command puts the design and its ids back as they were (Session::execute), so the two behave the same.left_outagainst the view's rule over 500 seeded paths:left_outcalls that rule (chosen) itself, so it would compare the rule with itself.git merge-tree): Drawing sheets: add manual centre marks and centre lines (#9419) #9421, Drawing W39a: sheet sets and output scopes, as data (#9723) #9725 and Drawing sheets: edit and export drawing-owned sketches #7608 conflict withdrawingsitself on the same files, so nothing new comes from this one. Drawing W29a: hole callouts (#7605) #7618, Drawing text: the paper scene counts a font's records, measures a run, and its reply schema allows text #12113, Drawing dimensions: their numbers on the sheet, set and measured in the drawing's font (#4896) #12356 and Drawing sheets: a title block's labels and values on the sheet (#3875) #12357 merge cleanly, and the merged trees with Drawing sheets: a title block's labels and values on the sheet (#3875) #12357 and Drawing W29a: hole callouts (#7605) #7618 build (cargo check --all-targets). Checked again on a7c0310: Drawing W29a: hole callouts (#7605) #7618 and test(drawings): W23a model-edit E2E acceptance recipes #8288 merge cleanly, and @armin0411's Drawing sheets: add manual centre marks and centre lines (#9419) #9421 and Drawing W20e: automatic centre marks for drawing views (#9462) #9463 conflict withdrawingsitself on the same files, with or without this one. @Benny1496's draft test(drawings): the W23 assembly sheet's parts list, balloons and revision rows (#11773) #11881 and this PR both add a test at the end ofdrawing_view_tests.rs. Whichever merges second keeps both tests.What the tests can't reach:
source. Its words come from the same code as the tested inheritedhide, but no test sets a parentsource.The real program, a release build of this commit driven through its control channel, on a plain test assembly (a 40 x 30 x 20 mm Block component and a Base box beside it), with a front view at 1:1, a balloon and a 40 mm dimension on the Block:
drawing.view.edit {"hide": [[2]]}: both inspects say "view … doesn't draw this part now: its hide leaves out occurrence path [2]";"hide": null): the warnings go. No crash reports.Screenshots of the behavior (when observable)
The sheet as the app exports it (
drawing.export, PNG). Balloons and dimension text don't draw ondrawingsyet (the text PRs #12356 and #12357 add the text).Before the hide, the Block (left) and the Base, with the Block's dimension:
After the hide: the view draws only the Base and is centred on it again; the dimension added before the hide stays, and inspect warns about it:
Integration status
One commit on
drawingsa7c0310 (the latest when pushed). It is rebased onto that commit because #12516 gave a resolved setting two more setters; the earlier commit didn't compile there. Other open work nearby: @armin0411's #9421 (manual centre marks and centre lines) adds two more commands that attach to a model edge or corner. Whichever of the two merges second calls the same check, so the rule covers them too.