@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.
Files changed (254) hide show
  1. package/.eslintrc.json +14 -7
  2. package/.github/workflows/DesignCoreQA.yml +3 -1
  3. package/README.md +11 -4
  4. package/TODO.md +19 -0
  5. package/core/core/core.js +49 -42
  6. package/core/designCore.js +61 -2
  7. package/core/dimensions/alignedDimension.js +142 -0
  8. package/core/dimensions/angularDimension.js +550 -0
  9. package/core/dimensions/baseCircularDimension.js +244 -0
  10. package/core/dimensions/baseDimension.js +558 -0
  11. package/core/dimensions/baseLinearDimension.js +371 -0
  12. package/core/dimensions/diametricDimension.js +82 -0
  13. package/core/dimensions/dimension.js +298 -0
  14. package/core/dimensions/linearDimension.js +29 -0
  15. package/core/dimensions/radialDimension.js +78 -0
  16. package/core/dimensions/rotatedDimension.js +167 -0
  17. package/core/entities/arc.js +314 -60
  18. package/core/entities/arctext.js +642 -0
  19. package/core/entities/basePolyline.js +553 -94
  20. package/core/entities/circle.js +181 -54
  21. package/core/entities/entity.js +154 -74
  22. package/core/entities/hatch.js +807 -0
  23. package/core/entities/insert.js +200 -39
  24. package/core/entities/line.js +196 -134
  25. package/core/entities/lwpolyline.js +21 -44
  26. package/core/entities/point.js +194 -29
  27. package/core/entities/polyline.js +54 -7
  28. package/core/entities/rectangle.js +43 -13
  29. package/core/entities/solid.js +43 -6
  30. package/core/entities/text.js +324 -181
  31. package/core/lib/boundingBox.js +73 -13
  32. package/core/lib/canvas.js +256 -65
  33. package/core/lib/clipboard.js +198 -0
  34. package/core/lib/colour.js +144 -0
  35. package/core/lib/colours.js +367 -301
  36. package/core/lib/commandLine.js +16 -28
  37. package/core/lib/commandManager.js +115 -58
  38. package/core/lib/constants.js +23 -0
  39. package/core/lib/dxf/dxf.js +249 -34
  40. package/core/lib/dxf/dxfFile.js +23 -38
  41. package/core/lib/dxf/dxfIterator.js +17 -5
  42. package/core/lib/dxf/dxfRead.js +23 -7
  43. package/core/lib/dxf/dxfWrite.js +39 -129
  44. package/core/lib/dxf/handleManager.js +97 -0
  45. package/core/lib/dxf/sections/blocks.js +16 -2
  46. package/core/lib/dxf/sections/entities.js +17 -3
  47. package/core/lib/dxf/sections/header.js +10 -1
  48. package/core/lib/dxf/sections/objects.js +36 -0
  49. package/core/lib/dxf/sections/section.js +43 -5
  50. package/core/lib/dxf/sections/tables.js +17 -3
  51. package/core/lib/entityManager.js +178 -0
  52. package/core/lib/fileio.js +14 -4
  53. package/core/lib/headers.js +229 -0
  54. package/core/lib/input.js +46 -0
  55. package/core/lib/inputManager.js +199 -194
  56. package/core/lib/intersect.js +341 -468
  57. package/core/lib/logging.js +25 -1
  58. package/core/lib/matrix.js +6 -8
  59. package/core/lib/mouse.js +24 -79
  60. package/core/lib/patterns.js +690 -0
  61. package/core/lib/promptOptions.js +133 -0
  62. package/core/lib/scene.js +71 -174
  63. package/core/lib/selectionManager.js +74 -48
  64. package/core/lib/selectionWindow.js +24 -10
  65. package/core/lib/settings.js +18 -11
  66. package/core/lib/snapping.js +129 -21
  67. package/core/lib/stateManager.js +288 -0
  68. package/core/lib/strings.js +57 -5
  69. package/core/lib/utils.js +95 -11
  70. package/core/objects/dictionary.js +43 -0
  71. package/core/objects/dictionaryManager.js +80 -0
  72. package/core/properties/dimType.js +117 -0
  73. package/core/properties/flags.js +66 -0
  74. package/core/properties/property.js +26 -0
  75. package/core/properties/propertyManager.js +65 -19
  76. package/core/tables/appId.js +31 -0
  77. package/core/tables/appIdManager.js +44 -0
  78. package/core/tables/block.js +323 -0
  79. package/core/tables/blockManager.js +48 -0
  80. package/core/tables/blockRecord.js +29 -0
  81. package/core/tables/blockRecordManager.js +37 -0
  82. package/core/tables/dimStyle.js +627 -0
  83. package/core/tables/dimStyleManager.js +187 -0
  84. package/core/tables/endblk.js +28 -0
  85. package/core/tables/layer.js +219 -0
  86. package/core/tables/layerManager.js +47 -0
  87. package/core/tables/ltype.js +85 -0
  88. package/core/tables/ltypeManager.js +65 -0
  89. package/core/tables/style.js +145 -0
  90. package/core/tables/styleManager.js +55 -0
  91. package/core/tables/styleManagerBase.js +110 -0
  92. package/core/tables/tableManagerBase.js +354 -0
  93. package/core/tables/ucs.js +28 -0
  94. package/core/tables/ucsManager.js +44 -0
  95. package/core/tables/view.js +28 -0
  96. package/core/tables/viewManager.js +44 -0
  97. package/core/tables/vport.js +70 -0
  98. package/core/tables/vportManager.js +65 -0
  99. package/core/tools/chamfer.js +343 -0
  100. package/core/tools/chamferFilletBase.js +162 -0
  101. package/core/tools/copy.js +68 -40
  102. package/core/tools/copybase.js +65 -0
  103. package/core/tools/copyclip.js +59 -0
  104. package/core/tools/cornerEntity.js +138 -0
  105. package/core/tools/cutclip.js +72 -0
  106. package/core/tools/distance.js +37 -9
  107. package/core/tools/erase.js +43 -13
  108. package/core/tools/explode.js +117 -0
  109. package/core/tools/extend.js +71 -32
  110. package/core/tools/fillet.js +336 -0
  111. package/core/tools/identify.js +33 -6
  112. package/core/tools/matchProp.js +106 -0
  113. package/core/tools/mirror.js +141 -0
  114. package/core/tools/move.js +65 -32
  115. package/core/tools/offset.js +321 -0
  116. package/core/tools/pan.js +54 -0
  117. package/core/tools/pasteclip.js +93 -0
  118. package/core/tools/purge.js +90 -0
  119. package/core/tools/rotate.js +105 -70
  120. package/core/tools/scale.js +166 -0
  121. package/core/tools/tool.js +14 -4
  122. package/core/tools/trim.js +71 -32
  123. package/core/tools/zoom.js +152 -0
  124. package/package.json +3 -305
  125. package/test/dimensions/alignedDimension.test.js +211 -0
  126. package/test/dimensions/angularDimension.test.js +243 -0
  127. package/test/dimensions/baseDimension.test.js +239 -0
  128. package/test/dimensions/diametricDimension.test.js +203 -0
  129. package/test/dimensions/dimension.test.js +102 -0
  130. package/test/dimensions/radialDimension.test.js +203 -0
  131. package/test/dimensions/rotatedDimension.test.js +224 -0
  132. package/test/entities/arc.test.js +463 -41
  133. package/test/entities/arctext.test.js +329 -0
  134. package/test/entities/basePolyline.test.js +459 -10
  135. package/test/entities/circle.test.js +312 -7
  136. package/test/entities/entity.test.js +28 -9
  137. package/test/entities/hatch.test.js +606 -0
  138. package/test/entities/insert.test.js +90 -0
  139. package/test/entities/line.test.js +182 -6
  140. package/test/entities/point.test.js +375 -37
  141. package/test/entities/solid.test.js +156 -0
  142. package/test/entities/text.test.js +533 -7
  143. package/test/integration/exportIntegration.reference.dxf +1706 -0
  144. package/test/integration/exportIntegration.test.js +186 -0
  145. package/test/integration/importExportIntegration.test.js +126 -0
  146. package/test/integration/intersectionIntegration.test.js +880 -0
  147. package/test/integration/userInputIntegration.reference.dxf +1410 -0
  148. package/test/integration/userInputIntegration.test.js +269 -0
  149. package/test/lib/boundingBox.test.js +26 -2
  150. package/test/lib/canvas.test.js +613 -5
  151. package/test/lib/clipboard.test.js +70 -0
  152. package/test/lib/colour.test.js +114 -0
  153. package/test/lib/colours.test.js +63 -18
  154. package/test/lib/commandLine.test.js +159 -22
  155. package/test/lib/commandManager.test.js +4 -4
  156. package/test/lib/constants.test.js +9 -0
  157. package/test/lib/dxf/dxfFile.test.js +6 -2
  158. package/test/lib/dxf/dxfIterator.test.js +1 -1
  159. package/test/lib/dxf/dxfWrite.test.js +173 -0
  160. package/test/lib/dxf/handleManager.test.js +137 -0
  161. package/test/lib/dxf/sections/blocks.test.js +5 -5
  162. package/test/lib/dxf/sections/entities.test.js +4 -4
  163. package/test/lib/dxf/sections/header.test.js +18 -4
  164. package/test/lib/dxf/sections/objects.test.js +132 -0
  165. package/test/lib/dxf/sections/section.test.js +29 -29
  166. package/test/lib/dxf/sections/tables.test.js +3 -3
  167. package/test/lib/entityManager.test.js +163 -0
  168. package/test/lib/headers.test.js +233 -0
  169. package/test/lib/inputManager.test.js +1144 -5
  170. package/test/lib/intersect.test.js +454 -331
  171. package/test/lib/logging.test.js +1 -1
  172. package/test/lib/matrix.test.js +1 -1
  173. package/test/lib/mouse.test.js +327 -4
  174. package/test/lib/patterns.test.js +105 -0
  175. package/test/lib/promptOptions.test.js +179 -0
  176. package/test/lib/scene.test.js +16 -52
  177. package/test/lib/selectionManager.test.js +17 -5
  178. package/test/lib/settings.test.js +111 -5
  179. package/test/lib/snapping.test.js +142 -4
  180. package/test/lib/stateManager.test.js +155 -0
  181. package/test/lib/utils.test.js +81 -1
  182. package/test/objects/dictionary.test.js +81 -0
  183. package/test/objects/dictionaryManager.test.js +34 -0
  184. package/test/properties/dimType.test.js +62 -0
  185. package/test/properties/flags.test.js +164 -0
  186. package/test/properties/property.test.js +13 -0
  187. package/test/properties/propertyManager.test.js +10 -11
  188. package/test/tables/appId.test.js +46 -0
  189. package/test/tables/appIdManager.test.js +72 -0
  190. package/test/tables/block.test.js +157 -0
  191. package/test/tables/blockManager.test.js +52 -0
  192. package/test/tables/blockRecord.test.js +39 -0
  193. package/test/tables/blockRecordManager.test.js +60 -0
  194. package/test/tables/dimstyle.test.js +72 -0
  195. package/test/tables/endblk.test.js +30 -0
  196. package/test/tables/layer.test.js +95 -0
  197. package/test/tables/layerManager.test.js +172 -0
  198. package/test/{styles → tables}/ltype.test.js +7 -7
  199. package/test/{styles → tables}/ltypeManager.test.js +2 -2
  200. package/test/tables/style.test.js +44 -0
  201. package/test/tables/stylemanagerbase.test.js +220 -0
  202. package/test/tables/tableManagerBase.test.js +194 -0
  203. package/test/tables/ucs.test.js +37 -0
  204. package/test/tables/ucsManager.test.js +48 -0
  205. package/test/tables/view.test.js +37 -0
  206. package/test/tables/viewManager.test.js +48 -0
  207. package/test/tables/vport.test.js +117 -0
  208. package/test/tables/vportManager.test.js +54 -0
  209. package/test/test-helpers/test-helpers.js +66 -0
  210. package/test/tools/chamfer.test.js +970 -0
  211. package/test/tools/chamferFilletBase.test.js +446 -0
  212. package/test/tools/copy.test.js +22 -14
  213. package/test/tools/copybase.test.js +93 -0
  214. package/test/tools/copyclip.test.js +92 -0
  215. package/test/tools/cornerEntity.test.js +201 -0
  216. package/test/tools/cutclip.test.js +94 -0
  217. package/test/tools/distance.test.js +140 -18
  218. package/test/tools/erase.test.js +12 -12
  219. package/test/tools/explode.test.js +45 -0
  220. package/test/tools/extend.test.js +326 -44
  221. package/test/tools/fillet.test.js +831 -0
  222. package/test/tools/identify.test.js +115 -16
  223. package/test/tools/matchProp.test.js +84 -0
  224. package/test/tools/mirror.test.js +475 -0
  225. package/test/tools/move.test.js +75 -19
  226. package/test/tools/offset.test.js +748 -0
  227. package/test/tools/pan.test.js +72 -0
  228. package/test/tools/pasteclip.test.js +100 -0
  229. package/test/tools/purge.test.js +89 -0
  230. package/test/tools/rotate.test.js +89 -23
  231. package/test/tools/scale.test.js +529 -0
  232. package/test/tools/trim.test.js +419 -84
  233. package/test/tools/zoom.test.js +504 -0
  234. package/core/entities/alignedDimension.js +0 -279
  235. package/core/entities/angularDimension.js +0 -194
  236. package/core/entities/baseDimension.js +0 -227
  237. package/core/entities/block.js +0 -247
  238. package/core/entities/diametricDimension.js +0 -133
  239. package/core/entities/dimension.js +0 -202
  240. package/core/entities/radialDimension.js +0 -126
  241. package/core/styles/dimStyle.js +0 -719
  242. package/core/styles/dimStyleManager.js +0 -47
  243. package/core/styles/layer.js +0 -133
  244. package/core/styles/layerManager.js +0 -40
  245. package/core/styles/ltype.js +0 -86
  246. package/core/styles/ltypeManager.js +0 -50
  247. package/core/styles/style.js +0 -158
  248. package/core/styles/styleManager.js +0 -43
  249. package/core/styles/styleManagerBase.js +0 -299
  250. package/test/entities/block.test.js +0 -22
  251. package/test/styles/dimstyle.test.js +0 -19
  252. package/test/styles/layerManager.test.js +0 -150
  253. package/test/styles/style.test.js +0 -33
  254. package/test/styles/stylemanagerbase.test.js +0 -219
package/.eslintrc.json CHANGED
@@ -4,16 +4,23 @@
4
4
  "es2021": true
5
5
  },
6
6
  "extends": "google",
7
- "overrides": [
8
- ],
7
+ "overrides": [],
9
8
  "parserOptions": {
10
9
  "ecmaVersion": "latest",
11
10
  "sourceType": "module"
12
11
  },
13
12
  "rules": {
14
- "require-jsdoc" : 0,
15
- "valid-jsdoc" : 0,
16
- "max-len" : 0
13
+ "require-jsdoc": 2,
14
+ "valid-jsdoc": 2,
15
+ "max-len": 0,
16
+ "function-paren-newline": "warn",
17
+ "object-curly-spacing": [
18
+ "error",
19
+ "always"
20
+ ],
21
+ "space-in-parens": [
22
+ "error",
23
+ "never"
24
+ ]
17
25
  }
18
- //"eslintIgnore": ["canvas.js"]
19
- }
26
+ }
@@ -38,4 +38,6 @@ jobs:
38
38
  run: npx eslint . --ext .js
39
39
 
40
40
  - name: Upload coverage to Codecov
41
- uses: codecov/codecov-action@v2
41
+ uses: codecov/codecov-action@v4
42
+ with:
43
+ token: ${{ secrets.CODECOV_TOKEN }}
package/README.md CHANGED
@@ -1,11 +1,12 @@
1
- # Design-Core [![Design-Core QA](https://github.com/dubstar-04/Design-Core/actions/workflows/DesignCoreQA.yml/badge.svg)](https://github.com/dubstar-04/Design-Core/actions/workflows/DesignCoreQA.yml) [![codecov](https://codecov.io/gh/dubstar-04/Design-Core/branch/main/graph/badge.svg?token=SH2E690AT0)](https://codecov.io/gh/dubstar-04/Design-Core)
1
+ # Design-Core [![Design-Core QA](https://github.com/dubstar-04/Design-Core/actions/workflows/DesignCoreQA.yml/badge.svg)](https://github.com/dubstar-04/Design-Core/actions/workflows/DesignCoreQA.yml) [![codecov](https://codecov.io/gh/dubstar-04/Design-Core/branch/main/graph/badge.svg?token=SH2E690AT0)](https://codecov.io/gh/dubstar-04/Design-Core) ![NPM Version](https://img.shields.io/npm/v/%40design-core%2Fcore?logo=npm)
2
2
 
3
3
 
4
- Design-Core is a dependancy free opensource javascript library for two dimensional computer aided design (CAD).
5
4
 
6
- Design-Core uses the industry standard Drawing Exchange Format (DXF) to read and write CAD data and impliments drawing visualisation functionality and can be used with HTML canvas elements or Cairo graphics.
5
+ Design-Core is a dependency free open source JavaScript library for two-dimensional computer-aided design (CAD).
7
6
 
8
- | :warning: WARNING: Design Core is currently experimental / Proof of concept and only suitable for testing. |
7
+ Design-Core uses the industry standard Drawing Exchange Format (DXF) to read and write CAD data and implements drawing visualization functionality. It can be used with HTML canvas elements or Cairo graphics.
8
+
9
+ | :warning: WARNING: Design-Core is currently experimental / proof of concept and only suitable for testing. |
9
10
 
10
11
  ## Links
11
12
  * Docs: https://design-app.readthedocs.io/en/latest/index.html
@@ -14,3 +15,9 @@ Design-Core uses the industry standard Drawing Exchange Format (DXF) to read and
14
15
  * HTML Canvas: https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API
15
16
  * Cairo: https://www.cairographics.org/
16
17
 
18
+
19
+ ## Publishing
20
+
21
+ npm login
22
+
23
+ npm publish --access public
package/TODO.md ADDED
@@ -0,0 +1,19 @@
1
+ # Design-Core TODO list
2
+
3
+ ## Beta
4
+ ### UNDO / REDO
5
+
6
+ ### Printing
7
+
8
+ ### Export PDF
9
+
10
+ ### Paperspace
11
+
12
+ ### Entity Editing
13
+
14
+ ### Dimensions
15
+ - Linear dimension
16
+ - Angular Dimension
17
+ - Radial Dimension
18
+ - Diametric Dimension
19
+
package/core/core/core.js CHANGED
@@ -1,49 +1,65 @@
1
- import {Scene} from '../lib/scene.js';
2
- import {CommandManager} from '../lib/commandManager.js';
3
- import {Mouse} from '../lib/mouse.js';
4
- import {Canvas} from '../lib/canvas.js';
5
- import {CommandLine} from '../lib/commandLine.js';
6
- import {LayerManager} from '../styles/layerManager.js';
7
- import {LTypeManager} from '../styles/ltypeManager.js';
8
- import {StyleManager} from '../styles/styleManager.js';
9
- import {DimStyleManager} from '../styles/dimStyleManager.js';
10
- import {PropertyManager} from '../properties/propertyManager.js';
11
-
12
- import {FileIO} from '../lib/fileio.js';
13
- import {Settings} from '../lib/settings.js';
14
- import {DXFFile} from '../lib/dxf/dxfFile.js';
15
- import {Logging} from '../lib/logging.js';
16
-
17
- import {DesignCore} from '../designCore.js';
1
+ import { Scene } from '../lib/scene.js';
2
+ import { CommandManager } from '../lib/commandManager.js';
3
+ import { Mouse } from '../lib/mouse.js';
4
+ import { Canvas } from '../lib/canvas.js';
5
+ import { CommandLine } from '../lib/commandLine.js';
6
+ import { LayerManager } from '../tables/layerManager.js';
7
+ import { LTypeManager } from '../tables/ltypeManager.js';
8
+ import { StyleManager } from '../tables/styleManager.js';
9
+ import { DimStyleManager } from '../tables/dimStyleManager.js';
10
+ import { ViewManager } from '../tables/viewManager.js';
11
+ import { VPortManager } from '../tables/vportManager.js';
12
+ import { UCSManager } from '../tables/ucsManager.js';
13
+ import { AppIDManager } from '../tables/appIdManager.js';
14
+ import { BlockRecordManager } from '../tables/blockRecordManager.js';
15
+ import { DictionaryManager } from '../objects/dictionaryManager.js';
16
+ import { PropertyManager } from '../properties/propertyManager.js';
17
+ import { Clipboard } from '../lib/clipboard.js';
18
+
19
+ import { FileIO } from '../lib/fileio.js';
20
+ import { Settings } from '../lib/settings.js';
21
+ import { DXFFile } from '../lib/dxf/dxfFile.js';
22
+ import { HandleManager } from '../lib/dxf/handleManager.js';
23
+ import { Logging } from '../lib/logging.js';
24
+
25
+ import { DesignCore } from '../designCore.js';
18
26
 
19
27
  /** Class representing design core. This is the primary entry point */
20
28
  export class Core {
21
29
  /** Create a core object */
22
30
  constructor() {
31
+ // Create handle manager and activate to enable handle assignment during construction
32
+ this.handleManager = new HandleManager();
33
+ this.activate();
34
+
35
+ // Create core components
23
36
  this.scene = new Scene();
24
37
  this.commandManager = new CommandManager();
25
38
  this.canvas = new Canvas();
26
-
27
39
  this.mouse = new Mouse();
28
40
  this.commandLine = new CommandLine();
29
41
 
30
- this.layerManager = new LayerManager();
42
+ // Create table managers
31
43
  this.ltypeManager = new LTypeManager();
44
+ this.layerManager = new LayerManager();
32
45
  this.styleManager = new StyleManager();
33
46
  this.dimStyleManager = new DimStyleManager();
47
+ this.viewManager = new ViewManager();
48
+ this.vportManager = new VPortManager();
49
+ this.ucsManager = new UCSManager();
50
+ this.appIdManager = new AppIDManager();
51
+ this.blockRecordManager = new BlockRecordManager();
52
+
53
+ // Create dictionary manager and property manager
54
+ this.dictionaryManager = new DictionaryManager();
34
55
  this.propertyManager = new PropertyManager();
35
-
56
+ // Create clipboard manager
57
+ this.clipboard = new Clipboard();
58
+ // Create settings manager
36
59
  this.settings = new Settings();
37
60
 
38
61
  // function to call external notification command for the ui
39
62
  this.externalNotifyCallbackFunction;
40
-
41
- // create a static reference to the instantiated core object
42
- // DesignCore._instance = this;
43
- // Design.Core = this;
44
-
45
- // return Design;
46
- this.activate();
47
63
  }
48
64
 
49
65
  /**
@@ -59,30 +75,20 @@ export class Core {
59
75
  * Get the current dxf version
60
76
  */
61
77
  get dxfVersion() {
62
- return this.scene.dxfVersion;
78
+ return this.scene.headers.dxfVersion;
63
79
  }
64
80
 
65
81
  /**
66
82
  * Set the current dxf version
83
+ * @param {string} version
67
84
  */
68
85
  set dxfVersion(version) {
69
- // version should be the RXXXX format for the dxf version
70
-
71
- // Check if we have the ACXXXX value
72
- if (DXFFile.validDxfVersion(version)) {
73
- // convert the ACXXXX value to the key RXXXX value
74
- version = DXFFile.getVersionKey(version);
75
- }
76
-
77
- // Check if we have the RXXXX value
78
- if (DXFFile.validDxfKey(version)) {
79
- this.scene.dxfVersion = version;
80
- }
86
+ this.scene.headers.dxfVersion = version;
81
87
  }
82
88
 
83
89
  /**
84
90
  * Set the external notification callback
85
- * @param {object} function
91
+ * @param {Object} callback
86
92
  */
87
93
  setExternalNotifyCallbackFunction(callback) {
88
94
  // set the callback
@@ -112,6 +118,7 @@ export class Core {
112
118
 
113
119
  /**
114
120
  * Save the current scene to a dxf string
121
+ * @param {string} version
115
122
  * @return {string} The dxf file as a string.
116
123
  */
117
124
  saveFile(version) {
@@ -120,7 +127,7 @@ export class Core {
120
127
 
121
128
  /**
122
129
  * Return the supported dxf versions
123
- * @returns array js object containing the version
130
+ * @return {string} array js object containing the version
124
131
  */
125
132
  supportedDXFVersions() {
126
133
  return DXFFile.Version;
@@ -23,10 +23,12 @@
23
23
 
24
24
  ***** End Usage *****/
25
25
 
26
-
26
+ /**
27
+ * Design Core Class
28
+ */
27
29
  export class DesignCore {
28
30
  static _core;
29
-
31
+ /** Create a Design Core */
30
32
  constructor() {
31
33
  const msg = 'DesignCore is a static class and cannot be instantiated';
32
34
  const err = (`${this.type} - ${msg}`);
@@ -35,6 +37,7 @@ export class DesignCore {
35
37
 
36
38
  /**
37
39
  * Set the Core Instance
40
+ * @param {Object} core
38
41
  */
39
42
  static set Core(core) {
40
43
  this._core = core;
@@ -58,6 +61,13 @@ export class DesignCore {
58
61
  return DesignCore.Core.scene;
59
62
  }
60
63
 
64
+ /**
65
+ * Get the Clipboard
66
+ */
67
+ static get Clipboard() {
68
+ return DesignCore.Core.clipboard;
69
+ }
70
+
61
71
  /**
62
72
  * Get the CommandManager
63
73
  */
@@ -114,6 +124,48 @@ export class DesignCore {
114
124
  return DesignCore.Core.dimStyleManager;
115
125
  }
116
126
 
127
+ /**
128
+ * Get the ViewManager
129
+ */
130
+ static get ViewManager() {
131
+ return DesignCore.Core.viewManager;
132
+ }
133
+
134
+ /**
135
+ * Get the VPortManager
136
+ */
137
+ static get VPortManager() {
138
+ return DesignCore.Core.vportManager;
139
+ }
140
+
141
+ /**
142
+ * Get the UCSManager
143
+ */
144
+ static get UCSManager() {
145
+ return DesignCore.Core.ucsManager;
146
+ }
147
+
148
+ /**
149
+ * Get the AppIDManager
150
+ */
151
+ static get AppIDManager() {
152
+ return DesignCore.Core.appIdManager;
153
+ }
154
+
155
+ /**
156
+ * Get the BlockRecordManager
157
+ */
158
+ static get BlockRecordManager() {
159
+ return DesignCore.Core.blockRecordManager;
160
+ }
161
+
162
+ /**
163
+ * Get the DictionaryManager
164
+ */
165
+ static get DictionaryManager() {
166
+ return DesignCore.Core.dictionaryManager;
167
+ }
168
+
117
169
  /**
118
170
  * Get the property manager
119
171
  */
@@ -121,6 +173,13 @@ export class DesignCore {
121
173
  return DesignCore.Core.propertyManager;
122
174
  }
123
175
 
176
+ /**
177
+ * Get the Handle
178
+ */
179
+ static get HandleManager() {
180
+ return DesignCore.Core.handleManager;
181
+ }
182
+
124
183
  /**
125
184
  * Get the property manager
126
185
  */
@@ -0,0 +1,142 @@
1
+ import { Strings } from '../lib/strings.js';
2
+ import { Line } from '../entities/line.js';
3
+ import { Input, PromptOptions } from '../lib/inputManager.js';
4
+ import { Logging } from '../lib/logging.js';
5
+ import { DXFFile } from '../lib/dxf/dxfFile.js';
6
+ import { Point } from '../entities/point.js';
7
+ import { BaseLinearDimension } from './baseLinearDimension.js';
8
+
9
+ import { DesignCore } from '../designCore.js';
10
+
11
+
12
+ /**
13
+ * Aligned Dimension Entity Class
14
+ * @extends LinearDimension
15
+ */
16
+ export class AlignedDimension extends BaseLinearDimension {
17
+ /**
18
+ * Create an Aligned Dimension
19
+ * @param {Array} data
20
+ */
21
+ constructor(data) {
22
+ super(data);
23
+ this.dimType.setDimType(1); // Aligned dimension
24
+ }
25
+
26
+ /**
27
+ * Register the command
28
+ * @return {Object}
29
+ * command = name of the command
30
+ * shortcut = shortcut for the command
31
+ * type = type to group command in toolbars (omitted if not shown)
32
+ */
33
+ static register() {
34
+ const command = { command: 'AlignedDimension', shortcut: 'DIMALI' };
35
+ return command;
36
+ }
37
+
38
+ /**
39
+ * Execute method
40
+ * executes the workflow, requesting input required to create an entity
41
+ */
42
+ async execute() {
43
+ try {
44
+ DesignCore.Scene.selectionManager.reset();
45
+ this.dimensionStyle = DesignCore.DimStyleManager.getCstyle();
46
+ this.dimType.setDimType(1); // Aligned dimension
47
+
48
+ const op = new PromptOptions(Strings.Input.START, [Input.Type.POINT]);
49
+ const pt13 = await DesignCore.Scene.inputManager.requestInput(op);
50
+ pt13.sequence = 13;
51
+ this.points.push(pt13);
52
+
53
+ const op1 = new PromptOptions(Strings.Input.END, [Input.Type.POINT]);
54
+ const pt14 = await DesignCore.Scene.inputManager.requestInput(op1);
55
+ pt14.sequence = 14;
56
+ this.points.push(pt14);
57
+
58
+ const op2 = new PromptOptions(Strings.Input.DIMENSION, [Input.Type.POINT]);
59
+ const pt11 = await DesignCore.Scene.inputManager.requestInput(op2);
60
+ pt11.sequence = 11;
61
+ this.points.push(pt11);
62
+
63
+ const tempLine = new Line({ points: [pt13, pt14] });
64
+ this.points = AlignedDimension.getPointsFromSelection([tempLine], pt11);
65
+
66
+ DesignCore.Scene.inputManager.executeCommand(this);
67
+ } catch (err) {
68
+ Logging.instance.error(`${this.type} - ${err}`);
69
+ }
70
+ }
71
+
72
+ /**
73
+ * Get sequenced points from user selection
74
+ * @param {any} items
75
+ * @param {Point} textPos
76
+ * @return {Array} array of points
77
+ */
78
+ static getPointsFromSelection(items, textPos) {
79
+ const points = [];
80
+ const item = items[0];
81
+
82
+ const Pt13 = item.points[0];
83
+ Pt13.sequence = 13;
84
+ points.push(Pt13);
85
+
86
+ const Pt14 = item.points[1];
87
+ Pt14.sequence = 14;
88
+ points.push(Pt14);
89
+
90
+ const Pt10 = new Point();
91
+ Pt10.sequence = 10;
92
+
93
+ const Pt11 = textPos;
94
+ Pt11.sequence = 11;
95
+ points.push(Pt11);
96
+
97
+ // Perpendicular to the selected line or line is vertical or horizontal
98
+ const pntPerp = Pt11.perpendicular(Pt13, Pt14);
99
+ const projectionAngle = pntPerp.angle(Pt11);
100
+ const distance = Pt11.distance(pntPerp);
101
+ const projectedPoint = Pt14.project(projectionAngle, distance);
102
+
103
+ Pt10.x = projectedPoint.x;
104
+ Pt10.y = projectedPoint.y;
105
+
106
+ points.push(Pt10);
107
+ return points;
108
+ }
109
+
110
+ /**
111
+ * Write the entity to file in the dxf format
112
+ * @param {DXFFile} file
113
+ */
114
+ dxf(file) {
115
+ const Pt10 = this.getPointBySequence(this.points, 10);
116
+ const Pt11 = this.getPointBySequence(this.points, 11);
117
+ const Pt13 = this.getPointBySequence(this.points, 13);
118
+ const Pt14 = this.getPointBySequence(this.points, 14);
119
+
120
+ file.writeGroupCode('0', 'DIMENSION');
121
+ file.writeGroupCode('5', this.handle, DXFFile.Version.R2000); // Handle
122
+ file.writeGroupCode('100', 'AcDbEntity', DXFFile.Version.R2000);
123
+ file.writeGroupCode('100', 'AcDbDimension', DXFFile.Version.R2000);
124
+ file.writeGroupCode('8', this.layer);
125
+ // file.writeGroupCode('2', this.blockName); // Block not required
126
+ file.writeGroupCode('10', Pt10.x); // X - definition / arrow point
127
+ file.writeGroupCode('20', Pt10.y); // Y
128
+ file.writeGroupCode('30', '0.0'); // Z
129
+ file.writeGroupCode('11', Pt11.x); // X - text midpoint
130
+ file.writeGroupCode('21', Pt11.y); // Y
131
+ file.writeGroupCode('31', '0.0'); // Z
132
+ file.writeGroupCode('70', this.dimType.getDimType()); // DIMENSION TYPE
133
+ file.writeGroupCode('3', this.dimensionStyle); // DIMENSION STYLE
134
+ file.writeGroupCode('100', 'AcDbAlignedDimension', DXFFile.Version.R2000);
135
+ file.writeGroupCode('13', Pt13.x); // X - start point of first extension line
136
+ file.writeGroupCode('23', Pt13.y); // Y
137
+ file.writeGroupCode('33', '0.0'); // Z
138
+ file.writeGroupCode('14', Pt14.x); // X - start point of second extension line
139
+ file.writeGroupCode('24', Pt14.y); // Y
140
+ file.writeGroupCode('34', '0.0'); // Z
141
+ }
142
+ }