@design-core/core 0.0.7 → 51.1.0
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/.github/workflows/DesignCoreQA.yml +3 -0
- package/core/designCore.js +1 -1
- package/core/dimensions/alignedDimension.js +7 -7
- package/core/dimensions/angularDimension.js +32 -32
- package/core/dimensions/{baseCircularDimension.js → circularDimensionBase.js} +19 -19
- package/core/dimensions/diametricDimension.js +10 -10
- package/core/dimensions/dimension.js +42 -42
- package/core/dimensions/{baseDimension.js → dimensionBase.js} +17 -17
- package/core/dimensions/{baseLinearDimension.js → linearDimensionBase.js} +9 -9
- package/core/dimensions/radialDimension.js +8 -8
- package/core/dimensions/rotatedDimension.js +8 -8
- package/core/entities/arc.js +22 -22
- package/core/entities/arctext.js +13 -13
- package/core/entities/circle.js +7 -7
- package/core/entities/hatch.js +210 -40
- package/core/entities/insert.js +11 -6
- package/core/entities/point.js +19 -19
- package/core/entities/polyline.js +3 -3
- package/core/entities/{basePolyline.js → polylineBase.js} +18 -18
- package/core/entities/text.js +4 -4
- package/core/lib/boundingBox.js +11 -11
- package/core/lib/canvas.js +13 -6
- package/core/lib/clipboard.js +2 -2
- package/core/lib/dxf/dxf.js +11 -11
- package/core/lib/dxf/dxfIterator.js +2 -2
- package/core/lib/entityManager.js +19 -19
- package/core/lib/inputManager.js +1 -1
- package/core/lib/matrix.js +1 -1
- package/core/lib/patterns.js +1 -1
- package/core/lib/polylineUtils.js +9 -9
- package/core/lib/renderers/cairoRenderer.js +5 -5
- package/core/lib/renderers/canvasRenderer.js +4 -4
- package/core/lib/renderers/pdfRenderer.js +7 -7
- package/core/lib/renderers/rendererBase.js +1 -1
- package/core/lib/scene.js +1 -1
- package/core/lib/selectionManager.js +18 -18
- package/core/lib/utils.js +5 -5
- package/core/properties/entityProperties.js +2 -1
- package/core/properties/flags.js +12 -0
- package/core/properties/property.js +8 -3
- package/core/properties/propertyManager.js +52 -37
- package/core/tables/block.js +50 -46
- package/core/tables/dimStyle.js +5 -5
- package/core/tables/ltypeManager.js +1 -1
- package/core/tables/vport.js +2 -2
- package/core/tools/chamfer.js +6 -6
- package/core/tools/chamferFilletBase.js +4 -4
- package/core/tools/copy.js +8 -8
- package/core/tools/copybase.js +3 -3
- package/core/tools/copyclip.js +3 -3
- package/core/tools/cornerEntity.js +2 -2
- package/core/tools/cutclip.js +3 -3
- package/core/tools/explode.js +6 -6
- package/core/tools/extend.js +13 -13
- package/core/tools/fillet.js +6 -6
- package/core/tools/matchProp.js +1 -1
- package/core/tools/mirror.js +11 -11
- package/core/tools/move.js +5 -5
- package/core/tools/offset.js +29 -29
- package/core/tools/purge.js +10 -10
- package/core/tools/rotate.js +16 -16
- package/core/tools/scale.js +6 -6
- package/core/tools/trim.js +15 -15
- package/cspell.json +323 -0
- package/package.json +1 -1
- package/test/dimensions/alignedDimension.test.js +3 -3
- package/test/dimensions/angularDimension.test.js +7 -7
- package/test/dimensions/diametricDimension.test.js +9 -9
- package/test/dimensions/dimension.test.js +12 -12
- package/test/dimensions/{baseDimension.test.js → dimensionBase.test.js} +12 -12
- package/test/dimensions/{baseLinearDimension.test.js → linearDimensionBase.test.js} +7 -7
- package/test/dimensions/radialDimension.test.js +9 -9
- package/test/dimensions/rotatedDimension.test.js +4 -4
- package/test/entities/arc.test.js +10 -10
- package/test/entities/arctext.test.js +6 -6
- package/test/entities/circle.test.js +18 -18
- package/test/entities/hatch.test.js +362 -39
- package/test/entities/insert.test.js +9 -9
- package/test/entities/point.test.js +3 -3
- package/test/entities/{basePolyline.test.js → polylineBase.test.js} +131 -62
- package/test/entities/text.test.js +19 -19
- package/test/integration/exportIntegration.test.js +3 -3
- package/test/integration/userInputIntegration.test.js +5 -5
- package/test/lib/boundingBox.test.js +3 -3
- package/test/lib/canvas.test.js +9 -9
- package/test/lib/clipboard.test.js +73 -0
- package/test/lib/inputManager.test.js +4 -4
- package/test/lib/scene.test.js +9 -9
- package/test/lib/selectionManager.test.js +3 -3
- package/test/lib/snapping.test.js +1 -1
- package/test/properties/flags.test.js +24 -0
- package/test/properties/propertyManager.test.js +93 -22
- package/test/renderers/pdfRenderer.test.js +2 -2
- package/test/tables/block.test.js +63 -14
- package/test/tables/layerManager.test.js +2 -2
- package/test/test-helpers/hatchGridRenderer.js +3 -3
- package/test/test-helpers/test-helpers.js +6 -6
- package/test/tools/chamfer.test.js +60 -60
- package/test/tools/chamferFilletBase.test.js +36 -36
- package/test/tools/copy.test.js +6 -6
- package/test/tools/copybase.test.js +2 -2
- package/test/tools/copyclip.test.js +2 -2
- package/test/tools/cornerEntity.test.js +8 -8
- package/test/tools/cutclip.test.js +2 -2
- package/test/tools/erase.test.js +6 -6
- package/test/tools/explode.test.js +2 -2
- package/test/tools/extend.test.js +84 -84
- package/test/tools/fillet.test.js +62 -62
- package/test/tools/matchProp.test.js +6 -6
- package/test/tools/mirror.test.js +26 -26
- package/test/tools/move.test.js +7 -7
- package/test/tools/offset.test.js +65 -65
- package/test/tools/purge.test.js +4 -4
- package/test/tools/rotate.test.js +10 -10
- package/test/tools/scale.test.js +28 -28
- package/test/tools/trim.test.js +109 -109
- package/test/tools/zoom.test.js +15 -17
package/cspell.json
ADDED
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.2",
|
|
3
|
+
"language": "en-GB",
|
|
4
|
+
"ignorePaths": [
|
|
5
|
+
"node_modules",
|
|
6
|
+
"_build",
|
|
7
|
+
"coverage",
|
|
8
|
+
"*.lock",
|
|
9
|
+
"package-lock.json",
|
|
10
|
+
"test/**"
|
|
11
|
+
],
|
|
12
|
+
"ignoreRegExpList": [
|
|
13
|
+
"[0-9a-fA-F]{6,}"
|
|
14
|
+
],
|
|
15
|
+
"words": [
|
|
16
|
+
"acad",
|
|
17
|
+
"ACADVER",
|
|
18
|
+
"autocad",
|
|
19
|
+
"ARCALIGNEDTEXT",
|
|
20
|
+
"ARCHTICK",
|
|
21
|
+
"arcpoints",
|
|
22
|
+
"ARCSIDE",
|
|
23
|
+
"arctext",
|
|
24
|
+
"ASME",
|
|
25
|
+
"AABB",
|
|
26
|
+
"basepoint",
|
|
27
|
+
"bbox",
|
|
28
|
+
"bboxes",
|
|
29
|
+
"bitmasked",
|
|
30
|
+
"byblock",
|
|
31
|
+
"bylayer",
|
|
32
|
+
"CANNOSCALE",
|
|
33
|
+
"CHARACTERSPACING",
|
|
34
|
+
"CHILDENTITIES",
|
|
35
|
+
"clayer",
|
|
36
|
+
"copybase",
|
|
37
|
+
"copyclip",
|
|
38
|
+
"cutclip",
|
|
39
|
+
"pasteclip",
|
|
40
|
+
"defpoints",
|
|
41
|
+
"dedup",
|
|
42
|
+
"DECIMALPLACES",
|
|
43
|
+
"DESTINATIONSET",
|
|
44
|
+
"dimstyle",
|
|
45
|
+
"dimstyles",
|
|
46
|
+
"dimline",
|
|
47
|
+
"DIMENSIONSTYLE",
|
|
48
|
+
"DIMADEC",
|
|
49
|
+
"DIMALI",
|
|
50
|
+
"DIMALT",
|
|
51
|
+
"DIMALTD",
|
|
52
|
+
"DIMALTF",
|
|
53
|
+
"DIMALTMZF",
|
|
54
|
+
"DIMALTMZS",
|
|
55
|
+
"DIMALTRND",
|
|
56
|
+
"DIMALTTD",
|
|
57
|
+
"DIMALTTZ",
|
|
58
|
+
"DIMALTU",
|
|
59
|
+
"DIMALTZ",
|
|
60
|
+
"DIMANG",
|
|
61
|
+
"DIMANNO",
|
|
62
|
+
"DIMAPOST",
|
|
63
|
+
"DIMARCSYM",
|
|
64
|
+
"DIMASO",
|
|
65
|
+
"DIMASSOC",
|
|
66
|
+
"DIMASZ",
|
|
67
|
+
"DIMATFIT",
|
|
68
|
+
"DIMAUNIT",
|
|
69
|
+
"DIMAZIN",
|
|
70
|
+
"DIMBLK",
|
|
71
|
+
"DIMCEN",
|
|
72
|
+
"DIMCENSTYL",
|
|
73
|
+
"DIMCENVALUE",
|
|
74
|
+
"DIMCLRD",
|
|
75
|
+
"DIMCLRE",
|
|
76
|
+
"DIMCLRT",
|
|
77
|
+
"DIMCONSTRAINTICON",
|
|
78
|
+
"DIMDEC",
|
|
79
|
+
"DIMDIA",
|
|
80
|
+
"DIMDLE",
|
|
81
|
+
"DIMDLI",
|
|
82
|
+
"DIMDSEP",
|
|
83
|
+
"DIMEXE",
|
|
84
|
+
"DIMEXO",
|
|
85
|
+
"DIMFIT",
|
|
86
|
+
"DIMFRAC",
|
|
87
|
+
"DIMFXL",
|
|
88
|
+
"DIMFXLON",
|
|
89
|
+
"DIMGAP",
|
|
90
|
+
"DIMJOGANG",
|
|
91
|
+
"DIMJUST",
|
|
92
|
+
"DIMLDRBLK",
|
|
93
|
+
"DIMLFAC",
|
|
94
|
+
"DIMLIM",
|
|
95
|
+
"DIMLIN",
|
|
96
|
+
"DIMLTEX",
|
|
97
|
+
"DIMLTYPE",
|
|
98
|
+
"DIMLUNIT",
|
|
99
|
+
"DIMLWD",
|
|
100
|
+
"DIMLWE",
|
|
101
|
+
"DIMMZF",
|
|
102
|
+
"DIMMZS",
|
|
103
|
+
"DIMPOST",
|
|
104
|
+
"DIMRAD",
|
|
105
|
+
"DIMRND",
|
|
106
|
+
"DIMROT",
|
|
107
|
+
"DIMSAH",
|
|
108
|
+
"DIMSCALE",
|
|
109
|
+
"DIMSD",
|
|
110
|
+
"DIMSE",
|
|
111
|
+
"DIMSHO",
|
|
112
|
+
"DIMSOXD",
|
|
113
|
+
"DIMTAD",
|
|
114
|
+
"DIMTDEC",
|
|
115
|
+
"DIMTFAC",
|
|
116
|
+
"DIMTFILL",
|
|
117
|
+
"DIMTFILLCLR",
|
|
118
|
+
"DIMTIH",
|
|
119
|
+
"DIMTIX",
|
|
120
|
+
"DIMTM",
|
|
121
|
+
"DIMTMOVE",
|
|
122
|
+
"DIMTOFL",
|
|
123
|
+
"DIMTOH",
|
|
124
|
+
"DIMTOL",
|
|
125
|
+
"DIMTOLJ",
|
|
126
|
+
"DIMTP",
|
|
127
|
+
"DIMTSZ",
|
|
128
|
+
"DIMTVP",
|
|
129
|
+
"DIMTXSTY",
|
|
130
|
+
"DIMTXT",
|
|
131
|
+
"DIMTXTDIRECTION",
|
|
132
|
+
"DIMTZIN",
|
|
133
|
+
"DIMUNIT",
|
|
134
|
+
"DIMUPT",
|
|
135
|
+
"DIMZIN",
|
|
136
|
+
"drawgrid",
|
|
137
|
+
"endblk",
|
|
138
|
+
"endsec",
|
|
139
|
+
"endsnap",
|
|
140
|
+
"EXTMAX",
|
|
141
|
+
"EXTMIN",
|
|
142
|
+
"FILLETRAD",
|
|
143
|
+
"FONTNAME",
|
|
144
|
+
"HATCHDOUBLE",
|
|
145
|
+
"HATCHSPACING",
|
|
146
|
+
"groupcode",
|
|
147
|
+
"groupcodes",
|
|
148
|
+
"groupvalue",
|
|
149
|
+
"handseed",
|
|
150
|
+
"HORIZONTALALIGNMENT",
|
|
151
|
+
"INSBASE",
|
|
152
|
+
"inputprompt",
|
|
153
|
+
"isopair",
|
|
154
|
+
"itemname",
|
|
155
|
+
"keypresses",
|
|
156
|
+
"lerp",
|
|
157
|
+
"LINEARDIMANGLE",
|
|
158
|
+
"linetype",
|
|
159
|
+
"linetypes",
|
|
160
|
+
"lineweight",
|
|
161
|
+
"ltscale",
|
|
162
|
+
"ltype",
|
|
163
|
+
"ltypes",
|
|
164
|
+
"lwpoly",
|
|
165
|
+
"lwpolyline",
|
|
166
|
+
"MLEADER",
|
|
167
|
+
"MLEADERSCALE",
|
|
168
|
+
"multileader",
|
|
169
|
+
"nearestsnap",
|
|
170
|
+
"midsnap",
|
|
171
|
+
"nodesnap",
|
|
172
|
+
"tangentsnap",
|
|
173
|
+
"quadrantsnap",
|
|
174
|
+
"perpendicularsnap",
|
|
175
|
+
"centresnap",
|
|
176
|
+
"NOCHAMFER",
|
|
177
|
+
"NOFILLET",
|
|
178
|
+
"NONCONSECUTIVESEGMENTS",
|
|
179
|
+
"NOREDO",
|
|
180
|
+
"NOTRIM",
|
|
181
|
+
"NOUNDO",
|
|
182
|
+
"OFFSETFROMARC",
|
|
183
|
+
"OFFSETFROMLEFT",
|
|
184
|
+
"OFFSETFROMRIGHT",
|
|
185
|
+
"Paperspace",
|
|
186
|
+
"PATTERNNAME",
|
|
187
|
+
"PLOTSTYLENAME",
|
|
188
|
+
"plottable",
|
|
189
|
+
"polarangle",
|
|
190
|
+
"polyface",
|
|
191
|
+
"postsuffix",
|
|
192
|
+
"preselection",
|
|
193
|
+
"RADIUSTOOLARGE",
|
|
194
|
+
"REFERENCELENGTH",
|
|
195
|
+
"RRGGBB",
|
|
196
|
+
"rubberbandcolour",
|
|
197
|
+
"SCALEFACTOR",
|
|
198
|
+
"selectedchild",
|
|
199
|
+
"SELECTIONSET",
|
|
200
|
+
"SEQEND",
|
|
201
|
+
"SINGLESELECTION",
|
|
202
|
+
"solidfill",
|
|
203
|
+
"standardflags",
|
|
204
|
+
"startxref",
|
|
205
|
+
"STYLENAME",
|
|
206
|
+
"TEXTALIGNMENT",
|
|
207
|
+
"TEXTORIENTATION",
|
|
208
|
+
"TEXTOVERRIDE",
|
|
209
|
+
"TEXTREVERSED",
|
|
210
|
+
"TEXTSIZE",
|
|
211
|
+
"TEXTSTYLE",
|
|
212
|
+
"THROUGHPOINT",
|
|
213
|
+
"truecolour",
|
|
214
|
+
"TRIMMODE",
|
|
215
|
+
"UCSICON",
|
|
216
|
+
"uncloseable",
|
|
217
|
+
"undrawn",
|
|
218
|
+
"UNKNOWNCOMMAND",
|
|
219
|
+
"unrecognised",
|
|
220
|
+
"VERTICALALIGNMENT",
|
|
221
|
+
"vport",
|
|
222
|
+
"WIDTHFACTOR",
|
|
223
|
+
"xgridmax",
|
|
224
|
+
"xgridmin",
|
|
225
|
+
"ygridmax",
|
|
226
|
+
"ygridmin",
|
|
227
|
+
"ZEROLENGTH",
|
|
228
|
+
"accentcolour",
|
|
229
|
+
"Alignedtext",
|
|
230
|
+
"BADINPUT",
|
|
231
|
+
"BLOCKNAME",
|
|
232
|
+
"boundingbox",
|
|
233
|
+
"BOXBLANK",
|
|
234
|
+
"BOXFILLED",
|
|
235
|
+
"BRELM",
|
|
236
|
+
"BRSTD",
|
|
237
|
+
"BRSTONE",
|
|
238
|
+
"canvasbackgroundcolour",
|
|
239
|
+
"CANNOTBEACTIONED",
|
|
240
|
+
"CANNOTBEDELETED",
|
|
241
|
+
"CANNOTBERENAMED",
|
|
242
|
+
"CHAMFERA",
|
|
243
|
+
"CHAMFERB",
|
|
244
|
+
"CHAMFERC",
|
|
245
|
+
"CHAMFERD",
|
|
246
|
+
"CHAMMODE",
|
|
247
|
+
"checkitems",
|
|
248
|
+
"CLOSEDBLANK",
|
|
249
|
+
"CONC",
|
|
250
|
+
"counterclockwise",
|
|
251
|
+
"cstyle",
|
|
252
|
+
"CSTYLEDELETE",
|
|
253
|
+
"currentstyle",
|
|
254
|
+
"DASHDOT",
|
|
255
|
+
"DATUMBLANK",
|
|
256
|
+
"DATUMFILLED",
|
|
257
|
+
"Degen",
|
|
258
|
+
"deleteblock",
|
|
259
|
+
"DOLMIT",
|
|
260
|
+
"DOTBLANK",
|
|
261
|
+
"DOTSMALL",
|
|
262
|
+
"Elec",
|
|
263
|
+
"ENDTAB",
|
|
264
|
+
"ERASESOURCE",
|
|
265
|
+
"Extline",
|
|
266
|
+
"FILEOPEN",
|
|
267
|
+
"fontbackwards",
|
|
268
|
+
"fontupsidedown",
|
|
269
|
+
"Gradians",
|
|
270
|
+
"gridcolour",
|
|
271
|
+
"gridlines",
|
|
272
|
+
"HBONE",
|
|
273
|
+
"INSUL",
|
|
274
|
+
"INVALIDBOUNDARY",
|
|
275
|
+
"INVALIDCLIPBOARD",
|
|
276
|
+
"INVALIDDXFFORMAT",
|
|
277
|
+
"INVALIDFILE",
|
|
278
|
+
"INVALIDGROUPCODE",
|
|
279
|
+
"INVALIDINTERSECTTYPE",
|
|
280
|
+
"INVALIDNUMBER",
|
|
281
|
+
"INVALIDPOINT",
|
|
282
|
+
"INVALIDTYPE",
|
|
283
|
+
"LAYERNAME",
|
|
284
|
+
"LEADERLENGTH",
|
|
285
|
+
"LWDEFAULT",
|
|
286
|
+
"MAXVALUE",
|
|
287
|
+
"midp",
|
|
288
|
+
"MINVALUE",
|
|
289
|
+
"MIRRORFIRST",
|
|
290
|
+
"MIRRORSECOND",
|
|
291
|
+
"MUDST",
|
|
292
|
+
"nendobj",
|
|
293
|
+
"NEWLENGTH",
|
|
294
|
+
"NEXTPOINT",
|
|
295
|
+
"NOEXTEND",
|
|
296
|
+
"nonexistent",
|
|
297
|
+
"NOTACOMMAND",
|
|
298
|
+
"NOTAPATTERN",
|
|
299
|
+
"NOTIMPLEMENTED",
|
|
300
|
+
"Offscreen",
|
|
301
|
+
"OFFSETDIST",
|
|
302
|
+
"PARALLELLINES",
|
|
303
|
+
"PARQ",
|
|
304
|
+
"PLAST",
|
|
305
|
+
"PLASTI",
|
|
306
|
+
"readblocks",
|
|
307
|
+
"renameitem",
|
|
308
|
+
"roundtrip",
|
|
309
|
+
"RROOF",
|
|
310
|
+
"RSHKE",
|
|
311
|
+
"SACNCR",
|
|
312
|
+
"Segs",
|
|
313
|
+
"TRIANG",
|
|
314
|
+
"underflowed",
|
|
315
|
+
"unminified",
|
|
316
|
+
"UNSUPPORTEDENTITIES",
|
|
317
|
+
"UPSIDEDOWN",
|
|
318
|
+
"Viewmode",
|
|
319
|
+
"xref",
|
|
320
|
+
"GOST",
|
|
321
|
+
"quot"
|
|
322
|
+
]
|
|
323
|
+
}
|
package/package.json
CHANGED
|
@@ -13,14 +13,14 @@ const scenarios = [
|
|
|
13
13
|
|
|
14
14
|
{ desc: 'Aligned dimension from point selection',
|
|
15
15
|
input: [new Point(), new Point(10, 0), new Point(5, 5)],
|
|
16
|
-
|
|
16
|
+
selectedEntities: [],
|
|
17
17
|
expectedDimType: 1,
|
|
18
18
|
dimensionValue: 10,
|
|
19
19
|
},
|
|
20
20
|
];
|
|
21
21
|
|
|
22
22
|
test.each(scenarios)('Dimension.execute handles $desc', async (scenario) => {
|
|
23
|
-
const { input,
|
|
23
|
+
const { input, selectedEntities, expectedDimType, dimensionValue } = scenario;
|
|
24
24
|
|
|
25
25
|
await withMockInput(DesignCore.Scene, input, async () => {
|
|
26
26
|
const dim = new AlignedDimension();
|
|
@@ -37,7 +37,7 @@ test.each(scenarios)('Dimension.execute handles $desc', async (scenario) => {
|
|
|
37
37
|
expect(Number(entity.getProperty('string'))).toBeCloseTo(dimensionValue);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
}, {
|
|
40
|
+
}, { selectedEntities });
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
test('constructor sets default properties', () => {
|
|
@@ -18,35 +18,35 @@ const scenarios = [
|
|
|
18
18
|
|
|
19
19
|
{ desc: 'Angular dimension from line selection - 45 degrees',
|
|
20
20
|
input: [new SingleSelection(0, new Point()), new SingleSelection(1, new Point()), new Point(5, 5)],
|
|
21
|
-
|
|
21
|
+
selectedEntities: [new Line({ points: [new Point(0, 0), new Point(10, 0)] }), new Line({ points: [new Point(0, 0), new Point(10, 10)] })],
|
|
22
22
|
expectedDimType: 2,
|
|
23
23
|
dimensionValue: 45,
|
|
24
24
|
dimensionEntities: 5,
|
|
25
25
|
},
|
|
26
26
|
{ desc: 'Angular dimension from line selection - 135 degrees',
|
|
27
27
|
input: [new SingleSelection(0, new Point()), new SingleSelection(1, new Point()), new Point(-5, 5)],
|
|
28
|
-
|
|
28
|
+
selectedEntities: [new Line({ points: [new Point(0, 0), new Point(10, 0)] }), new Line({ points: [new Point(0, 0), new Point(10, 10)] })],
|
|
29
29
|
expectedDimType: 2,
|
|
30
30
|
dimensionValue: 135,
|
|
31
31
|
dimensionEntities: 6,
|
|
32
32
|
},
|
|
33
33
|
{ desc: 'Angular dimension from line selection - 45 degrees',
|
|
34
34
|
input: [new SingleSelection(0, new Point()), new SingleSelection(1, new Point()), new Point(-5, -5)],
|
|
35
|
-
|
|
35
|
+
selectedEntities: [new Line({ points: [new Point(0, 0), new Point(10, 0)] }), new Line({ points: [new Point(0, 0), new Point(10, 10)] })],
|
|
36
36
|
expectedDimType: 2,
|
|
37
37
|
dimensionValue: 45,
|
|
38
38
|
dimensionEntities: 7,
|
|
39
39
|
},
|
|
40
40
|
{ desc: 'Angular dimension from line selection - 135 degrees',
|
|
41
41
|
input: [new SingleSelection(0, new Point()), new SingleSelection(1, new Point()), new Point(5, -5)],
|
|
42
|
-
|
|
42
|
+
selectedEntities: [new Line({ points: [new Point(0, 0), new Point(10, 0)] }), new Line({ points: [new Point(0, 0), new Point(10, 10)] })],
|
|
43
43
|
expectedDimType: 2,
|
|
44
44
|
dimensionValue: 135,
|
|
45
45
|
dimensionEntities: 6,
|
|
46
46
|
},
|
|
47
47
|
{ desc: 'Angular dimension from polyline selection - 45 degrees',
|
|
48
48
|
input: [new SingleSelection(0, new Point(5, 0)), new SingleSelection(1, new Point(5, 5)), new Point(5, 5)],
|
|
49
|
-
|
|
49
|
+
selectedEntities: [new Polyline({ points: [new Point(0, 0), new Point(10, 0)] }), new Polyline({ points: [new Point(0, 0), new Point(10, 10)] })],
|
|
50
50
|
expectedDimType: 2,
|
|
51
51
|
dimensionValue: 45,
|
|
52
52
|
dimensionEntities: 5,
|
|
@@ -54,7 +54,7 @@ const scenarios = [
|
|
|
54
54
|
];
|
|
55
55
|
|
|
56
56
|
test.each(scenarios)('Dimension.execute handles $desc', async (scenario) => {
|
|
57
|
-
const { input,
|
|
57
|
+
const { input, selectedEntities, expectedDimType, dimensionValue, dimensionEntities } = scenario;
|
|
58
58
|
|
|
59
59
|
await withMockInput(DesignCore.Scene, input, async () => {
|
|
60
60
|
const dim = new AngularDimension();
|
|
@@ -74,7 +74,7 @@ test.each(scenarios)('Dimension.execute handles $desc', async (scenario) => {
|
|
|
74
74
|
expect(entity.getProperty('string')).toContain('°');
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
}, {
|
|
77
|
+
}, { selectedEntities });
|
|
78
78
|
});
|
|
79
79
|
|
|
80
80
|
test('constructor sets default properties', () => {
|
|
@@ -17,28 +17,28 @@ const scenarios = [
|
|
|
17
17
|
|
|
18
18
|
{ desc: 'Diametric dimension from circle selection - Text outside circle',
|
|
19
19
|
input: [new SingleSelection(0, new Point()), new Point(20, 0)],
|
|
20
|
-
|
|
20
|
+
selectedEntities: [new Circle({ points: [new Point(0, 0), new Point(10, 0)] })],
|
|
21
21
|
expectedDimType: 3,
|
|
22
22
|
dimensionValue: 20,
|
|
23
23
|
dimensionEntities: 6,
|
|
24
24
|
},
|
|
25
25
|
{ desc: 'Diametric dimension from circle selection - Text inside circle',
|
|
26
26
|
input: [new SingleSelection(0, new Point()), new Point(0, 0)],
|
|
27
|
-
|
|
27
|
+
selectedEntities: [new Circle({ points: [new Point(0, 0), new Point(10, 0)] })],
|
|
28
28
|
expectedDimType: 3,
|
|
29
29
|
dimensionValue: 20,
|
|
30
30
|
dimensionEntities: 5,
|
|
31
31
|
},
|
|
32
32
|
{ desc: 'Diametric dimension from arc selection',
|
|
33
33
|
input: [new SingleSelection(0, new Point()), new Point(20, 10)],
|
|
34
|
-
|
|
34
|
+
selectedEntities: [new Arc({ points: [new Point(0, 0), new Point(20, 0), new Point(20, 20)] })],
|
|
35
35
|
expectedDimType: 3,
|
|
36
36
|
dimensionValue: 40,
|
|
37
37
|
dimensionEntities: 6,
|
|
38
38
|
},
|
|
39
39
|
{ desc: 'Diametric dimension from polyline selection',
|
|
40
40
|
input: [new SingleSelection(0, new Point(30, 10)), new Point(30, 10)],
|
|
41
|
-
|
|
41
|
+
selectedEntities: [new Polyline({ points: [new Point(0, 0), new Point(20, 0, 1), new Point(20, 20)] })],
|
|
42
42
|
expectedDimType: 3,
|
|
43
43
|
dimensionValue: 20,
|
|
44
44
|
dimensionEntities: 6,
|
|
@@ -46,7 +46,7 @@ const scenarios = [
|
|
|
46
46
|
];
|
|
47
47
|
|
|
48
48
|
test.each(scenarios)('DiametricDimension.execute handles $desc', async (scenario) => {
|
|
49
|
-
const { input,
|
|
49
|
+
const { input, selectedEntities, expectedDimType, dimensionValue, dimensionEntities } = scenario;
|
|
50
50
|
|
|
51
51
|
await withMockInput(DesignCore.Scene, input, async () => {
|
|
52
52
|
const dim = new DiametricDimension();
|
|
@@ -66,7 +66,7 @@ test.each(scenarios)('DiametricDimension.execute handles $desc', async (scenario
|
|
|
66
66
|
expect(entity.getProperty('string')).toContain('Ø');
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
}, {
|
|
69
|
+
}, { selectedEntities });
|
|
70
70
|
});
|
|
71
71
|
|
|
72
72
|
test('constructor sets default properties', () => {
|
|
@@ -77,14 +77,14 @@ test('constructor sets default properties', () => {
|
|
|
77
77
|
|
|
78
78
|
|
|
79
79
|
test('getPointsFromSelection returns correct sequenced points', () => {
|
|
80
|
-
const
|
|
80
|
+
const centre = new Point(0, 0);
|
|
81
81
|
const textPos = new Point(10, 0);
|
|
82
82
|
// Mock item with getRadius
|
|
83
|
-
const item = { points: [
|
|
83
|
+
const item = { points: [centre], getRadius: () => 10 };
|
|
84
84
|
const result = DiametricDimension.getPointsFromSelection([item], textPos);
|
|
85
85
|
expect(Array.isArray(result)).toBe(true);
|
|
86
86
|
expect(result.length).toBe(3);
|
|
87
|
-
expect(result[0].sequence).toBe(10); //
|
|
87
|
+
expect(result[0].sequence).toBe(10); // centre
|
|
88
88
|
expect(result[1].sequence).toBe(15); // radius point
|
|
89
89
|
expect(result[2].sequence).toBe(11); // text position
|
|
90
90
|
});
|
|
@@ -18,61 +18,61 @@ const scenarios = [
|
|
|
18
18
|
|
|
19
19
|
{ desc: 'Rotated dimension from line selection',
|
|
20
20
|
input: [new SingleSelection(0, new Point()), new Point(5, 5)],
|
|
21
|
-
|
|
21
|
+
selectedEntities: [new Line({ points: [new Point(), new Point(10, 0)] })],
|
|
22
22
|
expectedDimType: 0,
|
|
23
23
|
},
|
|
24
24
|
{ desc: 'Aligned dimension from line selection',
|
|
25
25
|
input: [new SingleSelection(0, new Point()), new Point(6.5, 3.5)],
|
|
26
|
-
|
|
26
|
+
selectedEntities: [new Line({ points: [new Point(), new Point(10, 10)] })],
|
|
27
27
|
expectedDimType: 1,
|
|
28
28
|
},
|
|
29
29
|
{ desc: 'Rotated dimension from point selection',
|
|
30
30
|
input: [new Point(), new Point(10, 0), new Point(5, 5)],
|
|
31
|
-
|
|
31
|
+
selectedEntities: [],
|
|
32
32
|
expectedDimType: 0,
|
|
33
33
|
},
|
|
34
34
|
{ desc: 'Diametric dimension from circle selection',
|
|
35
35
|
input: [new SingleSelection(0, new Point()), new Point(20, 10)],
|
|
36
|
-
|
|
36
|
+
selectedEntities: [new Circle({ points: [new Point(), new Point(10, 0)] })],
|
|
37
37
|
expectedDimType: 3,
|
|
38
38
|
},
|
|
39
39
|
{ desc: 'Radial dimension from arc selection',
|
|
40
40
|
input: [new SingleSelection(0, new Point()), new Point(20, 10)],
|
|
41
|
-
|
|
41
|
+
selectedEntities: [new Arc({ points: [new Point(), new Point(10, 0), new Point(10, 10)] })],
|
|
42
42
|
expectedDimType: 4,
|
|
43
43
|
},
|
|
44
44
|
{ desc: 'Angular dimension from line selection',
|
|
45
45
|
input: [new SingleSelection(0, new Point()), new SingleSelection(1, new Point()), new Point(5, 5)],
|
|
46
|
-
|
|
46
|
+
selectedEntities: [new Line({ points: [new Point(), new Point(10, 0)] }), new Line({ points: [new Point(), new Point(10, 10)] })],
|
|
47
47
|
expectedDimType: 2,
|
|
48
48
|
},
|
|
49
49
|
{ desc: 'Aligned dimension from polyline selection',
|
|
50
50
|
input: [new SingleSelection(0, new Point()), new SingleSelection(1, new Point()), new Point(5, 5)],
|
|
51
|
-
|
|
51
|
+
selectedEntities: [new Polyline({ points: [new Point(), new Point(10, 0)] })],
|
|
52
52
|
expectedDimType: 1,
|
|
53
53
|
},
|
|
54
54
|
{ desc: 'Radial dimension from polyline selection',
|
|
55
55
|
input: [new SingleSelection(0, new Point(16, 5)), new Point(20, 5)],
|
|
56
|
-
|
|
56
|
+
selectedEntities: [new Polyline({ points: [new Point(), new Point(10, 0, 1), new Point(10, 10)] })],
|
|
57
57
|
expectedDimType: 4,
|
|
58
58
|
},
|
|
59
59
|
{ desc: 'Angular dimension from polyline selection',
|
|
60
60
|
input: [new SingleSelection(0, new Point(5, 0)), new SingleSelection(1, new Point(5, 5)), new Point(5, 5)],
|
|
61
|
-
|
|
61
|
+
selectedEntities: [new Polyline({ points: [new Point(), new Point(10, 0)] }), new Polyline({ points: [new Point(), new Point(10, 10)] })],
|
|
62
62
|
expectedDimType: 2,
|
|
63
63
|
},
|
|
64
64
|
|
|
65
65
|
];
|
|
66
66
|
|
|
67
67
|
test.each(scenarios)('Dimension.execute handles $desc', async (scenario) => {
|
|
68
|
-
const { input,
|
|
68
|
+
const { input, selectedEntities, expectedDimType } = scenario;
|
|
69
69
|
|
|
70
70
|
await withMockInput(DesignCore.Scene, input, async () => {
|
|
71
71
|
const dim = new Dimension();
|
|
72
72
|
await dim.execute();
|
|
73
73
|
|
|
74
74
|
expect(dim.dimType.getBaseDimType()).toBe(expectedDimType);
|
|
75
|
-
}, {
|
|
75
|
+
}, { selectedEntities });
|
|
76
76
|
});
|
|
77
77
|
|
|
78
78
|
test('constructor instantiates correct dimension type', () => {
|
|
@@ -95,7 +95,7 @@ test('get linear dimension type', () => {
|
|
|
95
95
|
|
|
96
96
|
test('preview calls createTempItem with correct args', () => {
|
|
97
97
|
const dim = new Dimension({ 70: 1 });
|
|
98
|
-
dim.
|
|
98
|
+
dim.selectedEntities = [1];
|
|
99
99
|
dim.points = [{}, {}];
|
|
100
100
|
// Should not throw
|
|
101
101
|
expect(() => dim.preview()).not.toThrow();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DimensionBase } from '../../core/dimensions/dimensionBase.js';
|
|
2
2
|
import { Point } from '../../core/entities/point.js';
|
|
3
3
|
import { Core } from '../../core/core/core.js';
|
|
4
4
|
import { Text } from '../../core/entities/text.js';
|
|
@@ -9,11 +9,11 @@ import { jest } from '@jest/globals';
|
|
|
9
9
|
// initialise core
|
|
10
10
|
new Core();
|
|
11
11
|
|
|
12
|
-
describe('
|
|
12
|
+
describe('DimensionBase', () => {
|
|
13
13
|
let baseDim;
|
|
14
14
|
|
|
15
15
|
beforeEach(() => {
|
|
16
|
-
baseDim = new
|
|
16
|
+
baseDim = new DimensionBase({});
|
|
17
17
|
baseDim.points = [new Point(1, 2, 0), new Point(3, 4, 0)];
|
|
18
18
|
});
|
|
19
19
|
|
|
@@ -164,7 +164,7 @@ describe('BaseDimension', () => {
|
|
|
164
164
|
});
|
|
165
165
|
|
|
166
166
|
test('constructor throws on invalid dimType', () => {
|
|
167
|
-
expect(() => new
|
|
167
|
+
expect(() => new DimensionBase({ 70: 999 })).toThrow(/Invalid Dimension Type/);
|
|
168
168
|
});
|
|
169
169
|
|
|
170
170
|
test('getDimensionValue uses textOverride', () => {
|
|
@@ -241,11 +241,11 @@ describe('BaseDimension', () => {
|
|
|
241
241
|
|
|
242
242
|
describe('draw()', () => {
|
|
243
243
|
/**
|
|
244
|
-
* Return a
|
|
245
|
-
* @return {
|
|
244
|
+
* Return a DimensionBase with a stubbed buildDimension() that produces one Line.
|
|
245
|
+
* @return {DimensionBase}
|
|
246
246
|
*/
|
|
247
247
|
function makeDim() {
|
|
248
|
-
const dim = new
|
|
248
|
+
const dim = new DimensionBase({});
|
|
249
249
|
dim.points = [new Point(0, 0), new Point(10, 0)];
|
|
250
250
|
dim.buildDimension = jest.fn(() => {
|
|
251
251
|
return [new Line({ points: [new Point(0, 0), new Point(10, 0)] })];
|
|
@@ -256,21 +256,21 @@ describe('BaseDimension', () => {
|
|
|
256
256
|
test('draw() returns the block items array', () => {
|
|
257
257
|
const dim = makeDim();
|
|
258
258
|
const result = dim.draw({});
|
|
259
|
-
expect(result).toBe(dim.block.
|
|
259
|
+
expect(result).toBe(dim.block.entities);
|
|
260
260
|
});
|
|
261
261
|
|
|
262
262
|
test('draw() calls refresh() (via buildDimension) when block is empty', () => {
|
|
263
263
|
const dim = makeDim();
|
|
264
|
-
expect(dim.block.
|
|
264
|
+
expect(dim.block.entities).toHaveLength(0);
|
|
265
265
|
dim.draw({});
|
|
266
266
|
expect(dim.buildDimension).toHaveBeenCalledTimes(1);
|
|
267
|
-
expect(dim.block.
|
|
267
|
+
expect(dim.block.entities.length).toBeGreaterThan(0);
|
|
268
268
|
});
|
|
269
269
|
|
|
270
270
|
test('draw() does not call refresh() when block already has items', () => {
|
|
271
271
|
const dim = makeDim();
|
|
272
272
|
// pre-populate the block
|
|
273
|
-
dim.block.
|
|
273
|
+
dim.block.addEntity(new Line({ points: [new Point(0, 0), new Point(1, 1)] }));
|
|
274
274
|
dim.draw({});
|
|
275
275
|
expect(dim.buildDimension).not.toHaveBeenCalled();
|
|
276
276
|
});
|
|
@@ -292,7 +292,7 @@ describe('BaseDimension', () => {
|
|
|
292
292
|
test('draw() block items have BYBLOCK colour after refresh', () => {
|
|
293
293
|
const dim = makeDim();
|
|
294
294
|
dim.draw({});
|
|
295
|
-
for (const item of dim.block.
|
|
295
|
+
for (const item of dim.block.entities) {
|
|
296
296
|
expect(item.entityColour.aci).toBe(0); // BYBLOCK = ACI 0
|
|
297
297
|
}
|
|
298
298
|
});
|