@itwin/core-backend 5.4.0-dev.3 → 5.4.0-dev.5
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/lib/cjs/annotations/ElementDrivesTextAnnotation.d.ts +14 -0
- package/lib/cjs/annotations/ElementDrivesTextAnnotation.d.ts.map +1 -1
- package/lib/cjs/annotations/ElementDrivesTextAnnotation.js +32 -19
- package/lib/cjs/annotations/ElementDrivesTextAnnotation.js.map +1 -1
- package/lib/cjs/annotations/LeaderGeometry.d.ts.map +1 -1
- package/lib/cjs/annotations/LeaderGeometry.js +7 -9
- package/lib/cjs/annotations/LeaderGeometry.js.map +1 -1
- package/lib/cjs/annotations/TextAnnotationElement.d.ts.map +1 -1
- package/lib/cjs/annotations/TextAnnotationElement.js +3 -4
- package/lib/cjs/annotations/TextAnnotationElement.js.map +1 -1
- package/lib/cjs/annotations/TextBlockLayout.d.ts.map +1 -1
- package/lib/cjs/annotations/TextBlockLayout.js +2 -1
- package/lib/cjs/annotations/TextBlockLayout.js.map +1 -1
- package/lib/cjs/internal/annotations/fields.d.ts +3 -2
- package/lib/cjs/internal/annotations/fields.d.ts.map +1 -1
- package/lib/cjs/internal/annotations/fields.js +12 -5
- package/lib/cjs/internal/annotations/fields.js.map +1 -1
- package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts +14 -0
- package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts.map +1 -1
- package/lib/esm/annotations/ElementDrivesTextAnnotation.js +33 -20
- package/lib/esm/annotations/ElementDrivesTextAnnotation.js.map +1 -1
- package/lib/esm/annotations/LeaderGeometry.d.ts.map +1 -1
- package/lib/esm/annotations/LeaderGeometry.js +7 -9
- package/lib/esm/annotations/LeaderGeometry.js.map +1 -1
- package/lib/esm/annotations/TextAnnotationElement.d.ts.map +1 -1
- package/lib/esm/annotations/TextAnnotationElement.js +3 -4
- package/lib/esm/annotations/TextAnnotationElement.js.map +1 -1
- package/lib/esm/annotations/TextBlockLayout.d.ts.map +1 -1
- package/lib/esm/annotations/TextBlockLayout.js +2 -1
- package/lib/esm/annotations/TextBlockLayout.js.map +1 -1
- package/lib/esm/internal/annotations/fields.d.ts +3 -2
- package/lib/esm/internal/annotations/fields.d.ts.map +1 -1
- package/lib/esm/internal/annotations/fields.js +11 -5
- package/lib/esm/internal/annotations/fields.js.map +1 -1
- package/lib/esm/test/annotations/LeaderGeometry.test.js +0 -1
- package/lib/esm/test/annotations/LeaderGeometry.test.js.map +1 -1
- package/lib/esm/test/annotations/TextAnnotation.test.js +49 -6
- package/lib/esm/test/annotations/TextAnnotation.test.js.map +1 -1
- package/package.json +12 -12
|
@@ -36,6 +36,15 @@ export interface ITextAnnotation {
|
|
|
36
36
|
* @beta
|
|
37
37
|
*/
|
|
38
38
|
export declare function isITextAnnotation(element: Element): element is ITextAnnotation & Element;
|
|
39
|
+
/** Arguments supplied to [[ElementDrivesTextAnnotation.evaluateFields]].
|
|
40
|
+
* @beta
|
|
41
|
+
*/
|
|
42
|
+
export interface EvaluateFieldsArgs {
|
|
43
|
+
/** The text block whose fields are to be evaluated. */
|
|
44
|
+
block: TextBlock;
|
|
45
|
+
/** The iModel containing the elements supplying the display strings for the fields in [[block]]. */
|
|
46
|
+
iModel: IModelDb;
|
|
47
|
+
}
|
|
39
48
|
/** A relationship in which the source element hosts one or more properties that are displayed by a target [[ITextAnnotation]] element.
|
|
40
49
|
* This relationship is used to automatically update the [FieldRun]($common)s contained in the target element when the source element is modified.
|
|
41
50
|
* An [[ITextAnnotation]] element should invoke [[updateFieldDependencies]] from its [[Element.onInserted]] and [[Element.onUpdated]] functions to
|
|
@@ -60,6 +69,11 @@ export declare class ElementDrivesTextAnnotation extends ElementDrivesElement {
|
|
|
60
69
|
* It also deletes any stale relationships left over from fields that were deleted or whose source elements changed.
|
|
61
70
|
*/
|
|
62
71
|
static updateFieldDependencies(annotationElementId: Id64String, iModel: IModelDb): void;
|
|
72
|
+
/** Recompute the display strings of all [FieldRun]($common)s in a [TextBlock]($common).
|
|
73
|
+
* @returns the number of fields whose display strings were modified.
|
|
74
|
+
* @throws Error if evaluation of any field fails.
|
|
75
|
+
*/
|
|
76
|
+
static evaluateFields(args: EvaluateFieldsArgs): number;
|
|
63
77
|
/** When copying an [[ITextAnnotation]] from one iModel into another, remaps the element Ids in any [FieldPropertyHost]($common) within the cloned element
|
|
64
78
|
* so that they refer to elements in the `context`'s target iModel, and sets any Ids that cannot be remapped to [Id64.invalid]($bentley).
|
|
65
79
|
* Implementations of `ITextAnnotation` should invoke this function from their implementations of [[Element.onCloned]].
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementDrivesTextAnnotation.d.ts","sourceRoot":"","sources":["../../../src/annotations/ElementDrivesTextAnnotation.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,SAAS,EAA8B,MAAM,oBAAoB,CAAC;AAC9G,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,OAAO,EAAkB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAEzE;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,sBAAsB;IACtB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,gIAAgI;IAChI,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;CACtB;AAKD;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,uEAAuE;IACvE,gBAAgB,CAAC,EAAE,oCAAoC,CAAC;IACxD,sFAAsF;IACtF,aAAa,IAAI,QAAQ,CAAC,cAAc,CAAC,CAAC;IAC1C,mGAAmG;IACnG,gBAAgB,CAAC,UAAU,EAAE,cAAc,EAAE,GAAG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AAC,CAAC;IAC1C,mGAAmG;IACnG,gBAAgB,CAAC,UAAU,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;CACtD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,eAAe,GAAG,OAAO,CAExF;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,uDAAuD;IACvD,KAAK,EAAE,SAAS,CAAC;IACjB,oGAAoG;IACpG,MAAM,EAAE,QAAQ,CAAC;CAClB;AAED;;;;;;;GAOG;AACH,qBAAa,2BAA4B,SAAQ,oBAAoB;IACnE,WAA2B,SAAS,IAAI,MAAM,CAA0C;IAExF,gBAAgB;WACO,aAAa,CAAC,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAE,QAAQ,GAAG,IAAI;IAItF,gBAAgB;WACO,mBAAmB,CAAC,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAE,QAAQ,GAAG,IAAI;IAI5F;;;OAGG;WACW,oBAAoB,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO;IAI7D;;;OAGG;WACW,uBAAuB,CAAC,mBAAmB,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,GAAG,IAAI;IAqE9F;;;OAGG;WACW,cAAc,CAAC,IAAI,EAAE,kBAAkB,GAAG,MAAM;IAI9D;;;OAGG;WACW,WAAW,CAAC,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,yBAAyB,GAAG,IAAI;CAwB5F;AAED;;GAEG;AACH,qBAAa,oCAAqC,SAAQ,cAAc;IACtE,OAAc,aAAa,SAAkD;gBAC1D,qBAAqB,EAAE,UAAU,EAAE,YAAY,GAAE,MAA2D;CAGhI"}
|
|
@@ -45,17 +45,13 @@ class ElementDrivesTextAnnotation extends Relationship_1.ElementDrivesElement {
|
|
|
45
45
|
* update when the source element changes.
|
|
46
46
|
*/
|
|
47
47
|
static isSupportedForIModel(iModel) {
|
|
48
|
-
|
|
49
|
-
return undefined !== bisCoreVersion && bisCoreVersion.compare(minBisCoreVersion) >= 0;
|
|
48
|
+
return iModel.meetsMinimumSchemaVersion("BisCore", minBisCoreVersion);
|
|
50
49
|
}
|
|
51
50
|
/** Examines all of the [FieldRun]($common)s within the specified [[ITextAnnotation]] and ensures that the appropriate
|
|
52
51
|
* `ElementDrivesTextAnnotation` relationships exist between the fields' source elements and this target element.
|
|
53
52
|
* It also deletes any stale relationships left over from fields that were deleted or whose source elements changed.
|
|
54
53
|
*/
|
|
55
54
|
static updateFieldDependencies(annotationElementId, iModel) {
|
|
56
|
-
if (!ElementDrivesTextAnnotation.isSupportedForIModel(iModel)) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
55
|
const annotationElement = iModel.elements.tryGetElement(annotationElementId);
|
|
60
56
|
if (!annotationElement || !isITextAnnotation(annotationElement)) {
|
|
61
57
|
return;
|
|
@@ -73,27 +69,37 @@ class ElementDrivesTextAnnotation extends Relationship_1.ElementDrivesElement {
|
|
|
73
69
|
}
|
|
74
70
|
const sourceToRelationship = new Map();
|
|
75
71
|
const blocks = annotationElement.getTextBlocks();
|
|
72
|
+
let haveFields = false;
|
|
76
73
|
for (const block of blocks) {
|
|
77
74
|
for (const { child } of (0, core_common_1.traverseTextBlockComponent)(block.textBlock)) {
|
|
78
|
-
if (child.type === "field"
|
|
79
|
-
|
|
75
|
+
if (child.type === "field") {
|
|
76
|
+
haveFields = true;
|
|
77
|
+
if (isValidSourceId(child.propertyHost.elementId)) {
|
|
78
|
+
sourceToRelationship.set(child.propertyHost.elementId, null);
|
|
79
|
+
}
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
+
if (haveFields) {
|
|
84
|
+
iModel.requireMinimumSchemaVersion("BisCore", minBisCoreVersion, "Text fields");
|
|
85
|
+
(0, fields_1.updateAllFields)(annotationElementId, iModel);
|
|
86
|
+
}
|
|
83
87
|
const staleRelationships = new Set();
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
sourceToRelationship.
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
88
|
+
if (this.isSupportedForIModel(iModel)) {
|
|
89
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
90
|
+
annotationElement.iModel.withPreparedStatement(`SELECT ECInstanceId, SourceECInstanceId FROM BisCore.ElementDrivesTextAnnotation WHERE TargetECInstanceId=${annotationElement.id}`, (stmt) => {
|
|
91
|
+
while (core_bentley_1.DbResult.BE_SQLITE_ROW === stmt.step()) {
|
|
92
|
+
const relationshipId = stmt.getValue(0).getId();
|
|
93
|
+
const sourceId = stmt.getValue(1).getId();
|
|
94
|
+
if (sourceToRelationship.has(sourceId)) {
|
|
95
|
+
sourceToRelationship.set(sourceId, relationshipId);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
staleRelationships.add(relationshipId);
|
|
99
|
+
}
|
|
94
100
|
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
97
103
|
for (const [sourceId, relationshipId] of sourceToRelationship) {
|
|
98
104
|
if (relationshipId === null) {
|
|
99
105
|
ElementDrivesTextAnnotation.create(annotationElement.iModel, sourceId, annotationElement.id).insert();
|
|
@@ -104,6 +110,13 @@ class ElementDrivesTextAnnotation extends Relationship_1.ElementDrivesElement {
|
|
|
104
110
|
annotationElement.iModel.relationships.deleteInstances(staleRelationshipProps);
|
|
105
111
|
}
|
|
106
112
|
}
|
|
113
|
+
/** Recompute the display strings of all [FieldRun]($common)s in a [TextBlock]($common).
|
|
114
|
+
* @returns the number of fields whose display strings were modified.
|
|
115
|
+
* @throws Error if evaluation of any field fails.
|
|
116
|
+
*/
|
|
117
|
+
static evaluateFields(args) {
|
|
118
|
+
return (0, fields_1.updateFields)(args.block, (0, fields_1.createUpdateContext)(undefined, args.iModel, false));
|
|
119
|
+
}
|
|
107
120
|
/** When copying an [[ITextAnnotation]] from one iModel into another, remaps the element Ids in any [FieldPropertyHost]($common) within the cloned element
|
|
108
121
|
* so that they refer to elements in the `context`'s target iModel, and sets any Ids that cannot be remapped to [Id64.invalid]($bentley).
|
|
109
122
|
* Implementations of `ITextAnnotation` should invoke this function from their implementations of [[Element.onCloned]].
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementDrivesTextAnnotation.js","sourceRoot":"","sources":["../../../src/annotations/ElementDrivesTextAnnotation.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AA4CH,8CAEC;AA5CD,oDAA8G;AAC9G,kDAAuD;AAGvD,2DAAqE;AACrE,sDAAiE;AACjE,gEAAqD;AAgBrD,2IAA2I;AAC3I,MAAM,iBAAiB,GAAG,IAAI,6BAAS,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;AAgBlD;;GAEG;AACH,SAAgB,iBAAiB,CAAC,OAAgB;IAChD,OAAO,CAAC,eAAe,EAAE,kBAAkB,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,OAAO,IAAI,OAAQ,OAAe,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC;AACvH,CAAC;AAED;;;;;;;GAOG;AACH,MAAa,2BAA4B,SAAQ,mCAAoB;IAC5D,MAAM,KAAc,SAAS,KAAa,OAAO,6BAA6B,CAAC,CAAC,CAAC;IAExF,gBAAgB;IACT,MAAM,CAAU,aAAa,CAAC,KAAwB,EAAE,MAAgB;QAC7E,IAAA,4BAAmB,EAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC;IAED,gBAAgB;IACT,MAAM,CAAU,mBAAmB,CAAC,KAAwB,EAAE,MAAgB;QACnF,IAAA,4BAAmB,EAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,oBAAoB,CAAC,MAAgB;QACjD,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,CAAC,aAAa;QAC7H,KAAK,CAAC,EAAE,EAAE,EAAE,qBAAqB,EAAE,YAAY,EAAE,CAAC,CAAC;IACrD,CAAC;;AAJH,oFAKC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Elements\n */\n\nimport { RelatedElement, RelationshipProps, TextBlock, traverseTextBlockComponent } from \"@itwin/core-common\";\nimport { ElementDrivesElement } from \"../Relationship\";\nimport { IModelDb } from \"../IModelDb\";\nimport { Element } from \"../Element\";\nimport { updateElementFields } from \"../internal/annotations/fields\";\nimport { DbResult, Id64, Id64String } from \"@itwin/core-bentley\";\nimport { ECVersion } from \"@itwin/ecschema-metadata\";\nimport { IModelElementCloneContext } from \"../IModelElementCloneContext\";\n\n/** Describes one of potentially many [TextBlock]($common)s hosted by an [[ITextAnnotation]].\n * For example, a [[TextAnnotation2d]] hosts only a single text block, but an element representing a table may\n * host one text block for each cell in the table, in which case it might use the combination of row and column\n * as the [[id]] for each text block.\n * @beta\n */\nexport interface TextBlockAndId {\n /** The text block. */\n readonly textBlock: TextBlock;\n /** An opaque identifier that allows the [[ITextAnnotation]] to discern which of its hosted text blocks is being referred to. */\n readonly id: unknown;\n}\n\n// ElementDrivesTextAnnotation was introduced in this version of BisCore - iModels with earlier versions cannot support field dependencies.\nconst minBisCoreVersion = new ECVersion(1, 0, 22);\n\n/** Interface implemented by [[GeometricElement]] subclasses whose schemas declare them to implement the mix-in `BisCore:ITextAnnotation`.\n * Such elements may host any number of [TextBlock]($common)s. `ITextAnnotation` provides a uniform way to interact with text regardless of\n * the type of element to which it belongs.\n * @beta\n */\nexport interface ITextAnnotation {\n /** The default [[AnnotationTextStyle]] used by the text annotation. */\n defaultTextStyle?: TextAnnotationUsesTextStyleByDefault;\n /** Obtain a collection of all of the [TextBlock]($common)s hosted by this element. */\n getTextBlocks(): Iterable<TextBlockAndId>;\n /** Update the element in-memory to replace the contents of the specified [TextBlock]($common)s. */\n updateTextBlocks(textBlocks: TextBlockAndId[]): void;\n}\n\n/** Returns `true` if the specified `element` implements [[ITextAnnotation]].\n * @beta\n */\nexport function isITextAnnotation(element: Element): element is ITextAnnotation & Element {\n return [\"getTextBlocks\", \"updateTextBlocks\"].every((x) => x in element && typeof (element as any)[x] === \"function\");\n}\n\n/** A relationship in which the source element hosts one or more properties that are displayed by a target [[ITextAnnotation]] element.\n * This relationship is used to automatically update the [FieldRun]($common)s contained in the target element when the source element is modified.\n * An [[ITextAnnotation]] element should invoke [[updateFieldDependencies]] from its [[Element.onInserted]] and [[Element.onUpdated]] functions to\n * establish or update the relationships required for the [FieldRun]($common)s it contains.\n * @note This relationship was introduced in version 01.00.22 of the BisCore schema. [FieldRun]($common)s created in iModels that have not been upgraded to\n * that version or newer will not automatically update. Use [[isSupportedForIModel]] to check.\n * @beta\n */\nexport class ElementDrivesTextAnnotation extends ElementDrivesElement {\n public static override get className(): string { return \"ElementDrivesTextAnnotation\"; }\n\n /** @internal */\n public static override onRootChanged(props: RelationshipProps, iModel: IModelDb): void {\n updateElementFields(props, iModel, false);\n }\n\n /** @internal */\n public static override onDeletedDependency(props: RelationshipProps, iModel: IModelDb): void {\n updateElementFields(props, iModel, true);\n }\n\n /** Returns true if `iModel` contains a version of the BisCore schema new enough to support this relationship.\n * If not, the schema should be updated before inserting any [FieldRun]($common)s, or those runs will not\n * update when the source element changes.\n */\n public static isSupportedForIModel(iModel: IModelDb): boolean {\n const bisCoreVersion = iModel.querySchemaVersionNumbers(\"BisCore\");\n return undefined !== bisCoreVersion && bisCoreVersion.compare(minBisCoreVersion) >= 0;\n }\n\n /** Examines all of the [FieldRun]($common)s within the specified [[ITextAnnotation]] and ensures that the appropriate\n * `ElementDrivesTextAnnotation` relationships exist between the fields' source elements and this target element.\n * It also deletes any stale relationships left over from fields that were deleted or whose source elements changed.\n */\n public static updateFieldDependencies(annotationElementId: Id64String, iModel: IModelDb): void {\n if (!ElementDrivesTextAnnotation.isSupportedForIModel(iModel)) {\n return;\n }\n\n const annotationElement = iModel.elements.tryGetElement<Element>(annotationElementId);\n if (!annotationElement || !isITextAnnotation(annotationElement)) {\n return;\n }\n\n // The native layer will allow us to insert relationships to invalid or non-existent source elements...errors will arise later. Prevent it.\n function isValidSourceId(id: Id64String): boolean {\n if (!Id64.isValidId64(id)) {\n return false;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return iModel.withPreparedStatement(\"SELECT CodeValue FROM BisCore.Element WHERE ECInstanceId=?\", (stmt) => {\n stmt.bindId(1, id);\n return DbResult.BE_SQLITE_ROW === stmt.step();\n });\n }\n\n const sourceToRelationship = new Map<Id64String, Id64String | null>();\n const blocks = annotationElement.getTextBlocks();\n\n for (const block of blocks) {\n for (const { child } of traverseTextBlockComponent(block.textBlock)) {\n if (child.type === \"field\" && isValidSourceId(child.propertyHost.elementId)) {\n sourceToRelationship.set(child.propertyHost.elementId, null);\n }\n }\n }\n\n const staleRelationships = new Set<Id64String>();\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n annotationElement.iModel.withPreparedStatement(`SELECT ECInstanceId, SourceECInstanceId FROM BisCore.ElementDrivesTextAnnotation WHERE TargetECInstanceId=${annotationElement.id}`, (stmt) => {\n while (DbResult.BE_SQLITE_ROW === stmt.step()) {\n const relationshipId = stmt.getValue(0).getId();\n const sourceId = stmt.getValue(1).getId();\n if (sourceToRelationship.has(sourceId)) {\n sourceToRelationship.set(sourceId, relationshipId);\n } else {\n staleRelationships.add(relationshipId);\n }\n }\n });\n\n for (const [sourceId, relationshipId] of sourceToRelationship) {\n if (relationshipId === null) {\n ElementDrivesTextAnnotation.create(annotationElement.iModel, sourceId, annotationElement.id).insert();\n }\n }\n\n if (staleRelationships.size > 0) {\n const staleRelationshipProps = Array.from(staleRelationships).map(relationshipId =>\n annotationElement.iModel.relationships.getInstanceProps(\"BisCore.ElementDrivesTextAnnotation\", relationshipId)\n );\n annotationElement.iModel.relationships.deleteInstances(staleRelationshipProps);\n }\n }\n\n /** When copying an [[ITextAnnotation]] from one iModel into another, remaps the element Ids in any [FieldPropertyHost]($common) within the cloned element\n * so that they refer to elements in the `context`'s target iModel, and sets any Ids that cannot be remapped to [Id64.invalid]($bentley).\n * Implementations of `ITextAnnotation` should invoke this function from their implementations of [[Element.onCloned]].\n */\n public static remapFields(clone: ITextAnnotation, context: IModelElementCloneContext): void {\n if (!context.isBetweenIModels) {\n return;\n }\n\n const updatedBlocks = [];\n for (const block of clone.getTextBlocks()) {\n let anyUpdated = false;\n for (const { child } of traverseTextBlockComponent(block.textBlock)) {\n if (child.type === \"field\") {\n child.propertyHost.elementId = context.findTargetElementId(child.propertyHost.elementId);\n anyUpdated = true;\n }\n }\n\n if (anyUpdated) {\n updatedBlocks.push(block);\n }\n }\n\n if (updatedBlocks.length > 0) {\n clone.updateTextBlocks(updatedBlocks);\n }\n }\n}\n\n/** Relationship indicating that the [[AnnotationTextStyle]] is being used as the default style for the [[ITextAnnotation]].\n * @beta\n */\nexport class TextAnnotationUsesTextStyleByDefault extends RelatedElement {\n public static classFullName = \"BisCore:TextAnnotationUsesTextStyleByDefault\";\n public constructor(annotationTextStyleId: Id64String, relClassName: string = TextAnnotationUsesTextStyleByDefault.classFullName) {\n super({ id: annotationTextStyleId, relClassName });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ElementDrivesTextAnnotation.js","sourceRoot":"","sources":["../../../src/annotations/ElementDrivesTextAnnotation.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AA4CH,8CAEC;AA5CD,oDAA8G;AAC9G,kDAAuD;AAGvD,2DAAyH;AACzH,sDAAiE;AACjE,gEAAqD;AAgBrD,2IAA2I;AAC3I,MAAM,iBAAiB,GAAG,IAAI,6BAAS,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;AAgBlD;;GAEG;AACH,SAAgB,iBAAiB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,MAAM,EAAE,KAAK,CAAC,CAAC,CAAA;IACrF,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,WAAW,CAAC,KAAsB,EAAE,OAAkC;QAClF,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC;YAC9B,OAAO;QACT,CAAC;QAED,MAAM,aAAa,GAAG,EAAE,CAAC;QACzB,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,aAAa,EAAE,EAAE,CAAC;YAC1C,IAAI,UAAU,GAAG,KAAK,CAAC;YACvB,KAAK,MAAM,EAAE,KAAK,EAAE,IAAI,IAAA,wCAA0B,EAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;gBACpE,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;oBAC3B,KAAK,CAAC,YAAY,CAAC,SAAS,GAAG,OAAO,CAAC,mBAAmB,CAAC,KAAK,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;oBACzF,UAAU,GAAG,IAAI,CAAC;gBACpB,CAAC;YACH,CAAC;YAED,IAAI,UAAU,EAAE,CAAC;gBACf,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC;QAED,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7B,KAAK,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;CACF;AAlID,kEAkIC;AAED;;GAEG;AACH,MAAa,oCAAqC,SAAQ,4BAAc;IAC/D,MAAM,CAAC,aAAa,GAAG,8CAA8C,CAAC;IAC7E,YAAmB,qBAAiC,EAAE,eAAuB,oCAAoC,CAAC,aAAa;QAC7H,KAAK,CAAC,EAAE,EAAE,EAAE,qBAAqB,EAAE,YAAY,EAAE,CAAC,CAAC;IACrD,CAAC;;AAJH,oFAKC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Elements\n */\n\nimport { RelatedElement, RelationshipProps, TextBlock, traverseTextBlockComponent } from \"@itwin/core-common\";\nimport { ElementDrivesElement } from \"../Relationship\";\nimport { IModelDb } from \"../IModelDb\";\nimport { Element } from \"../Element\";\nimport { createUpdateContext, updateAllFields, updateElementFields, updateFields } from \"../internal/annotations/fields\";\nimport { DbResult, Id64, Id64String } from \"@itwin/core-bentley\";\nimport { ECVersion } from \"@itwin/ecschema-metadata\";\nimport { IModelElementCloneContext } from \"../IModelElementCloneContext\";\n\n/** Describes one of potentially many [TextBlock]($common)s hosted by an [[ITextAnnotation]].\n * For example, a [[TextAnnotation2d]] hosts only a single text block, but an element representing a table may\n * host one text block for each cell in the table, in which case it might use the combination of row and column\n * as the [[id]] for each text block.\n * @beta\n */\nexport interface TextBlockAndId {\n /** The text block. */\n readonly textBlock: TextBlock;\n /** An opaque identifier that allows the [[ITextAnnotation]] to discern which of its hosted text blocks is being referred to. */\n readonly id: unknown;\n}\n\n// ElementDrivesTextAnnotation was introduced in this version of BisCore - iModels with earlier versions cannot support field dependencies.\nconst minBisCoreVersion = new ECVersion(1, 0, 22);\n\n/** Interface implemented by [[GeometricElement]] subclasses whose schemas declare them to implement the mix-in `BisCore:ITextAnnotation`.\n * Such elements may host any number of [TextBlock]($common)s. `ITextAnnotation` provides a uniform way to interact with text regardless of\n * the type of element to which it belongs.\n * @beta\n */\nexport interface ITextAnnotation {\n /** The default [[AnnotationTextStyle]] used by the text annotation. */\n defaultTextStyle?: TextAnnotationUsesTextStyleByDefault;\n /** Obtain a collection of all of the [TextBlock]($common)s hosted by this element. */\n getTextBlocks(): Iterable<TextBlockAndId>;\n /** Update the element in-memory to replace the contents of the specified [TextBlock]($common)s. */\n updateTextBlocks(textBlocks: TextBlockAndId[]): void;\n}\n\n/** Returns `true` if the specified `element` implements [[ITextAnnotation]].\n * @beta\n */\nexport function isITextAnnotation(element: Element): element is ITextAnnotation & Element {\n return [\"getTextBlocks\", \"updateTextBlocks\"].every((x) => x in element && typeof (element as any)[x] === \"function\");\n}\n\n/** Arguments supplied to [[ElementDrivesTextAnnotation.evaluateFields]].\n * @beta\n */\nexport interface EvaluateFieldsArgs {\n /** The text block whose fields are to be evaluated. */\n block: TextBlock;\n /** The iModel containing the elements supplying the display strings for the fields in [[block]]. */\n iModel: IModelDb;\n}\n\n/** A relationship in which the source element hosts one or more properties that are displayed by a target [[ITextAnnotation]] element.\n * This relationship is used to automatically update the [FieldRun]($common)s contained in the target element when the source element is modified.\n * An [[ITextAnnotation]] element should invoke [[updateFieldDependencies]] from its [[Element.onInserted]] and [[Element.onUpdated]] functions to\n * establish or update the relationships required for the [FieldRun]($common)s it contains.\n * @note This relationship was introduced in version 01.00.22 of the BisCore schema. [FieldRun]($common)s created in iModels that have not been upgraded to\n * that version or newer will not automatically update. Use [[isSupportedForIModel]] to check.\n * @beta\n */\nexport class ElementDrivesTextAnnotation extends ElementDrivesElement {\n public static override get className(): string { return \"ElementDrivesTextAnnotation\"; }\n\n /** @internal */\n public static override onRootChanged(props: RelationshipProps, iModel: IModelDb): void {\n updateElementFields(props, iModel, false);\n }\n\n /** @internal */\n public static override onDeletedDependency(props: RelationshipProps, iModel: IModelDb): void {\n updateElementFields(props, iModel, true);\n }\n\n /** Returns true if `iModel` contains a version of the BisCore schema new enough to support this relationship.\n * If not, the schema should be updated before inserting any [FieldRun]($common)s, or those runs will not\n * update when the source element changes.\n */\n public static isSupportedForIModel(iModel: IModelDb): boolean {\n return iModel.meetsMinimumSchemaVersion(\"BisCore\", minBisCoreVersion);\n }\n\n /** Examines all of the [FieldRun]($common)s within the specified [[ITextAnnotation]] and ensures that the appropriate\n * `ElementDrivesTextAnnotation` relationships exist between the fields' source elements and this target element.\n * It also deletes any stale relationships left over from fields that were deleted or whose source elements changed.\n */\n public static updateFieldDependencies(annotationElementId: Id64String, iModel: IModelDb): void {\n const annotationElement = iModel.elements.tryGetElement<Element>(annotationElementId);\n if (!annotationElement || !isITextAnnotation(annotationElement)) {\n return;\n }\n\n // The native layer will allow us to insert relationships to invalid or non-existent source elements...errors will arise later. Prevent it.\n function isValidSourceId(id: Id64String): boolean {\n if (!Id64.isValidId64(id)) {\n return false;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return iModel.withPreparedStatement(\"SELECT CodeValue FROM BisCore.Element WHERE ECInstanceId=?\", (stmt) => {\n stmt.bindId(1, id);\n return DbResult.BE_SQLITE_ROW === stmt.step();\n });\n }\n\n const sourceToRelationship = new Map<Id64String, Id64String | null>();\n const blocks = annotationElement.getTextBlocks();\n\n let haveFields = false;\n for (const block of blocks) {\n for (const { child } of traverseTextBlockComponent(block.textBlock)) {\n if (child.type === \"field\") {\n haveFields = true;\n if (isValidSourceId(child.propertyHost.elementId)) {\n sourceToRelationship.set(child.propertyHost.elementId, null);\n }\n }\n }\n }\n\n if (haveFields) {\n iModel.requireMinimumSchemaVersion(\"BisCore\", minBisCoreVersion, \"Text fields\");\n updateAllFields(annotationElementId, iModel)\n }\n\n const staleRelationships = new Set<Id64String>();\n if (this.isSupportedForIModel(iModel)) {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n annotationElement.iModel.withPreparedStatement(`SELECT ECInstanceId, SourceECInstanceId FROM BisCore.ElementDrivesTextAnnotation WHERE TargetECInstanceId=${annotationElement.id}`, (stmt) => {\n while (DbResult.BE_SQLITE_ROW === stmt.step()) {\n const relationshipId = stmt.getValue(0).getId();\n const sourceId = stmt.getValue(1).getId();\n if (sourceToRelationship.has(sourceId)) {\n sourceToRelationship.set(sourceId, relationshipId);\n } else {\n staleRelationships.add(relationshipId);\n }\n }\n });\n }\n\n for (const [sourceId, relationshipId] of sourceToRelationship) {\n if (relationshipId === null) {\n ElementDrivesTextAnnotation.create(annotationElement.iModel, sourceId, annotationElement.id).insert();\n }\n }\n\n if (staleRelationships.size > 0) {\n const staleRelationshipProps = Array.from(staleRelationships).map(relationshipId =>\n annotationElement.iModel.relationships.getInstanceProps(\"BisCore.ElementDrivesTextAnnotation\", relationshipId)\n );\n annotationElement.iModel.relationships.deleteInstances(staleRelationshipProps);\n }\n }\n\n /** Recompute the display strings of all [FieldRun]($common)s in a [TextBlock]($common).\n * @returns the number of fields whose display strings were modified.\n * @throws Error if evaluation of any field fails.\n */\n public static evaluateFields(args: EvaluateFieldsArgs): number {\n return updateFields(args.block, createUpdateContext(undefined, args.iModel, false))\n }\n\n /** When copying an [[ITextAnnotation]] from one iModel into another, remaps the element Ids in any [FieldPropertyHost]($common) within the cloned element\n * so that they refer to elements in the `context`'s target iModel, and sets any Ids that cannot be remapped to [Id64.invalid]($bentley).\n * Implementations of `ITextAnnotation` should invoke this function from their implementations of [[Element.onCloned]].\n */\n public static remapFields(clone: ITextAnnotation, context: IModelElementCloneContext): void {\n if (!context.isBetweenIModels) {\n return;\n }\n\n const updatedBlocks = [];\n for (const block of clone.getTextBlocks()) {\n let anyUpdated = false;\n for (const { child } of traverseTextBlockComponent(block.textBlock)) {\n if (child.type === \"field\") {\n child.propertyHost.elementId = context.findTargetElementId(child.propertyHost.elementId);\n anyUpdated = true;\n }\n }\n\n if (anyUpdated) {\n updatedBlocks.push(block);\n }\n }\n\n if (updatedBlocks.length > 0) {\n clone.updateTextBlocks(updatedBlocks);\n }\n }\n}\n\n/** Relationship indicating that the [[AnnotationTextStyle]] is being used as the default style for the [[ITextAnnotation]].\n * @beta\n */\nexport class TextAnnotationUsesTextStyleByDefault extends RelatedElement {\n public static classFullName = \"BisCore:TextAnnotationUsesTextStyleByDefault\";\n public constructor(annotationTextStyleId: Id64String, relClassName: string = TextAnnotationUsesTextStyleByDefault.classFullName) {\n super({ id: annotationTextStyleId, relClassName });\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LeaderGeometry.d.ts","sourceRoot":"","sources":["../../../src/annotations/LeaderGeometry.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAY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AE,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAsEnP;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,eAAe,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,cAAc,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAwEnM;AAGD;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,eAAe,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,GAAG,IAAI,EAAE,WAAW,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CA4BlI;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,oBAAoB,EAC5B,UAAU,EAAE,IAAI,GAAG,IAAI,EACvB,UAAU,EAAE,eAAe,EAC3B,SAAS,EAAE,SAAS,GACnB,OAAO,GAAG,SAAS,CAyCrB"}
|
|
@@ -107,10 +107,10 @@ function createTerminatorGeometry(builder, point, dir, params, textStyleSettings
|
|
|
107
107
|
return false; // If dir is parallel to Z, we can't create a terminator
|
|
108
108
|
const terminatorHeight = textStyleSettings.leader.terminatorHeightFactor * textHeight;
|
|
109
109
|
const terminatorWidth = textStyleSettings.leader.terminatorWidthFactor * textHeight;
|
|
110
|
+
const terminatorHalfHeight = terminatorHeight / 2;
|
|
110
111
|
const basePoint = point.plusScaled(dir, terminatorWidth);
|
|
111
|
-
const point1 = basePoint.plusScaled(termY,
|
|
112
|
-
const point2 = basePoint.plusScaled(termY.negate(),
|
|
113
|
-
const radius = terminatorHeight / 2;
|
|
112
|
+
const point1 = basePoint.plusScaled(termY, terminatorHalfHeight);
|
|
113
|
+
const point2 = basePoint.plusScaled(termY.negate(), terminatorHalfHeight);
|
|
114
114
|
// Helper function to add fill parameters
|
|
115
115
|
const addFillParams = () => {
|
|
116
116
|
params.fillDisplay = core_common_1.FillDisplay.Always;
|
|
@@ -139,13 +139,13 @@ function createTerminatorGeometry(builder, point, dir, params, textStyleSettings
|
|
|
139
139
|
break;
|
|
140
140
|
}
|
|
141
141
|
case "circle": {
|
|
142
|
-
const circle = core_geometry_1.Arc3d.createXY(point,
|
|
142
|
+
const circle = core_geometry_1.Arc3d.createXY(point, terminatorHalfHeight);
|
|
143
143
|
addGeometry(circle);
|
|
144
144
|
break;
|
|
145
145
|
}
|
|
146
146
|
case "circleFilled": {
|
|
147
147
|
addFillParams();
|
|
148
|
-
const circle = core_geometry_1.Arc3d.createXY(point,
|
|
148
|
+
const circle = core_geometry_1.Arc3d.createXY(point, terminatorHalfHeight);
|
|
149
149
|
addGeometry(circle, true);
|
|
150
150
|
break;
|
|
151
151
|
}
|
|
@@ -154,14 +154,12 @@ function createTerminatorGeometry(builder, point, dir, params, textStyleSettings
|
|
|
154
154
|
if (!normalizedVector)
|
|
155
155
|
throw new Error("Invalid reference vector for slash terminator.");
|
|
156
156
|
const rotatedVector = normalizedVector.rotateXY(core_geometry_1.Angle.createDegrees(45));
|
|
157
|
-
const startPoint = point.plusScaled(rotatedVector, -
|
|
158
|
-
const endPoint = point.plusScaled(rotatedVector,
|
|
157
|
+
const startPoint = point.plusScaled(rotatedVector, -terminatorHalfHeight);
|
|
158
|
+
const endPoint = point.plusScaled(rotatedVector, terminatorHalfHeight);
|
|
159
159
|
const slashLine = core_geometry_1.LineSegment3d.create(startPoint, endPoint);
|
|
160
160
|
addGeometry(slashLine);
|
|
161
161
|
break;
|
|
162
162
|
}
|
|
163
|
-
default:
|
|
164
|
-
throw new Error(`Unknown terminator shape: ${textStyleSettings.leader.terminatorShape}`);
|
|
165
163
|
}
|
|
166
164
|
return result;
|
|
167
165
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LeaderGeometry.js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G,cAAc,CAAC,MAAM,EAAE,CAAC;QAC3C,CAAC;QACD,uFAAuF;QACvF,+EAA+E;QAC/E,MAAM,WAAW,GAAG,qBAAqB,CAAC,UAAU,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC,CAAC,8CAA8C;QACzH,MAAM,gBAAgB,GAAG,6BAAa,CAAC,MAAM,CAAC,qBAAqB,EAAE,WAAW,CAAC,CAAC;QAClF,MAAM,kBAAkB,GAAG,0BAAU,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":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ElementGeometry\n */\n\nimport { ColorDef, ElementGeometry, FillDisplay, GeometryParams, TextAnnotationLeader, TextFrameStyleProps, TextStyleColor, TextStyleSettings } from \"@itwin/core-common\";\nimport { Angle, Arc3d, CurveCurve, CurvePrimitive, LineSegment3d, LineString3d, Loop, Path, Point3d, Transform, Vector3d } from \"@itwin/core-geometry\";\nimport { computeFrame } from \"./FrameGeometry\";\nimport { TextBlockLayout, TextStyleResolver } from \"./TextBlockLayout\";\n\n/**\n * Constructs and appends leader lines and their terminators to the provided geometry builder for a text annotation.\n *\n * This function processes an array of `TextAnnotationLeader` objects, computes their attachment points\n * relative to a text frame (or a default rectangular frame if none is provided), and appends the leader\n * line and terminator geometry to the builder. It also applies color overrides if specified\n * in the leader's style overrides.\n *\n * @param builder - The geometry builder to which the leader geometries will be appended.\n * @param leaders - An array of leader properties.\n * @param layout - The layout information for the text block, including its range.\n * @param transform - The transform to apply to the frame and leader geometry.\n * @param params - The geometry parameters, such as color, to use for the leader lines.\n * @param textStyleResolver - Resolver for text styles, used to obtain leader styles.\n * @param scaleFactor - The scale factor to apply to leader dimensions, usually comes from the `scaleFactor` of a [[Drawing]] element.\n * @returns `true` if at least one leader with a terminator was successfully appended; otherwise, `false`.\n * @beta\n */\nexport function appendLeadersToBuilder(builder: ElementGeometry.Builder, leaders: TextAnnotationLeader[], layout: TextBlockLayout, transform: Transform, params: GeometryParams, textStyleResolver: TextStyleResolver, scaleFactor: number): boolean {\n let result = true;\n const scaledBlockTextHeight = textStyleResolver.blockSettings.textHeight * scaleFactor;\n let frame: TextFrameStyleProps | undefined = textStyleResolver.blockSettings.frame;\n\n // If there is no frame, use a rectangular frame to compute the attachmentPoints for leaders.\n if (frame === undefined || frame.shape === \"none\") {\n frame = { shape: \"rectangle\" }\n }\n if (frame.shape === undefined || frame.shape === \"none\") return false;\n const frameCurve = computeFrame({ frame: frame.shape, range: layout.range, transform });\n\n for (const leader of leaders) {\n const leaderStyle = textStyleResolver.resolveSettings(leader.styleOverrides ?? {}, true);\n\n let effectiveColor: TextStyleColor = \"subcategory\";\n\n if (leaderStyle.leader.color === \"inherit\") {\n effectiveColor = leaderStyle.color;\n } else if (leaderStyle.leader.color !== \"subcategory\") {\n effectiveColor = leaderStyle.leader.color;\n }\n\n if (effectiveColor !== \"subcategory\") {\n params.lineColor = ColorDef.fromJSON(effectiveColor);\n result = result && builder.appendGeometryParamsChange(params);\n }\n\n const attachmentPoint = computeLeaderAttachmentPoint(leader, frameCurve, layout, transform);\n if (!attachmentPoint) return false;\n\n // Leader line geometry\n const leaderLinePoints: Point3d[] = [];\n\n leaderLinePoints.push(leader.startPoint)\n\n leader.intermediatePoints?.forEach((point) => {\n leaderLinePoints.push(point);\n });\n\n if (leaderStyle.leader.wantElbow) {\n const elbowLength = leaderStyle.leader.elbowLength * scaledBlockTextHeight;\n const elbowDirection = computeElbowDirection(attachmentPoint, frameCurve, elbowLength);\n if (elbowDirection)\n leaderLinePoints.push(attachmentPoint.plusScaled(elbowDirection, elbowLength))\n }\n\n leaderLinePoints.push(attachmentPoint)\n\n const terminatorDirection = Vector3d.createStartEnd(\n leaderLinePoints[0], leaderLinePoints[1]\n ).normalize();\n const terminatorWidth = leaderStyle.leader.terminatorWidthFactor * scaledBlockTextHeight;\n // Truncate the first segment of the leader lines to account for the arrowhead size when closedArrow (hollow triangle) terminatorShape is used.\n if (leaderStyle.leader.terminatorShape === \"closedArrow\") {\n if (terminatorDirection)\n leaderLinePoints[0] = leaderLinePoints[0].plusScaled(terminatorDirection, terminatorWidth);\n }\n\n result = result && builder.appendGeometryQuery(LineString3d.create(leaderLinePoints));\n\n if (leaderStyle.leader.terminatorShape !== \"none\") {\n // Terminator geometry\n if (!terminatorDirection) continue; // Assuming leaders without terminators is a valid case.\n result = result && createTerminatorGeometry(builder, leader.startPoint, terminatorDirection, params, leaderStyle, scaledBlockTextHeight);\n\n }\n\n }\n return result;\n}\n\n/**\n * Creates the geometry for a terminator at the end of a leader line.\n * @param builder The geometry builder to append the terminator geometry to.\n * @param point The starting point of the leader line.\n * @param dir The direction vector of the leader line.\n * @param params The geometry parameters to use for the terminator.\n * @param textStyleSettings The text style settings to use for the terminator.\n * @param textHeight The height of the text block.\n * @returns True if the geometry was successfully created, false otherwise.\n * @beta\n */\nexport function createTerminatorGeometry(builder: ElementGeometry.Builder, point: Point3d, dir: Vector3d, params: GeometryParams, textStyleSettings: TextStyleSettings, textHeight: number): boolean {\n\n let result = true;\n const termY = dir.unitCrossProduct(Vector3d.unitZ());\n if (!termY) return false; // If dir is parallel to Z, we can't create a terminator\n const terminatorHeight = textStyleSettings.leader.terminatorHeightFactor * textHeight;\n const terminatorWidth = textStyleSettings.leader.terminatorWidthFactor * textHeight;\n const basePoint = point.plusScaled(dir, terminatorWidth);\n const point1 = basePoint.plusScaled(termY, terminatorHeight / 2);\n const point2 = basePoint.plusScaled(termY.negate(), terminatorHeight / 2);\n const radius = terminatorHeight / 2;\n\n // Helper function to add fill parameters\n const addFillParams = () => {\n params.fillDisplay = FillDisplay.Always;\n result = result && builder.appendGeometryParamsChange(params);\n };\n\n // Helper function to create geometry entry\n const addGeometry = (content: CurvePrimitive, useLoop = false) => {\n const finalContent = useLoop ? Loop.create(content) : content;\n result = result && builder.appendGeometryQuery(finalContent);\n };\n\n switch (textStyleSettings.leader.terminatorShape) {\n case \"openArrow\": {\n const lineString = LineString3d.create([point1, point, point2]);\n addGeometry(lineString);\n break;\n }\n\n case \"closedArrow\": {\n const lineString = LineString3d.create([point1, point, point2, point1]);\n addGeometry(lineString);\n break;\n }\n\n case \"closedArrowFilled\": {\n addFillParams();\n const lineString = LineString3d.create([point1, point, point2, point1]);\n addGeometry(lineString, true);\n break;\n }\n\n case \"circle\": {\n const circle = Arc3d.createXY(point, radius);\n addGeometry(circle);\n break;\n }\n\n case \"circleFilled\": {\n addFillParams();\n const circle = Arc3d.createXY(point, radius);\n addGeometry(circle, true);\n break;\n }\n\n case \"slash\": {\n const normalizedVector = dir.normalize();\n if (!normalizedVector) throw new Error(\"Invalid reference vector for slash terminator.\");\n\n const rotatedVector = normalizedVector.rotateXY(Angle.createDegrees(45));\n const startPoint = point.plusScaled(rotatedVector, -radius);\n const endPoint = point.plusScaled(rotatedVector, radius);\n\n const slashLine = LineSegment3d.create(startPoint, endPoint);\n addGeometry(slashLine);\n break;\n }\n\n default:\n throw new Error(`Unknown terminator shape: ${textStyleSettings.leader.terminatorShape}`);\n }\n\n return result;\n};\n\n\n/**\n * Computes the direction vector for an \"elbow\" for leader based on the attachment point and a frame curve.\n * The elbow direction is determined by whether the attachment point is closer to the left or right side of the frame.\n * If the computed elbow would be tangent to the frame at the intersection, no elbow direction is returned.\n *\n * @param attachmentPoint - The point where the leader attaches.\n * @param frameCurve - The frame curve (either a Loop or Path) to which the leader is attached.\n * @param elbowLength - The length of the elbow segment to be created.\n * @returns The direction vector for the elbow, or `undefined` if the elbow would be tangent to the frame.\n * @beta\n */\nexport function computeElbowDirection(attachmentPoint: Point3d, frameCurve: Loop | Path, elbowLength: number): Vector3d | undefined {\n\n let elbowDirection: Vector3d | undefined;\n // Determine the direction based on the closest point's position relative to the frame\n const isCloserToLeft = Math.abs(attachmentPoint.x - frameCurve.range().low.x) < Math.abs(attachmentPoint.x - frameCurve.range().high.x);\n\n // Decide the direction: left (-X) or right (+X)\n elbowDirection = isCloserToLeft ? Vector3d.unitX().negate() : Vector3d.unitX();\n\n // Verify if the elbow is a tangent to the frame, if yes, do not create an elbow\n const elbowPoint = attachmentPoint.plusScaled(elbowDirection, elbowLength);\n const elbowLine = LineSegment3d.create(attachmentPoint, elbowPoint);\n // Find intersection points between the elbow and the frame\n const intersections = CurveCurve.intersectionXYZPairs(elbowLine, false, frameCurve, false);\n // As the elbow will intersect the frame only at one point, we can safely use the first intersection\n const intersection = intersections[0];\n const curveFraction = intersection.detailB.fraction;\n const derivative = intersection.detailB.curve?.fractionToPointAndDerivative(curveFraction);\n const tangent = derivative?.direction.normalize();\n const lineDirection = Vector3d.createStartEnd(elbowLine.point0Ref, elbowLine.point1Ref).normalize();\n if (tangent && lineDirection) {\n const dot = tangent.dotProduct(lineDirection);\n // If the tangent and line direction are aligned (dot product close to 1 or -1), it's tangent\n if (Math.abs(dot) > 0.999) {\n elbowDirection = undefined;\n }\n }\n return elbowDirection;\n}\n\n/**\n * Computes the attachment point for a leader line on a text annotation frame.\n *\n * The attachment point is determined based on the leader's attachment mode:\n * - `\"Nearest\"`: Finds the closest point on the frame curve to the leader's start point.\n * - `\"KeyPoint\"`: Uses a specific curve segment and fraction along that segment to determine the point.\n * - `\"TextPoint\"`: Calculates a point on the text layout (top/bottom, left/right) and projects it onto the frame curve.\n *\n * @param leader - The leader props.\n * @param frameCurve - The curve (Loop or Path) representing the annotation frame.\n * @param textLayout - The layout information for the text block.\n * @param transform - The transform applied to the text layout.\n * @returns The computed attachment point as a `Point3d`, or `undefined` if it cannot be determined.\n * @beta\n */\nexport function computeLeaderAttachmentPoint(\n leader: TextAnnotationLeader,\n frameCurve: Loop | Path,\n textLayout: TextBlockLayout,\n transform: Transform\n): Point3d | undefined {\n let attachmentPoint: Point3d | undefined;\n\n if (leader.attachment.mode === \"Nearest\") {\n attachmentPoint = frameCurve.closestPoint(leader.startPoint)?.point;\n } else if (leader.attachment.mode === \"KeyPoint\") {\n const curves = frameCurve.collectCurvePrimitives(undefined, false, true);\n const curveIndex = leader.attachment.curveIndex;\n const fraction = leader.attachment.fraction;\n if (curveIndex >= curves.length) {\n // If the curveIndex is invalid, use the last curve\n // This is a fallback to avoid out-of-bounds access\n attachmentPoint = curves[curves.length - 1].fractionToPoint(fraction);\n } else {\n attachmentPoint = curves[curveIndex].fractionToPoint(fraction);\n }\n } else { // attachment.mode=\"TextPoint\"\n let scaleDirection = transform.matrix.getColumn(0).negate(); // direction to draw a scaled line from text attachment point to find intersection point on frame\n let lineIndex: number;\n if (leader.attachment.position.includes(\"Top\")) {\n lineIndex = 0\n } else {\n lineIndex = textLayout.lines.length - 1\n }\n const lineRange = textLayout.lines[lineIndex].range;\n const lineOffset = textLayout.lines[lineIndex].offsetFromDocument;\n const origin = transform.multiplyPoint3d(Point3d.fromJSON(lineOffset));\n let attachmentPointOnText = origin.plusScaled(transform.matrix.getColumn(1), ((lineRange.yLength()) / 2));\n\n if (leader.attachment.position.includes(\"Right\")) {\n attachmentPointOnText = attachmentPointOnText.plusScaled(transform.matrix.getColumn(0), lineRange.xLength());\n scaleDirection = scaleDirection.negate();\n }\n // Find the nearest intersection point on the frame to get the correct attachment point\n // Extend the direction vector to create a target point far along the direction\n const targetPoint = attachmentPointOnText.plusScaled(scaleDirection, 1e6); // Scale the direction vector to a large value\n const intersectionLine = LineSegment3d.create(attachmentPointOnText, targetPoint);\n const closestPointDetail = CurveCurve.intersectionXYZPairs(intersectionLine, false, frameCurve, false);\n attachmentPoint = closestPointDetail[0]?.detailA.point;\n }\n return attachmentPoint;\n}"]}
|
|
1
|
+
{"version":3,"file":"LeaderGeometry.js","sourceRoot":"","sources":["../../../src/annotations/Le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AAG,CAAC,CAAC,CAAC,8CAA8C;QACzH,MAAM,gBAAgB,GAAG,6BAAa,CAAC,MAAM,CAAC,qBAAqB,EAAE,WAAW,CAAC,CAAC;QAClF,MAAM,kBAAkB,GAAG,0BAAU,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":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ElementGeometry\n */\n\nimport { ColorDef, ElementGeometry, FillDisplay, GeometryParams, TextAnnotationLeader, TextFrameStyleProps, TextStyleColor, TextStyleSettings } from \"@itwin/core-common\";\nimport { Angle, Arc3d, CurveCurve, CurvePrimitive, LineSegment3d, LineString3d, Loop, Path, Point3d, Transform, Vector3d } from \"@itwin/core-geometry\";\nimport { computeFrame } from \"./FrameGeometry\";\nimport { TextBlockLayout, TextStyleResolver } from \"./TextBlockLayout\";\n\n/**\n * Constructs and appends leader lines and their terminators to the provided geometry builder for a text annotation.\n *\n * This function processes an array of `TextAnnotationLeader` objects, computes their attachment points\n * relative to a text frame (or a default rectangular frame if none is provided), and appends the leader\n * line and terminator geometry to the builder. It also applies color overrides if specified\n * in the leader's style overrides.\n *\n * @param builder - The geometry builder to which the leader geometries will be appended.\n * @param leaders - An array of leader properties.\n * @param layout - The layout information for the text block, including its range.\n * @param transform - The transform to apply to the frame and leader geometry.\n * @param params - The geometry parameters, such as color, to use for the leader lines.\n * @param textStyleResolver - Resolver for text styles, used to obtain leader styles.\n * @param scaleFactor - The scale factor to apply to leader dimensions, usually comes from the `scaleFactor` of a [[Drawing]] element.\n * @returns `true` if at least one leader with a terminator was successfully appended; otherwise, `false`.\n * @beta\n */\nexport function appendLeadersToBuilder(builder: ElementGeometry.Builder, leaders: TextAnnotationLeader[], layout: TextBlockLayout, transform: Transform, params: GeometryParams, textStyleResolver: TextStyleResolver, scaleFactor: number): boolean {\n let result = true;\n const scaledBlockTextHeight = textStyleResolver.blockSettings.textHeight * scaleFactor;\n let frame: TextFrameStyleProps | undefined = textStyleResolver.blockSettings.frame;\n\n // If there is no frame, use a rectangular frame to compute the attachmentPoints for leaders.\n if (frame === undefined || frame.shape === \"none\") {\n frame = { shape: \"rectangle\" }\n }\n if (frame.shape === undefined || frame.shape === \"none\") return false;\n const frameCurve = computeFrame({ frame: frame.shape, range: layout.range, transform });\n\n for (const leader of leaders) {\n const leaderStyle = textStyleResolver.resolveSettings(leader.styleOverrides ?? {}, true);\n\n let effectiveColor: TextStyleColor = \"subcategory\";\n\n if (leaderStyle.leader.color === \"inherit\") {\n effectiveColor = leaderStyle.color;\n } else if (leaderStyle.leader.color !== \"subcategory\") {\n effectiveColor = leaderStyle.leader.color;\n }\n\n if (effectiveColor !== \"subcategory\") {\n params.lineColor = ColorDef.fromJSON(effectiveColor);\n result = result && builder.appendGeometryParamsChange(params);\n }\n\n const attachmentPoint = computeLeaderAttachmentPoint(leader, frameCurve, layout, transform);\n if (!attachmentPoint) return false;\n\n // Leader line geometry\n const leaderLinePoints: Point3d[] = [];\n\n leaderLinePoints.push(leader.startPoint)\n\n leader.intermediatePoints?.forEach((point) => {\n leaderLinePoints.push(point);\n });\n\n if (leaderStyle.leader.wantElbow) {\n const elbowLength = leaderStyle.leader.elbowLength * scaledBlockTextHeight;\n const elbowDirection = computeElbowDirection(attachmentPoint, frameCurve, elbowLength);\n if (elbowDirection)\n leaderLinePoints.push(attachmentPoint.plusScaled(elbowDirection, elbowLength))\n }\n\n leaderLinePoints.push(attachmentPoint)\n\n const terminatorDirection = Vector3d.createStartEnd(\n leaderLinePoints[0], leaderLinePoints[1]\n ).normalize();\n const terminatorWidth = leaderStyle.leader.terminatorWidthFactor * scaledBlockTextHeight;\n // Truncate the first segment of the leader lines to account for the arrowhead size when closedArrow (hollow triangle) terminatorShape is used.\n if (leaderStyle.leader.terminatorShape === \"closedArrow\") {\n if (terminatorDirection)\n leaderLinePoints[0] = leaderLinePoints[0].plusScaled(terminatorDirection, terminatorWidth);\n }\n\n result = result && builder.appendGeometryQuery(LineString3d.create(leaderLinePoints));\n\n if (leaderStyle.leader.terminatorShape !== \"none\") {\n // Terminator geometry\n if (!terminatorDirection) continue; // Assuming leaders without terminators is a valid case.\n result = result && createTerminatorGeometry(builder, leader.startPoint, terminatorDirection, params, leaderStyle, scaledBlockTextHeight);\n\n }\n\n }\n return result;\n}\n\n/**\n * Creates the geometry for a terminator at the end of a leader line.\n * @param builder The geometry builder to append the terminator geometry to.\n * @param point The starting point of the leader line.\n * @param dir The direction vector of the leader line.\n * @param params The geometry parameters to use for the terminator.\n * @param textStyleSettings The text style settings to use for the terminator.\n * @param textHeight The height of the text block.\n * @returns True if the geometry was successfully created, false otherwise.\n * @beta\n */\nexport function createTerminatorGeometry(builder: ElementGeometry.Builder, point: Point3d, dir: Vector3d, params: GeometryParams, textStyleSettings: TextStyleSettings, textHeight: number): boolean {\n\n let result = true;\n const termY = dir.unitCrossProduct(Vector3d.unitZ());\n if (!termY) return false; // If dir is parallel to Z, we can't create a terminator\n const terminatorHeight = textStyleSettings.leader.terminatorHeightFactor * textHeight;\n const terminatorWidth = textStyleSettings.leader.terminatorWidthFactor * textHeight;\n const terminatorHalfHeight = terminatorHeight / 2;\n const basePoint = point.plusScaled(dir, terminatorWidth);\n const point1 = basePoint.plusScaled(termY, terminatorHalfHeight);\n const point2 = basePoint.plusScaled(termY.negate(), terminatorHalfHeight);\n\n // Helper function to add fill parameters\n const addFillParams = () => {\n params.fillDisplay = FillDisplay.Always;\n result = result && builder.appendGeometryParamsChange(params);\n };\n\n // Helper function to create geometry entry\n const addGeometry = (content: CurvePrimitive, useLoop = false) => {\n const finalContent = useLoop ? Loop.create(content) : content;\n result = result && builder.appendGeometryQuery(finalContent);\n };\n\n switch (textStyleSettings.leader.terminatorShape) {\n case \"openArrow\": {\n const lineString = LineString3d.create([point1, point, point2]);\n addGeometry(lineString);\n break;\n }\n\n case \"closedArrow\": {\n const lineString = LineString3d.create([point1, point, point2, point1]);\n addGeometry(lineString);\n break;\n }\n\n case \"closedArrowFilled\": {\n addFillParams();\n const lineString = LineString3d.create([point1, point, point2, point1]);\n addGeometry(lineString, true);\n break;\n }\n\n case \"circle\": {\n const circle = Arc3d.createXY(point, terminatorHalfHeight);\n addGeometry(circle);\n break;\n }\n\n case \"circleFilled\": {\n addFillParams();\n const circle = Arc3d.createXY(point, terminatorHalfHeight);\n addGeometry(circle, true);\n break;\n }\n\n case \"slash\": {\n const normalizedVector = dir.normalize();\n if (!normalizedVector) throw new Error(\"Invalid reference vector for slash terminator.\");\n\n const rotatedVector = normalizedVector.rotateXY(Angle.createDegrees(45));\n const startPoint = point.plusScaled(rotatedVector, -terminatorHalfHeight);\n const endPoint = point.plusScaled(rotatedVector, terminatorHalfHeight);\n\n const slashLine = LineSegment3d.create(startPoint, endPoint);\n addGeometry(slashLine);\n break;\n }\n }\n\n return result;\n};\n\n\n/**\n * Computes the direction vector for an \"elbow\" for leader based on the attachment point and a frame curve.\n * The elbow direction is determined by whether the attachment point is closer to the left or right side of the frame.\n * If the computed elbow would be tangent to the frame at the intersection, no elbow direction is returned.\n *\n * @param attachmentPoint - The point where the leader attaches.\n * @param frameCurve - The frame curve (either a Loop or Path) to which the leader is attached.\n * @param elbowLength - The length of the elbow segment to be created.\n * @returns The direction vector for the elbow, or `undefined` if the elbow would be tangent to the frame.\n * @beta\n */\nexport function computeElbowDirection(attachmentPoint: Point3d, frameCurve: Loop | Path, elbowLength: number): Vector3d | undefined {\n\n let elbowDirection: Vector3d | undefined;\n // Determine the direction based on the closest point's position relative to the frame\n const isCloserToLeft = Math.abs(attachmentPoint.x - frameCurve.range().low.x) < Math.abs(attachmentPoint.x - frameCurve.range().high.x);\n\n // Decide the direction: left (-X) or right (+X)\n elbowDirection = isCloserToLeft ? Vector3d.unitX().negate() : Vector3d.unitX();\n\n // Verify if the elbow is a tangent to the frame, if yes, do not create an elbow\n const elbowPoint = attachmentPoint.plusScaled(elbowDirection, elbowLength);\n const elbowLine = LineSegment3d.create(attachmentPoint, elbowPoint);\n // Find intersection points between the elbow and the frame\n const intersections = CurveCurve.intersectionXYZPairs(elbowLine, false, frameCurve, false);\n // As the elbow will intersect the frame only at one point, we can safely use the first intersection\n const intersection = intersections[0];\n const curveFraction = intersection.detailB.fraction;\n const derivative = intersection.detailB.curve?.fractionToPointAndDerivative(curveFraction);\n const tangent = derivative?.direction.normalize();\n const lineDirection = Vector3d.createStartEnd(elbowLine.point0Ref, elbowLine.point1Ref).normalize();\n if (tangent && lineDirection) {\n const dot = tangent.dotProduct(lineDirection);\n // If the tangent and line direction are aligned (dot product close to 1 or -1), it's tangent\n if (Math.abs(dot) > 0.999) {\n elbowDirection = undefined;\n }\n }\n return elbowDirection;\n}\n\n/**\n * Computes the attachment point for a leader line on a text annotation frame.\n *\n * The attachment point is determined based on the leader's attachment mode:\n * - `\"Nearest\"`: Finds the closest point on the frame curve to the leader's start point.\n * - `\"KeyPoint\"`: Uses a specific curve segment and fraction along that segment to determine the point.\n * - `\"TextPoint\"`: Calculates a point on the text layout (top/bottom, left/right) and projects it onto the frame curve.\n *\n * @param leader - The leader props.\n * @param frameCurve - The curve (Loop or Path) representing the annotation frame.\n * @param textLayout - The layout information for the text block.\n * @param transform - The transform applied to the text layout.\n * @returns The computed attachment point as a `Point3d`, or `undefined` if it cannot be determined.\n * @beta\n */\nexport function computeLeaderAttachmentPoint(\n leader: TextAnnotationLeader,\n frameCurve: Loop | Path,\n textLayout: TextBlockLayout,\n transform: Transform\n): Point3d | undefined {\n let attachmentPoint: Point3d | undefined;\n\n if (leader.attachment.mode === \"Nearest\") {\n attachmentPoint = frameCurve.closestPoint(leader.startPoint)?.point;\n } else if (leader.attachment.mode === \"KeyPoint\") {\n const curves = frameCurve.collectCurvePrimitives(undefined, false, true);\n const curveIndex = leader.attachment.curveIndex;\n const fraction = leader.attachment.fraction;\n if (curveIndex >= curves.length) {\n // If the curveIndex is invalid, use the last curve\n // This is a fallback to avoid out-of-bounds access\n attachmentPoint = curves[curves.length - 1].fractionToPoint(fraction);\n } else {\n attachmentPoint = curves[curveIndex].fractionToPoint(fraction);\n }\n } else { // attachment.mode=\"TextPoint\"\n let scaleDirection = transform.matrix.getColumn(0).negate(); // direction to draw a scaled line from text attachment point to find intersection point on frame\n let lineIndex: number;\n if (leader.attachment.position.includes(\"Top\")) {\n lineIndex = 0\n } else {\n lineIndex = textLayout.lines.length - 1\n }\n const lineRange = textLayout.lines[lineIndex].range;\n const lineOffset = textLayout.lines[lineIndex].offsetFromDocument;\n const origin = transform.multiplyPoint3d(Point3d.fromJSON(lineOffset));\n let attachmentPointOnText = origin.plusScaled(transform.matrix.getColumn(1), ((lineRange.yLength()) / 2));\n\n if (leader.attachment.position.includes(\"Right\")) {\n attachmentPointOnText = attachmentPointOnText.plusScaled(transform.matrix.getColumn(0), lineRange.xLength());\n scaleDirection = scaleDirection.negate();\n }\n // Find the nearest intersection point on the frame to get the correct attachment point\n // Extend the direction vector to create a target point far along the direction\n const targetPoint = attachmentPointOnText.plusScaled(scaleDirection, 1e6); // Scale the direction vector to a large value\n const intersectionLine = LineSegment3d.create(attachmentPointOnText, targetPoint);\n const closestPointDetail = CurveCurve.intersectionXYZPairs(intersectionLine, false, frameCurve, false);\n attachmentPoint = closestPointDetail[0]?.detailA.point;\n }\n return attachmentPoint;\n}"]}
|
|
@@ -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,E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AiB,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAKjG;;;;;;OAMG;WACW,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,mBAAmB,GAAG,mBAAmB;IAWvF;;;OAGG;IACa,MAAM,IAAI,wBAAwB;IAOlD,oFAAoF;WACtE,QAAQ,CAAC,KAAK,EAAE,wBAAwB,EAAE,MAAM,EAAE,QAAQ,GAAG,mBAAmB;IAI9F;;;;OAIG;qBACuB,QAAQ,CAAC,GAAG,EAAE,iBAAiB,GAAG,IAAI;IAKhE;;;;OAIG;qBACuB,QAAQ,CAAC,GAAG,EAAE,iBAAiB,GAAG,IAAI;IAKhE,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAU/B;;;;OAIG;IACH,0BAAmC,mBAAmB,EAAE,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;qBA+B5F,QAAQ,CAAC,OAAO,EAAE,yBAAyB,EAAE,QAAQ,EAAE,wBAAwB,EAAE,QAAQ,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;CAkBpK"}
|
|
@@ -448,12 +448,11 @@ exports.TEXT_STYLE_SETTINGS_JSON_VERSION = "1.0.1";
|
|
|
448
448
|
function migrateTextStyleSettings(oldData) {
|
|
449
449
|
if (oldData.version === exports.TEXT_STYLE_SETTINGS_JSON_VERSION)
|
|
450
450
|
return oldData.data;
|
|
451
|
-
|
|
452
|
-
|
|
451
|
+
// Migrate from 1.0.0 to 1.0.1
|
|
452
|
+
if (oldData.data.leader && !oldData.data.leader.terminatorShape) {
|
|
453
|
+
oldData.data.leader.terminatorShape = core_common_1.TextStyleSettings.defaultProps.leader.terminatorShape;
|
|
453
454
|
}
|
|
454
455
|
return oldData.data;
|
|
455
|
-
// Only if something goes wrong, throw an error.
|
|
456
|
-
// throw new Error(`Migration for settings from version ${oldData.version} to ${TEXT_STYLE_SETTINGS_JSON_VERSION} failed.`);
|
|
457
456
|
}
|
|
458
457
|
/**
|
|
459
458
|
* The definition element that holds text style information.
|