@itwin/core-backend 5.4.0-dev.2 → 5.4.0-dev.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/lib/cjs/Element.d.ts +29 -1
  2. package/lib/cjs/Element.d.ts.map +1 -1
  3. package/lib/cjs/Element.js +53 -1
  4. package/lib/cjs/Element.js.map +1 -1
  5. package/lib/cjs/ElementAspect.d.ts +24 -1
  6. package/lib/cjs/ElementAspect.d.ts.map +1 -1
  7. package/lib/cjs/ElementAspect.js +102 -1
  8. package/lib/cjs/ElementAspect.js.map +1 -1
  9. package/lib/cjs/IModelDb.d.ts +11 -0
  10. package/lib/cjs/IModelDb.d.ts.map +1 -1
  11. package/lib/cjs/IModelDb.js +18 -0
  12. package/lib/cjs/IModelDb.js.map +1 -1
  13. package/lib/cjs/NavigationRelationship.d.ts +15 -0
  14. package/lib/cjs/NavigationRelationship.d.ts.map +1 -1
  15. package/lib/cjs/NavigationRelationship.js +22 -1
  16. package/lib/cjs/NavigationRelationship.js.map +1 -1
  17. package/lib/cjs/annotations/LeaderGeometry.d.ts +13 -1
  18. package/lib/cjs/annotations/LeaderGeometry.d.ts.map +1 -1
  19. package/lib/cjs/annotations/LeaderGeometry.js +90 -10
  20. package/lib/cjs/annotations/LeaderGeometry.js.map +1 -1
  21. package/lib/cjs/annotations/TextAnnotationElement.d.ts +1 -1
  22. package/lib/cjs/annotations/TextAnnotationElement.d.ts.map +1 -1
  23. package/lib/cjs/annotations/TextAnnotationElement.js +8 -3
  24. package/lib/cjs/annotations/TextAnnotationElement.js.map +1 -1
  25. package/lib/esm/Element.d.ts +29 -1
  26. package/lib/esm/Element.d.ts.map +1 -1
  27. package/lib/esm/Element.js +53 -2
  28. package/lib/esm/Element.js.map +1 -1
  29. package/lib/esm/ElementAspect.d.ts +24 -1
  30. package/lib/esm/ElementAspect.d.ts.map +1 -1
  31. package/lib/esm/ElementAspect.js +101 -1
  32. package/lib/esm/ElementAspect.js.map +1 -1
  33. package/lib/esm/IModelDb.d.ts +11 -0
  34. package/lib/esm/IModelDb.d.ts.map +1 -1
  35. package/lib/esm/IModelDb.js +18 -0
  36. package/lib/esm/IModelDb.js.map +1 -1
  37. package/lib/esm/NavigationRelationship.d.ts +15 -0
  38. package/lib/esm/NavigationRelationship.d.ts.map +1 -1
  39. package/lib/esm/NavigationRelationship.js +19 -0
  40. package/lib/esm/NavigationRelationship.js.map +1 -1
  41. package/lib/esm/annotations/LeaderGeometry.d.ts +13 -1
  42. package/lib/esm/annotations/LeaderGeometry.d.ts.map +1 -1
  43. package/lib/esm/annotations/LeaderGeometry.js +91 -12
  44. package/lib/esm/annotations/LeaderGeometry.js.map +1 -1
  45. package/lib/esm/annotations/TextAnnotationElement.d.ts +1 -1
  46. package/lib/esm/annotations/TextAnnotationElement.d.ts.map +1 -1
  47. package/lib/esm/annotations/TextAnnotationElement.js +8 -3
  48. package/lib/esm/annotations/TextAnnotationElement.js.map +1 -1
  49. package/lib/esm/test/annotations/LeaderGeometry.test.js +48 -2
  50. package/lib/esm/test/annotations/LeaderGeometry.test.js.map +1 -1
  51. package/lib/esm/test/annotations/TextAnnotation.test.js +2 -2
  52. package/lib/esm/test/annotations/TextAnnotation.test.js.map +1 -1
  53. package/lib/esm/test/element/ProjectInformationRecord.test.d.ts +2 -0
  54. package/lib/esm/test/element/ProjectInformationRecord.test.d.ts.map +1 -0
  55. package/lib/esm/test/element/ProjectInformationRecord.test.js +80 -0
  56. package/lib/esm/test/element/ProjectInformationRecord.test.js.map +1 -0
  57. package/lib/esm/test/element/SheetInformationAspect.test.d.ts +2 -0
  58. package/lib/esm/test/element/SheetInformationAspect.test.d.ts.map +1 -0
  59. package/lib/esm/test/element/SheetInformationAspect.test.js +182 -0
  60. package/lib/esm/test/element/SheetInformationAspect.test.js.map +1 -0
  61. package/lib/esm/test/imodel/IModel.test.js +32 -2
  62. package/lib/esm/test/imodel/IModel.test.js.map +1 -1
  63. package/lib/esm/test/standalone/ChangesetReader.test.js +8 -11
  64. package/lib/esm/test/standalone/ChangesetReader.test.js.map +1 -1
  65. package/package.json +14 -14
@@ -1 +1 @@
1
- {"version":3,"file":"TextAnnotationElement.js","sourceRoot":"","sources":["../../../src/annotations/TextAnnotationElement.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAA4B,WAAW,EAAE,IAAI,EAAwD,eAAe,EAAoD,WAAW,EAAoB,WAAW,EAAoC,cAAc,EAAqE,iBAAiB,EAA0B,0BAA0B,EAAiB,MAAM,oBAAoB,CAAC;AAEjc,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,OAAO,EAAE,kBAAkB,EAAqC,MAAM,YAAY,CAAC;AACpI,OAAO,EAAE,MAAM,EAAE,IAAI,EAAc,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,2BAA2B,EAAE,oCAAoC,EAAkB,MAAM,+BAA+B,CAAC;AAGlI,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC;;;EAGE;AACF,MAAM,CAAC,MAAM,4BAA4B,GAAG,OAAO,CAAC;AAEpD,SAAS,+BAA+B,CACtC,IAAY,EACZ,cAA+B,EAC/B,OAAqC;IAErC,IAAI,MAAM,CAAC;IACX,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAqB,CAAC;IAChD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAC/B,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC;QACvD,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CA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AI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC;YAC9B,OAAO;QACT,CAAC;QAED,MAAM,aAAa,GAAG,mBAAmB,CAAC,sBAAsB,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACpF,MAAM,IAAI,GAAG,iBAAiB,CAAC,QAAQ,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC;QAElE,MAAM,YAAY,GAAG,EAAE,CAAC;QACxB,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,sBAAsB,EAAE,EAAE,CAAC;YACnE,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,KAAK,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBACxF,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;QAED,MAAM,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACtG,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 Elements\n */\n\nimport { AnnotationTextStyleProps, BisCodeSpec, Code, CodeProps, CodeScopeProps, CodeSpec, ECVersionString, ElementGeometry, ElementGeometryBuilderParams, EntityReferenceSet, Placement2d, Placement2dProps, Placement3d, Placement3dProps, PlacementProps, TextAnnotation, TextAnnotation2dProps, TextAnnotation3dProps, TextAnnotationProps, TextStyleSettings, TextStyleSettingsProps, traverseTextBlockComponent, VersionedJSON } from \"@itwin/core-common\";\nimport { IModelDb } from \"../IModelDb\";\nimport { AnnotationElement2d, DefinitionElement, Drawing, GraphicalElement3d, OnElementIdArg, OnElementPropsArg } from \"../Element\";\nimport { assert, Id64, Id64String } from \"@itwin/core-bentley\";\nimport { layoutTextBlock, TextStyleResolver } from \"./TextBlockLayout\";\nimport { appendTextAnnotationGeometry } from \"./TextAnnotationGeometry\";\nimport { ElementDrivesTextAnnotation, TextAnnotationUsesTextStyleByDefault, TextBlockAndId } from \"./ElementDrivesTextAnnotation\";\nimport { IModelElementCloneContext } from \"../IModelElementCloneContext\";\nimport { CustomHandledProperty, DeserializeEntityArgs, ECSqlRow } from \"../Entity\";\nimport * as semver from \"semver\";\n\n/** The version of the JSON stored in `TextAnnotation2d/3dProps.textAnnotationData` used by the code.\n * Uses the same semantics as [ECVersion]($ecschema-metadata).\n * @internal\n*/\nexport const TEXT_ANNOTATION_JSON_VERSION = \"1.0.0\";\n\nfunction validateAndMigrateVersionedJSON<T>(\n json: string,\n currentVersion: ECVersionString,\n migrate: (old: VersionedJSON<T>) => T\n): VersionedJSON<T> | undefined {\n let parsed;\n try {\n parsed = JSON.parse(json) as VersionedJSON<T>;\n } catch {\n return undefined;\n }\n\n const version = parsed.version;\n if (typeof version !== \"string\" || !semver.valid(version))\n throw new Error(\"JSON version is missing or invalid.\");\n\n if (typeof parsed.data !== \"object\" || parsed.data === null)\n throw new Error(\"JSON data is missing or invalid.\");\n\n // Newer\n if (semver.gt(version, currentVersion))\n throw new Error(`JSON version ${parsed.version} is newer than supported version ${currentVersion}. Application update required to understand data.`);\n\n // Older\n if (semver.lt(version, currentVersion)) {\n parsed.data = migrate(parsed);\n parsed.version = currentVersion;\n }\n\n return parsed;\n}\n\nfunction migrateTextAnnotationData(oldData: VersionedJSON<TextAnnotationProps>): TextAnnotationProps {\n if (oldData.version === TEXT_ANNOTATION_JSON_VERSION) return oldData.data;\n\n // Place migration logic here.\n\n throw new Error(`Migration for textAnnotationData from version ${oldData.version} to ${TEXT_ANNOTATION_JSON_VERSION} failed.`);\n}\n\n/** Parses, validates, and potentially migrates the text annotation data from a JSON string.\n * @internal\n */\nexport function parseTextAnnotationData(json: string | undefined): VersionedJSON<TextAnnotationProps> | undefined {\n if (!json) return undefined;\n\n return validateAndMigrateVersionedJSON<TextAnnotationProps>(json, TEXT_ANNOTATION_JSON_VERSION, migrateTextAnnotationData);\n}\n\nfunction getElementGeometryBuilderParams(iModel: IModelDb, modelId: Id64String, categoryId: Id64String, _placementProps: PlacementProps, annotationProps?: TextAnnotationProps, textStyleId?: Id64String, _subCategory?: Id64String): ElementGeometryBuilderParams {\n const textBlock = TextAnnotation.fromJSON(annotationProps).textBlock;\n const textStyleResolver = new TextStyleResolver({textBlock, textStyleId: textStyleId ?? \"\", iModel});\n const layout = layoutTextBlock({ iModel, textBlock, textStyleResolver });\n const builder = new ElementGeometry.Builder();\n let scaleFactor = 1;\n const element = iModel.elements.getElement(modelId);\n if (element instanceof Drawing)\n scaleFactor = element.scaleFactor;\n appendTextAnnotationGeometry({ layout, textStyleResolver, scaleFactor, annotationProps: annotationProps ?? {}, builder, categoryId });\n\n return { entryArray: builder.entries };\n}\n\n/** Arguments supplied when creating a [[TextAnnotation2d]].\n * @beta\n */\nexport interface TextAnnotation2dCreateArgs {\n /** The category ID for the annotation. */\n category: Id64String;\n /** The model ID where the annotation will be placed. */\n model: Id64String;\n /** The placement properties for the annotation. */\n placement: Placement2dProps;\n /** The default text style ID for the annotation. */\n defaultTextStyleId?: Id64String;\n /** Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation2d`. Essentially an empty element if not provided. */\n textAnnotationProps?: TextAnnotationProps;\n /** Optional code for the element. */\n code?: CodeProps;\n}\n\n/** Arguments supplied when creating a [[TextAnnotation3d]].\n * @beta\n */\nexport interface TextAnnotation3dCreateArgs {\n /** The category ID for the annotation. */\n category: Id64String;\n /** The model ID where the annotation will be placed. */\n model: Id64String;\n /** The placement properties for the annotation. */\n placement: Placement3dProps;\n /** The default text style ID for the annotation. */\n defaultTextStyleId?: Id64String;\n /** Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation3d`. Essentially an empty element if not provided. */\n textAnnotationProps?: TextAnnotationProps;\n /** Optional code for the element. */\n code?: CodeProps;\n}\n\n/** An element that displays textual content within a 2d model.\n * The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.\n * @see [[setAnnotation]] to change the textual content.\n * @public @preview\n */\nexport class TextAnnotation2d extends AnnotationElement2d /* implements ITextAnnotation */ {\n /** @internal */\n public static override get className(): string { return \"TextAnnotation2d\"; }\n /**\n * The default [[AnnotationTextStyle]] used by the TextAnnotation2d.\n * @beta\n */\n public defaultTextStyle?: TextAnnotationUsesTextStyleByDefault;\n /** The data associated with the text annotation. */\n private _textAnnotationProps?: TextAnnotationProps;\n\n /** Extract the textual content, if present.\n * @see [[setAnnotation]] to change it.\n */\n public getAnnotation(): TextAnnotation | undefined {\n return this._textAnnotationProps ? TextAnnotation.fromJSON(this._textAnnotationProps) : undefined;\n }\n\n /** Change the textual content of the `TextAnnotation2d`.\n * @see [[getAnnotation]] to extract the current annotation.\n * @param annotation The new annotation\n */\n public setAnnotation(annotation: TextAnnotation) {\n this._textAnnotationProps = annotation.toJSON();\n }\n\n protected constructor(props: TextAnnotation2dProps, iModel: IModelDb) {\n super(props, iModel);\n if (props.defaultTextStyle) {\n this.defaultTextStyle = new TextAnnotationUsesTextStyleByDefault(props.defaultTextStyle.id);\n }\n this._textAnnotationProps = parseTextAnnotationData(props.textAnnotationData)?.data;\n }\n\n /** Creates a new instance of `TextAnnotation2d` from its JSON representation. */\n public static fromJSON(props: TextAnnotation2dProps, iModel: IModelDb): TextAnnotation2d {\n return new TextAnnotation2d(props, iModel);\n }\n\n /**\n * Converts the current `TextAnnotation2d` instance to its JSON representation.\n * It also computes the `elementGeometryBuilderParams` property used to create the GeometryStream.\n * @inheritdoc\n */\n public override toJSON(): TextAnnotation2dProps {\n const props = super.toJSON() as TextAnnotation2dProps;\n props.textAnnotationData = this._textAnnotationProps ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: this._textAnnotationProps }) : undefined;\n if (this._textAnnotationProps) {\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(this.iModel, this.model, this.category, this.placement, this._textAnnotationProps, this.defaultTextStyle ? this.defaultTextStyle.id : undefined);\n }\n\n return props;\n }\n\n /** Creates a new `TextAnnotation2d` instance with the specified properties.\n * @param iModelDb The iModel.\n * @param arg The arguments for creating the TextAnnotation2d.\n * @beta\n */\n public static create(iModelDb: IModelDb, arg: TextAnnotation2dCreateArgs): TextAnnotation2d {\n const elementProps: TextAnnotation2dProps = {\n classFullName: this.classFullName,\n textAnnotationData: arg.textAnnotationProps ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: arg.textAnnotationProps }) : undefined,\n defaultTextStyle: arg.defaultTextStyleId ? new TextAnnotationUsesTextStyleByDefault(arg.defaultTextStyleId).toJSON() : undefined,\n placement: arg.placement,\n model: arg.model,\n category: arg.category,\n code: arg.code ?? Code.createEmpty(),\n };\n return new this(elementProps, iModelDb);\n }\n\n /**\n * Updates the geometry of the TextAnnotation2d on insert and validates version.\n * @inheritdoc\n * @beta\n */\n protected static override onInsert(arg: OnElementPropsArg): void {\n super.onInsert(arg);\n this.validateVersionAndUpdateGeometry(arg);\n }\n\n /**\n * Updates the geometry of the TextAnnotation2d on update and validates version.\n * @inheritdoc\n * @beta\n */\n protected static override onUpdate(arg: OnElementPropsArg): void {\n super.onUpdate(arg);\n this.validateVersionAndUpdateGeometry(arg);\n }\n\n /**\n * Populates the `elementGeometryBuilderParams` property in the [TextAnnotation2dProps]($common).\n * Only does this if the `elementGeometryBuilderParams` is not already set and if there is actually a text annotation to produce geometry for.\n * Also, validates the version of the text annotation data and migrates it if necessary.\n * @beta\n */\n protected static validateVersionAndUpdateGeometry(arg: OnElementPropsArg): void {\n const props = arg.props as TextAnnotation2dProps;\n const textAnnotationData = parseTextAnnotationData(props.textAnnotationData);\n if (!props.elementGeometryBuilderParams && textAnnotationData) {\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(arg.iModel, props.model, props.category, props.placement ?? Placement2d.fromJSON(), textAnnotationData.data, props.defaultTextStyle?.id);\n }\n }\n\n /**\n * TextAnnotation2d custom HandledProps include 'textAnnotationData'.\n * @inheritdoc\n * @internal\n */\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"textAnnotationData\", source: \"Class\" },\n ];\n\n /**\n * TextAnnotation2d deserializes 'textAnnotationData'.\n * @inheritdoc\n * @beta\n */\n public static override deserialize(props: DeserializeEntityArgs): TextAnnotation2dProps {\n const elProps = super.deserialize(props) as TextAnnotation2dProps;\n const textAnnotationData = parseTextAnnotationData(props.row.textAnnotationData);\n if (textAnnotationData) {\n elProps.textAnnotationData = JSON.stringify(textAnnotationData);\n }\n return elProps;\n }\n\n /**\n * TextAnnotation2d serializes 'textAnnotationData'.\n * @inheritdoc\n * @beta\n */\n public static override serialize(props: TextAnnotation2dProps, iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, iModel);\n if (props.textAnnotationData !== undefined) {\n inst.textAnnotationData = props.textAnnotationData;\n }\n return inst;\n }\n\n /** @internal */\n public getTextBlocks(): Iterable<TextBlockAndId> {\n return getTextBlocks(this);\n }\n\n /** @internal */\n public updateTextBlocks(textBlocks: TextBlockAndId[]): void {\n return updateTextBlocks(this, textBlocks);\n }\n\n /** @internal */\n public static override onInserted(arg: OnElementIdArg): void {\n super.onInserted(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n\n /** @internal */\n public static override onUpdated(arg: OnElementIdArg): void {\n super.onUpdated(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\n super.collectReferenceIds(referenceIds);\n collectReferenceIds(this, referenceIds);\n }\n\n /** @internal */\n protected static override async onCloned(context: IModelElementCloneContext, srcProps: TextAnnotation2dProps, dstProps: TextAnnotation2dProps): Promise<void> {\n await super.onCloned(context, srcProps, dstProps);\n\n const srcElem = TextAnnotation2d.fromJSON(srcProps, context.sourceDb);\n ElementDrivesTextAnnotation.remapFields(srcElem, context);\n const anno = srcElem.getAnnotation();\ndstProps.textAnnotationData = anno ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: anno.toJSON() }) : undefined;\n\n return remapTextStyle(context, srcElem, dstProps);\n }\n}\n\n/** An element that displays textual content within a 3d model.\n * The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.\n * @see [[setAnnotation]] to change the textual content.\n * @public @preview\n */\nexport class TextAnnotation3d extends GraphicalElement3d /* implements ITextAnnotation */ {\n /** @internal */\n public static override get className(): string { return \"TextAnnotation3d\"; }\n /**\n * The default [[AnnotationTextStyle]] used by the TextAnnotation3d.\n * @beta\n */\n public defaultTextStyle?: TextAnnotationUsesTextStyleByDefault;\n /** The data associated with the text annotation. */\n private _textAnnotationProps?: TextAnnotationProps;\n\n /** Extract the textual content, if present.\n * @see [[setAnnotation]] to change it.\n */\n public getAnnotation(): TextAnnotation | undefined {\n return this._textAnnotationProps ? TextAnnotation.fromJSON(this._textAnnotationProps) : undefined;\n }\n\n /** Change the textual content of the `TextAnnotation3d`.\n * @see [[getAnnotation]] to extract the current annotation.\n * @param annotation The new annotation\n */\n public setAnnotation(annotation: TextAnnotation) {\n this._textAnnotationProps = annotation.toJSON();\n }\n\n protected constructor(props: TextAnnotation3dProps, iModel: IModelDb) {\n super(props, iModel);\n if (props.defaultTextStyle) {\n this.defaultTextStyle = new TextAnnotationUsesTextStyleByDefault(props.defaultTextStyle.id);\n }\n this._textAnnotationProps = parseTextAnnotationData(props.textAnnotationData)?.data;\n }\n\n /** Creates a new instance of `TextAnnotation3d` from its JSON representation. */\n public static fromJSON(props: TextAnnotation3dProps, iModel: IModelDb): TextAnnotation3d {\n return new TextAnnotation3d(props, iModel);\n }\n\n /**\n * Converts the current `TextAnnotation3d` instance to its JSON representation.\n * It also computes the `elementGeometryBuilderParams` property used to create the GeometryStream.\n * @inheritdoc\n */\n public override toJSON(): TextAnnotation3dProps {\n const props = super.toJSON() as TextAnnotation3dProps;\n props.textAnnotationData = this._textAnnotationProps ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: this._textAnnotationProps }) : undefined;\n if (this._textAnnotationProps) {\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(this.iModel, this.model, this.category, this.placement, this._textAnnotationProps, this.defaultTextStyle ? this.defaultTextStyle.id : undefined);\n }\n\n return props;\n }\n\n /** Creates a new `TextAnnotation3d` instance with the specified properties.\n * @param iModelDb The iModel.\n * @param arg The arguments for creating the TextAnnotation3d.\n * @beta\n */\n public static create(iModelDb: IModelDb, arg: TextAnnotation3dCreateArgs): TextAnnotation3d {\n const elementProps: TextAnnotation3dProps = {\n classFullName: this.classFullName,\n textAnnotationData: arg.textAnnotationProps ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: arg.textAnnotationProps }) : undefined,\n defaultTextStyle: arg.defaultTextStyleId ? new TextAnnotationUsesTextStyleByDefault(arg.defaultTextStyleId).toJSON() : undefined,\n placement: arg.placement,\n model: arg.model,\n category: arg.category,\n code: arg.code ?? Code.createEmpty(),\n };\n return new this(elementProps, iModelDb);\n }\n\n /**\n * Updates the geometry of the TextAnnotation3d on insert and validates version..\n * @inheritdoc\n * @beta\n */\n protected static override onInsert(arg: OnElementPropsArg): void {\n super.onInsert(arg);\n this.validateVersionAndUpdateGeometry(arg);\n }\n\n /**\n * Updates the geometry of the TextAnnotation3d on update and validates version..\n * @inheritdoc\n * @beta\n */\n protected static override onUpdate(arg: OnElementPropsArg): void {\n super.onUpdate(arg);\n this.validateVersionAndUpdateGeometry(arg);\n }\n\n /**\n * Populates the `elementGeometryBuilderParams` property in the [TextAnnotation3dProps]($common).\n * Only does this if the `elementGeometryBuilderParams` is not already set and if there is actually a text annotation to produce geometry for.\n * Also, validates the version of the text annotation data and migrates it if necessary.\n * @beta\n */\n protected static validateVersionAndUpdateGeometry(arg: OnElementPropsArg): void {\n const props = arg.props as TextAnnotation3dProps;\n const textAnnotationData = parseTextAnnotationData(props.textAnnotationData);\n if (!props.elementGeometryBuilderParams && textAnnotationData) {\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(arg.iModel, props.model, props.category, props.placement ?? Placement3d.fromJSON(), textAnnotationData.data, props.defaultTextStyle?.id);\n }\n }\n\n /**\n * TextAnnotation3d custom HandledProps include 'textAnnotationData'.\n * @inheritdoc\n * @internal\n */\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"textAnnotationData\", source: \"Class\" },\n ];\n\n /**\n * TextAnnotation3d deserializes 'textAnnotationData'.\n * @inheritdoc\n * @beta\n */\n public static override deserialize(props: DeserializeEntityArgs): TextAnnotation3dProps {\n const elProps = super.deserialize(props) as TextAnnotation3dProps;\n const textAnnotationData = parseTextAnnotationData(props.row.textAnnotationData);\n if (textAnnotationData) {\n elProps.textAnnotationData = JSON.stringify(textAnnotationData);\n }\n return elProps;\n }\n\n /**\n * TextAnnotation3d serializes 'textAnnotationData'.\n * @inheritdoc\n * @beta\n */\n public static override serialize(props: TextAnnotation3dProps, iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, iModel);\n if (props.textAnnotationData !== undefined) {\n inst.textAnnotationData = props.textAnnotationData;\n }\n return inst;\n }\n\n /** @internal */\n public getTextBlocks(): Iterable<TextBlockAndId> {\n return getTextBlocks(this);\n }\n\n /** @internal */\n public updateTextBlocks(textBlocks: TextBlockAndId[]): void {\n return updateTextBlocks(this, textBlocks);\n }\n\n /** @internal */\n public static override onInserted(arg: OnElementIdArg): void {\n super.onInserted(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n\n /** @internal */\n public static override onUpdated(arg: OnElementIdArg): void {\n super.onUpdated(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\n super.collectReferenceIds(referenceIds);\n collectReferenceIds(this, referenceIds);\n }\n\n /** @internal */\n protected static override async onCloned(context: IModelElementCloneContext, srcProps: TextAnnotation3dProps, dstProps: TextAnnotation3dProps): Promise<void> {\n await super.onCloned(context, srcProps, dstProps);\n\n const srcElem = TextAnnotation3d.fromJSON(srcProps, context.sourceDb);\n ElementDrivesTextAnnotation.remapFields(srcElem, context);\n const anno = srcElem.getAnnotation();\n dstProps.textAnnotationData = anno ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: anno.toJSON() }) : undefined;\n\n return remapTextStyle(context, srcElem, dstProps);\n }\n}\n\nasync function remapTextStyle(\n context: IModelElementCloneContext,\n srcElem: TextAnnotation2d | TextAnnotation3d,\n dstProps: TextAnnotation2dProps | TextAnnotation3dProps\n): Promise<void> {\n const dstStyleId = await AnnotationTextStyle.remapTextStyleId(srcElem.defaultTextStyle?.id ?? Id64.invalid, context);\n dstProps.defaultTextStyle = Id64.isValid(dstStyleId) ? new TextAnnotationUsesTextStyleByDefault(dstStyleId).toJSON() : undefined;\n}\n\nfunction collectReferenceIds(elem: TextAnnotation2d | TextAnnotation3d, referenceIds: EntityReferenceSet): void {\n const style = elem.defaultTextStyle?.id;\n if (style && Id64.isValidId64(style)) {\n referenceIds.addElement(style);\n }\n\n const block = elem.getAnnotation()?.textBlock;\n if (block) {\n for (const { child } of traverseTextBlockComponent(block)) {\n if (child.type === \"field\") {\n const hostId = child.propertyHost.elementId;\n if (Id64.isValidId64(hostId)) {\n referenceIds.addElement(hostId);\n }\n }\n }\n }\n}\n\nfunction getTextBlocks(elem: TextAnnotation2d | TextAnnotation3d): Iterable<TextBlockAndId> {\n const annotation = elem.getAnnotation();\n return annotation ? [{ textBlock: annotation.textBlock, id: undefined }] : [];\n}\n\nfunction updateTextBlocks(elem: TextAnnotation2d | TextAnnotation3d, textBlocks: TextBlockAndId[]): void {\n assert(textBlocks.length === 1);\n assert(textBlocks[0].id === undefined);\n\n const annotation = elem.getAnnotation();\n if (!annotation) {\n // We must obtain the TextBlockAndId from the element in the first place, so the only way we could end up here is if\n // somebody removed the text annotation after we called getTextBlocks. That's gotta be a mistake.\n throw new Error(\"Text annotation element has no text\");\n }\n\n annotation.textBlock = textBlocks[0].textBlock;\n\n elem.setAnnotation(annotation);\n}\n\n/** The version of the JSON stored in `AnnotationTextStyleProps.settings` used by the code.\n * Uses the same semantics as [ECVersion]($ecschema-metadata).\n * @internal\n*/\nexport const TEXT_STYLE_SETTINGS_JSON_VERSION = \"1.0.0\";\n\nfunction migrateTextStyleSettings(oldData: VersionedJSON<TextStyleSettingsProps>): TextStyleSettingsProps {\n if (oldData.version === TEXT_STYLE_SETTINGS_JSON_VERSION) return oldData.data;\n\n // Place migration logic here.\n\n throw new Error(`Migration for settings from version ${oldData.version} to ${TEXT_STYLE_SETTINGS_JSON_VERSION} failed.`);\n}\n\n/** Arguments supplied when creating an [[AnnotationTextStyle]].\n * @beta\n */\nexport interface TextStyleCreateArgs {\n /** The ID of the [[DefinitionModel]]. */\n definitionModelId: Id64String;\n /** The name to assign to the [[AnnotationTextStyle]]. */\n name: string;\n /** Optional text style settings used to create the [[AnnotationTextStyle]]. Default settings will be used if not provided. */\n settings?: TextStyleSettingsProps;\n /** Optional description for the [[AnnotationTextStyle]]. */\n description?: string;\n}\n\n/**\n * The definition element that holds text style information.\n * The style is stored as a [TextStyleSettings]($common).\n * @beta\n */\nexport class AnnotationTextStyle extends DefinitionElement {\n /** @internal */\n public static override get className(): string { return \"AnnotationTextStyle\"; }\n /**\n * Optional text describing the `AnnotationTextStyle`.\n */\n public description?: string;\n /**\n * The text style settings for the `AnnotationTextStyle`.\n * @see [[TextStyleSettings]] for more information.\n */\n public settings: TextStyleSettings;\n\n protected constructor(props: AnnotationTextStyleProps, iModel: IModelDb) {\n super(props, iModel);\n this.description = props.description;\n const settingsProps = AnnotationTextStyle.parseTextStyleSettings(props.settings);\n this.settings = TextStyleSettings.fromJSON(settingsProps?.data);\n }\n\n /**\n * Creates a Code for an `AnnotationTextStyle` given a name that is meant to be unique within the scope of the specified DefinitionModel.\n *\n * @param iModel - The IModelDb.\n * @param definitionModelId - The ID of the DefinitionModel that contains the AnnotationTextStyle and provides the scope for its name.\n * @param name - The AnnotationTextStyle name.\n * @beta\n */\n public static createCode(iModel: IModelDb, definitionModelId: CodeScopeProps, name: string): Code {\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.annotationTextStyle);\n return new Code({ spec: codeSpec.id, scope: definitionModelId, value: name });\n }\n\n /**\n * Creates a new instance of `AnnotationTextStyle` with the specified properties.\n *\n * @param iModelDb - The iModelDb.\n * @param arg - The arguments for creating the AnnotationTextStyle.\n * @beta\n */\n public static create(iModelDb: IModelDb, arg: TextStyleCreateArgs): AnnotationTextStyle {\n const props: AnnotationTextStyleProps = {\n classFullName: this.classFullName,\n model: arg.definitionModelId,\n code: this.createCode(iModelDb, arg.definitionModelId, arg.name).toJSON(),\n description: arg.description,\n settings: arg.settings ? JSON.stringify({version: TEXT_STYLE_SETTINGS_JSON_VERSION, data: arg.settings}) : undefined,\n }\n return new this(props, iModelDb);\n }\n\n /**\n * Converts the current `AnnotationTextStyle` instance to its JSON representation.\n * @inheritdoc\n */\n public override toJSON(): AnnotationTextStyleProps {\n const props = super.toJSON() as AnnotationTextStyleProps;\n props.description = this.description;\n props.settings = JSON.stringify({version: TEXT_STYLE_SETTINGS_JSON_VERSION, data: this.settings.toJSON()});\n return props;\n }\n\n /** Creates a new instance of `AnnotationTextStyle` from its JSON representation. */\n public static fromJSON(props: AnnotationTextStyleProps, iModel: IModelDb): AnnotationTextStyle {\n return new AnnotationTextStyle(props, iModel);\n }\n\n /**\n * Validates that the AnnotationTextStyle's settings are valid before insert.\n * @inheritdoc\n * @beta\n */\n protected static override onInsert(arg: OnElementPropsArg): void {\n super.onInsert(arg);\n this.validateSettings(arg.props as AnnotationTextStyleProps);\n }\n\n /**\n * Validates that the AnnotationTextStyle's settings are valid before update.\n * @inheritdoc\n * @beta\n */\n protected static override onUpdate(arg: OnElementPropsArg): void {\n super.onUpdate(arg);\n this.validateSettings(arg.props as AnnotationTextStyleProps);\n }\n\n private static validateSettings(props: AnnotationTextStyleProps): void {\n const settingProps = AnnotationTextStyle.parseTextStyleSettings(props.settings);\n if (!settingProps) return;\n const settings = TextStyleSettings.fromJSON(settingProps.data);\n const errors = settings.getValidationErrors();\n if (errors.length > 0) {\n throw new Error(`Invalid AnnotationTextStyle settings: ${errors.join(\", \")}`);\n }\n }\n\n /**\n * AnnotationTextStyle custom HandledProps include 'settings'.\n * @inheritdoc\n * @beta\n */\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"settings\", source: \"Class\" },\n ];\n\n /**\n * AnnotationTextStyle deserializes 'settings'.\n * @inheritdoc\n * @beta\n */\n public static override deserialize(props: DeserializeEntityArgs): AnnotationTextStyleProps {\n const elProps = super.deserialize(props) as AnnotationTextStyleProps;\n const settings = this.parseTextStyleSettings(props.row.settings);\n if (settings) {\n elProps.settings = JSON.stringify(settings);\n }\n return elProps;\n }\n\n /**\n * AnnotationTextStyle serializes 'settings'.\n * @inheritdoc\n * @beta\n */\n public static override serialize(props: AnnotationTextStyleProps, iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, iModel);\n if (props.settings !== undefined) {\n inst.settings = props.settings;\n }\n return inst;\n }\n\n /** Parses, validates, and potentially migrates the text style settings data from a JSON string. */\n private static parseTextStyleSettings(json: string | undefined): VersionedJSON<TextStyleSettingsProps> | undefined {\n if (!json) return undefined;\n return validateAndMigrateVersionedJSON<TextStyleSettingsProps>(json, TEXT_STYLE_SETTINGS_JSON_VERSION, migrateTextStyleSettings);\n }\n\n /** When copying an element from one iModel to another, returns the Id of the AnnotationTextStyle in the `context`'s target iModel\n * corresponding to `sourceTextStyleId`, or [Id64.invalid]($bentley) if no corresponding text style exists.\n * If a text style with the same [Code]($common) exists in the target iModel, the style Id will be remapped to refer to that style.\n * Otherwise, a copy of the style will be imported into the target iModel and its element Id returned.\n * Implementations of [[ITextAnnotation]] should invoke this function when implementing their [[Element.onCloned]] method.\n * @throws Error if an attempt to import the text style failed.\n */\n public static async remapTextStyleId(sourceTextStyleId: Id64String, context: IModelElementCloneContext): Promise<Id64String> {\n // No remapping necessary if there's no text style or we're not copying to a different iModel.\n if (!Id64.isValid(sourceTextStyleId) || !context.isBetweenIModels) {\n return sourceTextStyleId;\n }\n\n // If the style's already been remapped, we're finished.\n let dstStyleId: Id64String | undefined = context.findTargetElementId(sourceTextStyleId);\n if (Id64.isValid(dstStyleId)) {\n return dstStyleId;\n }\n\n // Look up the style. It really ought to exist.\n const srcStyle = context.sourceDb.elements.tryGetElement<AnnotationTextStyle>(sourceTextStyleId);\n if (!srcStyle) {\n return Id64.invalid;\n }\n\n // If a style with the same code exists in the target iModel, remap to that one.\n dstStyleId = context.targetDb.elements.queryElementIdByCode(srcStyle.code);\n if (undefined !== dstStyleId) {\n return dstStyleId;\n }\n\n // Copy the style into the target iModel and remap its Id.\n const dstStyleProps = await context.cloneElement(srcStyle);\n dstStyleId = context.targetDb.elements.insertElement(dstStyleProps);\n context.remapElement(sourceTextStyleId, dstStyleId);\n return dstStyleId;\n }\n\n protected static override async onCloned(context: IModelElementCloneContext, srcProps: AnnotationTextStyleProps, dstProps: AnnotationTextStyleProps): Promise<void> {\n await super.onCloned(context, srcProps, dstProps);\n if (!context.isBetweenIModels) {\n return;\n }\n\n const settingsProps = AnnotationTextStyle.parseTextStyleSettings(srcProps.settings);\n const font = TextStyleSettings.fromJSON(settingsProps?.data).font;\n\n const fontsToEmbed = [];\n for (const file of context.sourceDb.fonts.queryEmbeddedFontFiles()) {\n if (file.type === font.type && file.faces.some((face) => face.familyName === font.name)) {\n fontsToEmbed.push(file);\n }\n }\n\n await Promise.all(fontsToEmbed.map(async (file) => context.targetDb.fonts.embedFontFile({ file })));\n }\n}\n"]}
1
+ {"version":3,"file":"TextAnnotationElement.js","sourceRoot":"","sources":["../../../src/annotations/TextAnnotationElement.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAA4B,WAAW,EAAE,IAAI,EAAwD,eAAe,EAAoD,WAAW,EAAoB,WAAW,EAAoC,cAAc,EAAqE,iBAAiB,EAA0B,0BAA0B,EAAiB,MAAM,oBAAoB,CAAC;AAEjc,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,OAAO,EAAE,kBAAkB,EAAqC,MAAM,YAAY,CAAC;AACpI,OAAO,EAAE,MAAM,EAAE,IAAI,EAAc,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,2BAA2B,EAAE,oCAAoC,EAAkB,MAAM,+BAA+B,CAAC;AAGlI,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC;;;EAGE;AACF,MAAM,CAAC,MAAM,4BAA4B,GAAG,OAAO,CAAC;AAEpD,SAAS,+BAA+B,CACtC,IAAY,EACZ,cAA+B,EAC/B,OAAqC;IAErC,IAAI,MAAM,CAAC;IACX,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAqB,CAAC;IAChD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAC/B,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC;QACvD,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IAEzD,IAAI,OAAO,MAAM,CAAC,IAAI,K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U,KAAK,CAAC,QAAQ,CAAC,OAAkC,EAAE,QAAkC,EAAE,QAAkC;QACjJ,MAAM,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAClD,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC;YAC9B,OAAO;QACT,CAAC;QAED,MAAM,aAAa,GAAG,mBAAmB,CAAC,sBAAsB,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACpF,MAAM,IAAI,GAAG,iBAAiB,CAAC,QAAQ,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC;QAElE,MAAM,YAAY,GAAG,EAAE,CAAC;QACxB,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,sBAAsB,EAAE,EAAE,CAAC;YACnE,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,KAAK,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBACxF,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;QAED,MAAM,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACtG,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 Elements\n */\n\nimport { AnnotationTextStyleProps, BisCodeSpec, Code, CodeProps, CodeScopeProps, CodeSpec, ECVersionString, ElementGeometry, ElementGeometryBuilderParams, EntityReferenceSet, Placement2d, Placement2dProps, Placement3d, Placement3dProps, PlacementProps, TextAnnotation, TextAnnotation2dProps, TextAnnotation3dProps, TextAnnotationProps, TextStyleSettings, TextStyleSettingsProps, traverseTextBlockComponent, VersionedJSON } from \"@itwin/core-common\";\nimport { IModelDb } from \"../IModelDb\";\nimport { AnnotationElement2d, DefinitionElement, Drawing, GraphicalElement3d, OnElementIdArg, OnElementPropsArg } from \"../Element\";\nimport { assert, Id64, Id64String } from \"@itwin/core-bentley\";\nimport { layoutTextBlock, TextStyleResolver } from \"./TextBlockLayout\";\nimport { appendTextAnnotationGeometry } from \"./TextAnnotationGeometry\";\nimport { ElementDrivesTextAnnotation, TextAnnotationUsesTextStyleByDefault, TextBlockAndId } from \"./ElementDrivesTextAnnotation\";\nimport { IModelElementCloneContext } from \"../IModelElementCloneContext\";\nimport { CustomHandledProperty, DeserializeEntityArgs, ECSqlRow } from \"../Entity\";\nimport * as semver from \"semver\";\n\n/** The version of the JSON stored in `TextAnnotation2d/3dProps.textAnnotationData` used by the code.\n * Uses the same semantics as [ECVersion]($ecschema-metadata).\n * @internal\n*/\nexport const TEXT_ANNOTATION_JSON_VERSION = \"1.0.0\";\n\nfunction validateAndMigrateVersionedJSON<T>(\n json: string,\n currentVersion: ECVersionString,\n migrate: (old: VersionedJSON<T>) => T\n): VersionedJSON<T> | undefined {\n let parsed;\n try {\n parsed = JSON.parse(json) as VersionedJSON<T>;\n } catch {\n return undefined;\n }\n\n const version = parsed.version;\n if (typeof version !== \"string\" || !semver.valid(version))\n throw new Error(\"JSON version is missing or invalid.\");\n\n if (typeof parsed.data !== \"object\" || parsed.data === null)\n throw new Error(\"JSON data is missing or invalid.\");\n\n // Newer\n if (semver.gt(version, currentVersion))\n throw new Error(`JSON version ${parsed.version} is newer than supported version ${currentVersion}. Application update required to understand data.`);\n\n // Older\n if (semver.lt(version, currentVersion)) {\n parsed.data = migrate(parsed);\n parsed.version = currentVersion;\n }\n\n return parsed;\n}\n\nfunction migrateTextAnnotationData(oldData: VersionedJSON<TextAnnotationProps>): TextAnnotationProps {\n if (oldData.version === TEXT_ANNOTATION_JSON_VERSION) return oldData.data;\n\n // Place migration logic here.\n\n throw new Error(`Migration for textAnnotationData from version ${oldData.version} to ${TEXT_ANNOTATION_JSON_VERSION} failed.`);\n}\n\n/** Parses, validates, and potentially migrates the text annotation data from a JSON string.\n * @internal\n */\nexport function parseTextAnnotationData(json: string | undefined): VersionedJSON<TextAnnotationProps> | undefined {\n if (!json) return undefined;\n\n return validateAndMigrateVersionedJSON<TextAnnotationProps>(json, TEXT_ANNOTATION_JSON_VERSION, migrateTextAnnotationData);\n}\n\nfunction getElementGeometryBuilderParams(iModel: IModelDb, modelId: Id64String, categoryId: Id64String, _placementProps: PlacementProps, annotationProps?: TextAnnotationProps, textStyleId?: Id64String, _subCategory?: Id64String): ElementGeometryBuilderParams {\n const textBlock = TextAnnotation.fromJSON(annotationProps).textBlock;\n const textStyleResolver = new TextStyleResolver({ textBlock, textStyleId: textStyleId ?? \"\", iModel });\n const layout = layoutTextBlock({ iModel, textBlock, textStyleResolver });\n const builder = new ElementGeometry.Builder();\n let scaleFactor = 1;\n const element = iModel.elements.getElement(modelId);\n if (element instanceof Drawing)\n scaleFactor = element.scaleFactor;\n appendTextAnnotationGeometry({ layout, textStyleResolver, scaleFactor, annotationProps: annotationProps ?? {}, builder, categoryId });\n\n return { entryArray: builder.entries };\n}\n\n/** Arguments supplied when creating a [[TextAnnotation2d]].\n * @beta\n */\nexport interface TextAnnotation2dCreateArgs {\n /** The category ID for the annotation. */\n category: Id64String;\n /** The model ID where the annotation will be placed. */\n model: Id64String;\n /** The placement properties for the annotation. */\n placement: Placement2dProps;\n /** The default text style ID for the annotation. */\n defaultTextStyleId?: Id64String;\n /** Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation2d`. Essentially an empty element if not provided. */\n textAnnotationProps?: TextAnnotationProps;\n /** Optional code for the element. */\n code?: CodeProps;\n}\n\n/** Arguments supplied when creating a [[TextAnnotation3d]].\n * @beta\n */\nexport interface TextAnnotation3dCreateArgs {\n /** The category ID for the annotation. */\n category: Id64String;\n /** The model ID where the annotation will be placed. */\n model: Id64String;\n /** The placement properties for the annotation. */\n placement: Placement3dProps;\n /** The default text style ID for the annotation. */\n defaultTextStyleId?: Id64String;\n /** Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation3d`. Essentially an empty element if not provided. */\n textAnnotationProps?: TextAnnotationProps;\n /** Optional code for the element. */\n code?: CodeProps;\n}\n\n/** An element that displays textual content within a 2d model.\n * The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.\n * @see [[setAnnotation]] to change the textual content.\n * @public @preview\n */\nexport class TextAnnotation2d extends AnnotationElement2d /* implements ITextAnnotation */ {\n /** @internal */\n public static override get className(): string { return \"TextAnnotation2d\"; }\n /**\n * The default [[AnnotationTextStyle]] used by the TextAnnotation2d.\n * @beta\n */\n public defaultTextStyle?: TextAnnotationUsesTextStyleByDefault;\n /** The data associated with the text annotation. */\n private _textAnnotationProps?: TextAnnotationProps;\n\n /** Extract the textual content, if present.\n * @see [[setAnnotation]] to change it.\n */\n public getAnnotation(): TextAnnotation | undefined {\n return this._textAnnotationProps ? TextAnnotation.fromJSON(this._textAnnotationProps) : undefined;\n }\n\n /** Change the textual content of the `TextAnnotation2d`.\n * @see [[getAnnotation]] to extract the current annotation.\n * @param annotation The new annotation\n */\n public setAnnotation(annotation: TextAnnotation) {\n this._textAnnotationProps = annotation.toJSON();\n }\n\n protected constructor(props: TextAnnotation2dProps, iModel: IModelDb) {\n super(props, iModel);\n if (props.defaultTextStyle) {\n this.defaultTextStyle = new TextAnnotationUsesTextStyleByDefault(props.defaultTextStyle.id);\n }\n this._textAnnotationProps = parseTextAnnotationData(props.textAnnotationData)?.data;\n }\n\n /** Creates a new instance of `TextAnnotation2d` from its JSON representation. */\n public static fromJSON(props: TextAnnotation2dProps, iModel: IModelDb): TextAnnotation2d {\n return new TextAnnotation2d(props, iModel);\n }\n\n /**\n * Converts the current `TextAnnotation2d` instance to its JSON representation.\n * It also computes the `elementGeometryBuilderParams` property used to create the GeometryStream.\n * @inheritdoc\n */\n public override toJSON(): TextAnnotation2dProps {\n const props = super.toJSON() as TextAnnotation2dProps;\n props.textAnnotationData = this._textAnnotationProps ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: this._textAnnotationProps }) : undefined;\n if (this._textAnnotationProps) {\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(this.iModel, this.model, this.category, this.placement, this._textAnnotationProps, this.defaultTextStyle ? this.defaultTextStyle.id : undefined);\n }\n\n return props;\n }\n\n /** Creates a new `TextAnnotation2d` instance with the specified properties.\n * @param iModelDb The iModel.\n * @param arg The arguments for creating the TextAnnotation2d.\n * @beta\n */\n public static create(iModelDb: IModelDb, arg: TextAnnotation2dCreateArgs): TextAnnotation2d {\n const elementProps: TextAnnotation2dProps = {\n classFullName: this.classFullName,\n textAnnotationData: arg.textAnnotationProps ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: arg.textAnnotationProps }) : undefined,\n defaultTextStyle: arg.defaultTextStyleId ? new TextAnnotationUsesTextStyleByDefault(arg.defaultTextStyleId).toJSON() : undefined,\n placement: arg.placement,\n model: arg.model,\n category: arg.category,\n code: arg.code ?? Code.createEmpty(),\n };\n return new this(elementProps, iModelDb);\n }\n\n /**\n * Updates the geometry of the TextAnnotation2d on insert and validates version.\n * @inheritdoc\n * @beta\n */\n protected static override onInsert(arg: OnElementPropsArg): void {\n super.onInsert(arg);\n this.validateVersionAndUpdateGeometry(arg);\n }\n\n /**\n * Updates the geometry of the TextAnnotation2d on update and validates version.\n * @inheritdoc\n * @beta\n */\n protected static override onUpdate(arg: OnElementPropsArg): void {\n super.onUpdate(arg);\n this.validateVersionAndUpdateGeometry(arg);\n }\n\n /**\n * Populates the `elementGeometryBuilderParams` property in the [TextAnnotation2dProps]($common).\n * Only does this if the `elementGeometryBuilderParams` is not already set and if there is actually a text annotation to produce geometry for.\n * Also, validates the version of the text annotation data and migrates it if necessary.\n * @beta\n */\n protected static validateVersionAndUpdateGeometry(arg: OnElementPropsArg): void {\n const props = arg.props as TextAnnotation2dProps;\n const textAnnotationData = parseTextAnnotationData(props.textAnnotationData);\n if (!props.elementGeometryBuilderParams && textAnnotationData) {\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(arg.iModel, props.model, props.category, props.placement ?? Placement2d.fromJSON(), textAnnotationData.data, props.defaultTextStyle?.id);\n }\n }\n\n /**\n * TextAnnotation2d custom HandledProps include 'textAnnotationData'.\n * @inheritdoc\n * @internal\n */\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"textAnnotationData\", source: \"Class\" },\n ];\n\n /**\n * TextAnnotation2d deserializes 'textAnnotationData'.\n * @inheritdoc\n * @beta\n */\n public static override deserialize(props: DeserializeEntityArgs): TextAnnotation2dProps {\n const elProps = super.deserialize(props) as TextAnnotation2dProps;\n const textAnnotationData = parseTextAnnotationData(props.row.textAnnotationData);\n if (textAnnotationData) {\n elProps.textAnnotationData = JSON.stringify(textAnnotationData);\n }\n return elProps;\n }\n\n /**\n * TextAnnotation2d serializes 'textAnnotationData'.\n * @inheritdoc\n * @beta\n */\n public static override serialize(props: TextAnnotation2dProps, iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, iModel);\n if (props.textAnnotationData !== undefined) {\n inst.textAnnotationData = props.textAnnotationData;\n }\n return inst;\n }\n\n /** @internal */\n public getTextBlocks(): Iterable<TextBlockAndId> {\n return getTextBlocks(this);\n }\n\n /** @internal */\n public updateTextBlocks(textBlocks: TextBlockAndId[]): void {\n return updateTextBlocks(this, textBlocks);\n }\n\n /** @internal */\n public static override onInserted(arg: OnElementIdArg): void {\n super.onInserted(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n\n /** @internal */\n public static override onUpdated(arg: OnElementIdArg): void {\n super.onUpdated(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\n super.collectReferenceIds(referenceIds);\n collectReferenceIds(this, referenceIds);\n }\n\n /** @internal */\n protected static override async onCloned(context: IModelElementCloneContext, srcProps: TextAnnotation2dProps, dstProps: TextAnnotation2dProps): Promise<void> {\n await super.onCloned(context, srcProps, dstProps);\n\n const srcElem = TextAnnotation2d.fromJSON(srcProps, context.sourceDb);\n ElementDrivesTextAnnotation.remapFields(srcElem, context);\n const anno = srcElem.getAnnotation();\n dstProps.textAnnotationData = anno ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: anno.toJSON() }) : undefined;\n\n return remapTextStyle(context, srcElem, dstProps);\n }\n}\n\n/** An element that displays textual content within a 3d model.\n * The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.\n * @see [[setAnnotation]] to change the textual content.\n * @public @preview\n */\nexport class TextAnnotation3d extends GraphicalElement3d /* implements ITextAnnotation */ {\n /** @internal */\n public static override get className(): string { return \"TextAnnotation3d\"; }\n /**\n * The default [[AnnotationTextStyle]] used by the TextAnnotation3d.\n * @beta\n */\n public defaultTextStyle?: TextAnnotationUsesTextStyleByDefault;\n /** The data associated with the text annotation. */\n private _textAnnotationProps?: TextAnnotationProps;\n\n /** Extract the textual content, if present.\n * @see [[setAnnotation]] to change it.\n */\n public getAnnotation(): TextAnnotation | undefined {\n return this._textAnnotationProps ? TextAnnotation.fromJSON(this._textAnnotationProps) : undefined;\n }\n\n /** Change the textual content of the `TextAnnotation3d`.\n * @see [[getAnnotation]] to extract the current annotation.\n * @param annotation The new annotation\n */\n public setAnnotation(annotation: TextAnnotation) {\n this._textAnnotationProps = annotation.toJSON();\n }\n\n protected constructor(props: TextAnnotation3dProps, iModel: IModelDb) {\n super(props, iModel);\n if (props.defaultTextStyle) {\n this.defaultTextStyle = new TextAnnotationUsesTextStyleByDefault(props.defaultTextStyle.id);\n }\n this._textAnnotationProps = parseTextAnnotationData(props.textAnnotationData)?.data;\n }\n\n /** Creates a new instance of `TextAnnotation3d` from its JSON representation. */\n public static fromJSON(props: TextAnnotation3dProps, iModel: IModelDb): TextAnnotation3d {\n return new TextAnnotation3d(props, iModel);\n }\n\n /**\n * Converts the current `TextAnnotation3d` instance to its JSON representation.\n * It also computes the `elementGeometryBuilderParams` property used to create the GeometryStream.\n * @inheritdoc\n */\n public override toJSON(): TextAnnotation3dProps {\n const props = super.toJSON() as TextAnnotation3dProps;\n props.textAnnotationData = this._textAnnotationProps ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: this._textAnnotationProps }) : undefined;\n if (this._textAnnotationProps) {\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(this.iModel, this.model, this.category, this.placement, this._textAnnotationProps, this.defaultTextStyle ? this.defaultTextStyle.id : undefined);\n }\n\n return props;\n }\n\n /** Creates a new `TextAnnotation3d` instance with the specified properties.\n * @param iModelDb The iModel.\n * @param arg The arguments for creating the TextAnnotation3d.\n * @beta\n */\n public static create(iModelDb: IModelDb, arg: TextAnnotation3dCreateArgs): TextAnnotation3d {\n const elementProps: TextAnnotation3dProps = {\n classFullName: this.classFullName,\n textAnnotationData: arg.textAnnotationProps ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: arg.textAnnotationProps }) : undefined,\n defaultTextStyle: arg.defaultTextStyleId ? new TextAnnotationUsesTextStyleByDefault(arg.defaultTextStyleId).toJSON() : undefined,\n placement: arg.placement,\n model: arg.model,\n category: arg.category,\n code: arg.code ?? Code.createEmpty(),\n };\n return new this(elementProps, iModelDb);\n }\n\n /**\n * Updates the geometry of the TextAnnotation3d on insert and validates version..\n * @inheritdoc\n * @beta\n */\n protected static override onInsert(arg: OnElementPropsArg): void {\n super.onInsert(arg);\n this.validateVersionAndUpdateGeometry(arg);\n }\n\n /**\n * Updates the geometry of the TextAnnotation3d on update and validates version..\n * @inheritdoc\n * @beta\n */\n protected static override onUpdate(arg: OnElementPropsArg): void {\n super.onUpdate(arg);\n this.validateVersionAndUpdateGeometry(arg);\n }\n\n /**\n * Populates the `elementGeometryBuilderParams` property in the [TextAnnotation3dProps]($common).\n * Only does this if the `elementGeometryBuilderParams` is not already set and if there is actually a text annotation to produce geometry for.\n * Also, validates the version of the text annotation data and migrates it if necessary.\n * @beta\n */\n protected static validateVersionAndUpdateGeometry(arg: OnElementPropsArg): void {\n const props = arg.props as TextAnnotation3dProps;\n const textAnnotationData = parseTextAnnotationData(props.textAnnotationData);\n if (!props.elementGeometryBuilderParams && textAnnotationData) {\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(arg.iModel, props.model, props.category, props.placement ?? Placement3d.fromJSON(), textAnnotationData.data, props.defaultTextStyle?.id);\n }\n }\n\n /**\n * TextAnnotation3d custom HandledProps include 'textAnnotationData'.\n * @inheritdoc\n * @internal\n */\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"textAnnotationData\", source: \"Class\" },\n ];\n\n /**\n * TextAnnotation3d deserializes 'textAnnotationData'.\n * @inheritdoc\n * @beta\n */\n public static override deserialize(props: DeserializeEntityArgs): TextAnnotation3dProps {\n const elProps = super.deserialize(props) as TextAnnotation3dProps;\n const textAnnotationData = parseTextAnnotationData(props.row.textAnnotationData);\n if (textAnnotationData) {\n elProps.textAnnotationData = JSON.stringify(textAnnotationData);\n }\n return elProps;\n }\n\n /**\n * TextAnnotation3d serializes 'textAnnotationData'.\n * @inheritdoc\n * @beta\n */\n public static override serialize(props: TextAnnotation3dProps, iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, iModel);\n if (props.textAnnotationData !== undefined) {\n inst.textAnnotationData = props.textAnnotationData;\n }\n return inst;\n }\n\n /** @internal */\n public getTextBlocks(): Iterable<TextBlockAndId> {\n return getTextBlocks(this);\n }\n\n /** @internal */\n public updateTextBlocks(textBlocks: TextBlockAndId[]): void {\n return updateTextBlocks(this, textBlocks);\n }\n\n /** @internal */\n public static override onInserted(arg: OnElementIdArg): void {\n super.onInserted(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n\n /** @internal */\n public static override onUpdated(arg: OnElementIdArg): void {\n super.onUpdated(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\n super.collectReferenceIds(referenceIds);\n collectReferenceIds(this, referenceIds);\n }\n\n /** @internal */\n protected static override async onCloned(context: IModelElementCloneContext, srcProps: TextAnnotation3dProps, dstProps: TextAnnotation3dProps): Promise<void> {\n await super.onCloned(context, srcProps, dstProps);\n\n const srcElem = TextAnnotation3d.fromJSON(srcProps, context.sourceDb);\n ElementDrivesTextAnnotation.remapFields(srcElem, context);\n const anno = srcElem.getAnnotation();\n dstProps.textAnnotationData = anno ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: anno.toJSON() }) : undefined;\n\n return remapTextStyle(context, srcElem, dstProps);\n }\n}\n\nasync function remapTextStyle(\n context: IModelElementCloneContext,\n srcElem: TextAnnotation2d | TextAnnotation3d,\n dstProps: TextAnnotation2dProps | TextAnnotation3dProps\n): Promise<void> {\n const dstStyleId = await AnnotationTextStyle.remapTextStyleId(srcElem.defaultTextStyle?.id ?? Id64.invalid, context);\n dstProps.defaultTextStyle = Id64.isValid(dstStyleId) ? new TextAnnotationUsesTextStyleByDefault(dstStyleId).toJSON() : undefined;\n}\n\nfunction collectReferenceIds(elem: TextAnnotation2d | TextAnnotation3d, referenceIds: EntityReferenceSet): void {\n const style = elem.defaultTextStyle?.id;\n if (style && Id64.isValidId64(style)) {\n referenceIds.addElement(style);\n }\n\n const block = elem.getAnnotation()?.textBlock;\n if (block) {\n for (const { child } of traverseTextBlockComponent(block)) {\n if (child.type === \"field\") {\n const hostId = child.propertyHost.elementId;\n if (Id64.isValidId64(hostId)) {\n referenceIds.addElement(hostId);\n }\n }\n }\n }\n}\n\nfunction getTextBlocks(elem: TextAnnotation2d | TextAnnotation3d): Iterable<TextBlockAndId> {\n const annotation = elem.getAnnotation();\n return annotation ? [{ textBlock: annotation.textBlock, id: undefined }] : [];\n}\n\nfunction updateTextBlocks(elem: TextAnnotation2d | TextAnnotation3d, textBlocks: TextBlockAndId[]): void {\n assert(textBlocks.length === 1);\n assert(textBlocks[0].id === undefined);\n\n const annotation = elem.getAnnotation();\n if (!annotation) {\n // We must obtain the TextBlockAndId from the element in the first place, so the only way we could end up here is if\n // somebody removed the text annotation after we called getTextBlocks. That's gotta be a mistake.\n throw new Error(\"Text annotation element has no text\");\n }\n\n annotation.textBlock = textBlocks[0].textBlock;\n\n elem.setAnnotation(annotation);\n}\n\n/** The version of the JSON stored in `AnnotationTextStyleProps.settings` used by the code.\n * Uses the same semantics as [ECVersion]($ecschema-metadata).\n * @internal\n*/\n// 1.0.1 - Added terminatorShapes for leaders\nexport const TEXT_STYLE_SETTINGS_JSON_VERSION = \"1.0.1\";\n\nfunction migrateTextStyleSettings(oldData: VersionedJSON<TextStyleSettingsProps>): TextStyleSettingsProps {\n if (oldData.version === TEXT_STYLE_SETTINGS_JSON_VERSION) return oldData.data;\n\n if (oldData.data.leader) {\n oldData.data.leader.terminatorShape = oldData.data.leader.terminatorShape ?? TextStyleSettings.defaultProps.leader.terminatorShape;\n }\n return oldData.data;\n\n // Only if something goes wrong, throw an error.\n // throw new Error(`Migration for settings from version ${oldData.version} to ${TEXT_STYLE_SETTINGS_JSON_VERSION} failed.`);\n}\n\n/** Arguments supplied when creating an [[AnnotationTextStyle]].\n * @beta\n */\nexport interface TextStyleCreateArgs {\n /** The ID of the [[DefinitionModel]]. */\n definitionModelId: Id64String;\n /** The name to assign to the [[AnnotationTextStyle]]. */\n name: string;\n /** Optional text style settings used to create the [[AnnotationTextStyle]]. Default settings will be used if not provided. */\n settings?: TextStyleSettingsProps;\n /** Optional description for the [[AnnotationTextStyle]]. */\n description?: string;\n}\n\n/**\n * The definition element that holds text style information.\n * The style is stored as a [TextStyleSettings]($common).\n * @beta\n */\nexport class AnnotationTextStyle extends DefinitionElement {\n /** @internal */\n public static override get className(): string { return \"AnnotationTextStyle\"; }\n /**\n * Optional text describing the `AnnotationTextStyle`.\n */\n public description?: string;\n /**\n * The text style settings for the `AnnotationTextStyle`.\n * @see [[TextStyleSettings]] for more information.\n */\n public settings: TextStyleSettings;\n\n protected constructor(props: AnnotationTextStyleProps, iModel: IModelDb) {\n super(props, iModel);\n this.description = props.description;\n const settingsProps = AnnotationTextStyle.parseTextStyleSettings(props.settings);\n this.settings = TextStyleSettings.fromJSON(settingsProps?.data);\n }\n\n /**\n * Creates a Code for an `AnnotationTextStyle` given a name that is meant to be unique within the scope of the specified DefinitionModel.\n *\n * @param iModel - The IModelDb.\n * @param definitionModelId - The ID of the DefinitionModel that contains the AnnotationTextStyle and provides the scope for its name.\n * @param name - The AnnotationTextStyle name.\n * @beta\n */\n public static createCode(iModel: IModelDb, definitionModelId: CodeScopeProps, name: string): Code {\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.annotationTextStyle);\n return new Code({ spec: codeSpec.id, scope: definitionModelId, value: name });\n }\n\n /**\n * Creates a new instance of `AnnotationTextStyle` with the specified properties.\n *\n * @param iModelDb - The iModelDb.\n * @param arg - The arguments for creating the AnnotationTextStyle.\n * @beta\n */\n public static create(iModelDb: IModelDb, arg: TextStyleCreateArgs): AnnotationTextStyle {\n const props: AnnotationTextStyleProps = {\n classFullName: this.classFullName,\n model: arg.definitionModelId,\n code: this.createCode(iModelDb, arg.definitionModelId, arg.name).toJSON(),\n description: arg.description,\n settings: arg.settings ? JSON.stringify({ version: TEXT_STYLE_SETTINGS_JSON_VERSION, data: arg.settings }) : undefined,\n }\n return new this(props, iModelDb);\n }\n\n /**\n * Converts the current `AnnotationTextStyle` instance to its JSON representation.\n * @inheritdoc\n */\n public override toJSON(): AnnotationTextStyleProps {\n const props = super.toJSON() as AnnotationTextStyleProps;\n props.description = this.description;\n props.settings = JSON.stringify({ version: TEXT_STYLE_SETTINGS_JSON_VERSION, data: this.settings.toJSON() });\n return props;\n }\n\n /** Creates a new instance of `AnnotationTextStyle` from its JSON representation. */\n public static fromJSON(props: AnnotationTextStyleProps, iModel: IModelDb): AnnotationTextStyle {\n return new AnnotationTextStyle(props, iModel);\n }\n\n /**\n * Validates that the AnnotationTextStyle's settings are valid before insert.\n * @inheritdoc\n * @beta\n */\n protected static override onInsert(arg: OnElementPropsArg): void {\n super.onInsert(arg);\n this.validateSettings(arg.props as AnnotationTextStyleProps);\n }\n\n /**\n * Validates that the AnnotationTextStyle's settings are valid before update.\n * @inheritdoc\n * @beta\n */\n protected static override onUpdate(arg: OnElementPropsArg): void {\n super.onUpdate(arg);\n this.validateSettings(arg.props as AnnotationTextStyleProps);\n }\n\n private static validateSettings(props: AnnotationTextStyleProps): void {\n const settingProps = AnnotationTextStyle.parseTextStyleSettings(props.settings);\n if (!settingProps) return;\n const settings = TextStyleSettings.fromJSON(settingProps.data);\n const errors = settings.getValidationErrors();\n if (errors.length > 0) {\n throw new Error(`Invalid AnnotationTextStyle settings: ${errors.join(\", \")}`);\n }\n }\n\n /**\n * AnnotationTextStyle custom HandledProps include 'settings'.\n * @inheritdoc\n * @beta\n */\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"settings\", source: \"Class\" },\n ];\n\n /**\n * AnnotationTextStyle deserializes 'settings'.\n * @inheritdoc\n * @beta\n */\n public static override deserialize(props: DeserializeEntityArgs): AnnotationTextStyleProps {\n const elProps = super.deserialize(props) as AnnotationTextStyleProps;\n const settings = this.parseTextStyleSettings(props.row.settings);\n if (settings) {\n elProps.settings = JSON.stringify(settings);\n }\n return elProps;\n }\n\n /**\n * AnnotationTextStyle serializes 'settings'.\n * @inheritdoc\n * @beta\n */\n public static override serialize(props: AnnotationTextStyleProps, iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, iModel);\n if (props.settings !== undefined) {\n inst.settings = props.settings;\n }\n return inst;\n }\n\n /** Parses, validates, and potentially migrates the text style settings data from a JSON string. */\n private static parseTextStyleSettings(json: string | undefined): VersionedJSON<TextStyleSettingsProps> | undefined {\n if (!json) return undefined;\n return validateAndMigrateVersionedJSON<TextStyleSettingsProps>(json, TEXT_STYLE_SETTINGS_JSON_VERSION, migrateTextStyleSettings);\n }\n\n /** When copying an element from one iModel to another, returns the Id of the AnnotationTextStyle in the `context`'s target iModel\n * corresponding to `sourceTextStyleId`, or [Id64.invalid]($bentley) if no corresponding text style exists.\n * If a text style with the same [Code]($common) exists in the target iModel, the style Id will be remapped to refer to that style.\n * Otherwise, a copy of the style will be imported into the target iModel and its element Id returned.\n * Implementations of [[ITextAnnotation]] should invoke this function when implementing their [[Element.onCloned]] method.\n * @throws Error if an attempt to import the text style failed.\n */\n public static async remapTextStyleId(sourceTextStyleId: Id64String, context: IModelElementCloneContext): Promise<Id64String> {\n // No remapping necessary if there's no text style or we're not copying to a different iModel.\n if (!Id64.isValid(sourceTextStyleId) || !context.isBetweenIModels) {\n return sourceTextStyleId;\n }\n\n // If the style's already been remapped, we're finished.\n let dstStyleId: Id64String | undefined = context.findTargetElementId(sourceTextStyleId);\n if (Id64.isValid(dstStyleId)) {\n return dstStyleId;\n }\n\n // Look up the style. It really ought to exist.\n const srcStyle = context.sourceDb.elements.tryGetElement<AnnotationTextStyle>(sourceTextStyleId);\n if (!srcStyle) {\n return Id64.invalid;\n }\n\n // If a style with the same code exists in the target iModel, remap to that one.\n dstStyleId = context.targetDb.elements.queryElementIdByCode(srcStyle.code);\n if (undefined !== dstStyleId) {\n return dstStyleId;\n }\n\n // Copy the style into the target iModel and remap its Id.\n const dstStyleProps = await context.cloneElement(srcStyle);\n dstStyleId = context.targetDb.elements.insertElement(dstStyleProps);\n context.remapElement(sourceTextStyleId, dstStyleId);\n return dstStyleId;\n }\n\n protected static override async onCloned(context: IModelElementCloneContext, srcProps: AnnotationTextStyleProps, dstProps: AnnotationTextStyleProps): Promise<void> {\n await super.onCloned(context, srcProps, dstProps);\n if (!context.isBetweenIModels) {\n return;\n }\n\n const settingsProps = AnnotationTextStyle.parseTextStyleSettings(srcProps.settings);\n const font = TextStyleSettings.fromJSON(settingsProps?.data).font;\n\n const fontsToEmbed = [];\n for (const file of context.sourceDb.fonts.queryEmbeddedFontFiles()) {\n if (file.type === font.type && file.faces.some((face) => face.familyName === font.name)) {\n fontsToEmbed.push(file);\n }\n }\n\n await Promise.all(fontsToEmbed.map(async (file) => context.targetDb.fonts.embedFontFile({ file })));\n }\n}\n"]}
@@ -3,7 +3,7 @@
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  import { expect } from "chai";
6
- import { ColorDef, GeometryParams, LineBreakRun, TextAnnotation, TextBlock, TextRun, TextStyleSettings } from "@itwin/core-common";
6
+ import { ColorDef, GeometryParams, LineBreakRun, terminatorShapes, TextAnnotation, TextBlock, TextRun, TextStyleSettings } from "@itwin/core-common";
7
7
  import { LineSegment3d, LineString3d, Point3d, Range2d, YawPitchRollAngles } from "@itwin/core-geometry";
8
8
  import { appendLeadersToBuilder, computeElbowDirection, computeFrame, computeLeaderAttachmentPoint, TextStyleResolver } from "../../core-backend";
9
9
  import { Id64 } from "@itwin/core-bentley";
@@ -142,6 +142,7 @@ describe("LeaderGeometry", () => {
142
142
  wantElbow: true,
143
143
  elbowLength: 5,
144
144
  color: ColorDef.red.toJSON(),
145
+ terminatorShape: terminatorShapes[0],
145
146
  terminatorHeightFactor: 2,
146
147
  terminatorWidthFactor: 2,
147
148
  }
@@ -163,7 +164,7 @@ describe("LeaderGeometry", () => {
163
164
  const terminatorWidth = (leaders[0].styleOverrides?.leader?.terminatorWidthFactor ?? 1) * textHeight;
164
165
  const terminatorHeight = (leaders[0].styleOverrides?.leader?.terminatorHeightFactor ?? 1) * textHeight;
165
166
  // terminator length is calculated based on the terminator width and height factors.
166
- const expectedTerminatorLength = Math.sqrt(terminatorWidth * terminatorWidth + terminatorHeight * terminatorHeight);
167
+ const expectedTerminatorLength = Math.sqrt(terminatorWidth * terminatorWidth + ((terminatorHeight / 2) * (terminatorHeight / 2)));
167
168
  expect(terminatorLength).to.be.closeTo(expectedTerminatorLength, 0.01);
168
169
  });
169
170
  it("should apply elbow length overrides", () => {
@@ -175,6 +176,51 @@ describe("LeaderGeometry", () => {
175
176
  const elbowLength = elbowLine.curveLength();
176
177
  expect(elbowLength).to.be.closeTo(leaders[0].styleOverrides?.leader?.elbowLength ?? 1, 0.01);
177
178
  });
179
+ it("should apply terminator shape overrides", () => {
180
+ const textHeight = 1;
181
+ const terminatorHeight = (leaders[0].styleOverrides?.leader?.terminatorHeightFactor ?? 1) * textHeight;
182
+ const terminatorWidth = (leaders[0].styleOverrides?.leader?.terminatorWidthFactor ?? 1) * textHeight;
183
+ let firstLeaderLineLengthBeforeTruncation;
184
+ terminatorShapes.forEach((shape) => {
185
+ it(`Terminator shape: ${shape}`, () => {
186
+ leaders[0].styleOverrides = { ...leaders[0].styleOverrides, leader: { terminatorShape: shape } };
187
+ const result = appendLeadersToBuilder(builder, leaders, layout, transform, defaultParams, textStyleResolver, scaleFactor);
188
+ expect(result).to.be.true;
189
+ if (shape === "none") {
190
+ expect(builder.geometries.length).to.equal(1); // Only leader line should be present with no terminators
191
+ }
192
+ else {
193
+ let terminatorGeometry = builder.geometries[1];
194
+ if (shape.includes("Filled")) {
195
+ expect(builder.geometries.length).to.equal(3); // One entry for geometry query and another for geometryParams for fill
196
+ terminatorGeometry = builder.geometries[2];
197
+ }
198
+ if (shape.includes("circle")) {
199
+ // expect(terminatorGeometry).to.be.instanceOf(Arc3d);
200
+ expect(terminatorGeometry.circularRadius()).to.equal(terminatorHeight / 2);
201
+ }
202
+ if (shape === "slash") {
203
+ expect(terminatorGeometry).to.be.instanceOf(LineSegment3d);
204
+ terminatorGeometry = terminatorGeometry;
205
+ expect(terminatorGeometry.curveLength()).to.equal(terminatorHeight);
206
+ }
207
+ if (shape === "closedArrow") {
208
+ // The leaderLine is truncated to accommodate the closed and hollow shape of the terminator
209
+ const leaderLine = builder.geometries[0];
210
+ const firstLeaderLine = LineSegment3d.create(leaderLine.points[0], leaderLine.points[1]);
211
+ const firstLeaderLineLength = firstLeaderLine.curveLength();
212
+ expect(firstLeaderLineLength).to.be.closeTo(firstLeaderLineLengthBeforeTruncation - terminatorWidth, 0.01);
213
+ }
214
+ else {
215
+ // keep record of first leader line length before truncation for closedArrow test
216
+ const leaderLine = builder.geometries[0];
217
+ const firstLeaderLineBeforeTruncation = LineSegment3d.create(leaderLine.points[0], leaderLine.points[1]);
218
+ firstLeaderLineLengthBeforeTruncation = firstLeaderLineBeforeTruncation.curveLength();
219
+ }
220
+ }
221
+ });
222
+ });
223
+ });
178
224
  });
179
225
  });
180
226
  describe("computeElbowDirection", () => {
@@ -1 +1 @@
1
- {"version":3,"file":"LeaderGeometry.test.js","sourceRoot":"","sources":["../../../../src/test/annotations/LeaderGeometry.test.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,YAAY,EAAE,cAAc,EAAwB,SAAS,EAAuB,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC9K,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACzG,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,YAAY,EAAE,4BAA4B,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAClJ,OAAO,EAAE,IAAI,EAAc,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE/D,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,IAAI,OAAoB,CAAC;IAC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MAAM,eAAe,GAAG,4BAA4B,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;YAChG,MAAM,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;YACjC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;YAC1B,MAAM,OAAO,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;YACjD,MAAM,CAAC,eAAgB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,oDAAoD;QAC9G,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAA;AAEJ,CAAC,CAAC,CAAA","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\nimport { expect } from \"chai\";\nimport { ColorDef, GeometryParams, LineBreakRun, TextAnnotation, TextAnnotationLeader, TextBlock, TextFrameStyleProps, TextRun, TextStyleSettings } from \"@itwin/core-common\";\nimport { LineSegment3d, LineString3d, Point3d, Range2d, YawPitchRollAngles } from \"@itwin/core-geometry\";\nimport { appendLeadersToBuilder, computeElbowDirection, computeFrame, computeLeaderAttachmentPoint, TextStyleResolver } from \"../../core-backend\";\nimport { Id64, Id64String } from \"@itwin/core-bentley\";\nimport { doLayout, MockBuilder } from \"../AnnotationTestUtils\";\n\ndescribe(\"LeaderGeometry\", () => {\n let builder: MockBuilder;\n let defaultParams: GeometryParams;\n\n const textBlock = TextBlock.create({ styleOverrides: { font: { name: \"Arial\" }, color: ColorDef.black.toJSON(), leader: {wantElbow: false} } });\n textBlock.appendRun(TextRun.create({ content: \"Hello\", styleOverrides: { font: { name: \"Arial\" } } }));\n textBlock.appendRun(LineBreakRun.create({\n styleOverrides: { font: { name: \"Arial\" } },\n }));\n textBlock.appendRun(TextRun.create({ content: \"World\", styleOverrides: { font: { name: \"Arial\" } } }));\n\n const frame: TextFrameStyleProps = { borderWeight: 1, shape: \"rectangle\" };\n\n const annotation = TextAnnotation.fromJSON({\n textBlock: textBlock.toJSON(),\n anchor: { horizontal: \"left\", vertical: \"top\" },\n orientation: YawPitchRollAngles.createDegrees(0, 0, 0).toJSON(),\n offset: { x: 0, y: 0 },\n });\n\n const findTextStyle = (id: Id64String) => TextStyleSettings.fromJSON(id === \"0x34\" ? { lineSpacingFactor: 12, font: { name: \"block\" }, frame } : { lineSpacingFactor: 99, font: { name: \"run\" }, frame });\n const textStyleResolver = new TextStyleResolver({\n textBlock,\n textStyleId: \"0x34\",\n iModel: {} as any,\n findTextStyle,\n });\n const layout = doLayout(textBlock, {\n textStyleId: \"0x34\",\n findTextStyle,\n findFontId: () => 0,\n });\n const scaleFactor = 1;\n\n\n const range = Range2d.fromJSON(layout.range);\n const transform = annotation.computeTransform(range);\n const frameCurve = computeFrame({ frame: frame.shape === \"none\" ? \"rectangle\" : (frame.shape ?? \"rectangle\"), range: layout.range, transform });\n\n beforeEach(() => {\n builder = new MockBuilder();\n defaultParams = new GeometryParams(Id64.invalid);\n });\n\n describe(\"appendLeaderToBuilder\", () => {\n it(\"should append a leader to the builder\", () => {\n const leaders: TextAnnotationLeader[] = [\n {\n startPoint: Point3d.create(10, 0, 0),\n attachment: { mode: \"Nearest\" }\n }\n ]\n const result = appendLeadersToBuilder(builder, leaders, layout, transform, defaultParams, textStyleResolver, scaleFactor);\n expect(result).to.be.true;\n const params = builder.params[builder.params.length - 1];\n expect(builder.params.length).to.be.equal(1);\n expect(params.lineColor).to.be.equal(ColorDef.black); // textBlock color\n expect(builder.geometries.length).to.be.equal(2); // One LineString3d for leadersLines and one for terminators\n for (const geometryEntry of builder.geometries) {\n expect(geometryEntry).to.be.instanceOf(LineString3d);\n }\n });\n\n it(\"should append multiple leaders to the builder\", () => {\n const leaders: TextAnnotationLeader[] = [{ startPoint: Point3d.create(20, 20, 0), attachment: { mode: \"Nearest\" } },\n { startPoint: Point3d.create(10, 0, 0), attachment: { mode: \"Nearest\" } }];\n const result = appendLeadersToBuilder(builder, leaders, layout, transform, defaultParams, textStyleResolver, scaleFactor);\n expect(result).to.be.true;\n expect(builder.params.length).to.be.equal(2); // One for each leader\n expect(builder.geometries.length).to.be.equal(4); // Two LineString3d for leadersSegments and two for terminators\n for (const geometryEntry of builder.geometries) {\n expect(geometryEntry).to.be.instanceOf(LineString3d);\n }\n });\n\n it(\"should have intermediate points in geometry\", () => {\n const leaders: TextAnnotationLeader[] = [\n {\n startPoint: Point3d.create(10, 0, 0),\n attachment: { mode: \"Nearest\" },\n intermediatePoints: [Point3d.create(15, 15, 0), Point3d.create(20, 20, 0)]\n }\n ];\n const result = appendLeadersToBuilder(builder, leaders, layout, transform, defaultParams, textStyleResolver, scaleFactor);\n expect(result).to.be.true;\n const geometries = builder.geometries;\n const leaderLines = geometries[0] as LineString3d;\n expect(leaderLines.points.length).to.be.equal(4); // start + 2 intermediate + end\n });\n\n it(\"should have elbow in the geometry\", () => {\n const leaders: TextAnnotationLeader[] = [\n {\n startPoint: Point3d.create(10, 0, 0),\n attachment: { mode: \"TextPoint\", position: \"TopLeft\" },\n styleOverrides: {\n leader: {\n wantElbow: true,\n elbowLength: 5\n }\n }\n }\n ];\n const result = appendLeadersToBuilder(builder, leaders, layout, transform, defaultParams, textStyleResolver, scaleFactor);\n expect(result).to.be.true;\n const geometries = builder.geometries;\n const leaderLines = geometries[0] as LineString3d;\n expect(leaderLines.points.length).to.be.equal(3); // start + elbowPoint + end\n });\n\n describe(\"should return correct geometry for different attachment modes\", () => {\n const leaders: TextAnnotationLeader[] = [{\n startPoint: Point3d.create(10, 0, 0),\n attachment: { mode: \"TextPoint\", position: \"TopLeft\" }\n }, {\n startPoint: Point3d.create(20, 20, 0),\n attachment: { mode: \"KeyPoint\", curveIndex: 0, fraction: 0.5 }\n }, {\n startPoint: Point3d.create(30, 30, 0),\n attachment: { mode: \"Nearest\" }\n }]\n\n for (const leader of leaders) {\n builder = new MockBuilder();\n it(`${leader.attachment.mode}`, () => {\n const attachmentPoint = computeLeaderAttachmentPoint(leader, frameCurve, layout, transform);\n if (!attachmentPoint) {\n expect.fail(\"Attachment point should not be undefined\");\n }\n const result = appendLeadersToBuilder(builder, [leader], layout, transform, defaultParams, textStyleResolver, scaleFactor);\n expect(result).to.be.true;\n const leaderLines = builder.geometries[0] as LineString3d;\n // The last point in the geometry is the point on frame where leader is supposed to be attached.\n expect(leaderLines.points[leaderLines.points.length - 1].isAlmostEqual(attachmentPoint)).to.be.true;\n })\n }\n })\n describe(\"should return correct geometry for different styleOverrides\", () => {\n const leaders: TextAnnotationLeader[] = [\n {\n startPoint: Point3d.create(10, 0, 0),\n attachment: { mode: \"TextPoint\", position: \"TopLeft\" },\n styleOverrides: {\n leader: {\n wantElbow: true,\n elbowLength: 5,\n color: ColorDef.red.toJSON(),\n terminatorHeightFactor: 2,\n terminatorWidthFactor: 2,\n }\n }\n }\n ];\n\n it(\"should apply color overrides\", () => {\n const result = appendLeadersToBuilder(builder, leaders, layout, transform, defaultParams, textStyleResolver, scaleFactor);\n expect(result).to.be.true;\n const params = builder.params[builder.params.length - 1];\n expect(params.lineColor).to.equal(ColorDef.red);\n });\n\n it(\"should apply terminator size overrides\", () => {\n const result = appendLeadersToBuilder(builder, leaders, layout, transform, defaultParams, textStyleResolver, scaleFactor);\n expect(result).to.be.true;\n const terminatorLines = builder.geometries[1] as LineString3d;\n const terminatorLength = LineSegment3d.create(terminatorLines.points[0], terminatorLines.points[1]).curveLength();\n const textHeight = 1;\n const terminatorWidth = (leaders[0].styleOverrides?.leader?.terminatorWidthFactor ?? 1) * textHeight;\n const terminatorHeight = (leaders[0].styleOverrides?.leader?.terminatorHeightFactor ?? 1) * textHeight;\n // terminator length is calculated based on the terminator width and height factors.\n const expectedTerminatorLength = Math.sqrt(terminatorWidth * terminatorWidth + terminatorHeight * terminatorHeight);\n expect(terminatorLength).to.be.closeTo(expectedTerminatorLength, 0.01);\n });\n\n it(\"should apply elbow length overrides\", () => {\n const result = appendLeadersToBuilder(builder, leaders, layout, transform, defaultParams, textStyleResolver, scaleFactor);\n expect(result).to.be.true;\n const leaderLines = builder.geometries[0] as LineString3d;\n // When elbow exists, the last two points in the leaderLines should form the elbow\n const elbowLine = LineSegment3d.create(leaderLines.points[leaderLines.points.length - 1], leaderLines.points[leaderLines.points.length - 2]);\n const elbowLength = elbowLine.curveLength();\n expect(elbowLength).to.be.closeTo(leaders[0].styleOverrides?.leader?.elbowLength ?? 1, 0.01);\n });\n });\n });\n\n describe(\"computeElbowDirection\", () => {\n it(\"should return elbow direction\", () => {\n const leaders: TextAnnotationLeader[] = [\n {\n startPoint: Point3d.create(10, 0, 0),\n attachment: { mode: \"TextPoint\", position: \"TopLeft\" },\n styleOverrides: {\n leader: {\n wantElbow: true,\n elbowLength: 5\n }\n }\n }\n ];\n\n const attachmentPoint = computeLeaderAttachmentPoint(leaders[0], frameCurve, layout, transform);\n if (attachmentPoint) {\n const elbowDirection = computeElbowDirection(attachmentPoint, frameCurve,\n leaders[0].styleOverrides?.leader?.elbowLength ?? 1);\n expect(elbowDirection).to.exist;\n }\n });\n\n it(\"should return undefined if elbow is tangential\", () => {\n const leaders: TextAnnotationLeader[] = [\n {\n startPoint: Point3d.create(10, 0, 0),\n attachment: { mode: \"Nearest\" },\n styleOverrides: {\n leader: {\n wantElbow: true,\n elbowLength: 5\n }\n }\n }\n ];\n\n const attachmentPoint = computeLeaderAttachmentPoint(leaders[0], frameCurve, layout, transform);\n if (attachmentPoint) {\n const elbowDirection = computeElbowDirection(attachmentPoint, frameCurve,\n leaders[0].styleOverrides?.leader?.elbowLength ?? 1);\n expect(elbowDirection).to.be.undefined;\n }\n });\n })\n\n describe(\"computeLeaderAttachmentPoint\", () => {\n it(\"should return correct attachmentPoint for 'Nearest' mode\", () => {\n const leaders: TextAnnotationLeader[] = [\n {\n startPoint: Point3d.create(-20, 0, 0),\n attachment: { mode: \"Nearest\" }\n }\n ];\n const attachmentPoint = computeLeaderAttachmentPoint(leaders[0], frameCurve, layout, transform);\n expect(attachmentPoint).to.exist;\n expect(attachmentPoint!.isAlmostEqual(Point3d.create(0, 0, 0))).to.be.true;\n });\n\n it(\"should return correct attachmentPoint for 'Keypoint' mode\", () => {\n const leaders: TextAnnotationLeader[] = [\n {\n startPoint: Point3d.create(-20, 0, 0),\n attachment: { mode: \"KeyPoint\", curveIndex: 0, fraction: 0 }\n }\n ];\n const attachmentPoint = computeLeaderAttachmentPoint(leaders[0], frameCurve, layout, transform);\n expect(attachmentPoint).to.exist;\n expect(attachmentPoint?.y).to.be.equal(range.low.y); // expected to be at the bottom of the TextBlock\n });\n\n it(\"should return correct attachmentPoint for 'TextPoint' mode\", () => {\n const leaders: TextAnnotationLeader[] = [\n {\n startPoint: Point3d.create(-20, 0, 0),\n attachment: { mode: \"TextPoint\", position: \"TopLeft\" }\n }\n ];\n const attachmentPoint = computeLeaderAttachmentPoint(leaders[0], frameCurve, layout, transform);\n expect(attachmentPoint).to.exist;\n const topY = range.high.y;\n const middleY = (range.low.y + range.high.y) / 2;\n expect(attachmentPoint!.y).to.be.within(middleY, topY); // expected to be in the upper half of the TextBlock\n });\n })\n\n})\n"]}
1
+ {"version":3,"file":"LeaderGeometry.test.js","sourceRoot":"","sources":["../../../../src/test/annotations/LeaderGeometry.test.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,YAAY,EAAmB,gBAAgB,EAAE,cAAc,EAAwB,SAAS,EAAuB,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACjN,OAAO,EAAS,aAAa,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,EA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J,CAAC,CAAC,CAAA","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\nimport { expect } from \"chai\";\nimport { ColorDef, GeometryParams, LineBreakRun, TerminatorShape, terminatorShapes, TextAnnotation, TextAnnotationLeader, TextBlock, TextFrameStyleProps, TextRun, TextStyleSettings } from \"@itwin/core-common\";\nimport { Arc3d, LineSegment3d, LineString3d, Point3d, Range2d, YawPitchRollAngles } from \"@itwin/core-geometry\";\nimport { appendLeadersToBuilder, computeElbowDirection, computeFrame, computeLeaderAttachmentPoint, TextStyleResolver } from \"../../core-backend\";\nimport { Id64, Id64String } from \"@itwin/core-bentley\";\nimport { doLayout, MockBuilder } from \"../AnnotationTestUtils\";\n\ndescribe(\"LeaderGeometry\", () => {\n let builder: MockBuilder;\n let defaultParams: GeometryParams;\n\n const textBlock = TextBlock.create({ styleOverrides: { font: { name: \"Arial\" }, color: ColorDef.black.toJSON(), leader: { wantElbow: false } } });\n textBlock.appendRun(TextRun.create({ content: \"Hello\", styleOverrides: { font: { name: \"Arial\" } } }));\n textBlock.appendRun(LineBreakRun.create({\n styleOverrides: { font: { name: \"Arial\" } },\n }));\n textBlock.appendRun(TextRun.create({ content: \"World\", styleOverrides: { font: { name: \"Arial\" } } }));\n\n const frame: TextFrameStyleProps = { borderWeight: 1, shape: \"rectangle\" };\n\n const annotation = TextAnnotation.fromJSON({\n textBlock: textBlock.toJSON(),\n anchor: { horizontal: \"left\", vertical: \"top\" },\n orientation: YawPitchRollAngles.createDegrees(0, 0, 0).toJSON(),\n offset: { x: 0, y: 0 },\n });\n\n const findTextStyle = (id: Id64String) => TextStyleSettings.fromJSON(id === \"0x34\" ? { lineSpacingFactor: 12, font: { name: \"block\" }, frame } : { lineSpacingFactor: 99, font: { name: \"run\" }, frame });\n const textStyleResolver = new TextStyleResolver({\n textBlock,\n textStyleId: \"0x34\",\n iModel: {} as any,\n findTextStyle,\n });\n const layout = doLayout(textBlock, {\n textStyleId: \"0x34\",\n findTextStyle,\n findFontId: () => 0,\n });\n const scaleFactor = 1;\n\n\n const range = Range2d.fromJSON(layout.range);\n const transform = annotation.computeTransform(range);\n const frameCurve = computeFrame({ frame: frame.shape === \"none\" ? \"rectangle\" : (frame.shape ?? \"rectangle\"), range: layout.range, transform });\n\n beforeEach(() => {\n builder = new MockBuilder();\n defaultParams = new GeometryParams(Id64.invalid);\n });\n\n describe(\"appendLeaderToBuilder\", () => {\n it(\"should append a leader to the builder\", () => {\n const leaders: TextAnnotationLeader[] = [\n {\n startPoint: Point3d.create(10, 0, 0),\n attachment: { mode: \"Nearest\" }\n }\n ]\n const result = appendLeadersToBuilder(builder, leaders, layout, transform, defaultParams, textStyleResolver, scaleFactor);\n expect(result).to.be.true;\n const params = builder.params[builder.params.length - 1];\n expect(builder.params.length).to.be.equal(1);\n expect(params.lineColor).to.be.equal(ColorDef.black); // textBlock color\n expect(builder.geometries.length).to.be.equal(2); // One LineString3d for leadersLines and one for terminators\n for (const geometryEntry of builder.geometries) {\n expect(geometryEntry).to.be.instanceOf(LineString3d);\n }\n });\n\n it(\"should append multiple leaders to the builder\", () => {\n const leaders: TextAnnotationLeader[] = [{ startPoint: Point3d.create(20, 20, 0), attachment: { mode: \"Nearest\" } },\n { startPoint: Point3d.create(10, 0, 0), attachment: { mode: \"Nearest\" } }];\n const result = appendLeadersToBuilder(builder, leaders, layout, transform, defaultParams, textStyleResolver, scaleFactor);\n expect(result).to.be.true;\n expect(builder.params.length).to.be.equal(2); // One for each leader\n expect(builder.geometries.length).to.be.equal(4); // Two LineString3d for leadersSegments and two for terminators\n for (const geometryEntry of builder.geometries) {\n expect(geometryEntry).to.be.instanceOf(LineString3d);\n }\n });\n\n it(\"should have intermediate points in geometry\", () => {\n const leaders: TextAnnotationLeader[] = [\n {\n startPoint: Point3d.create(10, 0, 0),\n attachment: { mode: \"Nearest\" },\n intermediatePoints: [Point3d.create(15, 15, 0), Point3d.create(20, 20, 0)]\n }\n ];\n const result = appendLeadersToBuilder(builder, leaders, layout, transform, defaultParams, textStyleResolver, scaleFactor);\n expect(result).to.be.true;\n const geometries = builder.geometries;\n const leaderLines = geometries[0] as LineString3d;\n expect(leaderLines.points.length).to.be.equal(4); // start + 2 intermediate + end\n });\n\n it(\"should have elbow in the geometry\", () => {\n const leaders: TextAnnotationLeader[] = [\n {\n startPoint: Point3d.create(10, 0, 0),\n attachment: { mode: \"TextPoint\", position: \"TopLeft\" },\n styleOverrides: {\n leader: {\n wantElbow: true,\n elbowLength: 5\n }\n }\n }\n ];\n const result = appendLeadersToBuilder(builder, leaders, layout, transform, defaultParams, textStyleResolver, scaleFactor);\n expect(result).to.be.true;\n const geometries = builder.geometries;\n const leaderLines = geometries[0] as LineString3d;\n expect(leaderLines.points.length).to.be.equal(3); // start + elbowPoint + end\n });\n\n describe(\"should return correct geometry for different attachment modes\", () => {\n const leaders: TextAnnotationLeader[] = [{\n startPoint: Point3d.create(10, 0, 0),\n attachment: { mode: \"TextPoint\", position: \"TopLeft\" }\n }, {\n startPoint: Point3d.create(20, 20, 0),\n attachment: { mode: \"KeyPoint\", curveIndex: 0, fraction: 0.5 }\n }, {\n startPoint: Point3d.create(30, 30, 0),\n attachment: { mode: \"Nearest\" }\n }]\n\n for (const leader of leaders) {\n builder = new MockBuilder();\n it(`${leader.attachment.mode}`, () => {\n const attachmentPoint = computeLeaderAttachmentPoint(leader, frameCurve, layout, transform);\n if (!attachmentPoint) {\n expect.fail(\"Attachment point should not be undefined\");\n }\n const result = appendLeadersToBuilder(builder, [leader], layout, transform, defaultParams, textStyleResolver, scaleFactor);\n expect(result).to.be.true;\n const leaderLines = builder.geometries[0] as LineString3d;\n // The last point in the geometry is the point on frame where leader is supposed to be attached.\n expect(leaderLines.points[leaderLines.points.length - 1].isAlmostEqual(attachmentPoint)).to.be.true;\n })\n }\n })\n describe(\"should return correct geometry for different styleOverrides\", () => {\n const leaders: TextAnnotationLeader[] = [\n {\n startPoint: Point3d.create(10, 0, 0),\n attachment: { mode: \"TextPoint\", position: \"TopLeft\" },\n styleOverrides: {\n leader: {\n wantElbow: true,\n elbowLength: 5,\n color: ColorDef.red.toJSON(),\n terminatorShape: terminatorShapes[0],\n terminatorHeightFactor: 2,\n terminatorWidthFactor: 2,\n }\n }\n }\n ];\n\n it(\"should apply color overrides\", () => {\n const result = appendLeadersToBuilder(builder, leaders, layout, transform, defaultParams, textStyleResolver, scaleFactor);\n expect(result).to.be.true;\n const params = builder.params[builder.params.length - 1];\n expect(params.lineColor).to.equal(ColorDef.red);\n });\n\n it(\"should apply terminator size overrides\", () => {\n const result = appendLeadersToBuilder(builder, leaders, layout, transform, defaultParams, textStyleResolver, scaleFactor);\n expect(result).to.be.true;\n const terminatorLines = builder.geometries[1] as LineString3d;\n const terminatorLength = LineSegment3d.create(terminatorLines.points[0], terminatorLines.points[1]).curveLength();\n const textHeight = 1;\n const terminatorWidth = (leaders[0].styleOverrides?.leader?.terminatorWidthFactor ?? 1) * textHeight;\n const terminatorHeight = (leaders[0].styleOverrides?.leader?.terminatorHeightFactor ?? 1) * textHeight;\n // terminator length is calculated based on the terminator width and height factors.\n const expectedTerminatorLength = Math.sqrt(terminatorWidth * terminatorWidth + ((terminatorHeight / 2) * (terminatorHeight / 2)));\n expect(terminatorLength).to.be.closeTo(expectedTerminatorLength, 0.01);\n });\n\n it(\"should apply elbow length overrides\", () => {\n const result = appendLeadersToBuilder(builder, leaders, layout, transform, defaultParams, textStyleResolver, scaleFactor);\n expect(result).to.be.true;\n const leaderLines = builder.geometries[0] as LineString3d;\n // When elbow exists, the last two points in the leaderLines should form the elbow\n const elbowLine = LineSegment3d.create(leaderLines.points[leaderLines.points.length - 1], leaderLines.points[leaderLines.points.length - 2]);\n const elbowLength = elbowLine.curveLength();\n expect(elbowLength).to.be.closeTo(leaders[0].styleOverrides?.leader?.elbowLength ?? 1, 0.01);\n });\n\n it(\"should apply terminator shape overrides\", () => {\n const textHeight = 1;\n const terminatorHeight = (leaders[0].styleOverrides?.leader?.terminatorHeightFactor ?? 1) * textHeight;\n const terminatorWidth = (leaders[0].styleOverrides?.leader?.terminatorWidthFactor ?? 1) * textHeight;\n let firstLeaderLineLengthBeforeTruncation: number;\n terminatorShapes.forEach((shape: TerminatorShape) => {\n it(`Terminator shape: ${shape}`, () => {\n leaders[0].styleOverrides = { ...leaders[0].styleOverrides, leader: { terminatorShape: shape } };\n const result = appendLeadersToBuilder(builder, leaders, layout, transform, defaultParams, textStyleResolver, scaleFactor);\n expect(result).to.be.true;\n if (shape === \"none\") {\n expect(builder.geometries.length).to.equal(1); // Only leader line should be present with no terminators\n } else {\n let terminatorGeometry = builder.geometries[1];\n if (shape.includes(\"Filled\")) {\n expect(builder.geometries.length).to.equal(3) // One entry for geometry query and another for geometryParams for fill\n terminatorGeometry = builder.geometries[2];\n }\n if (shape.includes(\"circle\")) {\n // expect(terminatorGeometry).to.be.instanceOf(Arc3d);\n expect((terminatorGeometry as Arc3d).circularRadius()).to.equal(terminatorHeight / 2)\n }\n\n if (shape === \"slash\") {\n expect(terminatorGeometry).to.be.instanceOf(LineSegment3d);\n terminatorGeometry = terminatorGeometry as LineSegment3d;\n expect(terminatorGeometry.curveLength()).to.equal(terminatorHeight);\n }\n\n if (shape === \"closedArrow\") {\n // The leaderLine is truncated to accommodate the closed and hollow shape of the terminator\n const leaderLine = builder.geometries[0] as LineString3d;\n const firstLeaderLine = LineSegment3d.create(leaderLine.points[0], leaderLine.points[1]);\n const firstLeaderLineLength = firstLeaderLine.curveLength();\n expect(firstLeaderLineLength).to.be.closeTo(firstLeaderLineLengthBeforeTruncation - terminatorWidth, 0.01);\n } else {\n // keep record of first leader line length before truncation for closedArrow test\n const leaderLine = builder.geometries[0] as LineString3d;\n const firstLeaderLineBeforeTruncation = LineSegment3d.create(leaderLine.points[0], leaderLine.points[1]);\n firstLeaderLineLengthBeforeTruncation = firstLeaderLineBeforeTruncation.curveLength();\n }\n }\n\n });\n\n });\n });\n\n });\n });\n\n describe(\"computeElbowDirection\", () => {\n it(\"should return elbow direction\", () => {\n const leaders: TextAnnotationLeader[] = [\n {\n startPoint: Point3d.create(10, 0, 0),\n attachment: { mode: \"TextPoint\", position: \"TopLeft\" },\n styleOverrides: {\n leader: {\n wantElbow: true,\n elbowLength: 5\n }\n }\n }\n ];\n\n const attachmentPoint = computeLeaderAttachmentPoint(leaders[0], frameCurve, layout, transform);\n if (attachmentPoint) {\n const elbowDirection = computeElbowDirection(attachmentPoint, frameCurve,\n leaders[0].styleOverrides?.leader?.elbowLength ?? 1);\n expect(elbowDirection).to.exist;\n }\n });\n\n it(\"should return undefined if elbow is tangential\", () => {\n const leaders: TextAnnotationLeader[] = [\n {\n startPoint: Point3d.create(10, 0, 0),\n attachment: { mode: \"Nearest\" },\n styleOverrides: {\n leader: {\n wantElbow: true,\n elbowLength: 5\n }\n }\n }\n ];\n\n const attachmentPoint = computeLeaderAttachmentPoint(leaders[0], frameCurve, layout, transform);\n if (attachmentPoint) {\n const elbowDirection = computeElbowDirection(attachmentPoint, frameCurve,\n leaders[0].styleOverrides?.leader?.elbowLength ?? 1);\n expect(elbowDirection).to.be.undefined;\n }\n });\n })\n\n describe(\"computeLeaderAttachmentPoint\", () => {\n it(\"should return correct attachmentPoint for 'Nearest' mode\", () => {\n const leaders: TextAnnotationLeader[] = [\n {\n startPoint: Point3d.create(-20, 0, 0),\n attachment: { mode: \"Nearest\" }\n }\n ];\n const attachmentPoint = computeLeaderAttachmentPoint(leaders[0], frameCurve, layout, transform);\n expect(attachmentPoint).to.exist;\n expect(attachmentPoint!.isAlmostEqual(Point3d.create(0, 0, 0))).to.be.true;\n });\n\n it(\"should return correct attachmentPoint for 'Keypoint' mode\", () => {\n const leaders: TextAnnotationLeader[] = [\n {\n startPoint: Point3d.create(-20, 0, 0),\n attachment: { mode: \"KeyPoint\", curveIndex: 0, fraction: 0 }\n }\n ];\n const attachmentPoint = computeLeaderAttachmentPoint(leaders[0], frameCurve, layout, transform);\n expect(attachmentPoint).to.exist;\n expect(attachmentPoint?.y).to.be.equal(range.low.y); // expected to be at the bottom of the TextBlock\n });\n\n it(\"should return correct attachmentPoint for 'TextPoint' mode\", () => {\n const leaders: TextAnnotationLeader[] = [\n {\n startPoint: Point3d.create(-20, 0, 0),\n attachment: { mode: \"TextPoint\", position: \"TopLeft\" }\n }\n ];\n const attachmentPoint = computeLeaderAttachmentPoint(leaders[0], frameCurve, layout, transform);\n expect(attachmentPoint).to.exist;\n const topY = range.high.y;\n const middleY = (range.low.y + range.high.y) / 2;\n expect(attachmentPoint!.y).to.be.within(middleY, topY); // expected to be in the upper half of the TextBlock\n });\n })\n\n})\n"]}
@@ -787,13 +787,13 @@ describe("AnnotationTextStyle", () => {
787
787
  }),
788
788
  })).to.throw(`JSON version 999.999.999 is newer than supported version ${TEXT_STYLE_SETTINGS_JSON_VERSION}. Application update required to understand data.`);
789
789
  });
790
- it("throws if the JSON version is old and cannot be migrated", () => {
790
+ it("should not throw error if the JSON version is old", () => {
791
791
  expect(() => makeStyle({
792
792
  settings: JSON.stringify({
793
793
  version: "0.0.1",
794
794
  data: TextStyleSettings.defaultProps
795
795
  }),
796
- })).to.throw(`Migration for settings from version 0.0.1 to ${TEXT_STYLE_SETTINGS_JSON_VERSION} failed.`);
796
+ })).to.not.throw();
797
797
  });
798
798
  });
799
799
  describe("onCloned", () => {