Keeps both sides in text_box (main's fitted height and rotation, this
branch's mirroring) and sets the two flags on the Text literals main
has added since.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Proxy graphics text, PDF import text and dynamic block grip text are built without Backwards or
Upside down; four tests build Text the same way.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
From CodeRabbit's reviews of #1136:
- TEXT's generation flags are AcDbText's group 71, but ATTDEF and ATTRIB
read the first 71 among all their groups. A multiline attribute's
AcDbAttribute / AcDbAttributeDefinition subclass has a 71 of its own (its
multiline flag: 2 for an attribute, 4 for a definition), which AutoCAD and
CADCraft write when the text has no generation flags, so multiline
definitions read upside down and multiline attributes backwards (and were
saved so). Only the groups before the attribute subclass give the flags
now; the multiline fixture checks it, read and saved again.
- The start of a justified TEXT's baseline (DXF group 10) is worked out with
the text's own Backwards and Upside down, as it's drawn and as its group
71 says; it took the style's.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TEXT, ATTDEF and ATTRIB have their own Backwards and Upside down, as AutoCAD's do (DXF group
71: 2 backwards, 4 upside down). New TEXT and attribute definitions take them from their style;
changing the style afterwards leaves existing text as it is. They were the style's only, so
text read from a file with its own flags was drawn as its style said.
- Model: `Text::backwards` and `Text::upside_down` (serde default false).
- DXF: read from 71 (the object's own groups, before an embedded MTEXT) and written when set.
- Render: drawn from the text's flags; the extents box mirrors with them, so zooming to
extents frames mirrored text. Linetype text keeps its style's.
- Properties: a Misc group with Upside down and Backwards (`properties.describe`, and
`properties.set` takes `backwards` and `upsideDown`), for several texts at once with *VARIES*.
- ATTDEF builds its text as TEXT does, so it also takes the style's width factor and obliquing.
- Round trip: #2237's matrices compare both flags, with DXF and DWG cases for them. Its
mirrored-style cases mirror the text by the text's own flags, and each mirrored style
also has text whose flags differ, so a style's flags can't leak into its text's.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
too_short's margin is TRIM's ON_CUT plus the 3 tol the traced ends and pick can be off by, not
twice ON_CUT. A cutting edge picked before MSPACE or PSPACE moved to another space cuts nothing
there: the preview shows nothing and the trim is refused, so the preview never shows a cut the
trim can't make.
* feat(offset): OFFSETGAPTYPE extends, fillets or chamfers polyline corner gaps
OFFSETGAPTYPE is a system variable (0, 1 or 2, default 0) kept in the
drawing header. Offsetting a polyline fills the gap at the outside of a
corner between two line segments: 0 extends both copies to meet, 1 inserts
an arc of radius equal to the offset distance centred on the original
vertex, 2 inserts a chamfer line at the offset distance from the vertex.
Inside corners and joints with an arc keep the extended join. OFFSET's
settings echo shows the current value.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* OFFSETGAPTYPE fills only corners the source polyline has; geometry parity headline and history match
* test(offset): OFFSETGAPTYPE fillets and chamfers open outside corners turning either way
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(offset): interactive OFFSET previews and makes the OFFSETGAPTYPE fill
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Remove a leftover merge file
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* OFFSETGAPTYPE: leave docs/geometry-parity.md to the maintainers
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Dimension text below the line (\X) and leader text at DIMSCALE (#1055, #1056)
- #1055: in dimension text, `\X` starts the text below the dimension
line (DXF Reference). CADCraft drew only the part before it, and its
*D block held only that part. The part after `\X` is now drawn below
the line, on the other side of it at the same distance (text centred
on the line moves above it), on screen, in plots and in the *D block
as a second MTEXT; text width for the fit is the wider part's.
- #1056: LEADER's annotation was DIMTXT high whatever DIMSCALE said
(0.25 instead of 6.25 beside dimensions at DIMSCALE 25). It is now
DIMTXT × DIMSCALE (the style's, else the drawing's; 1 for annotative
styles), in the style's text style, as AutoCAD's LEADER makes it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Dimension `\X`: measure from the dimension line, not DIMTMOVE 1's leader
The part after `\X` is placed from the dimension line's longest segment, and DIMTMOVE 1's leader
(added by #2015) is drawn as a dimension line too: with the text moved far away, the leader won
and the part below went next to the text. The leader's ends are now kept (`text_leader`) and its
segments skipped. Text moved off its place also leaves the part below at the usual clearance
under the line, instead of as far below as the text is above.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* LEADER text of an annotative dimension style: DIMSCALE, and annotative
With an annotative dimension style the leader's text left DIMSCALE out and was not annotative,
so at an annotation scale it stayed small beside the dimensions. It now takes DIMTXT × DIMSCALE
as a dimension of the style does, and is annotative at the current annotation scale.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* LEADER text of an annotative style: the annotation scale replaces DIMSCALE
An annotative dimension takes the annotation scale in DIMSCALE's place (anno_scaled sets its
scale override), so its text is DIMTXT × the annotation scale. The annotative leader text took
DIMTXT × DIMSCALE and then the annotation scale again: twice the dimension text with DIMSCALE 2.
It is now DIMTXT high and annotative; a non-annotative style still takes DIMTXT × DIMSCALE.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* DIMTMOVE 1 leader is kept as the text leader again
The merge of main moved the leader into dim/linear.rs without the text_leader record, so the
text below the line was placed over the leader.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Keep `\X` text below a suppressed or extension-line dimension line
With DIMSD1 and DIMSD2 both on, no dimension line segment is drawn, so
the part after `\X` was dropped. The linear dimension now records its
whole dimension line (`dim_axis`) and the `\X` layout falls back to it.
With DIMJUST 3 or 4 the text runs along an extension line, so its normal
is across the dimension line's: the text no longer moves onto the
dimension line at the arrow, and the part below stacks under it in the
text's own frame.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* FILLET/CHAMFER with polylines keep the picked side and join two polylines
A line crossing an open polyline's end segment cut the polyline on the
wrong side when the pick was past the crossing: the polyline always kept
the part towards its other end. Each object now keeps the side it was
picked on and drops what lies past the corner, as AutoCAD does.
Two open polylines picked at their end segments were refused. They now
join into one polyline through the corner (the first one picked keeps
its handle and direction), as AutoCAD does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* FILLET/CHAMFER: a line or polyline joins any straight segment of an open polyline
AutoCAD accepts a middle segment too: an open polyline's end segment
crossing another's middle segment joins them, each keeping its picked
side and dropping what lies past the crossing. Closed polylines and arc
segments are still refused.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* FILLET with polylines: a closed polyline opens to join a line; an arc segment is cut where a line crosses it
Checked against AutoCAD with the same shapes:
- A closed polyline filleted with a line opens at its first vertex: the
picked side of the picked segment joins the line, either side, and the
result is an open polyline. CADCraft refused closed polylines.
- An arc segment crossed by a line (radius 0) is cut where they cross,
keeping its picked side, with the bulge of what is left of it. A line
that misses the arc, or a radius, stays refused, as in AutoCAD.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* FILLET: a pick just before a polyline arc's start keeps the start side
Where the pick lies along an arc segment was clamped to the arc's end, so a pick a little before
its start (within the pick box) kept the end side. It now counts at the nearer end.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Drawing locks and WHOHAS: say when a drawing is open elsewhere (part of #540)
While a drawing opened from a DWG/DXF/DWT file is open, the app keeps
`.<file name>.cadcraft-lock` beside it (user, computer, app instance,
when opened), touched every minute; a lock not touched for five minutes
is stale. Opening a drawing someone else has open says who and since
when, on the command line and in the status bar, and opens it anyway:
the lock only informs. A lock is released when its drawing closes or is
saved under another name and when the app exits, only ever by the
instance that holds it; a stale one is taken over, and an app that finds
its lock taken over notes it instead of touching it. WHOHAS reports the
holder of the current drawing or of a file. The locks run with the
autosave tick; the format is CADCraft's own, not AutoCAD's .dwl.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Drawing lock: claim a free lock atomically
Two apps opening a drawing with no lock at the same moment could both write it and both think
they held it, so neither told its user until a later heartbeat. A missing lock is now created
atomically (a hard link of the staged file, or create_new without hard links), and a stale one
is replaced only if no other app has taken it meanwhile, then read back. The app that loses is
told at once who has the drawing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* WHOHAS: a `path` that isn't text is an error
A `path` of another type (`{"path": 7}`) was taken as left out, so WHOHAS answered for the
current drawing. Left out or null still means the current drawing; anything but a string is now
refused.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Drawing locks: name the imports of the native module
The workspace now denies clippy's wildcard_imports, which `use super::*`
in drawlock's native module trips after the merge of main.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Autosave: wake up for the drawing-lock heartbeat, not only for autosaves
Autosaver::tick kept the drawing locks but returned only the next autosave,
None with every drawing saved or SAVETIME 0, and the UI only schedules a
repaint on Some. An idle app then never touched its locks: after STALE_SECS
another app took the drawing over without a word. Locks::next_beat gives
the shortest wait until a held lock (or someone else's) is due again, and
tick returns the sooner of that and the next autosave.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* WHOHAS: an error on the web, not "nobody has it open"
The web has no lock files, so the lookup isn't done there; reporting no
holder presented that as a negative result.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fix the wasm build after the merge
The merge dropped the native-only cfg from main's autosave lock field, and
two drawlock items used only by native code warned on wasm.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* HATCH by internal point keeps the arcs of its boundary (#1167)
The boundary search works on flattened curves, so a hatch made by
picking inside a circle stored 158 chords and AREA came out short
(5025.22 for pi*40^2 = 5026.55).
Each traced edge now keeps the input polyline it came from
(region::Boundary::outer_edges, Island::edges, outline_edges,
enclosing_loop_edges_gap; bridged gaps are None), and each input
polyline is one piece of one object: a line, a circle, an arc or one
segment of a polyline. arcs::with_arcs turns each run of edges on the
same circular piece back into one bulged vertex and moves the corners
onto the exact curves (line-circle or circle-circle crossing nearest the
traced corner, within the reach a shallow crossing needs, else onto the
circle). Nothing is matched by proximity, so a line or an ellipse next
to a circle is never taken for it. The associative refill does the same,
so a hatch keeps its arcs when its objects move.
dedup_loops now merges only loops with the same role: a loop that is one
pick's outer loop and another's island stays twice, as the even-odd fill
needs (one hatch picked inside a circle and around it, or inside a square
within a square, left the inner shape empty once the two loops matched).
A boundary object selected twice is used once.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Hatch arcs: origin from the arcs' extents; opposite-role duplicate loops cancel
- HPORIGINMODE's corners came from the loop vertices only, so a circle kept as two half-circles
had no height and its corner origins fell on its centre line. The extents now include each
bulged edge's arc.
- A pick inside a circle and one around it keep the circle as an outer loop and as an island.
The renderer collapsed the two into one loop, so the circle drew empty, and AREA measured them
by nesting. Two loops that are the same boundary now collapse only in the same role (a repeated
loop); in opposite roles they cancel, as they do under the odd-parity fill. AREA measures the
loops the fill keeps (`hatch_fill_loop_indices`), exactly with their arcs.
- Tests: the circle's corner origins, BOUNDARY keeping a circle's and a rounded rectangle's
arcs, and the drawn fill and AREA of the circle inside a square.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Hatch loops: same-role repeats collapse before opposite roles cancel; HATCHEDIT keeps islands
- The renderer cancelled an outer loop and an island as it met them, so the same loops in another
order filled differently (outer, island, outer left a hole; outer, outer, island left none).
Repeats within a role now collapse first, then an outer loop and an island that are the same
boundary cancel, spending the same comparison budget.
- HATCHEDIT adding a boundary the hatch already has (its island) added a second copy, which then
cancelled the island. A boundary already there is no longer added.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* HATCHEDIT: a boundary already there takes the added objects' links
Adding a boundary the hatch already has dropped the added loop, and with it the objects it came
from, so an unlinked island picked with addBoundary stayed unlinked. The objects now join the
loop already there (no second copy is added).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* AREA of a hatch tests nesting at an edge's middle, as the fill does
AREA tested whether a loop is an island at its first vertex, which can lie on the loop around it
(an island touching the outer boundary): the island was then added instead of subtracted. It now
uses the fill's own test point, the middle of the first non-degenerate edge (`hatch_loop_probe`).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Hatch loop dedup: look only at loops that could match, stop when the budget is spent
The comparison budget bounded `same_polygon`, but both passes still walked every kept loop for
each new one, O(n²) in the number of loops however few matched. Loops are now found by (role,
vertex count), so only possible matches are looked at, and once the budget is spent no more are.
A test sorts 40,000 distinct loops.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs: hatch gap tolerance (HPGAPTOL) is done, not missing
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs: BOUNDARY keeps the arcs of what it traces
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
* RENAME keeps a layer's, block's or style's xdata, extension dictionary and reactors
The data CADCraft keeps for a table record or block without modelling it
(Drawing.foreign.records, and the roles of its file handles in foreign.targets)
is keyed by kind and upper-case name, so a rename left it under the old name:
a renamed dynamic block lost its dynamic data, and a renamed layer, text style,
dimstyle, linetype, view, UCS, multileader style or table style lost its other
applications' xdata, extension dictionary and reactors on the next save.
Foreign::rename re-keys both maps; every rename site (layer.set newName, which
RENAME and the Layer manager use; block; style; dimstyle; linetype; view, UCS,
multileader and table style) calls it through Foreign::rename_shared, which
clones the shared Foreign only when it holds something for that name. Undo needs
nothing: foreign is part of the drawing snapshot.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A case-only rename leaves the shared foreign data uncloned
* A case-only rename test checks the saved layer and block names exactly
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs: RENAME keeps the foreign data of layers, blocks, linetypes, text styles and dimension styles
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
* engine: check a paper's margins against its own axis
* doc: turn a paper's margins with the sheet when it is stored portrait
* fmt: keep plotters.rs rustfmt-clean
* engine: turn a device paper's margins to the page's orientation
* engine: turn a page's margins when only its orientation changes
PAGESETUP sets `landscape` before `page_device`, but a command that names no paper copies no
device paper, so the retained margins stayed on the old sheet's axes and Sheet::from_page
refused them on the new orientation, falling back to the whole sheet. Turn them with the page,
using the inverse of the rotation `set_paper` applies.
* engine: an orientation-only pagesetup turns the retained margins the way the page turns
---------
Co-authored-by: midasmatterhorn <236787783+midasmatterhorn@users.noreply.github.com>
Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
* Write RevcloudProps xdata on revision clouds
Fixes#1570
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* REVCLOUD: arcs use the bulge readers need to recognise a cloud (follow-up to #1605, #1570)
Readers take a closed polyline for a revision cloud only with RevcloudProps
xdata (#1605) and every bulge within 0.02 of 0.520567; clouds used 0.5,
just outside, so ezdxf's is_revcloud still said no. Clouds now use
0.520567050552 on every creation path. Tests check the reader's condition
for all six ways of drawing a cloud and after a DXF round trip.
* Parity checklist: regenerated after merging main
* Parity checklist: regenerated after merging main
* REVCLOUD: import RawTag in the revcloud module main split out of draw2
* Parity checklist: regenerated after merging main
* Revcloud: update the recognition test for main's prompts (#1692)
Main now asks for the minimum and maximum arc length and, after an object
pick, whether to reverse direction, so the old scripts left a prompt waiting
and the test read the previous entity. A helper now checks the prompts
finished and exactly one new entity was created.
* Revcloud: drop the file-format-parity.md change from this PR (#1692)
The LWPOLYLINE note and changelog entry are moved to the PR description, as review asked.
---------
Co-authored-by: NetterSilver <133535268+Silvertree2010@users.noreply.github.com>
Co-authored-by: Claude Haiku 5.5 <noreply@anthropic.com>
Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
Co-authored-by: SBaksa <18648812+SBaksa@users.noreply.github.com>
* fix(io): look up table, multileader and multiline styles without scans
A crafted DXF made several style lookups cost N^2 name comparisons
(#1924, F-04 item 5):
- the reader's TABLESTYLE, MLEADERSTYLE and MLINESTYLE records, each
scanning the styles read so far for an earlier one of its name, and its
VPORT records, each scanning the viewport configurations;
- each table from another writer, scanning the table styles on read;
- each TABLE, MULTILEADER and MLINE on DXF save, for its style's handle
and values;
- render's table_style_of, which a DXF save calls for every table;
- AUDIT's multileader and table style checks, which RECOVER runs on open.
On main, N = 40 000 MLEADERSTYLE or TABLESTYLE records took 65-69 s to
open, and the DXF save of 40 000 multileaders or foreign tables naming a
missing style ran past 300 s. With this change they take 0.4-5.5 s, and
the output is byte-identical.
- ByName (from #3562) moves to dxf_ext.rs and gains position(). The record
dedups go through it, keeping the rule: a later record of a name
replaces the first in place and takes its name. A VPORT record still
adds a tile to the first configuration of its name.
- Drawing::table_styles is a NamedList, like the other style tables.
- The writer's Ctx keeps a ByName beside its table and multileader style
lists. dxf_mline::plan and Plan keep one too. Missing names fall back as
before.
- When no styles are planned (entity_groups, for entget), the multileader
style is still looked up in the drawing.
- AUDIT checks multileader styles against a lower-cased BTreeSet, and
table styles with by_name.
Tests: cost tests for each path, with behaviour checks that also hold on
the old code, and an entity_groups test for the multileader's style.
Part of #1924.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(io): trim a multiline style's name when reading it
A DXF MLINESTYLE named " Road " was kept with its spaces. Its multilines
look their style up trimmed (dxf_mline::plan, Plan::handle,
Drawing::mline_style), so a save missed it, wrote a second Road style and
pointed the multilines at that copy. main did the same: its scan compared
the trimmed query with the untrimmed name. The writer already writes the
name trimmed, and the reader's fill key trims it, so the name is now
trimmed where it is read (CodeRabbit, on #3590).
Test: a_padded_multiline_style_name_is_saved_once (fails without the
trim: the save writes STANDARD, Road and Road).
Part of #1924.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
A table's data link path is stored in the drawing, and DATALINKUPDATE
copies the linked file's text into the table, where the next save keeps
it. A stored path could name any local file (by `..` or an absolute
path), so a drawing could pull any readable file into itself.
A link the drawing itself names is now read only when its file, resolved
by the file system (`..`, symbolic links and junctions followed), lies in
the drawing's folder or a folder below it, compared by whole components;
the resolved path is the one read. A file the user links with DATALINK
is remembered for that open drawing (never saved, at most 1000, newest
kept), so it keeps updating until the drawing is opened again. Refused
links are listed in DATALINKUPDATE's errors; the other links update. The
automation roots are still checked first.
Part of #1929 (F-08).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
One conflict, in crates/engine/src/cmd/modify/select_then.rs: this branch
adds COPY's copy_prompt, copy_input and copy_done just above join_now, and
main (#2725) rewrote join_now's doc comment. Kept both: the COPY methods,
then main's two-line doc. The struct fields (copy_single, copies,
copy_array, ask_circle), SelectThen::new and the match arms merged without
conflict. No behaviour changed on either side.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
acadrust 0.6.6 writes and reads a DWG linetype's element count as one
byte, so a linetype of 256 elements came back from a DWG save with none
(continuous) and one of 300 with 44. The DXF read cap of #3482 lets 256
through, so every capped DXF linetype hit the 256 -> 0 case.
The DWG bridge text now writes at most 255 elements per linetype (the
first ones, with group 40 totalling them); DXF output is unchanged.
cadcraft_io::dwg_notes gives one note counting the linetypes cut, counted
by the writer so an xref linetype the file leaves out is not counted. An
engine hook installed by the apps echoes it and returns it in `warnings`
on every DWG write: QSAVE/SAVEAS, document.bytes, EXPORT, WBLOCK,
-WBLOCK, LAYOUT SAVEAS; cadcraft-cli convert prints it.
Part of #1923 (F-05).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>