@itwin/core-common 4.7.0-dev.3 → 4.7.0-dev.4

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.
@@ -92,12 +92,12 @@ export declare class TextAnnotation {
92
92
  * The anchor point is computed as specified by this annotation's [[anchor]] setting. For example, if the text block is anchored
93
93
  * at the bottom left, then the transform will be relative to the bottom-left corner of `textBlockExtents`.
94
94
  * The text block will be rotated around the fixed anchor point according to [[orientation]], then the anchor point will be translated by [[offset]].
95
- * @param textBlockDimensions The width and height of the bounding box containing the text block. You can compute this using [computeTextBlockExtents]($common).
95
+ * @param textBlockDimensions The width and height of the bounding box containing the text block. You can compute this using [computeTextBlockExtents]($backend).
96
96
  * @see [[computeAnchorPoint]] to compute the transform's anchor point.
97
97
  */
98
98
  computeTransform(textBlockDimensions: XAndY): Transform;
99
99
  /** Compute the anchor point of this annotation as specified by [[anchor]].
100
- * @param textBlockDimensions The width and height of the bounding box containing the [[textBlock]]. You can compute this using [computeTextBlockExtents]($common).
100
+ * @param textBlockDimensions The width and height of the bounding box containing the [[textBlock]]. You can compute this using [computeTextBlockExtents]($backend).
101
101
  * @see [[computeTransform]] to compute the transform relative to the anchor point.
102
102
  */
103
103
  computeAnchorPoint(textBlockDimensions: XAndY): Point3d;
@@ -72,7 +72,7 @@ class TextAnnotation {
72
72
  * The anchor point is computed as specified by this annotation's [[anchor]] setting. For example, if the text block is anchored
73
73
  * at the bottom left, then the transform will be relative to the bottom-left corner of `textBlockExtents`.
74
74
  * The text block will be rotated around the fixed anchor point according to [[orientation]], then the anchor point will be translated by [[offset]].
75
- * @param textBlockDimensions The width and height of the bounding box containing the text block. You can compute this using [computeTextBlockExtents]($common).
75
+ * @param textBlockDimensions The width and height of the bounding box containing the text block. You can compute this using [computeTextBlockExtents]($backend).
76
76
  * @see [[computeAnchorPoint]] to compute the transform's anchor point.
77
77
  */
78
78
  computeTransform(textBlockDimensions) {
@@ -83,7 +83,7 @@ class TextAnnotation {
83
83
  return translation.multiplyTransformTransform(rotation, rotation);
84
84
  }
85
85
  /** Compute the anchor point of this annotation as specified by [[anchor]].
86
- * @param textBlockDimensions The width and height of the bounding box containing the [[textBlock]]. You can compute this using [computeTextBlockExtents]($common).
86
+ * @param textBlockDimensions The width and height of the bounding box containing the [[textBlock]]. You can compute this using [computeTextBlockExtents]($backend).
87
87
  * @see [[computeTransform]] to compute the transform relative to the anchor point.
88
88
  */
89
89
  computeAnchorPoint(textBlockDimensions) {
@@ -1 +1 @@
1
- {"version":3,"file":"TextAnnotation.js","sourceRoot":"","sources":["../../../src/annotation/TextAnnotation.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,wDAAkH;AAClH,2CAAwD;AAwDxD;;;;;;;;;;;;GAYG;AACH,MAAa,cAAc;IAYzB,YAAoB,MAAe,EAAE,MAA0B,EAAE,SAAoB,EAAE,MAA4B;QACjH,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC;QAC1B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,oCAAoC;IAC7B,MAAM,CAAC,MAAM,CAAC,IAA+B;QAClD,MAAM,MAAM,GAAG,IAAI,EAAE,MAAM,IAAI,IAAI,uBAAO,EAAE,CAAC;QAC7C,MAAM,MAAM,GAAG,IAAI,EAAE,WAAW,IAAI,IAAI,kCAAkB,EAAE,CAAC;QAC7D,MAAM,SAAS,GAAG,IAAI,EAAE,SAAS,IAAI,qBAAS,CAAC,WAAW,EAAE,CAAC;QAC7D,MAAM,MAAM,GAAG,IAAI,EAAE,MAAM,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;QAEvE,OAAO,IAAI,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;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C,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,KAAK,KAAK,CAAC,MAAM,CAAC,UAAU,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,KAAK,KAAK,CAAC,MAAM,CAAC,QAAQ;eACtG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC;eAC5F,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAC9C,CAAC;CACF;AArHD,wCAqHC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Annotation\r\n */\r\n\r\nimport { Point3d, Transform, XAndY, XYZProps, YawPitchRollAngles, YawPitchRollProps } from \"@itwin/core-geometry\";\r\nimport { TextBlock, TextBlockProps } from \"./TextBlock\";\r\n\r\n/** Describes how to compute the \"anchor point\" for a [[TextAnnotation]].\r\n * The anchor point is a point on or inside of the 2d bounding box enclosing the contents of the annotation's [[TextBlock]].\r\n * The annotation can be rotated and translated relative to the anchor point. The anchor point also serves as the snap point\r\n * when [AccuSnap]($frontend) is set to [SnapMode.Origin]($frontend).\r\n * @see [[TextAnnotation]] for a description of how the anchor point is computed.\r\n * @beta\r\n */\r\nexport interface TextAnnotationAnchor {\r\n /**\r\n * The vertical alignment of the anchor point.\r\n * \"top\" aligns the anchor point with the top of the text's bounding box.\r\n * \"middle\" aligns the anchor point with the middle of the text's bounding box.\r\n * \"bottom\" aligns the anchor point with the bottom of the text's bounding box.\r\n */\r\n vertical: \"top\" | \"middle\" | \"bottom\";\r\n\r\n /**\r\n * The horizontal alignment of the anchor point.\r\n * \"left\" aligns the anchor point with left side of the text's bounding box.\r\n * \"center\" aligns the anchor point with center of the text with's bounding box.\r\n * \"right\" aligns the anchor point with right side of the text's bounding box.\r\n */\r\n horizontal: \"left\" | \"center\" | \"right\";\r\n}\r\n\r\n/**\r\n * JSON representation of a [[TextAnnotation]].\r\n * @beta\r\n */\r\nexport interface TextAnnotationProps {\r\n /** See [[TextAnnotation.offset]]. Default: [0, 0, 0]. */\r\n offset?: XYZProps;\r\n /** See [[TextAnnotation.orientation]]. Default: no rotation. */\r\n orientation?: YawPitchRollProps;\r\n /** See [[TextAnnotation.textBlock]]. Default: an empty text block. */\r\n textBlock?: TextBlockProps;\r\n /** See [[TextAnnotation.anchor]]. Default: top-left. */\r\n anchor?: TextAnnotationAnchor;\r\n}\r\n\r\n/** Arguments supplied to [[TextAnnotation.create]].\r\n * @beta\r\n */\r\nexport interface TextAnnotationCreateArgs {\r\n /** See [[TextAnnotation.offset]]. Default: (0, 0, 0). */\r\n offset?: Point3d;\r\n /** See [[TextAnnotation.orientation]]. Default: no rotation. */\r\n orientation?: YawPitchRollAngles;\r\n /** See [[TextAnnotation.textBlock]]. Default: an empty text block. */\r\n textBlock?: TextBlock;\r\n /** See [[TextAnnotation.anchor]]. Default: top-left. */\r\n anchor?: TextAnnotationAnchor;\r\n}\r\n\r\n/**\r\n * Represents a formatted block of text positioned in 2d or 3d space.\r\n * [TextAnnotation2d]($backend) and [TextAnnotation3d]($backend) elements store a single TextAnnotation from which their geometric representation is generated.\r\n * Other types of elements may store multiple TextAnnotations, positioned relative to one another.\r\n * The annotation's position and orientation relative to the host element's [Placement]($common) is determined as follows:\r\n * - First, the width and height of a box enclosing the contents of the [[textBlock]] must be computed using [computeTextBlockExtents]($backend). This yields a box with the top-left\r\n * corner at (0, 0) and the bottom-right corner at (width, -height).\r\n * - Then, an \"anchor point\" is computed based on the text box and the [[anchor]] property. For example, if the annotation is anchored at the center-left, the anchor point will be (width/2, -height).\r\n * - The [[orientation]] is applied to rotate the box around the anchor point.\r\n * - Finally, the [[offset]] is added to the anchor point to apply translation.\r\n * @see [produceTextAnnotationGeometry]($backend) to decompose the annotation into a set of geometric primitives suitable for use with [[GeometryStreamBuilder.appendTextBlock]].\r\n * @beta\r\n */\r\nexport class TextAnnotation {\r\n /** The rotation of the annotation.\r\n * @note When defining an annotation for a [TextAnnotation2d]($backend), only the `yaw` component (rotation around the Z axis) is used.\r\n */\r\n public orientation: YawPitchRollAngles;\r\n /** The formatted document. */\r\n public textBlock: TextBlock;\r\n /** Describes how to compute the [[textBlock]]'s anchor point. */\r\n public anchor: TextAnnotationAnchor;\r\n /** An offset applied to the anchor point that can be used to position annotations within the same geometry stream relative to one another. */\r\n public offset: Point3d;\r\n\r\n private constructor(offset: Point3d, angles: YawPitchRollAngles, textBlock: TextBlock, anchor: TextAnnotationAnchor) {\r\n this.offset = offset;\r\n this.orientation = angles;\r\n this.textBlock = textBlock;\r\n this.anchor = anchor;\r\n }\r\n\r\n /** Creates a new TextAnnotation. */\r\n public static create(args?: TextAnnotationCreateArgs): TextAnnotation {\r\n const offset = args?.offset ?? new Point3d();\r\n const angles = args?.orientation ?? new YawPitchRollAngles();\r\n const textBlock = args?.textBlock ?? TextBlock.createEmpty();\r\n const anchor = args?.anchor ?? { vertical: \"top\", horizontal: \"left\" };\r\n\r\n return new TextAnnotation(offset, angles, textBlock, anchor);\r\n }\r\n\r\n /**\r\n * Creates a new TextAnnotation instance from its JSON representation.\r\n */\r\n public static fromJSON(props: TextAnnotationProps | undefined): TextAnnotation {\r\n return TextAnnotation.create({\r\n offset: props?.offset ? Point3d.fromJSON(props.offset) : undefined,\r\n orientation: props?.orientation ? YawPitchRollAngles.fromJSON(props.orientation) : undefined,\r\n textBlock: props?.textBlock ? TextBlock.create(props.textBlock) : undefined,\r\n anchor: props?.anchor ? { ...props.anchor } : undefined,\r\n });\r\n }\r\n\r\n /**\r\n * Converts this annotation to its JSON representation.\r\n */\r\n public toJSON(): TextAnnotationProps {\r\n const props: TextAnnotationProps = {};\r\n\r\n // Even if the text block is empty, we want to record its style name and overrides, e.g.,\r\n // so the user can pick up where they left off editing it next time.\r\n props.textBlock = this.textBlock.toJSON();\r\n\r\n if (!this.offset.isZero) {\r\n props.offset = this.offset.toJSON();\r\n }\r\n\r\n if (!this.orientation.isIdentity()) {\r\n props.orientation = this.orientation.toJSON();\r\n }\r\n\r\n if (this.anchor.vertical !== \"top\" || this.anchor.horizontal !== \"left\") {\r\n props.anchor = { ...this.anchor };\r\n }\r\n\r\n return props;\r\n }\r\n\r\n /** Compute the transform that positions and orients this annotation relative to its anchor point, based on the [[textBlock]]'s computed bounding box.\r\n * The anchor point is computed as specified by this annotation's [[anchor]] setting. For example, if the text block is anchored\r\n * at the bottom left, then the transform will be relative to the bottom-left corner of `textBlockExtents`.\r\n * The text block will be rotated around the fixed anchor point according to [[orientation]], then the anchor point will be translated by [[offset]].\r\n * @param textBlockDimensions The width and height of the bounding box containing the text block. You can compute this using [computeTextBlockExtents]($common).\r\n * @see [[computeAnchorPoint]] to compute the transform's anchor point.\r\n */\r\n public computeTransform(textBlockDimensions: XAndY): Transform {\r\n const anchorPt = this.computeAnchorPoint(textBlockDimensions);\r\n const matrix = this.orientation.toMatrix3d();\r\n\r\n const rotation = Transform.createFixedPointAndMatrix(anchorPt, matrix);\r\n const translation = Transform.createTranslation(this.offset);\r\n return translation.multiplyTransformTransform(rotation, rotation);\r\n }\r\n\r\n /** Compute the anchor point of this annotation as specified by [[anchor]].\r\n * @param textBlockDimensions The width and height of the bounding box containing the [[textBlock]]. You can compute this using [computeTextBlockExtents]($common).\r\n * @see [[computeTransform]] to compute the transform relative to the anchor point.\r\n */\r\n public computeAnchorPoint(textBlockDimensions: XAndY): Point3d {\r\n let x = 0;\r\n let y = 0;\r\n\r\n switch (this.anchor.horizontal) {\r\n case \"center\":\r\n x += textBlockDimensions.x / 2;\r\n break;\r\n case \"right\":\r\n x += textBlockDimensions.x;\r\n break;\r\n }\r\n\r\n switch (this.anchor.vertical) {\r\n case \"middle\":\r\n y -= textBlockDimensions.y / 2;\r\n break;\r\n case \"bottom\":\r\n y -= textBlockDimensions.y;\r\n break;\r\n }\r\n\r\n return new Point3d(x, y, 0);\r\n }\r\n\r\n /** Returns true if this annotation is logically equivalent to `other`. */\r\n public equals(other: TextAnnotation): boolean {\r\n return this.anchor.horizontal === other.anchor.horizontal && this.anchor.vertical === other.anchor.vertical\r\n && this.orientation.isAlmostEqual(other.orientation) && this.offset.isAlmostEqual(other.offset)\r\n && this.textBlock.equals(other.textBlock);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"TextAnnotation.js","sourceRoot":"","sources":["../../../src/annotation/TextAnnotation.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,wDAAkH;AAClH,2CAAwD;AAwDxD;;;;;;;;;;;;GAYG;AACH,MAAa,cAAc;IAYzB,YAAoB,MAAe,EAAE,MAA0B,EAAE,SAAoB,EAAE,MAA4B;QACjH,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC;QAC1B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,oCAAoC;IAC7B,MAAM,CAAC,MAAM,CAAC,IAA+B;QAClD,MAAM,MAAM,GAAG,IAAI,EAAE,MAAM,IAAI,IAAI,uBAAO,EAAE,CAAC;QAC7C,MAAM,MAAM,GAAG,IAAI,EAAE,WAAW,IAAI,IAAI,kCAAkB,EAAE,CAAC;QAC7D,MAAM,SAAS,GAAG,IAAI,EAAE,SAAS,IAAI,qBAAS,CAAC,WAAW,EAAE,CAAC;QAC7D,MAAM,MAAM,GAAG,IAAI,EAAE,MAAM,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;QAEvE,OAAO,IAAI,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IAC/D,CAAC;IAED;;OAEG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M,CAAC,UAAU,KAAK,KAAK,CAAC,MAAM,CAAC,UAAU,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,KAAK,KAAK,CAAC,MAAM,CAAC,QAAQ;eACtG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC;eAC5F,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAC9C,CAAC;CACF;AArHD,wCAqHC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Annotation\r\n */\r\n\r\nimport { Point3d, Transform, XAndY, XYZProps, YawPitchRollAngles, YawPitchRollProps } from \"@itwin/core-geometry\";\r\nimport { TextBlock, TextBlockProps } from \"./TextBlock\";\r\n\r\n/** Describes how to compute the \"anchor point\" for a [[TextAnnotation]].\r\n * The anchor point is a point on or inside of the 2d bounding box enclosing the contents of the annotation's [[TextBlock]].\r\n * The annotation can be rotated and translated relative to the anchor point. The anchor point also serves as the snap point\r\n * when [AccuSnap]($frontend) is set to [SnapMode.Origin]($frontend).\r\n * @see [[TextAnnotation]] for a description of how the anchor point is computed.\r\n * @beta\r\n */\r\nexport interface TextAnnotationAnchor {\r\n /**\r\n * The vertical alignment of the anchor point.\r\n * \"top\" aligns the anchor point with the top of the text's bounding box.\r\n * \"middle\" aligns the anchor point with the middle of the text's bounding box.\r\n * \"bottom\" aligns the anchor point with the bottom of the text's bounding box.\r\n */\r\n vertical: \"top\" | \"middle\" | \"bottom\";\r\n\r\n /**\r\n * The horizontal alignment of the anchor point.\r\n * \"left\" aligns the anchor point with left side of the text's bounding box.\r\n * \"center\" aligns the anchor point with center of the text with's bounding box.\r\n * \"right\" aligns the anchor point with right side of the text's bounding box.\r\n */\r\n horizontal: \"left\" | \"center\" | \"right\";\r\n}\r\n\r\n/**\r\n * JSON representation of a [[TextAnnotation]].\r\n * @beta\r\n */\r\nexport interface TextAnnotationProps {\r\n /** See [[TextAnnotation.offset]]. Default: [0, 0, 0]. */\r\n offset?: XYZProps;\r\n /** See [[TextAnnotation.orientation]]. Default: no rotation. */\r\n orientation?: YawPitchRollProps;\r\n /** See [[TextAnnotation.textBlock]]. Default: an empty text block. */\r\n textBlock?: TextBlockProps;\r\n /** See [[TextAnnotation.anchor]]. Default: top-left. */\r\n anchor?: TextAnnotationAnchor;\r\n}\r\n\r\n/** Arguments supplied to [[TextAnnotation.create]].\r\n * @beta\r\n */\r\nexport interface TextAnnotationCreateArgs {\r\n /** See [[TextAnnotation.offset]]. Default: (0, 0, 0). */\r\n offset?: Point3d;\r\n /** See [[TextAnnotation.orientation]]. Default: no rotation. */\r\n orientation?: YawPitchRollAngles;\r\n /** See [[TextAnnotation.textBlock]]. Default: an empty text block. */\r\n textBlock?: TextBlock;\r\n /** See [[TextAnnotation.anchor]]. Default: top-left. */\r\n anchor?: TextAnnotationAnchor;\r\n}\r\n\r\n/**\r\n * Represents a formatted block of text positioned in 2d or 3d space.\r\n * [TextAnnotation2d]($backend) and [TextAnnotation3d]($backend) elements store a single TextAnnotation from which their geometric representation is generated.\r\n * Other types of elements may store multiple TextAnnotations, positioned relative to one another.\r\n * The annotation's position and orientation relative to the host element's [Placement]($common) is determined as follows:\r\n * - First, the width and height of a box enclosing the contents of the [[textBlock]] must be computed using [computeTextBlockExtents]($backend). This yields a box with the top-left\r\n * corner at (0, 0) and the bottom-right corner at (width, -height).\r\n * - Then, an \"anchor point\" is computed based on the text box and the [[anchor]] property. For example, if the annotation is anchored at the center-left, the anchor point will be (width/2, -height).\r\n * - The [[orientation]] is applied to rotate the box around the anchor point.\r\n * - Finally, the [[offset]] is added to the anchor point to apply translation.\r\n * @see [produceTextAnnotationGeometry]($backend) to decompose the annotation into a set of geometric primitives suitable for use with [[GeometryStreamBuilder.appendTextBlock]].\r\n * @beta\r\n */\r\nexport class TextAnnotation {\r\n /** The rotation of the annotation.\r\n * @note When defining an annotation for a [TextAnnotation2d]($backend), only the `yaw` component (rotation around the Z axis) is used.\r\n */\r\n public orientation: YawPitchRollAngles;\r\n /** The formatted document. */\r\n public textBlock: TextBlock;\r\n /** Describes how to compute the [[textBlock]]'s anchor point. */\r\n public anchor: TextAnnotationAnchor;\r\n /** An offset applied to the anchor point that can be used to position annotations within the same geometry stream relative to one another. */\r\n public offset: Point3d;\r\n\r\n private constructor(offset: Point3d, angles: YawPitchRollAngles, textBlock: TextBlock, anchor: TextAnnotationAnchor) {\r\n this.offset = offset;\r\n this.orientation = angles;\r\n this.textBlock = textBlock;\r\n this.anchor = anchor;\r\n }\r\n\r\n /** Creates a new TextAnnotation. */\r\n public static create(args?: TextAnnotationCreateArgs): TextAnnotation {\r\n const offset = args?.offset ?? new Point3d();\r\n const angles = args?.orientation ?? new YawPitchRollAngles();\r\n const textBlock = args?.textBlock ?? TextBlock.createEmpty();\r\n const anchor = args?.anchor ?? { vertical: \"top\", horizontal: \"left\" };\r\n\r\n return new TextAnnotation(offset, angles, textBlock, anchor);\r\n }\r\n\r\n /**\r\n * Creates a new TextAnnotation instance from its JSON representation.\r\n */\r\n public static fromJSON(props: TextAnnotationProps | undefined): TextAnnotation {\r\n return TextAnnotation.create({\r\n offset: props?.offset ? Point3d.fromJSON(props.offset) : undefined,\r\n orientation: props?.orientation ? YawPitchRollAngles.fromJSON(props.orientation) : undefined,\r\n textBlock: props?.textBlock ? TextBlock.create(props.textBlock) : undefined,\r\n anchor: props?.anchor ? { ...props.anchor } : undefined,\r\n });\r\n }\r\n\r\n /**\r\n * Converts this annotation to its JSON representation.\r\n */\r\n public toJSON(): TextAnnotationProps {\r\n const props: TextAnnotationProps = {};\r\n\r\n // Even if the text block is empty, we want to record its style name and overrides, e.g.,\r\n // so the user can pick up where they left off editing it next time.\r\n props.textBlock = this.textBlock.toJSON();\r\n\r\n if (!this.offset.isZero) {\r\n props.offset = this.offset.toJSON();\r\n }\r\n\r\n if (!this.orientation.isIdentity()) {\r\n props.orientation = this.orientation.toJSON();\r\n }\r\n\r\n if (this.anchor.vertical !== \"top\" || this.anchor.horizontal !== \"left\") {\r\n props.anchor = { ...this.anchor };\r\n }\r\n\r\n return props;\r\n }\r\n\r\n /** Compute the transform that positions and orients this annotation relative to its anchor point, based on the [[textBlock]]'s computed bounding box.\r\n * The anchor point is computed as specified by this annotation's [[anchor]] setting. For example, if the text block is anchored\r\n * at the bottom left, then the transform will be relative to the bottom-left corner of `textBlockExtents`.\r\n * The text block will be rotated around the fixed anchor point according to [[orientation]], then the anchor point will be translated by [[offset]].\r\n * @param textBlockDimensions The width and height of the bounding box containing the text block. You can compute this using [computeTextBlockExtents]($backend).\r\n * @see [[computeAnchorPoint]] to compute the transform's anchor point.\r\n */\r\n public computeTransform(textBlockDimensions: XAndY): Transform {\r\n const anchorPt = this.computeAnchorPoint(textBlockDimensions);\r\n const matrix = this.orientation.toMatrix3d();\r\n\r\n const rotation = Transform.createFixedPointAndMatrix(anchorPt, matrix);\r\n const translation = Transform.createTranslation(this.offset);\r\n return translation.multiplyTransformTransform(rotation, rotation);\r\n }\r\n\r\n /** Compute the anchor point of this annotation as specified by [[anchor]].\r\n * @param textBlockDimensions The width and height of the bounding box containing the [[textBlock]]. You can compute this using [computeTextBlockExtents]($backend).\r\n * @see [[computeTransform]] to compute the transform relative to the anchor point.\r\n */\r\n public computeAnchorPoint(textBlockDimensions: XAndY): Point3d {\r\n let x = 0;\r\n let y = 0;\r\n\r\n switch (this.anchor.horizontal) {\r\n case \"center\":\r\n x += textBlockDimensions.x / 2;\r\n break;\r\n case \"right\":\r\n x += textBlockDimensions.x;\r\n break;\r\n }\r\n\r\n switch (this.anchor.vertical) {\r\n case \"middle\":\r\n y -= textBlockDimensions.y / 2;\r\n break;\r\n case \"bottom\":\r\n y -= textBlockDimensions.y;\r\n break;\r\n }\r\n\r\n return new Point3d(x, y, 0);\r\n }\r\n\r\n /** Returns true if this annotation is logically equivalent to `other`. */\r\n public equals(other: TextAnnotation): boolean {\r\n return this.anchor.horizontal === other.anchor.horizontal && this.anchor.vertical === other.anchor.vertical\r\n && this.orientation.isAlmostEqual(other.orientation) && this.offset.isAlmostEqual(other.offset)\r\n && this.textBlock.equals(other.textBlock);\r\n }\r\n}\r\n"]}
@@ -92,12 +92,12 @@ export declare class TextAnnotation {
92
92
  * The anchor point is computed as specified by this annotation's [[anchor]] setting. For example, if the text block is anchored
93
93
  * at the bottom left, then the transform will be relative to the bottom-left corner of `textBlockExtents`.
94
94
  * The text block will be rotated around the fixed anchor point according to [[orientation]], then the anchor point will be translated by [[offset]].
95
- * @param textBlockDimensions The width and height of the bounding box containing the text block. You can compute this using [computeTextBlockExtents]($common).
95
+ * @param textBlockDimensions The width and height of the bounding box containing the text block. You can compute this using [computeTextBlockExtents]($backend).
96
96
  * @see [[computeAnchorPoint]] to compute the transform's anchor point.
97
97
  */
98
98
  computeTransform(textBlockDimensions: XAndY): Transform;
99
99
  /** Compute the anchor point of this annotation as specified by [[anchor]].
100
- * @param textBlockDimensions The width and height of the bounding box containing the [[textBlock]]. You can compute this using [computeTextBlockExtents]($common).
100
+ * @param textBlockDimensions The width and height of the bounding box containing the [[textBlock]]. You can compute this using [computeTextBlockExtents]($backend).
101
101
  * @see [[computeTransform]] to compute the transform relative to the anchor point.
102
102
  */
103
103
  computeAnchorPoint(textBlockDimensions: XAndY): Point3d;
@@ -69,7 +69,7 @@ export class TextAnnotation {
69
69
  * The anchor point is computed as specified by this annotation's [[anchor]] setting. For example, if the text block is anchored
70
70
  * at the bottom left, then the transform will be relative to the bottom-left corner of `textBlockExtents`.
71
71
  * The text block will be rotated around the fixed anchor point according to [[orientation]], then the anchor point will be translated by [[offset]].
72
- * @param textBlockDimensions The width and height of the bounding box containing the text block. You can compute this using [computeTextBlockExtents]($common).
72
+ * @param textBlockDimensions The width and height of the bounding box containing the text block. You can compute this using [computeTextBlockExtents]($backend).
73
73
  * @see [[computeAnchorPoint]] to compute the transform's anchor point.
74
74
  */
75
75
  computeTransform(textBlockDimensions) {
@@ -80,7 +80,7 @@ export class TextAnnotation {
80
80
  return translation.multiplyTransformTransform(rotation, rotation);
81
81
  }
82
82
  /** Compute the anchor point of this annotation as specified by [[anchor]].
83
- * @param textBlockDimensions The width and height of the bounding box containing the [[textBlock]]. You can compute this using [computeTextBlockExtents]($common).
83
+ * @param textBlockDimensions The width and height of the bounding box containing the [[textBlock]]. You can compute this using [computeTextBlockExtents]($backend).
84
84
  * @see [[computeTransform]] to compute the transform relative to the anchor point.
85
85
  */
86
86
  computeAnchorPoint(textBlockDimensions) {
@@ -1 +1 @@
1
- {"version":3,"file":"TextAnnotation.js","sourceRoot":"","sources":["../../../src/annotation/TextAnnotation.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,SAAS,EAAmB,kBAAkB,EAAqB,MAAM,sBAAsB,CAAC;AAClH,OAAO,EAAE,SAAS,EAAkB,MAAM,aAAa,CAAC;AAwDxD;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,cAAc;IAYzB,YAAoB,MAAe,EAAE,MAA0B,EAAE,SAAoB,EAAE,MAA4B;QACjH,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC;QAC1B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,oCAAoC;IAC7B,MAAM,CAAC,MAAM,CAAC,IAA+B;QAClD,MAAM,MAAM,GAAG,IAAI,EAAE,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;QAC7C,MAAM,MAAM,GAAG,IAAI,EAAE,WAAW,IAAI,IAAI,kBAAkB,EAAE,CAAC;QAC7D,MAAM,SAAS,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AC,GAAG,CAAC,CAAC;gBAC/B,MAAM;YACR,KAAK,QAAQ;gBACX,CAAC,IAAI,mBAAmB,CAAC,CAAC,CAAC;gBAC3B,MAAM;QACV,CAAC;QAED,OAAO,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9B,CAAC;IAED,0EAA0E;IACnE,MAAM,CAAC,KAAqB;QACjC,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,KAAK,KAAK,CAAC,MAAM,CAAC,UAAU,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,KAAK,KAAK,CAAC,MAAM,CAAC,QAAQ;eACtG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC;eAC5F,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAC9C,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Annotation\r\n */\r\n\r\nimport { Point3d, Transform, XAndY, XYZProps, YawPitchRollAngles, YawPitchRollProps } from \"@itwin/core-geometry\";\r\nimport { TextBlock, TextBlockProps } from \"./TextBlock\";\r\n\r\n/** Describes how to compute the \"anchor point\" for a [[TextAnnotation]].\r\n * The anchor point is a point on or inside of the 2d bounding box enclosing the contents of the annotation's [[TextBlock]].\r\n * The annotation can be rotated and translated relative to the anchor point. The anchor point also serves as the snap point\r\n * when [AccuSnap]($frontend) is set to [SnapMode.Origin]($frontend).\r\n * @see [[TextAnnotation]] for a description of how the anchor point is computed.\r\n * @beta\r\n */\r\nexport interface TextAnnotationAnchor {\r\n /**\r\n * The vertical alignment of the anchor point.\r\n * \"top\" aligns the anchor point with the top of the text's bounding box.\r\n * \"middle\" aligns the anchor point with the middle of the text's bounding box.\r\n * \"bottom\" aligns the anchor point with the bottom of the text's bounding box.\r\n */\r\n vertical: \"top\" | \"middle\" | \"bottom\";\r\n\r\n /**\r\n * The horizontal alignment of the anchor point.\r\n * \"left\" aligns the anchor point with left side of the text's bounding box.\r\n * \"center\" aligns the anchor point with center of the text with's bounding box.\r\n * \"right\" aligns the anchor point with right side of the text's bounding box.\r\n */\r\n horizontal: \"left\" | \"center\" | \"right\";\r\n}\r\n\r\n/**\r\n * JSON representation of a [[TextAnnotation]].\r\n * @beta\r\n */\r\nexport interface TextAnnotationProps {\r\n /** See [[TextAnnotation.offset]]. Default: [0, 0, 0]. */\r\n offset?: XYZProps;\r\n /** See [[TextAnnotation.orientation]]. Default: no rotation. */\r\n orientation?: YawPitchRollProps;\r\n /** See [[TextAnnotation.textBlock]]. Default: an empty text block. */\r\n textBlock?: TextBlockProps;\r\n /** See [[TextAnnotation.anchor]]. Default: top-left. */\r\n anchor?: TextAnnotationAnchor;\r\n}\r\n\r\n/** Arguments supplied to [[TextAnnotation.create]].\r\n * @beta\r\n */\r\nexport interface TextAnnotationCreateArgs {\r\n /** See [[TextAnnotation.offset]]. Default: (0, 0, 0). */\r\n offset?: Point3d;\r\n /** See [[TextAnnotation.orientation]]. Default: no rotation. */\r\n orientation?: YawPitchRollAngles;\r\n /** See [[TextAnnotation.textBlock]]. Default: an empty text block. */\r\n textBlock?: TextBlock;\r\n /** See [[TextAnnotation.anchor]]. Default: top-left. */\r\n anchor?: TextAnnotationAnchor;\r\n}\r\n\r\n/**\r\n * Represents a formatted block of text positioned in 2d or 3d space.\r\n * [TextAnnotation2d]($backend) and [TextAnnotation3d]($backend) elements store a single TextAnnotation from which their geometric representation is generated.\r\n * Other types of elements may store multiple TextAnnotations, positioned relative to one another.\r\n * The annotation's position and orientation relative to the host element's [Placement]($common) is determined as follows:\r\n * - First, the width and height of a box enclosing the contents of the [[textBlock]] must be computed using [computeTextBlockExtents]($backend). This yields a box with the top-left\r\n * corner at (0, 0) and the bottom-right corner at (width, -height).\r\n * - Then, an \"anchor point\" is computed based on the text box and the [[anchor]] property. For example, if the annotation is anchored at the center-left, the anchor point will be (width/2, -height).\r\n * - The [[orientation]] is applied to rotate the box around the anchor point.\r\n * - Finally, the [[offset]] is added to the anchor point to apply translation.\r\n * @see [produceTextAnnotationGeometry]($backend) to decompose the annotation into a set of geometric primitives suitable for use with [[GeometryStreamBuilder.appendTextBlock]].\r\n * @beta\r\n */\r\nexport class TextAnnotation {\r\n /** The rotation of the annotation.\r\n * @note When defining an annotation for a [TextAnnotation2d]($backend), only the `yaw` component (rotation around the Z axis) is used.\r\n */\r\n public orientation: YawPitchRollAngles;\r\n /** The formatted document. */\r\n public textBlock: TextBlock;\r\n /** Describes how to compute the [[textBlock]]'s anchor point. */\r\n public anchor: TextAnnotationAnchor;\r\n /** An offset applied to the anchor point that can be used to position annotations within the same geometry stream relative to one another. */\r\n public offset: Point3d;\r\n\r\n private constructor(offset: Point3d, angles: YawPitchRollAngles, textBlock: TextBlock, anchor: TextAnnotationAnchor) {\r\n this.offset = offset;\r\n this.orientation = angles;\r\n this.textBlock = textBlock;\r\n this.anchor = anchor;\r\n }\r\n\r\n /** Creates a new TextAnnotation. */\r\n public static create(args?: TextAnnotationCreateArgs): TextAnnotation {\r\n const offset = args?.offset ?? new Point3d();\r\n const angles = args?.orientation ?? new YawPitchRollAngles();\r\n const textBlock = args?.textBlock ?? TextBlock.createEmpty();\r\n const anchor = args?.anchor ?? { vertical: \"top\", horizontal: \"left\" };\r\n\r\n return new TextAnnotation(offset, angles, textBlock, anchor);\r\n }\r\n\r\n /**\r\n * Creates a new TextAnnotation instance from its JSON representation.\r\n */\r\n public static fromJSON(props: TextAnnotationProps | undefined): TextAnnotation {\r\n return TextAnnotation.create({\r\n offset: props?.offset ? Point3d.fromJSON(props.offset) : undefined,\r\n orientation: props?.orientation ? YawPitchRollAngles.fromJSON(props.orientation) : undefined,\r\n textBlock: props?.textBlock ? TextBlock.create(props.textBlock) : undefined,\r\n anchor: props?.anchor ? { ...props.anchor } : undefined,\r\n });\r\n }\r\n\r\n /**\r\n * Converts this annotation to its JSON representation.\r\n */\r\n public toJSON(): TextAnnotationProps {\r\n const props: TextAnnotationProps = {};\r\n\r\n // Even if the text block is empty, we want to record its style name and overrides, e.g.,\r\n // so the user can pick up where they left off editing it next time.\r\n props.textBlock = this.textBlock.toJSON();\r\n\r\n if (!this.offset.isZero) {\r\n props.offset = this.offset.toJSON();\r\n }\r\n\r\n if (!this.orientation.isIdentity()) {\r\n props.orientation = this.orientation.toJSON();\r\n }\r\n\r\n if (this.anchor.vertical !== \"top\" || this.anchor.horizontal !== \"left\") {\r\n props.anchor = { ...this.anchor };\r\n }\r\n\r\n return props;\r\n }\r\n\r\n /** Compute the transform that positions and orients this annotation relative to its anchor point, based on the [[textBlock]]'s computed bounding box.\r\n * The anchor point is computed as specified by this annotation's [[anchor]] setting. For example, if the text block is anchored\r\n * at the bottom left, then the transform will be relative to the bottom-left corner of `textBlockExtents`.\r\n * The text block will be rotated around the fixed anchor point according to [[orientation]], then the anchor point will be translated by [[offset]].\r\n * @param textBlockDimensions The width and height of the bounding box containing the text block. You can compute this using [computeTextBlockExtents]($common).\r\n * @see [[computeAnchorPoint]] to compute the transform's anchor point.\r\n */\r\n public computeTransform(textBlockDimensions: XAndY): Transform {\r\n const anchorPt = this.computeAnchorPoint(textBlockDimensions);\r\n const matrix = this.orientation.toMatrix3d();\r\n\r\n const rotation = Transform.createFixedPointAndMatrix(anchorPt, matrix);\r\n const translation = Transform.createTranslation(this.offset);\r\n return translation.multiplyTransformTransform(rotation, rotation);\r\n }\r\n\r\n /** Compute the anchor point of this annotation as specified by [[anchor]].\r\n * @param textBlockDimensions The width and height of the bounding box containing the [[textBlock]]. You can compute this using [computeTextBlockExtents]($common).\r\n * @see [[computeTransform]] to compute the transform relative to the anchor point.\r\n */\r\n public computeAnchorPoint(textBlockDimensions: XAndY): Point3d {\r\n let x = 0;\r\n let y = 0;\r\n\r\n switch (this.anchor.horizontal) {\r\n case \"center\":\r\n x += textBlockDimensions.x / 2;\r\n break;\r\n case \"right\":\r\n x += textBlockDimensions.x;\r\n break;\r\n }\r\n\r\n switch (this.anchor.vertical) {\r\n case \"middle\":\r\n y -= textBlockDimensions.y / 2;\r\n break;\r\n case \"bottom\":\r\n y -= textBlockDimensions.y;\r\n break;\r\n }\r\n\r\n return new Point3d(x, y, 0);\r\n }\r\n\r\n /** Returns true if this annotation is logically equivalent to `other`. */\r\n public equals(other: TextAnnotation): boolean {\r\n return this.anchor.horizontal === other.anchor.horizontal && this.anchor.vertical === other.anchor.vertical\r\n && this.orientation.isAlmostEqual(other.orientation) && this.offset.isAlmostEqual(other.offset)\r\n && this.textBlock.equals(other.textBlock);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"TextAnnotation.js","sourceRoot":"","sources":["../../../src/annotation/TextAnnotation.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,SAAS,EAAmB,kBAAkB,EAAqB,MAAM,sBAAsB,CAAC;AAClH,OAAO,EAAE,SAAS,EAAkB,MAAM,aAAa,CAAC;AAwDxD;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,cAAc;IAYzB,YAAoB,MAAe,EAAE,MAA0B,EAAE,SAAoB,EAAE,MAA4B;QACjH,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC;QAC1B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,oCAAoC;IAC7B,MAAM,CAAC,MAAM,CAAC,IAA+B;QAClD,MAAM,MAAM,GAAG,IAAI,EAAE,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;QAC7C,MAAM,MAAM,GAAG,IAAI,EAAE,W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;YAC7B,KAAK,QAAQ;gBACX,CAAC,IAAI,mBAAmB,CAAC,CAAC,GAAG,CAAC,CAAC;gBAC/B,MAAM;YACR,KAAK,QAAQ;gBACX,CAAC,IAAI,mBAAmB,CAAC,CAAC,CAAC;gBAC3B,MAAM;QACV,CAAC;QAED,OAAO,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9B,CAAC;IAED,0EAA0E;IACnE,MAAM,CAAC,KAAqB;QACjC,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,KAAK,KAAK,CAAC,MAAM,CAAC,UAAU,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,KAAK,KAAK,CAAC,MAAM,CAAC,QAAQ;eACtG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC;eAC5F,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAC9C,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Annotation\r\n */\r\n\r\nimport { Point3d, Transform, XAndY, XYZProps, YawPitchRollAngles, YawPitchRollProps } from \"@itwin/core-geometry\";\r\nimport { TextBlock, TextBlockProps } from \"./TextBlock\";\r\n\r\n/** Describes how to compute the \"anchor point\" for a [[TextAnnotation]].\r\n * The anchor point is a point on or inside of the 2d bounding box enclosing the contents of the annotation's [[TextBlock]].\r\n * The annotation can be rotated and translated relative to the anchor point. The anchor point also serves as the snap point\r\n * when [AccuSnap]($frontend) is set to [SnapMode.Origin]($frontend).\r\n * @see [[TextAnnotation]] for a description of how the anchor point is computed.\r\n * @beta\r\n */\r\nexport interface TextAnnotationAnchor {\r\n /**\r\n * The vertical alignment of the anchor point.\r\n * \"top\" aligns the anchor point with the top of the text's bounding box.\r\n * \"middle\" aligns the anchor point with the middle of the text's bounding box.\r\n * \"bottom\" aligns the anchor point with the bottom of the text's bounding box.\r\n */\r\n vertical: \"top\" | \"middle\" | \"bottom\";\r\n\r\n /**\r\n * The horizontal alignment of the anchor point.\r\n * \"left\" aligns the anchor point with left side of the text's bounding box.\r\n * \"center\" aligns the anchor point with center of the text with's bounding box.\r\n * \"right\" aligns the anchor point with right side of the text's bounding box.\r\n */\r\n horizontal: \"left\" | \"center\" | \"right\";\r\n}\r\n\r\n/**\r\n * JSON representation of a [[TextAnnotation]].\r\n * @beta\r\n */\r\nexport interface TextAnnotationProps {\r\n /** See [[TextAnnotation.offset]]. Default: [0, 0, 0]. */\r\n offset?: XYZProps;\r\n /** See [[TextAnnotation.orientation]]. Default: no rotation. */\r\n orientation?: YawPitchRollProps;\r\n /** See [[TextAnnotation.textBlock]]. Default: an empty text block. */\r\n textBlock?: TextBlockProps;\r\n /** See [[TextAnnotation.anchor]]. Default: top-left. */\r\n anchor?: TextAnnotationAnchor;\r\n}\r\n\r\n/** Arguments supplied to [[TextAnnotation.create]].\r\n * @beta\r\n */\r\nexport interface TextAnnotationCreateArgs {\r\n /** See [[TextAnnotation.offset]]. Default: (0, 0, 0). */\r\n offset?: Point3d;\r\n /** See [[TextAnnotation.orientation]]. Default: no rotation. */\r\n orientation?: YawPitchRollAngles;\r\n /** See [[TextAnnotation.textBlock]]. Default: an empty text block. */\r\n textBlock?: TextBlock;\r\n /** See [[TextAnnotation.anchor]]. Default: top-left. */\r\n anchor?: TextAnnotationAnchor;\r\n}\r\n\r\n/**\r\n * Represents a formatted block of text positioned in 2d or 3d space.\r\n * [TextAnnotation2d]($backend) and [TextAnnotation3d]($backend) elements store a single TextAnnotation from which their geometric representation is generated.\r\n * Other types of elements may store multiple TextAnnotations, positioned relative to one another.\r\n * The annotation's position and orientation relative to the host element's [Placement]($common) is determined as follows:\r\n * - First, the width and height of a box enclosing the contents of the [[textBlock]] must be computed using [computeTextBlockExtents]($backend). This yields a box with the top-left\r\n * corner at (0, 0) and the bottom-right corner at (width, -height).\r\n * - Then, an \"anchor point\" is computed based on the text box and the [[anchor]] property. For example, if the annotation is anchored at the center-left, the anchor point will be (width/2, -height).\r\n * - The [[orientation]] is applied to rotate the box around the anchor point.\r\n * - Finally, the [[offset]] is added to the anchor point to apply translation.\r\n * @see [produceTextAnnotationGeometry]($backend) to decompose the annotation into a set of geometric primitives suitable for use with [[GeometryStreamBuilder.appendTextBlock]].\r\n * @beta\r\n */\r\nexport class TextAnnotation {\r\n /** The rotation of the annotation.\r\n * @note When defining an annotation for a [TextAnnotation2d]($backend), only the `yaw` component (rotation around the Z axis) is used.\r\n */\r\n public orientation: YawPitchRollAngles;\r\n /** The formatted document. */\r\n public textBlock: TextBlock;\r\n /** Describes how to compute the [[textBlock]]'s anchor point. */\r\n public anchor: TextAnnotationAnchor;\r\n /** An offset applied to the anchor point that can be used to position annotations within the same geometry stream relative to one another. */\r\n public offset: Point3d;\r\n\r\n private constructor(offset: Point3d, angles: YawPitchRollAngles, textBlock: TextBlock, anchor: TextAnnotationAnchor) {\r\n this.offset = offset;\r\n this.orientation = angles;\r\n this.textBlock = textBlock;\r\n this.anchor = anchor;\r\n }\r\n\r\n /** Creates a new TextAnnotation. */\r\n public static create(args?: TextAnnotationCreateArgs): TextAnnotation {\r\n const offset = args?.offset ?? new Point3d();\r\n const angles = args?.orientation ?? new YawPitchRollAngles();\r\n const textBlock = args?.textBlock ?? TextBlock.createEmpty();\r\n const anchor = args?.anchor ?? { vertical: \"top\", horizontal: \"left\" };\r\n\r\n return new TextAnnotation(offset, angles, textBlock, anchor);\r\n }\r\n\r\n /**\r\n * Creates a new TextAnnotation instance from its JSON representation.\r\n */\r\n public static fromJSON(props: TextAnnotationProps | undefined): TextAnnotation {\r\n return TextAnnotation.create({\r\n offset: props?.offset ? Point3d.fromJSON(props.offset) : undefined,\r\n orientation: props?.orientation ? YawPitchRollAngles.fromJSON(props.orientation) : undefined,\r\n textBlock: props?.textBlock ? TextBlock.create(props.textBlock) : undefined,\r\n anchor: props?.anchor ? { ...props.anchor } : undefined,\r\n });\r\n }\r\n\r\n /**\r\n * Converts this annotation to its JSON representation.\r\n */\r\n public toJSON(): TextAnnotationProps {\r\n const props: TextAnnotationProps = {};\r\n\r\n // Even if the text block is empty, we want to record its style name and overrides, e.g.,\r\n // so the user can pick up where they left off editing it next time.\r\n props.textBlock = this.textBlock.toJSON();\r\n\r\n if (!this.offset.isZero) {\r\n props.offset = this.offset.toJSON();\r\n }\r\n\r\n if (!this.orientation.isIdentity()) {\r\n props.orientation = this.orientation.toJSON();\r\n }\r\n\r\n if (this.anchor.vertical !== \"top\" || this.anchor.horizontal !== \"left\") {\r\n props.anchor = { ...this.anchor };\r\n }\r\n\r\n return props;\r\n }\r\n\r\n /** Compute the transform that positions and orients this annotation relative to its anchor point, based on the [[textBlock]]'s computed bounding box.\r\n * The anchor point is computed as specified by this annotation's [[anchor]] setting. For example, if the text block is anchored\r\n * at the bottom left, then the transform will be relative to the bottom-left corner of `textBlockExtents`.\r\n * The text block will be rotated around the fixed anchor point according to [[orientation]], then the anchor point will be translated by [[offset]].\r\n * @param textBlockDimensions The width and height of the bounding box containing the text block. You can compute this using [computeTextBlockExtents]($backend).\r\n * @see [[computeAnchorPoint]] to compute the transform's anchor point.\r\n */\r\n public computeTransform(textBlockDimensions: XAndY): Transform {\r\n const anchorPt = this.computeAnchorPoint(textBlockDimensions);\r\n const matrix = this.orientation.toMatrix3d();\r\n\r\n const rotation = Transform.createFixedPointAndMatrix(anchorPt, matrix);\r\n const translation = Transform.createTranslation(this.offset);\r\n return translation.multiplyTransformTransform(rotation, rotation);\r\n }\r\n\r\n /** Compute the anchor point of this annotation as specified by [[anchor]].\r\n * @param textBlockDimensions The width and height of the bounding box containing the [[textBlock]]. You can compute this using [computeTextBlockExtents]($backend).\r\n * @see [[computeTransform]] to compute the transform relative to the anchor point.\r\n */\r\n public computeAnchorPoint(textBlockDimensions: XAndY): Point3d {\r\n let x = 0;\r\n let y = 0;\r\n\r\n switch (this.anchor.horizontal) {\r\n case \"center\":\r\n x += textBlockDimensions.x / 2;\r\n break;\r\n case \"right\":\r\n x += textBlockDimensions.x;\r\n break;\r\n }\r\n\r\n switch (this.anchor.vertical) {\r\n case \"middle\":\r\n y -= textBlockDimensions.y / 2;\r\n break;\r\n case \"bottom\":\r\n y -= textBlockDimensions.y;\r\n break;\r\n }\r\n\r\n return new Point3d(x, y, 0);\r\n }\r\n\r\n /** Returns true if this annotation is logically equivalent to `other`. */\r\n public equals(other: TextAnnotation): boolean {\r\n return this.anchor.horizontal === other.anchor.horizontal && this.anchor.vertical === other.anchor.vertical\r\n && this.orientation.isAlmostEqual(other.orientation) && this.offset.isAlmostEqual(other.offset)\r\n && this.textBlock.equals(other.textBlock);\r\n }\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/core-common",
3
- "version": "4.7.0-dev.3",
3
+ "version": "4.7.0-dev.4",
4
4
  "description": "iTwin.js components common to frontend and backend",
5
5
  "main": "lib/cjs/core-common.js",
6
6
  "module": "lib/esm/core-common.js",
@@ -27,8 +27,8 @@
27
27
  "js-base64": "^3.6.1"
28
28
  },
29
29
  "peerDependencies": {
30
- "@itwin/core-bentley": "^4.7.0-dev.3",
31
- "@itwin/core-geometry": "^4.7.0-dev.3"
30
+ "@itwin/core-bentley": "^4.7.0-dev.4",
31
+ "@itwin/core-geometry": "^4.7.0-dev.4"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@itwin/eslint-plugin": "^4.0.2",
@@ -43,9 +43,9 @@
43
43
  "nyc": "^15.1.0",
44
44
  "rimraf": "^3.0.2",
45
45
  "typescript": "~5.3.3",
46
- "@itwin/build-tools": "4.7.0-dev.3",
47
- "@itwin/core-bentley": "4.7.0-dev.3",
48
- "@itwin/core-geometry": "4.7.0-dev.3"
46
+ "@itwin/build-tools": "4.7.0-dev.4",
47
+ "@itwin/core-bentley": "4.7.0-dev.4",
48
+ "@itwin/core-geometry": "4.7.0-dev.4"
49
49
  },
50
50
  "nyc": {
51
51
  "extends": "./node_modules/@itwin/build-tools/.nycrc",