@mlightcad/cad-diff-viewer 1.7.7-preview.1 → 1.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +203 -203
- package/package.json +3 -3
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 mlightcad
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 mlightcad
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,203 +1,203 @@
|
|
|
1
|
-
# @mlightcad/cad-diff-viewer
|
|
2
|
-
|
|
3
|
-
Reusable side-by-side / overlay CAD comparison widget. It depends on
|
|
4
|
-
[`@mlightcad/cad-simple-viewer`](../cad-simple-viewer) and creates both WebGL
|
|
5
|
-
canvases internally — the host only supplies a parent container.
|
|
6
|
-
|
|
7
|
-
## How it works
|
|
8
|
-
|
|
9
|
-
`AcApDiffViewer` does not reimplement CAD conversion. It creates one
|
|
10
|
-
`AcApDocManager` with two canvases (left = old, right = new), opens each file
|
|
11
|
-
into its own document session, then:
|
|
12
|
-
|
|
13
|
-
1. Runs [`acapCompareDrawings`](./src/compare/acapCompareDrawings.ts) on the two
|
|
14
|
-
model-space databases.
|
|
15
|
-
2. Turns the result into per-entity **compare roles**.
|
|
16
|
-
3. Paints those roles with **compare display mode** — a GPU tint that replaces
|
|
17
|
-
the drawing’s own ACI / TrueColor.
|
|
18
|
-
|
|
19
|
-
### Compare display (why everything looks one color)
|
|
20
|
-
|
|
21
|
-
Normal viewing keeps each entity’s CAD color. Compare display does the opposite:
|
|
22
|
-
when it is enabled, **every batched fragment is first forced to a single base
|
|
23
|
-
color** (default gray `#9ca3af`). Only entities with a role override then pick
|
|
24
|
-
up deleted / added / modified colors.
|
|
25
|
-
|
|
26
|
-
That tint is applied in the batch highlight shader, not by rewriting entity
|
|
27
|
-
materials on the CPU:
|
|
28
|
-
|
|
29
|
-
| Mask channel | Meaning |
|
|
30
|
-
| --- | --- |
|
|
31
|
-
| R | selection (wins over compare) |
|
|
32
|
-
| G | hover (wins over compare) |
|
|
33
|
-
| B | compare role: none / deleted / added / modified |
|
|
34
|
-
|
|
35
|
-
While `u_compareEnabled` is on, the fragment shader:
|
|
36
|
-
|
|
37
|
-
1. Sets the color to `u_compareBaseColor`.
|
|
38
|
-
2. Reads the B channel of the per-slot mask texture and swaps in
|
|
39
|
-
deleted / added / modified if a role is set.
|
|
40
|
-
3. Still lets selection and hover replace that color.
|
|
41
|
-
|
|
42
|
-
Unbatched drawables (for example fat lines) get the same roles via cloned
|
|
43
|
-
materials. Overlay/XREF layouts are colored separately through
|
|
44
|
-
`setOverlayCompareDisplay`.
|
|
45
|
-
|
|
46
|
-
**Side-by-side:** each canvas tints its own drawing. Unchanged geometry stays
|
|
47
|
-
gray. The left canvas marks deletions (and modified-left hits); the right
|
|
48
|
-
canvas marks additions (and modified-right hits).
|
|
49
|
-
|
|
50
|
-
**Overlay:** the right database is registered as a read-only overlay on the left
|
|
51
|
-
canvas (geometry is converted again; scenes are not moved between renderers).
|
|
52
|
-
The left drawing uses the deleted color for deleted *and* modified-left
|
|
53
|
-
entities; the overlay uses the added color for added *and* modified-right
|
|
54
|
-
entities. Unchanged geometry from both files sits on the gray base so you can
|
|
55
|
-
see what moved.
|
|
56
|
-
|
|
57
|
-
Default role colors (overridable via `compareColors`):
|
|
58
|
-
|
|
59
|
-
- unchanged: `#9ca3af`
|
|
60
|
-
- deleted (left / old): `#e11d48`
|
|
61
|
-
- added (right / new): `#22c55e`
|
|
62
|
-
- modified: same as deleted in side-by-side; folded into red/green in overlay
|
|
63
|
-
|
|
64
|
-
### Diff algorithm
|
|
65
|
-
|
|
66
|
-
`acapCompareDrawings(leftDb, rightDb, options)` compares the two model-space
|
|
67
|
-
databases. Left is the old drawing; right is the new drawing. Options follow
|
|
68
|
-
AutoCAD COMPARE system variables from `@mlightcad/data-model`:
|
|
69
|
-
|
|
70
|
-
| Sysvar | Default | Effect |
|
|
71
|
-
| --- | --- | --- |
|
|
72
|
-
| **COMPAREPROPS** | `0` | Bitcode for object property diffs: Color `1`, Layer `2`, Linetype `4`, Linetype scale `8`, Lineweight `16`, Transparency `32`, Thickness `64`. `0` ignores property-only changes (geometry still compared). |
|
|
73
|
-
| **COMPAREHATCH** | `0` | `0` excludes hatch objects; `1` includes them. |
|
|
74
|
-
| **COMPARETEXT** | `1` | `0` excludes TEXT/MTEXT/ATTRIB/ATTDEF; `1` includes them. |
|
|
75
|
-
| **COMPARETOLERANCE** | `6` | Decimal places of geometric precision (`6` → `1e-6`). |
|
|
76
|
-
| **COMPARERCMARGIN** | `5` | `1–25`. Scales change-set clustering and revision-cloud padding. |
|
|
77
|
-
|
|
78
|
-
**Tolerance.** Coordinates and angles are quantized onto
|
|
79
|
-
`10 ** -COMPARETOLERANCE`, unless you pass an explicit `tolerance`.
|
|
80
|
-
|
|
81
|
-
Each entity then gets two strings:
|
|
82
|
-
|
|
83
|
-
- **Fingerprint** — DXF type plus quantized geometry (line endpoints, center /
|
|
84
|
-
radius / angles, position, rotation, height, block name, scale, TEXT /
|
|
85
|
-
MTEXT contents). If those fields are missing, axis-aligned extents are used.
|
|
86
|
-
Line endpoints are stored in a direction-independent order.
|
|
87
|
-
- **Property key** — only the COMPAREPROPS bits that are enabled (empty when
|
|
88
|
-
COMPAREPROPS is `0`).
|
|
89
|
-
|
|
90
|
-
**Matching (in order):**
|
|
91
|
-
|
|
92
|
-
1. Same DWG/DXF handle (`objectId`) **and** the same DXF type. Typical when
|
|
93
|
-
the file was edited in place.
|
|
94
|
-
2. Among leftovers, same `dxfType` (and layer, when COMPAREPROPS includes
|
|
95
|
-
Layer) **and** the same fingerprint.
|
|
96
|
-
|
|
97
|
-
**Classification:**
|
|
98
|
-
|
|
99
|
-
| Fingerprint | Property key | Result |
|
|
100
|
-
| --- | --- | --- |
|
|
101
|
-
| equal | equal | unchanged (omitted unless `includeUnchanged`) |
|
|
102
|
-
| equal | different | modified (attribute-only change; COMPAREPROPS ≠ 0) |
|
|
103
|
-
| different | — (handle match) | modified |
|
|
104
|
-
| no match | — | deleted (left only) or added (right only) |
|
|
105
|
-
|
|
106
|
-
Modified pairs emit **two** hits (one per side) with `pairedId` pointing at the
|
|
107
|
-
other entity. Nearby differences are grouped into **change sets**. The markup
|
|
108
|
-
toolbar can create built-in cloud markups around those sets. A cloud uses the
|
|
109
|
-
Settings color for its single change kind (added, deleted, or modified);
|
|
110
|
-
mixed-kind sets use the modified color. The results panel navigates
|
|
111
|
-
`deleted → modified (left) → added`.
|
|
112
|
-
|
|
113
|
-
The Settings dialog (Colors / Objects / Geometry tabs) edits compare colors
|
|
114
|
-
and these sysvars (live preview; Cancel restores the previous values).
|
|
115
|
-
COMPAREPROPS is registry-saved. The other four are read from the first
|
|
116
|
-
opened drawing, then written onto both open drawings so the panes stay in
|
|
117
|
-
sync.
|
|
118
|
-
|
|
119
|
-
## Limitations
|
|
120
|
-
|
|
121
|
-
Several of these match AutoCAD COMPARE. Others are current-scope gaps in
|
|
122
|
-
this viewer.
|
|
123
|
-
|
|
124
|
-
**Scope**
|
|
125
|
-
|
|
126
|
-
- Only **model-space, top-level** entities are compared. Paper space, other
|
|
127
|
-
layouts, and entities nested inside an INSERT / block definition are not.
|
|
128
|
-
- An INSERT is one object (block name, insertion point, rotation, scale, and
|
|
129
|
-
the INSERT’s own properties). Edits inside the block definition are ignored.
|
|
130
|
-
Compare coloring keys off the INSERT handle, so nested primitives share one
|
|
131
|
-
role color instead of being tinted individually.
|
|
132
|
-
- Hatches are omitted unless COMPAREHATCH is `1`. TEXT / MTEXT / ATTRIB /
|
|
133
|
-
ATTDEF are omitted when COMPARETEXT is `0`.
|
|
134
|
-
|
|
135
|
-
**Properties vs appearance**
|
|
136
|
-
|
|
137
|
-
- The algorithm compares **stored entity values**, not the final rendered
|
|
138
|
-
look. ByLayer / ByBlock color and linetype are not resolved against the
|
|
139
|
-
layer table or a parent block.
|
|
140
|
-
- Changing a layer’s color or linetype in the layer table does **not** mark
|
|
141
|
-
entities on that layer as modified. COMPAREPROPS Layer only means the
|
|
142
|
-
entity moved to a different layer name.
|
|
143
|
-
- COMPAREPROPS defaults to `0`, so color, layer name, linetype, linetype
|
|
144
|
-
scale, lineweight, transparency, and thickness are ignored until the
|
|
145
|
-
matching bit is enabled in Settings.
|
|
146
|
-
|
|
147
|
-
**Matching**
|
|
148
|
-
|
|
149
|
-
- Same-handle pairing also requires the same DXF type. Unrelated files often
|
|
150
|
-
reuse handles; a LINE and a CIRCLE that share a handle are not treated as
|
|
151
|
-
one entity.
|
|
152
|
-
- Fingerprints cover common geometry (line endpoints, circle/arc, text,
|
|
153
|
-
INSERT transform, and similar). Types without those fields fall back to
|
|
154
|
-
axis-aligned extents, so some edits can be missed or over-matched.
|
|
155
|
-
|
|
156
|
-
**Display**
|
|
157
|
-
|
|
158
|
-
- Compare display replaces each drawing’s ACI / TrueColor with role tints
|
|
159
|
-
(gray / red / green). It is not a true-color overlay of the originals.
|
|
160
|
-
- Overlay mode does not keep a distinct modified color: modified-left is
|
|
161
|
-
painted as deleted, modified-right as added.
|
|
162
|
-
- Overlay mode converts the right drawing again as a read-only overlay; GPU
|
|
163
|
-
scenes are not moved between the two canvases.
|
|
164
|
-
|
|
165
|
-
**Hosting**
|
|
166
|
-
|
|
167
|
-
- `AcApDocManager` is a process singleton. Do not mount `AcApDiffViewer` on a
|
|
168
|
-
page that already hosts another CAD viewer from this stack.
|
|
169
|
-
- DWG parsing is not bundled. Register a converter in the host (see
|
|
170
|
-
[`cad-diff-viewer-example`](../cad-diff-viewer-example)).
|
|
171
|
-
|
|
172
|
-
## Usage
|
|
173
|
-
|
|
174
|
-
```ts
|
|
175
|
-
import { AcApDiffViewer } from '@mlightcad/cad-diff-viewer'
|
|
176
|
-
|
|
177
|
-
const viewer = new AcApDiffViewer({
|
|
178
|
-
container: document.getElementById('diff-host')!,
|
|
179
|
-
compareColors: {
|
|
180
|
-
unchanged: 0x9ca3af,
|
|
181
|
-
deleted: 0xe11d48, // left / old
|
|
182
|
-
added: 0x22c55e, // right / new
|
|
183
|
-
modified: 0xe11d48
|
|
184
|
-
},
|
|
185
|
-
webworkerFileUrls: {
|
|
186
|
-
mtextRender: './workers/mtext-renderer-worker.js',
|
|
187
|
-
dwgParser: './workers/libredwg-parser-worker.js'
|
|
188
|
-
}
|
|
189
|
-
})
|
|
190
|
-
|
|
191
|
-
await viewer.openDocument('left', file.name, await file.arrayBuffer())
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
### Features
|
|
195
|
-
|
|
196
|
-
- Side-by-side or overlay view modes
|
|
197
|
-
- Drop a DWG/DXF onto a pane, or click the pane / open-file icon
|
|
198
|
-
- Compare results panel (by change kind or entity type) with prev/next navigation
|
|
199
|
-
- Markup tools (cloud, callout, text, rect, circle, arrow, stamp, …)
|
|
200
|
-
- Show / hide markups, and clear markups on both drawings
|
|
201
|
-
- Generate cloud markups from compare change sets
|
|
202
|
-
- Compare display mode: gray base, deleted red, added green (configurable)
|
|
203
|
-
- Strings go through `AcApI18n` (`diffViewer.*`)
|
|
1
|
+
# @mlightcad/cad-diff-viewer
|
|
2
|
+
|
|
3
|
+
Reusable side-by-side / overlay CAD comparison widget. It depends on
|
|
4
|
+
[`@mlightcad/cad-simple-viewer`](../cad-simple-viewer) and creates both WebGL
|
|
5
|
+
canvases internally — the host only supplies a parent container.
|
|
6
|
+
|
|
7
|
+
## How it works
|
|
8
|
+
|
|
9
|
+
`AcApDiffViewer` does not reimplement CAD conversion. It creates one
|
|
10
|
+
`AcApDocManager` with two canvases (left = old, right = new), opens each file
|
|
11
|
+
into its own document session, then:
|
|
12
|
+
|
|
13
|
+
1. Runs [`acapCompareDrawings`](./src/compare/acapCompareDrawings.ts) on the two
|
|
14
|
+
model-space databases.
|
|
15
|
+
2. Turns the result into per-entity **compare roles**.
|
|
16
|
+
3. Paints those roles with **compare display mode** — a GPU tint that replaces
|
|
17
|
+
the drawing’s own ACI / TrueColor.
|
|
18
|
+
|
|
19
|
+
### Compare display (why everything looks one color)
|
|
20
|
+
|
|
21
|
+
Normal viewing keeps each entity’s CAD color. Compare display does the opposite:
|
|
22
|
+
when it is enabled, **every batched fragment is first forced to a single base
|
|
23
|
+
color** (default gray `#9ca3af`). Only entities with a role override then pick
|
|
24
|
+
up deleted / added / modified colors.
|
|
25
|
+
|
|
26
|
+
That tint is applied in the batch highlight shader, not by rewriting entity
|
|
27
|
+
materials on the CPU:
|
|
28
|
+
|
|
29
|
+
| Mask channel | Meaning |
|
|
30
|
+
| --- | --- |
|
|
31
|
+
| R | selection (wins over compare) |
|
|
32
|
+
| G | hover (wins over compare) |
|
|
33
|
+
| B | compare role: none / deleted / added / modified |
|
|
34
|
+
|
|
35
|
+
While `u_compareEnabled` is on, the fragment shader:
|
|
36
|
+
|
|
37
|
+
1. Sets the color to `u_compareBaseColor`.
|
|
38
|
+
2. Reads the B channel of the per-slot mask texture and swaps in
|
|
39
|
+
deleted / added / modified if a role is set.
|
|
40
|
+
3. Still lets selection and hover replace that color.
|
|
41
|
+
|
|
42
|
+
Unbatched drawables (for example fat lines) get the same roles via cloned
|
|
43
|
+
materials. Overlay/XREF layouts are colored separately through
|
|
44
|
+
`setOverlayCompareDisplay`.
|
|
45
|
+
|
|
46
|
+
**Side-by-side:** each canvas tints its own drawing. Unchanged geometry stays
|
|
47
|
+
gray. The left canvas marks deletions (and modified-left hits); the right
|
|
48
|
+
canvas marks additions (and modified-right hits).
|
|
49
|
+
|
|
50
|
+
**Overlay:** the right database is registered as a read-only overlay on the left
|
|
51
|
+
canvas (geometry is converted again; scenes are not moved between renderers).
|
|
52
|
+
The left drawing uses the deleted color for deleted *and* modified-left
|
|
53
|
+
entities; the overlay uses the added color for added *and* modified-right
|
|
54
|
+
entities. Unchanged geometry from both files sits on the gray base so you can
|
|
55
|
+
see what moved.
|
|
56
|
+
|
|
57
|
+
Default role colors (overridable via `compareColors`):
|
|
58
|
+
|
|
59
|
+
- unchanged: `#9ca3af`
|
|
60
|
+
- deleted (left / old): `#e11d48`
|
|
61
|
+
- added (right / new): `#22c55e`
|
|
62
|
+
- modified: same as deleted in side-by-side; folded into red/green in overlay
|
|
63
|
+
|
|
64
|
+
### Diff algorithm
|
|
65
|
+
|
|
66
|
+
`acapCompareDrawings(leftDb, rightDb, options)` compares the two model-space
|
|
67
|
+
databases. Left is the old drawing; right is the new drawing. Options follow
|
|
68
|
+
AutoCAD COMPARE system variables from `@mlightcad/data-model`:
|
|
69
|
+
|
|
70
|
+
| Sysvar | Default | Effect |
|
|
71
|
+
| --- | --- | --- |
|
|
72
|
+
| **COMPAREPROPS** | `0` | Bitcode for object property diffs: Color `1`, Layer `2`, Linetype `4`, Linetype scale `8`, Lineweight `16`, Transparency `32`, Thickness `64`. `0` ignores property-only changes (geometry still compared). |
|
|
73
|
+
| **COMPAREHATCH** | `0` | `0` excludes hatch objects; `1` includes them. |
|
|
74
|
+
| **COMPARETEXT** | `1` | `0` excludes TEXT/MTEXT/ATTRIB/ATTDEF; `1` includes them. |
|
|
75
|
+
| **COMPARETOLERANCE** | `6` | Decimal places of geometric precision (`6` → `1e-6`). |
|
|
76
|
+
| **COMPARERCMARGIN** | `5` | `1–25`. Scales change-set clustering and revision-cloud padding. |
|
|
77
|
+
|
|
78
|
+
**Tolerance.** Coordinates and angles are quantized onto
|
|
79
|
+
`10 ** -COMPARETOLERANCE`, unless you pass an explicit `tolerance`.
|
|
80
|
+
|
|
81
|
+
Each entity then gets two strings:
|
|
82
|
+
|
|
83
|
+
- **Fingerprint** — DXF type plus quantized geometry (line endpoints, center /
|
|
84
|
+
radius / angles, position, rotation, height, block name, scale, TEXT /
|
|
85
|
+
MTEXT contents). If those fields are missing, axis-aligned extents are used.
|
|
86
|
+
Line endpoints are stored in a direction-independent order.
|
|
87
|
+
- **Property key** — only the COMPAREPROPS bits that are enabled (empty when
|
|
88
|
+
COMPAREPROPS is `0`).
|
|
89
|
+
|
|
90
|
+
**Matching (in order):**
|
|
91
|
+
|
|
92
|
+
1. Same DWG/DXF handle (`objectId`) **and** the same DXF type. Typical when
|
|
93
|
+
the file was edited in place.
|
|
94
|
+
2. Among leftovers, same `dxfType` (and layer, when COMPAREPROPS includes
|
|
95
|
+
Layer) **and** the same fingerprint.
|
|
96
|
+
|
|
97
|
+
**Classification:**
|
|
98
|
+
|
|
99
|
+
| Fingerprint | Property key | Result |
|
|
100
|
+
| --- | --- | --- |
|
|
101
|
+
| equal | equal | unchanged (omitted unless `includeUnchanged`) |
|
|
102
|
+
| equal | different | modified (attribute-only change; COMPAREPROPS ≠ 0) |
|
|
103
|
+
| different | — (handle match) | modified |
|
|
104
|
+
| no match | — | deleted (left only) or added (right only) |
|
|
105
|
+
|
|
106
|
+
Modified pairs emit **two** hits (one per side) with `pairedId` pointing at the
|
|
107
|
+
other entity. Nearby differences are grouped into **change sets**. The markup
|
|
108
|
+
toolbar can create built-in cloud markups around those sets. A cloud uses the
|
|
109
|
+
Settings color for its single change kind (added, deleted, or modified);
|
|
110
|
+
mixed-kind sets use the modified color. The results panel navigates
|
|
111
|
+
`deleted → modified (left) → added`.
|
|
112
|
+
|
|
113
|
+
The Settings dialog (Colors / Objects / Geometry tabs) edits compare colors
|
|
114
|
+
and these sysvars (live preview; Cancel restores the previous values).
|
|
115
|
+
COMPAREPROPS is registry-saved. The other four are read from the first
|
|
116
|
+
opened drawing, then written onto both open drawings so the panes stay in
|
|
117
|
+
sync.
|
|
118
|
+
|
|
119
|
+
## Limitations
|
|
120
|
+
|
|
121
|
+
Several of these match AutoCAD COMPARE. Others are current-scope gaps in
|
|
122
|
+
this viewer.
|
|
123
|
+
|
|
124
|
+
**Scope**
|
|
125
|
+
|
|
126
|
+
- Only **model-space, top-level** entities are compared. Paper space, other
|
|
127
|
+
layouts, and entities nested inside an INSERT / block definition are not.
|
|
128
|
+
- An INSERT is one object (block name, insertion point, rotation, scale, and
|
|
129
|
+
the INSERT’s own properties). Edits inside the block definition are ignored.
|
|
130
|
+
Compare coloring keys off the INSERT handle, so nested primitives share one
|
|
131
|
+
role color instead of being tinted individually.
|
|
132
|
+
- Hatches are omitted unless COMPAREHATCH is `1`. TEXT / MTEXT / ATTRIB /
|
|
133
|
+
ATTDEF are omitted when COMPARETEXT is `0`.
|
|
134
|
+
|
|
135
|
+
**Properties vs appearance**
|
|
136
|
+
|
|
137
|
+
- The algorithm compares **stored entity values**, not the final rendered
|
|
138
|
+
look. ByLayer / ByBlock color and linetype are not resolved against the
|
|
139
|
+
layer table or a parent block.
|
|
140
|
+
- Changing a layer’s color or linetype in the layer table does **not** mark
|
|
141
|
+
entities on that layer as modified. COMPAREPROPS Layer only means the
|
|
142
|
+
entity moved to a different layer name.
|
|
143
|
+
- COMPAREPROPS defaults to `0`, so color, layer name, linetype, linetype
|
|
144
|
+
scale, lineweight, transparency, and thickness are ignored until the
|
|
145
|
+
matching bit is enabled in Settings.
|
|
146
|
+
|
|
147
|
+
**Matching**
|
|
148
|
+
|
|
149
|
+
- Same-handle pairing also requires the same DXF type. Unrelated files often
|
|
150
|
+
reuse handles; a LINE and a CIRCLE that share a handle are not treated as
|
|
151
|
+
one entity.
|
|
152
|
+
- Fingerprints cover common geometry (line endpoints, circle/arc, text,
|
|
153
|
+
INSERT transform, and similar). Types without those fields fall back to
|
|
154
|
+
axis-aligned extents, so some edits can be missed or over-matched.
|
|
155
|
+
|
|
156
|
+
**Display**
|
|
157
|
+
|
|
158
|
+
- Compare display replaces each drawing’s ACI / TrueColor with role tints
|
|
159
|
+
(gray / red / green). It is not a true-color overlay of the originals.
|
|
160
|
+
- Overlay mode does not keep a distinct modified color: modified-left is
|
|
161
|
+
painted as deleted, modified-right as added.
|
|
162
|
+
- Overlay mode converts the right drawing again as a read-only overlay; GPU
|
|
163
|
+
scenes are not moved between the two canvases.
|
|
164
|
+
|
|
165
|
+
**Hosting**
|
|
166
|
+
|
|
167
|
+
- `AcApDocManager` is a process singleton. Do not mount `AcApDiffViewer` on a
|
|
168
|
+
page that already hosts another CAD viewer from this stack.
|
|
169
|
+
- DWG parsing is not bundled. Register a converter in the host (see
|
|
170
|
+
[`cad-diff-viewer-example`](../cad-diff-viewer-example)).
|
|
171
|
+
|
|
172
|
+
## Usage
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
import { AcApDiffViewer } from '@mlightcad/cad-diff-viewer'
|
|
176
|
+
|
|
177
|
+
const viewer = new AcApDiffViewer({
|
|
178
|
+
container: document.getElementById('diff-host')!,
|
|
179
|
+
compareColors: {
|
|
180
|
+
unchanged: 0x9ca3af,
|
|
181
|
+
deleted: 0xe11d48, // left / old
|
|
182
|
+
added: 0x22c55e, // right / new
|
|
183
|
+
modified: 0xe11d48
|
|
184
|
+
},
|
|
185
|
+
webworkerFileUrls: {
|
|
186
|
+
mtextRender: './workers/mtext-renderer-worker.js',
|
|
187
|
+
dwgParser: './workers/libredwg-parser-worker.js'
|
|
188
|
+
}
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
await viewer.openDocument('left', file.name, await file.arrayBuffer())
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Features
|
|
195
|
+
|
|
196
|
+
- Side-by-side or overlay view modes
|
|
197
|
+
- Drop a DWG/DXF onto a pane, or click the pane / open-file icon
|
|
198
|
+
- Compare results panel (by change kind or entity type) with prev/next navigation
|
|
199
|
+
- Markup tools (cloud, callout, text, rect, circle, arrow, stamp, …)
|
|
200
|
+
- Show / hide markups, and clear markups on both drawings
|
|
201
|
+
- Generate cloud markups from compare change sets
|
|
202
|
+
- Compare display mode: gray base, deleted red, added green (configurable)
|
|
203
|
+
- Strings go through `AcApI18n` (`diffViewer.*`)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mlightcad/cad-diff-viewer",
|
|
3
|
-
"version": "1.7.7
|
|
3
|
+
"version": "1.7.7",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@mlightcad/data-model": "1.15.14",
|
|
37
|
-
"@mlightcad/cad-simple-viewer": "1.7.7
|
|
37
|
+
"@mlightcad/cad-simple-viewer": "1.7.7"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"@mlightcad/data-model": "1.15.14",
|
|
41
|
-
"@mlightcad/cad-simple-viewer": "1.7.7
|
|
41
|
+
"@mlightcad/cad-simple-viewer": "1.7.7"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"clean": "rimraf dist lib tsconfig.tsbuildinfo",
|