@design-core/core 0.0.6 → 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.
Files changed (173) hide show
  1. package/.eslintrc.json +4 -0
  2. package/.github/workflows/DesignCoreQA.yml +3 -0
  3. package/TODO.md +49 -6
  4. package/core/core/core.js +0 -3
  5. package/core/designCore.js +1 -1
  6. package/core/dimensions/alignedDimension.js +12 -11
  7. package/core/dimensions/angularDimension.js +38 -37
  8. package/core/dimensions/{baseCircularDimension.js → circularDimensionBase.js} +22 -21
  9. package/core/dimensions/diametricDimension.js +14 -13
  10. package/core/dimensions/dimension.js +62 -55
  11. package/core/dimensions/{baseDimension.js → dimensionBase.js} +73 -107
  12. package/core/dimensions/{baseLinearDimension.js → linearDimensionBase.js} +15 -14
  13. package/core/dimensions/radialDimension.js +12 -11
  14. package/core/dimensions/rotatedDimension.js +20 -19
  15. package/core/entities/arc.js +123 -156
  16. package/core/entities/arctext.js +222 -184
  17. package/core/entities/circle.js +77 -99
  18. package/core/entities/entity.js +114 -93
  19. package/core/entities/hatch.js +346 -273
  20. package/core/entities/insert.js +68 -83
  21. package/core/entities/line.js +21 -142
  22. package/core/entities/lwpolyline.js +16 -11
  23. package/core/entities/point.js +19 -19
  24. package/core/entities/polyline.js +7 -7
  25. package/core/entities/{basePolyline.js → polylineBase.js} +47 -299
  26. package/core/entities/rectangle.js +3 -1
  27. package/core/entities/solid.js +6 -15
  28. package/core/entities/text.js +190 -201
  29. package/core/lib/auxiliary/rubberBand.js +32 -0
  30. package/core/lib/auxiliary/selectionWindow.js +63 -0
  31. package/core/lib/auxiliary/snapPoint.js +113 -0
  32. package/core/lib/auxiliary/trackingLine.js +76 -0
  33. package/core/lib/boundingBox.js +11 -11
  34. package/core/lib/canvas.js +232 -168
  35. package/core/lib/clipboard.js +9 -3
  36. package/core/lib/colour.js +16 -0
  37. package/core/lib/commandLine.js +1 -6
  38. package/core/lib/commandManager.js +18 -8
  39. package/core/lib/constants.js +28 -0
  40. package/core/lib/dxf/dxf.js +15 -14
  41. package/core/lib/dxf/dxfIterator.js +2 -2
  42. package/core/lib/entityManager.js +33 -26
  43. package/core/lib/inputManager.js +36 -12
  44. package/core/lib/intersect.js +25 -0
  45. package/core/lib/matrix.js +1 -1
  46. package/core/lib/patterns.js +9 -2
  47. package/core/lib/plotOptions.js +67 -0
  48. package/core/lib/polylineUtils.js +75 -0
  49. package/core/lib/renderers/cairoRenderer.js +371 -0
  50. package/core/lib/renderers/canvasRenderer.js +315 -0
  51. package/core/lib/renderers/pdfRenderer.js +366 -0
  52. package/core/lib/renderers/rendererBase.js +284 -0
  53. package/core/lib/renderers/svgRenderer.js +343 -0
  54. package/core/lib/scene.js +28 -6
  55. package/core/lib/selectionManager.js +20 -20
  56. package/core/lib/settings.js +4 -2
  57. package/core/lib/snapping.js +4 -191
  58. package/core/lib/stateManager.js +30 -1
  59. package/core/lib/utils.js +26 -7
  60. package/core/properties/entityProperties.js +104 -0
  61. package/core/properties/property.js +106 -2
  62. package/core/properties/propertyManager.js +60 -44
  63. package/core/tables/block.js +50 -81
  64. package/core/tables/dimStyle.js +5 -5
  65. package/core/tables/endblk.js +1 -1
  66. package/core/tables/layer.js +8 -0
  67. package/core/tables/ltypeManager.js +1 -1
  68. package/core/tables/styleManagerBase.js +3 -2
  69. package/core/tables/tableManagerBase.js +8 -3
  70. package/core/tables/vport.js +2 -2
  71. package/core/tools/chamfer.js +117 -143
  72. package/core/tools/chamferFilletBase.js +138 -37
  73. package/core/tools/copy.js +11 -11
  74. package/core/tools/copybase.js +3 -3
  75. package/core/tools/copyclip.js +3 -3
  76. package/core/tools/cornerEntity.js +2 -2
  77. package/core/tools/cutclip.js +3 -3
  78. package/core/tools/explode.js +7 -7
  79. package/core/tools/extend.js +138 -25
  80. package/core/tools/fillet.js +92 -189
  81. package/core/tools/matchProp.js +3 -12
  82. package/core/tools/mirror.js +15 -14
  83. package/core/tools/move.js +8 -8
  84. package/core/tools/offset.js +31 -33
  85. package/core/tools/pasteclip.js +1 -1
  86. package/core/tools/purge.js +10 -10
  87. package/core/tools/rotate.js +19 -16
  88. package/core/tools/scale.js +7 -7
  89. package/core/tools/trim.js +271 -29
  90. package/core/tools/zoom.js +1 -1
  91. package/cspell.json +321 -0
  92. package/jest.config.js +6 -0
  93. package/package.json +5 -3
  94. package/test/dimensions/alignedDimension.test.js +17 -10
  95. package/test/dimensions/angularDimension.test.js +13 -13
  96. package/test/dimensions/diametricDimension.test.js +15 -15
  97. package/test/dimensions/dimension.test.js +12 -12
  98. package/test/dimensions/{baseDimension.test.js → dimensionBase.test.js} +73 -12
  99. package/test/dimensions/linearDimensionBase.test.js +62 -0
  100. package/test/dimensions/radialDimension.test.js +15 -15
  101. package/test/dimensions/rotatedDimension.test.js +18 -11
  102. package/test/entities/arc.test.js +83 -86
  103. package/test/entities/arctext.test.js +184 -57
  104. package/test/entities/circle.test.js +68 -96
  105. package/test/entities/entity.test.js +42 -8
  106. package/test/entities/hatch.test.js +569 -96
  107. package/test/entities/insert.test.js +99 -4
  108. package/test/entities/line.test.js +15 -41
  109. package/test/entities/lwpolyline.test.js +104 -0
  110. package/test/entities/point.test.js +3 -3
  111. package/test/entities/polyline.test.js +11 -0
  112. package/test/entities/{basePolyline.test.js → polylineBase.test.js} +192 -57
  113. package/test/entities/rectangle.test.js +11 -0
  114. package/test/entities/solid.test.js +1 -1
  115. package/test/entities/text.test.js +302 -77
  116. package/test/integration/exportIntegration.reference.dxf +9 -9
  117. package/test/integration/exportIntegration.test.js +5 -5
  118. package/test/integration/intersectionIntegration.test.js +4 -5
  119. package/test/integration/pdfRendererIntegration.reference.pdf +17709 -0
  120. package/test/integration/pdfRendererIntegration.test.js +61 -0
  121. package/test/integration/svgRendererIntegration.reference.svg +3343 -0
  122. package/test/integration/svgRendererIntegration.test.js +61 -0
  123. package/test/integration/userInputIntegration.reference.dxf +1165 -105
  124. package/test/integration/userInputIntegration.test.js +239 -132
  125. package/test/lib/boundingBox.test.js +3 -3
  126. package/test/lib/canvas.test.js +744 -125
  127. package/test/lib/constants.test.js +27 -0
  128. package/test/lib/entityManager.test.js +4 -4
  129. package/test/lib/inputManager.test.js +81 -20
  130. package/test/lib/intersect.test.js +83 -0
  131. package/test/lib/plotOptions.test.js +179 -0
  132. package/test/lib/rubberBand.test.js +84 -0
  133. package/test/lib/scene.test.js +9 -9
  134. package/test/lib/selectionManager.test.js +3 -3
  135. package/test/lib/settings.test.js +5 -6
  136. package/test/lib/snapping.test.js +72 -130
  137. package/test/lib/stateManager.test.js +7 -7
  138. package/test/lib/utils.test.js +36 -2
  139. package/test/properties/entityProperties.test.js +132 -0
  140. package/test/properties/property.test.js +53 -0
  141. package/test/properties/propertyManager.test.js +25 -25
  142. package/test/renderers/canvasRenderer.test.js +317 -0
  143. package/test/renderers/pdfRenderer.test.js +271 -0
  144. package/test/renderers/rendererBase.test.js +213 -0
  145. package/test/renderers/svgRenderer.test.js +326 -0
  146. package/test/tables/block.test.js +92 -13
  147. package/test/tables/endblk.test.js +2 -2
  148. package/test/tables/layer.test.js +30 -0
  149. package/test/tables/layerManager.test.js +2 -2
  150. package/test/test-helpers/hatchGridRenderer.js +180 -0
  151. package/test/test-helpers/test-helpers.js +158 -6
  152. package/test/tools/chamfer.test.js +273 -51
  153. package/test/tools/chamferFilletBase.test.js +125 -36
  154. package/test/tools/copy.test.js +8 -8
  155. package/test/tools/copybase.test.js +2 -2
  156. package/test/tools/copyclip.test.js +2 -2
  157. package/test/tools/cornerEntity.test.js +8 -8
  158. package/test/tools/cutclip.test.js +2 -2
  159. package/test/tools/erase.test.js +6 -6
  160. package/test/tools/explode.test.js +5 -5
  161. package/test/tools/extend.test.js +373 -42
  162. package/test/tools/fillet.test.js +230 -49
  163. package/test/tools/matchProp.test.js +11 -11
  164. package/test/tools/mirror.test.js +39 -39
  165. package/test/tools/move.test.js +7 -7
  166. package/test/tools/offset.test.js +222 -55
  167. package/test/tools/pasteclip.test.js +5 -5
  168. package/test/tools/purge.test.js +4 -4
  169. package/test/tools/rotate.test.js +39 -9
  170. package/test/tools/scale.test.js +33 -33
  171. package/test/tools/trim.test.js +579 -53
  172. package/test/tools/zoom.test.js +12 -12
  173. package/core/lib/selectionWindow.js +0 -83
package/.eslintrc.json CHANGED
@@ -9,10 +9,14 @@
9
9
  "ecmaVersion": "latest",
10
10
  "sourceType": "module"
11
11
  },
12
+ "plugins": [
13
+ "import"
14
+ ],
12
15
  "rules": {
13
16
  "require-jsdoc": 2,
14
17
  "valid-jsdoc": 2,
15
18
  "max-len": 0,
19
+ "import/first": "error",
16
20
  "function-paren-newline": "warn",
17
21
  "object-curly-spacing": [
18
22
  "error",
@@ -27,6 +27,9 @@ jobs:
27
27
  node-version: ${{ matrix.node-version }}
28
28
  cache: 'npm'
29
29
 
30
+ - name: Spell Check
31
+ run: npx cspell "**/*.{js,md}" --no-progress
32
+
30
33
  - name: Circular Dependency Check
31
34
  run: npx madge --circular --extensions js .
32
35
 
package/TODO.md CHANGED
@@ -1,12 +1,6 @@
1
1
  # Design-Core TODO list
2
2
 
3
3
  ## Beta
4
- ### UNDO / REDO
5
-
6
- ### Printing
7
-
8
- ### Export PDF
9
-
10
4
  ### Paperspace
11
5
 
12
6
  ### Entity Editing
@@ -17,3 +11,52 @@
17
11
  - Radial Dimension
18
12
  - Diametric Dimension
19
13
 
14
+ ### Text sizing
15
+ - Text size - need a non-hacky glyph-advance measuring API on each the renderer
16
+ - ArcAlignedText characterSpacing=0 overlap — Cairo's cap-height correction scales glyph advances wider than getApproximateWidth predicts;
17
+
18
+ ### performance optimisation
19
+
20
+ #### 1. `LType.getPattern(scale)` — cache the scaled array (easy)
21
+ Called once per entity per frame. Currently allocates a new array every call via `.map()`.
22
+ A two-field cache (`#lastScale`, `#cachedPattern`) returns the existing array when scale hasn't changed.
23
+
24
+ - **Effort**: ~10 lines, isolated to `ltype.js`
25
+ - **Expected gain**: small but consistent; removes N allocations per frame where N = entity count
26
+
27
+ #### 2. State dedup in renderers — skip no-op `setColour`/`setLineWidth`/`setDash` calls (medium)
28
+ `setContext` is called unconditionally for every entity. For entities sharing colour and line width (the common case), the underlying Canvas/Cairo API calls are redundant.
29
+ Track the last-set value in each renderer and return early when unchanged.
30
+
31
+ - **Effort**: ~20 lines per renderer, self-contained
32
+ - **Expected gain**: meaningful for large scenes with many same-layer entities; could save 10–30% of state-setting overhead
33
+
34
+ #### 3. Skip `save()`/`restore()` for leaf entities (medium)
35
+ `#paintEntity` wraps every entity in `save()`/`restore()` even though only container entities (Insert, BaseDimension) actually change the transform. Requires an `entity.isContainer` flag or restructuring to save lazily.
36
+
37
+ - **Effort**: entity API change + `#paintEntity` refactor
38
+ - **Expected gain**: ~1 `save`/`restore` pair eliminated per leaf entity per frame; measurable at high entity counts
39
+
40
+ #### 4. Offscreen canvas for static scene (large, architectural)
41
+ The full scene repaints on every mouse move (hover detection, rubber band, cursor). Splitting into a static layer (repaint on data change only) and a dynamic overlay (hover, preview, selection) would eliminate most per-frame work.
42
+
43
+ - **Effort**: significant — touches `canvas.js`, rendering pipeline, and UI integration
44
+ - **Expected gain**: potentially 3–5× frame rate improvement during mouse movement over a complex scene
45
+
46
+ #### 5. Viewport culling — skip entities outside the visible area (medium, high impact when zoomed in)
47
+ Every entity already has `boundingBox()` and `canvas.getSceneOffset()` returns the visible scene rectangle.
48
+ A simple AABB overlap test in `#paintEntities` would skip entities outside the viewport before calling `#paintEntity`.
49
+
50
+ - **Effort**: ~10 lines in `#paintEntities`; call `getSceneOffset()` once per `paint()` and pass it in
51
+
52
+ - **Caveat — bounding box caching**: `Hatch.boundingBox()` and `Block.boundingBox()` iterate all child entities on every call. Per-frame culling cost could exceed draw cost for those types unless bboxes are cached on the entity and invalidated on edit. Simple entity types (Line, Circle, Arc) have trivial bbox cost and benefit immediately.
53
+
54
+ - **Caveat — Text**: `Text.boundingBox()` depends on `boundingRect` which is only populated after the first `draw()` call — needs a fallback to avoid incorrectly culling undrawn text.
55
+
56
+ - **Expected gain**: negligible when fully zoomed out; potentially 5–50× reduction in draw calls when working zoomed into a small area of a large drawing
57
+
58
+ ### Test clean up
59
+ - Have the renderer changes provided any opportunity to clean up tests
60
+ - Is there opportunity for extended testing with the mock renderer
61
+
62
+
package/core/core/core.js CHANGED
@@ -24,9 +24,6 @@ import { Logging } from '../lib/logging.js';
24
24
 
25
25
  import { DesignCore } from '../designCore.js';
26
26
 
27
- // re-export core components for external use
28
- export { Patterns } from '../lib/patterns.js';
29
-
30
27
  /** Class representing design core. This is the primary entry point */
31
28
  export class Core {
32
29
  /** Create a core object */
@@ -11,7 +11,7 @@
11
11
  import {Core} from "core.js";
12
12
  import {DesignCore} from "designCore.js";
13
13
 
14
- // Core must be instanciated and activated before use:
14
+ // Core must be instantiated and activated before use:
15
15
  const core = new Core()
16
16
  core.activate()
17
17
 
@@ -4,16 +4,17 @@ import { Input, PromptOptions } from '../lib/inputManager.js';
4
4
  import { Logging } from '../lib/logging.js';
5
5
  import { DXFFile } from '../lib/dxf/dxfFile.js';
6
6
  import { Point } from '../entities/point.js';
7
- import { BaseLinearDimension } from './baseLinearDimension.js';
7
+ import { LinearDimensionBase } from './linearDimensionBase.js';
8
8
 
9
9
  import { DesignCore } from '../designCore.js';
10
+ import { Property } from '../properties/property.js';
10
11
 
11
12
 
12
13
  /**
13
14
  * Aligned Dimension Entity Class
14
15
  * @extends LinearDimension
15
16
  */
16
- export class AlignedDimension extends BaseLinearDimension {
17
+ export class AlignedDimension extends LinearDimensionBase {
17
18
  /**
18
19
  * Create an Aligned Dimension
19
20
  * @param {Array} data
@@ -42,7 +43,7 @@ export class AlignedDimension extends BaseLinearDimension {
42
43
  async execute() {
43
44
  try {
44
45
  DesignCore.Scene.selectionManager.reset();
45
- this.dimensionStyle = DesignCore.DimStyleManager.getCstyle();
46
+ this.setProperty(Property.Names.DIMENSIONSTYLE, DesignCore.DimStyleManager.getCstyle());
46
47
  this.dimType.setDimType(1); // Aligned dimension
47
48
 
48
49
  const op = new PromptOptions(Strings.Input.START, [Input.Type.POINT]);
@@ -71,19 +72,19 @@ export class AlignedDimension extends BaseLinearDimension {
71
72
 
72
73
  /**
73
74
  * Get sequenced points from user selection
74
- * @param {any} items
75
+ * @param {any} entities
75
76
  * @param {Point} textPos
76
77
  * @return {Array} array of points
77
78
  */
78
- static getPointsFromSelection(items, textPos) {
79
+ static getPointsFromSelection(entities, textPos) {
79
80
  const points = [];
80
- const item = items[0];
81
+ const entity = entities[0];
81
82
 
82
- const Pt13 = item.points[0];
83
+ const Pt13 = entity.points[0];
83
84
  Pt13.sequence = 13;
84
85
  points.push(Pt13);
85
86
 
86
- const Pt14 = item.points[1];
87
+ const Pt14 = entity.points[1];
87
88
  Pt14.sequence = 14;
88
89
  points.push(Pt14);
89
90
 
@@ -118,10 +119,10 @@ export class AlignedDimension extends BaseLinearDimension {
118
119
  const Pt14 = this.getPointBySequence(this.points, 14);
119
120
 
120
121
  file.writeGroupCode('0', 'DIMENSION');
121
- file.writeGroupCode('5', this.handle, DXFFile.Version.R2000); // Handle
122
+ file.writeGroupCode('5', this.getProperty(Property.Names.HANDLE), DXFFile.Version.R2000); // Handle
122
123
  file.writeGroupCode('100', 'AcDbEntity', DXFFile.Version.R2000);
123
124
  file.writeGroupCode('100', 'AcDbDimension', DXFFile.Version.R2000);
124
- file.writeGroupCode('8', this.layer);
125
+ file.writeGroupCode('8', this.getProperty(Property.Names.LAYER));
125
126
  // file.writeGroupCode('2', this.blockName); // Block not required
126
127
  file.writeGroupCode('10', Pt10.x); // X - definition / arrow point
127
128
  file.writeGroupCode('20', Pt10.y); // Y
@@ -130,7 +131,7 @@ export class AlignedDimension extends BaseLinearDimension {
130
131
  file.writeGroupCode('21', Pt11.y); // Y
131
132
  file.writeGroupCode('31', '0.0'); // Z
132
133
  file.writeGroupCode('70', this.dimType.getDimType()); // DIMENSION TYPE
133
- file.writeGroupCode('3', this.dimensionStyle); // DIMENSION STYLE
134
+ file.writeGroupCode('3', this.getProperty(Property.Names.DIMENSIONSTYLE)); // DIMENSION STYLE
134
135
  file.writeGroupCode('100', 'AcDbAlignedDimension', DXFFile.Version.R2000);
135
136
  file.writeGroupCode('13', Pt13.x); // X - start point of first extension line
136
137
  file.writeGroupCode('23', Pt13.y); // Y
@@ -2,24 +2,25 @@
2
2
  import { Utils } from '../lib/utils.js';
3
3
  import { Strings } from '../lib/strings.js';
4
4
  import { Arc } from '../entities/arc.js';
5
- import { BasePolyline } from '../entities/basePolyline.js';
5
+ import { PolylineBase } from '../entities/polylineBase.js';
6
6
  import { Line } from '../entities/line.js';
7
7
  import { Input, PromptOptions } from '../lib/inputManager.js';
8
8
  import { Logging } from '../lib/logging.js';
9
9
  import { DXFFile } from '../lib/dxf/dxfFile.js';
10
- import { BaseDimension } from './baseDimension.js';
10
+ import { DimensionBase } from './dimensionBase.js';
11
11
  import { Intersection } from '../lib/intersect.js';
12
12
  import { Point } from '../entities/point.js';
13
13
 
14
14
  import { Text } from '../entities/text.js'; // used to debug the dimension points
15
15
 
16
16
  import { DesignCore } from '../designCore.js';
17
+ import { Property } from '../properties/property.js';
17
18
 
18
19
  /**
19
20
  * Angular Dimension Entity Class
20
- * @extends BaseDimension
21
+ * @extends DimensionBase
21
22
  */
22
- export class AngularDimension extends BaseDimension {
23
+ export class AngularDimension extends DimensionBase {
23
24
  /**
24
25
  * Create an Angular Dimension
25
26
  * @param {Array} data
@@ -47,7 +48,7 @@ export class AngularDimension extends BaseDimension {
47
48
  */
48
49
  async execute() {
49
50
  try {
50
- this.dimensionStyle = DesignCore.DimStyleManager.getCstyle();
51
+ this.setProperty(Property.Names.DIMENSIONSTYLE, DesignCore.DimStyleManager.getCstyle());
51
52
  this.dimType.setDimType(2); // Angular dimension
52
53
 
53
54
  let Pt10;
@@ -61,25 +62,25 @@ export class AngularDimension extends BaseDimension {
61
62
 
62
63
  const op = new PromptOptions(Strings.Input.SELECT, [Input.Type.SINGLESELECTION]);
63
64
  const selection = await DesignCore.Scene.inputManager.requestInput(op);
64
- let selectedItem = DesignCore.Scene.entities.get(selection.selectedItemIndex);
65
+ let selectedEntity = DesignCore.Scene.entities.get(selection.selectedEntityIndex);
65
66
 
66
- if ([Line, BasePolyline].some((entity) => selectedItem instanceof entity)) {
67
- if (selectedItem instanceof BasePolyline) {
67
+ if ([Line, PolylineBase].some((entity) => selectedEntity instanceof entity)) {
68
+ if (selectedEntity instanceof PolylineBase) {
68
69
  // get the segment closest to the mouse point
69
- const segment = selectedItem.getClosestSegment(selection.selectedPoint);
70
+ const segment = selectedEntity.getClosestSegment(selection.selectedPoint);
70
71
 
71
72
  if (segment instanceof Line) {
72
- // update the selected item to be the polyline arc segment
73
- selectedItem = segment;
73
+ // update the selected entity to be the polyline arc segment
74
+ selectedEntity = segment;
74
75
  }
75
76
  }
76
77
 
77
- if (selectedItem instanceof Line) {
78
- Pt15 = selectedItem.points[0];
78
+ if (selectedEntity instanceof Line) {
79
+ Pt15 = selectedEntity.points[0];
79
80
  Pt15.sequence = 15;
80
81
  this.points.push(Pt15);
81
82
 
82
- Pt10 = selectedItem.points[1];
83
+ Pt10 = selectedEntity.points[1];
83
84
  Pt10.sequence = 10;
84
85
  this.points.push(Pt10);
85
86
  }
@@ -90,24 +91,24 @@ export class AngularDimension extends BaseDimension {
90
91
  DesignCore.Scene.selectionManager.reset();
91
92
  const op1 = new PromptOptions(Strings.Input.SELECT, [Input.Type.SINGLESELECTION]);
92
93
  const selection2 = await DesignCore.Scene.inputManager.requestInput(op1);
93
- let selectedItem = DesignCore.Scene.entities.get(selection2.selectedItemIndex);
94
+ let selectedEntity = DesignCore.Scene.entities.get(selection2.selectedEntityIndex);
94
95
 
95
- if ([Line, BasePolyline].some((entity) => selectedItem instanceof entity)) {
96
- if (selectedItem instanceof BasePolyline) {
96
+ if ([Line, PolylineBase].some((entity) => selectedEntity instanceof entity)) {
97
+ if (selectedEntity instanceof PolylineBase) {
97
98
  // get the segment closest to the mouse point
98
- const segment = selectedItem.getClosestSegment(selection2.selectedPoint);
99
+ const segment = selectedEntity.getClosestSegment(selection2.selectedPoint);
99
100
 
100
101
  if (segment instanceof Line) {
101
- // update the selected item to be the polyline arc segment
102
- selectedItem = segment;
102
+ // update the selected entity to be the polyline arc segment
103
+ selectedEntity = segment;
103
104
  }
104
105
  }
105
- if (selectedItem instanceof Line) {
106
- Pt13 = selectedItem.points[0];
106
+ if (selectedEntity instanceof Line) {
107
+ Pt13 = selectedEntity.points[0];
107
108
  Pt13.sequence = 13;
108
109
  this.points.push(Pt13);
109
110
 
110
- Pt14 = selectedItem.points[1];
111
+ Pt14 = selectedEntity.points[1];
111
112
  Pt14.sequence = 14;
112
113
  this.points.push(Pt14);
113
114
  }
@@ -146,29 +147,29 @@ export class AngularDimension extends BaseDimension {
146
147
 
147
148
  const points = AngularDimension.getPointsFromSelection([tempLineOne, tempLineTwo], Pt11);
148
149
 
149
- DesignCore.Scene.tempEntities.create(this.type, { points: points, dimensionStyle: this.dimensionStyle });
150
+ DesignCore.Scene.previewEntities.create(this.type, { points: points, dimensionStyle: this.getProperty(Property.Names.DIMENSIONSTYLE) });
150
151
  }
151
152
  }
152
153
 
153
154
  /**
154
155
  * Get sequenced points from user selection
155
- * @param {any} items
156
+ * @param {any} entities
156
157
  * @param {Point} textPos
157
158
  * @return {Array} array of points
158
159
  */
159
- static getPointsFromSelection(items, textPos) {
160
- // Transform the items into points
161
- // Do nothing more than transform the items into points
160
+ static getPointsFromSelection(entities, textPos) {
161
+ // Transform the entities into points
162
+ // Do nothing more than transform the entities into points
162
163
 
163
164
  const points = [];
164
- const item1 = items[0];
165
- const item2 = items[1];
165
+ const entity1 = entities[0];
166
+ const entity2 = entities[1];
166
167
 
167
- const tempPt15 = item1.points[0];
168
- const tempPt10 = item1.points[1];
168
+ const tempPt15 = entity1.points[0];
169
+ const tempPt10 = entity1.points[1];
169
170
 
170
- const tempPt13 = item2.points[0];
171
- const tempPt14 = item2.points[1];
171
+ const tempPt13 = entity2.points[0];
172
+ const tempPt14 = entity2.points[1];
172
173
 
173
174
  // Check the lines intersect
174
175
  const intersect = Intersection.intersectSegmentSegment(tempPt15, tempPt10, tempPt13, tempPt14, false, true);
@@ -520,10 +521,10 @@ export class AngularDimension extends BaseDimension {
520
521
  const Pt16 = this.getPointBySequence(this.points, 16);
521
522
 
522
523
  file.writeGroupCode('0', 'DIMENSION');
523
- file.writeGroupCode('5', this.handle, DXFFile.Version.R2000); // Handle
524
+ file.writeGroupCode('5', this.getProperty(Property.Names.HANDLE), DXFFile.Version.R2000); // Handle
524
525
  file.writeGroupCode('100', 'AcDbEntity', DXFFile.Version.R2000);
525
526
  file.writeGroupCode('100', 'AcDbDimension', DXFFile.Version.R2000);
526
- file.writeGroupCode('8', this.layer);
527
+ file.writeGroupCode('8', this.getProperty(Property.Names.LAYER));
527
528
  // file.writeGroupCode('2', this.blockName); // Block not required
528
529
  file.writeGroupCode('10', Pt10.x); // X - Start of Dimension Line
529
530
  file.writeGroupCode('20', Pt10.y); // Y
@@ -532,7 +533,7 @@ export class AngularDimension extends BaseDimension {
532
533
  file.writeGroupCode('21', Pt11.y); // Y
533
534
  file.writeGroupCode('31', '0.0'); // Z
534
535
  file.writeGroupCode('70', this.dimType.getDimType()); // DIMENSION TYPE
535
- file.writeGroupCode('3', this.dimensionStyle); // DIMENSION STYLE
536
+ file.writeGroupCode('3', this.getProperty(Property.Names.DIMENSIONSTYLE)); // DIMENSION STYLE
536
537
  file.writeGroupCode('100', 'AcDb2LineAngularDimension', DXFFile.Version.R2000);
537
538
  file.writeGroupCode('13', Pt13.x); // X
538
539
  file.writeGroupCode('23', Pt13.y); // Y
@@ -1,23 +1,24 @@
1
1
  import { Strings } from '../lib/strings.js';
2
2
  import { Circle } from '../entities/circle.js';
3
3
  import { Arc } from '../entities/arc.js';
4
- import { BasePolyline } from '../entities/basePolyline.js';
4
+ import { PolylineBase } from '../entities/polylineBase.js';
5
5
  import { Line } from '../entities/line.js';
6
6
  import { Text } from '../entities/text.js';
7
7
  import { Point } from '../entities/point.js';
8
8
  import { Intersection } from '../lib/intersect.js';
9
9
  import { Input, PromptOptions } from '../lib/inputManager.js';
10
10
  import { Logging } from '../lib/logging.js';
11
- import { BaseDimension } from './baseDimension.js';
11
+ import { DimensionBase } from './dimensionBase.js';
12
12
 
13
13
  import { DesignCore } from '../designCore.js';
14
+ import { Property } from '../properties/property.js';
14
15
 
15
16
 
16
17
  /**
17
18
  * Base Class for Circular Dimensions - Radius and Diameter
18
- * @extends BaseDimension
19
+ * @extends DimensionBase
19
20
  */
20
- export class BaseCircularDimension extends BaseDimension {
21
+ export class CircularDimensionBase extends DimensionBase {
21
22
  /**
22
23
  * Circular Dimension Constructor
23
24
  * @param {Array} data
@@ -32,7 +33,7 @@ export class BaseCircularDimension extends BaseDimension {
32
33
  */
33
34
  async execute() {
34
35
  try {
35
- this.dimensionStyle = DesignCore.DimStyleManager.getCstyle();
36
+ this.setProperty(Property.Names.DIMENSIONSTYLE, DesignCore.DimStyleManager.getCstyle());
36
37
 
37
38
  let Pt10;
38
39
  let Pt15;
@@ -43,25 +44,25 @@ export class BaseCircularDimension extends BaseDimension {
43
44
  const op = new PromptOptions(Strings.Input.SELECT, [Input.Type.SINGLESELECTION]);
44
45
  const selection = await DesignCore.Scene.inputManager.requestInput(op);
45
46
 
46
- let selectedItem = DesignCore.Scene.entities.get(selection.selectedItemIndex);
47
+ let selectedEntity = DesignCore.Scene.entities.get(selection.selectedEntityIndex);
47
48
 
48
- if ([Circle, Arc, BasePolyline].some((entity) => selectedItem instanceof entity)) {
49
- if (selectedItem instanceof BasePolyline) {
49
+ if ([Circle, Arc, PolylineBase].some((entity) => selectedEntity instanceof entity)) {
50
+ if (selectedEntity instanceof PolylineBase) {
50
51
  // get the segment closest to the mouse point
51
- const segment = selectedItem.getClosestSegment(selection.selectedPoint);
52
+ const segment = selectedEntity.getClosestSegment(selection.selectedPoint);
52
53
 
53
54
  if (segment instanceof Arc) {
54
- // update the selected item to be the polyline arc segment
55
- selectedItem = segment;
55
+ // update the selected entity to be the polyline arc segment
56
+ selectedEntity = segment;
56
57
  }
57
58
  }
58
59
 
59
- if (selectedItem instanceof Circle || selectedItem instanceof Arc) {
60
- Pt15 = selectedItem.points[1];
60
+ if (selectedEntity instanceof Circle || selectedEntity instanceof Arc) {
61
+ Pt15 = selectedEntity.points[1];
61
62
  Pt15.sequence = 15;
62
63
  this.points.push(Pt15);
63
64
 
64
- Pt10 = selectedItem.points[0];
65
+ Pt10 = selectedEntity.points[0];
65
66
  Pt10.sequence = 10;
66
67
  this.points.push(Pt10);
67
68
  }
@@ -96,7 +97,7 @@ export class BaseCircularDimension extends BaseDimension {
96
97
  const tempCircle = new Circle({ points: [Pt10, Pt15] });
97
98
  const points = this.constructor.getPointsFromSelection([tempCircle], Pt11);
98
99
 
99
- DesignCore.Scene.tempEntities.create(this.type, { points: points });
100
+ DesignCore.Scene.previewEntities.create(this.type, { points: points });
100
101
  }
101
102
  }
102
103
 
@@ -110,7 +111,7 @@ export class BaseCircularDimension extends BaseDimension {
110
111
  const entities = [];
111
112
 
112
113
  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
+ const Pt10 = this.getPointBySequence(this.points, 10); // centre point for radial dim or radial point for diametric dim
114
115
  let Pt11 = this.getPointBySequence(this.points, 11); // text position
115
116
 
116
117
  // Style values
@@ -191,7 +192,7 @@ export class BaseCircularDimension extends BaseDimension {
191
192
 
192
193
  // DIMTAD - Text vertical position
193
194
  switch (DIMTAD) {
194
- case 0: // 0 = Centers the dimension text between the extension lines.
195
+ case 0: // 0 = Centres the dimension text between the extension lines.
195
196
  break;
196
197
  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
198
  textPosition = textPosition.project(textAboveDirection, textAboveDistance);
@@ -230,13 +231,13 @@ export class BaseCircularDimension extends BaseDimension {
230
231
  if (!DIMTOFL) {
231
232
  // Add the centre mark for circular dimensions
232
233
 
233
- let center = Pt10;
234
+ let centre = Pt10;
234
235
 
235
- // center point is mid point for diametric dimensions
236
+ // centre point is mid point for diametric dimensions
236
237
  if (this.dimType.getBaseDimType() === 3) {
237
- center = Pt10.midPoint(Pt15);
238
+ centre = Pt10.midPoint(Pt15);
238
239
  }
239
- entities.push(...this.getCentreMark(center));
240
+ entities.push(...this.getCentreMark(centre));
240
241
  }
241
242
 
242
243
  return entities;
@@ -1,11 +1,12 @@
1
1
  import { DXFFile } from '../lib/dxf/dxfFile.js';
2
- import { BaseCircularDimension } from './baseCircularDimension.js';
2
+ import { CircularDimensionBase } from './circularDimensionBase.js';
3
+ import { Property } from '../properties/property.js';
3
4
 
4
5
  /**
5
6
  * Diametric Dimension Entity Class
6
- * @extends BaseCircularDimension
7
+ * @extends CircularDimensionBase
7
8
  */
8
- export class DiametricDimension extends BaseCircularDimension {
9
+ export class DiametricDimension extends CircularDimensionBase {
9
10
  /**
10
11
  * Create a Diametric Dimension
11
12
  * @param {Array} data
@@ -29,22 +30,22 @@ export class DiametricDimension extends BaseCircularDimension {
29
30
 
30
31
  /**
31
32
  * Get sequenced points from user selection
32
- * @param {any} items
33
+ * @param {any} entities
33
34
  * @param {Point} textPos
34
35
  * @return {Array} array of points
35
36
  */
36
- static getPointsFromSelection(items, textPos) {
37
- const item = items[0];
38
- const center = item.points[0];
37
+ static getPointsFromSelection(entities, textPos) {
38
+ const entity = entities[0];
39
+ const centre = entity.points[0];
39
40
 
40
41
  const Pt11 = textPos;
41
42
  Pt11.sequence = 11;
42
43
 
43
- const angle = Pt11.angle(center);
44
- const Pt10 = center.project(angle, item.getRadius());
44
+ const angle = Pt11.angle(centre);
45
+ const Pt10 = centre.project(angle, entity.getRadius());
45
46
  Pt10.sequence = 10;
46
47
  // Pt15 should be closest point to the text position
47
- const Pt15 = center.project(angle - Math.PI, item.getRadius());
48
+ const Pt15 = centre.project(angle - Math.PI, entity.getRadius());
48
49
  Pt15.sequence = 15;
49
50
 
50
51
  const points = [Pt10, Pt15, Pt11];
@@ -61,10 +62,10 @@ export class DiametricDimension extends BaseCircularDimension {
61
62
  const Pt15 = this.getPointBySequence(this.points, 15);
62
63
 
63
64
  file.writeGroupCode('0', 'DIMENSION');
64
- file.writeGroupCode('5', this.handle, DXFFile.Version.R2000); // Handle
65
+ file.writeGroupCode('5', this.getProperty(Property.Names.HANDLE), DXFFile.Version.R2000); // Handle
65
66
  file.writeGroupCode('100', 'AcDbEntity', DXFFile.Version.R2000);
66
67
  file.writeGroupCode('100', 'AcDbDimension', DXFFile.Version.R2000);
67
- file.writeGroupCode('8', this.layer);
68
+ file.writeGroupCode('8', this.getProperty(Property.Names.LAYER));
68
69
  // file.writeGroupCode('2', this.blockName); // Block not required
69
70
  file.writeGroupCode('10', Pt10.x); // X - Start of Dimension Line
70
71
  file.writeGroupCode('20', Pt10.y); // Y
@@ -73,7 +74,7 @@ export class DiametricDimension extends BaseCircularDimension {
73
74
  file.writeGroupCode('21', Pt11.y); // Y
74
75
  file.writeGroupCode('31', '0.0'); // Z
75
76
  file.writeGroupCode('70', this.dimType.getDimType()); // DIMENSION TYPE
76
- file.writeGroupCode('3', this.dimensionStyle); // DIMENSION STYLE
77
+ file.writeGroupCode('3', this.getProperty(Property.Names.DIMENSIONSTYLE)); // DIMENSION STYLE
77
78
  file.writeGroupCode('100', 'AcDbDiametricDimension', DXFFile.Version.R2000);
78
79
  file.writeGroupCode('15', Pt15.x); // X - End of Dimension Line
79
80
  file.writeGroupCode('25', Pt15.y); // Y