@mlightcad/data-model 1.7.28 → 1.7.29
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.
- package/dist/data-model.cjs +4 -4
- package/dist/data-model.js +2805 -2126
- package/dist/dxf-parser-worker.js +325 -304
- package/lib/converter/AcDbDxfConverter.d.ts +1 -0
- package/lib/converter/AcDbDxfConverter.d.ts.map +1 -1
- package/lib/converter/AcDbDxfConverter.js +20 -1
- package/lib/converter/AcDbDxfConverter.js.map +1 -1
- package/lib/converter/AcDbEntitiyConverter.d.ts.map +1 -1
- package/lib/converter/AcDbEntitiyConverter.js +18 -42
- package/lib/converter/AcDbEntitiyConverter.js.map +1 -1
- package/lib/converter/AcDbObjectConverter.d.ts.map +1 -1
- package/lib/converter/AcDbObjectConverter.js +30 -11
- package/lib/converter/AcDbObjectConverter.js.map +1 -1
- package/lib/database/AcDbBlockTableRecord.d.ts.map +1 -1
- package/lib/database/AcDbBlockTableRecord.js +1 -0
- package/lib/database/AcDbBlockTableRecord.js.map +1 -1
- package/lib/database/AcDbDatabase.d.ts +38 -0
- package/lib/database/AcDbDatabase.d.ts.map +1 -1
- package/lib/database/AcDbDatabase.js +193 -27
- package/lib/database/AcDbDatabase.js.map +1 -1
- package/lib/database/AcDbSysVarManager.d.ts.map +1 -1
- package/lib/database/AcDbSysVarManager.js +28 -1
- package/lib/database/AcDbSysVarManager.js.map +1 -1
- package/lib/database/AcDbSystemVariables.d.ts +7 -1
- package/lib/database/AcDbSystemVariables.d.ts.map +1 -1
- package/lib/database/AcDbSystemVariables.js +6 -0
- package/lib/database/AcDbSystemVariables.js.map +1 -1
- package/lib/entity/AcDbMLeader.d.ts +200 -7
- package/lib/entity/AcDbMLeader.d.ts.map +1 -1
- package/lib/entity/AcDbMLeader.js +456 -25
- package/lib/entity/AcDbMLeader.js.map +1 -1
- package/lib/entity/AcDbMLine.d.ts +548 -0
- package/lib/entity/AcDbMLine.d.ts.map +1 -1
- package/lib/entity/AcDbMLine.js +986 -24
- package/lib/entity/AcDbMLine.js.map +1 -1
- package/lib/misc/AcDbConstants.d.ts +14 -0
- package/lib/misc/AcDbConstants.d.ts.map +1 -1
- package/lib/misc/AcDbConstants.js +14 -0
- package/lib/misc/AcDbConstants.js.map +1 -1
- package/lib/misc/AcDbMLeaderStyleColorCodec.d.ts +59 -0
- package/lib/misc/AcDbMLeaderStyleColorCodec.d.ts.map +1 -0
- package/lib/misc/AcDbMLeaderStyleColorCodec.js +101 -0
- package/lib/misc/AcDbMLeaderStyleColorCodec.js.map +1 -0
- package/lib/misc/index.d.ts +1 -0
- package/lib/misc/index.d.ts.map +1 -1
- package/lib/misc/index.js +1 -0
- package/lib/misc/index.js.map +1 -1
- package/lib/object/AcDbMLeaderStyle.d.ts +9 -8
- package/lib/object/AcDbMLeaderStyle.d.ts.map +1 -1
- package/lib/object/AcDbMLeaderStyle.js +11 -9
- package/lib/object/AcDbMLeaderStyle.js.map +1 -1
- package/lib/object/AcDbMlineStyle.d.ts +5 -4
- package/lib/object/AcDbMlineStyle.d.ts.map +1 -1
- package/lib/object/AcDbMlineStyle.js +12 -18
- package/lib/object/AcDbMlineStyle.js.map +1 -1
- package/package.json +5 -5
|
@@ -13,6 +13,17 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
13
13
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
14
|
};
|
|
15
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
|
+
};
|
|
16
27
|
var __read = (this && this.__read) || function (o, n) {
|
|
17
28
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
18
29
|
if (!m) return o;
|
|
@@ -38,9 +49,20 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
38
49
|
}
|
|
39
50
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
40
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
|
+
};
|
|
41
63
|
import { AcGeArea2d, AcGeBox3d, AcGeMatrix3d, AcGePoint3d, AcGePolyline2d, AcGeVector3d } from '@mlightcad/geometry-engine';
|
|
42
64
|
import { AcGiMTextAttachmentPoint, AcGiMTextFlowDirection } from '@mlightcad/graphic-interface';
|
|
43
|
-
import { AcDbRenderingCache, DEFAULT_TEXT_STYLE } from '../misc';
|
|
65
|
+
import { AcDbRenderingCache, decodeMLeaderStyleRawColor, DEFAULT_MLEADER_STYLE, DEFAULT_TEXT_STYLE } from '../misc';
|
|
44
66
|
import { AcDbEntity } from './AcDbEntity';
|
|
45
67
|
/**
|
|
46
68
|
* Defines the type of leader line used by a multileader.
|
|
@@ -94,6 +116,13 @@ export var AcDbMLeaderDirectionType;
|
|
|
94
116
|
/** Leader points below the content. */
|
|
95
117
|
AcDbMLeaderDirectionType[AcDbMLeaderDirectionType["Bottom"] = 4] = "Bottom";
|
|
96
118
|
})(AcDbMLeaderDirectionType || (AcDbMLeaderDirectionType = {}));
|
|
119
|
+
var MLEADER_OVERRIDE_LEADER_LINE_TYPE = 1 << 0;
|
|
120
|
+
var MLEADER_OVERRIDE_LEADER_LINE_COLOR = 1 << 1;
|
|
121
|
+
var MLEADER_OVERRIDE_LEADER_LINE_TYPE_ID = 1 << 2;
|
|
122
|
+
var MLEADER_OVERRIDE_LEADER_LINE_WEIGHT = 1 << 3;
|
|
123
|
+
var MLEADER_OVERRIDE_DOGLEG_ENABLED = 1 << 6;
|
|
124
|
+
var MLEADER_OVERRIDE_DOGLEG_LENGTH = 1 << 7;
|
|
125
|
+
var MLEADER_OVERRIDE_TEXT_COLOR = 1 << 15;
|
|
97
126
|
/**
|
|
98
127
|
* Represents a multileader entity.
|
|
99
128
|
*
|
|
@@ -104,6 +133,10 @@ var AcDbMLeader = /** @class */ (function (_super) {
|
|
|
104
133
|
__extends(AcDbMLeader, _super);
|
|
105
134
|
/**
|
|
106
135
|
* Creates an empty multileader entity with default style-related state.
|
|
136
|
+
*
|
|
137
|
+
* @remarks
|
|
138
|
+
* Initializes geometry, text, and block-related members to defaults that
|
|
139
|
+
* are compatible with common MLEADER behavior.
|
|
107
140
|
*/
|
|
108
141
|
function AcDbMLeader() {
|
|
109
142
|
var _this = _super.call(this) || this;
|
|
@@ -1227,6 +1260,9 @@ var AcDbMLeader = /** @class */ (function (_super) {
|
|
|
1227
1260
|
});
|
|
1228
1261
|
/**
|
|
1229
1262
|
* Adds a leader branch and returns its index.
|
|
1263
|
+
*
|
|
1264
|
+
* @param leader Optional leader payload used to initialize branch data.
|
|
1265
|
+
* @returns Index of the newly added leader branch.
|
|
1230
1266
|
*/
|
|
1231
1267
|
AcDbMLeader.prototype.addLeader = function (leader) {
|
|
1232
1268
|
var _this = this;
|
|
@@ -1262,6 +1298,9 @@ var AcDbMLeader = /** @class */ (function (_super) {
|
|
|
1262
1298
|
};
|
|
1263
1299
|
/**
|
|
1264
1300
|
* Removes a leader branch.
|
|
1301
|
+
*
|
|
1302
|
+
* @param leaderIndex Zero-based index of the leader branch to remove.
|
|
1303
|
+
* @returns The current entity instance for chaining.
|
|
1265
1304
|
*/
|
|
1266
1305
|
AcDbMLeader.prototype.removeLeader = function (leaderIndex) {
|
|
1267
1306
|
this.checkLeaderIndex(leaderIndex);
|
|
@@ -1270,6 +1309,10 @@ var AcDbMLeader = /** @class */ (function (_super) {
|
|
|
1270
1309
|
};
|
|
1271
1310
|
/**
|
|
1272
1311
|
* Adds a leader line to a leader branch and returns the line index.
|
|
1312
|
+
*
|
|
1313
|
+
* @param leaderIndex Index of the target leader branch.
|
|
1314
|
+
* @param vertices Optional initial vertices for the leader line.
|
|
1315
|
+
* @returns Index of the newly added leader line.
|
|
1273
1316
|
*/
|
|
1274
1317
|
AcDbMLeader.prototype.addLeaderLine = function (leaderIndex, vertices) {
|
|
1275
1318
|
if (vertices === void 0) { vertices = []; }
|
|
@@ -1279,6 +1322,11 @@ var AcDbMLeader = /** @class */ (function (_super) {
|
|
|
1279
1322
|
};
|
|
1280
1323
|
/**
|
|
1281
1324
|
* Appends a vertex to one leader line.
|
|
1325
|
+
*
|
|
1326
|
+
* @param leaderIndex Index of the target leader branch.
|
|
1327
|
+
* @param leaderLineIndex Index of the target leader line.
|
|
1328
|
+
* @param point Vertex to append.
|
|
1329
|
+
* @returns The current entity instance for chaining.
|
|
1282
1330
|
*/
|
|
1283
1331
|
AcDbMLeader.prototype.appendVertex = function (leaderIndex, leaderLineIndex, point) {
|
|
1284
1332
|
this.getMutableLeaderLine(leaderIndex, leaderLineIndex).vertices.push(this.createPoint(point));
|
|
@@ -1286,6 +1334,11 @@ var AcDbMLeader = /** @class */ (function (_super) {
|
|
|
1286
1334
|
};
|
|
1287
1335
|
/**
|
|
1288
1336
|
* Replaces the vertices of one leader line.
|
|
1337
|
+
*
|
|
1338
|
+
* @param leaderIndex Index of the target leader branch.
|
|
1339
|
+
* @param leaderLineIndex Index of the target leader line.
|
|
1340
|
+
* @param vertices New vertex sequence.
|
|
1341
|
+
* @returns The current entity instance for chaining.
|
|
1289
1342
|
*/
|
|
1290
1343
|
AcDbMLeader.prototype.setLeaderLineVertices = function (leaderIndex, leaderLineIndex, vertices) {
|
|
1291
1344
|
var _this = this;
|
|
@@ -1580,6 +1633,20 @@ var AcDbMLeader = /** @class */ (function (_super) {
|
|
|
1580
1633
|
enumerable: false,
|
|
1581
1634
|
configurable: true
|
|
1582
1635
|
});
|
|
1636
|
+
/**
|
|
1637
|
+
* @inheritdoc
|
|
1638
|
+
*
|
|
1639
|
+
* @returns The current entity instance with effective properties resolved.
|
|
1640
|
+
*/
|
|
1641
|
+
AcDbMLeader.prototype.resolveEffectiveProperties = function () {
|
|
1642
|
+
_super.prototype.resolveEffectiveProperties.call(this);
|
|
1643
|
+
if (this._mleaderStyleId)
|
|
1644
|
+
return;
|
|
1645
|
+
var style = this.getDefaultMLeaderStyle();
|
|
1646
|
+
if (style) {
|
|
1647
|
+
this._mleaderStyleId = style.objectId;
|
|
1648
|
+
}
|
|
1649
|
+
};
|
|
1583
1650
|
/**
|
|
1584
1651
|
* Builds renderable primitives for this multileader entity.
|
|
1585
1652
|
*
|
|
@@ -1589,7 +1656,18 @@ var AcDbMLeader = /** @class */ (function (_super) {
|
|
|
1589
1656
|
AcDbMLeader.prototype.subWorldDraw = function (renderer) {
|
|
1590
1657
|
var _this = this;
|
|
1591
1658
|
var entities = [];
|
|
1592
|
-
|
|
1659
|
+
var traits = renderer.subEntityTraits;
|
|
1660
|
+
var originalColor = traits.color;
|
|
1661
|
+
var originalRgbColor = traits.rgbColor;
|
|
1662
|
+
var originalLineType = traits.lineType;
|
|
1663
|
+
var originalLineWeight = traits.lineWeight;
|
|
1664
|
+
var leaderLineColor = this.getResolvedLeaderLineColor();
|
|
1665
|
+
var leaderLineStyle = this.getResolvedLeaderLineStyle();
|
|
1666
|
+
var leaderLineWeight = this.getResolvedLeaderLineWeight();
|
|
1667
|
+
var textColor = this.getResolvedTextColor();
|
|
1668
|
+
if (this.getResolvedLeaderLineType() !== AcDbMLeaderLineType.InvisibleLeader) {
|
|
1669
|
+
this.applyColorTraits(traits, leaderLineColor, originalColor, originalRgbColor);
|
|
1670
|
+
this.applyLineTraits(traits, leaderLineStyle, leaderLineWeight);
|
|
1593
1671
|
this._leaders.forEach(function (leader) {
|
|
1594
1672
|
leader.leaderLines.forEach(function (line) {
|
|
1595
1673
|
var points = _this.getLeaderLineDrawPoints(leader, line);
|
|
@@ -1608,6 +1686,7 @@ var AcDbMLeader = /** @class */ (function (_super) {
|
|
|
1608
1686
|
var mtextContent = this.getRenderableMTextContent();
|
|
1609
1687
|
if (this.contentType === AcDbMLeaderContentType.MTextContent &&
|
|
1610
1688
|
mtextContent) {
|
|
1689
|
+
this.applyColorTraits(traits, textColor, originalColor, originalRgbColor);
|
|
1611
1690
|
var textHeight = this.getResolvedTextHeight();
|
|
1612
1691
|
var mtextData = {
|
|
1613
1692
|
text: mtextContent.text,
|
|
@@ -1624,6 +1703,10 @@ var AcDbMLeader = /** @class */ (function (_super) {
|
|
|
1624
1703
|
// only scheduled for top-level entities, so render nested MText eagerly.
|
|
1625
1704
|
entities.push(renderer.mtext(mtextData, this.getTextStyle(), false));
|
|
1626
1705
|
}
|
|
1706
|
+
traits.color = originalColor;
|
|
1707
|
+
traits.rgbColor = originalRgbColor;
|
|
1708
|
+
traits.lineType = originalLineType;
|
|
1709
|
+
traits.lineWeight = originalLineWeight;
|
|
1627
1710
|
if (entities.length === 0)
|
|
1628
1711
|
return undefined;
|
|
1629
1712
|
return entities.length === 1 ? entities[0] : renderer.group(entities);
|
|
@@ -1745,6 +1828,8 @@ var AcDbMLeader = /** @class */ (function (_super) {
|
|
|
1745
1828
|
* Validates that a leader index is in range.
|
|
1746
1829
|
*
|
|
1747
1830
|
* @param leaderIndex Leader branch index to validate.
|
|
1831
|
+
* @throws {Error} Thrown when `leaderIndex` is outside valid range.
|
|
1832
|
+
* @returns `void`.
|
|
1748
1833
|
*/
|
|
1749
1834
|
AcDbMLeader.prototype.checkLeaderIndex = function (leaderIndex) {
|
|
1750
1835
|
if (leaderIndex < 0 || leaderIndex >= this._leaders.length) {
|
|
@@ -1833,34 +1918,20 @@ var AcDbMLeader = /** @class */ (function (_super) {
|
|
|
1833
1918
|
* @returns Dogleg segment points, or `undefined` if not applicable.
|
|
1834
1919
|
*/
|
|
1835
1920
|
AcDbMLeader.prototype.getDoglegPoints = function (leader) {
|
|
1836
|
-
var _a, _b, _c, _d
|
|
1837
|
-
if (!this.
|
|
1921
|
+
var _a, _b, _c, _d;
|
|
1922
|
+
if (!this.getResolvedDoglegEnabled())
|
|
1838
1923
|
return undefined;
|
|
1839
|
-
var start = (
|
|
1840
|
-
var vector = (
|
|
1841
|
-
var length = (
|
|
1842
|
-
if (!start || length === 0 || vector.lengthSq() === 0)
|
|
1924
|
+
var start = (_b = (_a = leader.lastLeaderLinePoint) !== null && _a !== void 0 ? _a : leader.landingPoint) !== null && _b !== void 0 ? _b : this._landingPoint;
|
|
1925
|
+
var vector = (_c = leader.doglegVector) !== null && _c !== void 0 ? _c : this._doglegVector;
|
|
1926
|
+
var length = (_d = leader.doglegLength) !== null && _d !== void 0 ? _d : this.getResolvedDoglegLength();
|
|
1927
|
+
if (!start || length == null || length === 0 || vector.lengthSq() === 0) {
|
|
1843
1928
|
return undefined;
|
|
1929
|
+
}
|
|
1844
1930
|
var end = start
|
|
1845
1931
|
.clone()
|
|
1846
1932
|
.add(vector.clone().normalize().multiplyScalar(length));
|
|
1847
1933
|
return [start, end];
|
|
1848
1934
|
};
|
|
1849
|
-
/**
|
|
1850
|
-
* Gets the last available vertex from all lines in one leader branch.
|
|
1851
|
-
*
|
|
1852
|
-
* @param leader Leader branch to inspect.
|
|
1853
|
-
* @returns The last vertex, or `undefined` when no vertices exist.
|
|
1854
|
-
*/
|
|
1855
|
-
AcDbMLeader.prototype.getLastLeaderLineVertex = function (leader) {
|
|
1856
|
-
for (var i = leader.leaderLines.length - 1; i >= 0; i--) {
|
|
1857
|
-
var line = leader.leaderLines[i];
|
|
1858
|
-
if (line.vertices.length > 0) {
|
|
1859
|
-
return line.vertices[line.vertices.length - 1];
|
|
1860
|
-
}
|
|
1861
|
-
}
|
|
1862
|
-
return undefined;
|
|
1863
|
-
};
|
|
1864
1935
|
/**
|
|
1865
1936
|
* Builds arrowhead polyline points from leader-line points.
|
|
1866
1937
|
*
|
|
@@ -1899,16 +1970,107 @@ var AcDbMLeader = /** @class */ (function (_super) {
|
|
|
1899
1970
|
};
|
|
1900
1971
|
/**
|
|
1901
1972
|
* Draws one leader line and applies arrow style from MLEADER/MLEADERSTYLE.
|
|
1973
|
+
*
|
|
1974
|
+
* @param renderer Graphics renderer used to create primitives.
|
|
1975
|
+
* @param points Leader-line draw points.
|
|
1976
|
+
* @returns One entity or an entity group representing the full leader line.
|
|
1902
1977
|
*/
|
|
1903
1978
|
AcDbMLeader.prototype.drawLeaderLine = function (renderer, points) {
|
|
1904
|
-
var entities = [
|
|
1979
|
+
var entities = [];
|
|
1980
|
+
var linePoints = this.getLeaderLinePointsForDraw(points);
|
|
1981
|
+
if (linePoints.length >= 2) {
|
|
1982
|
+
entities.push(renderer.lines(linePoints));
|
|
1983
|
+
}
|
|
1905
1984
|
var arrow = this.drawArrowhead(renderer, points);
|
|
1906
1985
|
if (arrow)
|
|
1907
1986
|
entities.push(arrow);
|
|
1987
|
+
if (entities.length === 0)
|
|
1988
|
+
return undefined;
|
|
1908
1989
|
return entities.length === 1 ? entities[0] : renderer.group(entities);
|
|
1909
1990
|
};
|
|
1991
|
+
/**
|
|
1992
|
+
* Resolves leader-line points used for stroke drawing after arrow overlap trim.
|
|
1993
|
+
*
|
|
1994
|
+
* @param points Original leader polyline points.
|
|
1995
|
+
* @returns Trimmed points used to draw the leader stroke.
|
|
1996
|
+
*/
|
|
1997
|
+
AcDbMLeader.prototype.getLeaderLinePointsForDraw = function (points) {
|
|
1998
|
+
var trimDistance = this.getArrowheadLeaderLineTrimDistance();
|
|
1999
|
+
if (trimDistance <= 0)
|
|
2000
|
+
return points;
|
|
2001
|
+
return this.trimPolylineStart(points, trimDistance);
|
|
2002
|
+
};
|
|
2003
|
+
/**
|
|
2004
|
+
* Resolves how much of leader start should be trimmed to avoid arrow overlap.
|
|
2005
|
+
*
|
|
2006
|
+
* @returns Trim distance in drawing units.
|
|
2007
|
+
*/
|
|
2008
|
+
AcDbMLeader.prototype.getArrowheadLeaderLineTrimDistance = function () {
|
|
2009
|
+
var e_1, _a;
|
|
2010
|
+
var _b;
|
|
2011
|
+
if (!this.isArrowheadVisible())
|
|
2012
|
+
return 0;
|
|
2013
|
+
var blockTableRecord = this.getResolvedArrowheadBlockTableRecord();
|
|
2014
|
+
if (!blockTableRecord)
|
|
2015
|
+
return 0;
|
|
2016
|
+
var size = this.getResolvedArrowheadSize();
|
|
2017
|
+
if (size <= 0)
|
|
2018
|
+
return 0;
|
|
2019
|
+
var basePoint = (_b = blockTableRecord.origin) !== null && _b !== void 0 ? _b : AcGePoint3d.ORIGIN;
|
|
2020
|
+
var maxX = basePoint.x;
|
|
2021
|
+
try {
|
|
2022
|
+
for (var _c = __values(blockTableRecord.newIterator()), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
2023
|
+
var entity = _d.value;
|
|
2024
|
+
var extents = entity.geometricExtents;
|
|
2025
|
+
if (extents.isEmpty())
|
|
2026
|
+
continue;
|
|
2027
|
+
if (extents.max.x > maxX)
|
|
2028
|
+
maxX = extents.max.x;
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2032
|
+
finally {
|
|
2033
|
+
try {
|
|
2034
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
2035
|
+
}
|
|
2036
|
+
finally { if (e_1) throw e_1.error; }
|
|
2037
|
+
}
|
|
2038
|
+
return Math.max(0, (maxX - basePoint.x) * size);
|
|
2039
|
+
};
|
|
2040
|
+
/**
|
|
2041
|
+
* Trims the start of a polyline by a given distance.
|
|
2042
|
+
*
|
|
2043
|
+
* @param points Polyline points.
|
|
2044
|
+
* @param trimDistance Distance to trim from the start.
|
|
2045
|
+
* @returns Trimmed polyline points.
|
|
2046
|
+
*/
|
|
2047
|
+
AcDbMLeader.prototype.trimPolylineStart = function (points, trimDistance) {
|
|
2048
|
+
if (points.length < 2 || trimDistance <= 0)
|
|
2049
|
+
return points;
|
|
2050
|
+
var remaining = trimDistance;
|
|
2051
|
+
for (var i = 0; i < points.length - 1; i++) {
|
|
2052
|
+
var start = points[i];
|
|
2053
|
+
var end = points[i + 1];
|
|
2054
|
+
var segment = end.distanceTo(start);
|
|
2055
|
+
if (segment <= 0)
|
|
2056
|
+
continue;
|
|
2057
|
+
if (remaining < segment) {
|
|
2058
|
+
var direction = new AcGeVector3d().subVectors(end, start);
|
|
2059
|
+
var newStart = start
|
|
2060
|
+
.clone()
|
|
2061
|
+
.add(direction.multiplyScalar(remaining / segment));
|
|
2062
|
+
return __spreadArray([newStart], __read(points.slice(i + 1)), false);
|
|
2063
|
+
}
|
|
2064
|
+
remaining -= segment;
|
|
2065
|
+
}
|
|
2066
|
+
return [points[points.length - 1]];
|
|
2067
|
+
};
|
|
1910
2068
|
/**
|
|
1911
2069
|
* Draws one arrowhead primitive from leader-line points.
|
|
2070
|
+
*
|
|
2071
|
+
* @param renderer Graphics renderer used to create primitives.
|
|
2072
|
+
* @param points Leader-line points where the first point is treated as tip.
|
|
2073
|
+
* @returns Arrowhead entity, or `undefined` when no arrowhead is drawable.
|
|
1912
2074
|
*/
|
|
1913
2075
|
AcDbMLeader.prototype.drawArrowhead = function (renderer, points) {
|
|
1914
2076
|
if (!this.isArrowheadVisible())
|
|
@@ -1934,6 +2096,10 @@ var AcDbMLeader = /** @class */ (function (_super) {
|
|
|
1934
2096
|
};
|
|
1935
2097
|
/**
|
|
1936
2098
|
* Draws arrowhead by rendering entities from referenced arrow block record.
|
|
2099
|
+
*
|
|
2100
|
+
* @param renderer Graphics renderer used to create primitives.
|
|
2101
|
+
* @param points Leader-line points where the first point is treated as tip.
|
|
2102
|
+
* @returns Rendered block-based arrowhead entity, or `undefined`.
|
|
1937
2103
|
*/
|
|
1938
2104
|
AcDbMLeader.prototype.drawArrowheadBlock = function (renderer, points) {
|
|
1939
2105
|
var _a;
|
|
@@ -1959,6 +2125,9 @@ var AcDbMLeader = /** @class */ (function (_super) {
|
|
|
1959
2125
|
};
|
|
1960
2126
|
/**
|
|
1961
2127
|
* Resolves tip point and direction for arrowhead placement.
|
|
2128
|
+
*
|
|
2129
|
+
* @param points Leader-line points where the first point is treated as tip.
|
|
2130
|
+
* @returns Tip and normalized direction, or `undefined` when unavailable.
|
|
1962
2131
|
*/
|
|
1963
2132
|
AcDbMLeader.prototype.getArrowheadFrame = function (points) {
|
|
1964
2133
|
if (points.length < 2)
|
|
@@ -1987,6 +2156,8 @@ var AcDbMLeader = /** @class */ (function (_super) {
|
|
|
1987
2156
|
};
|
|
1988
2157
|
/**
|
|
1989
2158
|
* Resolves arrowhead block record by Arrowhead ID handle.
|
|
2159
|
+
*
|
|
2160
|
+
* @returns Arrowhead block table record, or `undefined` when not found.
|
|
1990
2161
|
*/
|
|
1991
2162
|
AcDbMLeader.prototype.getResolvedArrowheadBlockTableRecord = function () {
|
|
1992
2163
|
var arrowId = this.getResolvedArrowheadId();
|
|
@@ -2007,6 +2178,8 @@ var AcDbMLeader = /** @class */ (function (_super) {
|
|
|
2007
2178
|
};
|
|
2008
2179
|
/**
|
|
2009
2180
|
* Resolves effective text height by style and override-flag rules.
|
|
2181
|
+
*
|
|
2182
|
+
* @returns Effective text height used for rendering.
|
|
2010
2183
|
*/
|
|
2011
2184
|
AcDbMLeader.prototype.getResolvedTextHeight = function () {
|
|
2012
2185
|
var _a;
|
|
@@ -2019,6 +2192,8 @@ var AcDbMLeader = /** @class */ (function (_super) {
|
|
|
2019
2192
|
};
|
|
2020
2193
|
/**
|
|
2021
2194
|
* Resolves renderable MText content using entity content first, with style fallback.
|
|
2195
|
+
*
|
|
2196
|
+
* @returns Renderable text payload, or `undefined` when unavailable.
|
|
2022
2197
|
*/
|
|
2023
2198
|
AcDbMLeader.prototype.getRenderableMTextContent = function () {
|
|
2024
2199
|
var _a, _b, _c;
|
|
@@ -2040,6 +2215,8 @@ var AcDbMLeader = /** @class */ (function (_super) {
|
|
|
2040
2215
|
/**
|
|
2041
2216
|
* Computes render width for current MText content.
|
|
2042
2217
|
*
|
|
2218
|
+
* @param text Source MText content string.
|
|
2219
|
+
* @param textHeight Effective text height used for fallback estimation.
|
|
2043
2220
|
* @returns Explicit width or an estimated width based on plain text length.
|
|
2044
2221
|
*/
|
|
2045
2222
|
AcDbMLeader.prototype.getMTextRenderWidth = function (text, textHeight) {
|
|
@@ -2059,6 +2236,7 @@ var AcDbMLeader = /** @class */ (function (_super) {
|
|
|
2059
2236
|
*
|
|
2060
2237
|
* @param vector Vector to mutate.
|
|
2061
2238
|
* @param matrix Transformation matrix.
|
|
2239
|
+
* @returns `void`.
|
|
2062
2240
|
*/
|
|
2063
2241
|
AcDbMLeader.prototype.transformVector = function (vector, matrix) {
|
|
2064
2242
|
var origin = new AcGePoint3d();
|
|
@@ -2069,6 +2247,8 @@ var AcDbMLeader = /** @class */ (function (_super) {
|
|
|
2069
2247
|
};
|
|
2070
2248
|
/**
|
|
2071
2249
|
* Resolves the referenced MLeader style object.
|
|
2250
|
+
*
|
|
2251
|
+
* @returns Resolved style object or `undefined` when not available.
|
|
2072
2252
|
*/
|
|
2073
2253
|
AcDbMLeader.prototype.getMLeaderStyle = function () {
|
|
2074
2254
|
var dictionary = this.database.objects.mleaderStyle;
|
|
@@ -2078,10 +2258,72 @@ var AcDbMLeader = /** @class */ (function (_super) {
|
|
|
2078
2258
|
if (style)
|
|
2079
2259
|
return style;
|
|
2080
2260
|
}
|
|
2081
|
-
return
|
|
2261
|
+
return this.getDefaultMLeaderStyle();
|
|
2262
|
+
};
|
|
2263
|
+
/**
|
|
2264
|
+
* Resolves the default MLEADER style from CMLEADERSTYLE, with first-entry fallback.
|
|
2265
|
+
*
|
|
2266
|
+
* @returns Default style object or `undefined` when style dictionary is empty.
|
|
2267
|
+
*/
|
|
2268
|
+
AcDbMLeader.prototype.getDefaultMLeaderStyle = function () {
|
|
2269
|
+
var bySysVar = this.resolveMLeaderStyleByName(this.getDefaultMLeaderStyleName());
|
|
2270
|
+
if (bySysVar)
|
|
2271
|
+
return bySysVar;
|
|
2272
|
+
return this.database.objects.mleaderStyle.newIterator().toArray()[0];
|
|
2273
|
+
};
|
|
2274
|
+
/**
|
|
2275
|
+
* Resolves one MLEADER style by style name (dictionary key) or object ID.
|
|
2276
|
+
*
|
|
2277
|
+
* @param styleName Style name or object id candidate.
|
|
2278
|
+
* @returns Matching style object, or `undefined` when not found.
|
|
2279
|
+
*/
|
|
2280
|
+
AcDbMLeader.prototype.resolveMLeaderStyleByName = function (styleName) {
|
|
2281
|
+
var e_2, _a;
|
|
2282
|
+
var rawName = styleName === null || styleName === void 0 ? void 0 : styleName.trim();
|
|
2283
|
+
if (!rawName)
|
|
2284
|
+
return undefined;
|
|
2285
|
+
var dictionary = this.database.objects.mleaderStyle;
|
|
2286
|
+
var directByName = dictionary.getAt(rawName);
|
|
2287
|
+
if (directByName)
|
|
2288
|
+
return directByName;
|
|
2289
|
+
var directById = dictionary.getIdAt(rawName);
|
|
2290
|
+
if (directById)
|
|
2291
|
+
return directById;
|
|
2292
|
+
var normalizedStyleName = rawName.toUpperCase();
|
|
2293
|
+
try {
|
|
2294
|
+
for (var _b = __values(dictionary.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2295
|
+
var _d = __read(_c.value, 2), name_1 = _d[0], style = _d[1];
|
|
2296
|
+
if (name_1.toUpperCase() === normalizedStyleName) {
|
|
2297
|
+
return style;
|
|
2298
|
+
}
|
|
2299
|
+
}
|
|
2300
|
+
}
|
|
2301
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
2302
|
+
finally {
|
|
2303
|
+
try {
|
|
2304
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2305
|
+
}
|
|
2306
|
+
finally { if (e_2) throw e_2.error; }
|
|
2307
|
+
}
|
|
2308
|
+
return undefined;
|
|
2309
|
+
};
|
|
2310
|
+
/**
|
|
2311
|
+
* Resolves current CMLEADERSTYLE value with a stable default fallback.
|
|
2312
|
+
*
|
|
2313
|
+
* @returns Preferred default style name.
|
|
2314
|
+
*/
|
|
2315
|
+
AcDbMLeader.prototype.getDefaultMLeaderStyleName = function () {
|
|
2316
|
+
try {
|
|
2317
|
+
return this.database.cmleaderstyle || DEFAULT_MLEADER_STYLE;
|
|
2318
|
+
}
|
|
2319
|
+
catch (_a) {
|
|
2320
|
+
return DEFAULT_MLEADER_STYLE;
|
|
2321
|
+
}
|
|
2082
2322
|
};
|
|
2083
2323
|
/**
|
|
2084
2324
|
* Resolves text style name considering entity values, ids and style fallback.
|
|
2325
|
+
*
|
|
2326
|
+
* @returns Resolved text style name, or `undefined` when unresolved.
|
|
2085
2327
|
*/
|
|
2086
2328
|
AcDbMLeader.prototype.getResolvedTextStyleName = function () {
|
|
2087
2329
|
var _a, _b;
|
|
@@ -2114,6 +2356,195 @@ var AcDbMLeader = /** @class */ (function (_super) {
|
|
|
2114
2356
|
}
|
|
2115
2357
|
return style.textStyle;
|
|
2116
2358
|
};
|
|
2359
|
+
/**
|
|
2360
|
+
* Resolves effective leader-line color by override-flag and style rules.
|
|
2361
|
+
*
|
|
2362
|
+
* @returns Effective leader-line color.
|
|
2363
|
+
*/
|
|
2364
|
+
AcDbMLeader.prototype.getResolvedLeaderLineColor = function () {
|
|
2365
|
+
var _a;
|
|
2366
|
+
return this.getResolvedComponentColor(this.leaderLineColor, (_a = this.getMLeaderStyle()) === null || _a === void 0 ? void 0 : _a.leaderLineColor, MLEADER_OVERRIDE_LEADER_LINE_COLOR);
|
|
2367
|
+
};
|
|
2368
|
+
/**
|
|
2369
|
+
* Resolves effective leader-line geometry type.
|
|
2370
|
+
*
|
|
2371
|
+
* @returns Effective leader-line type.
|
|
2372
|
+
*/
|
|
2373
|
+
AcDbMLeader.prototype.getResolvedLeaderLineType = function () {
|
|
2374
|
+
var _a;
|
|
2375
|
+
var styleLineType = (_a = this.getMLeaderStyle()) === null || _a === void 0 ? void 0 : _a.leaderLineType;
|
|
2376
|
+
return this.getResolvedStyleDrivenValue(this.leaderLineType, styleLineType, MLEADER_OVERRIDE_LEADER_LINE_TYPE);
|
|
2377
|
+
};
|
|
2378
|
+
/**
|
|
2379
|
+
* Resolves effective leader-line linetype id/handle.
|
|
2380
|
+
*
|
|
2381
|
+
* @returns Effective linetype id, or `undefined` when not available.
|
|
2382
|
+
*/
|
|
2383
|
+
AcDbMLeader.prototype.getResolvedLeaderLineTypeId = function () {
|
|
2384
|
+
var _a;
|
|
2385
|
+
return this.getResolvedStyleDrivenValue(this.leaderLineTypeId, (_a = this.getMLeaderStyle()) === null || _a === void 0 ? void 0 : _a.leaderLineTypeId, MLEADER_OVERRIDE_LEADER_LINE_TYPE_ID);
|
|
2386
|
+
};
|
|
2387
|
+
/**
|
|
2388
|
+
* Resolves renderer linetype style for leader lines.
|
|
2389
|
+
*
|
|
2390
|
+
* @returns User-specified renderer linetype style, or `undefined`.
|
|
2391
|
+
*/
|
|
2392
|
+
AcDbMLeader.prototype.getResolvedLeaderLineStyle = function () {
|
|
2393
|
+
var lineTypeId = this.getResolvedLeaderLineTypeId();
|
|
2394
|
+
if (!lineTypeId)
|
|
2395
|
+
return undefined;
|
|
2396
|
+
var lineTypeRecord = this.database.tables.linetypeTable.getIdAt(lineTypeId);
|
|
2397
|
+
if (!lineTypeRecord)
|
|
2398
|
+
return undefined;
|
|
2399
|
+
return __assign({ type: 'UserSpecified' }, lineTypeRecord.linetype);
|
|
2400
|
+
};
|
|
2401
|
+
/**
|
|
2402
|
+
* Resolves effective leader-line weight by override-flag and style rules.
|
|
2403
|
+
*
|
|
2404
|
+
* @returns Effective line weight, or `undefined`.
|
|
2405
|
+
*/
|
|
2406
|
+
AcDbMLeader.prototype.getResolvedLeaderLineWeight = function () {
|
|
2407
|
+
var _a;
|
|
2408
|
+
var styleLineWeight = (_a = this.getMLeaderStyle()) === null || _a === void 0 ? void 0 : _a.leaderLineWeight;
|
|
2409
|
+
var lineWeight = this.getResolvedStyleDrivenValue(this.leaderLineWeight, styleLineWeight, MLEADER_OVERRIDE_LEADER_LINE_WEIGHT);
|
|
2410
|
+
if (lineWeight == null)
|
|
2411
|
+
return undefined;
|
|
2412
|
+
return lineWeight;
|
|
2413
|
+
};
|
|
2414
|
+
/**
|
|
2415
|
+
* Resolves whether dogleg drawing is effectively enabled.
|
|
2416
|
+
*
|
|
2417
|
+
* @returns Effective dogleg-enabled state.
|
|
2418
|
+
*/
|
|
2419
|
+
AcDbMLeader.prototype.getResolvedDoglegEnabled = function () {
|
|
2420
|
+
var _a;
|
|
2421
|
+
var styleEnabled = (_a = this.getMLeaderStyle()) === null || _a === void 0 ? void 0 : _a.doglegEnabled;
|
|
2422
|
+
return this.getResolvedStyleDrivenValue(this.doglegEnabled, styleEnabled, MLEADER_OVERRIDE_DOGLEG_ENABLED);
|
|
2423
|
+
};
|
|
2424
|
+
/**
|
|
2425
|
+
* Resolves effective dogleg length by override-flag and style rules.
|
|
2426
|
+
*
|
|
2427
|
+
* @returns Effective dogleg length.
|
|
2428
|
+
*/
|
|
2429
|
+
AcDbMLeader.prototype.getResolvedDoglegLength = function () {
|
|
2430
|
+
var _a;
|
|
2431
|
+
var styleLength = (_a = this.getMLeaderStyle()) === null || _a === void 0 ? void 0 : _a.doglegLength;
|
|
2432
|
+
return this.getResolvedStyleDrivenValue(this.doglegLength, styleLength, MLEADER_OVERRIDE_DOGLEG_LENGTH);
|
|
2433
|
+
};
|
|
2434
|
+
/**
|
|
2435
|
+
* Resolves effective text color by override-flag and style rules.
|
|
2436
|
+
*
|
|
2437
|
+
* @returns Effective text color.
|
|
2438
|
+
*/
|
|
2439
|
+
AcDbMLeader.prototype.getResolvedTextColor = function () {
|
|
2440
|
+
var _a;
|
|
2441
|
+
return this.getResolvedComponentColor(this.textColor, (_a = this.getMLeaderStyle()) === null || _a === void 0 ? void 0 : _a.textColor, MLEADER_OVERRIDE_TEXT_COLOR);
|
|
2442
|
+
};
|
|
2443
|
+
/**
|
|
2444
|
+
* Resolves effective component color from entity raw value and style fallback.
|
|
2445
|
+
*
|
|
2446
|
+
* @param rawEntityColor Raw DXF color value stored on the entity.
|
|
2447
|
+
* @param styleColor Style-level fallback color.
|
|
2448
|
+
* @param overrideFlagMask Property-override flag mask for this component.
|
|
2449
|
+
* @returns Effective color used for rendering and trait application.
|
|
2450
|
+
*/
|
|
2451
|
+
AcDbMLeader.prototype.getResolvedComponentColor = function (rawEntityColor, styleColor, overrideFlagMask) {
|
|
2452
|
+
var entityColor = rawEntityColor != null
|
|
2453
|
+
? decodeMLeaderStyleRawColor(rawEntityColor)
|
|
2454
|
+
: undefined;
|
|
2455
|
+
if (!entityColor)
|
|
2456
|
+
return styleColor;
|
|
2457
|
+
var overrideEnabled = this.isPropertyOverrideEnabled(overrideFlagMask);
|
|
2458
|
+
if (overrideEnabled === true)
|
|
2459
|
+
return entityColor;
|
|
2460
|
+
if (overrideEnabled === false)
|
|
2461
|
+
return styleColor !== null && styleColor !== void 0 ? styleColor : entityColor;
|
|
2462
|
+
// Some DXF producers always write entity color fields as ByBlock/ByLayer even
|
|
2463
|
+
// when no override flag is enabled. Prefer style color in that ambiguous case.
|
|
2464
|
+
if (!entityColor.isByBlock && !entityColor.isByLayer) {
|
|
2465
|
+
return entityColor;
|
|
2466
|
+
}
|
|
2467
|
+
return styleColor !== null && styleColor !== void 0 ? styleColor : entityColor;
|
|
2468
|
+
};
|
|
2469
|
+
/**
|
|
2470
|
+
* Resolves effective value using override-flag and style fallback rules.
|
|
2471
|
+
*
|
|
2472
|
+
* @typeParam T Value type.
|
|
2473
|
+
* @param entityValue Value stored on the entity.
|
|
2474
|
+
* @param styleValue Value provided by style.
|
|
2475
|
+
* @param overrideFlagMask Property-override flag mask for this component.
|
|
2476
|
+
* @returns Effective resolved value.
|
|
2477
|
+
*/
|
|
2478
|
+
AcDbMLeader.prototype.getResolvedStyleDrivenValue = function (entityValue, styleValue, overrideFlagMask) {
|
|
2479
|
+
var overrideEnabled = this.isPropertyOverrideEnabled(overrideFlagMask);
|
|
2480
|
+
if (overrideEnabled === true)
|
|
2481
|
+
return entityValue !== null && entityValue !== void 0 ? entityValue : styleValue;
|
|
2482
|
+
if (overrideEnabled === false)
|
|
2483
|
+
return styleValue !== null && styleValue !== void 0 ? styleValue : entityValue;
|
|
2484
|
+
return styleValue !== null && styleValue !== void 0 ? styleValue : entityValue;
|
|
2485
|
+
};
|
|
2486
|
+
/**
|
|
2487
|
+
* Checks whether a specific property-override bit is enabled.
|
|
2488
|
+
*
|
|
2489
|
+
* @param flagMask Bit mask for the property being queried.
|
|
2490
|
+
* @returns `true` if enabled, `false` if disabled, or `undefined` when flag is absent.
|
|
2491
|
+
*/
|
|
2492
|
+
AcDbMLeader.prototype.isPropertyOverrideEnabled = function (flagMask) {
|
|
2493
|
+
if (this.propertyOverrideFlag == null)
|
|
2494
|
+
return undefined;
|
|
2495
|
+
return (this.propertyOverrideFlag & flagMask) !== 0;
|
|
2496
|
+
};
|
|
2497
|
+
/**
|
|
2498
|
+
* Applies color traits while preserving original values for reset.
|
|
2499
|
+
*
|
|
2500
|
+
* @param traits Renderer traits object to mutate.
|
|
2501
|
+
* @param color Effective component color to apply.
|
|
2502
|
+
* @param originalColor Original trait color value.
|
|
2503
|
+
* @param originalRgbColor Original trait RGB value.
|
|
2504
|
+
* @returns `void`.
|
|
2505
|
+
*/
|
|
2506
|
+
AcDbMLeader.prototype.applyColorTraits = function (traits, color, originalColor, originalRgbColor) {
|
|
2507
|
+
traits.color = originalColor;
|
|
2508
|
+
traits.rgbColor = originalRgbColor;
|
|
2509
|
+
if (!color)
|
|
2510
|
+
return;
|
|
2511
|
+
traits.color = color;
|
|
2512
|
+
traits.rgbColor = this.resolveColorToRgb(color);
|
|
2513
|
+
};
|
|
2514
|
+
/**
|
|
2515
|
+
* Applies line style traits when resolved values are available.
|
|
2516
|
+
*
|
|
2517
|
+
* @param traits Renderer traits object to mutate.
|
|
2518
|
+
* @param lineType Resolved linetype style.
|
|
2519
|
+
* @param lineWeight Resolved line weight.
|
|
2520
|
+
* @returns `void`.
|
|
2521
|
+
*/
|
|
2522
|
+
AcDbMLeader.prototype.applyLineTraits = function (traits, lineType, lineWeight) {
|
|
2523
|
+
if (lineType) {
|
|
2524
|
+
traits.lineType = lineType;
|
|
2525
|
+
}
|
|
2526
|
+
if (lineWeight != null) {
|
|
2527
|
+
traits.lineWeight = lineWeight;
|
|
2528
|
+
}
|
|
2529
|
+
};
|
|
2530
|
+
/**
|
|
2531
|
+
* Converts an `AcCmColor` to resolved RGB for rendering.
|
|
2532
|
+
*
|
|
2533
|
+
* @param color Source color definition.
|
|
2534
|
+
* @returns Resolved RGB integer color.
|
|
2535
|
+
*/
|
|
2536
|
+
AcDbMLeader.prototype.resolveColorToRgb = function (color) {
|
|
2537
|
+
var _a;
|
|
2538
|
+
if (color.isByLayer) {
|
|
2539
|
+
var layerColor = this.getLayerColor();
|
|
2540
|
+
if ((layerColor === null || layerColor === void 0 ? void 0 : layerColor.RGB) != null)
|
|
2541
|
+
return layerColor.RGB;
|
|
2542
|
+
return this.rgbColor;
|
|
2543
|
+
}
|
|
2544
|
+
if (color.isByBlock)
|
|
2545
|
+
return this.rgbColor;
|
|
2546
|
+
return (_a = color.RGB) !== null && _a !== void 0 ? _a : this.rgbColor;
|
|
2547
|
+
};
|
|
2117
2548
|
/** The entity type name. */
|
|
2118
2549
|
AcDbMLeader.typeName = 'MLeader';
|
|
2119
2550
|
return AcDbMLeader;
|