@design-core/core 0.0.7 → 50.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 +28 -28
- package/core/entities/insert.js +5 -5
- 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 +6 -4
- 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/property.js +1 -1
- package/core/properties/propertyManager.js +37 -37
- package/core/tables/block.js +48 -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 +321 -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 +39 -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/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/propertyManager.test.js +22 -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 +5 -5
package/core/tools/trim.js
CHANGED
|
@@ -20,7 +20,7 @@ export class Trim extends Tool {
|
|
|
20
20
|
/** Create a Trim command */
|
|
21
21
|
constructor() {
|
|
22
22
|
super();
|
|
23
|
-
this.
|
|
23
|
+
this.selectedEntity = null;
|
|
24
24
|
this.selectedBoundaryItems = [];
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -49,7 +49,7 @@ export class Trim extends Tool {
|
|
|
49
49
|
if (boundary === undefined) return;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
// add all selected
|
|
52
|
+
// add all selected entities to boundary items
|
|
53
53
|
for (let i = 0; i < DesignCore.Scene.selectionManager.selectionSet.selectionSet.length; i++) {
|
|
54
54
|
const boundaryItem = DesignCore.Scene.entities.get(DesignCore.Scene.selectionManager.selectionSet.selectionSet[i]);
|
|
55
55
|
this.selectedBoundaryItems.push(boundaryItem);
|
|
@@ -59,7 +59,7 @@ export class Trim extends Tool {
|
|
|
59
59
|
while (true) {
|
|
60
60
|
const selection = await DesignCore.Scene.inputManager.requestInput(selectOp);
|
|
61
61
|
if (selection === undefined) break;
|
|
62
|
-
this.
|
|
62
|
+
this.selectedEntity = DesignCore.Scene.entities.get(selection.selectedEntityIndex);
|
|
63
63
|
DesignCore.Scene.selectionManager.removeLastSelection();
|
|
64
64
|
DesignCore.Scene.inputManager.actionCommand();
|
|
65
65
|
}
|
|
@@ -103,26 +103,26 @@ export class Trim extends Tool {
|
|
|
103
103
|
* Perform the command
|
|
104
104
|
*/
|
|
105
105
|
action() {
|
|
106
|
-
if (this.
|
|
107
|
-
if (typeof this.
|
|
108
|
-
DesignCore.Core.notify(`${this.type} - ${this.
|
|
109
|
-
this.
|
|
106
|
+
if (this.selectedEntity && this.selectedBoundaryItems.length) {
|
|
107
|
+
if (typeof this.selectedEntity.fromPolylinePoints !== 'function') {
|
|
108
|
+
DesignCore.Core.notify(`${this.type} - ${this.selectedEntity.type} ${Strings.Message.NOTRIM}`);
|
|
109
|
+
this.selectedEntity = null;
|
|
110
110
|
return;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
const intersectPoints = this.#collectIntersectPoints(this.
|
|
113
|
+
const intersectPoints = this.#collectIntersectPoints(this.selectedEntity);
|
|
114
114
|
|
|
115
115
|
if (intersectPoints.length) {
|
|
116
|
-
const stateChanges = this.#trimEntity(this.
|
|
116
|
+
const stateChanges = this.#trimEntity(this.selectedEntity, intersectPoints);
|
|
117
117
|
if (stateChanges?.length) {
|
|
118
118
|
DesignCore.Scene.commit(stateChanges);
|
|
119
119
|
}
|
|
120
120
|
} else {
|
|
121
|
-
DesignCore.Core.notify(`${this.type} - ${this.
|
|
121
|
+
DesignCore.Core.notify(`${this.type} - ${this.selectedEntity.type} ${Strings.Message.NOTRIM}`);
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
this.
|
|
125
|
+
this.selectedEntity = null;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
/**
|
|
@@ -150,7 +150,7 @@ export class Trim extends Tool {
|
|
|
150
150
|
* surrounding the mouse position. Operates entirely in polyline-point space
|
|
151
151
|
* via entity.toPolylinePoints() / entity.fromPolylinePoints(), so it works
|
|
152
152
|
* for any entity that implements that protocol (Line, Arc, Circle,
|
|
153
|
-
*
|
|
153
|
+
* PolylineBase, and future entities such as Spline or Ellipse).
|
|
154
154
|
* @param {Object} entity
|
|
155
155
|
* @param {Array} intersectPoints
|
|
156
156
|
* @return {Array}
|
|
@@ -296,10 +296,10 @@ export class Trim extends Tool {
|
|
|
296
296
|
if (fromLoc.segmentIndex === toLoc.segmentIndex) {
|
|
297
297
|
const startPoint = fromLoc.point.clone();
|
|
298
298
|
if (fromSegStart.bulge !== 0 && fromSegStart.bulge !== undefined) {
|
|
299
|
-
const
|
|
299
|
+
const centre = fromSegStart.bulgeCentrePoint(fromSegEnd);
|
|
300
300
|
const direction = fromSegStart.bulge > 0 ? 1 : -1;
|
|
301
|
-
const startAngle =
|
|
302
|
-
const endAngle =
|
|
301
|
+
const startAngle = centre.angle(fromLoc.point);
|
|
302
|
+
const endAngle = centre.angle(toLoc.point);
|
|
303
303
|
const includedAngle = ((endAngle - startAngle) * direction + 4 * Math.PI) % (2 * Math.PI);
|
|
304
304
|
startPoint.bulge = Math.tan(includedAngle / 4) * direction;
|
|
305
305
|
}
|
package/cspell.json
ADDED
|
@@ -0,0 +1,321 @@
|
|
|
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
|
+
"groupcode",
|
|
145
|
+
"groupcodes",
|
|
146
|
+
"groupvalue",
|
|
147
|
+
"handseed",
|
|
148
|
+
"HORIZONTALALIGNMENT",
|
|
149
|
+
"INSBASE",
|
|
150
|
+
"inputprompt",
|
|
151
|
+
"isopair",
|
|
152
|
+
"itemname",
|
|
153
|
+
"keypresses",
|
|
154
|
+
"lerp",
|
|
155
|
+
"LINEARDIMANGLE",
|
|
156
|
+
"linetype",
|
|
157
|
+
"linetypes",
|
|
158
|
+
"lineweight",
|
|
159
|
+
"ltscale",
|
|
160
|
+
"ltype",
|
|
161
|
+
"ltypes",
|
|
162
|
+
"lwpoly",
|
|
163
|
+
"lwpolyline",
|
|
164
|
+
"MLEADER",
|
|
165
|
+
"MLEADERSCALE",
|
|
166
|
+
"multileader",
|
|
167
|
+
"nearestsnap",
|
|
168
|
+
"midsnap",
|
|
169
|
+
"nodesnap",
|
|
170
|
+
"tangentsnap",
|
|
171
|
+
"quadrantsnap",
|
|
172
|
+
"perpendicularsnap",
|
|
173
|
+
"centresnap",
|
|
174
|
+
"NOCHAMFER",
|
|
175
|
+
"NOFILLET",
|
|
176
|
+
"NONCONSECUTIVESEGMENTS",
|
|
177
|
+
"NOREDO",
|
|
178
|
+
"NOTRIM",
|
|
179
|
+
"NOUNDO",
|
|
180
|
+
"OFFSETFROMARC",
|
|
181
|
+
"OFFSETFROMLEFT",
|
|
182
|
+
"OFFSETFROMRIGHT",
|
|
183
|
+
"Paperspace",
|
|
184
|
+
"PATTERNNAME",
|
|
185
|
+
"PLOTSTYLENAME",
|
|
186
|
+
"plottable",
|
|
187
|
+
"polarangle",
|
|
188
|
+
"polyface",
|
|
189
|
+
"postsuffix",
|
|
190
|
+
"preselection",
|
|
191
|
+
"RADIUSTOOLARGE",
|
|
192
|
+
"REFERENCELENGTH",
|
|
193
|
+
"RRGGBB",
|
|
194
|
+
"rubberbandcolour",
|
|
195
|
+
"SCALEFACTOR",
|
|
196
|
+
"selectedchild",
|
|
197
|
+
"SELECTIONSET",
|
|
198
|
+
"SEQEND",
|
|
199
|
+
"SINGLESELECTION",
|
|
200
|
+
"solidfill",
|
|
201
|
+
"standardflags",
|
|
202
|
+
"startxref",
|
|
203
|
+
"STYLENAME",
|
|
204
|
+
"TEXTALIGNMENT",
|
|
205
|
+
"TEXTORIENTATION",
|
|
206
|
+
"TEXTOVERRIDE",
|
|
207
|
+
"TEXTREVERSED",
|
|
208
|
+
"TEXTSIZE",
|
|
209
|
+
"TEXTSTYLE",
|
|
210
|
+
"THROUGHPOINT",
|
|
211
|
+
"truecolour",
|
|
212
|
+
"TRIMMODE",
|
|
213
|
+
"UCSICON",
|
|
214
|
+
"uncloseable",
|
|
215
|
+
"undrawn",
|
|
216
|
+
"UNKNOWNCOMMAND",
|
|
217
|
+
"unrecognised",
|
|
218
|
+
"VERTICALALIGNMENT",
|
|
219
|
+
"vport",
|
|
220
|
+
"WIDTHFACTOR",
|
|
221
|
+
"xgridmax",
|
|
222
|
+
"xgridmin",
|
|
223
|
+
"ygridmax",
|
|
224
|
+
"ygridmin",
|
|
225
|
+
"ZEROLENGTH",
|
|
226
|
+
"accentcolour",
|
|
227
|
+
"Alignedtext",
|
|
228
|
+
"BADINPUT",
|
|
229
|
+
"BLOCKNAME",
|
|
230
|
+
"boundingbox",
|
|
231
|
+
"BOXBLANK",
|
|
232
|
+
"BOXFILLED",
|
|
233
|
+
"BRELM",
|
|
234
|
+
"BRSTD",
|
|
235
|
+
"BRSTONE",
|
|
236
|
+
"canvasbackgroundcolour",
|
|
237
|
+
"CANNOTBEACTIONED",
|
|
238
|
+
"CANNOTBEDELETED",
|
|
239
|
+
"CANNOTBERENAMED",
|
|
240
|
+
"CHAMFERA",
|
|
241
|
+
"CHAMFERB",
|
|
242
|
+
"CHAMFERC",
|
|
243
|
+
"CHAMFERD",
|
|
244
|
+
"CHAMMODE",
|
|
245
|
+
"checkitems",
|
|
246
|
+
"CLOSEDBLANK",
|
|
247
|
+
"CONC",
|
|
248
|
+
"counterclockwise",
|
|
249
|
+
"cstyle",
|
|
250
|
+
"CSTYLEDELETE",
|
|
251
|
+
"currentstyle",
|
|
252
|
+
"DASHDOT",
|
|
253
|
+
"DATUMBLANK",
|
|
254
|
+
"DATUMFILLED",
|
|
255
|
+
"Degen",
|
|
256
|
+
"deleteblock",
|
|
257
|
+
"DOLMIT",
|
|
258
|
+
"DOTBLANK",
|
|
259
|
+
"DOTSMALL",
|
|
260
|
+
"Elec",
|
|
261
|
+
"ENDTAB",
|
|
262
|
+
"ERASESOURCE",
|
|
263
|
+
"Extline",
|
|
264
|
+
"FILEOPEN",
|
|
265
|
+
"fontbackwards",
|
|
266
|
+
"fontupsidedown",
|
|
267
|
+
"Gradians",
|
|
268
|
+
"gridcolour",
|
|
269
|
+
"gridlines",
|
|
270
|
+
"HBONE",
|
|
271
|
+
"INSUL",
|
|
272
|
+
"INVALIDBOUNDARY",
|
|
273
|
+
"INVALIDCLIPBOARD",
|
|
274
|
+
"INVALIDDXFFORMAT",
|
|
275
|
+
"INVALIDFILE",
|
|
276
|
+
"INVALIDGROUPCODE",
|
|
277
|
+
"INVALIDINTERSECTTYPE",
|
|
278
|
+
"INVALIDNUMBER",
|
|
279
|
+
"INVALIDPOINT",
|
|
280
|
+
"INVALIDTYPE",
|
|
281
|
+
"LAYERNAME",
|
|
282
|
+
"LEADERLENGTH",
|
|
283
|
+
"LWDEFAULT",
|
|
284
|
+
"MAXVALUE",
|
|
285
|
+
"midp",
|
|
286
|
+
"MINVALUE",
|
|
287
|
+
"MIRRORFIRST",
|
|
288
|
+
"MIRRORSECOND",
|
|
289
|
+
"MUDST",
|
|
290
|
+
"nendobj",
|
|
291
|
+
"NEWLENGTH",
|
|
292
|
+
"NEXTPOINT",
|
|
293
|
+
"NOEXTEND",
|
|
294
|
+
"nonexistent",
|
|
295
|
+
"NOTACOMMAND",
|
|
296
|
+
"NOTAPATTERN",
|
|
297
|
+
"NOTIMPLEMENTED",
|
|
298
|
+
"Offscreen",
|
|
299
|
+
"OFFSETDIST",
|
|
300
|
+
"PARALLELLINES",
|
|
301
|
+
"PARQ",
|
|
302
|
+
"PLAST",
|
|
303
|
+
"PLASTI",
|
|
304
|
+
"readblocks",
|
|
305
|
+
"renameitem",
|
|
306
|
+
"roundtrip",
|
|
307
|
+
"RROOF",
|
|
308
|
+
"RSHKE",
|
|
309
|
+
"SACNCR",
|
|
310
|
+
"Segs",
|
|
311
|
+
"TRIANG",
|
|
312
|
+
"underflowed",
|
|
313
|
+
"unminified",
|
|
314
|
+
"UNSUPPORTEDENTITIES",
|
|
315
|
+
"UPSIDEDOWN",
|
|
316
|
+
"Viewmode",
|
|
317
|
+
"xref",
|
|
318
|
+
"GOST",
|
|
319
|
+
"quot"
|
|
320
|
+
]
|
|
321
|
+
}
|
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();
|