@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
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { Strings } from '../lib/strings.js';
|
|
2
|
+
import { Circle } from '../entities/circle.js';
|
|
3
|
+
import { Arc } from '../entities/arc.js';
|
|
4
|
+
import { BasePolyline } from '../entities/basePolyline.js';
|
|
5
|
+
import { Line } from '../entities/line.js';
|
|
6
|
+
import { Text } from '../entities/text.js';
|
|
7
|
+
import { Point } from '../entities/point.js';
|
|
8
|
+
import { Intersection } from '../lib/intersect.js';
|
|
9
|
+
import { Input, PromptOptions } from '../lib/inputManager.js';
|
|
10
|
+
import { Logging } from '../lib/logging.js';
|
|
11
|
+
import { BaseDimension } from './baseDimension.js';
|
|
12
|
+
|
|
13
|
+
import { DesignCore } from '../designCore.js';
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Base Class for Circular Dimensions - Radius and Diameter
|
|
18
|
+
* @extends BaseDimension
|
|
19
|
+
*/
|
|
20
|
+
export class BaseCircularDimension extends BaseDimension {
|
|
21
|
+
/**
|
|
22
|
+
* Circular Dimension Constructor
|
|
23
|
+
* @param {Array} data
|
|
24
|
+
*/
|
|
25
|
+
constructor(data) {
|
|
26
|
+
super(data);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Execute method
|
|
31
|
+
* executes the workflow, requesting input required to create an entity
|
|
32
|
+
*/
|
|
33
|
+
async execute() {
|
|
34
|
+
try {
|
|
35
|
+
this.dimensionStyle = DesignCore.DimStyleManager.getCstyle();
|
|
36
|
+
|
|
37
|
+
let Pt10;
|
|
38
|
+
let Pt15;
|
|
39
|
+
|
|
40
|
+
while (!Pt10 && !Pt15) {
|
|
41
|
+
this.points = [];
|
|
42
|
+
DesignCore.Scene.selectionManager.reset();
|
|
43
|
+
const op = new PromptOptions(Strings.Input.SELECT, [Input.Type.SINGLESELECTION]);
|
|
44
|
+
const selection = await DesignCore.Scene.inputManager.requestInput(op);
|
|
45
|
+
|
|
46
|
+
let selectedItem = DesignCore.Scene.entities.get(selection.selectedItemIndex);
|
|
47
|
+
|
|
48
|
+
if ([Circle, Arc, BasePolyline].some((entity) => selectedItem instanceof entity)) {
|
|
49
|
+
if (selectedItem instanceof BasePolyline) {
|
|
50
|
+
// get the segment closest to the mouse point
|
|
51
|
+
const segment = selectedItem.getClosestSegment(selection.selectedPoint);
|
|
52
|
+
|
|
53
|
+
if (segment instanceof Arc) {
|
|
54
|
+
// update the selected item to be the polyline arc segment
|
|
55
|
+
selectedItem = segment;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (selectedItem instanceof Circle || selectedItem instanceof Arc) {
|
|
60
|
+
Pt15 = selectedItem.points[1];
|
|
61
|
+
Pt15.sequence = 15;
|
|
62
|
+
this.points.push(Pt15);
|
|
63
|
+
|
|
64
|
+
Pt10 = selectedItem.points[0];
|
|
65
|
+
Pt10.sequence = 10;
|
|
66
|
+
this.points.push(Pt10);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const op1 = new PromptOptions(Strings.Input.DIMENSION, [Input.Type.POINT]);
|
|
72
|
+
const Pt11 = await DesignCore.Scene.inputManager.requestInput(op1);
|
|
73
|
+
Pt11.sequence = 11;
|
|
74
|
+
this.points.push(Pt11);
|
|
75
|
+
|
|
76
|
+
const tempCircle = new Circle({ points: [Pt10, Pt15] });
|
|
77
|
+
this.points = this.constructor.getPointsFromSelection([tempCircle], Pt11);
|
|
78
|
+
|
|
79
|
+
DesignCore.Scene.inputManager.executeCommand(this);
|
|
80
|
+
} catch (err) {
|
|
81
|
+
Logging.instance.error(`${this.type} - ${err}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Preview the entity during creation
|
|
87
|
+
*/
|
|
88
|
+
preview() {
|
|
89
|
+
if (DesignCore.Scene.selectionManager.selectionSet.selectionSet.length) {
|
|
90
|
+
const Pt11 = DesignCore.Mouse.pointOnScene();
|
|
91
|
+
Pt11.sequence = 11;
|
|
92
|
+
|
|
93
|
+
const Pt15 = this.getPointBySequence(this.points, 15);
|
|
94
|
+
const Pt10 = this.getPointBySequence(this.points, 10);
|
|
95
|
+
|
|
96
|
+
const tempCircle = new Circle({ points: [Pt10, Pt15] });
|
|
97
|
+
const points = this.constructor.getPointsFromSelection([tempCircle], Pt11);
|
|
98
|
+
|
|
99
|
+
DesignCore.Scene.tempEntities.create(this.type, { points: points });
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Build the dimension
|
|
105
|
+
* @param {Object} style
|
|
106
|
+
* @return {Array} - Array of entities that compose the dimension
|
|
107
|
+
*/
|
|
108
|
+
buildDimension() {
|
|
109
|
+
let dimension = 0;
|
|
110
|
+
const entities = [];
|
|
111
|
+
|
|
112
|
+
const Pt15 = this.getPointBySequence(this.points, 15); // radius point
|
|
113
|
+
const Pt10 = this.getPointBySequence(this.points, 10); // center point for radial dim or radial point for diameteric dim
|
|
114
|
+
let Pt11 = this.getPointBySequence(this.points, 11); // text position
|
|
115
|
+
|
|
116
|
+
// Style values
|
|
117
|
+
const DIMTIH = this.getDimensionStyle().getValue('DIMTIH'); // Text inside horizontal alignment
|
|
118
|
+
const DIMTOH = this.getDimensionStyle().getValue('DIMTOH'); // Text outside horizontal alignment
|
|
119
|
+
const DIMASZ = this.getDimensionStyle().getValue('DIMASZ'); // Arrow size (used for extension line length)
|
|
120
|
+
const DIMTXT = this.getDimensionStyle().getValue('DIMTXT'); // Text size (used for estimated text width)
|
|
121
|
+
const DIMTOFL = this.getDimensionStyle().getValue('DIMTOFL'); // Force extension line if text outside
|
|
122
|
+
const DIMTAD = this.getDimensionStyle().getValue('DIMTAD'); // Text vertical position
|
|
123
|
+
const DIMGAP = this.getDimensionStyle().getValue('DIMGAP'); // Gap between dimension line and text
|
|
124
|
+
|
|
125
|
+
if (!Pt10 || !Pt11 || !Pt15) {
|
|
126
|
+
return entities;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Ensure points are aligned Pt10 > Pt15 > Pt11
|
|
130
|
+
// This resets the points to a known state to allow application of the dimstyle
|
|
131
|
+
if (Pt15.isOnLine(Pt10, Pt11) === false) {
|
|
132
|
+
// Find the intersection between Pt10 > Pt15 and a horizontal ray from Pt11
|
|
133
|
+
const line2 = { start: Pt10, end: Pt15 };
|
|
134
|
+
const line1 = { start: Pt11, end: new Point(Pt10.x, Pt11.y) };
|
|
135
|
+
const intersect = Intersection.intersectSegmentSegment(line1.start, line1.end, line2.start, line2.end, false, true);
|
|
136
|
+
// Reset Pt11 - This should be the same as the originally selected Pt11
|
|
137
|
+
// Pt11 position can be changed depending on the dimstyle
|
|
138
|
+
if (intersect.points[0]) {
|
|
139
|
+
Pt11 = intersect.points[0];
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// set a minimum position for the text
|
|
144
|
+
if (Pt15.distance(Pt11) < DIMASZ + DIMTXT) {
|
|
145
|
+
Pt11 = Pt15.project(Pt10.angle(Pt11), DIMASZ + DIMTXT);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const formattedDimensionValue = this.getDimensionValue(dimension);
|
|
149
|
+
// approximate text width based on height
|
|
150
|
+
const approxTextWidth = Text.getApproximateWidth(formattedDimensionValue, DIMTXT);
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
// let textPosition = Pt11;
|
|
154
|
+
let textPosition = Pt11.project(Pt15.angle(Pt11), approxTextWidth * 0.5);
|
|
155
|
+
let textRotation = this.getTextDirection(Pt15.angle(Pt10));
|
|
156
|
+
// Get the direction for the dimension text offset
|
|
157
|
+
const textAboveDirection = textRotation + Math.PI / 2;
|
|
158
|
+
const textAboveDistance = DIMTXT * 0.5 + DIMGAP;
|
|
159
|
+
dimension = Pt15.distance(Pt10);
|
|
160
|
+
|
|
161
|
+
const isInside = Pt10.distance(Pt11) < Pt10.distance(Pt15);
|
|
162
|
+
|
|
163
|
+
// Check if the dimension text is aligned with the dimension line or horizontal
|
|
164
|
+
// This is determined by the DIMTIH and DIMTOH values
|
|
165
|
+
// 0 = Aligns text with the dimension line
|
|
166
|
+
// 1 = Draws text horizontally
|
|
167
|
+
// Determine if text should be horizontal, and handle extension line and text position
|
|
168
|
+
const shouldDrawTextHorizontal = (isInside && DIMTIH === 1) || (!isInside && DIMTOH === 1);
|
|
169
|
+
|
|
170
|
+
if (shouldDrawTextHorizontal) {
|
|
171
|
+
// Determine extension line direction (+1 or -1)
|
|
172
|
+
const extDir = isInside ? Math.sign(Pt10.x - Pt11.x) : Math.sign(Pt11.x - Pt10.x);
|
|
173
|
+
|
|
174
|
+
// Calculate distances for extension line and text offset
|
|
175
|
+
let textOffset = approxTextWidth * 0.5 + DIMTXT;
|
|
176
|
+
let extLineDist = DIMASZ * extDir;
|
|
177
|
+
|
|
178
|
+
if (DIMTAD > 0) {
|
|
179
|
+
extLineDist += approxTextWidth * extDir;
|
|
180
|
+
textOffset = -approxTextWidth;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const extLineEnd = new Point(Pt11.x + extLineDist, Pt11.y);
|
|
184
|
+
textRotation = 0;
|
|
185
|
+
|
|
186
|
+
if (!Pt10.isSame(Pt11)) {
|
|
187
|
+
textPosition = extLineEnd.project(Pt11.angle(extLineEnd), textOffset);
|
|
188
|
+
entities.push(new Line({ points: [Pt11, extLineEnd] }));
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// DIMTAD - Text vertical position
|
|
193
|
+
switch (DIMTAD) {
|
|
194
|
+
case 0: // 0 = Centers the dimension text between the extension lines.
|
|
195
|
+
break;
|
|
196
|
+
case 1: // 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).
|
|
197
|
+
textPosition = textPosition.project(textAboveDirection, textAboveDistance);
|
|
198
|
+
break;
|
|
199
|
+
case 2: // 2 = Places the dimension text on the side of the dimension line farthest away from the defining points.
|
|
200
|
+
textPosition = textPosition.project(textAboveDirection, textAboveDistance);
|
|
201
|
+
break;
|
|
202
|
+
case 3: // 3 = Places the dimension text to conform to Japanese Industrial Standards (JIS).
|
|
203
|
+
textPosition = textPosition.project(textAboveDirection, textAboveDistance);
|
|
204
|
+
break;
|
|
205
|
+
case 4: // 4 = Places the dimension text below the dimension line.
|
|
206
|
+
textPosition = textPosition.project(textAboveDirection, -textAboveDistance);
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Check if the text is aligned with the dimension line
|
|
211
|
+
const textAndDimlineAligned = this.alignedOrOpposite(textRotation, Pt10.angle(Pt15));
|
|
212
|
+
|
|
213
|
+
// Add the dimension line and arrow head
|
|
214
|
+
let lineLength = Pt15.distance(Pt11);
|
|
215
|
+
if (DIMTAD !== 0 && textAndDimlineAligned) {
|
|
216
|
+
lineLength = lineLength + approxTextWidth + DIMTXT; // Add text offset to line length
|
|
217
|
+
}
|
|
218
|
+
const startPoint = DIMTOFL ? Pt10 : Pt15;
|
|
219
|
+
const endPoint = Pt15.project(Pt10.angle(Pt15), isInside ? -lineLength : lineLength);
|
|
220
|
+
const line = new Line({ points: [startPoint, endPoint] });
|
|
221
|
+
const arrowDirection = isInside ? Pt15.angle(Pt10) : Pt10.angle(Pt15);
|
|
222
|
+
const arrowHead = this.getArrowHead(Pt15, arrowDirection);
|
|
223
|
+
entities.push(line, arrowHead);
|
|
224
|
+
|
|
225
|
+
// Get the dimension text using the value, position and rotation
|
|
226
|
+
const text = this.getDimensionText(dimension, textPosition, textRotation);
|
|
227
|
+
entities.push(text);
|
|
228
|
+
|
|
229
|
+
// If DIMTOFL is true, the centre mark is not drawn
|
|
230
|
+
if (!DIMTOFL) {
|
|
231
|
+
// Add the centre mark for circular dimensions
|
|
232
|
+
|
|
233
|
+
let center = Pt10;
|
|
234
|
+
|
|
235
|
+
// center point is mid point for diametric dimensions
|
|
236
|
+
if (this.dimType.getBaseDimType() === 3) {
|
|
237
|
+
center = Pt10.midPoint(Pt15);
|
|
238
|
+
}
|
|
239
|
+
entities.push(...this.getCentreMark(center));
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return entities;
|
|
243
|
+
}
|
|
244
|
+
}
|