@mlightcad/data-model 1.14.9 → 1.14.11

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 (57) hide show
  1. package/dist/data-model.cjs +17 -15
  2. package/lib/base/AcDbObject.d.ts.map +1 -1
  3. package/lib/base/AcDbObject.js +9 -18
  4. package/lib/base/AcDbObject.js.map +1 -1
  5. package/lib/database/AcDbDatabase.d.ts +7 -0
  6. package/lib/database/AcDbDatabase.d.ts.map +1 -1
  7. package/lib/database/AcDbDatabase.js +18 -0
  8. package/lib/database/AcDbDatabase.js.map +1 -1
  9. package/lib/database/AcDbLayerTableRecord.d.ts +1 -1
  10. package/lib/dxf/AcDbDxfEntityFactory.d.ts.map +1 -1
  11. package/lib/dxf/AcDbDxfEntityFactory.js +3 -0
  12. package/lib/dxf/AcDbDxfEntityFactory.js.map +1 -1
  13. package/lib/entity/AcDbArcAlignedText.d.ts +174 -0
  14. package/lib/entity/AcDbArcAlignedText.d.ts.map +1 -0
  15. package/lib/entity/AcDbArcAlignedText.js +879 -0
  16. package/lib/entity/AcDbArcAlignedText.js.map +1 -0
  17. package/lib/entity/AcDbBlockReference.d.ts +8 -0
  18. package/lib/entity/AcDbBlockReference.d.ts.map +1 -1
  19. package/lib/entity/AcDbBlockReference.js +22 -7
  20. package/lib/entity/AcDbBlockReference.js.map +1 -1
  21. package/lib/entity/index.d.ts +2 -0
  22. package/lib/entity/index.d.ts.map +1 -1
  23. package/lib/entity/index.js +1 -0
  24. package/lib/entity/index.js.map +1 -1
  25. package/lib/index.d.ts +4 -4
  26. package/lib/index.d.ts.map +1 -1
  27. package/lib/index.js +3 -3
  28. package/lib/index.js.map +1 -1
  29. package/lib/misc/AcDbDynBlockConstants.d.ts +19 -0
  30. package/lib/misc/AcDbDynBlockConstants.d.ts.map +1 -0
  31. package/lib/misc/AcDbDynBlockConstants.js +23 -0
  32. package/lib/misc/AcDbDynBlockConstants.js.map +1 -0
  33. package/lib/misc/AcDbImportDynBlockMetadata.d.ts +46 -0
  34. package/lib/misc/AcDbImportDynBlockMetadata.d.ts.map +1 -0
  35. package/lib/misc/AcDbImportDynBlockMetadata.js +184 -0
  36. package/lib/misc/AcDbImportDynBlockMetadata.js.map +1 -0
  37. package/lib/misc/index.d.ts +3 -0
  38. package/lib/misc/index.d.ts.map +1 -1
  39. package/lib/misc/index.js +2 -0
  40. package/lib/misc/index.js.map +1 -1
  41. package/lib/object/AcDbBlockRepresentationData.d.ts +28 -0
  42. package/lib/object/AcDbBlockRepresentationData.d.ts.map +1 -0
  43. package/lib/object/AcDbBlockRepresentationData.js +104 -0
  44. package/lib/object/AcDbBlockRepresentationData.js.map +1 -0
  45. package/lib/object/AcDbDynBlockReference.d.ts +67 -0
  46. package/lib/object/AcDbDynBlockReference.d.ts.map +1 -0
  47. package/lib/object/AcDbDynBlockReference.js +236 -0
  48. package/lib/object/AcDbDynBlockReference.js.map +1 -0
  49. package/lib/object/AcDbDynBlockTableRecord.d.ts +28 -0
  50. package/lib/object/AcDbDynBlockTableRecord.d.ts.map +1 -0
  51. package/lib/object/AcDbDynBlockTableRecord.js +200 -0
  52. package/lib/object/AcDbDynBlockTableRecord.js.map +1 -0
  53. package/lib/object/index.d.ts +2 -0
  54. package/lib/object/index.d.ts.map +1 -1
  55. package/lib/object/index.js +2 -0
  56. package/lib/object/index.js.map +1 -1
  57. package/package.json +4 -4
@@ -0,0 +1,879 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ var __assign = (this && this.__assign) || function () {
17
+ __assign = Object.assign || function(t) {
18
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
19
+ s = arguments[i];
20
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
21
+ t[p] = s[p];
22
+ }
23
+ return t;
24
+ };
25
+ return __assign.apply(this, arguments);
26
+ };
27
+ var __read = (this && this.__read) || function (o, n) {
28
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
29
+ if (!m) return o;
30
+ var i = m.call(o), r, ar = [], e;
31
+ try {
32
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
33
+ }
34
+ catch (error) { e = { error: error }; }
35
+ finally {
36
+ try {
37
+ if (r && !r.done && (m = i["return"])) m.call(i);
38
+ }
39
+ finally { if (e) throw e.error; }
40
+ }
41
+ return ar;
42
+ };
43
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
44
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
45
+ if (ar || !(i in from)) {
46
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
47
+ ar[i] = from[i];
48
+ }
49
+ }
50
+ return to.concat(ar || Array.prototype.slice.call(from));
51
+ };
52
+ var __values = (this && this.__values) || function(o) {
53
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
54
+ if (m) return m.call(o);
55
+ if (o && typeof o.length === "number") return {
56
+ next: function () {
57
+ if (o && i >= o.length) o = void 0;
58
+ return { value: o && o[i++], done: !o };
59
+ }
60
+ };
61
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
62
+ };
63
+ import { AcCmColor } from '@mlightcad/common';
64
+ import { AcGeBox3d, AcGeMatrix3d, AcGePoint3d, AcGeVector3d } from '@mlightcad/geometry-engine';
65
+ import { AcGiMTextAttachmentPoint, AcGiMTextFlowDirection } from '@mlightcad/graphic-interface';
66
+ import { DEFAULT_TEXT_STYLE } from '../misc/AcDbConstants';
67
+ import { AcDbEntity } from './AcDbEntity';
68
+ import { acdbEstimatePlainTextWidth } from './AcDbTextExtentsHelpers';
69
+ /**
70
+ * How characters are distributed between the arc's left and right offsets.
71
+ *
72
+ * Values match DXF group 72 / LibreDWG `alignment`:
73
+ * 1 fit, 2 left, 3 right, 4 center.
74
+ */
75
+ export var AcDbArcTextAlignment;
76
+ (function (AcDbArcTextAlignment) {
77
+ AcDbArcTextAlignment[AcDbArcTextAlignment["Fit"] = 1] = "Fit";
78
+ AcDbArcTextAlignment[AcDbArcTextAlignment["Left"] = 2] = "Left";
79
+ AcDbArcTextAlignment[AcDbArcTextAlignment["Right"] = 3] = "Right";
80
+ AcDbArcTextAlignment[AcDbArcTextAlignment["Center"] = 4] = "Center";
81
+ })(AcDbArcTextAlignment || (AcDbArcTextAlignment = {}));
82
+ /**
83
+ * Which way the glyph "up" direction points relative to the arc center.
84
+ *
85
+ * Values match DXF group 71: 1 outward from center, 2 inward to the center.
86
+ */
87
+ export var AcDbArcTextDirection;
88
+ (function (AcDbArcTextDirection) {
89
+ AcDbArcTextDirection[AcDbArcTextDirection["OutwardFromCenter"] = 1] = "OutwardFromCenter";
90
+ AcDbArcTextDirection[AcDbArcTextDirection["InwardToTheCenter"] = 2] = "InwardToTheCenter";
91
+ })(AcDbArcTextDirection || (AcDbArcTextDirection = {}));
92
+ /**
93
+ * Which side of the reference arc the text sits on.
94
+ *
95
+ * Values match DXF group 73: 1 convex (outside), 2 concave (inside).
96
+ */
97
+ export var AcDbArcTextPosition;
98
+ (function (AcDbArcTextPosition) {
99
+ AcDbArcTextPosition[AcDbArcTextPosition["OnConvexSide"] = 1] = "OnConvexSide";
100
+ AcDbArcTextPosition[AcDbArcTextPosition["OnConcaveSide"] = 2] = "OnConcaveSide";
101
+ })(AcDbArcTextPosition || (AcDbArcTextPosition = {}));
102
+ var TWO_PI = Math.PI * 2;
103
+ function parseFinite(value, fallback) {
104
+ var n = typeof value === 'number' ? value : Number(value);
105
+ return Number.isFinite(n) ? n : fallback;
106
+ }
107
+ /**
108
+ * Arc-aligned text created by the AutoCAD Express Tools `ARCTEXT` command.
109
+ *
110
+ * This is not `AcDbText`. The string is laid out along an arc
111
+ * (center, radius, start angle, end angle), one glyph at a time, with its
112
+ * baseline following the arc tangent.
113
+ */
114
+ var AcDbArcAlignedText = /** @class */ (function (_super) {
115
+ __extends(AcDbArcAlignedText, _super);
116
+ function AcDbArcAlignedText() {
117
+ var _this = _super.apply(this, __spreadArray([], __read(arguments), false)) || this;
118
+ _this._textString = '';
119
+ _this._textSize = 0;
120
+ _this._xScale = 1;
121
+ _this._characterSpacing = 0;
122
+ _this._styleName = '';
123
+ _this._fontName = '';
124
+ _this._bigFontName = '';
125
+ _this._offsetFromArc = 0;
126
+ _this._rightOffset = 0;
127
+ _this._leftOffset = 0;
128
+ _this._center = new AcGePoint3d();
129
+ _this._radius = 0;
130
+ _this._startAngle = 0;
131
+ _this._endAngle = 0;
132
+ _this._normal = new AcGeVector3d(0, 0, 1);
133
+ _this._characterSet = 0;
134
+ _this._pitchAndFamily = 0;
135
+ _this._isShx = false;
136
+ _this._isBold = false;
137
+ _this._isItalic = false;
138
+ _this._isUnderlined = false;
139
+ _this._alignment = AcDbArcTextAlignment.Fit;
140
+ _this._isReverse = false;
141
+ _this._wizardFlag = 0;
142
+ _this._textPosition = AcDbArcTextPosition.OnConvexSide;
143
+ _this._textDirection = AcDbArcTextDirection.OutwardFromCenter;
144
+ _this._arcId = '';
145
+ return _this;
146
+ }
147
+ Object.defineProperty(AcDbArcAlignedText.prototype, "dxfTypeName", {
148
+ get: function () {
149
+ return 'ARCALIGNEDTEXT';
150
+ },
151
+ enumerable: false,
152
+ configurable: true
153
+ });
154
+ Object.defineProperty(AcDbArcAlignedText.prototype, "textString", {
155
+ get: function () {
156
+ return this._textString;
157
+ },
158
+ set: function (value) {
159
+ this._textString = value !== null && value !== void 0 ? value : '';
160
+ },
161
+ enumerable: false,
162
+ configurable: true
163
+ });
164
+ Object.defineProperty(AcDbArcAlignedText.prototype, "textSize", {
165
+ /** Text height (DXF group 42). */
166
+ get: function () {
167
+ return this._textSize;
168
+ },
169
+ set: function (value) {
170
+ this._textSize = value;
171
+ },
172
+ enumerable: false,
173
+ configurable: true
174
+ });
175
+ Object.defineProperty(AcDbArcAlignedText.prototype, "xScale", {
176
+ /** Width factor (DXF group 41). */
177
+ get: function () {
178
+ return this._xScale;
179
+ },
180
+ set: function (value) {
181
+ this._xScale = value;
182
+ },
183
+ enumerable: false,
184
+ configurable: true
185
+ });
186
+ Object.defineProperty(AcDbArcAlignedText.prototype, "characterSpacing", {
187
+ /** Extra distance inserted between characters, in drawing units. */
188
+ get: function () {
189
+ return this._characterSpacing;
190
+ },
191
+ set: function (value) {
192
+ this._characterSpacing = value;
193
+ },
194
+ enumerable: false,
195
+ configurable: true
196
+ });
197
+ Object.defineProperty(AcDbArcAlignedText.prototype, "styleName", {
198
+ get: function () {
199
+ return this._styleName;
200
+ },
201
+ set: function (value) {
202
+ this._styleName = value !== null && value !== void 0 ? value : '';
203
+ },
204
+ enumerable: false,
205
+ configurable: true
206
+ });
207
+ Object.defineProperty(AcDbArcAlignedText.prototype, "fontName", {
208
+ get: function () {
209
+ return this._fontName;
210
+ },
211
+ set: function (value) {
212
+ this._fontName = value !== null && value !== void 0 ? value : '';
213
+ },
214
+ enumerable: false,
215
+ configurable: true
216
+ });
217
+ Object.defineProperty(AcDbArcAlignedText.prototype, "bigFontName", {
218
+ get: function () {
219
+ return this._bigFontName;
220
+ },
221
+ set: function (value) {
222
+ this._bigFontName = value !== null && value !== void 0 ? value : '';
223
+ },
224
+ enumerable: false,
225
+ configurable: true
226
+ });
227
+ Object.defineProperty(AcDbArcAlignedText.prototype, "offsetFromArc", {
228
+ /** Radial distance from the reference arc to the text baseline. */
229
+ get: function () {
230
+ return this._offsetFromArc;
231
+ },
232
+ set: function (value) {
233
+ this._offsetFromArc = value;
234
+ },
235
+ enumerable: false,
236
+ configurable: true
237
+ });
238
+ Object.defineProperty(AcDbArcAlignedText.prototype, "rightOffset", {
239
+ get: function () {
240
+ return this._rightOffset;
241
+ },
242
+ set: function (value) {
243
+ this._rightOffset = value;
244
+ },
245
+ enumerable: false,
246
+ configurable: true
247
+ });
248
+ Object.defineProperty(AcDbArcAlignedText.prototype, "leftOffset", {
249
+ get: function () {
250
+ return this._leftOffset;
251
+ },
252
+ set: function (value) {
253
+ this._leftOffset = value;
254
+ },
255
+ enumerable: false,
256
+ configurable: true
257
+ });
258
+ Object.defineProperty(AcDbArcAlignedText.prototype, "center", {
259
+ /** Arc center in OCS (DXF group 10). */
260
+ get: function () {
261
+ return this._center;
262
+ },
263
+ set: function (value) {
264
+ this._center.copy(value);
265
+ },
266
+ enumerable: false,
267
+ configurable: true
268
+ });
269
+ Object.defineProperty(AcDbArcAlignedText.prototype, "radius", {
270
+ get: function () {
271
+ return this._radius;
272
+ },
273
+ set: function (value) {
274
+ this._radius = value;
275
+ },
276
+ enumerable: false,
277
+ configurable: true
278
+ });
279
+ Object.defineProperty(AcDbArcAlignedText.prototype, "startAngle", {
280
+ get: function () {
281
+ return this._startAngle;
282
+ },
283
+ set: function (value) {
284
+ this._startAngle = value;
285
+ },
286
+ enumerable: false,
287
+ configurable: true
288
+ });
289
+ Object.defineProperty(AcDbArcAlignedText.prototype, "endAngle", {
290
+ get: function () {
291
+ return this._endAngle;
292
+ },
293
+ set: function (value) {
294
+ this._endAngle = value;
295
+ },
296
+ enumerable: false,
297
+ configurable: true
298
+ });
299
+ Object.defineProperty(AcDbArcAlignedText.prototype, "normal", {
300
+ get: function () {
301
+ return this._normal;
302
+ },
303
+ set: function (value) {
304
+ this._normal.copy(value);
305
+ },
306
+ enumerable: false,
307
+ configurable: true
308
+ });
309
+ Object.defineProperty(AcDbArcAlignedText.prototype, "characterSet", {
310
+ get: function () {
311
+ return this._characterSet;
312
+ },
313
+ set: function (value) {
314
+ this._characterSet = value;
315
+ },
316
+ enumerable: false,
317
+ configurable: true
318
+ });
319
+ Object.defineProperty(AcDbArcAlignedText.prototype, "pitchAndFamily", {
320
+ get: function () {
321
+ return this._pitchAndFamily;
322
+ },
323
+ set: function (value) {
324
+ this._pitchAndFamily = value;
325
+ },
326
+ enumerable: false,
327
+ configurable: true
328
+ });
329
+ Object.defineProperty(AcDbArcAlignedText.prototype, "isShx", {
330
+ get: function () {
331
+ return this._isShx;
332
+ },
333
+ set: function (value) {
334
+ this._isShx = value;
335
+ },
336
+ enumerable: false,
337
+ configurable: true
338
+ });
339
+ Object.defineProperty(AcDbArcAlignedText.prototype, "isBold", {
340
+ get: function () {
341
+ return this._isBold;
342
+ },
343
+ set: function (value) {
344
+ this._isBold = value;
345
+ },
346
+ enumerable: false,
347
+ configurable: true
348
+ });
349
+ Object.defineProperty(AcDbArcAlignedText.prototype, "isItalic", {
350
+ get: function () {
351
+ return this._isItalic;
352
+ },
353
+ set: function (value) {
354
+ this._isItalic = value;
355
+ },
356
+ enumerable: false,
357
+ configurable: true
358
+ });
359
+ Object.defineProperty(AcDbArcAlignedText.prototype, "isUnderlined", {
360
+ get: function () {
361
+ return this._isUnderlined;
362
+ },
363
+ set: function (value) {
364
+ this._isUnderlined = value;
365
+ },
366
+ enumerable: false,
367
+ configurable: true
368
+ });
369
+ Object.defineProperty(AcDbArcAlignedText.prototype, "alignment", {
370
+ get: function () {
371
+ return this._alignment;
372
+ },
373
+ set: function (value) {
374
+ this._alignment = value;
375
+ },
376
+ enumerable: false,
377
+ configurable: true
378
+ });
379
+ Object.defineProperty(AcDbArcAlignedText.prototype, "isReverse", {
380
+ get: function () {
381
+ return this._isReverse;
382
+ },
383
+ set: function (value) {
384
+ this._isReverse = value;
385
+ },
386
+ enumerable: false,
387
+ configurable: true
388
+ });
389
+ Object.defineProperty(AcDbArcAlignedText.prototype, "wizardFlag", {
390
+ get: function () {
391
+ return this._wizardFlag;
392
+ },
393
+ set: function (value) {
394
+ this._wizardFlag = value;
395
+ },
396
+ enumerable: false,
397
+ configurable: true
398
+ });
399
+ Object.defineProperty(AcDbArcAlignedText.prototype, "textPosition", {
400
+ get: function () {
401
+ return this._textPosition;
402
+ },
403
+ set: function (value) {
404
+ this._textPosition = value;
405
+ },
406
+ enumerable: false,
407
+ configurable: true
408
+ });
409
+ Object.defineProperty(AcDbArcAlignedText.prototype, "textDirection", {
410
+ get: function () {
411
+ return this._textDirection;
412
+ },
413
+ set: function (value) {
414
+ this._textDirection = value;
415
+ },
416
+ enumerable: false,
417
+ configurable: true
418
+ });
419
+ Object.defineProperty(AcDbArcAlignedText.prototype, "arcId", {
420
+ /** Handle of the arc this text was created from (DXF group 330). */
421
+ get: function () {
422
+ return this._arcId;
423
+ },
424
+ set: function (value) {
425
+ this._arcId = value !== null && value !== void 0 ? value : '';
426
+ },
427
+ enumerable: false,
428
+ configurable: true
429
+ });
430
+ /**
431
+ * Applies the arc-text color (DXF group 90 / LibreDWG `color`).
432
+ *
433
+ * `0` is ByBlock, `256` is ByLayer, `1..255` is an ACI index. Larger values
434
+ * are treated as a CMC color whose high byte is the method.
435
+ */
436
+ AcDbArcAlignedText.prototype.applyRawTextColor = function (raw) {
437
+ if (!Number.isFinite(raw))
438
+ return;
439
+ var color = new AcCmColor();
440
+ var method = (raw >>> 24) & 0xff;
441
+ if (raw === 0 || method === 0xc1) {
442
+ color.setByBlock();
443
+ }
444
+ else if (raw === 256 || method === 0xc0 || method === 0xc8) {
445
+ color.setByLayer();
446
+ }
447
+ else if (raw > 0 && raw < 256) {
448
+ color.colorIndex = raw;
449
+ }
450
+ else if (method === 0xc2 || method === 0xc3 || method === 0xc5) {
451
+ color.setRGBValue(raw & 0xffffff);
452
+ }
453
+ else {
454
+ return;
455
+ }
456
+ this._rawTextColor = raw;
457
+ this.color = color;
458
+ };
459
+ /**
460
+ * Encodes the entity color as DXF group 90 / LibreDWG `rawTextColor`.
461
+ *
462
+ * Prefers the last value passed to {@link applyRawTextColor} so DWG→DXF
463
+ * round-trips keep the original packed form.
464
+ */
465
+ AcDbArcAlignedText.prototype.rawTextColor = function () {
466
+ if (this._rawTextColor != null && Number.isFinite(this._rawTextColor)) {
467
+ return this._rawTextColor;
468
+ }
469
+ if (this.color.isByBlock)
470
+ return 0;
471
+ if (this.color.isByLayer)
472
+ return 256;
473
+ var aci = this.color.colorIndex;
474
+ if (aci != null && aci > 0 && aci < 256)
475
+ return aci;
476
+ var rgb = this.color.RGB;
477
+ if (rgb != null)
478
+ return ((0xc2 << 24) | (rgb & 0xffffff)) >> 0;
479
+ return 256;
480
+ };
481
+ /**
482
+ * Places each character on the reference arc.
483
+ *
484
+ * The arc runs counter-clockwise from {@link startAngle} to {@link endAngle}.
485
+ * {@link offsetFromArc} is the gap to the nearest text edge. Inward text
486
+ * sits with its baseline one text height farther from the center.
487
+ */
488
+ AcDbArcAlignedText.prototype.glyphPlacements = function () {
489
+ var _a, _b;
490
+ var chars = Array.from(this._textString).filter(function (ch) { return ch !== '\r'; });
491
+ if (this._isReverse)
492
+ chars.reverse();
493
+ if (chars.length === 0)
494
+ return [];
495
+ var height = this._textSize > 0 ? this._textSize : 1;
496
+ var widthFactor = this._xScale > 0 ? this._xScale : 1;
497
+ var widths = chars.map(function (ch) {
498
+ return ch === ' ' || ch === '\n'
499
+ ? height * 0.5 * widthFactor
500
+ : acdbEstimatePlainTextWidth(ch, height, widthFactor);
501
+ });
502
+ var widthsSum = widths.reduce(function (sum, width) { return sum + width; }, 0);
503
+ var convex = this._textPosition !== AcDbArcTextPosition.OnConcaveSide;
504
+ var outward = this._textDirection === AcDbArcTextDirection.OutwardFromCenter;
505
+ // Offset is the gap between the arc and the nearest edge of the text,
506
+ // not the baseline. Inward text has its baseline on the outer edge.
507
+ var arcEdge = Math.abs(this._radius) + (convex ? 1 : -1) * this._offsetFromArc;
508
+ var heightShift = convex === outward ? 0 : convex ? height : -height;
509
+ var radius = Math.max(1e-6, arcEdge + heightShift);
510
+ var sweep = this._endAngle - this._startAngle;
511
+ while (sweep <= 1e-9)
512
+ sweep += TWO_PI;
513
+ while (sweep > TWO_PI)
514
+ sweep -= TWO_PI;
515
+ var arcLength = sweep * radius;
516
+ var usable = Math.max(0, arcLength - this._leftOffset - this._rightOffset);
517
+ var gaps = Math.max(0, chars.length - 1);
518
+ var gap = this._characterSpacing;
519
+ if (this._alignment === AcDbArcTextAlignment.Fit && gaps > 0) {
520
+ gap = (usable - widthsSum) / gaps;
521
+ }
522
+ var natural = widthsSum + gap * gaps;
523
+ var distance = this._leftOffset;
524
+ if (this._alignment === AcDbArcTextAlignment.Right) {
525
+ distance = arcLength - this._rightOffset - natural;
526
+ }
527
+ else if (this._alignment === AcDbArcTextAlignment.Center ||
528
+ this._alignment === 0) {
529
+ distance = this._leftOffset + (usable - natural) / 2;
530
+ }
531
+ var extrusion = this.extrusionMatrix();
532
+ var glyphs = [];
533
+ for (var i = 0; i < chars.length; i++) {
534
+ var width = (_a = widths[i]) !== null && _a !== void 0 ? _a : 0;
535
+ var char = (_b = chars[i]) !== null && _b !== void 0 ? _b : '';
536
+ if (char === '\n')
537
+ continue;
538
+ var mid = distance + width / 2;
539
+ var angle = this._startAngle + mid / radius;
540
+ var local = new AcGePoint3d(this._center.x + radius * Math.cos(angle), this._center.y + radius * Math.sin(angle), this._center.z);
541
+ // Group 71 = 1 points glyph tops away from the center. Group 71 = 2
542
+ // points them toward the center, which keeps text upright along the
543
+ // bottom of a counter-clockwise arc.
544
+ var rotation = angle + Math.PI / 2;
545
+ if (this._textDirection === AcDbArcTextDirection.OutwardFromCenter) {
546
+ rotation += Math.PI;
547
+ }
548
+ glyphs.push({
549
+ text: char,
550
+ position: local.applyMatrix4(extrusion),
551
+ rotation: this.rotationInWcs(rotation, extrusion)
552
+ });
553
+ distance += width + gap;
554
+ }
555
+ return glyphs;
556
+ };
557
+ Object.defineProperty(AcDbArcAlignedText.prototype, "geometricExtents", {
558
+ get: function () {
559
+ var e_1, _a;
560
+ var box = new AcGeBox3d();
561
+ var glyphs = this.glyphPlacements();
562
+ if (glyphs.length === 0) {
563
+ box.expandByPoint(this._center);
564
+ return box;
565
+ }
566
+ var height = this._textSize > 0 ? this._textSize : 1;
567
+ try {
568
+ for (var glyphs_1 = __values(glyphs), glyphs_1_1 = glyphs_1.next(); !glyphs_1_1.done; glyphs_1_1 = glyphs_1.next()) {
569
+ var glyph = glyphs_1_1.value;
570
+ var width = acdbEstimatePlainTextWidth(glyph.text, height, this._xScale > 0 ? this._xScale : 1);
571
+ var half = Math.max(width, height) / 2;
572
+ box.expandByPoint(new AcGePoint3d(glyph.position.x - half, glyph.position.y - half, glyph.position.z));
573
+ box.expandByPoint(new AcGePoint3d(glyph.position.x + half, glyph.position.y + half, glyph.position.z));
574
+ }
575
+ }
576
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
577
+ finally {
578
+ try {
579
+ if (glyphs_1_1 && !glyphs_1_1.done && (_a = glyphs_1.return)) _a.call(glyphs_1);
580
+ }
581
+ finally { if (e_1) throw e_1.error; }
582
+ }
583
+ return box;
584
+ },
585
+ enumerable: false,
586
+ configurable: true
587
+ });
588
+ Object.defineProperty(AcDbArcAlignedText.prototype, "properties", {
589
+ get: function () {
590
+ var _this = this;
591
+ return {
592
+ type: this.type,
593
+ groups: [
594
+ this.getGeneralProperties(),
595
+ {
596
+ groupName: 'text',
597
+ properties: [
598
+ {
599
+ name: 'contents',
600
+ type: 'string',
601
+ editable: true,
602
+ accessor: {
603
+ get: function () { return _this.textString; },
604
+ set: function (v) {
605
+ _this.textString = v;
606
+ }
607
+ }
608
+ },
609
+ {
610
+ name: 'styleName',
611
+ type: 'string',
612
+ editable: true,
613
+ accessor: {
614
+ get: function () { return _this.styleName; },
615
+ set: function (v) {
616
+ _this.styleName = v;
617
+ }
618
+ }
619
+ },
620
+ {
621
+ name: 'textHeight',
622
+ type: 'float',
623
+ editable: true,
624
+ accessor: {
625
+ get: function () { return _this.textSize; },
626
+ set: function (v) {
627
+ _this.textSize = v;
628
+ }
629
+ }
630
+ }
631
+ ]
632
+ }
633
+ ]
634
+ };
635
+ },
636
+ enumerable: false,
637
+ configurable: true
638
+ });
639
+ AcDbArcAlignedText.prototype.subWorldDraw = function (renderer, delay) {
640
+ var e_2, _a;
641
+ var glyphs = this.glyphPlacements();
642
+ if (glyphs.length === 0)
643
+ return undefined;
644
+ var style = this.getTextStyle();
645
+ var height = this._textSize > 0 ? this._textSize : 1;
646
+ var entities = [];
647
+ try {
648
+ for (var glyphs_2 = __values(glyphs), glyphs_2_1 = glyphs_2.next(); !glyphs_2_1.done; glyphs_2_1 = glyphs_2.next()) {
649
+ var glyph = glyphs_2_1.value;
650
+ var text = this._isUnderlined ? "\\L".concat(glyph.text) : glyph.text;
651
+ var mtextData = {
652
+ text: text,
653
+ height: height,
654
+ width: Infinity,
655
+ widthFactor: this._xScale > 0 ? this._xScale : 1,
656
+ position: glyph.position,
657
+ rotation: glyph.rotation,
658
+ drawingDirection: AcGiMTextFlowDirection.BOTTOM_TO_TOP,
659
+ attachmentPoint: AcGiMTextAttachmentPoint.BaselineCenter
660
+ };
661
+ entities.push(renderer.mtext(mtextData, style, delay));
662
+ }
663
+ }
664
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
665
+ finally {
666
+ try {
667
+ if (glyphs_2_1 && !glyphs_2_1.done && (_a = glyphs_2.return)) _a.call(glyphs_2);
668
+ }
669
+ finally { if (e_2) throw e_2.error; }
670
+ }
671
+ if (entities.length === 1)
672
+ return entities[0];
673
+ return renderer.group(entities);
674
+ };
675
+ AcDbArcAlignedText.prototype.dxfOutFields = function (filer) {
676
+ _super.prototype.dxfOutFields.call(this, filer);
677
+ filer.writeSubclassMarker('AcDbArcAlignedText');
678
+ filer.writeString(1, this._textString);
679
+ filer.writeString(2, this._fontName);
680
+ filer.writeString(3, this._bigFontName);
681
+ filer.writeString(7, this._styleName);
682
+ filer.writePoint3d(10, this._center);
683
+ filer.writeDouble(40, this._radius);
684
+ filer.writeDouble(41, this._xScale);
685
+ filer.writeDouble(42, this._textSize);
686
+ filer.writeDouble(43, this._characterSpacing);
687
+ filer.writeDouble(44, this._offsetFromArc);
688
+ filer.writeDouble(45, this._rightOffset);
689
+ filer.writeDouble(46, this._leftOffset);
690
+ filer.writeAngle(50, this._startAngle);
691
+ filer.writeAngle(51, this._endAngle);
692
+ filer.writeInt16(70, this._isReverse ? 1 : 0);
693
+ filer.writeInt16(71, this._textDirection);
694
+ filer.writeInt16(72, this._alignment);
695
+ filer.writeInt16(73, this._textPosition);
696
+ filer.writeInt16(74, this._isBold ? 1 : 0);
697
+ filer.writeInt16(75, this._isItalic ? 1 : 0);
698
+ filer.writeInt16(76, this._isUnderlined ? 1 : 0);
699
+ filer.writeInt16(77, this._characterSet);
700
+ filer.writeInt16(78, this._pitchAndFamily);
701
+ filer.writeInt16(79, this._isShx ? 1 : 0);
702
+ filer.writeInt32(90, this.rawTextColor());
703
+ filer.writeVector3d(210, this._normal);
704
+ filer.writeInt16(280, this._wizardFlag);
705
+ if (this._arcId)
706
+ filer.writeHandle(330, this._arcId);
707
+ return this;
708
+ };
709
+ AcDbArcAlignedText.prototype.dxfInFields = function (filer) {
710
+ _super.prototype.dxfInFields.call(this, filer);
711
+ filer.atSubclassData('AcDbArcAlignedText');
712
+ var cx = this._center.x;
713
+ var cy = this._center.y;
714
+ var cz = this._center.z;
715
+ var nx = this._normal.x;
716
+ var ny = this._normal.y;
717
+ var nz = this._normal.z;
718
+ while (!filer.atEndOfObject && !filer.atEof && !filer.atExtendedData) {
719
+ var item = filer.readItem();
720
+ if (!item)
721
+ break;
722
+ var code = Number(item.code);
723
+ var n = Number(item.value);
724
+ var text = item.value == null ? '' : String(item.value);
725
+ switch (code) {
726
+ case 1:
727
+ this._textString = text;
728
+ break;
729
+ case 2:
730
+ this._fontName = text;
731
+ break;
732
+ case 3:
733
+ this._bigFontName = text;
734
+ break;
735
+ case 7:
736
+ this._styleName = text;
737
+ break;
738
+ case 10:
739
+ cx = n;
740
+ break;
741
+ case 20:
742
+ cy = n;
743
+ break;
744
+ case 30:
745
+ cz = n;
746
+ break;
747
+ case 40:
748
+ this._radius = n;
749
+ break;
750
+ case 41:
751
+ this._xScale = n;
752
+ break;
753
+ case 42:
754
+ this._textSize = n;
755
+ break;
756
+ case 43:
757
+ this._characterSpacing = n;
758
+ break;
759
+ case 44:
760
+ this._offsetFromArc = n;
761
+ break;
762
+ case 45:
763
+ this._rightOffset = n;
764
+ break;
765
+ case 46:
766
+ this._leftOffset = n;
767
+ break;
768
+ case 50:
769
+ this._startAngle = n;
770
+ break;
771
+ case 51:
772
+ this._endAngle = n;
773
+ break;
774
+ case 70:
775
+ this._isReverse = n !== 0;
776
+ break;
777
+ case 71:
778
+ this._textDirection = n;
779
+ break;
780
+ case 72:
781
+ this._alignment = n;
782
+ break;
783
+ case 73:
784
+ this._textPosition = n;
785
+ break;
786
+ case 74:
787
+ this._isBold = n !== 0;
788
+ break;
789
+ case 75:
790
+ this._isItalic = n !== 0;
791
+ break;
792
+ case 76:
793
+ this._isUnderlined = n !== 0;
794
+ break;
795
+ case 77:
796
+ this._characterSet = n;
797
+ break;
798
+ case 78:
799
+ this._pitchAndFamily = n;
800
+ break;
801
+ case 79:
802
+ this._isShx = n !== 0;
803
+ break;
804
+ case 90:
805
+ this.applyRawTextColor(n);
806
+ break;
807
+ case 210:
808
+ nx = n;
809
+ break;
810
+ case 220:
811
+ ny = n;
812
+ break;
813
+ case 230:
814
+ nz = n;
815
+ break;
816
+ case 280:
817
+ this._wizardFlag = n;
818
+ break;
819
+ case 330:
820
+ this._arcId = text;
821
+ break;
822
+ default:
823
+ break;
824
+ }
825
+ }
826
+ this._center.set(cx, cy, cz);
827
+ this._normal.set(nx, ny, nz);
828
+ return this;
829
+ };
830
+ AcDbArcAlignedText.prototype.getTextStyle = function () {
831
+ var _a, _b, _c;
832
+ var table = (_b = (_a = this.database) === null || _a === void 0 ? void 0 : _a.tables) === null || _b === void 0 ? void 0 : _b.textStyleTable;
833
+ var record = (_c = table === null || table === void 0 ? void 0 : table.resolveAt(this._styleName)) !== null && _c !== void 0 ? _c : table === null || table === void 0 ? void 0 : table.resolveAt(DEFAULT_TEXT_STYLE);
834
+ var style = record
835
+ ? __assign({}, record.textStyle) : {
836
+ name: this._styleName || DEFAULT_TEXT_STYLE,
837
+ standardFlag: 0,
838
+ fixedTextHeight: 0,
839
+ widthFactor: this._xScale > 0 ? this._xScale : 1,
840
+ obliqueAngle: 0,
841
+ textGenerationFlag: 0,
842
+ lastHeight: this._textSize,
843
+ font: this._fontName || 'txt',
844
+ bigFont: this._bigFontName
845
+ };
846
+ if (this._fontName)
847
+ style.font = this._fontName;
848
+ if (this._bigFontName)
849
+ style.bigFont = this._bigFontName;
850
+ if (this._xScale > 0)
851
+ style.widthFactor = this._xScale;
852
+ return style;
853
+ };
854
+ AcDbArcAlignedText.prototype.isPlanarInWcs = function () {
855
+ return (Math.abs(this._normal.x) < 1e-10 &&
856
+ Math.abs(this._normal.y) < 1e-10 &&
857
+ this._normal.z > 0);
858
+ };
859
+ AcDbArcAlignedText.prototype.extrusionMatrix = function () {
860
+ if (this.isPlanarInWcs())
861
+ return new AcGeMatrix3d();
862
+ return new AcGeMatrix3d().setFromExtrusionDirection(this._normal);
863
+ };
864
+ AcDbArcAlignedText.prototype.rotationInWcs = function (rotation, extrusion) {
865
+ if (this.isPlanarInWcs())
866
+ return rotation;
867
+ var axis = new AcGeVector3d(Math.cos(rotation), Math.sin(rotation), 0);
868
+ axis.transformDirection(extrusion);
869
+ return Math.atan2(axis.y, axis.x);
870
+ };
871
+ AcDbArcAlignedText.typeName = 'ArcAlignedText';
872
+ return AcDbArcAlignedText;
873
+ }(AcDbEntity));
874
+ export { AcDbArcAlignedText };
875
+ export function acdbParseArcAlignedNumber(value, fallback) {
876
+ if (fallback === void 0) { fallback = 0; }
877
+ return parseFinite(value, fallback);
878
+ }
879
+ //# sourceMappingURL=AcDbArcAlignedText.js.map