@itwin/core-backend 5.13.0-dev.9 → 5.14.0-dev.1
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/CHANGELOG.md +33 -1
- package/lib/cjs/Category.d.ts +4 -4
- package/lib/cjs/Category.js.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.d.ts +5 -0
- package/lib/cjs/ChangesetECAdaptor.d.ts.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.js +13 -3
- package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
- package/lib/cjs/CodeSpecs.d.ts +3 -3
- package/lib/cjs/CodeSpecs.js.map +1 -1
- package/lib/cjs/DisplayStyle.d.ts +2 -2
- package/lib/cjs/DisplayStyle.js.map +1 -1
- package/lib/cjs/EditTxn.d.ts.map +1 -1
- package/lib/cjs/EditTxn.js +1 -0
- package/lib/cjs/EditTxn.js.map +1 -1
- package/lib/cjs/Element.d.ts +48 -12
- package/lib/cjs/Element.d.ts.map +1 -1
- package/lib/cjs/Element.js +120 -24
- package/lib/cjs/Element.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +30 -15
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +51 -15
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/Model.d.ts +5 -5
- package/lib/cjs/Model.d.ts.map +1 -1
- package/lib/cjs/Model.js.map +1 -1
- package/lib/cjs/PropertyStore.js +1 -1
- package/lib/cjs/PropertyStore.js.map +1 -1
- package/lib/cjs/SchemaSync.d.ts +37 -9
- package/lib/cjs/SchemaSync.d.ts.map +1 -1
- package/lib/cjs/SchemaSync.js +125 -6
- package/lib/cjs/SchemaSync.js.map +1 -1
- package/lib/cjs/SynchronousChannel.d.ts +62 -0
- package/lib/cjs/SynchronousChannel.d.ts.map +1 -0
- package/lib/cjs/SynchronousChannel.js +11 -0
- package/lib/cjs/SynchronousChannel.js.map +1 -0
- package/lib/cjs/Texture.d.ts +1 -1
- package/lib/cjs/Texture.js.map +1 -1
- package/lib/cjs/TxnManager.d.ts +44 -4
- package/lib/cjs/TxnManager.d.ts.map +1 -1
- package/lib/cjs/TxnManager.js +72 -14
- package/lib/cjs/TxnManager.js.map +1 -1
- package/lib/cjs/ViewDefinition.d.ts +6 -6
- package/lib/cjs/ViewDefinition.d.ts.map +1 -1
- package/lib/cjs/ViewDefinition.js.map +1 -1
- package/lib/cjs/annotations/LeaderGeometry.d.ts +22 -7
- package/lib/cjs/annotations/LeaderGeometry.d.ts.map +1 -1
- package/lib/cjs/annotations/LeaderGeometry.js +104 -36
- package/lib/cjs/annotations/LeaderGeometry.js.map +1 -1
- package/lib/cjs/annotations/TextAnnotationElement.d.ts +1 -1
- package/lib/cjs/annotations/TextAnnotationElement.d.ts.map +1 -1
- package/lib/cjs/annotations/TextAnnotationElement.js +25 -10
- package/lib/cjs/annotations/TextAnnotationElement.js.map +1 -1
- package/lib/cjs/core-backend.d.ts +1 -0
- package/lib/cjs/core-backend.d.ts.map +1 -1
- package/lib/cjs/core-backend.js +1 -0
- package/lib/cjs/core-backend.js.map +1 -1
- package/lib/cjs/internal/IntegrityCheck.d.ts +22 -0
- package/lib/cjs/internal/IntegrityCheck.d.ts.map +1 -1
- package/lib/cjs/internal/IntegrityCheck.js +13 -0
- package/lib/cjs/internal/IntegrityCheck.js.map +1 -1
- package/lib/cjs/internal/NoReservations.d.ts +6 -0
- package/lib/cjs/internal/NoReservations.d.ts.map +1 -0
- package/lib/cjs/internal/NoReservations.js +21 -0
- package/lib/cjs/internal/NoReservations.js.map +1 -0
- package/lib/cjs/internal/SchemaSyncReservations.d.ts +4 -0
- package/lib/cjs/internal/SchemaSyncReservations.d.ts.map +1 -0
- package/lib/cjs/internal/SchemaSyncReservations.js +118 -0
- package/lib/cjs/internal/SchemaSyncReservations.js.map +1 -0
- package/lib/cjs/internal/Symbols.d.ts +1 -0
- package/lib/cjs/internal/Symbols.d.ts.map +1 -1
- package/lib/cjs/internal/Symbols.js +2 -1
- package/lib/cjs/internal/Symbols.js.map +1 -1
- package/lib/esm/Category.d.ts +4 -4
- package/lib/esm/Category.js.map +1 -1
- package/lib/esm/ChangesetECAdaptor.d.ts +5 -0
- package/lib/esm/ChangesetECAdaptor.d.ts.map +1 -1
- package/lib/esm/ChangesetECAdaptor.js +13 -3
- package/lib/esm/ChangesetECAdaptor.js.map +1 -1
- package/lib/esm/CodeSpecs.d.ts +3 -3
- package/lib/esm/CodeSpecs.js.map +1 -1
- package/lib/esm/DisplayStyle.d.ts +2 -2
- package/lib/esm/DisplayStyle.js.map +1 -1
- package/lib/esm/EditTxn.d.ts.map +1 -1
- package/lib/esm/EditTxn.js +1 -0
- package/lib/esm/EditTxn.js.map +1 -1
- package/lib/esm/Element.d.ts +48 -12
- package/lib/esm/Element.d.ts.map +1 -1
- package/lib/esm/Element.js +121 -25
- package/lib/esm/Element.js.map +1 -1
- package/lib/esm/IModelDb.d.ts +30 -15
- package/lib/esm/IModelDb.d.ts.map +1 -1
- package/lib/esm/IModelDb.js +52 -16
- package/lib/esm/IModelDb.js.map +1 -1
- package/lib/esm/Model.d.ts +5 -5
- package/lib/esm/Model.d.ts.map +1 -1
- package/lib/esm/Model.js.map +1 -1
- package/lib/esm/PropertyStore.js +1 -1
- package/lib/esm/PropertyStore.js.map +1 -1
- package/lib/esm/SchemaSync.d.ts +37 -9
- package/lib/esm/SchemaSync.d.ts.map +1 -1
- package/lib/esm/SchemaSync.js +127 -8
- package/lib/esm/SchemaSync.js.map +1 -1
- package/lib/esm/SynchronousChannel.d.ts +62 -0
- package/lib/esm/SynchronousChannel.d.ts.map +1 -0
- package/lib/esm/SynchronousChannel.js +9 -0
- package/lib/esm/SynchronousChannel.js.map +1 -0
- package/lib/esm/Texture.d.ts +1 -1
- package/lib/esm/Texture.js.map +1 -1
- package/lib/esm/TxnManager.d.ts +44 -4
- package/lib/esm/TxnManager.d.ts.map +1 -1
- package/lib/esm/TxnManager.js +72 -14
- package/lib/esm/TxnManager.js.map +1 -1
- package/lib/esm/ViewDefinition.d.ts +6 -6
- package/lib/esm/ViewDefinition.d.ts.map +1 -1
- package/lib/esm/ViewDefinition.js.map +1 -1
- package/lib/esm/annotations/LeaderGeometry.d.ts +22 -7
- package/lib/esm/annotations/LeaderGeometry.d.ts.map +1 -1
- package/lib/esm/annotations/LeaderGeometry.js +104 -36
- package/lib/esm/annotations/LeaderGeometry.js.map +1 -1
- package/lib/esm/annotations/TextAnnotationElement.d.ts +1 -1
- package/lib/esm/annotations/TextAnnotationElement.d.ts.map +1 -1
- package/lib/esm/annotations/TextAnnotationElement.js +25 -10
- package/lib/esm/annotations/TextAnnotationElement.js.map +1 -1
- package/lib/esm/core-backend.d.ts +1 -0
- package/lib/esm/core-backend.d.ts.map +1 -1
- package/lib/esm/core-backend.js +1 -0
- package/lib/esm/core-backend.js.map +1 -1
- package/lib/esm/internal/IntegrityCheck.d.ts +22 -0
- package/lib/esm/internal/IntegrityCheck.d.ts.map +1 -1
- package/lib/esm/internal/IntegrityCheck.js +13 -0
- package/lib/esm/internal/IntegrityCheck.js.map +1 -1
- package/lib/esm/internal/NoReservations.d.ts +6 -0
- package/lib/esm/internal/NoReservations.d.ts.map +1 -0
- package/lib/esm/internal/NoReservations.js +18 -0
- package/lib/esm/internal/NoReservations.js.map +1 -0
- package/lib/esm/internal/SchemaSyncReservations.d.ts +4 -0
- package/lib/esm/internal/SchemaSyncReservations.d.ts.map +1 -0
- package/lib/esm/internal/SchemaSyncReservations.js +115 -0
- package/lib/esm/internal/SchemaSyncReservations.js.map +1 -0
- package/lib/esm/internal/Symbols.d.ts +1 -0
- package/lib/esm/internal/Symbols.d.ts.map +1 -1
- package/lib/esm/internal/Symbols.js +1 -0
- package/lib/esm/internal/Symbols.js.map +1 -1
- package/lib/esm/test/IModelTestUtils.d.ts +1 -1
- package/lib/esm/test/IModelTestUtils.d.ts.map +1 -1
- package/lib/esm/test/IModelTestUtils.js +8 -3
- package/lib/esm/test/IModelTestUtils.js.map +1 -1
- package/lib/esm/test/annotations/LeaderGeometry.test.js +178 -2
- package/lib/esm/test/annotations/LeaderGeometry.test.js.map +1 -1
- package/lib/esm/test/annotations/TextAnnotation.test.js +48 -18
- package/lib/esm/test/annotations/TextAnnotation.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECSqlStatement.test.js +177 -0
- package/lib/esm/test/ecdb/ECSqlStatement.test.js.map +1 -1
- package/lib/esm/test/ecdb/QueryReaders.test.js +2 -16
- package/lib/esm/test/ecdb/QueryReaders.test.js.map +1 -1
- package/lib/esm/test/ecsql/src/ECSqlTestRunner.test.js +2 -2
- package/lib/esm/test/ecsql/src/ECSqlTestRunner.test.js.map +1 -1
- package/lib/esm/test/element/ElementRoundTrip.test.js +80 -2
- package/lib/esm/test/element/ElementRoundTrip.test.js.map +1 -1
- package/lib/esm/test/imodel/IModelECSql.test.d.ts +2 -0
- package/lib/esm/test/imodel/IModelECSql.test.d.ts.map +1 -0
- package/lib/esm/test/imodel/IModelECSql.test.js +367 -0
- package/lib/esm/test/imodel/IModelECSql.test.js.map +1 -0
- package/lib/esm/test/imodel/IModelElements.test.d.ts +2 -0
- package/lib/esm/test/imodel/IModelElements.test.d.ts.map +1 -0
- package/lib/esm/test/imodel/IModelElements.test.js +969 -0
- package/lib/esm/test/imodel/IModelElements.test.js.map +1 -0
- package/lib/esm/test/imodel/IModelGeolocation.test.d.ts +2 -0
- package/lib/esm/test/imodel/IModelGeolocation.test.d.ts.map +1 -0
- package/lib/esm/test/imodel/IModelGeolocation.test.js +539 -0
- package/lib/esm/test/imodel/IModelGeolocation.test.js.map +1 -0
- package/lib/esm/test/imodel/IModelLifecycle.test.d.ts +2 -0
- package/lib/esm/test/imodel/IModelLifecycle.test.d.ts.map +1 -0
- package/lib/esm/test/imodel/IModelLifecycle.test.js +499 -0
- package/lib/esm/test/imodel/IModelLifecycle.test.js.map +1 -0
- package/lib/esm/test/imodel/IModelMetadata.test.d.ts +2 -0
- package/lib/esm/test/imodel/IModelMetadata.test.d.ts.map +1 -0
- package/lib/esm/test/imodel/IModelMetadata.test.js +274 -0
- package/lib/esm/test/imodel/IModelMetadata.test.js.map +1 -0
- package/lib/esm/test/imodel/IModelModels.test.d.ts +2 -0
- package/lib/esm/test/imodel/IModelModels.test.d.ts.map +1 -0
- package/lib/esm/test/imodel/IModelModels.test.js +357 -0
- package/lib/esm/test/imodel/IModelModels.test.js.map +1 -0
- package/lib/esm/test/imodel/IModelRelationships.test.d.ts +2 -0
- package/lib/esm/test/imodel/IModelRelationships.test.d.ts.map +1 -0
- package/lib/esm/test/imodel/IModelRelationships.test.js +407 -0
- package/lib/esm/test/imodel/IModelRelationships.test.js.map +1 -0
- package/lib/esm/test/imodel/IModelTestFixtures.d.ts +53 -0
- package/lib/esm/test/imodel/IModelTestFixtures.d.ts.map +1 -0
- package/lib/esm/test/imodel/IModelTestFixtures.js +107 -0
- package/lib/esm/test/imodel/IModelTestFixtures.js.map +1 -0
- package/lib/esm/test/imodel/IModelViews.test.d.ts +2 -0
- package/lib/esm/test/imodel/IModelViews.test.d.ts.map +1 -0
- package/lib/esm/test/imodel/IModelViews.test.js +199 -0
- package/lib/esm/test/imodel/IModelViews.test.js.map +1 -0
- package/lib/esm/test/index.d.ts +0 -1
- package/lib/esm/test/index.d.ts.map +1 -1
- package/lib/esm/test/index.js +0 -1
- package/lib/esm/test/index.js.map +1 -1
- package/lib/esm/test/standalone/ChangesetReader.test.js +8 -26
- package/lib/esm/test/standalone/ChangesetReader.test.js.map +1 -1
- package/lib/esm/test/standalone/DgnDomainMergeConflict.test.d.ts +2 -0
- package/lib/esm/test/standalone/DgnDomainMergeConflict.test.d.ts.map +1 -0
- package/lib/esm/test/standalone/DgnDomainMergeConflict.test.js +263 -0
- package/lib/esm/test/standalone/DgnDomainMergeConflict.test.js.map +1 -0
- package/lib/esm/test/standalone/GeometryStream.test.js +1 -3
- package/lib/esm/test/standalone/GeometryStream.test.js.map +1 -1
- package/lib/esm/test/standalone/IModelWrite.test.d.ts.map +1 -1
- package/lib/esm/test/standalone/IModelWrite.test.js +78 -1
- package/lib/esm/test/standalone/IModelWrite.test.js.map +1 -1
- package/lib/esm/test/standalone/IntegrityCheck.test.js +29 -10
- package/lib/esm/test/standalone/IntegrityCheck.test.js.map +1 -1
- package/lib/esm/test/standalone/SQliteChangesetReaderAndChangesetECAdaptor.test.js +23 -0
- package/lib/esm/test/standalone/SQliteChangesetReaderAndChangesetECAdaptor.test.js.map +1 -1
- package/lib/esm/test/standalone/SchemaSyncDb.test.d.ts +2 -0
- package/lib/esm/test/standalone/SchemaSyncDb.test.d.ts.map +1 -0
- package/lib/esm/test/standalone/SchemaSyncDb.test.js +221 -0
- package/lib/esm/test/standalone/SchemaSyncDb.test.js.map +1 -0
- package/lib/esm/test/standalone/SchemaSyncElementReservation.test.d.ts +2 -0
- package/lib/esm/test/standalone/SchemaSyncElementReservation.test.d.ts.map +1 -0
- package/lib/esm/test/standalone/SchemaSyncElementReservation.test.js +459 -0
- package/lib/esm/test/standalone/SchemaSyncElementReservation.test.js.map +1 -0
- package/lib/esm/test/standalone/SnapshotDb.test.js +1 -0
- package/lib/esm/test/standalone/SnapshotDb.test.js.map +1 -1
- package/lib/esm/test/standalone/TxnManager.test.js +108 -8
- package/lib/esm/test/standalone/TxnManager.test.js.map +1 -1
- package/package.json +14 -17
- package/lib/esm/test/RevisionUtility.d.ts +0 -33
- package/lib/esm/test/RevisionUtility.d.ts.map +0 -1
- package/lib/esm/test/RevisionUtility.js +0 -52
- package/lib/esm/test/RevisionUtility.js.map +0 -1
- package/lib/esm/test/imodel/IModel.test.d.ts +0 -2
- package/lib/esm/test/imodel/IModel.test.d.ts.map +0 -1
- package/lib/esm/test/imodel/IModel.test.js +0 -3277
- package/lib/esm/test/imodel/IModel.test.js.map +0 -1
|
@@ -50,51 +50,76 @@ export function appendLeadersToBuilder(builder, leaders, layout, transform, para
|
|
|
50
50
|
params.lineColor = ColorDef.fromJSON(effectiveColor);
|
|
51
51
|
result = result && builder.appendGeometryParamsChange(params);
|
|
52
52
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
53
|
+
if (leaderStyle.leader.showLeaders) {
|
|
54
|
+
const attachmentPoint = computeLeaderAttachmentPoint(leader, frameCurve, layout, transform);
|
|
55
|
+
if (!attachmentPoint)
|
|
56
|
+
return false;
|
|
57
|
+
let elbowPoint;
|
|
58
|
+
if (leaderStyle.leader.wantElbow) {
|
|
59
|
+
const elbowLength = leaderStyle.leader.elbowLength * scaledBlockTextHeight;
|
|
60
|
+
const elbowDirection = computeElbowDirection(attachmentPoint, frameCurve, elbowLength);
|
|
61
|
+
if (elbowDirection)
|
|
62
|
+
elbowPoint = attachmentPoint.plusScaled(elbowDirection, elbowLength);
|
|
63
|
+
}
|
|
64
|
+
// Leader line geometry
|
|
65
|
+
const leaderLinePoints = [];
|
|
66
|
+
const terminatorWidth = leaderStyle.leader.terminatorWidthFactor * scaledBlockTextHeight;
|
|
67
|
+
let leaderStartPoint = leader.startPoint;
|
|
68
|
+
if (leaderStyle.leader.showTargetPoint && leaderStyle.leader.targetPointOffsetFactor !== 0) {
|
|
69
|
+
const offset = leaderStyle.leader.targetPointOffsetFactor * scaledBlockTextHeight;
|
|
70
|
+
let firstSegmentEnd = leader.intermediatePoints?.[0];
|
|
71
|
+
// If there are no intermediate points, offset along the elbow segment when present.
|
|
72
|
+
if (!firstSegmentEnd && elbowPoint)
|
|
73
|
+
firstSegmentEnd = elbowPoint;
|
|
74
|
+
if (!firstSegmentEnd)
|
|
75
|
+
firstSegmentEnd = attachmentPoint;
|
|
76
|
+
// Offset the target-point marker away from the start point along the first leader segment.
|
|
77
|
+
// Clamp the added distance so negative values resolve to 0 and large values cannot overshoot the first vertex.
|
|
78
|
+
// When terminators are hidden, use the text height as a conservative guard distance; otherwise use the terminator width.
|
|
79
|
+
const firstSegmentLength = leader.startPoint.distance(firstSegmentEnd);
|
|
80
|
+
const clampDistance = leaderStyle.leader.showTerminators ? terminatorWidth : scaledBlockTextHeight;
|
|
81
|
+
const maxOffset = Math.max(0, firstSegmentLength - clampDistance);
|
|
82
|
+
const clampedOffset = Math.min(Math.max(offset, 0), maxOffset);
|
|
83
|
+
const leaderDirection = Vector3d.createStartEnd(leader.startPoint, firstSegmentEnd).normalize();
|
|
84
|
+
if (leaderDirection)
|
|
85
|
+
leaderStartPoint = leader.startPoint.plusScaled(leaderDirection, clampedOffset);
|
|
86
|
+
}
|
|
87
|
+
leaderLinePoints.push(leaderStartPoint);
|
|
88
|
+
leader.intermediatePoints?.forEach((point) => {
|
|
89
|
+
leaderLinePoints.push(point);
|
|
90
|
+
});
|
|
91
|
+
if (elbowPoint)
|
|
92
|
+
leaderLinePoints.push(elbowPoint);
|
|
93
|
+
leaderLinePoints.push(attachmentPoint);
|
|
94
|
+
const terminatorDirection = Vector3d.createStartEnd(leaderLinePoints[0], leaderLinePoints[1]).normalize();
|
|
95
|
+
// Truncate the first segment of the leader lines to account for the arrowhead size when closedArrow (hollow triangle) terminatorShape is used.
|
|
96
|
+
if (leaderStyle.leader.showTerminators && leaderStyle.leader.terminatorShape === "closedArrow") {
|
|
97
|
+
if (terminatorDirection)
|
|
98
|
+
leaderLinePoints[0] = leaderLinePoints[0].plusScaled(terminatorDirection, terminatorWidth);
|
|
99
|
+
}
|
|
100
|
+
result = result && builder.appendGeometryQuery(LineString3d.create(leaderLinePoints));
|
|
101
|
+
if (leaderStyle.leader.terminatorShape !== "none" && leaderStyle.leader.showTerminators) {
|
|
102
|
+
// Terminator geometry
|
|
103
|
+
if (!terminatorDirection)
|
|
104
|
+
continue; // Assuming leaders without terminators is a valid case.
|
|
105
|
+
result = result && createTerminatorGeometry({ builder, point: leaderStartPoint, dir: terminatorDirection, params, textStyleSettings: leaderStyle, textHeight: scaledBlockTextHeight });
|
|
106
|
+
}
|
|
67
107
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const terminatorWidth = leaderStyle.leader.terminatorWidthFactor * scaledBlockTextHeight;
|
|
71
|
-
// Truncate the first segment of the leader lines to account for the arrowhead size when closedArrow (hollow triangle) terminatorShape is used.
|
|
72
|
-
if (leaderStyle.leader.terminatorShape === "closedArrow") {
|
|
73
|
-
if (terminatorDirection)
|
|
74
|
-
leaderLinePoints[0] = leaderLinePoints[0].plusScaled(terminatorDirection, terminatorWidth);
|
|
75
|
-
}
|
|
76
|
-
result = result && builder.appendGeometryQuery(LineString3d.create(leaderLinePoints));
|
|
77
|
-
if (leaderStyle.leader.terminatorShape !== "none") {
|
|
78
|
-
// Terminator geometry
|
|
79
|
-
if (!terminatorDirection)
|
|
80
|
-
continue; // Assuming leaders without terminators is a valid case.
|
|
81
|
-
result = result && createTerminatorGeometry(builder, leader.startPoint, terminatorDirection, params, leaderStyle, scaledBlockTextHeight);
|
|
108
|
+
if (leaderStyle.leader.showTargetPoint) {
|
|
109
|
+
result = result && createTerminatorGeometry({ builder, point: leader.startPoint, dir: Vector3d.unitX(), params, textStyleSettings: leaderStyle, textHeight: scaledBlockTextHeight, isArrow: false });
|
|
82
110
|
}
|
|
83
111
|
}
|
|
84
112
|
return result;
|
|
85
113
|
}
|
|
86
114
|
/**
|
|
87
115
|
* Creates the geometry for a terminator at the end of a leader line.
|
|
88
|
-
* @param
|
|
89
|
-
* @param point The starting point of the leader line.
|
|
90
|
-
* @param dir The direction vector of the leader line.
|
|
91
|
-
* @param params The geometry parameters to use for the terminator.
|
|
92
|
-
* @param textStyleSettings The text style settings to use for the terminator.
|
|
93
|
-
* @param textHeight The height of the text block.
|
|
116
|
+
* @param args Describes the terminator geometry to create. See [[CreateTerminatorGeometryArgs]].
|
|
94
117
|
* @returns True if the geometry was successfully created, false otherwise.
|
|
95
118
|
* @beta
|
|
96
119
|
*/
|
|
97
|
-
export function createTerminatorGeometry(
|
|
120
|
+
export function createTerminatorGeometry(args) {
|
|
121
|
+
const { builder, point, dir, params, textStyleSettings, textHeight } = args;
|
|
122
|
+
const isArrow = args.isArrow ?? true;
|
|
98
123
|
let result = true;
|
|
99
124
|
const termY = dir.unitCrossProduct(Vector3d.unitZ());
|
|
100
125
|
if (!termY)
|
|
@@ -115,7 +140,8 @@ export function createTerminatorGeometry(builder, point, dir, params, textStyleS
|
|
|
115
140
|
const finalContent = useLoop ? Loop.create(content) : content;
|
|
116
141
|
result = result && builder.appendGeometryQuery(finalContent);
|
|
117
142
|
};
|
|
118
|
-
|
|
143
|
+
const shape = isArrow ? textStyleSettings.leader.terminatorShape : textStyleSettings.leader.targetPointShape;
|
|
144
|
+
switch (shape) {
|
|
119
145
|
case "openArrow": {
|
|
120
146
|
const lineString = LineString3d.create([point1, point, point2]);
|
|
121
147
|
addGeometry(lineString);
|
|
@@ -154,6 +180,48 @@ export function createTerminatorGeometry(builder, point, dir, params, textStyleS
|
|
|
154
180
|
addGeometry(slashLine);
|
|
155
181
|
break;
|
|
156
182
|
}
|
|
183
|
+
case "cross": {
|
|
184
|
+
// Diagonal "X" centered on the point, axis-aligned (horizontal upright).
|
|
185
|
+
const halfSize = terminatorHalfHeight;
|
|
186
|
+
addGeometry(LineSegment3d.create(point.plusXYZ(-halfSize, -halfSize), point.plusXYZ(halfSize, halfSize)));
|
|
187
|
+
addGeometry(LineSegment3d.create(point.plusXYZ(-halfSize, halfSize), point.plusXYZ(halfSize, -halfSize)));
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
case "plus": {
|
|
191
|
+
// Orthogonal "+" centered on the point, axis-aligned (horizontal upright).
|
|
192
|
+
const halfSize = terminatorHalfHeight;
|
|
193
|
+
addGeometry(LineSegment3d.create(point.plusXYZ(-halfSize, 0), point.plusXYZ(halfSize, 0)));
|
|
194
|
+
addGeometry(LineSegment3d.create(point.plusXYZ(0, -halfSize), point.plusXYZ(0, halfSize)));
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
case "square": {
|
|
198
|
+
// Axis-aligned square centered on the point (horizontal upright).
|
|
199
|
+
const halfSize = terminatorHalfHeight;
|
|
200
|
+
const square = LineString3d.create([
|
|
201
|
+
point.plusXYZ(-halfSize, -halfSize),
|
|
202
|
+
point.plusXYZ(halfSize, -halfSize),
|
|
203
|
+
point.plusXYZ(halfSize, halfSize),
|
|
204
|
+
point.plusXYZ(-halfSize, halfSize),
|
|
205
|
+
point.plusXYZ(-halfSize, -halfSize),
|
|
206
|
+
]);
|
|
207
|
+
addGeometry(square);
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
case "rectangle": {
|
|
211
|
+
// Axis-aligned rectangle centered on the point (horizontal upright).
|
|
212
|
+
// Respect the configured width/height factors directly.
|
|
213
|
+
const halfWidth = terminatorWidth / 2;
|
|
214
|
+
const halfHeight = terminatorHalfHeight;
|
|
215
|
+
const rectangle = LineString3d.create([
|
|
216
|
+
point.plusXYZ(-halfWidth, -halfHeight),
|
|
217
|
+
point.plusXYZ(halfWidth, -halfHeight),
|
|
218
|
+
point.plusXYZ(halfWidth, halfHeight),
|
|
219
|
+
point.plusXYZ(-halfWidth, halfHeight),
|
|
220
|
+
point.plusXYZ(-halfWidth, -halfHeight),
|
|
221
|
+
]);
|
|
222
|
+
addGeometry(rectangle);
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
157
225
|
}
|
|
158
226
|
return result;
|
|
159
227
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LeaderGeometry.js","sourceRoot":"","sources":["../../../src/annotations/LeaderGeometry.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAmB,WAAW,EAAgG,MAAM,oBAAoB,CAAC;AAC1K,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAkB,aAAa,EAAE,YAAY,EAAE,IAAI,EAAQ,OAAO,EAAa,QAAQ,EAAE,MAAM,sB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QAClF,MAAM,kBAAkB,GAAG,UAAU,CAAC,oBAAoB,CAAC,gBAAgB,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;QACvG,eAAe,GAAG,kBAAkB,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC;IACzD,CAAC;IACD,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module ElementGeometry\r\n */\r\n\r\nimport { ColorDef, ElementGeometry, FillDisplay, GeometryParams, TextAnnotationLeader, TextFrameStyleProps, TextStyleColor, TextStyleSettings } from \"@itwin/core-common\";\r\nimport { Angle, Arc3d, CurveCurve, CurvePrimitive, LineSegment3d, LineString3d, Loop, Path, Point3d, Transform, Vector3d } from \"@itwin/core-geometry\";\r\nimport { computeFrame } from \"./FrameGeometry\";\r\nimport { TextBlockLayout, TextStyleResolver } from \"./TextBlockLayout\";\r\n\r\n/**\r\n * Constructs and appends leader lines and their terminators to the provided geometry builder for a text annotation.\r\n *\r\n * This function processes an array of `TextAnnotationLeader` objects, computes their attachment points\r\n * relative to a text frame (or a default rectangular frame if none is provided), and appends the leader\r\n * line and terminator geometry to the builder. It also applies color overrides if specified\r\n * in the leader's style overrides.\r\n *\r\n * @param builder - The geometry builder to which the leader geometries will be appended.\r\n * @param leaders - An array of leader properties.\r\n * @param layout - The layout information for the text block, including its range.\r\n * @param transform - The transform to apply to the frame and leader geometry.\r\n * @param params - The geometry parameters, such as color, to use for the leader lines.\r\n * @param textStyleResolver - Resolver for text styles, used to obtain leader styles.\r\n * @param scaleFactor - The scale factor to apply to leader dimensions, usually comes from the `scaleFactor` of a [[Drawing]] element.\r\n * @returns `true` if at least one leader with a terminator was successfully appended; otherwise, `false`.\r\n * @beta\r\n */\r\nexport function appendLeadersToBuilder(builder: ElementGeometry.Builder, leaders: TextAnnotationLeader[], layout: TextBlockLayout, transform: Transform, params: GeometryParams, textStyleResolver: TextStyleResolver, scaleFactor: number): boolean {\r\n let result = true;\r\n const scaledBlockTextHeight = textStyleResolver.blockSettings.textHeight * scaleFactor;\r\n let frame: TextFrameStyleProps | undefined = textStyleResolver.blockSettings.frame;\r\n\r\n // If there is no frame, use a rectangular frame to compute the attachmentPoints for leaders.\r\n if (frame === undefined || frame.shape === \"none\") {\r\n frame = { shape: \"rectangle\" }\r\n }\r\n if (frame.shape === undefined || frame.shape === \"none\") return false;\r\n const frameCurve = computeFrame({ frame: frame.shape, range: layout.range, transform });\r\n\r\n for (const leader of leaders) {\r\n const leaderStyle = textStyleResolver.resolveSettings(leader.styleOverrides ?? {}, true);\r\n\r\n let effectiveColor: TextStyleColor = \"subcategory\";\r\n\r\n if (leaderStyle.leader.color === \"inherit\") {\r\n effectiveColor = leaderStyle.color;\r\n } else if (leaderStyle.leader.color !== \"subcategory\") {\r\n effectiveColor = leaderStyle.leader.color;\r\n }\r\n\r\n if (effectiveColor !== \"subcategory\") {\r\n params.lineColor = ColorDef.fromJSON(effectiveColor);\r\n result = result && builder.appendGeometryParamsChange(params);\r\n }\r\n\r\n const attachmentPoint = computeLeaderAttachmentPoint(leader, frameCurve, layout, transform);\r\n if (!attachmentPoint) return false;\r\n\r\n // Leader line geometry\r\n const leaderLinePoints: Point3d[] = [];\r\n\r\n leaderLinePoints.push(leader.startPoint)\r\n\r\n leader.intermediatePoints?.forEach((point) => {\r\n leaderLinePoints.push(point);\r\n });\r\n\r\n if (leaderStyle.leader.wantElbow) {\r\n const elbowLength = leaderStyle.leader.elbowLength * scaledBlockTextHeight;\r\n const elbowDirection = computeElbowDirection(attachmentPoint, frameCurve, elbowLength);\r\n if (elbowDirection)\r\n leaderLinePoints.push(attachmentPoint.plusScaled(elbowDirection, elbowLength))\r\n }\r\n\r\n leaderLinePoints.push(attachmentPoint)\r\n\r\n const terminatorDirection = Vector3d.createStartEnd(\r\n leaderLinePoints[0], leaderLinePoints[1]\r\n ).normalize();\r\n const terminatorWidth = leaderStyle.leader.terminatorWidthFactor * scaledBlockTextHeight;\r\n // Truncate the first segment of the leader lines to account for the arrowhead size when closedArrow (hollow triangle) terminatorShape is used.\r\n if (leaderStyle.leader.terminatorShape === \"closedArrow\") {\r\n if (terminatorDirection)\r\n leaderLinePoints[0] = leaderLinePoints[0].plusScaled(terminatorDirection, terminatorWidth);\r\n }\r\n\r\n result = result && builder.appendGeometryQuery(LineString3d.create(leaderLinePoints));\r\n\r\n if (leaderStyle.leader.terminatorShape !== \"none\") {\r\n // Terminator geometry\r\n if (!terminatorDirection) continue; // Assuming leaders without terminators is a valid case.\r\n result = result && createTerminatorGeometry(builder, leader.startPoint, terminatorDirection, params, leaderStyle, scaledBlockTextHeight);\r\n\r\n }\r\n\r\n }\r\n return result;\r\n}\r\n\r\n/**\r\n * Creates the geometry for a terminator at the end of a leader line.\r\n * @param builder The geometry builder to append the terminator geometry to.\r\n * @param point The starting point of the leader line.\r\n * @param dir The direction vector of the leader line.\r\n * @param params The geometry parameters to use for the terminator.\r\n * @param textStyleSettings The text style settings to use for the terminator.\r\n * @param textHeight The height of the text block.\r\n * @returns True if the geometry was successfully created, false otherwise.\r\n * @beta\r\n */\r\nexport function createTerminatorGeometry(builder: ElementGeometry.Builder, point: Point3d, dir: Vector3d, params: GeometryParams, textStyleSettings: TextStyleSettings, textHeight: number): boolean {\r\n\r\n let result = true;\r\n const termY = dir.unitCrossProduct(Vector3d.unitZ());\r\n if (!termY) return false; // If dir is parallel to Z, we can't create a terminator\r\n const terminatorHeight = textStyleSettings.leader.terminatorHeightFactor * textHeight;\r\n const terminatorWidth = textStyleSettings.leader.terminatorWidthFactor * textHeight;\r\n const terminatorHalfHeight = terminatorHeight / 2;\r\n const basePoint = point.plusScaled(dir, terminatorWidth);\r\n const point1 = basePoint.plusScaled(termY, terminatorHalfHeight);\r\n const point2 = basePoint.plusScaled(termY.negate(), terminatorHalfHeight);\r\n\r\n // Helper function to add fill parameters\r\n const addFillParams = () => {\r\n params.fillDisplay = FillDisplay.Always;\r\n result = result && builder.appendGeometryParamsChange(params);\r\n };\r\n\r\n // Helper function to create geometry entry\r\n const addGeometry = (content: CurvePrimitive, useLoop = false) => {\r\n const finalContent = useLoop ? Loop.create(content) : content;\r\n result = result && builder.appendGeometryQuery(finalContent);\r\n };\r\n\r\n switch (textStyleSettings.leader.terminatorShape) {\r\n case \"openArrow\": {\r\n const lineString = LineString3d.create([point1, point, point2]);\r\n addGeometry(lineString);\r\n break;\r\n }\r\n\r\n case \"closedArrow\": {\r\n const lineString = LineString3d.create([point1, point, point2, point1]);\r\n addGeometry(lineString);\r\n break;\r\n }\r\n\r\n case \"closedArrowFilled\": {\r\n addFillParams();\r\n const lineString = LineString3d.create([point1, point, point2, point1]);\r\n addGeometry(lineString, true);\r\n break;\r\n }\r\n\r\n case \"circle\": {\r\n const circle = Arc3d.createXY(point, terminatorHalfHeight);\r\n addGeometry(circle);\r\n break;\r\n }\r\n\r\n case \"circleFilled\": {\r\n addFillParams();\r\n const circle = Arc3d.createXY(point, terminatorHalfHeight);\r\n addGeometry(circle, true);\r\n break;\r\n }\r\n\r\n case \"slash\": {\r\n const normalizedVector = dir.normalize();\r\n if (!normalizedVector) throw new Error(\"Invalid reference vector for slash terminator.\");\r\n\r\n const rotatedVector = normalizedVector.rotateXY(Angle.createDegrees(45));\r\n const startPoint = point.plusScaled(rotatedVector, -terminatorHalfHeight);\r\n const endPoint = point.plusScaled(rotatedVector, terminatorHalfHeight);\r\n\r\n const slashLine = LineSegment3d.create(startPoint, endPoint);\r\n addGeometry(slashLine);\r\n break;\r\n }\r\n }\r\n\r\n return result;\r\n};\r\n\r\n\r\n/**\r\n * Computes the direction vector for an \"elbow\" for leader based on the attachment point and a frame curve.\r\n * The elbow direction is determined by whether the attachment point is closer to the left or right side of the frame.\r\n * If the computed elbow would be tangent to the frame at the intersection, no elbow direction is returned.\r\n *\r\n * @param attachmentPoint - The point where the leader attaches.\r\n * @param frameCurve - The frame curve (either a Loop or Path) to which the leader is attached.\r\n * @param elbowLength - The length of the elbow segment to be created.\r\n * @returns The direction vector for the elbow, or `undefined` if the elbow would be tangent to the frame.\r\n * @beta\r\n */\r\nexport function computeElbowDirection(attachmentPoint: Point3d, frameCurve: Loop | Path, elbowLength: number): Vector3d | undefined {\r\n\r\n let elbowDirection: Vector3d | undefined;\r\n // Determine the direction based on the closest point's position relative to the frame\r\n const isCloserToLeft = Math.abs(attachmentPoint.x - frameCurve.range().low.x) < Math.abs(attachmentPoint.x - frameCurve.range().high.x);\r\n\r\n // Decide the direction: left (-X) or right (+X)\r\n elbowDirection = isCloserToLeft ? Vector3d.unitX().negate() : Vector3d.unitX();\r\n\r\n // Verify if the elbow is a tangent to the frame, if yes, do not create an elbow\r\n const elbowPoint = attachmentPoint.plusScaled(elbowDirection, elbowLength);\r\n const elbowLine = LineSegment3d.create(attachmentPoint, elbowPoint);\r\n // Find intersection points between the elbow and the frame\r\n const intersections = CurveCurve.intersectionXYZPairs(elbowLine, false, frameCurve, false);\r\n // As the elbow will intersect the frame only at one point, we can safely use the first intersection\r\n const intersection = intersections[0];\r\n const curveFraction = intersection.detailB.fraction;\r\n const derivative = intersection.detailB.curve?.fractionToPointAndDerivative(curveFraction);\r\n const tangent = derivative?.direction.normalize();\r\n const lineDirection = Vector3d.createStartEnd(elbowLine.point0Ref, elbowLine.point1Ref).normalize();\r\n if (tangent && lineDirection) {\r\n const dot = tangent.dotProduct(lineDirection);\r\n // If the tangent and line direction are aligned (dot product close to 1 or -1), it's tangent\r\n if (Math.abs(dot) > 0.999) {\r\n elbowDirection = undefined;\r\n }\r\n }\r\n return elbowDirection;\r\n}\r\n\r\n/**\r\n * Computes the attachment point for a leader line on a text annotation frame.\r\n *\r\n * The attachment point is determined based on the leader's attachment mode:\r\n * - `\"Nearest\"`: Finds the closest point on the frame curve to the leader's start point.\r\n * - `\"KeyPoint\"`: Uses a specific curve segment and fraction along that segment to determine the point.\r\n * - `\"TextPoint\"`: Calculates a point on the text layout (top/bottom, left/right) and projects it onto the frame curve.\r\n *\r\n * @param leader - The leader props.\r\n * @param frameCurve - The curve (Loop or Path) representing the annotation frame.\r\n * @param textLayout - The layout information for the text block.\r\n * @param transform - The transform applied to the text layout.\r\n * @returns The computed attachment point as a `Point3d`, or `undefined` if it cannot be determined.\r\n * @beta\r\n */\r\nexport function computeLeaderAttachmentPoint(\r\n leader: TextAnnotationLeader,\r\n frameCurve: Loop | Path,\r\n textLayout: TextBlockLayout,\r\n transform: Transform\r\n): Point3d | undefined {\r\n let attachmentPoint: Point3d | undefined;\r\n\r\n if (leader.attachment.mode === \"Nearest\") {\r\n attachmentPoint = frameCurve.closestPoint(leader.startPoint)?.point;\r\n } else if (leader.attachment.mode === \"KeyPoint\") {\r\n const curves = frameCurve.collectCurvePrimitives(undefined, false, true);\r\n const curveIndex = leader.attachment.curveIndex;\r\n const fraction = leader.attachment.fraction;\r\n if (curveIndex >= curves.length) {\r\n // If the curveIndex is invalid, use the last curve\r\n // This is a fallback to avoid out-of-bounds access\r\n attachmentPoint = curves[curves.length - 1].fractionToPoint(fraction);\r\n } else {\r\n attachmentPoint = curves[curveIndex].fractionToPoint(fraction);\r\n }\r\n } else { // attachment.mode=\"TextPoint\"\r\n let scaleDirection = transform.matrix.getColumn(0).negate(); // direction to draw a scaled line from text attachment point to find intersection point on frame\r\n let lineIndex: number;\r\n if (leader.attachment.position.includes(\"Top\")) {\r\n lineIndex = 0\r\n } else {\r\n lineIndex = textLayout.lines.length - 1\r\n }\r\n const lineRange = textLayout.lines[lineIndex].range;\r\n const lineOffset = textLayout.lines[lineIndex].offsetFromDocument;\r\n const origin = transform.multiplyPoint3d(Point3d.fromJSON(lineOffset));\r\n let attachmentPointOnText = origin.plusScaled(transform.matrix.getColumn(1), ((lineRange.yLength()) / 2));\r\n\r\n if (leader.attachment.position.includes(\"Right\")) {\r\n attachmentPointOnText = attachmentPointOnText.plusScaled(transform.matrix.getColumn(0), lineRange.xLength());\r\n scaleDirection = scaleDirection.negate();\r\n }\r\n // Find the nearest intersection point on the frame to get the correct attachment point\r\n // Extend the direction vector to create a target point far along the direction\r\n const targetPoint = attachmentPointOnText.plusScaled(scaleDirection, 1e6); // Scale the direction vector to a large value\r\n const intersectionLine = LineSegment3d.create(attachmentPointOnText, targetPoint);\r\n const closestPointDetail = CurveCurve.intersectionXYZPairs(intersectionLine, false, frameCurve, false);\r\n attachmentPoint = closestPointDetail[0]?.detailA.point;\r\n }\r\n return attachmentPoint;\r\n}"]}
|
|
1
|
+
{"version":3,"file":"LeaderGeometry.js","sourceRoot":"","sources":["../../../src/annotations/LeaderGeometry.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAmB,WAAW,EAAgG,MAAM,oBAAoB,CAAC;AAC1K,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAkB,aAAa,EAAE,YAAY,EAAE,IAAI,EAAQ,OAAO,EAAa,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACvJ,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/C;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAgC,EAAE,OAA+B,EAAE,MAAuB,EAAE,SAAoB,EAAE,MAAsB,EAAE,iBAAoC,EAAE,WAAmB;IACxO,IAAI,MAAM,GAAG,IAAI,CAAC;IAClB,MAAM,qBAAqB,GAAG,iBAAiB,CAAC,aAAa,CAAC,UAAU,GAAG,WAAW,CAAC;IACvF,IAAI,KAAK,GAAoC,iBAAiB,CAAC,aAAa,CAAC,KAAK,CAAC;IAEnF,6FAA6F;IAC7F,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,KAAK,KAAK,MAAM,EAAE,CAAC;QAClD,KAAK,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,CAAA;I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------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module ElementGeometry\r\n */\r\n\r\nimport { ColorDef, ElementGeometry, FillDisplay, GeometryParams, TextAnnotationLeader, TextFrameStyleProps, TextStyleColor, TextStyleSettings } from \"@itwin/core-common\";\r\nimport { Angle, Arc3d, CurveCurve, CurvePrimitive, LineSegment3d, LineString3d, Loop, Path, Point3d, Transform, Vector3d } from \"@itwin/core-geometry\";\r\nimport { computeFrame } from \"./FrameGeometry\";\r\nimport { TextBlockLayout, TextStyleResolver } from \"./TextBlockLayout\";\r\n\r\n/**\r\n * Constructs and appends leader lines and their terminators to the provided geometry builder for a text annotation.\r\n *\r\n * This function processes an array of `TextAnnotationLeader` objects, computes their attachment points\r\n * relative to a text frame (or a default rectangular frame if none is provided), and appends the leader\r\n * line and terminator geometry to the builder. It also applies color overrides if specified\r\n * in the leader's style overrides.\r\n *\r\n * @param builder - The geometry builder to which the leader geometries will be appended.\r\n * @param leaders - An array of leader properties.\r\n * @param layout - The layout information for the text block, including its range.\r\n * @param transform - The transform to apply to the frame and leader geometry.\r\n * @param params - The geometry parameters, such as color, to use for the leader lines.\r\n * @param textStyleResolver - Resolver for text styles, used to obtain leader styles.\r\n * @param scaleFactor - The scale factor to apply to leader dimensions, usually comes from the `scaleFactor` of a [[Drawing]] element.\r\n * @returns `true` if at least one leader with a terminator was successfully appended; otherwise, `false`.\r\n * @beta\r\n */\r\nexport function appendLeadersToBuilder(builder: ElementGeometry.Builder, leaders: TextAnnotationLeader[], layout: TextBlockLayout, transform: Transform, params: GeometryParams, textStyleResolver: TextStyleResolver, scaleFactor: number): boolean {\r\n let result = true;\r\n const scaledBlockTextHeight = textStyleResolver.blockSettings.textHeight * scaleFactor;\r\n let frame: TextFrameStyleProps | undefined = textStyleResolver.blockSettings.frame;\r\n\r\n // If there is no frame, use a rectangular frame to compute the attachmentPoints for leaders.\r\n if (frame === undefined || frame.shape === \"none\") {\r\n frame = { shape: \"rectangle\" }\r\n }\r\n if (frame.shape === undefined || frame.shape === \"none\") return false;\r\n const frameCurve = computeFrame({ frame: frame.shape, range: layout.range, transform });\r\n\r\n for (const leader of leaders) {\r\n const leaderStyle = textStyleResolver.resolveSettings(leader.styleOverrides ?? {}, true);\r\n\r\n let effectiveColor: TextStyleColor = \"subcategory\";\r\n\r\n if (leaderStyle.leader.color === \"inherit\") {\r\n effectiveColor = leaderStyle.color;\r\n } else if (leaderStyle.leader.color !== \"subcategory\") {\r\n effectiveColor = leaderStyle.leader.color;\r\n }\r\n\r\n if (effectiveColor !== \"subcategory\") {\r\n params.lineColor = ColorDef.fromJSON(effectiveColor);\r\n result = result && builder.appendGeometryParamsChange(params);\r\n }\r\n\r\n if (leaderStyle.leader.showLeaders) {\r\n const attachmentPoint = computeLeaderAttachmentPoint(leader, frameCurve, layout, transform);\r\n if (!attachmentPoint) return false;\r\n\r\n let elbowPoint: Point3d | undefined;\r\n if (leaderStyle.leader.wantElbow) {\r\n const elbowLength = leaderStyle.leader.elbowLength * scaledBlockTextHeight;\r\n const elbowDirection = computeElbowDirection(attachmentPoint, frameCurve, elbowLength);\r\n if (elbowDirection)\r\n elbowPoint = attachmentPoint.plusScaled(elbowDirection, elbowLength);\r\n }\r\n\r\n // Leader line geometry\r\n const leaderLinePoints: Point3d[] = [];\r\n const terminatorWidth = leaderStyle.leader.terminatorWidthFactor * scaledBlockTextHeight;\r\n let leaderStartPoint = leader.startPoint;\r\n if (leaderStyle.leader.showTargetPoint && leaderStyle.leader.targetPointOffsetFactor !== 0) {\r\n const offset = leaderStyle.leader.targetPointOffsetFactor * scaledBlockTextHeight;\r\n let firstSegmentEnd = leader.intermediatePoints?.[0];\r\n\r\n // If there are no intermediate points, offset along the elbow segment when present.\r\n if (!firstSegmentEnd && elbowPoint)\r\n firstSegmentEnd = elbowPoint;\r\n\r\n if (!firstSegmentEnd)\r\n firstSegmentEnd = attachmentPoint;\r\n\r\n\r\n // Offset the target-point marker away from the start point along the first leader segment.\r\n // Clamp the added distance so negative values resolve to 0 and large values cannot overshoot the first vertex.\r\n // When terminators are hidden, use the text height as a conservative guard distance; otherwise use the terminator width.\r\n const firstSegmentLength = leader.startPoint.distance(firstSegmentEnd);\r\n const clampDistance = leaderStyle.leader.showTerminators ? terminatorWidth : scaledBlockTextHeight;\r\n const maxOffset = Math.max(0, firstSegmentLength - clampDistance);\r\n const clampedOffset = Math.min(Math.max(offset, 0), maxOffset);\r\n const leaderDirection = Vector3d.createStartEnd(leader.startPoint, firstSegmentEnd).normalize();\r\n if (leaderDirection)\r\n leaderStartPoint = leader.startPoint.plusScaled(leaderDirection, clampedOffset);\r\n }\r\n leaderLinePoints.push(leaderStartPoint);\r\n\r\n leader.intermediatePoints?.forEach((point) => {\r\n leaderLinePoints.push(point);\r\n });\r\n\r\n if (elbowPoint)\r\n leaderLinePoints.push(elbowPoint);\r\n\r\n leaderLinePoints.push(attachmentPoint);\r\n\r\n const terminatorDirection = Vector3d.createStartEnd(\r\n leaderLinePoints[0], leaderLinePoints[1]\r\n ).normalize();\r\n\r\n // Truncate the first segment of the leader lines to account for the arrowhead size when closedArrow (hollow triangle) terminatorShape is used.\r\n if (leaderStyle.leader.showTerminators && leaderStyle.leader.terminatorShape === \"closedArrow\") {\r\n if (terminatorDirection)\r\n leaderLinePoints[0] = leaderLinePoints[0].plusScaled(terminatorDirection, terminatorWidth);\r\n }\r\n\r\n result = result && builder.appendGeometryQuery(LineString3d.create(leaderLinePoints));\r\n if (leaderStyle.leader.terminatorShape !== \"none\" && leaderStyle.leader.showTerminators) {\r\n // Terminator geometry\r\n if (!terminatorDirection) continue; // Assuming leaders without terminators is a valid case.\r\n result = result && createTerminatorGeometry({ builder, point: leaderStartPoint, dir: terminatorDirection, params, textStyleSettings: leaderStyle, textHeight: scaledBlockTextHeight });\r\n\r\n }\r\n }\r\n\r\n if (leaderStyle.leader.showTargetPoint) {\r\n result = result && createTerminatorGeometry({ builder, point: leader.startPoint, dir: Vector3d.unitX(), params, textStyleSettings: leaderStyle, textHeight: scaledBlockTextHeight, isArrow: false });\r\n }\r\n\r\n }\r\n return result;\r\n}\r\n\r\n/**\r\n * Arguments supplied to [[createTerminatorGeometry]].\r\n * @beta\r\n */\r\nexport interface CreateTerminatorGeometryArgs {\r\n /** The geometry builder to append the terminator geometry to. */\r\n builder: ElementGeometry.Builder;\r\n /** The point at which the terminator is placed - typically the start or end of a leader line. */\r\n point: Point3d;\r\n /** The direction vector of the leader line. */\r\n dir: Vector3d;\r\n /** The geometry parameters to use for the terminator. */\r\n params: GeometryParams;\r\n /** The text style settings describing the terminator's shape and dimensions. */\r\n textStyleSettings: TextStyleSettings;\r\n /** The height of the text block, used to scale the terminator's dimensions. */\r\n textHeight: number;\r\n /** If `true` (the default), the leader's terminator shape is used; otherwise the target-point shape is used. */\r\n isArrow?: boolean;\r\n}\r\n\r\n/**\r\n * Creates the geometry for a terminator at the end of a leader line.\r\n * @param args Describes the terminator geometry to create. See [[CreateTerminatorGeometryArgs]].\r\n * @returns True if the geometry was successfully created, false otherwise.\r\n * @beta\r\n */\r\nexport function createTerminatorGeometry(args: CreateTerminatorGeometryArgs): boolean {\r\n const { builder, point, dir, params, textStyleSettings, textHeight } = args;\r\n const isArrow = args.isArrow ?? true;\r\n\r\n let result = true;\r\n const termY = dir.unitCrossProduct(Vector3d.unitZ());\r\n if (!termY) return false; // If dir is parallel to Z, we can't create a terminator\r\n const terminatorHeight = textStyleSettings.leader.terminatorHeightFactor * textHeight;\r\n const terminatorWidth = textStyleSettings.leader.terminatorWidthFactor * textHeight;\r\n const terminatorHalfHeight = terminatorHeight / 2;\r\n const basePoint = point.plusScaled(dir, terminatorWidth);\r\n const point1 = basePoint.plusScaled(termY, terminatorHalfHeight);\r\n const point2 = basePoint.plusScaled(termY.negate(), terminatorHalfHeight);\r\n\r\n // Helper function to add fill parameters\r\n const addFillParams = () => {\r\n params.fillDisplay = FillDisplay.Always;\r\n result = result && builder.appendGeometryParamsChange(params);\r\n };\r\n\r\n // Helper function to create geometry entry\r\n const addGeometry = (content: CurvePrimitive, useLoop = false) => {\r\n const finalContent = useLoop ? Loop.create(content) : content;\r\n result = result && builder.appendGeometryQuery(finalContent);\r\n };\r\n const shape = isArrow ? textStyleSettings.leader.terminatorShape : textStyleSettings.leader.targetPointShape;\r\n\r\n switch (shape) {\r\n case \"openArrow\": {\r\n const lineString = LineString3d.create([point1, point, point2]);\r\n addGeometry(lineString);\r\n break;\r\n }\r\n\r\n case \"closedArrow\": {\r\n const lineString = LineString3d.create([point1, point, point2, point1]);\r\n addGeometry(lineString);\r\n break;\r\n }\r\n\r\n case \"closedArrowFilled\": {\r\n addFillParams();\r\n const lineString = LineString3d.create([point1, point, point2, point1]);\r\n addGeometry(lineString, true);\r\n break;\r\n }\r\n\r\n case \"circle\": {\r\n const circle = Arc3d.createXY(point, terminatorHalfHeight);\r\n addGeometry(circle);\r\n break;\r\n }\r\n\r\n case \"circleFilled\": {\r\n addFillParams();\r\n const circle = Arc3d.createXY(point, terminatorHalfHeight);\r\n addGeometry(circle, true);\r\n break;\r\n }\r\n\r\n case \"slash\": {\r\n const normalizedVector = dir.normalize();\r\n if (!normalizedVector) throw new Error(\"Invalid reference vector for slash terminator.\");\r\n\r\n const rotatedVector = normalizedVector.rotateXY(Angle.createDegrees(45));\r\n const startPoint = point.plusScaled(rotatedVector, -terminatorHalfHeight);\r\n const endPoint = point.plusScaled(rotatedVector, terminatorHalfHeight);\r\n\r\n const slashLine = LineSegment3d.create(startPoint, endPoint);\r\n addGeometry(slashLine);\r\n break;\r\n }\r\n\r\n case \"cross\": {\r\n // Diagonal \"X\" centered on the point, axis-aligned (horizontal upright).\r\n const halfSize = terminatorHalfHeight;\r\n addGeometry(LineSegment3d.create(point.plusXYZ(-halfSize, -halfSize), point.plusXYZ(halfSize, halfSize)));\r\n addGeometry(LineSegment3d.create(point.plusXYZ(-halfSize, halfSize), point.plusXYZ(halfSize, -halfSize)));\r\n break;\r\n }\r\n\r\n case \"plus\": {\r\n // Orthogonal \"+\" centered on the point, axis-aligned (horizontal upright).\r\n const halfSize = terminatorHalfHeight;\r\n addGeometry(LineSegment3d.create(point.plusXYZ(-halfSize, 0), point.plusXYZ(halfSize, 0)));\r\n addGeometry(LineSegment3d.create(point.plusXYZ(0, -halfSize), point.plusXYZ(0, halfSize)));\r\n break;\r\n }\r\n\r\n case \"square\": {\r\n // Axis-aligned square centered on the point (horizontal upright).\r\n const halfSize = terminatorHalfHeight;\r\n const square = LineString3d.create([\r\n point.plusXYZ(-halfSize, -halfSize),\r\n point.plusXYZ(halfSize, -halfSize),\r\n point.plusXYZ(halfSize, halfSize),\r\n point.plusXYZ(-halfSize, halfSize),\r\n point.plusXYZ(-halfSize, -halfSize),\r\n ]);\r\n addGeometry(square);\r\n break;\r\n }\r\n\r\n case \"rectangle\": {\r\n // Axis-aligned rectangle centered on the point (horizontal upright).\r\n // Respect the configured width/height factors directly.\r\n const halfWidth = terminatorWidth / 2;\r\n const halfHeight = terminatorHalfHeight;\r\n const rectangle = LineString3d.create([\r\n point.plusXYZ(-halfWidth, -halfHeight),\r\n point.plusXYZ(halfWidth, -halfHeight),\r\n point.plusXYZ(halfWidth, halfHeight),\r\n point.plusXYZ(-halfWidth, halfHeight),\r\n point.plusXYZ(-halfWidth, -halfHeight),\r\n ]);\r\n addGeometry(rectangle);\r\n break;\r\n }\r\n }\r\n\r\n return result;\r\n};\r\n\r\n\r\n/**\r\n * Computes the direction vector for an \"elbow\" for leader based on the attachment point and a frame curve.\r\n * The elbow direction is determined by whether the attachment point is closer to the left or right side of the frame.\r\n * If the computed elbow would be tangent to the frame at the intersection, no elbow direction is returned.\r\n *\r\n * @param attachmentPoint - The point where the leader attaches.\r\n * @param frameCurve - The frame curve (either a Loop or Path) to which the leader is attached.\r\n * @param elbowLength - The length of the elbow segment to be created.\r\n * @returns The direction vector for the elbow, or `undefined` if the elbow would be tangent to the frame.\r\n * @beta\r\n */\r\nexport function computeElbowDirection(attachmentPoint: Point3d, frameCurve: Loop | Path, elbowLength: number): Vector3d | undefined {\r\n\r\n let elbowDirection: Vector3d | undefined;\r\n // Determine the direction based on the closest point's position relative to the frame\r\n const isCloserToLeft = Math.abs(attachmentPoint.x - frameCurve.range().low.x) < Math.abs(attachmentPoint.x - frameCurve.range().high.x);\r\n\r\n // Decide the direction: left (-X) or right (+X)\r\n elbowDirection = isCloserToLeft ? Vector3d.unitX().negate() : Vector3d.unitX();\r\n\r\n // Verify if the elbow is a tangent to the frame, if yes, do not create an elbow\r\n const elbowPoint = attachmentPoint.plusScaled(elbowDirection, elbowLength);\r\n const elbowLine = LineSegment3d.create(attachmentPoint, elbowPoint);\r\n // Find intersection points between the elbow and the frame\r\n const intersections = CurveCurve.intersectionXYZPairs(elbowLine, false, frameCurve, false);\r\n // As the elbow will intersect the frame only at one point, we can safely use the first intersection\r\n const intersection = intersections[0];\r\n const curveFraction = intersection.detailB.fraction;\r\n const derivative = intersection.detailB.curve?.fractionToPointAndDerivative(curveFraction);\r\n const tangent = derivative?.direction.normalize();\r\n const lineDirection = Vector3d.createStartEnd(elbowLine.point0Ref, elbowLine.point1Ref).normalize();\r\n if (tangent && lineDirection) {\r\n const dot = tangent.dotProduct(lineDirection);\r\n // If the tangent and line direction are aligned (dot product close to 1 or -1), it's tangent\r\n if (Math.abs(dot) > 0.999) {\r\n elbowDirection = undefined;\r\n }\r\n }\r\n return elbowDirection;\r\n}\r\n\r\n/**\r\n * Computes the attachment point for a leader line on a text annotation frame.\r\n *\r\n * The attachment point is determined based on the leader's attachment mode:\r\n * - `\"Nearest\"`: Finds the closest point on the frame curve to the leader's start point.\r\n * - `\"KeyPoint\"`: Uses a specific curve segment and fraction along that segment to determine the point.\r\n * - `\"TextPoint\"`: Calculates a point on the text layout (top/bottom, left/right) and projects it onto the frame curve.\r\n *\r\n * @param leader - The leader props.\r\n * @param frameCurve - The curve (Loop or Path) representing the annotation frame.\r\n * @param textLayout - The layout information for the text block.\r\n * @param transform - The transform applied to the text layout.\r\n * @returns The computed attachment point as a `Point3d`, or `undefined` if it cannot be determined.\r\n * @beta\r\n */\r\nexport function computeLeaderAttachmentPoint(\r\n leader: TextAnnotationLeader,\r\n frameCurve: Loop | Path,\r\n textLayout: TextBlockLayout,\r\n transform: Transform\r\n): Point3d | undefined {\r\n let attachmentPoint: Point3d | undefined;\r\n\r\n if (leader.attachment.mode === \"Nearest\") {\r\n attachmentPoint = frameCurve.closestPoint(leader.startPoint)?.point;\r\n } else if (leader.attachment.mode === \"KeyPoint\") {\r\n const curves = frameCurve.collectCurvePrimitives(undefined, false, true);\r\n const curveIndex = leader.attachment.curveIndex;\r\n const fraction = leader.attachment.fraction;\r\n if (curveIndex >= curves.length) {\r\n // If the curveIndex is invalid, use the last curve\r\n // This is a fallback to avoid out-of-bounds access\r\n attachmentPoint = curves[curves.length - 1].fractionToPoint(fraction);\r\n } else {\r\n attachmentPoint = curves[curveIndex].fractionToPoint(fraction);\r\n }\r\n } else { // attachment.mode=\"TextPoint\"\r\n let scaleDirection = transform.matrix.getColumn(0).negate(); // direction to draw a scaled line from text attachment point to find intersection point on frame\r\n let lineIndex: number;\r\n if (leader.attachment.position.includes(\"Top\")) {\r\n lineIndex = 0\r\n } else {\r\n lineIndex = textLayout.lines.length - 1\r\n }\r\n const lineRange = textLayout.lines[lineIndex].range;\r\n const lineOffset = textLayout.lines[lineIndex].offsetFromDocument;\r\n const origin = transform.multiplyPoint3d(Point3d.fromJSON(lineOffset));\r\n let attachmentPointOnText = origin.plusScaled(transform.matrix.getColumn(1), ((lineRange.yLength()) / 2));\r\n\r\n if (leader.attachment.position.includes(\"Right\")) {\r\n attachmentPointOnText = attachmentPointOnText.plusScaled(transform.matrix.getColumn(0), lineRange.xLength());\r\n scaleDirection = scaleDirection.negate();\r\n }\r\n // Find the nearest intersection point on the frame to get the correct attachment point\r\n // Extend the direction vector to create a target point far along the direction\r\n const targetPoint = attachmentPointOnText.plusScaled(scaleDirection, 1e6); // Scale the direction vector to a large value\r\n const intersectionLine = LineSegment3d.create(attachmentPointOnText, targetPoint);\r\n const closestPointDetail = CurveCurve.intersectionXYZPairs(intersectionLine, false, frameCurve, false);\r\n attachmentPoint = closestPointDetail[0]?.detailA.point;\r\n }\r\n return attachmentPoint;\r\n}"]}
|
|
@@ -231,7 +231,7 @@ export declare class TextAnnotation3d extends GraphicalElement3d {
|
|
|
231
231
|
* Uses the same semantics as [ECVersion]($ecschema-metadata).
|
|
232
232
|
* @internal
|
|
233
233
|
*/
|
|
234
|
-
export declare const TEXT_STYLE_SETTINGS_JSON_VERSION = "1.0.
|
|
234
|
+
export declare const TEXT_STYLE_SETTINGS_JSON_VERSION = "1.0.3";
|
|
235
235
|
/** Arguments supplied when creating an [[AnnotationTextStyle]].
|
|
236
236
|
* @beta
|
|
237
237
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextAnnotationElement.d.ts","sourceRoot":"","sources":["../../../src/annotations/TextAnnotationElement.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,wBAAwB,EAAe,IAAI,EAAE,SAAS,EAAE,cAAc,EAA4E,kBAAkB,EAAe,gBAAgB,EAAe,gBAAgB,EAAkB,cAAc,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,sBAAsB,EAA8B,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACjc,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAW,kBAAkB,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpI,OAAO,EAAgB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAG/D,OAAO,EAA+B,oCAAoC,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAClI,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8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,qBAAqB,EAAE,CAE7E;IAEF;;;;OAIG;WACoB,WAAW,CAAC,KAAK,EAAE,qBAAqB,GAAG,wBAAwB;IAS1F;;;;OAIG;WACoB,SAAS,CAAC,KAAK,EAAE,wBAAwB,EAAE,MAAM,EAAE,QAAQ,GAAG,QAAQ;IAQ7F,mGAAmG;IACnG,OAAO,CAAC,MAAM,CAAC,sBAAsB;IAKrC;;;;;;OAMG;WACiB,gBAAgB,CAAC,iBAAiB,EAAE,UAAU,EAAE,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,UAAU,CAAC;qBAgC5F,QAAQ,CAAC,OAAO,EAAE,yBAAyB,EAAE,QAAQ,EAAE,wBAAwB,EAAE,QAAQ,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;CAkBpK"}
|
|
@@ -439,27 +439,42 @@ function updateTextBlocks(elem, textBlocks) {
|
|
|
439
439
|
*/
|
|
440
440
|
// 1.0.1 - Added terminatorShapes for leaders
|
|
441
441
|
// 1.0.2 - Changed margins to be fractions of text height instead of absolute values
|
|
442
|
-
|
|
442
|
+
// 1.0.3 - Added new leader style properties for targetPoint feature (showLeaders,showTerminators,showTargetPoint,targetPointShape,targetPointOffsetFactor)
|
|
443
|
+
export const TEXT_STYLE_SETTINGS_JSON_VERSION = "1.0.3";
|
|
443
444
|
function migrateTextStyleSettings(oldData) {
|
|
444
|
-
|
|
445
|
-
|
|
445
|
+
const data = oldData.data;
|
|
446
|
+
const version = oldData.version;
|
|
447
|
+
if (version === TEXT_STYLE_SETTINGS_JSON_VERSION)
|
|
448
|
+
return data;
|
|
446
449
|
// Migrate from 1.0.0 to 1.0.1
|
|
447
|
-
if (
|
|
448
|
-
|
|
450
|
+
if (semver.lt(version, "1.0.1")) {
|
|
451
|
+
if (data.leader && !data.leader.terminatorShape) {
|
|
452
|
+
data.leader.terminatorShape = TextStyleSettings.defaultProps.leader.terminatorShape;
|
|
453
|
+
}
|
|
449
454
|
}
|
|
450
455
|
// Migrate from 1.0.1 to 1.0.2.
|
|
451
|
-
if (
|
|
456
|
+
if (semver.lt(version, "1.0.2")) {
|
|
452
457
|
// In 1.0.2, margins are specified as a fraction of text height instead of absolute values.
|
|
453
|
-
const textHeight =
|
|
454
|
-
const margins =
|
|
455
|
-
|
|
458
|
+
const textHeight = data.textHeight ?? TextStyleSettings.defaultProps.textHeight;
|
|
459
|
+
const margins = data.margins ?? TextStyleSettings.defaultProps.margins;
|
|
460
|
+
data.margins = {
|
|
456
461
|
top: (margins.top ?? TextStyleSettings.defaultProps.margins.top) / textHeight,
|
|
457
462
|
bottom: (margins.bottom ?? TextStyleSettings.defaultProps.margins.bottom) / textHeight,
|
|
458
463
|
left: (margins.left ?? TextStyleSettings.defaultProps.margins.left) / textHeight,
|
|
459
464
|
right: (margins.right ?? TextStyleSettings.defaultProps.margins.right) / textHeight,
|
|
460
465
|
};
|
|
461
466
|
}
|
|
462
|
-
|
|
467
|
+
// Migrate from 1.0.2 to 1.0.3.
|
|
468
|
+
if (semver.lt(version, "1.0.3")) {
|
|
469
|
+
if (data.leader) {
|
|
470
|
+
data.leader.showLeaders = data.leader?.showLeaders ?? TextStyleSettings.defaultProps.leader.showLeaders;
|
|
471
|
+
data.leader.showTerminators = data.leader?.showTerminators ?? TextStyleSettings.defaultProps.leader.showTerminators;
|
|
472
|
+
data.leader.showTargetPoint = data.leader?.showTargetPoint ?? TextStyleSettings.defaultProps.leader.showTargetPoint;
|
|
473
|
+
data.leader.targetPointShape = data.leader?.targetPointShape ?? TextStyleSettings.defaultProps.leader.targetPointShape;
|
|
474
|
+
data.leader.targetPointOffsetFactor = data.leader?.targetPointOffsetFactor ?? TextStyleSettings.defaultProps.leader.targetPointOffsetFactor;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
return data;
|
|
463
478
|
}
|
|
464
479
|
/**
|
|
465
480
|
* The definition element that holds text style information.
|