@design-core/core 0.0.7 → 50.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/.github/workflows/DesignCoreQA.yml +3 -0
  2. package/core/designCore.js +1 -1
  3. package/core/dimensions/alignedDimension.js +7 -7
  4. package/core/dimensions/angularDimension.js +32 -32
  5. package/core/dimensions/{baseCircularDimension.js → circularDimensionBase.js} +19 -19
  6. package/core/dimensions/diametricDimension.js +10 -10
  7. package/core/dimensions/dimension.js +42 -42
  8. package/core/dimensions/{baseDimension.js → dimensionBase.js} +17 -17
  9. package/core/dimensions/{baseLinearDimension.js → linearDimensionBase.js} +9 -9
  10. package/core/dimensions/radialDimension.js +8 -8
  11. package/core/dimensions/rotatedDimension.js +8 -8
  12. package/core/entities/arc.js +22 -22
  13. package/core/entities/arctext.js +13 -13
  14. package/core/entities/circle.js +7 -7
  15. package/core/entities/hatch.js +28 -28
  16. package/core/entities/insert.js +5 -5
  17. package/core/entities/point.js +19 -19
  18. package/core/entities/polyline.js +3 -3
  19. package/core/entities/{basePolyline.js → polylineBase.js} +18 -18
  20. package/core/entities/text.js +4 -4
  21. package/core/lib/boundingBox.js +11 -11
  22. package/core/lib/canvas.js +6 -4
  23. package/core/lib/clipboard.js +2 -2
  24. package/core/lib/dxf/dxf.js +11 -11
  25. package/core/lib/dxf/dxfIterator.js +2 -2
  26. package/core/lib/entityManager.js +19 -19
  27. package/core/lib/inputManager.js +1 -1
  28. package/core/lib/matrix.js +1 -1
  29. package/core/lib/patterns.js +1 -1
  30. package/core/lib/polylineUtils.js +9 -9
  31. package/core/lib/renderers/cairoRenderer.js +5 -5
  32. package/core/lib/renderers/canvasRenderer.js +4 -4
  33. package/core/lib/renderers/pdfRenderer.js +7 -7
  34. package/core/lib/renderers/rendererBase.js +1 -1
  35. package/core/lib/scene.js +1 -1
  36. package/core/lib/selectionManager.js +18 -18
  37. package/core/lib/utils.js +5 -5
  38. package/core/properties/property.js +1 -1
  39. package/core/properties/propertyManager.js +37 -37
  40. package/core/tables/block.js +48 -46
  41. package/core/tables/dimStyle.js +5 -5
  42. package/core/tables/ltypeManager.js +1 -1
  43. package/core/tables/vport.js +2 -2
  44. package/core/tools/chamfer.js +6 -6
  45. package/core/tools/chamferFilletBase.js +4 -4
  46. package/core/tools/copy.js +8 -8
  47. package/core/tools/copybase.js +3 -3
  48. package/core/tools/copyclip.js +3 -3
  49. package/core/tools/cornerEntity.js +2 -2
  50. package/core/tools/cutclip.js +3 -3
  51. package/core/tools/explode.js +6 -6
  52. package/core/tools/extend.js +13 -13
  53. package/core/tools/fillet.js +6 -6
  54. package/core/tools/matchProp.js +1 -1
  55. package/core/tools/mirror.js +11 -11
  56. package/core/tools/move.js +5 -5
  57. package/core/tools/offset.js +29 -29
  58. package/core/tools/purge.js +10 -10
  59. package/core/tools/rotate.js +16 -16
  60. package/core/tools/scale.js +6 -6
  61. package/core/tools/trim.js +15 -15
  62. package/cspell.json +321 -0
  63. package/package.json +1 -1
  64. package/test/dimensions/alignedDimension.test.js +3 -3
  65. package/test/dimensions/angularDimension.test.js +7 -7
  66. package/test/dimensions/diametricDimension.test.js +9 -9
  67. package/test/dimensions/dimension.test.js +12 -12
  68. package/test/dimensions/{baseDimension.test.js → dimensionBase.test.js} +12 -12
  69. package/test/dimensions/{baseLinearDimension.test.js → linearDimensionBase.test.js} +7 -7
  70. package/test/dimensions/radialDimension.test.js +9 -9
  71. package/test/dimensions/rotatedDimension.test.js +4 -4
  72. package/test/entities/arc.test.js +10 -10
  73. package/test/entities/arctext.test.js +6 -6
  74. package/test/entities/circle.test.js +18 -18
  75. package/test/entities/hatch.test.js +39 -39
  76. package/test/entities/insert.test.js +9 -9
  77. package/test/entities/point.test.js +3 -3
  78. package/test/entities/{basePolyline.test.js → polylineBase.test.js} +131 -62
  79. package/test/entities/text.test.js +19 -19
  80. package/test/integration/exportIntegration.test.js +3 -3
  81. package/test/integration/userInputIntegration.test.js +5 -5
  82. package/test/lib/boundingBox.test.js +3 -3
  83. package/test/lib/canvas.test.js +9 -9
  84. package/test/lib/inputManager.test.js +4 -4
  85. package/test/lib/scene.test.js +9 -9
  86. package/test/lib/selectionManager.test.js +3 -3
  87. package/test/lib/snapping.test.js +1 -1
  88. package/test/properties/propertyManager.test.js +22 -22
  89. package/test/renderers/pdfRenderer.test.js +2 -2
  90. package/test/tables/block.test.js +63 -14
  91. package/test/tables/layerManager.test.js +2 -2
  92. package/test/test-helpers/hatchGridRenderer.js +3 -3
  93. package/test/test-helpers/test-helpers.js +6 -6
  94. package/test/tools/chamfer.test.js +60 -60
  95. package/test/tools/chamferFilletBase.test.js +36 -36
  96. package/test/tools/copy.test.js +6 -6
  97. package/test/tools/copybase.test.js +2 -2
  98. package/test/tools/copyclip.test.js +2 -2
  99. package/test/tools/cornerEntity.test.js +8 -8
  100. package/test/tools/cutclip.test.js +2 -2
  101. package/test/tools/erase.test.js +6 -6
  102. package/test/tools/explode.test.js +2 -2
  103. package/test/tools/extend.test.js +84 -84
  104. package/test/tools/fillet.test.js +62 -62
  105. package/test/tools/matchProp.test.js +6 -6
  106. package/test/tools/mirror.test.js +26 -26
  107. package/test/tools/move.test.js +7 -7
  108. package/test/tools/offset.test.js +65 -65
  109. package/test/tools/purge.test.js +4 -4
  110. package/test/tools/rotate.test.js +10 -10
  111. package/test/tools/scale.test.js +28 -28
  112. package/test/tools/trim.test.js +109 -109
  113. package/test/tools/zoom.test.js +5 -5
@@ -2,7 +2,7 @@ import { Tool } from './tool.js';
2
2
  import { Strings } from '../lib/strings.js';
3
3
  import { Constants } from '../lib/constants.js';
4
4
  import { Line } from '../entities/line.js';
5
- import { BasePolyline } from '../entities/basePolyline.js';
5
+ import { PolylineBase } from '../entities/polylineBase.js';
6
6
  import { AddState, RemoveState, UpdateState } from '../lib/stateManager.js';
7
7
  import { CornerEntity } from './cornerEntity.js';
8
8
  import { Intersection } from '../lib/intersect.js';
@@ -104,7 +104,7 @@ export class ChamferFilletBase extends Tool {
104
104
  if (index === undefined) return null;
105
105
 
106
106
  const candidate = DesignCore.Scene.entities.get(index);
107
- if (!(candidate instanceof Line) && !(candidate instanceof BasePolyline)) return null;
107
+ if (!(candidate instanceof Line) && !(candidate instanceof PolylineBase)) return null;
108
108
 
109
109
  const tempSecond = new CornerEntity();
110
110
  if (!tempSecond.setPick(candidate, mousePoint, '')) return null;
@@ -143,8 +143,8 @@ export class ChamferFilletBase extends Tool {
143
143
  */
144
144
  applyCornerTrim(firstCornerPoint, secondCornerPoint, newEntity) {
145
145
  const isSharpTrim = newEntity === null;
146
- const firstIsPolyline = this.firstPick.entity instanceof BasePolyline;
147
- const secondIsPolyline = this.secondPick.entity instanceof BasePolyline;
146
+ const firstIsPolyline = this.firstPick.entity instanceof PolylineBase;
147
+ const secondIsPolyline = this.secondPick.entity instanceof PolylineBase;
148
148
 
149
149
  // Two standalone entities: update both, optionally add the new entity.
150
150
  if (!firstIsPolyline && !secondIsPolyline) {
@@ -84,10 +84,10 @@ export class Copy extends Tool {
84
84
  const delta = mousePoint.subtract(this.lastMousePoint || this.points[0]);
85
85
  this.lastMousePoint = mousePoint;
86
86
 
87
- for (let i = 0; i < DesignCore.Scene.selectionManager.selectedItems.length; i++) {
88
- const item = DesignCore.Scene.selectionManager.selectedItems[i];
89
- const offsetPoints = item.points.map((p) => new Point(p.x, p.y, p.bulge, p.sequence).add(delta));
90
- item.setProperty('points', offsetPoints);
87
+ for (let i = 0; i < DesignCore.Scene.selectionManager.selectedEntities.length; i++) {
88
+ const entity = DesignCore.Scene.selectionManager.selectedEntities[i];
89
+ const offsetPoints = entity.points.map((p) => new Point(p.x, p.y, p.bulge, p.sequence).add(delta));
90
+ entity.setProperty('points', offsetPoints);
91
91
  }
92
92
  }
93
93
  }
@@ -103,10 +103,10 @@ export class Copy extends Tool {
103
103
  const stateChanges = [];
104
104
 
105
105
  for (let i = 0; i < DesignCore.Scene.selectionManager.selectionSet.selectionSet.length; i++) {
106
- const copyofitem = Utils.cloneObject(DesignCore.Scene.entities.get(DesignCore.Scene.selectionManager.selectionSet.selectionSet[i]));
107
- const offsetPoints = copyofitem.points.map((p) => new Point(p.x, p.y, p.bulge, p.sequence).add(delta));
108
- copyofitem.setProperty('points', offsetPoints);
109
- const stateChange = new AddState(copyofitem);
106
+ const copyOfEntity = Utils.cloneObject(DesignCore.Scene.entities.get(DesignCore.Scene.selectionManager.selectionSet.selectionSet[i]));
107
+ const offsetPoints = copyOfEntity.points.map((p) => new Point(p.x, p.y, p.bulge, p.sequence).add(delta));
108
+ copyOfEntity.setProperty('points', offsetPoints);
109
+ const stateChange = new AddState(copyOfEntity);
110
110
  stateChanges.push(stateChange);
111
111
  }
112
112
 
@@ -56,11 +56,11 @@ export class Copybase extends Tool {
56
56
  * Perform the command
57
57
  */
58
58
  action() {
59
- // generate clipboard data from selected items
60
- const selectedItems = DesignCore.Scene.selectionManager.selectedItems;
59
+ // generate clipboard data from selected entities
60
+ const selectedEntities = DesignCore.Scene.selectionManager.selectedEntities;
61
61
 
62
62
  // create clipboard data
63
- DesignCore.Clipboard.Entities = selectedItems;
63
+ DesignCore.Clipboard.Entities = selectedEntities;
64
64
  // set base point
65
65
  DesignCore.Clipboard.BasePoint = this.points[0];
66
66
  }
@@ -52,10 +52,10 @@ export class Copyclip extends Tool {
52
52
  * Perform the command
53
53
  */
54
54
  action() {
55
- // generate clipboard data from selected items
56
- const selectedItems = DesignCore.Scene.selectionManager.selectedItems;
55
+ // generate clipboard data from selected entities
56
+ const selectedEntities = DesignCore.Scene.selectionManager.selectedEntities;
57
57
 
58
58
  // create clipboard data
59
- DesignCore.Clipboard.Entities = selectedItems;
59
+ DesignCore.Clipboard.Entities = selectedEntities;
60
60
  }
61
61
  }
@@ -1,5 +1,5 @@
1
1
  import { Line } from '../entities/line.js';
2
- import { BasePolyline } from '../entities/basePolyline.js';
2
+ import { PolylineBase } from '../entities/polylineBase.js';
3
3
 
4
4
  import { DesignCore } from '../designCore.js';
5
5
 
@@ -61,7 +61,7 @@ export class CornerEntity {
61
61
  setPick(entity, clickPoint, arcSegmentErrorMsg) {
62
62
  this.entity = entity;
63
63
  this.clickPoint = clickPoint;
64
- if (!(this.entity instanceof BasePolyline)) {
64
+ if (!(this.entity instanceof PolylineBase)) {
65
65
  this.segment = null;
66
66
  this.segmentIndex = null;
67
67
  return true;
@@ -53,11 +53,11 @@ export class Cutclip extends Tool {
53
53
  * Perform the command
54
54
  */
55
55
  action() {
56
- // generate clipboard data from selected items
57
- const selectedItems = DesignCore.Scene.selectionManager.selectedItems;
56
+ // generate clipboard data from selected entities
57
+ const selectedEntities = DesignCore.Scene.selectionManager.selectedEntities;
58
58
 
59
59
  // create clipboard data
60
- DesignCore.Clipboard.Entities = selectedItems;
60
+ DesignCore.Clipboard.Entities = selectedEntities;
61
61
  // get a copy of the selection set
62
62
  const selections = DesignCore.Scene.selectionManager.selectionSet.selectionSet.slice();
63
63
  // create state changes for each of the selections
@@ -83,23 +83,23 @@ export class Explode extends Tool {
83
83
 
84
84
  // check the insert has a block and
85
85
  // check the block has items
86
- if (insert.block === undefined || insert.block.items.length == 0) {
86
+ if (insert.block === undefined || insert.block.entities.length === 0) {
87
87
  counter++;
88
88
  continue;
89
89
  }
90
90
 
91
91
  const insertPoint = insert.points[0];
92
92
  const block = insert.block;
93
- const blockItems = block.items;
93
+ const blockItems = block.entities;
94
94
 
95
95
  const rotation = Utils.degrees2radians(insert.getProperty('rotation'));
96
96
  const origin = new Point(0, 0);
97
97
 
98
98
  blockItems.forEach((blockItem) => {
99
- const copyofitem = Utils.cloneObject(blockItem);
100
- const points = copyofitem.points.map((p) => new Point(p.x, p.y, p.bulge, p.sequence).rotate(origin, rotation).add(insertPoint));
101
- copyofitem.points = points;
102
- const stateChange = new AddState(copyofitem);
99
+ const copyOfItem = Utils.cloneObject(blockItem);
100
+ const points = copyOfItem.points.map((p) => new Point(p.x, p.y, p.bulge, p.sequence).rotate(origin, rotation).add(insertPoint));
101
+ copyOfItem.points = points;
102
+ const stateChange = new AddState(copyOfItem);
103
103
  stateChanges.push(stateChange);
104
104
  });
105
105
 
@@ -19,7 +19,7 @@ export class Extend extends Tool {
19
19
  /** Create an Extend command */
20
20
  constructor() {
21
21
  super();
22
- this.selectedItem = null;
22
+ this.selectedEntity = null;
23
23
  this.selectedBoundaryItems = [];
24
24
  }
25
25
 
@@ -48,7 +48,7 @@ export class Extend extends Tool {
48
48
  if (boundary === undefined) return;
49
49
  }
50
50
 
51
- // add all selected items to boundary items
51
+ // add all selected entities to boundary items
52
52
  for (let i = 0; i < DesignCore.Scene.selectionManager.selectionSet.selectionSet.length; i++) {
53
53
  const boundaryItem = DesignCore.Scene.entities.get(DesignCore.Scene.selectionManager.selectionSet.selectionSet[i]);
54
54
  this.selectedBoundaryItems.push(boundaryItem);
@@ -58,7 +58,7 @@ export class Extend extends Tool {
58
58
  while (true) {
59
59
  const selection = await DesignCore.Scene.inputManager.requestInput(op2);
60
60
  if (selection === undefined) break;
61
- this.selectedItem = DesignCore.Scene.entities.get(selection.selectedItemIndex);
61
+ this.selectedEntity = DesignCore.Scene.entities.get(selection.selectedEntityIndex);
62
62
  DesignCore.Scene.selectionManager.removeLastSelection();
63
63
  DesignCore.Scene.inputManager.actionCommand();
64
64
  }
@@ -99,28 +99,28 @@ export class Extend extends Tool {
99
99
  * Perform the command
100
100
  */
101
101
  action() {
102
- if (this.selectedItem && this.selectedBoundaryItems.length) {
103
- if (typeof this.selectedItem.fromPolylinePoints !== 'function') {
104
- DesignCore.Core.notify(`${this.type} - ${this.selectedItem.type} ${Strings.Message.NOEXTEND}`);
105
- this.selectedItem = null;
102
+ if (this.selectedEntity && this.selectedBoundaryItems.length) {
103
+ if (typeof this.selectedEntity.fromPolylinePoints !== 'function') {
104
+ DesignCore.Core.notify(`${this.type} - ${this.selectedEntity.type} ${Strings.Message.NOEXTEND}`);
105
+ this.selectedEntity = null;
106
106
  return;
107
107
  }
108
108
 
109
- const intersectPoints = this.#collectIntersectPoints(this.selectedItem);
109
+ const intersectPoints = this.#collectIntersectPoints(this.selectedEntity);
110
110
 
111
111
  if (intersectPoints.length) {
112
- const stateChanges = this.#extendEntity(this.selectedItem, intersectPoints);
112
+ const stateChanges = this.#extendEntity(this.selectedEntity, intersectPoints);
113
113
  if (stateChanges?.length) {
114
114
  DesignCore.Scene.commit(stateChanges);
115
115
  } else {
116
- DesignCore.Core.notify(`${this.type} - ${this.selectedItem.type} ${Strings.Message.NOEXTEND}`);
116
+ DesignCore.Core.notify(`${this.type} - ${this.selectedEntity.type} ${Strings.Message.NOEXTEND}`);
117
117
  }
118
118
  } else {
119
- DesignCore.Core.notify(`${this.type} - ${this.selectedItem.type} ${Strings.Message.NOEXTEND}`);
119
+ DesignCore.Core.notify(`${this.type} - ${this.selectedEntity.type} ${Strings.Message.NOEXTEND}`);
120
120
  }
121
121
  }
122
122
 
123
- this.selectedItem = null;
123
+ this.selectedEntity = null;
124
124
  }
125
125
 
126
126
  /**
@@ -147,7 +147,7 @@ export class Extend extends Tool {
147
147
  * Compute a state change to extend entity to the nearest valid boundary
148
148
  * intersection. Operates entirely in polyline-point space via
149
149
  * entity.toPolylinePoints() / entity.fromPolylinePoints(), so it works for
150
- * any entity that implements that protocol (Line, BasePolyline, and future
150
+ * any entity that implements that protocol (Line, PolylineBase, and future
151
151
  * entities such as Spline or Ellipse).
152
152
  * Only straight end-segments (bulge === 0) can be extended.
153
153
  * @param {Object} entity
@@ -5,7 +5,7 @@ import { Logging } from '../lib/logging.js';
5
5
  import { Constants } from '../lib/constants.js';
6
6
  import { Utils } from '../lib/utils.js';
7
7
  import { Line } from '../entities/line.js';
8
- import { BasePolyline } from '../entities/basePolyline.js';
8
+ import { PolylineBase } from '../entities/polylineBase.js';
9
9
  import { AddState } from '../lib/stateManager.js';
10
10
  import { Colour } from '../lib/colour.js';
11
11
 
@@ -65,9 +65,9 @@ export class Fillet extends ChamferFilletBase {
65
65
  }
66
66
 
67
67
  // input1 is a selection — validate and store first entity
68
- const firstEntity = DesignCore.Scene.entities.get(input1.selectedItemIndex);
68
+ const firstEntity = DesignCore.Scene.entities.get(input1.selectedEntityIndex);
69
69
  DesignCore.Scene.selectionManager.removeLastSelection();
70
- if (!(firstEntity instanceof Line) && !(firstEntity instanceof BasePolyline)) {
70
+ if (!(firstEntity instanceof Line) && !(firstEntity instanceof PolylineBase)) {
71
71
  DesignCore.Core.notify(`${this.type} - ${firstEntity.type} ${Strings.Message.NOFILLET}`);
72
72
  continue;
73
73
  }
@@ -79,16 +79,16 @@ export class Fillet extends ChamferFilletBase {
79
79
  const input2 = await DesignCore.Scene.inputManager.requestInput(op2);
80
80
  if (input2 === undefined) return;
81
81
 
82
- const candidate = DesignCore.Scene.entities.get(input2.selectedItemIndex);
82
+ const candidate = DesignCore.Scene.entities.get(input2.selectedEntityIndex);
83
83
  DesignCore.Scene.selectionManager.removeLastSelection();
84
- if (!(candidate instanceof Line) && !(candidate instanceof BasePolyline)) {
84
+ if (!(candidate instanceof Line) && !(candidate instanceof PolylineBase)) {
85
85
  DesignCore.Core.notify(`${this.type} - ${candidate.type} ${Strings.Message.NOFILLET}`);
86
86
  continue;
87
87
  }
88
88
  if (!this.secondPick.setPick(candidate, input2.selectedPoint, `${Strings.Strings.ARC} - ${Strings.Message.NOFILLET}`)) continue;
89
89
  // If both selections are the same polyline, segments must be consecutive
90
90
  // or they must be the open-end segments of an open polyline.
91
- if (candidate === firstEntity && firstEntity instanceof BasePolyline) {
91
+ if (candidate === firstEntity && firstEntity instanceof PolylineBase) {
92
92
  const isConsecutive = firstEntity.areConsecutiveSegments(this.firstPick.segmentIndex, this.secondPick.segmentIndex);
93
93
  const lastIdx = firstEntity.points.length - 1;
94
94
  const isOpenEnds = !firstEntity.flags.hasFlag(1) &&
@@ -48,7 +48,7 @@ export class MatchProp extends Tool {
48
48
  const sourceSelection = new PromptOptions(Strings.Input.SOURCE, [Input.Type.SINGLESELECTION], []);
49
49
  const input = await DesignCore.Scene.inputManager.requestInput(sourceSelection);
50
50
  if (input === undefined) return;
51
- this.sourceIndex = input.selectedItemIndex;
51
+ this.sourceIndex = input.selectedEntityIndex;
52
52
  }
53
53
 
54
54
  const destinationSelection = new PromptOptions(Strings.Input.DESTINATIONSET, [Input.Type.SELECTIONSET]);
@@ -80,13 +80,13 @@ export class Mirror extends Tool {
80
80
 
81
81
  // Preview mirrored entities (skip if mirror line has zero length)
82
82
  if (!pt1.isSame(pt2)) {
83
- for (let i = 0; i < DesignCore.Scene.selectionManager.selectedItems.length; i++) {
84
- const item = DesignCore.Scene.selectionManager.selectedItems[i];
83
+ for (let i = 0; i < DesignCore.Scene.selectionManager.selectedEntities.length; i++) {
84
+ const entity = DesignCore.Scene.selectionManager.selectedEntities[i];
85
85
  const entityIndex = DesignCore.Scene.selectionManager.selectionSet.selectionSet[i];
86
- const originalItem = DesignCore.Scene.entities.get(entityIndex);
87
- item.setProperty('points', this.getMirroredPoints(originalItem.points, pt1, pt2));
88
- if (originalItem.properties?.has('direction')) {
89
- item.setProperty('direction', -originalItem.getProperty('direction'));
86
+ const originalEntity = DesignCore.Scene.entities.get(entityIndex);
87
+ entity.setProperty('points', this.getMirroredPoints(originalEntity.points, pt1, pt2));
88
+ if (originalEntity.properties?.has('direction')) {
89
+ entity.setProperty('direction', -originalEntity.getProperty('direction'));
90
90
  }
91
91
  }
92
92
  }
@@ -109,18 +109,18 @@ export class Mirror extends Tool {
109
109
 
110
110
  for (let i = 0; i < DesignCore.Scene.selectionManager.selectionSet.selectionSet.length; i++) {
111
111
  const entityIndex = DesignCore.Scene.selectionManager.selectionSet.selectionSet[i];
112
- const item = DesignCore.Scene.entities.get(entityIndex);
113
- const mirroredPoints = this.getMirroredPoints(item.points, pt1, pt2);
112
+ const entity = DesignCore.Scene.entities.get(entityIndex);
113
+ const mirroredPoints = this.getMirroredPoints(entity.points, pt1, pt2);
114
114
 
115
115
  if (this.eraseSource) {
116
116
  // Replace the original with its mirrored version
117
117
  const updates = { points: mirroredPoints };
118
- if (item.properties?.has('direction')) updates.direction = -item.getProperty('direction');
119
- const stateChange = new UpdateState(item, updates);
118
+ if (entity.properties?.has('direction')) updates.direction = -entity.getProperty('direction');
119
+ const stateChange = new UpdateState(entity, updates);
120
120
  stateChanges.push(stateChange);
121
121
  } else {
122
122
  // Keep the original and add a mirrored copy
123
- const copyOfItem = Utils.cloneObject(item);
123
+ const copyOfItem = Utils.cloneObject(entity);
124
124
  copyOfItem.setProperty('points', mirroredPoints);
125
125
  if (copyOfItem.properties?.has('direction')) copyOfItem.setProperty('direction', -copyOfItem.getProperty('direction'));
126
126
  const stateChange = new AddState(copyOfItem);
@@ -74,9 +74,9 @@ export class Move extends Tool {
74
74
  const delta = mousePoint.subtract(this.lastMousePoint || this.points[0]);
75
75
  this.lastMousePoint = mousePoint;
76
76
 
77
- for (let i = 0; i < DesignCore.Scene.selectionManager.selectedItems.length; i++) {
78
- const item = DesignCore.Scene.selectionManager.selectedItems[i];
79
- item.setProperty('points', this.getOffsetPoints(item.points, delta));
77
+ for (let i = 0; i < DesignCore.Scene.selectionManager.selectedEntities.length; i++) {
78
+ const entity = DesignCore.Scene.selectionManager.selectedEntities[i];
79
+ entity.setProperty('points', this.getOffsetPoints(entity.points, delta));
80
80
  }
81
81
  }
82
82
  }
@@ -94,8 +94,8 @@ export class Move extends Tool {
94
94
 
95
95
  for (let i = 0; i < DesignCore.Scene.selectionManager.selectionSet.selectionSet.length; i++) {
96
96
  const index = DesignCore.Scene.selectionManager.selectionSet.selectionSet[i];
97
- const item = DesignCore.Scene.entities.get(index);
98
- const stateChange = new UpdateState(item, { points: this.getOffsetPoints(item.points, delta) });
97
+ const entity = DesignCore.Scene.entities.get(index);
98
+ const stateChange = new UpdateState(entity, { points: this.getOffsetPoints(entity.points, delta) });
99
99
  stateChanges.push(stateChange);
100
100
  }
101
101
 
@@ -19,7 +19,7 @@ export class Offset extends Tool {
19
19
  /** Create an Offset command */
20
20
  constructor() {
21
21
  super();
22
- this.selectedItem = null;
22
+ this.selectedEntity = null;
23
23
  }
24
24
 
25
25
  /**
@@ -67,28 +67,28 @@ export class Offset extends Tool {
67
67
  while (true) {
68
68
  const preselected = DesignCore.Scene.selectionManager.selectionSet.selectionSet;
69
69
  if (preselected.length === 1) {
70
- this.selectedItem = DesignCore.Scene.entities.get(preselected[0]);
70
+ this.selectedEntity = DesignCore.Scene.entities.get(preselected[0]);
71
71
  DesignCore.Scene.selectionManager.reset();
72
72
  } else {
73
73
  DesignCore.Scene.selectionManager.reset();
74
74
  const selection = await DesignCore.Scene.inputManager.requestInput(op2);
75
75
  if (selection === undefined) break;
76
- this.selectedItem = DesignCore.Scene.entities.get(selection.selectedItemIndex);
76
+ this.selectedEntity = DesignCore.Scene.entities.get(selection.selectedEntityIndex);
77
77
  DesignCore.Scene.selectionManager.removeLastSelection();
78
78
  }
79
79
 
80
80
  const point = await DesignCore.Scene.inputManager.requestInput(op3);
81
81
  if (point === undefined) {
82
- this.selectedItem = null;
82
+ this.selectedEntity = null;
83
83
  break;
84
84
  }
85
85
 
86
86
  if (throughMode) {
87
- DesignCore.Scene.headers.offsetDistance = this.getThroughDistance(this.selectedItem, point);
87
+ DesignCore.Scene.headers.offsetDistance = this.getThroughDistance(this.selectedEntity, point);
88
88
  }
89
89
  this.points = [point];
90
90
  DesignCore.Scene.inputManager.actionCommand();
91
- this.selectedItem = null;
91
+ this.selectedEntity = null;
92
92
  }
93
93
 
94
94
  DesignCore.Scene.inputManager.reset();
@@ -102,12 +102,12 @@ export class Offset extends Tool {
102
102
  */
103
103
  preview() {
104
104
  const offsetDistance = DesignCore.Scene.headers.offsetDistance;
105
- if (this.selectedItem && offsetDistance > 0) {
105
+ if (this.selectedEntity && offsetDistance > 0) {
106
106
  const mousePoint = DesignCore.Mouse.pointOnScene();
107
- const offsetPoints = this.getOffsetPoints(this.selectedItem, mousePoint, offsetDistance);
107
+ const offsetPoints = this.getOffsetPoints(this.selectedEntity, mousePoint, offsetDistance);
108
108
 
109
109
  if (offsetPoints) {
110
- const previewEntity = Utils.cloneObject(this.selectedItem).fromPolylinePoints(offsetPoints);
110
+ const previewEntity = Utils.cloneObject(this.selectedEntity).fromPolylinePoints(offsetPoints);
111
111
  DesignCore.Scene.previewEntities.add(previewEntity);
112
112
  }
113
113
  }
@@ -118,10 +118,10 @@ export class Offset extends Tool {
118
118
  */
119
119
  action() {
120
120
  const offsetDistance = DesignCore.Scene.headers.offsetDistance;
121
- if (!this.selectedItem || offsetDistance <= 0) return;
121
+ if (!this.selectedEntity || offsetDistance <= 0) return;
122
122
 
123
123
  const sidePoint = this.points[0];
124
- const entity = this.selectedItem;
124
+ const entity = this.selectedEntity;
125
125
  const offsetPoints = this.getOffsetPoints(entity, sidePoint, offsetDistance);
126
126
 
127
127
  if (!offsetPoints) {
@@ -187,20 +187,20 @@ export class Offset extends Tool {
187
187
  sign = cross >= 0 ? 1 : -1;
188
188
  }
189
189
  } else {
190
- const center = A.bulgeCentrePoint(B);
191
- const currentRadius = center.distance(A);
190
+ const centre = A.bulgeCentrePoint(B);
191
+ const currentRadius = centre.distance(A);
192
192
  const arcDir = A.bulge > 0 ? 1 : -1;
193
- const closestPt = sidePoint.closestPointOnArc(A, B, center, arcDir);
193
+ const closestPt = sidePoint.closestPointOnArc(A, B, centre, arcDir);
194
194
  if (closestPt === null) continue;
195
195
  const dist = sidePoint.distance(closestPt);
196
196
  if (dist < minDist) {
197
197
  minDist = dist;
198
- const distToCenter = center.distance(sidePoint);
199
- // For CCW arc (arcDir>0): left of travel = toward center (smaller radius)
200
- // For CW arc (arcDir<0): left of travel = away from center (larger radius)
198
+ const distToCentre = centre.distance(sidePoint);
199
+ // For CCW arc (arcDir>0): left of travel = toward centre (smaller radius)
200
+ // For CW arc (arcDir<0): left of travel = away from centre (larger radius)
201
201
  sign = arcDir > 0 ?
202
- (distToCenter < currentRadius ? 1 : -1) :
203
- (distToCenter >= currentRadius ? 1 : -1);
202
+ (distToCentre < currentRadius ? 1 : -1) :
203
+ (distToCentre >= currentRadius ? 1 : -1);
204
204
  }
205
205
  }
206
206
  }
@@ -221,19 +221,19 @@ export class Offset extends Tool {
221
221
  bulge: 0,
222
222
  });
223
223
  } else {
224
- const center = A.bulgeCentrePoint(B);
225
- const currentRadius = center.distance(A);
224
+ const centre = A.bulgeCentrePoint(B);
225
+ const currentRadius = centre.distance(A);
226
226
  const arcDir = A.bulge > 0 ? 1 : -1;
227
227
  const newRadius = currentRadius - arcDir * distance * sign;
228
228
  if (newRadius <= 0) return null;
229
- const startAngle = Math.atan2(A.y - center.y, A.x - center.x);
230
- const endAngle = Math.atan2(B.y - center.y, B.x - center.x);
229
+ const startAngle = Math.atan2(A.y - centre.y, A.x - centre.x);
230
+ const endAngle = Math.atan2(B.y - centre.y, B.x - centre.x);
231
231
  offsetSegs.push({
232
232
  type: 'arc',
233
- A: new Point(center.x + newRadius * Math.cos(startAngle), center.y + newRadius * Math.sin(startAngle)),
234
- B: new Point(center.x + newRadius * Math.cos(endAngle), center.y + newRadius * Math.sin(endAngle)),
233
+ A: new Point(centre.x + newRadius * Math.cos(startAngle), centre.y + newRadius * Math.sin(startAngle)),
234
+ B: new Point(centre.x + newRadius * Math.cos(endAngle), centre.y + newRadius * Math.sin(endAngle)),
235
235
  bulge: A.bulge,
236
- center,
236
+ centre,
237
237
  radius: newRadius,
238
238
  });
239
239
  }
@@ -309,9 +309,9 @@ export class Offset extends Tool {
309
309
  const dist = throughPoint.distance(closest);
310
310
  if (dist < minDist) minDist = dist;
311
311
  } else {
312
- const center = A.bulgeCentrePoint(B);
313
- const radius = center.distance(A);
314
- const dist = Math.abs(center.distance(throughPoint) - radius);
312
+ const centre = A.bulgeCentrePoint(B);
313
+ const radius = centre.distance(A);
314
+ const dist = Math.abs(centre.distance(throughPoint) - radius);
315
315
  if (dist < minDist) minDist = dist;
316
316
  }
317
317
  }
@@ -60,31 +60,31 @@ export class Purge extends Tool {
60
60
  let purgedCount = 0;
61
61
 
62
62
  if (this.option === 'Blocks' || this.option === 'All') {
63
- const intialitemCount = DesignCore.Scene.blockManager.itemCount();
63
+ const initialItemCount = DesignCore.Scene.blockManager.itemCount();
64
64
  DesignCore.Scene.blockManager.purge();
65
- const finalitemCount = DesignCore.Scene.blockManager.itemCount();
66
- purgedCount += (intialitemCount - finalitemCount);
65
+ const finalItemCount = DesignCore.Scene.blockManager.itemCount();
66
+ purgedCount += (initialItemCount - finalItemCount);
67
67
  }
68
68
 
69
69
  if (this.option === 'Dimstyles' || this.option === 'All') {
70
- const intialitemCount = DesignCore.DimStyleManager.itemCount();
70
+ const initialItemCount = DesignCore.DimStyleManager.itemCount();
71
71
  DesignCore.DimStyleManager.purge();
72
- const finalitemCount = DesignCore.DimStyleManager.itemCount();
73
- purgedCount += (intialitemCount - finalitemCount);
72
+ const finalItemCount = DesignCore.DimStyleManager.itemCount();
73
+ purgedCount += (initialItemCount - finalItemCount);
74
74
  }
75
75
 
76
76
  if (this.option === 'Layers' || this.option === 'All') {
77
- const intialLayerCount = DesignCore.LayerManager.itemCount();
77
+ const initialLayerCount = DesignCore.LayerManager.itemCount();
78
78
  DesignCore.LayerManager.purge();
79
79
  const finalLayerCount = DesignCore.LayerManager.itemCount();
80
- purgedCount += (intialLayerCount - finalLayerCount);
80
+ purgedCount += (initialLayerCount - finalLayerCount);
81
81
  }
82
82
 
83
83
  if (this.option === 'LTypes' || this.option === 'All') {
84
- const intialLTypeCount = DesignCore.LTypeManager.itemCount();
84
+ const initialLTypeCount = DesignCore.LTypeManager.itemCount();
85
85
  DesignCore.LTypeManager.purge();
86
86
  const finalLTypeCount = DesignCore.LTypeManager.itemCount();
87
- purgedCount += (intialLTypeCount - finalLTypeCount);
87
+ purgedCount += (initialLTypeCount - finalLTypeCount);
88
88
  }
89
89
 
90
90
  DesignCore.Core.notify(`${this.type} - ${this.option}: ${purgedCount} ${Strings.Strings.ITEMS} ${Strings.Strings.REMOVED}`);
@@ -73,7 +73,7 @@ export class Rotate extends Tool {
73
73
  this.baseAngle = refBase.angle(refEnd);
74
74
  // set the base point to null
75
75
  this.basePoint = null;
76
- // restore inputPoint to the rotation center so the tracking line
76
+ // restore inputPoint to the rotation centre so the tracking line
77
77
  // uses the correct origin for the final angle input
78
78
  DesignCore.Scene.inputManager.inputPoint = this.points[0];
79
79
  } else if (Input.getType(input2) === Input.Type.NUMBER) {
@@ -99,22 +99,22 @@ export class Rotate extends Tool {
99
99
  const mousePoint = DesignCore.Mouse.pointOnScene();
100
100
 
101
101
  if (this.points.length >= 1 && this.baseAngle !== null || this.basePoint !== null) {
102
- // Draw a rubber-band line from center to mouse
103
- const center = this.basePoint === null ? this.points.at(0) : this.basePoint;
104
- DesignCore.Scene.auxiliaryEntities.add(new RubberBand([center, mousePoint]));
102
+ // Draw a rubber-band line from centre to mouse
103
+ const centre = this.basePoint === null ? this.points.at(0) : this.basePoint;
104
+ DesignCore.Scene.auxiliaryEntities.add(new RubberBand([centre, mousePoint]));
105
105
  }
106
106
 
107
107
  if (this.points.length >= 1) {
108
108
  const ang = this.points[0].angle(mousePoint);
109
109
  const theta = this.baseAngle === null ? 0 : ang - this.baseAngle;
110
- const center = this.points[0];
110
+ const centre = this.points[0];
111
111
 
112
- for (let i = 0; i < DesignCore.Scene.selectionManager.selectedItems.length; i++) {
113
- const item = DesignCore.Scene.selectionManager.selectedItems[i];
112
+ for (let i = 0; i < DesignCore.Scene.selectionManager.selectedEntities.length; i++) {
113
+ const entity = DesignCore.Scene.selectionManager.selectedEntities[i];
114
114
  // get the original points from the scene entities
115
115
  const entityIndex = DesignCore.Scene.selectionManager.selectionSet.selectionSet[i];
116
- const originalItem = DesignCore.Scene.entities.get(entityIndex);
117
- item.setProperty('points', this.getRotatedPoints(originalItem.points, center, theta));
116
+ const originalEntity = DesignCore.Scene.entities.get(entityIndex);
117
+ entity.setProperty('points', this.getRotatedPoints(originalEntity.points, centre, theta));
118
118
  }
119
119
  }
120
120
  };
@@ -125,13 +125,13 @@ export class Rotate extends Tool {
125
125
  action() {
126
126
  const ang = this.points[0].angle(this.points[1]);
127
127
  const theta = ang - this.baseAngle;
128
- const center = this.points[0];
128
+ const centre = this.points[0];
129
129
 
130
130
  const stateChanges = [];
131
131
 
132
132
  for (let index = 0; index < DesignCore.Scene.selectionManager.selectionSet.selectionSet.length; index++) {
133
- const item = DesignCore.Scene.entities.get(DesignCore.Scene.selectionManager.selectionSet.selectionSet[index]);
134
- const stateChange = new UpdateState(item, { points: this.getRotatedPoints(item.points, center, theta) });
133
+ const entity = DesignCore.Scene.entities.get(DesignCore.Scene.selectionManager.selectionSet.selectionSet[index]);
134
+ const stateChange = new UpdateState(entity, { points: this.getRotatedPoints(entity.points, centre, theta) });
135
135
  stateChanges.push(stateChange);
136
136
  }
137
137
 
@@ -141,12 +141,12 @@ export class Rotate extends Tool {
141
141
  /**
142
142
  * Get rotated points
143
143
  * @param {Array} points
144
- * @param {Point} center
145
- * @param {Point} theta
144
+ * @param {Point} centre
145
+ * @param {number} theta
146
146
  * @return {Array} rotatedPoints
147
147
  */
148
- getRotatedPoints(points, center, theta) {
149
- const rotatedPoints = points.map((p) => new Point(p.x, p.y, p.bulge, p.sequence).rotate(center, theta));
148
+ getRotatedPoints(points, centre, theta) {
149
+ const rotatedPoints = points.map((p) => new Point(p.x, p.y, p.bulge, p.sequence).rotate(centre, theta));
150
150
  return rotatedPoints;
151
151
  }
152
152
  }
@@ -130,11 +130,11 @@ export class Scale extends Tool {
130
130
 
131
131
  const factor = this.referenceLength !== null ? distance / this.referenceLength : distance;
132
132
 
133
- for (let i = 0; i < DesignCore.Scene.selectionManager.selectedItems.length; i++) {
134
- const item = DesignCore.Scene.selectionManager.selectedItems[i];
133
+ for (let i = 0; i < DesignCore.Scene.selectionManager.selectedEntities.length; i++) {
134
+ const entity = DesignCore.Scene.selectionManager.selectedEntities[i];
135
135
  const entityIndex = DesignCore.Scene.selectionManager.selectionSet.selectionSet[i];
136
- const originalItem = DesignCore.Scene.entities.get(entityIndex);
137
- item.setProperty('points', this.getScaledPoints(originalItem.points, base, factor));
136
+ const originalEntity = DesignCore.Scene.entities.get(entityIndex);
137
+ entity.setProperty('points', this.getScaledPoints(originalEntity.points, base, factor));
138
138
  }
139
139
  }
140
140
  }
@@ -147,8 +147,8 @@ export class Scale extends Tool {
147
147
  const stateChanges = [];
148
148
 
149
149
  for (let i = 0; i < DesignCore.Scene.selectionManager.selectionSet.selectionSet.length; i++) {
150
- const item = DesignCore.Scene.entities.get(DesignCore.Scene.selectionManager.selectionSet.selectionSet[i]);
151
- const stateChange = new UpdateState(item, { points: this.getScaledPoints(item.points, base, this.scaleFactor) });
150
+ const entity = DesignCore.Scene.entities.get(DesignCore.Scene.selectionManager.selectionSet.selectionSet[i]);
151
+ const stateChange = new UpdateState(entity, { points: this.getScaledPoints(entity.points, base, this.scaleFactor) });
152
152
  stateChanges.push(stateChange);
153
153
  }
154
154