@design-core/core 0.0.1 → 0.0.3
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/.eslintrc.json +14 -7
- package/.github/workflows/DesignCoreQA.yml +3 -1
- package/README.md +11 -4
- package/TODO.md +19 -0
- package/core/core/core.js +49 -42
- package/core/designCore.js +61 -2
- package/core/dimensions/alignedDimension.js +142 -0
- package/core/dimensions/angularDimension.js +550 -0
- package/core/dimensions/baseCircularDimension.js +244 -0
- package/core/dimensions/baseDimension.js +558 -0
- package/core/dimensions/baseLinearDimension.js +371 -0
- package/core/dimensions/diametricDimension.js +82 -0
- package/core/dimensions/dimension.js +298 -0
- package/core/dimensions/linearDimension.js +29 -0
- package/core/dimensions/radialDimension.js +78 -0
- package/core/dimensions/rotatedDimension.js +167 -0
- package/core/entities/arc.js +314 -60
- package/core/entities/arctext.js +642 -0
- package/core/entities/basePolyline.js +553 -94
- package/core/entities/circle.js +181 -54
- package/core/entities/entity.js +154 -74
- package/core/entities/hatch.js +807 -0
- package/core/entities/insert.js +200 -39
- package/core/entities/line.js +196 -134
- package/core/entities/lwpolyline.js +21 -44
- package/core/entities/point.js +194 -29
- package/core/entities/polyline.js +54 -7
- package/core/entities/rectangle.js +43 -13
- package/core/entities/solid.js +43 -6
- package/core/entities/text.js +324 -181
- package/core/lib/boundingBox.js +73 -13
- package/core/lib/canvas.js +256 -65
- package/core/lib/clipboard.js +198 -0
- package/core/lib/colour.js +144 -0
- package/core/lib/colours.js +367 -301
- package/core/lib/commandLine.js +16 -28
- package/core/lib/commandManager.js +115 -58
- package/core/lib/constants.js +23 -0
- package/core/lib/dxf/dxf.js +249 -34
- package/core/lib/dxf/dxfFile.js +23 -38
- package/core/lib/dxf/dxfIterator.js +17 -5
- package/core/lib/dxf/dxfRead.js +23 -7
- package/core/lib/dxf/dxfWrite.js +39 -129
- package/core/lib/dxf/handleManager.js +97 -0
- package/core/lib/dxf/sections/blocks.js +16 -2
- package/core/lib/dxf/sections/entities.js +17 -3
- package/core/lib/dxf/sections/header.js +10 -1
- package/core/lib/dxf/sections/objects.js +36 -0
- package/core/lib/dxf/sections/section.js +43 -5
- package/core/lib/dxf/sections/tables.js +17 -3
- package/core/lib/entityManager.js +178 -0
- package/core/lib/fileio.js +14 -4
- package/core/lib/headers.js +229 -0
- package/core/lib/input.js +46 -0
- package/core/lib/inputManager.js +199 -194
- package/core/lib/intersect.js +341 -468
- package/core/lib/logging.js +25 -1
- package/core/lib/matrix.js +6 -8
- package/core/lib/mouse.js +24 -79
- package/core/lib/patterns.js +690 -0
- package/core/lib/promptOptions.js +133 -0
- package/core/lib/scene.js +71 -174
- package/core/lib/selectionManager.js +74 -48
- package/core/lib/selectionWindow.js +24 -10
- package/core/lib/settings.js +18 -11
- package/core/lib/snapping.js +129 -21
- package/core/lib/stateManager.js +288 -0
- package/core/lib/strings.js +57 -5
- package/core/lib/utils.js +95 -11
- package/core/objects/dictionary.js +43 -0
- package/core/objects/dictionaryManager.js +80 -0
- package/core/properties/dimType.js +117 -0
- package/core/properties/flags.js +66 -0
- package/core/properties/property.js +26 -0
- package/core/properties/propertyManager.js +65 -19
- package/core/tables/appId.js +31 -0
- package/core/tables/appIdManager.js +44 -0
- package/core/tables/block.js +323 -0
- package/core/tables/blockManager.js +48 -0
- package/core/tables/blockRecord.js +29 -0
- package/core/tables/blockRecordManager.js +37 -0
- package/core/tables/dimStyle.js +627 -0
- package/core/tables/dimStyleManager.js +187 -0
- package/core/tables/endblk.js +28 -0
- package/core/tables/layer.js +219 -0
- package/core/tables/layerManager.js +47 -0
- package/core/tables/ltype.js +85 -0
- package/core/tables/ltypeManager.js +65 -0
- package/core/tables/style.js +145 -0
- package/core/tables/styleManager.js +55 -0
- package/core/tables/styleManagerBase.js +110 -0
- package/core/tables/tableManagerBase.js +354 -0
- package/core/tables/ucs.js +28 -0
- package/core/tables/ucsManager.js +44 -0
- package/core/tables/view.js +28 -0
- package/core/tables/viewManager.js +44 -0
- package/core/tables/vport.js +70 -0
- package/core/tables/vportManager.js +65 -0
- package/core/tools/chamfer.js +343 -0
- package/core/tools/chamferFilletBase.js +162 -0
- package/core/tools/copy.js +68 -40
- package/core/tools/copybase.js +65 -0
- package/core/tools/copyclip.js +59 -0
- package/core/tools/cornerEntity.js +138 -0
- package/core/tools/cutclip.js +72 -0
- package/core/tools/distance.js +37 -9
- package/core/tools/erase.js +43 -13
- package/core/tools/explode.js +117 -0
- package/core/tools/extend.js +71 -32
- package/core/tools/fillet.js +336 -0
- package/core/tools/identify.js +33 -6
- package/core/tools/matchProp.js +106 -0
- package/core/tools/mirror.js +141 -0
- package/core/tools/move.js +65 -32
- package/core/tools/offset.js +321 -0
- package/core/tools/pan.js +54 -0
- package/core/tools/pasteclip.js +93 -0
- package/core/tools/purge.js +90 -0
- package/core/tools/rotate.js +105 -70
- package/core/tools/scale.js +166 -0
- package/core/tools/tool.js +14 -4
- package/core/tools/trim.js +71 -32
- package/core/tools/zoom.js +152 -0
- package/package.json +3 -305
- package/test/dimensions/alignedDimension.test.js +211 -0
- package/test/dimensions/angularDimension.test.js +243 -0
- package/test/dimensions/baseDimension.test.js +239 -0
- package/test/dimensions/diametricDimension.test.js +203 -0
- package/test/dimensions/dimension.test.js +102 -0
- package/test/dimensions/radialDimension.test.js +203 -0
- package/test/dimensions/rotatedDimension.test.js +224 -0
- package/test/entities/arc.test.js +463 -41
- package/test/entities/arctext.test.js +329 -0
- package/test/entities/basePolyline.test.js +459 -10
- package/test/entities/circle.test.js +312 -7
- package/test/entities/entity.test.js +28 -9
- package/test/entities/hatch.test.js +606 -0
- package/test/entities/insert.test.js +90 -0
- package/test/entities/line.test.js +182 -6
- package/test/entities/point.test.js +375 -37
- package/test/entities/solid.test.js +156 -0
- package/test/entities/text.test.js +533 -7
- package/test/integration/exportIntegration.reference.dxf +1706 -0
- package/test/integration/exportIntegration.test.js +186 -0
- package/test/integration/importExportIntegration.test.js +126 -0
- package/test/integration/intersectionIntegration.test.js +880 -0
- package/test/integration/userInputIntegration.reference.dxf +1410 -0
- package/test/integration/userInputIntegration.test.js +269 -0
- package/test/lib/boundingBox.test.js +26 -2
- package/test/lib/canvas.test.js +613 -5
- package/test/lib/clipboard.test.js +70 -0
- package/test/lib/colour.test.js +114 -0
- package/test/lib/colours.test.js +63 -18
- package/test/lib/commandLine.test.js +159 -22
- package/test/lib/commandManager.test.js +4 -4
- package/test/lib/constants.test.js +9 -0
- package/test/lib/dxf/dxfFile.test.js +6 -2
- package/test/lib/dxf/dxfIterator.test.js +1 -1
- package/test/lib/dxf/dxfWrite.test.js +173 -0
- package/test/lib/dxf/handleManager.test.js +137 -0
- package/test/lib/dxf/sections/blocks.test.js +5 -5
- package/test/lib/dxf/sections/entities.test.js +4 -4
- package/test/lib/dxf/sections/header.test.js +18 -4
- package/test/lib/dxf/sections/objects.test.js +132 -0
- package/test/lib/dxf/sections/section.test.js +29 -29
- package/test/lib/dxf/sections/tables.test.js +3 -3
- package/test/lib/entityManager.test.js +163 -0
- package/test/lib/headers.test.js +233 -0
- package/test/lib/inputManager.test.js +1144 -5
- package/test/lib/intersect.test.js +454 -331
- package/test/lib/logging.test.js +1 -1
- package/test/lib/matrix.test.js +1 -1
- package/test/lib/mouse.test.js +327 -4
- package/test/lib/patterns.test.js +105 -0
- package/test/lib/promptOptions.test.js +179 -0
- package/test/lib/scene.test.js +16 -52
- package/test/lib/selectionManager.test.js +17 -5
- package/test/lib/settings.test.js +111 -5
- package/test/lib/snapping.test.js +142 -4
- package/test/lib/stateManager.test.js +155 -0
- package/test/lib/utils.test.js +81 -1
- package/test/objects/dictionary.test.js +81 -0
- package/test/objects/dictionaryManager.test.js +34 -0
- package/test/properties/dimType.test.js +62 -0
- package/test/properties/flags.test.js +164 -0
- package/test/properties/property.test.js +13 -0
- package/test/properties/propertyManager.test.js +10 -11
- package/test/tables/appId.test.js +46 -0
- package/test/tables/appIdManager.test.js +72 -0
- package/test/tables/block.test.js +157 -0
- package/test/tables/blockManager.test.js +52 -0
- package/test/tables/blockRecord.test.js +39 -0
- package/test/tables/blockRecordManager.test.js +60 -0
- package/test/tables/dimstyle.test.js +72 -0
- package/test/tables/endblk.test.js +30 -0
- package/test/tables/layer.test.js +95 -0
- package/test/tables/layerManager.test.js +172 -0
- package/test/{styles → tables}/ltype.test.js +7 -7
- package/test/{styles → tables}/ltypeManager.test.js +2 -2
- package/test/tables/style.test.js +44 -0
- package/test/tables/stylemanagerbase.test.js +220 -0
- package/test/tables/tableManagerBase.test.js +194 -0
- package/test/tables/ucs.test.js +37 -0
- package/test/tables/ucsManager.test.js +48 -0
- package/test/tables/view.test.js +37 -0
- package/test/tables/viewManager.test.js +48 -0
- package/test/tables/vport.test.js +117 -0
- package/test/tables/vportManager.test.js +54 -0
- package/test/test-helpers/test-helpers.js +66 -0
- package/test/tools/chamfer.test.js +970 -0
- package/test/tools/chamferFilletBase.test.js +446 -0
- package/test/tools/copy.test.js +22 -14
- package/test/tools/copybase.test.js +93 -0
- package/test/tools/copyclip.test.js +92 -0
- package/test/tools/cornerEntity.test.js +201 -0
- package/test/tools/cutclip.test.js +94 -0
- package/test/tools/distance.test.js +140 -18
- package/test/tools/erase.test.js +12 -12
- package/test/tools/explode.test.js +45 -0
- package/test/tools/extend.test.js +326 -44
- package/test/tools/fillet.test.js +831 -0
- package/test/tools/identify.test.js +115 -16
- package/test/tools/matchProp.test.js +84 -0
- package/test/tools/mirror.test.js +475 -0
- package/test/tools/move.test.js +75 -19
- package/test/tools/offset.test.js +748 -0
- package/test/tools/pan.test.js +72 -0
- package/test/tools/pasteclip.test.js +100 -0
- package/test/tools/purge.test.js +89 -0
- package/test/tools/rotate.test.js +89 -23
- package/test/tools/scale.test.js +529 -0
- package/test/tools/trim.test.js +419 -84
- package/test/tools/zoom.test.js +504 -0
- package/core/entities/alignedDimension.js +0 -279
- package/core/entities/angularDimension.js +0 -194
- package/core/entities/baseDimension.js +0 -227
- package/core/entities/block.js +0 -247
- package/core/entities/diametricDimension.js +0 -133
- package/core/entities/dimension.js +0 -202
- package/core/entities/radialDimension.js +0 -126
- package/core/styles/dimStyle.js +0 -719
- package/core/styles/dimStyleManager.js +0 -47
- package/core/styles/layer.js +0 -133
- package/core/styles/layerManager.js +0 -40
- package/core/styles/ltype.js +0 -86
- package/core/styles/ltypeManager.js +0 -50
- package/core/styles/style.js +0 -158
- package/core/styles/styleManager.js +0 -43
- package/core/styles/styleManagerBase.js +0 -299
- package/test/entities/block.test.js +0 -22
- package/test/styles/dimstyle.test.js +0 -19
- package/test/styles/layerManager.test.js +0 -150
- package/test/styles/style.test.js +0 -33
- package/test/styles/stylemanagerbase.test.js +0 -219
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import {Utils} from '../lib/utils.js';
|
|
3
|
-
import {Strings} from '../lib/strings.js';
|
|
4
|
-
import {Line} from './line.js';
|
|
5
|
-
import {Input, PromptOptions} from '../lib/inputManager.js';
|
|
6
|
-
import {Logging} from '../lib/logging.js';
|
|
7
|
-
import {DXFFile} from '../lib/dxf/dxfFile.js';
|
|
8
|
-
import {BaseDimension} from './baseDimension.js';
|
|
9
|
-
import {Point} from './point.js';
|
|
10
|
-
|
|
11
|
-
import {DesignCore} from '../designCore.js';
|
|
12
|
-
|
|
13
|
-
export class AlignedDimension extends BaseDimension {
|
|
14
|
-
constructor(data) {
|
|
15
|
-
super(data);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
static register() {
|
|
19
|
-
const command = {command: 'AlignedDimension', shortcut: 'DIMALIGNED'};
|
|
20
|
-
return command;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async execute() {
|
|
24
|
-
try {
|
|
25
|
-
const op = new PromptOptions(Strings.Input.START, [Input.Type.POINT]);
|
|
26
|
-
const pt13 = await DesignCore.Scene.inputManager.requestInput(op);
|
|
27
|
-
pt13.sequence = 13;
|
|
28
|
-
this.points.push(pt13);
|
|
29
|
-
|
|
30
|
-
const op1 = new PromptOptions(Strings.Input.END, [Input.Type.POINT]);
|
|
31
|
-
const pt14 = await DesignCore.Scene.inputManager.requestInput(op1);
|
|
32
|
-
pt14.sequence = 14;
|
|
33
|
-
this.points.push(pt14);
|
|
34
|
-
|
|
35
|
-
const op2 = new PromptOptions(Strings.Input.END, [Input.Type.POINT]);
|
|
36
|
-
const pt11 = await DesignCore.Scene.inputManager.requestInput(op2);
|
|
37
|
-
pt11.sequence = 11;
|
|
38
|
-
this.points.push(pt11);
|
|
39
|
-
|
|
40
|
-
DesignCore.Scene.inputManager.executeCommand(this);
|
|
41
|
-
} catch (err) {
|
|
42
|
-
Logging.instance.error(`${this.type} - ${err}`);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
preview() {
|
|
47
|
-
if (this.points.length == 1) {
|
|
48
|
-
const mousePoint = DesignCore.Mouse.pointOnScene();
|
|
49
|
-
const points = [this.points.at(0), mousePoint];
|
|
50
|
-
DesignCore.Scene.createTempItem('Line', {points: points});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (this.points.length > 1) {
|
|
54
|
-
const mousePoint = DesignCore.Mouse.pointOnScene();
|
|
55
|
-
mousePoint.sequence = 11;
|
|
56
|
-
const points = [...this.points, mousePoint];
|
|
57
|
-
DesignCore.Scene.createTempItem(this.type, {points: points});
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
static getPointsFromSelection(items) {
|
|
62
|
-
const points = [];
|
|
63
|
-
const item = items[0];
|
|
64
|
-
|
|
65
|
-
const pt13 = item.points[0];
|
|
66
|
-
pt13.sequence = 13;
|
|
67
|
-
points.push(pt13);
|
|
68
|
-
|
|
69
|
-
const pt14 = item.points[1];
|
|
70
|
-
pt14.sequence = 14;
|
|
71
|
-
points.push(pt14);
|
|
72
|
-
|
|
73
|
-
return points;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
buildDimension(style) {
|
|
77
|
-
const Pt1 = this.getPointBySequence(13);
|
|
78
|
-
const Pt2 = this.getPointBySequence(14);
|
|
79
|
-
const Pt3 = this.getPointBySequence(11);
|
|
80
|
-
|
|
81
|
-
let dimension = 0;
|
|
82
|
-
const entities = [];
|
|
83
|
-
|
|
84
|
-
// invalid points
|
|
85
|
-
if (Pt1.isSame(Pt2) || Pt1.isSame(Pt3) || Pt2.isSame(Pt3)) {
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// extension points
|
|
90
|
-
let P1e = new Point();
|
|
91
|
-
let P2e = new Point();
|
|
92
|
-
let P3e = new Point();
|
|
93
|
-
|
|
94
|
-
const pntPerp = Pt3.closestPointOnLine(Pt1, Pt2);
|
|
95
|
-
|
|
96
|
-
if (pntPerp !== null) {
|
|
97
|
-
const projectionAngle = pntPerp.angle(Pt3);
|
|
98
|
-
const distance = Pt3.distance(pntPerp);
|
|
99
|
-
P1e = Pt1.project(projectionAngle, distance);
|
|
100
|
-
P2e = Pt2.project(projectionAngle, distance);
|
|
101
|
-
dimension = Pt1.distance(Pt2);
|
|
102
|
-
} else {
|
|
103
|
-
const dx = Pt2.x - Pt1.x;
|
|
104
|
-
const dy = Pt2.y - Pt1.y;
|
|
105
|
-
|
|
106
|
-
const iX = ((Math.abs(Pt3.x - Pt1.x) + Math.abs(Pt2.x - Pt3.x)) - Math.abs(dx));
|
|
107
|
-
const iY = ((Math.abs(Pt3.y - Pt1.y) + Math.abs(Pt2.y - Pt3.y)) - Math.abs(dy));
|
|
108
|
-
|
|
109
|
-
if (iX >= iY && dy !== 0) {
|
|
110
|
-
P1e.x = Pt3.x;
|
|
111
|
-
P1e.y = Pt1.y;
|
|
112
|
-
P2e.x = Pt3.x;
|
|
113
|
-
P2e.y = Pt2.y;
|
|
114
|
-
dimension = dy;
|
|
115
|
-
} else if (iX < iY && dx !== 0) {
|
|
116
|
-
P1e.x = Pt1.x;
|
|
117
|
-
P1e.y = Pt3.y;
|
|
118
|
-
P2e.x = Pt2.x;
|
|
119
|
-
P2e.y = Pt3.y;
|
|
120
|
-
dimension = dx;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const dimAngle = P1e.angle(P2e);
|
|
126
|
-
const projectAngle = Pt1.angle(P1e);
|
|
127
|
-
|
|
128
|
-
// Text
|
|
129
|
-
const midPoint = P1e.midPoint(P2e);
|
|
130
|
-
P3e = midPoint.project(projectAngle, style.getValue('DIMGAP')); // Offset text from baseline
|
|
131
|
-
this.text.points = [P3e];
|
|
132
|
-
this.text.setRotation(dimAngle);
|
|
133
|
-
this.text.height = style.getValue('DIMTXT');
|
|
134
|
-
|
|
135
|
-
let horizontalAlignment = 0;
|
|
136
|
-
switch (style.getValue('DIMJUST')) {
|
|
137
|
-
case 0:
|
|
138
|
-
// 0 = Above dimension line and center-justified between extension lines
|
|
139
|
-
horizontalAlignment = 1;
|
|
140
|
-
break;
|
|
141
|
-
case 1:
|
|
142
|
-
// 1 = Above dimension line and next to first extension line
|
|
143
|
-
break;
|
|
144
|
-
case 2:
|
|
145
|
-
// 2 = Above dimension line and next to second extension line
|
|
146
|
-
break;
|
|
147
|
-
case 3:
|
|
148
|
-
// 3 = Above and center-justified to first extension line
|
|
149
|
-
break;
|
|
150
|
-
case 4:
|
|
151
|
-
// 4 = Above and center-justified to second extension line
|
|
152
|
-
break;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// 0 = Left; 1= Center; 2 = Right
|
|
156
|
-
// 3 = Aligned (if vertical alignment = 0)
|
|
157
|
-
// 4 = Middle (if vertical alignment = 0)
|
|
158
|
-
// 5 = Fit (if vertical alignment = 0)
|
|
159
|
-
|
|
160
|
-
this.text.horizontalAlignment = horizontalAlignment;
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
let verticalAlignment = 1;
|
|
164
|
-
switch (style.getValue('DIMTAD')) {
|
|
165
|
-
case 0:
|
|
166
|
-
// 0 = Centers the dimension text between the extension lines.
|
|
167
|
-
verticalAlignment = 1;
|
|
168
|
-
break;
|
|
169
|
-
case 1:
|
|
170
|
-
// 1 = Places the dimension text above the dimension line except when the dimension line is not horizontal and text inside the extension lines is forced horizontal ( DIMTIH = 1).
|
|
171
|
-
// The distance from the dimension line to the baseline of the lowest line of text is the current DIMGAP value.
|
|
172
|
-
verticalAlignment = 2;
|
|
173
|
-
break;
|
|
174
|
-
case 2:
|
|
175
|
-
// 2 = Places the dimension text on the side of the dimension line farthest away from the defining points.
|
|
176
|
-
break;
|
|
177
|
-
case 3:
|
|
178
|
-
// 3 = Places the dimension text to conform to Japanese Industrial Standards (JIS).
|
|
179
|
-
break;
|
|
180
|
-
case 4:
|
|
181
|
-
// 4 = Places the dimension text below the dimension line.
|
|
182
|
-
break;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// 0 = Baseline; 1 = Bottom; 2 = Middle; 3 = Top
|
|
186
|
-
this.text.verticalAlignment = verticalAlignment;
|
|
187
|
-
|
|
188
|
-
if (typeof(dimension) === 'number') {
|
|
189
|
-
this.text.string = Math.abs(dimension.toFixed(2)).toString(); // TODO: Honor the precision from the style
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
if (typeof(dimAngle) === 'number') {
|
|
193
|
-
const angle = Utils.radians2degrees(dimAngle);
|
|
194
|
-
this.text.rotation = angle; // TODO: Honor the style
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
// get style properties
|
|
199
|
-
const extension = style.getValue('DIMEXE');
|
|
200
|
-
const offset = style.getValue('DIMEXO');
|
|
201
|
-
const arrowsize = style.getValue('DIMASZ');
|
|
202
|
-
|
|
203
|
-
// generate dimension points
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
const extLineOneStart = Pt1.project(projectAngle, offset);
|
|
207
|
-
const extLineTwoStart = Pt2.project(projectAngle, offset);
|
|
208
|
-
|
|
209
|
-
const extLineOneEnd = P1e.project(projectAngle, extension);
|
|
210
|
-
const extLineTwoEnd = P2e.project(projectAngle, extension);
|
|
211
|
-
|
|
212
|
-
const dimLineOneStart = P1e;
|
|
213
|
-
const dimLineTwoStart = P2e;
|
|
214
|
-
|
|
215
|
-
const dimLineOneEnd = midPoint;
|
|
216
|
-
const dimLineTwoEnd = midPoint;
|
|
217
|
-
|
|
218
|
-
// generate dimension geometry
|
|
219
|
-
const extLine1 = new Line({points: [extLineOneStart, extLineOneEnd]});
|
|
220
|
-
// Supress extension line 1 if DIMS1 is true
|
|
221
|
-
if (!style.getValue('DIMSE1')) {
|
|
222
|
-
entities.push(extLine1);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
const extLine2 = new Line({points: [extLineTwoStart, extLineTwoEnd]});
|
|
226
|
-
// Supress extendsion line 2 if DIMSE2 is true
|
|
227
|
-
if (!style.getValue('DIMSE2')) {
|
|
228
|
-
entities.push(extLine2);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
const dimLine1 = new Line({points: [dimLineOneStart, dimLineOneEnd]});
|
|
232
|
-
// Supress dimension line 1 if DIMSD1 is true
|
|
233
|
-
if (!style.getValue('DIMSD1')) {
|
|
234
|
-
entities.push(dimLine1);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
const dimLine2 = new Line({points: [dimLineTwoStart, dimLineTwoEnd]});
|
|
238
|
-
// Supress dimension line 2 if DIMSD2 is true
|
|
239
|
-
if (!style.getValue('DIMSD2')) {
|
|
240
|
-
entities.push(dimLine2);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
const arrowHead1 = this.getArrowHead(P1e, P1e.angle(P2e), arrowsize);
|
|
244
|
-
const arrowHead2 = this.getArrowHead(P2e, P2e.angle(P1e), arrowsize);
|
|
245
|
-
|
|
246
|
-
entities.push(arrowHead1, arrowHead2);
|
|
247
|
-
|
|
248
|
-
return entities;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
dxf(file) {
|
|
252
|
-
const Pt10 = this.getPointBySequence(10);
|
|
253
|
-
const Pt11 = this.text.points[0];
|
|
254
|
-
const Pt13 = this.getPointBySequence(13);
|
|
255
|
-
const Pt14 = this.getPointBySequence(14);
|
|
256
|
-
|
|
257
|
-
file.writeGroupCode('0', 'DIMENSION');
|
|
258
|
-
file.writeGroupCode('5', file.nextHandle(), DXFFile.Version.R2000); // Handle
|
|
259
|
-
file.writeGroupCode('100', 'AcDbEntity', DXFFile.Version.R2000);
|
|
260
|
-
file.writeGroupCode('100', 'AcDbDimension', DXFFile.Version.R2000);
|
|
261
|
-
file.writeGroupCode('8', this.layer);
|
|
262
|
-
// file.writeGroupCode('2', this.blockName); // Block not required
|
|
263
|
-
file.writeGroupCode('10', Pt10.x); // X - definition / arrow point
|
|
264
|
-
file.writeGroupCode('20', Pt10.y); // Y
|
|
265
|
-
file.writeGroupCode('30', '0.0'); // Z
|
|
266
|
-
file.writeGroupCode('11', Pt11.x); // X - text midpoint
|
|
267
|
-
file.writeGroupCode('21', Pt11.y); // Y
|
|
268
|
-
file.writeGroupCode('31', '0.0'); // Z
|
|
269
|
-
file.writeGroupCode('70', 1); // DIMENSION TYPE 0 = rotated, 1 = aligned
|
|
270
|
-
file.writeGroupCode('3', 'STANDARD'); // DIMENSION STYLE
|
|
271
|
-
file.writeGroupCode('100', 'AcDbAlignedDimension', DXFFile.Version.R2000);
|
|
272
|
-
file.writeGroupCode('13', Pt13.x); // X - start point of first extension line
|
|
273
|
-
file.writeGroupCode('23', Pt13.y); // Y
|
|
274
|
-
file.writeGroupCode('33', '0.0'); // Z
|
|
275
|
-
file.writeGroupCode('14', Pt14.x); // X - start point of second extension line
|
|
276
|
-
file.writeGroupCode('24', Pt14.y); // Y
|
|
277
|
-
file.writeGroupCode('34', '0.0'); // Z
|
|
278
|
-
}
|
|
279
|
-
}
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import {Utils} from '../lib/utils.js';
|
|
3
|
-
import {Strings} from '../lib/strings.js';
|
|
4
|
-
import {Arc} from './arc.js';
|
|
5
|
-
import {Line} from './line.js';
|
|
6
|
-
import {Input, PromptOptions} from '../lib/inputManager.js';
|
|
7
|
-
import {Logging} from '../lib/logging.js';
|
|
8
|
-
import {DXFFile} from '../lib/dxf/dxfFile.js';
|
|
9
|
-
import {BaseDimension} from './baseDimension.js';
|
|
10
|
-
import {Intersection} from '../lib/intersect.js';
|
|
11
|
-
|
|
12
|
-
import {DesignCore} from '../designCore.js';
|
|
13
|
-
|
|
14
|
-
export class AngularDimension extends BaseDimension {
|
|
15
|
-
constructor(data) {
|
|
16
|
-
super(data);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
static register() {
|
|
20
|
-
const command = {command: 'AngularDimension', shortcut: 'DIMANG'};
|
|
21
|
-
return command;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
async execute() {
|
|
25
|
-
try {
|
|
26
|
-
const op = new PromptOptions(Strings.Input.SELECT, [Input.Type.SINGLESELECTION]);
|
|
27
|
-
|
|
28
|
-
if (!DesignCore.Scene.selectionManager.selectionSet.selectionSet.length) {
|
|
29
|
-
const selection = await DesignCore.Scene.inputManager.requestInput(op);
|
|
30
|
-
|
|
31
|
-
const line1 = DesignCore.Scene.getItem(selection.selectedItemIndex);
|
|
32
|
-
|
|
33
|
-
const pt15 = line1.points[0];
|
|
34
|
-
pt15.sequence = 15;
|
|
35
|
-
this.points.push(pt15);
|
|
36
|
-
|
|
37
|
-
const pt10 = line1.points[1];
|
|
38
|
-
pt10.sequence = 10;
|
|
39
|
-
this.points.push(pt10);
|
|
40
|
-
|
|
41
|
-
DesignCore.Scene.selectionManager.reset();
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const op1 = new PromptOptions(Strings.Input.SELECT, [Input.Type.SINGLESELECTION]);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (!DesignCore.Scene.selectionManager.selectionSet.selectionSet.length) {
|
|
48
|
-
const selection2 = await DesignCore.Scene.inputManager.requestInput(op1);
|
|
49
|
-
|
|
50
|
-
const line2 = DesignCore.Scene.getItem(selection2.selectedItemIndex);
|
|
51
|
-
|
|
52
|
-
const pt13 = line2.points[0];
|
|
53
|
-
pt13.sequence = 13;
|
|
54
|
-
this.points.push(pt13);
|
|
55
|
-
|
|
56
|
-
const pt14 = line2.points[1];
|
|
57
|
-
pt14.sequence = 14;
|
|
58
|
-
this.points.push(pt14);
|
|
59
|
-
|
|
60
|
-
DesignCore.Scene.selectionManager.reset();
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const op2 = new PromptOptions(Strings.Input.START, [Input.Type.POINT]);
|
|
64
|
-
const pt11 = await DesignCore.Scene.inputManager.requestInput(op2);
|
|
65
|
-
pt11.sequence = 11;
|
|
66
|
-
this.points.push(pt11);
|
|
67
|
-
|
|
68
|
-
const pt15 = this.points.find((point) => point === 15);
|
|
69
|
-
const pt10 = this.getPointBySequence(10);
|
|
70
|
-
|
|
71
|
-
const pt16 = pt11.perpendicular(pt15, pt10);
|
|
72
|
-
pt16.sequence = 16;
|
|
73
|
-
this.points.push(pt16);
|
|
74
|
-
|
|
75
|
-
DesignCore.Scene.inputManager.executeCommand(this);
|
|
76
|
-
} catch (err) {
|
|
77
|
-
Logging.instance.error(`${this.type} - ${err}`);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
preview() {
|
|
82
|
-
if (this.points.length >= 4) {
|
|
83
|
-
const mousePoint = DesignCore.Mouse.pointOnScene();
|
|
84
|
-
mousePoint.sequence = 11;
|
|
85
|
-
|
|
86
|
-
const pt15 = this.getPointBySequence(15);
|
|
87
|
-
const pt10 = this.getPointBySequence(10);
|
|
88
|
-
|
|
89
|
-
const pt16 = mousePoint.perpendicular(pt15, pt10);
|
|
90
|
-
pt16.sequence = 16;
|
|
91
|
-
|
|
92
|
-
const points = [...this.points, mousePoint, pt16];
|
|
93
|
-
DesignCore.Scene.createTempItem(this.type, {points: points});
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
static getPointsFromSelection(items) {
|
|
98
|
-
const points = [];
|
|
99
|
-
|
|
100
|
-
const item1= items[0];
|
|
101
|
-
const item2 = items[1];
|
|
102
|
-
|
|
103
|
-
const pt15 = item1.points[0];
|
|
104
|
-
pt15.sequence = 15;
|
|
105
|
-
points.push(pt15);
|
|
106
|
-
|
|
107
|
-
const pt10 = item1.points[1];
|
|
108
|
-
pt10.sequence = 10;
|
|
109
|
-
points.push(pt10);
|
|
110
|
-
|
|
111
|
-
const pt13 = item2.points[0];
|
|
112
|
-
pt13.sequence = 13;
|
|
113
|
-
points.push(pt13);
|
|
114
|
-
|
|
115
|
-
const pt14 = item2.points[1];
|
|
116
|
-
pt14.sequence = 14;
|
|
117
|
-
points.push(pt14);
|
|
118
|
-
|
|
119
|
-
return points;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
buildDimension(style) {
|
|
123
|
-
// Angular
|
|
124
|
-
let dimension = 0;
|
|
125
|
-
const entities = [];
|
|
126
|
-
|
|
127
|
-
const Pt1 = this.getPointBySequence(15);
|
|
128
|
-
const Pt2 = this.getPointBySequence(10);
|
|
129
|
-
const Pt3 = this.getPointBySequence(13);
|
|
130
|
-
const Pt4 = this.getPointBySequence(14);
|
|
131
|
-
const Pt5 = this.getPointBySequence(11); // 16); // should be point 16 changed to debug
|
|
132
|
-
const Pt6 = this.getPointBySequence(11);
|
|
133
|
-
|
|
134
|
-
const line1 = new Line({points: [Pt1, Pt2]});
|
|
135
|
-
const line2 = new Line({points: [Pt3, Pt4]});
|
|
136
|
-
const arrow1pos = Pt5.perpendicular(Pt1, Pt2);
|
|
137
|
-
const arrow2pos = Pt5.perpendicular(Pt3, Pt4);
|
|
138
|
-
const arrowHead1 = this.getArrowHead(arrow1pos, Pt1.angle(Pt2) + 1.5708, this.text.height / 2);
|
|
139
|
-
const arrowHead2 = this.getArrowHead(arrow2pos, Pt3.angle(Pt4) + 1.5708, this.text.height / 2);
|
|
140
|
-
|
|
141
|
-
const intersect = Intersection.intersectLineLine({start: Pt1, end: Pt2}, {start: Pt3, end: Pt4}, true);
|
|
142
|
-
const arc = new Arc({points: [intersect.points[0], arrow1pos, arrow2pos]});
|
|
143
|
-
|
|
144
|
-
entities.push(line1, line2, arrowHead1, arrowHead2, arc);
|
|
145
|
-
|
|
146
|
-
this.text.points = [Pt6];
|
|
147
|
-
// this.text.setRotation(Pt1.angle(Pt2));
|
|
148
|
-
const angle = Utils.radians2degrees(Pt1.angle(Pt2));
|
|
149
|
-
this.text.rotation = angle;
|
|
150
|
-
const line1Angle = Pt1.angle(Pt2);
|
|
151
|
-
const line2Angle = Pt3.angle(Pt4);
|
|
152
|
-
dimension = Utils.radians2degrees(line1Angle - line2Angle);
|
|
153
|
-
this.text.string = `${Math.abs(dimension.toFixed(2)).toString()}${Strings.Symbol.DEGREE}`;
|
|
154
|
-
|
|
155
|
-
return entities;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
dxf(file) {
|
|
159
|
-
const Pt10 = this.getPointBySequence(10);
|
|
160
|
-
const Pt11 = this.text.points[0];
|
|
161
|
-
const Pt13 = this.getPointBySequence(13);
|
|
162
|
-
const Pt14 = this.getPointBySequence(14);
|
|
163
|
-
const Pt15 = this.getPointBySequence(15);
|
|
164
|
-
const Pt16 = Pt11; // this.getPointBySequence(16);
|
|
165
|
-
|
|
166
|
-
file.writeGroupCode('0', 'DIMENSION');
|
|
167
|
-
file.writeGroupCode('5', file.nextHandle(), DXFFile.Version.R2000); // Handle
|
|
168
|
-
file.writeGroupCode('100', 'AcDbEntity', DXFFile.Version.R2000);
|
|
169
|
-
file.writeGroupCode('100', 'AcDbDimension', DXFFile.Version.R2000);
|
|
170
|
-
file.writeGroupCode('8', this.layer);
|
|
171
|
-
// file.writeGroupCode('2', this.blockName); // Block not required
|
|
172
|
-
file.writeGroupCode('10', Pt10.x); // X - Start of Dimension Line
|
|
173
|
-
file.writeGroupCode('20', Pt10.y); // Y
|
|
174
|
-
file.writeGroupCode('30', '0.0'); // Z
|
|
175
|
-
file.writeGroupCode('11', Pt11.x); // X - Text Midpoint
|
|
176
|
-
file.writeGroupCode('21', Pt11.y); // Y
|
|
177
|
-
file.writeGroupCode('31', '0.0'); // Z
|
|
178
|
-
file.writeGroupCode('70', this.dimType); // DIMENSION TYPE
|
|
179
|
-
file.writeGroupCode('3', 'STANDARD'); // DIMENSION STYLE
|
|
180
|
-
file.writeGroupCode('100', 'AcDb2LineAngularDimension', DXFFile.Version.R2000);
|
|
181
|
-
file.writeGroupCode('13', Pt13.x); // X
|
|
182
|
-
file.writeGroupCode('23', Pt13.y); // Y
|
|
183
|
-
file.writeGroupCode('33', '0.0'); // Z
|
|
184
|
-
file.writeGroupCode('14', Pt14.x); // X
|
|
185
|
-
file.writeGroupCode('24', Pt14.y); // Y
|
|
186
|
-
file.writeGroupCode('34', '0.0'); // Z
|
|
187
|
-
file.writeGroupCode('15', Pt15.x); // X
|
|
188
|
-
file.writeGroupCode('25', Pt15.y); // Y
|
|
189
|
-
file.writeGroupCode('35', '0.0'); // Z
|
|
190
|
-
file.writeGroupCode('16', Pt16.x); // X
|
|
191
|
-
file.writeGroupCode('26', Pt16.y); // Y
|
|
192
|
-
file.writeGroupCode('36', '0.0'); // Z
|
|
193
|
-
}
|
|
194
|
-
}
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import {Point} from './point.js';
|
|
2
|
-
import {Block} from './block.js';
|
|
3
|
-
import {Text} from './text.js';
|
|
4
|
-
import {Solid} from './solid.js';
|
|
5
|
-
import {Entity} from './entity.js';
|
|
6
|
-
import {Logging} from '../lib/logging.js';
|
|
7
|
-
|
|
8
|
-
import {DesignCore} from '../designCore.js';
|
|
9
|
-
|
|
10
|
-
export class BaseDimension extends Entity {
|
|
11
|
-
constructor(data) {
|
|
12
|
-
super(data);
|
|
13
|
-
|
|
14
|
-
Object.defineProperty(this, 'blockName', {
|
|
15
|
-
value: '',
|
|
16
|
-
writable: true,
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
Object.defineProperty(this, 'block', {
|
|
20
|
-
value: new Block({points: [new Point(), new Point()]}),
|
|
21
|
-
writable: true,
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
Object.defineProperty(this, 'text', {
|
|
25
|
-
value: new Text(),
|
|
26
|
-
writable: true,
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
Object.defineProperty(this, 'dimType', {
|
|
30
|
-
value: 0,
|
|
31
|
-
writable: true,
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
Object.defineProperty(this, 'styleName', {
|
|
35
|
-
value: 'STANDARD',
|
|
36
|
-
writable: true,
|
|
37
|
-
enumerable: true,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
Object.defineProperty(this, 'leaderLength', {
|
|
41
|
-
value: 0,
|
|
42
|
-
writable: true,
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
Object.defineProperty(this, 'linearDimAngle', {
|
|
46
|
-
value: 0,
|
|
47
|
-
writable: true,
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
if (data) {
|
|
51
|
-
if (data[1]) {
|
|
52
|
-
// DXF Groupcode 1 - Dimension text
|
|
53
|
-
// The string explicitly entered by the user.
|
|
54
|
-
// Optional; default is the measurement. If null or “<>”, the dimension measurement is drawn as the text,
|
|
55
|
-
// if ““ (one blank space), the text is suppressed. Anything else is drawn as the text
|
|
56
|
-
const err = 'Groupcode 1 not implemented';
|
|
57
|
-
Logging.instance.warn(`${this.type} - ${err}`);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/*
|
|
61
|
-
if (data.block) {
|
|
62
|
-
// Reference to block that contains the entities that make up this dimension
|
|
63
|
-
this.block = data.block;
|
|
64
|
-
}*/
|
|
65
|
-
|
|
66
|
-
if (data.blockName || data[2]) {
|
|
67
|
-
// DXF Groupcode 2 - Blockname
|
|
68
|
-
this.blockName = data.blockName || data[2];
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (data.styleName || data[3]) {
|
|
72
|
-
// DXF Groupcode 3 - Dimension Style Name
|
|
73
|
-
this.styleName = data.styleName || data[3];
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (data[40]) {
|
|
77
|
-
// DXF Groupcode 40 - Leader length for radius and diameter dimensions
|
|
78
|
-
this.leaderLength = data[40];
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (data[41]) {
|
|
82
|
-
// DXF Groupcode 41 - Line Spacing Factor
|
|
83
|
-
// Percentage of default (3-on-5) line spacing to be applied.
|
|
84
|
-
// Valid values range from 0.25 to 4.00
|
|
85
|
-
const err = 'Groupcode 41 not implemented';
|
|
86
|
-
Logging.instance.warn(`${this.type} - ${err}`);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (data[42]) {
|
|
90
|
-
// DXF Groupcode 42 - Actual Measurement
|
|
91
|
-
// Read-only
|
|
92
|
-
const err = 'Groupcode 42 not implemented';
|
|
93
|
-
Logging.instance.warn(`${this.type} - ${err}`);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (data[50]) {
|
|
97
|
-
// DXF Groupcode 50 - Angle of rotated, horizontal, or vertical dimensions
|
|
98
|
-
this.linearDimAngle = data[50];
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (data[51]) {
|
|
102
|
-
// DXF Groupcode 51 - Horizontal Direction
|
|
103
|
-
// All dimension types have an optional 51 group code, which indicates the horizontal direction
|
|
104
|
-
// for the dimension entity. The dimension entity determines the orientation of dimension
|
|
105
|
-
// text and lines for horizontal, vertical, and rotated linear dimensions
|
|
106
|
-
// This group value is the negative if the angle between the OCS X axis and the UCS X axis.
|
|
107
|
-
// It is always in the XY plane of the OCS
|
|
108
|
-
const err = 'Groupcode 51 not implemented';
|
|
109
|
-
Logging.instance.warn(`${this.type} - ${err}`);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (data.angle || data[53]) {
|
|
113
|
-
// DXF Groupcode 53 - Rotation
|
|
114
|
-
// rotation angle of the dimension text away from its default orientation
|
|
115
|
-
this.angle = data.angle || data[53];
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (data.dimType || data[70]) {
|
|
119
|
-
// DXF Groupcode 70 - Dimension Type
|
|
120
|
-
// Values 0-6 are integer values that represent the dimension type. Values 32, 64, and 128
|
|
121
|
-
// are bit values, which are added to the integer values
|
|
122
|
-
// (value 32 is always set in R13 and later releases)
|
|
123
|
-
// 0 = Rotated, horizontal, or vertical;
|
|
124
|
-
// 1 = Aligned;
|
|
125
|
-
// 2 = Angular;
|
|
126
|
-
// 3 = Diameter;
|
|
127
|
-
// 4 = Radius;
|
|
128
|
-
// 5 = Angular 3 point;
|
|
129
|
-
// 6 = Ordinate;
|
|
130
|
-
// 32 = Indicates that the block reference (group code 2) is referenced by this dimension only
|
|
131
|
-
// 64 = Ordinate type. This is a bit value (bit 7) used only with integer value 6.
|
|
132
|
-
// If set, ordinate is X-type; if not set, ordinate is Y-type
|
|
133
|
-
// 128 = This is a bit value (bit 8) added to the other group 70 values if the dimension text
|
|
134
|
-
// has been positioned at a user-defined location rather than at the default location
|
|
135
|
-
this.dimType = data.dimType || data[70];
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (data[71]) {
|
|
139
|
-
// DXF Groupcode 71 - Attachment Point
|
|
140
|
-
// 1 = Top left; 2 = Top center; 3 = Top right
|
|
141
|
-
// 4 = Middle left; 5 = Middle center; 6 = Middle right
|
|
142
|
-
// 7 = Bottom left; 8 = Bottom center; 9 = Bottom right
|
|
143
|
-
const err = 'Groupcode 71 not implemented';
|
|
144
|
-
Logging.instance.warn(`${this.type} - ${err}`);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
if (data[72]) {
|
|
148
|
-
// DXF Groupcode 72 - Line Spacing
|
|
149
|
-
// 1 (or missing) = At least (taller characters will override)
|
|
150
|
-
// 2 = Exact (taller characters will not override)
|
|
151
|
-
const err = 'Groupcode 72 not implemented';
|
|
152
|
-
Logging.instance.warn(`${this.type} - ${err}`);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
if (data.leaderLength) {
|
|
156
|
-
this.leaderLength = data.leaderLength;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
getBaseDimType() {
|
|
162
|
-
const type = this.dimType % 32;
|
|
163
|
-
return type;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
getPointBySequence(sequenceNumber) {
|
|
167
|
-
const point = this.points.find((point) => point.sequence === sequenceNumber);
|
|
168
|
-
return point;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
getArrowHead(point, angle, size) {
|
|
172
|
-
let p1 = new Point(point.x + size/4, point.y + size);
|
|
173
|
-
let p2 = new Point(point.x - size/4, point.y + size);
|
|
174
|
-
const ang = angle - Math.PI / 2;
|
|
175
|
-
p1 = p1.rotate(point, ang);
|
|
176
|
-
p2 = p2.rotate(point, ang);
|
|
177
|
-
|
|
178
|
-
const points = [point, p1, p2];
|
|
179
|
-
|
|
180
|
-
const arrowHead = new Solid({points: points});
|
|
181
|
-
|
|
182
|
-
return arrowHead;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
draw(ctx, scale) {
|
|
186
|
-
const style = DesignCore.DimStyleManager.getStyleByName(this.styleName);
|
|
187
|
-
|
|
188
|
-
const entities = this.buildDimension(style);
|
|
189
|
-
|
|
190
|
-
if (entities) {
|
|
191
|
-
this.block.clearItems();
|
|
192
|
-
|
|
193
|
-
entities.forEach((element) => {
|
|
194
|
-
this.block.addItem(element);
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
this.block.addItem(this.text);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
this.block.draw(ctx, scale);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
snaps(mousePoint, delta) {
|
|
204
|
-
const snaps = [];
|
|
205
|
-
return snaps;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
closestPoint(P) {
|
|
209
|
-
return this.block.closestPoint(P);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
boundingBox() {
|
|
213
|
-
return this.block.boundingBox();
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
within(selectionExtremes) {
|
|
217
|
-
return this.block.within(selectionExtremes);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
intersectPoints() {
|
|
221
|
-
return this.block.intersectPoints();
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
touched(selectionExtremes) {
|
|
225
|
-
return this.block.touched(selectionExtremes);
|
|
226
|
-
}
|
|
227
|
-
}
|