@vitrosoftware/common-ui-ts 1.1.121 → 1.1.123

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 (135) hide show
  1. package/css/std/controls/checkbox/checkbox.css +4 -0
  2. package/css/std/controls/checkbox/img/checkbox-indeterminate.svg +4 -0
  3. package/css/std/controls/date-picker/date-picker.css +1 -25
  4. package/css/std/controls/dxf-viewer/annotation.css +85 -0
  5. package/css/std/controls/dxf-viewer/common.css +24 -0
  6. package/css/std/controls/dxf-viewer/dxf-viewer-index.css +14081 -0
  7. package/css/std/controls/dxf-viewer/dxf-viewer.css +194 -0
  8. package/css/std/controls/dxf-viewer/img/cancel-dark-grey.svg +5 -0
  9. package/css/std/controls/dxf-viewer/img/collapse-bottom.svg +5 -0
  10. package/css/std/controls/dxf-viewer/img/collapse-up-blue.svg +5 -0
  11. package/css/std/controls/dxf-viewer/img/delete-active.svg +11 -0
  12. package/css/std/controls/dxf-viewer/img/delete.svg +11 -0
  13. package/css/std/controls/dxf-viewer/img/draw-annotation.svg +3 -0
  14. package/css/std/controls/dxf-viewer/img/invisible-eye.svg +4 -0
  15. package/css/std/controls/dxf-viewer/img/show-annotation.svg +3 -0
  16. package/css/std/controls/dxf-viewer/img/sidebar-layers-toggle.svg +6 -0
  17. package/css/std/controls/dxf-viewer/img/sidebar-notes-toggle.svg +5 -0
  18. package/css/std/controls/dxf-viewer/img/sidebar-resizer.svg +6 -0
  19. package/css/std/controls/dxf-viewer/img/sidebar-toggle.svg +7 -0
  20. package/css/std/controls/dxf-viewer/img/visible-eye.svg +4 -0
  21. package/css/std/controls/dxf-viewer/img/zoom-in.svg +6 -0
  22. package/css/std/controls/dxf-viewer/img/zoom-out.svg +5 -0
  23. package/css/std/controls/dxf-viewer/layer-list.css +104 -0
  24. package/css/std/controls/dxf-viewer/panel.css +34 -0
  25. package/css/std/controls/dxf-viewer/prop-inspector.css +102 -0
  26. package/css/std/controls/dxf-viewer/select.css +111 -0
  27. package/css/std/controls/dxf-viewer/sidebar.css +190 -0
  28. package/css/std/controls/dxf-viewer/thumbnail-list.css +65 -0
  29. package/css/std/controls/dxf-viewer/toolbar.css +117 -0
  30. package/css/std/controls/dxf-viewer/treeview.css +3 -0
  31. package/css/std/controls/dxf-viewer/treeview.panel.css +108 -0
  32. package/css/std/controls/error-message/error-message.css +22 -0
  33. package/css/std/controls/image-picker/image-picker.css +0 -26
  34. package/css/std/controls/input/input.css +1 -24
  35. package/css/std/controls/issue-tile/issue-tile-header.css +1 -0
  36. package/css/std/controls/login/ntlm-authentication-form.css +9 -12
  37. package/css/std/controls/lookup-picker/lookup-picker-value-list.css +38 -2
  38. package/css/std/controls/lookup-picker/lookup-picker.css +1 -25
  39. package/css/std/controls/table-view/treegrid-context-menu.css +44 -18
  40. package/css/std/controls/table-view/treegrid-message.css +4 -4
  41. package/css/std/controls/time-picker/time-picker.css +1 -25
  42. package/dist/index.css +81 -143
  43. package/dist/index.js +15137 -489
  44. package/dist/index.js.map +1 -1
  45. package/dist/src/controls/Checkbox/Checkbox.d.ts +1 -0
  46. package/dist/src/controls/DxfViewer/DxfViewer.d.ts +6 -0
  47. package/dist/src/controls/DxfViewer/DxfViewerContext.d.ts +31 -0
  48. package/dist/src/controls/DxfViewer/Layer.d.ts +9 -0
  49. package/dist/src/controls/DxfViewer/LayerList.d.ts +11 -0
  50. package/dist/src/controls/DxfViewer/Thumbnail.d.ts +7 -0
  51. package/dist/src/controls/DxfViewer/ThumbnailList.d.ts +6 -0
  52. package/dist/src/controls/DxfViewer/Viewer.d.ts +6 -0
  53. package/dist/src/controls/ErrorMessage/ErrorMessage.d.ts +6 -0
  54. package/dist/src/controls/Login/FormRef.d.ts +3 -0
  55. package/dist/src/controls/Login/LoginConstants.d.ts +2 -1
  56. package/dist/src/controls/Login/LoginFormRef.d.ts +2 -2
  57. package/dist/src/controls/Login/NTLMAuthenticationForm.d.ts +5 -2
  58. package/dist/src/controls/LookupPicker/LookupPicker.d.ts +2 -0
  59. package/dist/src/controls/LookupPicker/ValueList.d.ts +2 -0
  60. package/dist/src/controls/TableView/TableViewConstants.d.ts +11 -0
  61. package/dist/src/controls/TableView/TreeGridTableViewContextImpl.d.ts +1 -0
  62. package/dist/src/controls/TreeView/TreeView.d.ts +4 -0
  63. package/dist/src/controls/TreeView/TreeViewConfig.d.ts +3 -0
  64. package/dist/src/controls/TreeView/TreeViewConstants.d.ts +2 -1
  65. package/dist/src/index.d.ts +7 -1
  66. package/lib/dxf-viewer/BatchingKey.js +91 -0
  67. package/lib/dxf-viewer/DxfFetcher.js +39 -0
  68. package/lib/dxf-viewer/DxfScene.js +2695 -0
  69. package/lib/dxf-viewer/DxfViewer.js +1056 -0
  70. package/lib/dxf-viewer/DxfWorker.js +229 -0
  71. package/lib/dxf-viewer/DynamicBuffer.js +100 -0
  72. package/lib/dxf-viewer/HatchCalculator.js +345 -0
  73. package/lib/dxf-viewer/LinearDimension.js +323 -0
  74. package/lib/dxf-viewer/MTextFormatParser.js +211 -0
  75. package/lib/dxf-viewer/MaterialKey.js +37 -0
  76. package/lib/dxf-viewer/OrbitControls.js +1253 -0
  77. package/lib/dxf-viewer/Pattern.js +94 -0
  78. package/lib/dxf-viewer/RBTree.js +471 -0
  79. package/lib/dxf-viewer/TextRenderer.js +1038 -0
  80. package/lib/dxf-viewer/index.js +42 -0
  81. package/lib/dxf-viewer/math/Matrix2.js +77 -0
  82. package/lib/dxf-viewer/math/utils.js +59 -0
  83. package/lib/dxf-viewer/parser/AutoCadColorIndex.js +265 -0
  84. package/lib/dxf-viewer/parser/DimStyleCodes.js +33 -0
  85. package/lib/dxf-viewer/parser/DxfArrayScanner.js +143 -0
  86. package/lib/dxf-viewer/parser/DxfParser.js +980 -0
  87. package/lib/dxf-viewer/parser/ExtendedDataParse-My.js +91 -0
  88. package/lib/dxf-viewer/parser/ExtendedDataParser.js +123 -0
  89. package/lib/dxf-viewer/parser/ParseHelpers.js +142 -0
  90. package/lib/dxf-viewer/parser/entities/3dface.js +83 -0
  91. package/lib/dxf-viewer/parser/entities/arc.js +38 -0
  92. package/lib/dxf-viewer/parser/entities/attdef.js +89 -0
  93. package/lib/dxf-viewer/parser/entities/attrib.js +34 -0
  94. package/lib/dxf-viewer/parser/entities/attribute.js +109 -0
  95. package/lib/dxf-viewer/parser/entities/circle.js +43 -0
  96. package/lib/dxf-viewer/parser/entities/dimension.js +72 -0
  97. package/lib/dxf-viewer/parser/entities/ellipse.js +46 -0
  98. package/lib/dxf-viewer/parser/entities/hatch.js +343 -0
  99. package/lib/dxf-viewer/parser/entities/insert.js +62 -0
  100. package/lib/dxf-viewer/parser/entities/leader.js +84 -0
  101. package/lib/dxf-viewer/parser/entities/line.js +34 -0
  102. package/lib/dxf-viewer/parser/entities/lwpolyline.js +100 -0
  103. package/lib/dxf-viewer/parser/entities/mtext.js +54 -0
  104. package/lib/dxf-viewer/parser/entities/point.js +35 -0
  105. package/lib/dxf-viewer/parser/entities/polyline.js +92 -0
  106. package/lib/dxf-viewer/parser/entities/solid.js +40 -0
  107. package/lib/dxf-viewer/parser/entities/spline.js +70 -0
  108. package/lib/dxf-viewer/parser/entities/text.js +47 -0
  109. package/lib/dxf-viewer/parser/entities/vertex.js +62 -0
  110. package/lib/dxf-viewer/parser/entities/viewport.js +56 -0
  111. package/lib/dxf-viewer/parser/objects/dictionary.js +29 -0
  112. package/lib/dxf-viewer/parser/objects/layout.js +35 -0
  113. package/lib/dxf-viewer/parser/objects/xrecord.js +29 -0
  114. package/lib/opentype/opentype.module.js +14571 -0
  115. package/lib/three/CSS2DRenderer.js +235 -0
  116. package/lib/three/three.module.js +49912 -0
  117. package/lib/xeokit/xeokit-sdk-2.6.10.es.js +136629 -0
  118. package/lib/xeokit/xeokit-sdk-2.6.10.min.es.js +299 -0
  119. package/package.json +12 -10
  120. package/src/controls/BimViewer/js/bim-viewer-models.js +93 -0
  121. package/src/controls/BimViewer/js/bim-viewer.js +194 -5
  122. package/src/controls/DxfViewer/js/dxf-viewer.js +3541 -0
  123. package/src/controls/PdfViewer/js/pdf-viewer.js +1 -1
  124. package/css/std/controls/input/img/error-message.svg +0 -6
  125. package/css/std/controls/lookup-picker/img/error-message.svg +0 -6
  126. package/css/std/controls/time-picker/img/error-message.svg +0 -6
  127. package/dist/src/controls/ActionHandler/ActionInfo.d.ts +0 -12
  128. package/dist/src/controls/ActionHandler/ActionInfoItem.d.ts +0 -13
  129. package/dist/src/controls/ActionHandler/UpdatingPopover.d.ts +0 -2
  130. package/dist/src/controls/Dialog/DialogButton.d.ts +0 -8
  131. package/dist/src/controls/Dialog/DialogCloseButton.d.ts +0 -8
  132. package/dist/src/controls/Icon/Icon.d.ts +0 -11
  133. package/dist/src/controls/Search/Input.d.ts +0 -21
  134. package/dist/src/controls/Search/SearchConstants.d.ts +0 -4
  135. /package/css/std/controls/{date-picker → error-message}/img/error-message.svg +0 -0
@@ -0,0 +1,42 @@
1
+
2
+ //export * from "./DxfViewer.js"
3
+
4
+
5
+ //import * as three from "./dep/three.module.js";
6
+ //import * as THREE from "./dep/three.module.js"
7
+ //import "./DxfViewer.js";
8
+ //import {Matrix3, Vector2, ShapePath, ShapeUtils} from "./dep/three.js"
9
+ //import "./dep/opentype.js"
10
+
11
+ //import { DxfFetcher } from "./DxfFetcher.js";
12
+ //import { DxfViewer } from "./DxfViewer.js";
13
+ //import { Block } from "./DxfScene.js";
14
+
15
+
16
+ //export { DxfFetcher, DxfViewer, Block }
17
+
18
+ //import { }
19
+
20
+ //export { DxfFetcher } from "./DxfFetcher.js";
21
+ //export { DxfViewer } from "./DxfViewer.js";
22
+ //export { DxfWorker } from "./DxfWorker.js";
23
+ //export { ParseSpecialChars } from "./TextRenderer.js";
24
+ //export { Block, DxfScene, RenderBatch } from "./DxfScene.js"
25
+
26
+
27
+
28
+ export { Batch, DxfViewer, Layer } from "./DxfViewer.js";
29
+ export { Block as SceneBlock } from "./DxfScene.js";
30
+ export { Block } from "./DxfViewer.js";
31
+ export { DxfScene, Entity, ColorCode } from "./DxfScene.js";
32
+ export { TextRenderer, ParseSpecialChars, HAlign, VAlign } from "./TextRenderer.js";
33
+ export { DxfWorker } from "./DxfWorker.js";
34
+ export { DxfFetcher } from "./DxfFetcher.js";
35
+ export { DxfParser } from "./parser/DxfParser.js";
36
+ export { RenderBatch } from "./DxfScene.js";
37
+ export { DynamicBuffer, NativeType } from "./DynamicBuffer.js";
38
+ export { OrbitControls } from "./OrbitControls.js";
39
+
40
+ //export default Block;
41
+
42
+
@@ -0,0 +1,77 @@
1
+ import { Vector2 } from "../dep/three/three.module.js"
2
+
3
+ export class Matrix2 {
4
+ /**
5
+ *
6
+ * @param {number} a00
7
+ * @param {number} a01
8
+ * @param {number} a10
9
+ * @param {number} a11
10
+ */
11
+ constructor(a00, a01, a10, a11) {
12
+ this.a00 = a00
13
+ this.a01 = a01
14
+ this.a10 = a10
15
+ this.a11 = a11
16
+ }
17
+
18
+ /**
19
+ * Multiply Vector2 to this matrix as Av
20
+ * @param {Vector2} v
21
+ * @returns {Vector2} transformed v
22
+ */
23
+ multiply(v) {
24
+ return new Vector2(
25
+ this.a00 * v.x + this.a01 * v.y,
26
+ this.a10 * v.x + this.a11 * v.y,
27
+ )
28
+ }
29
+
30
+ /**
31
+ * Return determinant of this matrix
32
+ * @returns {number}
33
+ */
34
+ det() {
35
+ return this.a00 * this.a11 - this.a01 * this.a10
36
+ }
37
+
38
+ /**
39
+ * Return inverse of this matrix. If inverse is not exists i.e.
40
+ * this.det() === 0, return `undefined`.
41
+ * @param {number | undefined} - in case of pre computed determinant, you may pass it to parameter
42
+ * @returns {Matrix2 | undefined} inverse of this matrix
43
+ */
44
+ inverse(determinant = det()) {
45
+ if (determinant === 0) return undefined
46
+
47
+ return new Matrix2(
48
+ this.a11 / determinant, -this.a01 / determinant,
49
+ -this.a10 / determinant, this.a00 / determinant,
50
+ )
51
+ }
52
+
53
+ /**
54
+ * Solve linear equation Ax = b using Gauss-Jordan reduction
55
+ * where A is `this`. If it's singular, return `undefined`
56
+ * @param {Vector2} b
57
+ * @returns {Vector2 | undefined}
58
+ */
59
+ solve(b) {
60
+ if (this.a00 * this.a11 === this.a10 * this.a01) return undefined
61
+
62
+ if (Math.abs(this.a00) >= Math.abs(this.a10)) {
63
+ const alpha = this.a10 / this.a00
64
+ const beta = this.a11 - this.a01 * alpha
65
+ const gamma = b.y - b.x * alpha
66
+ const y = gamma / beta
67
+ const x = (b.x - this.a01 * y) / this.a00
68
+ return new Vector2(x, y)
69
+ }
70
+ const alpha = this.a00 / this.a10
71
+ const beta = this.a01 - this.a11 * alpha
72
+ const gamma = b.x - b.y * alpha
73
+ const y = gamma / beta
74
+ const x = (b.y - this.a11 * y) / this.a10
75
+ return new Vector2(x, y)
76
+ }
77
+ }
@@ -0,0 +1,59 @@
1
+ import { Vector2 } from "../dep/three/three.module.js"
2
+
3
+
4
+ /** Find intersection points of two segments in a parametric form.
5
+ * @param {Vector2} a1 First segment start point.
6
+ * @param {Vector2} a2 First segment end point.
7
+ * @param {Vector2} b1 Second segment start point.
8
+ * @param {Vector2} b2 Second segment end point.
9
+ * @param {boolean} force Force intersection calculation even if intersection point is out of
10
+ * segment range.
11
+ * @return {?number[3]} Parameters for the first and second segment in the intersection point
12
+ * (parameter value 0 corresponds to a start point, 1 - to an end point). Third number is segments
13
+ * direction vectors pseudo-cross-product. Null if there is no intersection.
14
+ */
15
+ export function IntersectSegmentsParametric(a1, a2, b1, b2, force = false) {
16
+ const a = a2.clone().sub(a1)
17
+ const b = b2.clone().sub(b1)
18
+
19
+ if (a.lengthSq() == 0 || b.lengthSq() == 0) {
20
+ return null
21
+ }
22
+
23
+ const S = a.cross(b)
24
+ if (Math.abs(S) <= Number.EPSILON) {
25
+ /* Consider parallel. */
26
+ return null
27
+ }
28
+
29
+ const c = b1.clone().sub(a1)
30
+
31
+ const t = c.cross(b) / S
32
+ if (!force && (t < 0 || t > 1)) {
33
+ /* Intersection point is out the first segment endpoints. */
34
+ return null
35
+ }
36
+
37
+ const u = c.cross(a) / S
38
+ if (!force && (u < 0 || u > 1)) {
39
+ /* Intersection point is out the second segment endpoints. */
40
+ return null
41
+ }
42
+
43
+ return [t, u, S]
44
+ }
45
+
46
+ /** Find intersection points of two segments.
47
+ * @param {Vector2} a1 First segment start point.
48
+ * @param {Vector2} a2 First segment end point.
49
+ * @param {Vector2} b1 Second segment start point.
50
+ * @param {Vector2} b2 Second segment end point.
51
+ * @return {?Vector2} Intersection point coordinate, null if no intersection.
52
+ */
53
+ export function IntersectSegments(a1, a2, b1, b2) {
54
+ const params = IntersectSegmentsParametric(a1, a2, b1, b2)
55
+ if (!params) {
56
+ return null
57
+ }
58
+ return a2.clone().sub(a1).multiplyScalar(params[0]).add(a1)
59
+ }
@@ -0,0 +1,265 @@
1
+ /**
2
+ * AutoCad files sometimes use an indexed color value between 1 and 255 inclusive.
3
+ * Each value corresponds to a color. index 1 is red, that is 16711680 or 0xFF0000.
4
+ * index 0 and 256, while included in this array, are actually reserved for inheritance
5
+ * values in AutoCad so they should not be used for index color lookups.
6
+ */
7
+
8
+ export default [
9
+ 0,
10
+ 16711680,
11
+ 16776960,
12
+ 65280,
13
+ 65535,
14
+ 255,
15
+ 16711935,
16
+ 16777215,
17
+ 8421504,
18
+ 12632256,
19
+ 16711680,
20
+ 16744319,
21
+ 13369344,
22
+ 13395558,
23
+ 10027008,
24
+ 10046540,
25
+ 8323072,
26
+ 8339263,
27
+ 4980736,
28
+ 4990502,
29
+ 16727808,
30
+ 16752511,
31
+ 13382400,
32
+ 13401958,
33
+ 10036736,
34
+ 10051404,
35
+ 8331008,
36
+ 8343359,
37
+ 4985600,
38
+ 4992806,
39
+ 16744192,
40
+ 16760703,
41
+ 13395456,
42
+ 13408614,
43
+ 10046464,
44
+ 10056268,
45
+ 8339200,
46
+ 8347455,
47
+ 4990464,
48
+ 4995366,
49
+ 16760576,
50
+ 16768895,
51
+ 13408512,
52
+ 13415014,
53
+ 10056192,
54
+ 10061132,
55
+ 8347392,
56
+ 8351551,
57
+ 4995328,
58
+ 4997670,
59
+ 16776960,
60
+ 16777087,
61
+ 13421568,
62
+ 13421670,
63
+ 10000384,
64
+ 10000460,
65
+ 8355584,
66
+ 8355647,
67
+ 5000192,
68
+ 5000230,
69
+ 12582656,
70
+ 14679935,
71
+ 10079232,
72
+ 11717734,
73
+ 7510016,
74
+ 8755276,
75
+ 6258432,
76
+ 7307071,
77
+ 3755008,
78
+ 4344870,
79
+ 8388352,
80
+ 12582783,
81
+ 6736896,
82
+ 10079334,
83
+ 5019648,
84
+ 7510092,
85
+ 4161280,
86
+ 6258495,
87
+ 2509824,
88
+ 3755046,
89
+ 4194048,
90
+ 10485631,
91
+ 3394560,
92
+ 8375398,
93
+ 2529280,
94
+ 6264908,
95
+ 2064128,
96
+ 5209919,
97
+ 1264640,
98
+ 3099686,
99
+ 65280,
100
+ 8388479,
101
+ 52224,
102
+ 6736998,
103
+ 38912,
104
+ 5019724,
105
+ 32512,
106
+ 4161343,
107
+ 19456,
108
+ 2509862,
109
+ 65343,
110
+ 8388511,
111
+ 52275,
112
+ 6737023,
113
+ 38950,
114
+ 5019743,
115
+ 32543,
116
+ 4161359,
117
+ 19475,
118
+ 2509871,
119
+ 65407,
120
+ 8388543,
121
+ 52326,
122
+ 6737049,
123
+ 38988,
124
+ 5019762,
125
+ 32575,
126
+ 4161375,
127
+ 19494,
128
+ 2509881,
129
+ 65471,
130
+ 8388575,
131
+ 52377,
132
+ 6737074,
133
+ 39026,
134
+ 5019781,
135
+ 32607,
136
+ 4161391,
137
+ 19513,
138
+ 2509890,
139
+ 65535,
140
+ 8388607,
141
+ 52428,
142
+ 6737100,
143
+ 39064,
144
+ 5019800,
145
+ 32639,
146
+ 4161407,
147
+ 19532,
148
+ 2509900,
149
+ 49151,
150
+ 8380415,
151
+ 39372,
152
+ 6730444,
153
+ 29336,
154
+ 5014936,
155
+ 24447,
156
+ 4157311,
157
+ 14668,
158
+ 2507340,
159
+ 32767,
160
+ 8372223,
161
+ 26316,
162
+ 6724044,
163
+ 19608,
164
+ 5010072,
165
+ 16255,
166
+ 4153215,
167
+ 9804,
168
+ 2505036,
169
+ 16383,
170
+ 8364031,
171
+ 13260,
172
+ 6717388,
173
+ 9880,
174
+ 5005208,
175
+ 8063,
176
+ 4149119,
177
+ 4940,
178
+ 2502476,
179
+ 255,
180
+ 8355839,
181
+ 204,
182
+ 6710988,
183
+ 152,
184
+ 5000344,
185
+ 127,
186
+ 4145023,
187
+ 76,
188
+ 2500172,
189
+ 4129023,
190
+ 10452991,
191
+ 3342540,
192
+ 8349388,
193
+ 2490520,
194
+ 6245528,
195
+ 2031743,
196
+ 5193599,
197
+ 1245260,
198
+ 3089996,
199
+ 8323327,
200
+ 12550143,
201
+ 6684876,
202
+ 10053324,
203
+ 4980888,
204
+ 7490712,
205
+ 4128895,
206
+ 6242175,
207
+ 2490444,
208
+ 3745356,
209
+ 12517631,
210
+ 14647295,
211
+ 10027212,
212
+ 11691724,
213
+ 7471256,
214
+ 8735896,
215
+ 6226047,
216
+ 7290751,
217
+ 3735628,
218
+ 4335180,
219
+ 16711935,
220
+ 16744447,
221
+ 13369548,
222
+ 13395660,
223
+ 9961624,
224
+ 9981080,
225
+ 8323199,
226
+ 8339327,
227
+ 4980812,
228
+ 4990540,
229
+ 16711871,
230
+ 16744415,
231
+ 13369497,
232
+ 13395634,
233
+ 9961586,
234
+ 9981061,
235
+ 8323167,
236
+ 8339311,
237
+ 4980793,
238
+ 4990530,
239
+ 16711807,
240
+ 16744383,
241
+ 13369446,
242
+ 13395609,
243
+ 9961548,
244
+ 9981042,
245
+ 8323135,
246
+ 8339295,
247
+ 4980774,
248
+ 4990521,
249
+ 16711743,
250
+ 16744351,
251
+ 13369395,
252
+ 13395583,
253
+ 9961510,
254
+ 9981023,
255
+ 8323103,
256
+ 8339279,
257
+ 4980755,
258
+ 4990511,
259
+ 3355443,
260
+ 5987163,
261
+ 8684676,
262
+ 11382189,
263
+ 14079702,
264
+ 16777215
265
+ ];
@@ -0,0 +1,33 @@
1
+ /** Dimension style variables are used either in DIMSTYLE table or in DIMENSION entity style
2
+ * override in XDATA.
3
+ */
4
+ const codes = new Map([
5
+ [140, "DIMTXT"],
6
+ [142, "DIMTSZ"],
7
+ [144, "DIMLFAC"],
8
+ [147, "DIMGAP"],
9
+ [173, "DIMSAH"],
10
+ [175, "DIMSOXD"],
11
+ [176, "DIMCLRD"],
12
+ [177, "DIMCLRE"],
13
+ [178, "DIMCLRT"],
14
+ [271, "DIMDEC"],
15
+ [278, "DIMDSEP"],
16
+ [281, "DIMSD1"],
17
+ [282, "DIMSD2"],
18
+ [3, "DIMPOST"],
19
+ [40, "DIMSCALE"],
20
+ [41, "DIMASZ"],
21
+ [42, "DIMEXO"],
22
+ [44, "DIMEXE"],
23
+ [45, "DIMRND"],
24
+ [46, "DIMDLE"],
25
+ [5, "DIMBLK"],
26
+ [6, "DIMBLK1"],
27
+ [7, "DIMBLK2"],
28
+ [75, "DIMSE1"],
29
+ [76, "DIMSE2"],
30
+ [78, "DIMZIN"],
31
+ ])
32
+
33
+ export default codes
@@ -0,0 +1,143 @@
1
+ /**
2
+ * DxfArrayScanner
3
+ *
4
+ * Based off the AutoCad 2012 DXF Reference
5
+ * http://images.autodesk.com/adsk/files/autocad_2012_pdf_dxf-reference_enu.pdf
6
+ *
7
+ * Reads through an array representing lines of a dxf file. Takes an array and
8
+ * provides an easy interface to extract group code and value pairs.
9
+ * @param data - an array where each element represents a line in the dxf file
10
+ * @constructor
11
+ */
12
+ export default function DxfArrayScanner(data) {
13
+ this._pointer = 0;
14
+ this._data = data;
15
+ this._eof = false;
16
+ }
17
+
18
+ /**
19
+ * Gets the next group (code, value) from the array. A group is two consecutive elements
20
+ * in the array. The first is the code, the second is the value.
21
+ * @returns {{code: Number}|*}
22
+ */
23
+ DxfArrayScanner.prototype.next = function() {
24
+ var group;
25
+ if(!this.hasNext()) {
26
+ if(!this._eof)
27
+ throw new Error('Unexpected end of input: EOF group not read before end of file. Ended on code ' + this._data[this._pointer]);
28
+ else
29
+ throw new Error('Cannot call \'next\' after EOF group has been read');
30
+ }
31
+
32
+ group = {
33
+ code: parseInt(this._data[this._pointer])
34
+ };
35
+
36
+ this._pointer++;
37
+
38
+ group.value = parseGroupValue(group.code, this._data[this._pointer]);
39
+
40
+ this._pointer++;
41
+
42
+ if(group.code === 0 && group.value === 'EOF') this._eof = true;
43
+
44
+ this.lastReadGroup = group;
45
+
46
+ return group;
47
+ };
48
+
49
+ DxfArrayScanner.prototype.peek = function() {
50
+ if(!this.hasNext()) {
51
+ if(!this._eof)
52
+ throw new Error('Unexpected end of input: EOF group not read before end of file. Ended on code ' + this._data[this._pointer]);
53
+ else
54
+ throw new Error('Cannot call \'next\' after EOF group has been read');
55
+ }
56
+
57
+ var group = {
58
+ code: parseInt(this._data[this._pointer])
59
+ };
60
+
61
+ group.value = parseGroupValue(group.code, this._data[this._pointer + 1]);
62
+
63
+ return group;
64
+ };
65
+
66
+
67
+ DxfArrayScanner.prototype.rewind = function(numberOfGroups) {
68
+ numberOfGroups = numberOfGroups || 1;
69
+ this._pointer = this._pointer - numberOfGroups * 2;
70
+ };
71
+
72
+ /**
73
+ * Returns true if there is another code/value pair (2 elements in the array).
74
+ * @returns {boolean}
75
+ */
76
+ DxfArrayScanner.prototype.hasNext = function() {
77
+ // Check if we have read EOF group code
78
+ if(this._eof) {
79
+ return false;
80
+ }
81
+
82
+ // We need to be sure there are two lines available
83
+ if(this._pointer > this._data.length - 2) {
84
+ return false;
85
+ }
86
+ return true;
87
+ };
88
+
89
+ /**
90
+ * Returns true if the scanner is at the end of the array
91
+ * @returns {boolean}
92
+ */
93
+ DxfArrayScanner.prototype.isEOF = function() {
94
+ return this._eof;
95
+ };
96
+
97
+ /**
98
+ * Parse a value to its proper type.
99
+ * See pages 3 - 10 of the AutoCad DXF 2012 reference given at the top of this file
100
+ *
101
+ * @param code
102
+ * @param value
103
+ * @returns {*}
104
+ */
105
+ function parseGroupValue(code, value) {
106
+ if(code <= 9) return value;
107
+ if(code >= 10 && code <= 59) return parseFloat(value.trim());
108
+ if(code >= 60 && code <= 99) return parseInt(value.trim());
109
+ if(code >= 100 && code <= 109) return value;
110
+ if(code >= 110 && code <= 149) return parseFloat(value.trim());
111
+ if(code >= 160 && code <= 179) return parseInt(value.trim());
112
+ if(code >= 210 && code <= 239) return parseFloat(value.trim());
113
+ if(code >= 270 && code <= 289) return parseInt(value.trim());
114
+ if(code >= 290 && code <= 299) return parseBoolean(value.trim());
115
+ if(code >= 300 && code <= 369) return value;
116
+ if(code >= 370 && code <= 389) return parseInt(value.trim());
117
+ if(code >= 390 && code <= 399) return value;
118
+ if(code >= 400 && code <= 409) return parseInt(value.trim());
119
+ if(code >= 410 && code <= 419) return value;
120
+ if(code >= 420 && code <= 429) return parseInt(value.trim());
121
+ if(code >= 430 && code <= 439) return value;
122
+ if(code >= 440 && code <= 459) return parseInt(value.trim());
123
+ if(code >= 460 && code <= 469) return parseFloat(value.trim());
124
+ if(code >= 470 && code <= 481) return value;
125
+ if(code === 999) return value;
126
+ if(code >= 1000 && code <= 1009) return value;
127
+ if(code >= 1010 && code <= 1059) return parseFloat(value.trim());
128
+ if(code >= 1060 && code <= 1071) return parseInt(value.trim());
129
+
130
+ console.log('WARNING: Group code does not have a defined type: %j', { code: code, value: value });
131
+ return value;
132
+ }
133
+
134
+ /**
135
+ * Parse a boolean according to a 1 or 0 value
136
+ * @param str
137
+ * @returns {boolean}
138
+ */
139
+ function parseBoolean(str) {
140
+ if(str === '0') return false;
141
+ if(str === '1') return true;
142
+ throw TypeError('String \'' + str + '\' cannot be cast to Boolean type');
143
+ }