@itwin/core-common 5.1.0-dev.56 → 5.1.0-dev.58

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.
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import { Point3d, Range2d, Transform, XYZProps, YawPitchRollAngles, YawPitchRollProps } from "@itwin/core-geometry";
5
5
  import { TextBlock, TextBlockProps } from "./TextBlock";
6
- import { TextStyleColor } from "./TextStyle";
6
+ import { TextStyleColor, TextStyleSettingsProps } from "./TextStyle";
7
7
  /** Describes how to compute the "anchor point" for a [[TextAnnotation]].
8
8
  * The anchor point is a point on or inside of the 2d bounding box enclosing the contents of the annotation's [[TextBlock]].
9
9
  * The annotation can be rotated and translated relative to the anchor point. The anchor point also serves as the snap point
@@ -57,6 +57,73 @@ export interface TextFrameStyleProps {
57
57
  /** This will be used to set the [[GeometryParams.weight]] property of the frame (in pixels). Default: 1px */
58
58
  borderWeight?: number;
59
59
  }
60
+ /**
61
+ * Describes how to attach a [[TextAnnotationLeader]] to the frame around a [[TextBlock]].
62
+ * Leader can be attached using one of the three modes:
63
+ * - KeyPoint: attach to a point on the frame specified by the given curveIndex and fractional position.
64
+ * - TextPoint: attach to a point that is projected on to the frame from the point on a particular line of text specified by [[LeaderTextPointOptions]].
65
+ * - Nearest: attach to the point on frame that is nearest to [[TextAnnotationLeader.startPoint]].
66
+ * @beta
67
+ */
68
+ export type LeaderAttachment = {
69
+ mode: "KeyPoint";
70
+ curveIndex: number;
71
+ fraction: number;
72
+ } | {
73
+ mode: "TextPoint";
74
+ position: LeaderTextPointOptions;
75
+ } | {
76
+ mode: "Nearest";
77
+ };
78
+ /**
79
+ * Specifies the possible positions to attach a leader on the frame around a [[TextBlock]]
80
+ * when [[TextAnnotationLeader.attachment.mode]] is set to TextPoint.
81
+ * TopLeft : attach to a point projected onto the frame from the point on the left side of the first line of text.
82
+ * TopRight : attach to a point projected onto the frame from the point on the right side of the first line of text.
83
+ * BottomLeft : attach to a point projected onto the frame from the point on the left side of the last line of text.
84
+ * BottomRight : attach to a point projected onto the frame from the point on the right side of the last line of text.
85
+ * @beta
86
+ */
87
+ export type LeaderTextPointOptions = "TopLeft" | "TopRight" | "BottomLeft" | "BottomRight";
88
+ /**
89
+ * A line that connects a [[TextAnnotation]] to a point in space relative to another element in the iModel.
90
+ * A leader is always attached to the frame around the annotation's [[TextBlock]].
91
+ * If the frame is not visible, the leader attaches to an invisible rectangular frame around the text block.
92
+ * @see [[TextAnnotation.leaders]] for the leaders associated with an annotation.
93
+ * @see [[TextStyleSettings.leader]] and [[styleOverrides]] to customize the appearance of leaders.
94
+ * @beta
95
+ */
96
+ export interface TextAnnotationLeader {
97
+ /** The point where the leader starts.
98
+ * This is the point on another element where the leader points to */
99
+ startPoint: Point3d;
100
+ /** Describes how to attach the leader to the frame around [[textBlock]].*/
101
+ attachment: LeaderAttachment;
102
+ /** Optional intermediate points that the leader should pass through.
103
+ * If not specified, the leader will be a straight line from startPoint to the point on the frame.
104
+ * For now, intermediate points are a set of points which create additional LineSegments in the leader, but there could be intermediate shapes instead of straight LineSegments in future*/
105
+ intermediatePoints?: Point3d[];
106
+ /** Optional style overrides for the leader. If not specified, the leader will use the style defined by [[TextBlock.styleName]] as it is.
107
+ * If specified, these overrides will be applied to the style.
108
+ */
109
+ styleOverrides?: TextStyleSettingsProps;
110
+ }
111
+ /**
112
+ * JSON representation of a [[TextAnnotationLeader]].
113
+ * @beta
114
+ */
115
+ export interface TextAnnotationLeaderProps {
116
+ /** See [[TextAnnotationLeader.startPoint]]. */
117
+ startPoint: XYZProps;
118
+ /** See [[TextAnnotationLeader.attachment]]. */
119
+ attachment: LeaderAttachment;
120
+ /** See [[TextAnnotationLeader.intermediatePoints]]. Default: no intermediate points. */
121
+ intermediatePoints?: XYZProps[];
122
+ /** See [[TextAnnotationLeader.styleOverrides]]. Default: no style overrides. */
123
+ styleOverrides?: TextStyleSettingsProps;
124
+ }
125
+ /**
126
+
60
127
  /**
61
128
  * JSON representation of a [[TextAnnotation]].
62
129
  * @beta
@@ -72,6 +139,8 @@ export interface TextAnnotationProps {
72
139
  anchor?: TextAnnotationAnchor;
73
140
  /** See [[TextAnnotation.frame]]. Default: no frame */
74
141
  frame?: TextFrameStyleProps;
142
+ /** See [[TextAnnotation.leader]]. Default: an empty leader array */
143
+ leaders?: TextAnnotationLeaderProps[];
75
144
  }
76
145
  /** Arguments supplied to [[TextAnnotation.create]].
77
146
  * @beta
@@ -87,6 +156,8 @@ export interface TextAnnotationCreateArgs {
87
156
  anchor?: TextAnnotationAnchor;
88
157
  /** See [[TextAnnotation.frame]]. Default: no frame */
89
158
  frame?: TextFrameStyleProps;
159
+ /** See [[TextAnnotation.leader]]. Default: an empty leader array */
160
+ leaders?: TextAnnotationLeader[];
90
161
  }
91
162
  /**
92
163
  * Represents a formatted block of text positioned in 2d or 3d space.
@@ -114,6 +185,8 @@ export declare class TextAnnotation {
114
185
  offset: Point3d;
115
186
  /** The frame settings of the text annotation. */
116
187
  frame?: TextFrameStyleProps;
188
+ /** The leaders of the text annotation. */
189
+ leaders?: TextAnnotationLeader[];
117
190
  private constructor();
118
191
  /** Creates a new TextAnnotation. */
119
192
  static create(args?: TextAnnotationCreateArgs): TextAnnotation;
@@ -140,6 +213,8 @@ export declare class TextAnnotation {
140
213
  * @see [[computeTransform]] to compute the transform relative to the anchor point.
141
214
  */
142
215
  computeAnchorPoint(boundingBox: Range2d): Point3d;
216
+ /** Returns true if the leaders of this annotation are equal to the leaders of `other`. */
217
+ private areLeadersEqual;
143
218
  /** Returns true if this annotation is logically equivalent to `other`. */
144
219
  equals(other: TextAnnotation): boolean;
145
220
  }
@@ -1 +1 @@
1
- {"version":3,"file":"TextAnnotation.d.ts","sourceRoot":"","sources":["../../../src/annotation/TextAnnotation.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,kBAAkB,EAAE,iBAAiB,EAA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AM,EAAE,OAAO,CAAC;IACvB,iDAAiD;IAC1C,KAAK,CAAC,EAAE,mBAAmB,CAAC;IACnC,0CAA0C;IACnC,OAAO,CAAC,EAAE,oBAAoB,EAAE,CAAC;IAExC,OAAO;IASP,oCAAoC;WACtB,MAAM,CAAC,IAAI,CAAC,EAAE,wBAAwB,GAAG,cAAc;IAYrE;;OAEG;WACW,QAAQ,CAAC,KAAK,EAAE,mBAAmB,GAAG,SAAS,GAAG,cAAc;IAgB9E;;OAEG;IACI,MAAM,IAAI,mBAAmB;IAgCpC;;;;;;;;OAQG;IACI,gBAAgB,CAAC,WAAW,EAAE,OAAO,GAAG,SAAS;IAUxD;;;OAGG;IACI,kBAAkB,CAAC,WAAW,EAAE,OAAO,GAAG,OAAO;IAyBxD,0FAA0F;IAC1F,OAAO,CAAC,eAAe;IAsBvB,0EAA0E;IACnE,MAAM,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO;CAmB9C"}
@@ -40,12 +40,15 @@ class TextAnnotation {
40
40
  offset;
41
41
  /** The frame settings of the text annotation. */
42
42
  frame;
43
- constructor(offset, angles, textBlock, anchor, frame) {
43
+ /** The leaders of the text annotation. */
44
+ leaders;
45
+ constructor(offset, angles, textBlock, anchor, frame, leaders) {
44
46
  this.offset = offset;
45
47
  this.orientation = angles;
46
48
  this.textBlock = textBlock;
47
49
  this.anchor = anchor;
48
50
  this.frame = frame;
51
+ this.leaders = leaders;
49
52
  }
50
53
  /** Creates a new TextAnnotation. */
51
54
  static create(args) {
@@ -56,7 +59,8 @@ class TextAnnotation {
56
59
  // If the user supplies a frame, but doesn't supply a shape, default the shape to "rectangle"
57
60
  const shape = args?.frame?.shape ?? "rectangle";
58
61
  const frame = args?.frame ? { shape, ...args.frame } : undefined;
59
- return new TextAnnotation(offset, angles, textBlock, anchor, frame);
62
+ const leaders = args?.leaders ?? undefined;
63
+ return new TextAnnotation(offset, angles, textBlock, anchor, frame, leaders);
60
64
  }
61
65
  /**
62
66
  * Creates a new TextAnnotation instance from its JSON representation.
@@ -68,6 +72,12 @@ class TextAnnotation {
68
72
  textBlock: props?.textBlock ? TextBlock_1.TextBlock.create(props.textBlock) : undefined,
69
73
  anchor: props?.anchor ? { ...props.anchor } : undefined,
70
74
  frame: props?.frame ? { shape: "rectangle", ...props.frame } : undefined,
75
+ leaders: props?.leaders ? props.leaders.map((leader) => ({
76
+ startPoint: core_geometry_1.Point3d.fromJSON(leader.startPoint),
77
+ attachment: leader.attachment,
78
+ styleOverrides: leader.styleOverrides ?? undefined,
79
+ intermediatePoints: leader.intermediatePoints ? leader.intermediatePoints.map((point) => core_geometry_1.Point3d.fromJSON(point)) : undefined,
80
+ })) : undefined,
71
81
  });
72
82
  }
73
83
  /**
@@ -89,6 +99,12 @@ class TextAnnotation {
89
99
  }
90
100
  // Default frame to "none"
91
101
  props.frame = this.frame ? { ...this.frame } : undefined;
102
+ props.leaders = this.leaders?.map((leader) => ({
103
+ startPoint: leader.startPoint.toJSON(),
104
+ attachment: leader.attachment,
105
+ styleOverrides: leader.styleOverrides ?? undefined,
106
+ intermediatePoints: leader.intermediatePoints ? leader.intermediatePoints.map((point) => point.toJSON()) : undefined,
107
+ })) ?? undefined;
92
108
  return props;
93
109
  }
94
110
  /** Compute the transform that positions and orients this annotation relative to its anchor point, based on the [[textBlock]]'s computed bounding box.
@@ -132,16 +148,47 @@ class TextAnnotation {
132
148
  }
133
149
  return new core_geometry_1.Point3d(x, y, 0);
134
150
  }
151
+ /** Returns true if the leaders of this annotation are equal to the leaders of `other`. */
152
+ areLeadersEqual(leadersA, leadersB) {
153
+ if (leadersA === leadersB)
154
+ return true;
155
+ if (!leadersA || !leadersB || leadersA.length !== leadersB.length)
156
+ return false;
157
+ for (let i = 0; i < leadersA.length; ++i) {
158
+ const a = leadersA[i];
159
+ const b = leadersB[i];
160
+ if (!a.startPoint.isAlmostEqual(b.startPoint))
161
+ return false;
162
+ if (JSON.stringify(a.attachment) !== JSON.stringify(b.attachment))
163
+ return false;
164
+ if (JSON.stringify(a.styleOverrides) !== JSON.stringify(b.styleOverrides))
165
+ return false;
166
+ const pointsA = a.intermediatePoints ?? [];
167
+ const pointsB = b.intermediatePoints ?? [];
168
+ if (pointsA.length !== pointsB.length)
169
+ return false;
170
+ for (let j = 0; j < pointsA.length; ++j) {
171
+ if (!pointsA[j].isAlmostEqual(pointsB[j]))
172
+ return false;
173
+ }
174
+ }
175
+ return true;
176
+ }
135
177
  /** Returns true if this annotation is logically equivalent to `other`. */
136
178
  equals(other) {
179
+ if (this.anchor.horizontal !== other.anchor.horizontal ||
180
+ this.anchor.vertical !== other.anchor.vertical ||
181
+ !this.orientation.isAlmostEqual(other.orientation) ||
182
+ !this.offset.isAlmostEqual(other.offset) ||
183
+ !this.textBlock.equals(other.textBlock))
184
+ return false;
137
185
  const framesMatch = this.frame?.shape === other.frame?.shape
138
186
  && this.frame?.fill === other.frame?.fill
139
187
  && this.frame?.border === other.frame?.border
140
188
  && this.frame?.borderWeight === other.frame?.borderWeight;
141
- return this.anchor.horizontal === other.anchor.horizontal && this.anchor.vertical === other.anchor.vertical
142
- && this.orientation.isAlmostEqual(other.orientation) && this.offset.isAlmostEqual(other.offset)
143
- && this.textBlock.equals(other.textBlock)
144
- && framesMatch;
189
+ if (!framesMatch)
190
+ return false;
191
+ return this.areLeadersEqual(this.leaders, other.leaders);
145
192
  }
146
193
  }
147
194
  exports.TextAnnotation = TextAnnotation;
@@ -1 +1 @@
1
- {"version":3,"file":"TextAnnotation.js","sourceRoot":"","sources":["../../../src/annotation/TextAnnotation.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,wDAAoH;AACpH,2CAAwD;AA6BxD;;EAEE;AACW,QAAA,yBAAyB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,qBAAqB,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,kBAAkB,CAAU,CA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AM;QACV,CAAC;QAED,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;YAC7B,KAAK,QAAQ;gBACX,CAAC,IAAI,WAAW,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;gBAC/B,MAAM;YACR,KAAK,QAAQ;gBACX,CAAC,IAAI,WAAW,CAAC,OAAO,EAAE,CAAC;gBAC3B,MAAM;QACV,CAAC;QAED,OAAO,IAAI,uBAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9B,CAAC;IAED,0EAA0E;IACnE,MAAM,CAAC,KAAqB;QACjC,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,EAAE,KAAK,KAAK,KAAK,CAAC,KAAK,EAAE,KAAK;eACvD,IAAI,CAAC,KAAK,EAAE,IAAI,KAAK,KAAK,CAAC,KAAK,EAAE,IAAI;eACtC,IAAI,CAAC,KAAK,EAAE,MAAM,KAAK,KAAK,CAAC,KAAK,EAAE,MAAM;eAC1C,IAAI,CAAC,KAAK,EAAE,YAAY,KAAK,KAAK,CAAC,KAAK,EAAE,YAAY,CAAC;QAE5D,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;eACtC,WAAW,CAAC;IACnB,CAAC;CACF;AAxID,wCAwIC","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 Annotation\n */\n\nimport { Point3d, Range2d, Transform, XYZProps, YawPitchRollAngles, YawPitchRollProps } from \"@itwin/core-geometry\";\nimport { TextBlock, TextBlockProps } from \"./TextBlock\";\nimport { TextStyleColor } from \"./TextStyle\";\n\n/** Describes how to compute the \"anchor point\" for a [[TextAnnotation]].\n * The anchor point is a point on or inside of the 2d bounding box enclosing the contents of the annotation's [[TextBlock]].\n * The annotation can be rotated and translated relative to the anchor point. The anchor point also serves as the snap point\n * when [AccuSnap]($frontend) is set to [SnapMode.Origin]($frontend).\n * [[TextAnnotation.computeTransform]] will align the anchor point with (0, 0).\n * @see [[TextAnnotation]] for a description of how the anchor point is computed.\n * @beta\n */\nexport interface TextAnnotationAnchor {\n /**\n * The vertical alignment of the anchor point.\n * \"top\" aligns the anchor point with the top of the text's bounding box.\n * \"middle\" aligns the anchor point with the middle of the text's bounding box.\n * \"bottom\" aligns the anchor point with the bottom of the text's bounding box.\n */\n vertical: \"top\" | \"middle\" | \"bottom\";\n\n /**\n * The horizontal alignment of the anchor point.\n * \"left\" aligns the anchor point with left side of the text's bounding box.\n * \"center\" aligns the anchor point with center of the text with's bounding box.\n * \"right\" aligns the anchor point with right side of the text's bounding box.\n */\n horizontal: \"left\" | \"center\" | \"right\";\n}\n\n/** Set of predefined shapes that can be computed and drawn around the margins of a [[TextBlock]]\n * @beta\n*/\nexport const textAnnotationFrameShapes = [\"none\", \"line\", \"rectangle\", \"circle\", \"equilateralTriangle\", \"diamond\", \"square\", \"pentagon\", \"hexagon\", \"octagon\", \"capsule\", \"roundedRectangle\"] as const;\n\n/** Describes a predefined shape that can be computed and drawn around the margins of a [[TextBlock]]\n * @beta\n*/\nexport type TextAnnotationFrameShape = typeof textAnnotationFrameShapes[number];\n\n/**\n * Describes what color to use when filling the frame around a [[TextBlock]].\n * If `background` is specified, [[GeometryParams.BackgroundFill]] will be set to `BackgroundFill.Outline`.\n * @beta\n */\nexport type TextAnnotationFillColor = TextStyleColor | \"background\";\n\n/**\n * Describes how to draw the frame around a [[TextBlock]].\n * The frame can be a simple line, a filled shape, or both.\n * @beta\n */\nexport interface TextFrameStyleProps {\n /** Shape of the frame. Default: \"rectangle\" */\n shape?: TextAnnotationFrameShape;\n /** The color to fill the shape of the text frame. This fill will is applied using [[FillDisplay.Blanking]]. Default: no fill */\n fill?: TextAnnotationFillColor;\n /** The color of the text frame's outline. Default: black */\n border?: TextStyleColor;\n /** This will be used to set the [[GeometryParams.weight]] property of the frame (in pixels). Default: 1px */\n borderWeight?: number;\n}\n\n/**\n * JSON representation of a [[TextAnnotation]].\n * @beta\n */\nexport interface TextAnnotationProps {\n /** See [[TextAnnotation.offset]]. Default: [0, 0, 0]. */\n offset?: XYZProps;\n /** See [[TextAnnotation.orientation]]. Default: no rotation. */\n orientation?: YawPitchRollProps;\n /** See [[TextAnnotation.textBlock]]. Default: an empty text block. */\n textBlock?: TextBlockProps;\n /** See [[TextAnnotation.anchor]]. Default: top-left. */\n anchor?: TextAnnotationAnchor;\n /** See [[TextAnnotation.frame]]. Default: no frame */\n frame?: TextFrameStyleProps\n}\n\n/** Arguments supplied to [[TextAnnotation.create]].\n * @beta\n */\nexport interface TextAnnotationCreateArgs {\n /** See [[TextAnnotation.offset]]. Default: (0, 0, 0). */\n offset?: Point3d;\n /** See [[TextAnnotation.orientation]]. Default: no rotation. */\n orientation?: YawPitchRollAngles;\n /** See [[TextAnnotation.textBlock]]. Default: an empty text block. */\n textBlock?: TextBlock;\n /** See [[TextAnnotation.anchor]]. Default: top-left. */\n anchor?: TextAnnotationAnchor;\n /** See [[TextAnnotation.frame]]. Default: no frame */\n frame?: TextFrameStyleProps\n}\n\n/**\n * Represents a formatted block of text positioned in 2d or 3d space.\n * [TextAnnotation2d]($backend) and [TextAnnotation3d]($backend) elements store a single TextAnnotation from which their geometric representation is generated.\n * Other types of elements may store multiple TextAnnotations, positioned relative to one another.\n * The annotation's position and orientation relative to the host element's [Placement]($common) is determined as follows:\n * - First, a bounding box is computed enclosing the contents of the [[textBlock].\n * - Then, an \"anchor point\" is computed based on the bounding box and the [[anchor]] property. The anchor point can be at one of the four corners of the box, in the middle of one of its four\n * edges, or in the center of the box.\n * - The [[orientation]] is applied to rotate the box around the anchor point.\n * - Finally, the [[offset]] is added to the anchor point to apply translation.\n * @see [appendTextAnnotationGeometry]($backend) to construct the geometry and append it to an [[ElementGeometry.Builder]].\n * @beta\n */\nexport class TextAnnotation {\n /** The rotation of the annotation.\n * @note When defining an annotation for a [TextAnnotation2d]($backend), only the `yaw` component (rotation around the Z axis) is used.\n */\n public orientation: YawPitchRollAngles;\n /** The formatted document. */\n public textBlock: TextBlock;\n /** Describes how to compute the [[textBlock]]'s anchor point. */\n public anchor: TextAnnotationAnchor;\n /** An offset applied to the anchor point that can be used to position annotations within the same geometry stream relative to one another. */\n public offset: Point3d;\n /** The frame settings of the text annotation. */\n public frame?: TextFrameStyleProps;\n\n private constructor(offset: Point3d, angles: YawPitchRollAngles, textBlock: TextBlock, anchor: TextAnnotationAnchor, frame?: TextFrameStyleProps) {\n this.offset = offset;\n this.orientation = angles;\n this.textBlock = textBlock;\n this.anchor = anchor;\n this.frame = frame\n }\n\n /** Creates a new TextAnnotation. */\n public static create(args?: TextAnnotationCreateArgs): TextAnnotation {\n const offset = args?.offset ?? new Point3d();\n const angles = args?.orientation ?? new YawPitchRollAngles();\n const textBlock = args?.textBlock ?? TextBlock.createEmpty();\n const anchor = args?.anchor ?? { vertical: \"top\", horizontal: \"left\" };\n // If the user supplies a frame, but doesn't supply a shape, default the shape to \"rectangle\"\n const shape: TextAnnotationFrameShape = args?.frame?.shape ?? \"rectangle\";\n const frame = args?.frame ? { shape, ...args.frame } : undefined;\n\n return new TextAnnotation(offset, angles, textBlock, anchor, frame);\n }\n\n /**\n * Creates a new TextAnnotation instance from its JSON representation.\n */\n public static fromJSON(props: TextAnnotationProps | undefined): TextAnnotation {\n return TextAnnotation.create({\n offset: props?.offset ? Point3d.fromJSON(props.offset) : undefined,\n orientation: props?.orientation ? YawPitchRollAngles.fromJSON(props.orientation) : undefined,\n textBlock: props?.textBlock ? TextBlock.create(props.textBlock) : undefined,\n anchor: props?.anchor ? { ...props.anchor } : undefined,\n frame: props?.frame ? { shape: \"rectangle\", ...props.frame } : undefined,\n });\n }\n\n /**\n * Converts this annotation to its JSON representation.\n */\n public toJSON(): TextAnnotationProps {\n const props: TextAnnotationProps = {};\n\n // Even if the text block is empty, we want to record its style name and overrides, e.g.,\n // so the user can pick up where they left off editing it next time.\n props.textBlock = this.textBlock.toJSON();\n\n if (!this.offset.isZero) {\n props.offset = this.offset.toJSON();\n }\n\n if (!this.orientation.isIdentity()) {\n props.orientation = this.orientation.toJSON();\n }\n\n if (this.anchor.vertical !== \"top\" || this.anchor.horizontal !== \"left\") {\n props.anchor = { ...this.anchor };\n }\n\n // Default frame to \"none\"\n props.frame = this.frame ? { ...this.frame } : undefined;\n\n return props;\n }\n\n /** Compute the transform that positions and orients this annotation relative to its anchor point, based on the [[textBlock]]'s computed bounding box.\n * The anchor point is computed as specified by this annotation's [[anchor]] setting. For example, if the text block is anchored\n * at the bottom left, then the transform will be relative to the bottom-left corner of `textBlockExtents`.\n * The text block will be rotated around the fixed anchor point according to [[orientation]], then translated by [[offset]].\n * The anchor point will coincide with (0, 0, 0) unless an [[offset]] is present.\n * @param boundingBox A box fully containing the [[textBlock]]. This range should include the margins.\n * @see [[computeAnchorPoint]] to compute the transform's anchor point.\n * @see [computeLayoutTextBlockResult]($backend) to lay out a `TextBlock`.\n */\n public computeTransform(boundingBox: Range2d): Transform {\n const anchorPt = this.computeAnchorPoint(boundingBox);\n const matrix = this.orientation.toMatrix3d();\n\n const rotation = Transform.createFixedPointAndMatrix(anchorPt, matrix);\n const translation = Transform.createTranslation(this.offset.minus(anchorPt));\n\n return translation.multiplyTransformTransform(rotation, rotation);\n }\n\n /** Compute the anchor point of this annotation as specified by [[anchor]].\n * @param boundingBox A box fully containing the [[textBlock]].\n * @see [[computeTransform]] to compute the transform relative to the anchor point.\n */\n public computeAnchorPoint(boundingBox: Range2d): Point3d {\n let x = boundingBox.low.x;\n let y = boundingBox.high.y;\n\n switch (this.anchor.horizontal) {\n case \"center\":\n x += boundingBox.xLength() / 2;\n break;\n case \"right\":\n x += boundingBox.xLength();\n break;\n }\n\n switch (this.anchor.vertical) {\n case \"middle\":\n y -= boundingBox.yLength() / 2;\n break;\n case \"bottom\":\n y -= boundingBox.yLength();\n break;\n }\n\n return new Point3d(x, y, 0);\n }\n\n /** Returns true if this annotation is logically equivalent to `other`. */\n public equals(other: TextAnnotation): boolean {\n const framesMatch = this.frame?.shape === other.frame?.shape\n && this.frame?.fill === other.frame?.fill\n && this.frame?.border === other.frame?.border\n && this.frame?.borderWeight === other.frame?.borderWeight;\n\n return this.anchor.horizontal === other.anchor.horizontal && this.anchor.vertical === other.anchor.vertical\n && this.orientation.isAlmostEqual(other.orientation) && this.offset.isAlmostEqual(other.offset)\n && this.textBlock.equals(other.textBlock)\n && framesMatch;\n }\n}\n"]}
1
+ {"version":3,"file":"TextAnnotation.js","sourceRoot":"","sources":["../../../src/annotation/TextAnnotation.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,wDAAoH;AACpH,2CAAwD;AA6BxD;;EAEE;AACW,QAAA,yBAAyB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,qBAAqB,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,kBAAkB,CAAU,CAAC;AAmIvM;;;;;;;;;;;;GAYG;AACH,MAAa,cAAc;IACzB;;OAEG;IACI,WAAW,CAAqB;IACvC,8BAA8B;IACvB,SAAS,CAAY;IAC5B,iEAAiE;IAC1D,MAAM,CAAuB;IACpC,8IAA8I;IACvI,MAAM,CAAU;IACvB,iDAAiD;IAC1C,KAAK,CAAuB;IACnC,0CAA0C;IACnC,OAAO,CAA0B;IAExC,YAAoB,MAA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O,KAAK,CAAC;YAC1D,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,0EAA0E;IACnE,MAAM,CAAC,KAAqB;QACjC,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,KAAK,KAAK,CAAC,MAAM,CAAC,UAAU;YACpD,IAAI,CAAC,MAAM,CAAC,QAAQ,KAAK,KAAK,CAAC,MAAM,CAAC,QAAQ;YAC9C,CAAC,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC;YAClD,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC;YACxC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC;YACvC,OAAO,KAAK,CAAC;QAEf,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,EAAE,KAAK,KAAK,KAAK,CAAC,KAAK,EAAE,KAAK;eACvD,IAAI,CAAC,KAAK,EAAE,IAAI,KAAK,KAAK,CAAC,KAAK,EAAE,IAAI;eACtC,IAAI,CAAC,KAAK,EAAE,MAAM,KAAK,KAAK,CAAC,KAAK,EAAE,MAAM;eAC1C,IAAI,CAAC,KAAK,EAAE,YAAY,KAAK,KAAK,CAAC,KAAK,EAAE,YAAY,CAAC;QAE5D,IAAI,CAAC,WAAW;YACd,OAAO,KAAK,CAAC;QAEf,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IAE3D,CAAC;CACF;AAvLD,wCAuLC","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 Annotation\n */\n\nimport { Point3d, Range2d, Transform, XYZProps, YawPitchRollAngles, YawPitchRollProps } from \"@itwin/core-geometry\";\nimport { TextBlock, TextBlockProps } from \"./TextBlock\";\nimport { TextStyleColor, TextStyleSettingsProps } from \"./TextStyle\";\n\n/** Describes how to compute the \"anchor point\" for a [[TextAnnotation]].\n * The anchor point is a point on or inside of the 2d bounding box enclosing the contents of the annotation's [[TextBlock]].\n * The annotation can be rotated and translated relative to the anchor point. The anchor point also serves as the snap point\n * when [AccuSnap]($frontend) is set to [SnapMode.Origin]($frontend).\n * [[TextAnnotation.computeTransform]] will align the anchor point with (0, 0).\n * @see [[TextAnnotation]] for a description of how the anchor point is computed.\n * @beta\n */\nexport interface TextAnnotationAnchor {\n /**\n * The vertical alignment of the anchor point.\n * \"top\" aligns the anchor point with the top of the text's bounding box.\n * \"middle\" aligns the anchor point with the middle of the text's bounding box.\n * \"bottom\" aligns the anchor point with the bottom of the text's bounding box.\n */\n vertical: \"top\" | \"middle\" | \"bottom\";\n\n /**\n * The horizontal alignment of the anchor point.\n * \"left\" aligns the anchor point with left side of the text's bounding box.\n * \"center\" aligns the anchor point with center of the text with's bounding box.\n * \"right\" aligns the anchor point with right side of the text's bounding box.\n */\n horizontal: \"left\" | \"center\" | \"right\";\n}\n\n/** Set of predefined shapes that can be computed and drawn around the margins of a [[TextBlock]]\n * @beta\n*/\nexport const textAnnotationFrameShapes = [\"none\", \"line\", \"rectangle\", \"circle\", \"equilateralTriangle\", \"diamond\", \"square\", \"pentagon\", \"hexagon\", \"octagon\", \"capsule\", \"roundedRectangle\"] as const;\n\n/** Describes a predefined shape that can be computed and drawn around the margins of a [[TextBlock]]\n * @beta\n*/\nexport type TextAnnotationFrameShape = typeof textAnnotationFrameShapes[number];\n\n/**\n * Describes what color to use when filling the frame around a [[TextBlock]].\n * If `background` is specified, [[GeometryParams.BackgroundFill]] will be set to `BackgroundFill.Outline`.\n * @beta\n */\nexport type TextAnnotationFillColor = TextStyleColor | \"background\";\n\n/**\n * Describes how to draw the frame around a [[TextBlock]].\n * The frame can be a simple line, a filled shape, or both.\n * @beta\n */\nexport interface TextFrameStyleProps {\n /** Shape of the frame. Default: \"rectangle\" */\n shape?: TextAnnotationFrameShape;\n /** The color to fill the shape of the text frame. This fill will is applied using [[FillDisplay.Blanking]]. Default: no fill */\n fill?: TextAnnotationFillColor;\n /** The color of the text frame's outline. Default: black */\n border?: TextStyleColor;\n /** This will be used to set the [[GeometryParams.weight]] property of the frame (in pixels). Default: 1px */\n borderWeight?: number;\n}\n\n/**\n * Describes how to attach a [[TextAnnotationLeader]] to the frame around a [[TextBlock]].\n * Leader can be attached using one of the three modes:\n * - KeyPoint: attach to a point on the frame specified by the given curveIndex and fractional position.\n * - TextPoint: attach to a point that is projected on to the frame from the point on a particular line of text specified by [[LeaderTextPointOptions]].\n * - Nearest: attach to the point on frame that is nearest to [[TextAnnotationLeader.startPoint]].\n * @beta\n */\nexport type LeaderAttachment =\n | { mode: \"KeyPoint\"; curveIndex: number; fraction: number }\n | { mode: \"TextPoint\"; position: LeaderTextPointOptions }\n | { mode: \"Nearest\" };\n\n/**\n * Specifies the possible positions to attach a leader on the frame around a [[TextBlock]]\n * when [[TextAnnotationLeader.attachment.mode]] is set to TextPoint.\n * TopLeft : attach to a point projected onto the frame from the point on the left side of the first line of text.\n * TopRight : attach to a point projected onto the frame from the point on the right side of the first line of text.\n * BottomLeft : attach to a point projected onto the frame from the point on the left side of the last line of text.\n * BottomRight : attach to a point projected onto the frame from the point on the right side of the last line of text.\n * @beta\n */\nexport type LeaderTextPointOptions = \"TopLeft\" | \"TopRight\" | \"BottomLeft\" | \"BottomRight\"\n\n/**\n * A line that connects a [[TextAnnotation]] to a point in space relative to another element in the iModel.\n * A leader is always attached to the frame around the annotation's [[TextBlock]].\n * If the frame is not visible, the leader attaches to an invisible rectangular frame around the text block.\n * @see [[TextAnnotation.leaders]] for the leaders associated with an annotation.\n * @see [[TextStyleSettings.leader]] and [[styleOverrides]] to customize the appearance of leaders.\n * @beta\n*/\nexport interface TextAnnotationLeader {\n /** The point where the leader starts.\n * This is the point on another element where the leader points to */\n startPoint: Point3d;\n /** Describes how to attach the leader to the frame around [[textBlock]].*/\n attachment: LeaderAttachment;\n /** Optional intermediate points that the leader should pass through.\n * If not specified, the leader will be a straight line from startPoint to the point on the frame.\n * For now, intermediate points are a set of points which create additional LineSegments in the leader, but there could be intermediate shapes instead of straight LineSegments in future*/\n intermediatePoints?: Point3d[];\n /** Optional style overrides for the leader. If not specified, the leader will use the style defined by [[TextBlock.styleName]] as it is.\n * If specified, these overrides will be applied to the style.\n */\n styleOverrides?: TextStyleSettingsProps;\n}\n/**\n * JSON representation of a [[TextAnnotationLeader]].\n * @beta\n */\nexport interface TextAnnotationLeaderProps {\n /** See [[TextAnnotationLeader.startPoint]]. */\n startPoint: XYZProps;\n /** See [[TextAnnotationLeader.attachment]]. */\n attachment: LeaderAttachment;\n /** See [[TextAnnotationLeader.intermediatePoints]]. Default: no intermediate points. */\n intermediatePoints?: XYZProps[];\n /** See [[TextAnnotationLeader.styleOverrides]]. Default: no style overrides. */\n styleOverrides?: TextStyleSettingsProps;\n}\n\n/**\n\n/**\n * JSON representation of a [[TextAnnotation]].\n * @beta\n */\nexport interface TextAnnotationProps {\n /** See [[TextAnnotation.offset]]. Default: [0, 0, 0]. */\n offset?: XYZProps;\n /** See [[TextAnnotation.orientation]]. Default: no rotation. */\n orientation?: YawPitchRollProps;\n /** See [[TextAnnotation.textBlock]]. Default: an empty text block. */\n textBlock?: TextBlockProps;\n /** See [[TextAnnotation.anchor]]. Default: top-left. */\n anchor?: TextAnnotationAnchor;\n /** See [[TextAnnotation.frame]]. Default: no frame */\n frame?: TextFrameStyleProps;\n /** See [[TextAnnotation.leader]]. Default: an empty leader array */\n leaders?: TextAnnotationLeaderProps[];\n}\n\n/** Arguments supplied to [[TextAnnotation.create]].\n * @beta\n */\nexport interface TextAnnotationCreateArgs {\n /** See [[TextAnnotation.offset]]. Default: (0, 0, 0). */\n offset?: Point3d;\n /** See [[TextAnnotation.orientation]]. Default: no rotation. */\n orientation?: YawPitchRollAngles;\n /** See [[TextAnnotation.textBlock]]. Default: an empty text block. */\n textBlock?: TextBlock;\n /** See [[TextAnnotation.anchor]]. Default: top-left. */\n anchor?: TextAnnotationAnchor;\n /** See [[TextAnnotation.frame]]. Default: no frame */\n frame?: TextFrameStyleProps;\n /** See [[TextAnnotation.leader]]. Default: an empty leader array */\n leaders?: TextAnnotationLeader[];\n}\n\n/**\n * Represents a formatted block of text positioned in 2d or 3d space.\n * [TextAnnotation2d]($backend) and [TextAnnotation3d]($backend) elements store a single TextAnnotation from which their geometric representation is generated.\n * Other types of elements may store multiple TextAnnotations, positioned relative to one another.\n * The annotation's position and orientation relative to the host element's [Placement]($common) is determined as follows:\n * - First, a bounding box is computed enclosing the contents of the [[textBlock].\n * - Then, an \"anchor point\" is computed based on the bounding box and the [[anchor]] property. The anchor point can be at one of the four corners of the box, in the middle of one of its four\n * edges, or in the center of the box.\n * - The [[orientation]] is applied to rotate the box around the anchor point.\n * - Finally, the [[offset]] is added to the anchor point to apply translation.\n * @see [appendTextAnnotationGeometry]($backend) to construct the geometry and append it to an [[ElementGeometry.Builder]].\n * @beta\n */\nexport class TextAnnotation {\n /** The rotation of the annotation.\n * @note When defining an annotation for a [TextAnnotation2d]($backend), only the `yaw` component (rotation around the Z axis) is used.\n */\n public orientation: YawPitchRollAngles;\n /** The formatted document. */\n public textBlock: TextBlock;\n /** Describes how to compute the [[textBlock]]'s anchor point. */\n public anchor: TextAnnotationAnchor;\n /** An offset applied to the anchor point that can be used to position annotations within the same geometry stream relative to one another. */\n public offset: Point3d;\n /** The frame settings of the text annotation. */\n public frame?: TextFrameStyleProps;\n /** The leaders of the text annotation. */\n public leaders?: TextAnnotationLeader[];\n\n private constructor(offset: Point3d, angles: YawPitchRollAngles, textBlock: TextBlock, anchor: TextAnnotationAnchor, frame?: TextFrameStyleProps, leaders?: TextAnnotationLeader[]) {\n this.offset = offset;\n this.orientation = angles;\n this.textBlock = textBlock;\n this.anchor = anchor;\n this.frame = frame;\n this.leaders = leaders;\n }\n\n /** Creates a new TextAnnotation. */\n public static create(args?: TextAnnotationCreateArgs): TextAnnotation {\n const offset = args?.offset ?? new Point3d();\n const angles = args?.orientation ?? new YawPitchRollAngles();\n const textBlock = args?.textBlock ?? TextBlock.createEmpty();\n const anchor = args?.anchor ?? { vertical: \"top\", horizontal: \"left\" };\n // If the user supplies a frame, but doesn't supply a shape, default the shape to \"rectangle\"\n const shape: TextAnnotationFrameShape = args?.frame?.shape ?? \"rectangle\";\n const frame = args?.frame ? { shape, ...args.frame } : undefined;\n const leaders = args?.leaders ?? undefined;\n return new TextAnnotation(offset, angles, textBlock, anchor, frame, leaders);\n }\n\n /**\n * Creates a new TextAnnotation instance from its JSON representation.\n */\n public static fromJSON(props: TextAnnotationProps | undefined): TextAnnotation {\n return TextAnnotation.create({\n offset: props?.offset ? Point3d.fromJSON(props.offset) : undefined,\n orientation: props?.orientation ? YawPitchRollAngles.fromJSON(props.orientation) : undefined,\n textBlock: props?.textBlock ? TextBlock.create(props.textBlock) : undefined,\n anchor: props?.anchor ? { ...props.anchor } : undefined,\n frame: props?.frame ? { shape: \"rectangle\", ...props.frame } : undefined,\n leaders: props?.leaders ? props.leaders.map((leader) => ({\n startPoint: Point3d.fromJSON(leader.startPoint),\n attachment: leader.attachment,\n styleOverrides: leader.styleOverrides ?? undefined,\n intermediatePoints: leader.intermediatePoints ? leader.intermediatePoints.map((point) => Point3d.fromJSON(point)) : undefined,\n })) : undefined,\n });\n }\n\n /**\n * Converts this annotation to its JSON representation.\n */\n public toJSON(): TextAnnotationProps {\n const props: TextAnnotationProps = {};\n\n // Even if the text block is empty, we want to record its style name and overrides, e.g.,\n // so the user can pick up where they left off editing it next time.\n props.textBlock = this.textBlock.toJSON();\n\n if (!this.offset.isZero) {\n props.offset = this.offset.toJSON();\n }\n\n if (!this.orientation.isIdentity()) {\n props.orientation = this.orientation.toJSON();\n }\n\n if (this.anchor.vertical !== \"top\" || this.anchor.horizontal !== \"left\") {\n props.anchor = { ...this.anchor };\n }\n\n // Default frame to \"none\"\n props.frame = this.frame ? { ...this.frame } : undefined;\n\n props.leaders = this.leaders?.map((leader) => ({\n startPoint: leader.startPoint.toJSON(),\n attachment: leader.attachment,\n styleOverrides: leader.styleOverrides ?? undefined,\n intermediatePoints: leader.intermediatePoints ? leader.intermediatePoints.map((point) => point.toJSON()) : undefined,\n })) ?? undefined;\n\n return props;\n }\n\n /** Compute the transform that positions and orients this annotation relative to its anchor point, based on the [[textBlock]]'s computed bounding box.\n * The anchor point is computed as specified by this annotation's [[anchor]] setting. For example, if the text block is anchored\n * at the bottom left, then the transform will be relative to the bottom-left corner of `textBlockExtents`.\n * The text block will be rotated around the fixed anchor point according to [[orientation]], then translated by [[offset]].\n * The anchor point will coincide with (0, 0, 0) unless an [[offset]] is present.\n * @param boundingBox A box fully containing the [[textBlock]]. This range should include the margins.\n * @see [[computeAnchorPoint]] to compute the transform's anchor point.\n * @see [computeLayoutTextBlockResult]($backend) to lay out a `TextBlock`.\n */\n public computeTransform(boundingBox: Range2d): Transform {\n const anchorPt = this.computeAnchorPoint(boundingBox);\n const matrix = this.orientation.toMatrix3d();\n\n const rotation = Transform.createFixedPointAndMatrix(anchorPt, matrix);\n const translation = Transform.createTranslation(this.offset.minus(anchorPt));\n\n return translation.multiplyTransformTransform(rotation, rotation);\n }\n\n /** Compute the anchor point of this annotation as specified by [[anchor]].\n * @param boundingBox A box fully containing the [[textBlock]].\n * @see [[computeTransform]] to compute the transform relative to the anchor point.\n */\n public computeAnchorPoint(boundingBox: Range2d): Point3d {\n let x = boundingBox.low.x;\n let y = boundingBox.high.y;\n\n switch (this.anchor.horizontal) {\n case \"center\":\n x += boundingBox.xLength() / 2;\n break;\n case \"right\":\n x += boundingBox.xLength();\n break;\n }\n\n switch (this.anchor.vertical) {\n case \"middle\":\n y -= boundingBox.yLength() / 2;\n break;\n case \"bottom\":\n y -= boundingBox.yLength();\n break;\n }\n\n return new Point3d(x, y, 0);\n }\n\n /** Returns true if the leaders of this annotation are equal to the leaders of `other`. */\n private areLeadersEqual(leadersA?: TextAnnotationLeader[], leadersB?: TextAnnotationLeader[]): boolean {\n if (leadersA === leadersB) return true;\n if (!leadersA || !leadersB || leadersA.length !== leadersB.length) return false;\n\n for (let i = 0; i < leadersA.length; ++i) {\n const a = leadersA[i];\n const b = leadersB[i];\n\n if (!a.startPoint.isAlmostEqual(b.startPoint)) return false;\n if (JSON.stringify(a.attachment) !== JSON.stringify(b.attachment)) return false;\n if (JSON.stringify(a.styleOverrides) !== JSON.stringify(b.styleOverrides)) return false;\n\n const pointsA = a.intermediatePoints ?? [];\n const pointsB = b.intermediatePoints ?? [];\n if (pointsA.length !== pointsB.length) return false;\n for (let j = 0; j < pointsA.length; ++j) {\n if (!pointsA[j].isAlmostEqual(pointsB[j])) return false;\n }\n }\n return true;\n }\n\n /** Returns true if this annotation is logically equivalent to `other`. */\n public equals(other: TextAnnotation): boolean {\n if (this.anchor.horizontal !== other.anchor.horizontal ||\n this.anchor.vertical !== other.anchor.vertical ||\n !this.orientation.isAlmostEqual(other.orientation) ||\n !this.offset.isAlmostEqual(other.offset) ||\n !this.textBlock.equals(other.textBlock))\n return false;\n\n const framesMatch = this.frame?.shape === other.frame?.shape\n && this.frame?.fill === other.frame?.fill\n && this.frame?.border === other.frame?.border\n && this.frame?.borderWeight === other.frame?.borderWeight;\n\n if (!framesMatch)\n return false;\n\n return this.areLeadersEqual(this.leaders, other.leaders);\n\n }\n}\n"]}
@@ -13,6 +13,35 @@ export type StackedFractionType = "horizontal" | "diagonal";
13
13
  * @beta
14
14
  */
15
15
  export type TextStyleColor = ColorDefProps | "subcategory";
16
+ /** Properties describing the appearance of [[TextAnnotationLeader]] in a [[TextAnnotation]].
17
+ * Used when producing geometry for [[TextAnnotation]].
18
+ * @beta
19
+ */
20
+ export interface TextLeaderStyleProps {
21
+ /** The color of the leader.
22
+ * Default: "subcategory".
23
+ */
24
+ color?: TextStyleColor;
25
+ /** Whether to use an elbow in the leader.
26
+ * Default: false
27
+ */
28
+ wantElbow?: boolean;
29
+ /** Multiplier used to compute length of the elbow in the leader.
30
+ * The elbowLength is computed in meters as elbowLength * [[lineHeight]].
31
+ * Default: 1.0
32
+ */
33
+ elbowLength?: number;
34
+ /** Multiplier to compute height of the leader terminator.
35
+ * The terminator height is computed in meters as terminatorHeight * [[lineHeight]].
36
+ * Default: 1.0
37
+ */
38
+ terminatorHeightFactor?: number;
39
+ /** Multiplier to compute width of the leader terminator.
40
+ * The terminator width is computed in meters as terminatorWidth * [[lineHeight]].
41
+ * Default: 1.0
42
+ */
43
+ terminatorWidthFactor?: number;
44
+ }
16
45
  /** Serves both as the JSON representation of a [[TextStyleSettings]], and a way for a [[TextBlockComponent]] to selectively override aspects of a [[TextStyle]]'s properties.
17
46
  * @beta
18
47
  */
@@ -80,6 +109,11 @@ export interface TextStyleSettingsProps {
80
109
  * Default: 1.0
81
110
  */
82
111
  widthFactor?: number;
112
+ /** Properties describing appearance of leaders in a [[TextAnnotation]]
113
+ * Used when producing geometry for [[TextAnnotation]]
114
+ * Default: {color:"subcategory", wantElbow:"false",elbowLength:1, terminatorWidthFactor:1, terminatorHeightFactor:1}.
115
+ */
116
+ leader?: TextLeaderStyleProps;
83
117
  /** The size (in meters) used to calculate the tab stops in a run.
84
118
  * These are equally spaced from the left edge of the TextBlock.
85
119
  * Default: 4 meters.
@@ -137,6 +171,10 @@ export declare class TextStyleSettings {
137
171
  readonly superScriptScale: number;
138
172
  /** Multiplier used to compute the width of each glyph, relative to [[lineHeight]]. */
139
173
  readonly widthFactor: number;
174
+ /** Properties describing appearance of leaders in a [[TextAnnotation]].
175
+ * Used when producing geometry for [[TextAnnotation]].
176
+ */
177
+ readonly leader: Readonly<Required<TextLeaderStyleProps>>;
140
178
  /** The size (in meters) used to calculate the tab stops in a run.
141
179
  * These are equally spaced from the left edge of the TextBlock. Default is 4 meters.
142
180
  */
@@ -151,6 +189,11 @@ export declare class TextStyleSettings {
151
189
  /** Create settings from their JSON representation. */
152
190
  static fromJSON(props?: TextStyleSettingsProps): TextStyleSettings;
153
191
  toJSON(): TextStyleSettingsProps;
192
+ /** Compare two [[TextLeaderStyleProps]] for equality.
193
+ * @param other The other leader style properties to compare against.
194
+ * @returns true if the two leader styles are equal, false otherwise.
195
+ */
196
+ leaderEquals(other: TextLeaderStyleProps): boolean;
154
197
  equals(other: TextStyleSettings): boolean;
155
198
  }
156
199
  /** The JSON representation of a [[TextStyle]].
@@ -1 +1 @@
1
- {"version":3,"file":"TextStyle.d.ts","sourceRoot":"","sources":["../../../src/annotation/TextStyle.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,YAAY,GAAG,UAAU,CAAC;AAE5D;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG,aAAa,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;uBAGmB;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;OAEG;IACH,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C;;;OAGG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC;;;OAGG;IACH,gBAAgB,CAAC,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EAAE,iBAAiB,CAAC;IAE5C,OAAO;IAKP,mDAAmD;WACrC,QAAQ,CAAC,IAAI,EAAE,cAAc,GAAG,SAAS;IAIvD,0BAA0B;WACZ,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,iBAAiB,GAAG,SAAS;IAI1E,sIAAsI;IAC/H,KAAK,CAAC,eAAe,EAAE,sBAAsB,GAAG,SAAS;IAIzD,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO;CAGzC"}
@@ -59,6 +59,10 @@ class TextStyleSettings {
59
59
  superScriptScale;
60
60
  /** Multiplier used to compute the width of each glyph, relative to [[lineHeight]]. */
61
61
  widthFactor;
62
+ /** Properties describing appearance of leaders in a [[TextAnnotation]].
63
+ * Used when producing geometry for [[TextAnnotation]].
64
+ */
65
+ leader;
62
66
  /** The size (in meters) used to calculate the tab stops in a run.
63
67
  * These are equally spaced from the left edge of the TextBlock. Default is 4 meters.
64
68
  */
@@ -79,6 +83,13 @@ class TextStyleSettings {
79
83
  superScriptOffsetFactor: 0.5,
80
84
  superScriptScale: 2 / 3,
81
85
  widthFactor: 1,
86
+ leader: {
87
+ color: "subcategory",
88
+ wantElbow: false,
89
+ elbowLength: 1.0,
90
+ terminatorHeightFactor: 1.0,
91
+ terminatorWidthFactor: 1.0,
92
+ },
82
93
  tabInterval: 4,
83
94
  };
84
95
  /** Settings initialized to all default values. */
@@ -101,6 +112,14 @@ class TextStyleSettings {
101
112
  this.superScriptOffsetFactor = props.superScriptOffsetFactor ?? defaults.superScriptOffsetFactor;
102
113
  this.superScriptScale = props.superScriptScale ?? defaults.superScriptScale;
103
114
  this.widthFactor = props.widthFactor ?? defaults.widthFactor;
115
+ const leader = {
116
+ color: props.leader?.color ?? defaults.leader.color,
117
+ wantElbow: props.leader?.wantElbow ?? defaults.leader.wantElbow,
118
+ elbowLength: props.leader?.elbowLength ?? defaults.leader.elbowLength,
119
+ terminatorHeightFactor: props.leader?.terminatorHeightFactor ?? defaults.leader.terminatorHeightFactor,
120
+ terminatorWidthFactor: props.leader?.terminatorWidthFactor ?? defaults.leader.terminatorWidthFactor,
121
+ };
122
+ this.leader = Object.freeze(leader);
104
123
  this.tabInterval = props.tabInterval ?? defaults.tabInterval;
105
124
  }
106
125
  /** Create a copy of these settings, modified according to the properties defined by `alteredProps`. */
@@ -114,14 +133,24 @@ class TextStyleSettings {
114
133
  toJSON() {
115
134
  return { ...this };
116
135
  }
136
+ /** Compare two [[TextLeaderStyleProps]] for equality.
137
+ * @param other The other leader style properties to compare against.
138
+ * @returns true if the two leader styles are equal, false otherwise.
139
+ */
140
+ leaderEquals(other) {
141
+ return this.leader.color === other.color && this.leader.wantElbow === other.wantElbow
142
+ && this.leader.elbowLength === other.elbowLength && this.leader.terminatorHeightFactor === other.terminatorHeightFactor
143
+ && this.leader.terminatorWidthFactor === other.terminatorWidthFactor;
144
+ }
117
145
  equals(other) {
118
146
  return this.color === other.color && this.fontName === other.fontName
119
147
  && this.lineHeight === other.lineHeight && this.lineSpacingFactor === other.lineSpacingFactor && this.widthFactor === other.widthFactor
120
148
  && this.isBold === other.isBold && this.isItalic === other.isItalic && this.isUnderlined === other.isUnderlined
121
149
  && this.stackedFractionType === other.stackedFractionType && this.stackedFractionScale === other.stackedFractionScale
122
150
  && this.subScriptOffsetFactor === other.subScriptOffsetFactor && this.subScriptScale === other.subScriptScale
123
- && this.superScriptOffsetFactor === other.superScriptOffsetFactor && this.superScriptScale === other.superScriptScale
124
- && this.tabInterval === other.tabInterval;
151
+ && this.superScriptOffsetFactor === other.superScriptOffsetFactor
152
+ && this.superScriptScale === other.superScriptScale
153
+ && this.tabInterval === other.tabInterval && this.leaderEquals(other.leader);
125
154
  }
126
155
  }
127
156
  exports.TextStyleSettings = TextStyleSettings;
@@ -1 +1 @@
1
- {"version":3,"file":"TextStyle.js","sourceRoot":"","sources":["../../../src/annotation/TextStyle.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AA2FH;;;;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AAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC;AAC9C,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;AAY1C;;;;GAIG;AACH,MAAa,SAAS;IACJ,IAAI,CAAS;IACb,QAAQ,CAAoB;IAE5C,YAAoB,IAAY,EAAE,QAA2B;QAC3D,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,mDAAmD;IAC5C,MAAM,CAAC,QAAQ,CAAC,IAAoB;QACzC,OAAO,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAChF,CAAC;IAED,0BAA0B;IACnB,MAAM,CAAC,MAAM,CAAC,IAAY,EAAE,QAA2B;QAC5D,OAAO,IAAI,SAAS,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACvC,CAAC;IAED,sIAAsI;IAC/H,KAAK,CAAC,eAAuC;QAClD,OAAO,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC;IAC3E,CAAC;IAEM,MAAM,CAAC,KAAgB;QAC5B,OAAO,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC1E,CAAC;CACF;AA3BD,8BA2BC","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 Annotation\n */\n\nimport { ColorDefProps } from \"../ColorDef\";\n\n/** Specifies how to separate the numerator and denominator of a [[FractionRun]], by either a horizontal or diagonal bar.\n * @see [[TextStyleSettingsProps.stackedFractionType]] and [[TextStyleSettings.stackedFractionType]].\n * @beta\n */\nexport type StackedFractionType = \"horizontal\" | \"diagonal\";\n\n/** Describes the color in which to draw the text in a [[TextRun]].\n * \"subcategory\" indicates that the text should be drawn using the color of the [SubCategory]($backend) specified by the [GeometryStream]($docs/learning/common/GeometryStream.md) hosting the\n * text.\n * @beta\n */\nexport type TextStyleColor = ColorDefProps | \"subcategory\";\n\n/** Serves both as the JSON representation of a [[TextStyleSettings]], and a way for a [[TextBlockComponent]] to selectively override aspects of a [[TextStyle]]'s properties.\n * @beta\n */\nexport interface TextStyleSettingsProps {\n /** The color of the text.\n * Default: \"subcategory\".\n */\n color?: TextStyleColor;\n /** The name of a font stored in a [Workspace]($backend), used to draw the contents of a [[TextRun]].\n * Default: \"\" (an invalid font name).\n */\n fontName?: string;\n /** The height each line of text, in meters. Many other settings use the line height as the basis for computing their own values.\n * For example, the height and offset from baseline of a subscript [[TextRun]] are computed as lineHeight * [[subScriptScale]] and\n * lineHeight * [[subScriptOffsetFactor]], respectively.\n * Default: 1.0. */\n lineHeight?: number;\n /** Multiplier used to compute the vertical distance between two lines of text.\n * The distance is computed in meters as lineSpacingFactor * [[lineHeight]].\n * Default: 0.5.\n */\n lineSpacingFactor?: number;\n /** Specifies whether the content of a [[TextRun]] should be rendered **bold**.\n * Default: false.\n */\n isBold?: boolean;\n /** Specifies whether the content of a [[TextRun]] should be rendered in *italics*.\n * Default: false.\n */\n isItalic?: boolean;\n /** Specifies whether the content of a [[TextRun]] should be underlined.\n * Default: false.\n */\n isUnderlined?: boolean;\n /** Multiplier used to compute the height of both the numerator and denominator of a [[FractionRun]].\n * The height is computed in meters as stackedFractionScale * [[lineHeight]].\n * Default: 0.7.\n */\n stackedFractionScale?: number;\n /** Specifies how to separate the numerator and denominator of a [[FractionRun]].\n * Default: \"horizontal\".\n */\n stackedFractionType?: StackedFractionType;\n /** Multiplier used to compute the vertical offset from the baseline for a subscript [[TextRun]].\n * The offset is computed in meters as subScriptOffsetFactor * [[lineHeight]].\n * Default: -0.15.\n */\n subScriptOffsetFactor?: number;\n /** Multiplier used to compute the height of a subscript [[TextRun]].\n * The height is computed as subScriptScale * [[lineHeight]].\n * Default: 2/3\n */\n subScriptScale?: number;\n /** Multiplier used to compute the vertical offset from the baseline for a super [[TextRun]].\n * The offset is computed in meters as superScriptOffsetFactor * [[lineHeight]].\n * Default: -0.5.\n */\n superScriptOffsetFactor?: number;\n /** Multiplier used to compute the height of a superscript [[TextRun]].\n * The height is computed as superScriptScale * [[lineHeight]].\n * Default: 2/3\n */\n superScriptScale?: number;\n /** A scale applied to the width of each glyph.\n * Default: 1.0\n */\n widthFactor?: number;\n /** The size (in meters) used to calculate the tab stops in a run.\n * These are equally spaced from the left edge of the TextBlock.\n * Default: 4 meters.\n */\n tabInterval?: number;\n}\n\n/** A description of the formatting to be applied to a [[TextBlockComponent]].\n * Named instances of these settings can be stored as [[TextStyle]]s in a [Workspace]($backend).\n * @note This is an immutable type. Use [[clone]] to create a modified copy.\n * @see [[TextStyleSettingsProps]] for documentation of each of the settings.\n * @beta\n */\nexport class TextStyleSettings {\n /** The color of the text. */\n public readonly color: TextStyleColor;\n /** The name of a font stored in a [Workspace]($backend), used to draw the contents of a [[TextRun]].\n */\n public readonly fontName: string;\n /** The height each line of text, in meters. Many other settings use the line height as the basis for computing their own values.\n * For example, the height and offset from baseline of a subscript [[TextRun]] are computed as lineHeight * [[subScriptScale]] and\n * lineHeight * [[subScriptOffsetFactor]], respectively.\n */\n public readonly lineHeight: number;\n /** Multiplier used to compute the vertical distance between two lines of text.\n * The distance is computed in meters as lineSpacingFactor * [[lineHeight]].\n */\n public readonly lineSpacingFactor: number;\n /** Specifies whether the content of a [[TextRun]] should be rendered **bold**. */\n public readonly isBold: boolean;\n /** Specifies whether the content of a [[TextRun]] should be rendered in *italics*. */\n public readonly isItalic: boolean;\n /** Specifies whether the content of a [[TextRun]] should be underlined. */\n public readonly isUnderlined: boolean;\n /** Multiplier used to compute the height of both the numerator and denominator of a [[FractionRun]].\n * The height is computed in meters as stackedFractionScale * [[lineHeight]].\n */\n public readonly stackedFractionScale: number;\n /** Specifies how to separate the numerator and denominator of a [[FractionRun]]. */\n public readonly stackedFractionType: StackedFractionType;\n /** Multiplier used to compute the vertical offset from the baseline for a subscript [[TextRun]].\n * The offset is computed in meters as subScriptOffsetFactor * [[lineHeight]].\n */\n public readonly subScriptOffsetFactor: number;\n /** Multiplier used to compute the height of a subscript [[TextRun]].\n * The height is computed as subScriptScale * [[lineHeight]].\n */\n public readonly subScriptScale: number;\n /** Multiplier used to compute the vertical offset from the baseline for a super [[TextRun]].\n * The offset is computed in meters as superScriptOffsetFactor * [[lineHeight]].\n */\n public readonly superScriptOffsetFactor: number;\n /** Multiplier used to compute the height of a superscript [[TextRun]].\n * The height is computed as superScriptScale * [[lineHeight]].\n */\n public readonly superScriptScale: number;\n /** Multiplier used to compute the width of each glyph, relative to [[lineHeight]]. */\n public readonly widthFactor: number;\n /** The size (in meters) used to calculate the tab stops in a run.\n * These are equally spaced from the left edge of the TextBlock. Default is 4 meters.\n */\n public readonly tabInterval: number;\n\n /** A fully-populated JSON representation of the default settings. */\n public static defaultProps: Readonly<Required<TextStyleSettingsProps>> = {\n color: \"subcategory\",\n fontName: \"\",\n lineHeight: 1,\n lineSpacingFactor: 0.5,\n isBold: false,\n isItalic: false,\n isUnderlined: false,\n stackedFractionScale: 0.7,\n stackedFractionType: \"horizontal\",\n subScriptOffsetFactor: -0.15,\n subScriptScale: 2 / 3,\n superScriptOffsetFactor: 0.5,\n superScriptScale: 2 / 3,\n widthFactor: 1,\n tabInterval: 4,\n };\n\n /** Settings initialized to all default values. */\n public static defaults: TextStyleSettings = new TextStyleSettings({ });\n\n private constructor(props: TextStyleSettingsProps, defaults?: Required<TextStyleSettingsProps>) {\n if (!defaults) {\n defaults = TextStyleSettings.defaultProps;\n }\n\n this.color = props.color ?? defaults.color;\n this.fontName = props.fontName ?? defaults.fontName;\n this.lineHeight = props.lineHeight ?? defaults.lineHeight;\n this.lineSpacingFactor = props.lineSpacingFactor ?? defaults.lineSpacingFactor;\n this.isBold = props.isBold ?? defaults.isBold;\n this.isItalic = props.isItalic ?? defaults.isItalic;\n this.isUnderlined = props.isUnderlined ?? defaults.isUnderlined;\n this.stackedFractionScale = props.stackedFractionScale ?? defaults.stackedFractionScale;\n this.stackedFractionType = props.stackedFractionType ?? defaults.stackedFractionType;\n this.subScriptOffsetFactor = props.subScriptOffsetFactor ?? defaults.subScriptOffsetFactor;\n this.subScriptScale = props.subScriptScale ?? defaults.subScriptScale;\n this.superScriptOffsetFactor = props.superScriptOffsetFactor ?? defaults.superScriptOffsetFactor;\n this.superScriptScale = props.superScriptScale ?? defaults.superScriptScale;\n this.widthFactor = props.widthFactor ?? defaults.widthFactor;\n this.tabInterval = props.tabInterval ?? defaults.tabInterval;\n }\n\n /** Create a copy of these settings, modified according to the properties defined by `alteredProps`. */\n public clone(alteredProps?: TextStyleSettingsProps): TextStyleSettings {\n return alteredProps ? new TextStyleSettings(alteredProps, this) : this;\n }\n\n /** Create settings from their JSON representation. */\n public static fromJSON(props?: TextStyleSettingsProps): TextStyleSettings {\n return props ? new TextStyleSettings(props) : TextStyleSettings.defaults;\n }\n\n public toJSON(): TextStyleSettingsProps {\n return { ...this };\n }\n\n public equals(other: TextStyleSettings): boolean {\n return this.color === other.color && this.fontName === other.fontName\n && this.lineHeight === other.lineHeight && this.lineSpacingFactor === other.lineSpacingFactor && this.widthFactor === other.widthFactor\n && this.isBold === other.isBold && this.isItalic === other.isItalic && this.isUnderlined === other.isUnderlined\n && this.stackedFractionType === other.stackedFractionType && this.stackedFractionScale === other.stackedFractionScale\n && this.subScriptOffsetFactor === other.subScriptOffsetFactor && this.subScriptScale === other.subScriptScale\n && this.superScriptOffsetFactor === other.superScriptOffsetFactor && this.superScriptScale === other.superScriptScale\n && this.tabInterval === other.tabInterval;\n }\n}\n\nObject.freeze(TextStyleSettings.defaultProps);\nObject.freeze(TextStyleSettings.defaults);\n\n/** The JSON representation of a [[TextStyle]].\n * @beta\n */\nexport interface TextStyleProps {\n /** The name of the style. */\n name: string;\n /** The settings defined for the style. Any omitted properties will use their default values, as described by [[TextStyleSettingsProps]]. */\n settings?: TextStyleSettingsProps;\n}\n\n/** A named, immutable [[TextStyleSettings]] stored in a [Workspace]($backend).\n * @see [[TextBlockComponent.styleName]] to define the text style for a component of a [[TextBlock]].\n * @note This is an immutable type. Use [[clone]] to create a modified copy.\n * @beta\n */\nexport class TextStyle {\n public readonly name: string;\n public readonly settings: TextStyleSettings;\n\n private constructor(name: string, settings: TextStyleSettings) {\n this.name = name;\n this.settings = settings;\n }\n\n /** Create a style from its JSON representation. */\n public static fromJSON(json: TextStyleProps): TextStyle {\n return TextStyle.create(json.name, TextStyleSettings.fromJSON(json.settings));\n }\n\n /** Create a new style. */\n public static create(name: string, settings: TextStyleSettings): TextStyle {\n return new TextStyle(name, settings);\n }\n\n /** Create a copy of this style with the same name, and settings modified according to the properties defined by `alteredSettings`. */\n public clone(alteredSettings: TextStyleSettingsProps): TextStyle {\n return TextStyle.create(this.name, this.settings.clone(alteredSettings));\n }\n\n public equals(other: TextStyle): boolean {\n return this.name === other.name && this.settings.equals(other.settings);\n }\n}\n\n"]}
1
+ {"version":3,"file":"TextStyle.js","sourceRoot":"","sources":["../../../src/annotation/TextStyle.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AA+HH;;;;;GAKG;AACH,MAAa,iBAAiB;IAC5B,6BAA6B;IACb,KAAK,CAAiB;IACtC;OACG;IACa,QAAQ,CAAS;IACjC;;;OAGG;IACa,UAAU,CAAS;IACnC;;OAEG;IACa,iBAAiB,CAAS;IAC1C,kFAAkF;IAClE,MAAM,CAAU;IAChC,sFAAsF;IACtE,QAAQ,CAAU;IAClC,2EAA2E;IAC3D,YAAY,CAAU;IACtC;;OAEG;IACa,oBAAoB,CAAS;IA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Q,CAAC,IAAoB;QACzC,OAAO,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAChF,CAAC;IAED,0BAA0B;IACnB,MAAM,CAAC,MAAM,CAAC,IAAY,EAAE,QAA2B;QAC5D,OAAO,IAAI,SAAS,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACvC,CAAC;IAED,sIAAsI;IAC/H,KAAK,CAAC,eAAuC;QAClD,OAAO,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC;IAC3E,CAAC;IAEM,MAAM,CAAC,KAAgB;QAC5B,OAAO,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC1E,CAAC;CACF;AA3BD,8BA2BC","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 Annotation\n */\n\nimport { ColorDefProps } from \"../ColorDef\";\n\n/** Specifies how to separate the numerator and denominator of a [[FractionRun]], by either a horizontal or diagonal bar.\n * @see [[TextStyleSettingsProps.stackedFractionType]] and [[TextStyleSettings.stackedFractionType]].\n * @beta\n */\nexport type StackedFractionType = \"horizontal\" | \"diagonal\";\n\n/** Describes the color in which to draw the text in a [[TextRun]].\n * \"subcategory\" indicates that the text should be drawn using the color of the [SubCategory]($backend) specified by the [GeometryStream]($docs/learning/common/GeometryStream.md) hosting the\n * text.\n * @beta\n */\nexport type TextStyleColor = ColorDefProps | \"subcategory\";\n\n/** Properties describing the appearance of [[TextAnnotationLeader]] in a [[TextAnnotation]].\n * Used when producing geometry for [[TextAnnotation]].\n * @beta\n */\nexport interface TextLeaderStyleProps {\n /** The color of the leader.\n * Default: \"subcategory\".\n */\n color?: TextStyleColor;\n /** Whether to use an elbow in the leader.\n * Default: false\n */\n wantElbow?: boolean;\n /** Multiplier used to compute length of the elbow in the leader.\n * The elbowLength is computed in meters as elbowLength * [[lineHeight]].\n * Default: 1.0\n */\n elbowLength?: number;\n /** Multiplier to compute height of the leader terminator.\n * The terminator height is computed in meters as terminatorHeight * [[lineHeight]].\n * Default: 1.0\n */\n terminatorHeightFactor?: number;\n /** Multiplier to compute width of the leader terminator.\n * The terminator width is computed in meters as terminatorWidth * [[lineHeight]].\n * Default: 1.0\n */\n terminatorWidthFactor?: number;\n}\n\n/** Serves both as the JSON representation of a [[TextStyleSettings]], and a way for a [[TextBlockComponent]] to selectively override aspects of a [[TextStyle]]'s properties.\n * @beta\n */\nexport interface TextStyleSettingsProps {\n /** The color of the text.\n * Default: \"subcategory\".\n */\n color?: TextStyleColor;\n /** The name of a font stored in a [Workspace]($backend), used to draw the contents of a [[TextRun]].\n * Default: \"\" (an invalid font name).\n */\n fontName?: string;\n /** The height each line of text, in meters. Many other settings use the line height as the basis for computing their own values.\n * For example, the height and offset from baseline of a subscript [[TextRun]] are computed as lineHeight * [[subScriptScale]] and\n * lineHeight * [[subScriptOffsetFactor]], respectively.\n * Default: 1.0. */\n lineHeight?: number;\n /** Multiplier used to compute the vertical distance between two lines of text.\n * The distance is computed in meters as lineSpacingFactor * [[lineHeight]].\n * Default: 0.5.\n */\n lineSpacingFactor?: number;\n /** Specifies whether the content of a [[TextRun]] should be rendered **bold**.\n * Default: false.\n */\n isBold?: boolean;\n /** Specifies whether the content of a [[TextRun]] should be rendered in *italics*.\n * Default: false.\n */\n isItalic?: boolean;\n /** Specifies whether the content of a [[TextRun]] should be underlined.\n * Default: false.\n */\n isUnderlined?: boolean;\n /** Multiplier used to compute the height of both the numerator and denominator of a [[FractionRun]].\n * The height is computed in meters as stackedFractionScale * [[lineHeight]].\n * Default: 0.7.\n */\n stackedFractionScale?: number;\n /** Specifies how to separate the numerator and denominator of a [[FractionRun]].\n * Default: \"horizontal\".\n */\n stackedFractionType?: StackedFractionType;\n /** Multiplier used to compute the vertical offset from the baseline for a subscript [[TextRun]].\n * The offset is computed in meters as subScriptOffsetFactor * [[lineHeight]].\n * Default: -0.15.\n */\n subScriptOffsetFactor?: number;\n /** Multiplier used to compute the height of a subscript [[TextRun]].\n * The height is computed as subScriptScale * [[lineHeight]].\n * Default: 2/3\n */\n subScriptScale?: number;\n /** Multiplier used to compute the vertical offset from the baseline for a super [[TextRun]].\n * The offset is computed in meters as superScriptOffsetFactor * [[lineHeight]].\n * Default: -0.5.\n */\n superScriptOffsetFactor?: number;\n /** Multiplier used to compute the height of a superscript [[TextRun]].\n * The height is computed as superScriptScale * [[lineHeight]].\n * Default: 2/3\n */\n superScriptScale?: number;\n /** A scale applied to the width of each glyph.\n * Default: 1.0\n */\n widthFactor?: number;\n\n /** Properties describing appearance of leaders in a [[TextAnnotation]]\n * Used when producing geometry for [[TextAnnotation]]\n * Default: {color:\"subcategory\", wantElbow:\"false\",elbowLength:1, terminatorWidthFactor:1, terminatorHeightFactor:1}.\n */\n leader?: TextLeaderStyleProps;\n /** The size (in meters) used to calculate the tab stops in a run.\n * These are equally spaced from the left edge of the TextBlock.\n * Default: 4 meters.\n */\n tabInterval?: number;\n}\n\n/** A description of the formatting to be applied to a [[TextBlockComponent]].\n * Named instances of these settings can be stored as [[TextStyle]]s in a [Workspace]($backend).\n * @note This is an immutable type. Use [[clone]] to create a modified copy.\n * @see [[TextStyleSettingsProps]] for documentation of each of the settings.\n * @beta\n */\nexport class TextStyleSettings {\n /** The color of the text. */\n public readonly color: TextStyleColor;\n /** The name of a font stored in a [Workspace]($backend), used to draw the contents of a [[TextRun]].\n */\n public readonly fontName: string;\n /** The height each line of text, in meters. Many other settings use the line height as the basis for computing their own values.\n * For example, the height and offset from baseline of a subscript [[TextRun]] are computed as lineHeight * [[subScriptScale]] and\n * lineHeight * [[subScriptOffsetFactor]], respectively.\n */\n public readonly lineHeight: number;\n /** Multiplier used to compute the vertical distance between two lines of text.\n * The distance is computed in meters as lineSpacingFactor * [[lineHeight]].\n */\n public readonly lineSpacingFactor: number;\n /** Specifies whether the content of a [[TextRun]] should be rendered **bold**. */\n public readonly isBold: boolean;\n /** Specifies whether the content of a [[TextRun]] should be rendered in *italics*. */\n public readonly isItalic: boolean;\n /** Specifies whether the content of a [[TextRun]] should be underlined. */\n public readonly isUnderlined: boolean;\n /** Multiplier used to compute the height of both the numerator and denominator of a [[FractionRun]].\n * The height is computed in meters as stackedFractionScale * [[lineHeight]].\n */\n public readonly stackedFractionScale: number;\n /** Specifies how to separate the numerator and denominator of a [[FractionRun]]. */\n public readonly stackedFractionType: StackedFractionType;\n /** Multiplier used to compute the vertical offset from the baseline for a subscript [[TextRun]].\n * The offset is computed in meters as subScriptOffsetFactor * [[lineHeight]].\n */\n public readonly subScriptOffsetFactor: number;\n /** Multiplier used to compute the height of a subscript [[TextRun]].\n * The height is computed as subScriptScale * [[lineHeight]].\n */\n public readonly subScriptScale: number;\n /** Multiplier used to compute the vertical offset from the baseline for a super [[TextRun]].\n * The offset is computed in meters as superScriptOffsetFactor * [[lineHeight]].\n */\n public readonly superScriptOffsetFactor: number;\n /** Multiplier used to compute the height of a superscript [[TextRun]].\n * The height is computed as superScriptScale * [[lineHeight]].\n */\n public readonly superScriptScale: number;\n /** Multiplier used to compute the width of each glyph, relative to [[lineHeight]]. */\n public readonly widthFactor: number;\n /** Properties describing appearance of leaders in a [[TextAnnotation]].\n * Used when producing geometry for [[TextAnnotation]].\n */\n public readonly leader: Readonly<Required<TextLeaderStyleProps>>;\n /** The size (in meters) used to calculate the tab stops in a run.\n * These are equally spaced from the left edge of the TextBlock. Default is 4 meters.\n */\n public readonly tabInterval: number;\n\n /** A fully-populated JSON representation of the default settings. */\n public static defaultProps: Readonly<Required<TextStyleSettingsProps>> = {\n color: \"subcategory\",\n fontName: \"\",\n lineHeight: 1,\n lineSpacingFactor: 0.5,\n isBold: false,\n isItalic: false,\n isUnderlined: false,\n stackedFractionScale: 0.7,\n stackedFractionType: \"horizontal\",\n subScriptOffsetFactor: -0.15,\n subScriptScale: 2 / 3,\n superScriptOffsetFactor: 0.5,\n superScriptScale: 2 / 3,\n widthFactor: 1,\n leader: {\n color: \"subcategory\",\n wantElbow: false,\n elbowLength: 1.0,\n terminatorHeightFactor: 1.0,\n terminatorWidthFactor: 1.0,\n },\n tabInterval: 4,\n };\n\n /** Settings initialized to all default values. */\n public static defaults: TextStyleSettings = new TextStyleSettings({});\n\n private constructor(props: TextStyleSettingsProps, defaults?: Required<TextStyleSettingsProps>) {\n if (!defaults) {\n defaults = TextStyleSettings.defaultProps;\n }\n\n this.color = props.color ?? defaults.color;\n this.fontName = props.fontName ?? defaults.fontName;\n this.lineHeight = props.lineHeight ?? defaults.lineHeight;\n this.lineSpacingFactor = props.lineSpacingFactor ?? defaults.lineSpacingFactor;\n this.isBold = props.isBold ?? defaults.isBold;\n this.isItalic = props.isItalic ?? defaults.isItalic;\n this.isUnderlined = props.isUnderlined ?? defaults.isUnderlined;\n this.stackedFractionScale = props.stackedFractionScale ?? defaults.stackedFractionScale;\n this.stackedFractionType = props.stackedFractionType ?? defaults.stackedFractionType;\n this.subScriptOffsetFactor = props.subScriptOffsetFactor ?? defaults.subScriptOffsetFactor;\n this.subScriptScale = props.subScriptScale ?? defaults.subScriptScale;\n this.superScriptOffsetFactor = props.superScriptOffsetFactor ?? defaults.superScriptOffsetFactor;\n this.superScriptScale = props.superScriptScale ?? defaults.superScriptScale;\n this.widthFactor = props.widthFactor ?? defaults.widthFactor;\n const leader = {\n color: props.leader?.color ?? defaults.leader.color,\n wantElbow: props.leader?.wantElbow ?? defaults.leader.wantElbow,\n elbowLength: props.leader?.elbowLength ?? defaults.leader.elbowLength,\n terminatorHeightFactor: props.leader?.terminatorHeightFactor ?? defaults.leader.terminatorHeightFactor,\n terminatorWidthFactor: props.leader?.terminatorWidthFactor ?? defaults.leader.terminatorWidthFactor,\n }\n this.leader = Object.freeze(leader) as Readonly<Required<TextLeaderStyleProps>>;\n this.tabInterval = props.tabInterval ?? defaults.tabInterval;\n }\n\n /** Create a copy of these settings, modified according to the properties defined by `alteredProps`. */\n public clone(alteredProps?: TextStyleSettingsProps): TextStyleSettings {\n return alteredProps ? new TextStyleSettings(alteredProps, this) : this;\n }\n\n /** Create settings from their JSON representation. */\n public static fromJSON(props?: TextStyleSettingsProps): TextStyleSettings {\n return props ? new TextStyleSettings(props) : TextStyleSettings.defaults;\n }\n\n public toJSON(): TextStyleSettingsProps {\n return { ...this };\n }\n /** Compare two [[TextLeaderStyleProps]] for equality.\n * @param other The other leader style properties to compare against.\n * @returns true if the two leader styles are equal, false otherwise.\n */\n public leaderEquals(other: TextLeaderStyleProps): boolean {\n return this.leader.color === other.color && this.leader.wantElbow === other.wantElbow\n && this.leader.elbowLength === other.elbowLength && this.leader.terminatorHeightFactor === other.terminatorHeightFactor\n && this.leader.terminatorWidthFactor === other.terminatorWidthFactor;\n }\n\n public equals(other: TextStyleSettings): boolean {\n return this.color === other.color && this.fontName === other.fontName\n && this.lineHeight === other.lineHeight && this.lineSpacingFactor === other.lineSpacingFactor && this.widthFactor === other.widthFactor\n && this.isBold === other.isBold && this.isItalic === other.isItalic && this.isUnderlined === other.isUnderlined\n && this.stackedFractionType === other.stackedFractionType && this.stackedFractionScale === other.stackedFractionScale\n && this.subScriptOffsetFactor === other.subScriptOffsetFactor && this.subScriptScale === other.subScriptScale\n && this.superScriptOffsetFactor === other.superScriptOffsetFactor\n && this.superScriptScale === other.superScriptScale\n && this.tabInterval === other.tabInterval && this.leaderEquals(other.leader);\n }\n}\n\nObject.freeze(TextStyleSettings.defaultProps);\nObject.freeze(TextStyleSettings.defaults);\n\n/** The JSON representation of a [[TextStyle]].\n * @beta\n */\nexport interface TextStyleProps {\n /** The name of the style. */\n name: string;\n /** The settings defined for the style. Any omitted properties will use their default values, as described by [[TextStyleSettingsProps]]. */\n settings?: TextStyleSettingsProps;\n}\n\n/** A named, immutable [[TextStyleSettings]] stored in a [Workspace]($backend).\n * @see [[TextBlockComponent.styleName]] to define the text style for a component of a [[TextBlock]].\n * @note This is an immutable type. Use [[clone]] to create a modified copy.\n * @beta\n */\nexport class TextStyle {\n public readonly name: string;\n public readonly settings: TextStyleSettings;\n\n private constructor(name: string, settings: TextStyleSettings) {\n this.name = name;\n this.settings = settings;\n }\n\n /** Create a style from its JSON representation. */\n public static fromJSON(json: TextStyleProps): TextStyle {\n return TextStyle.create(json.name, TextStyleSettings.fromJSON(json.settings));\n }\n\n /** Create a new style. */\n public static create(name: string, settings: TextStyleSettings): TextStyle {\n return new TextStyle(name, settings);\n }\n\n /** Create a copy of this style with the same name, and settings modified according to the properties defined by `alteredSettings`. */\n public clone(alteredSettings: TextStyleSettingsProps): TextStyle {\n return TextStyle.create(this.name, this.settings.clone(alteredSettings));\n }\n\n public equals(other: TextStyle): boolean {\n return this.name === other.name && this.settings.equals(other.settings);\n }\n}\n\n"]}
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import { Point3d, Range2d, Transform, XYZProps, YawPitchRollAngles, YawPitchRollProps } from "@itwin/core-geometry";
5
5
  import { TextBlock, TextBlockProps } from "./TextBlock";
6
- import { TextStyleColor } from "./TextStyle";
6
+ import { TextStyleColor, TextStyleSettingsProps } from "./TextStyle";
7
7
  /** Describes how to compute the "anchor point" for a [[TextAnnotation]].
8
8
  * The anchor point is a point on or inside of the 2d bounding box enclosing the contents of the annotation's [[TextBlock]].
9
9
  * The annotation can be rotated and translated relative to the anchor point. The anchor point also serves as the snap point
@@ -57,6 +57,73 @@ export interface TextFrameStyleProps {
57
57
  /** This will be used to set the [[GeometryParams.weight]] property of the frame (in pixels). Default: 1px */
58
58
  borderWeight?: number;
59
59
  }
60
+ /**
61
+ * Describes how to attach a [[TextAnnotationLeader]] to the frame around a [[TextBlock]].
62
+ * Leader can be attached using one of the three modes:
63
+ * - KeyPoint: attach to a point on the frame specified by the given curveIndex and fractional position.
64
+ * - TextPoint: attach to a point that is projected on to the frame from the point on a particular line of text specified by [[LeaderTextPointOptions]].
65
+ * - Nearest: attach to the point on frame that is nearest to [[TextAnnotationLeader.startPoint]].
66
+ * @beta
67
+ */
68
+ export type LeaderAttachment = {
69
+ mode: "KeyPoint";
70
+ curveIndex: number;
71
+ fraction: number;
72
+ } | {
73
+ mode: "TextPoint";
74
+ position: LeaderTextPointOptions;
75
+ } | {
76
+ mode: "Nearest";
77
+ };
78
+ /**
79
+ * Specifies the possible positions to attach a leader on the frame around a [[TextBlock]]
80
+ * when [[TextAnnotationLeader.attachment.mode]] is set to TextPoint.
81
+ * TopLeft : attach to a point projected onto the frame from the point on the left side of the first line of text.
82
+ * TopRight : attach to a point projected onto the frame from the point on the right side of the first line of text.
83
+ * BottomLeft : attach to a point projected onto the frame from the point on the left side of the last line of text.
84
+ * BottomRight : attach to a point projected onto the frame from the point on the right side of the last line of text.
85
+ * @beta
86
+ */
87
+ export type LeaderTextPointOptions = "TopLeft" | "TopRight" | "BottomLeft" | "BottomRight";
88
+ /**
89
+ * A line that connects a [[TextAnnotation]] to a point in space relative to another element in the iModel.
90
+ * A leader is always attached to the frame around the annotation's [[TextBlock]].
91
+ * If the frame is not visible, the leader attaches to an invisible rectangular frame around the text block.
92
+ * @see [[TextAnnotation.leaders]] for the leaders associated with an annotation.
93
+ * @see [[TextStyleSettings.leader]] and [[styleOverrides]] to customize the appearance of leaders.
94
+ * @beta
95
+ */
96
+ export interface TextAnnotationLeader {
97
+ /** The point where the leader starts.
98
+ * This is the point on another element where the leader points to */
99
+ startPoint: Point3d;
100
+ /** Describes how to attach the leader to the frame around [[textBlock]].*/
101
+ attachment: LeaderAttachment;
102
+ /** Optional intermediate points that the leader should pass through.
103
+ * If not specified, the leader will be a straight line from startPoint to the point on the frame.
104
+ * For now, intermediate points are a set of points which create additional LineSegments in the leader, but there could be intermediate shapes instead of straight LineSegments in future*/
105
+ intermediatePoints?: Point3d[];
106
+ /** Optional style overrides for the leader. If not specified, the leader will use the style defined by [[TextBlock.styleName]] as it is.
107
+ * If specified, these overrides will be applied to the style.
108
+ */
109
+ styleOverrides?: TextStyleSettingsProps;
110
+ }
111
+ /**
112
+ * JSON representation of a [[TextAnnotationLeader]].
113
+ * @beta
114
+ */
115
+ export interface TextAnnotationLeaderProps {
116
+ /** See [[TextAnnotationLeader.startPoint]]. */
117
+ startPoint: XYZProps;
118
+ /** See [[TextAnnotationLeader.attachment]]. */
119
+ attachment: LeaderAttachment;
120
+ /** See [[TextAnnotationLeader.intermediatePoints]]. Default: no intermediate points. */
121
+ intermediatePoints?: XYZProps[];
122
+ /** See [[TextAnnotationLeader.styleOverrides]]. Default: no style overrides. */
123
+ styleOverrides?: TextStyleSettingsProps;
124
+ }
125
+ /**
126
+
60
127
  /**
61
128
  * JSON representation of a [[TextAnnotation]].
62
129
  * @beta
@@ -72,6 +139,8 @@ export interface TextAnnotationProps {
72
139
  anchor?: TextAnnotationAnchor;
73
140
  /** See [[TextAnnotation.frame]]. Default: no frame */
74
141
  frame?: TextFrameStyleProps;
142
+ /** See [[TextAnnotation.leader]]. Default: an empty leader array */
143
+ leaders?: TextAnnotationLeaderProps[];
75
144
  }
76
145
  /** Arguments supplied to [[TextAnnotation.create]].
77
146
  * @beta
@@ -87,6 +156,8 @@ export interface TextAnnotationCreateArgs {
87
156
  anchor?: TextAnnotationAnchor;
88
157
  /** See [[TextAnnotation.frame]]. Default: no frame */
89
158
  frame?: TextFrameStyleProps;
159
+ /** See [[TextAnnotation.leader]]. Default: an empty leader array */
160
+ leaders?: TextAnnotationLeader[];
90
161
  }
91
162
  /**
92
163
  * Represents a formatted block of text positioned in 2d or 3d space.
@@ -114,6 +185,8 @@ export declare class TextAnnotation {
114
185
  offset: Point3d;
115
186
  /** The frame settings of the text annotation. */
116
187
  frame?: TextFrameStyleProps;
188
+ /** The leaders of the text annotation. */
189
+ leaders?: TextAnnotationLeader[];
117
190
  private constructor();
118
191
  /** Creates a new TextAnnotation. */
119
192
  static create(args?: TextAnnotationCreateArgs): TextAnnotation;
@@ -140,6 +213,8 @@ export declare class TextAnnotation {
140
213
  * @see [[computeTransform]] to compute the transform relative to the anchor point.
141
214
  */
142
215
  computeAnchorPoint(boundingBox: Range2d): Point3d;
216
+ /** Returns true if the leaders of this annotation are equal to the leaders of `other`. */
217
+ private areLeadersEqual;
143
218
  /** Returns true if this annotation is logically equivalent to `other`. */
144
219
  equals(other: TextAnnotation): boolean;
145
220
  }
@@ -1 +1 @@
1
- {"version":3,"file":"TextAnnotation.d.ts","sourceRoot":"","sources":["../../../src/annotation/TextAnnotation.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACpH,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C;;;;;;;GAOG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;;OAKG;IACH,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAEtC;;;;;OAKG;IACH,UAAU,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;CACzC;AAED;;EAEE;AACF,eAAO,MAAM,yBAAyB,+JAAgK,CAAC;AAEvM;;EAEE;AACF,MAAM,MAAM,wBAAwB,GAAG,OAAO,yBAAyB,CAAC,MAAM,CAAC,CAAC;AAEhF;;;;GAIG;AACH,MAAM,MAAM,uBAAuB,GAAG,cAAc,GAAG,YAAY,CAAC;AAEpE;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,+CAA+C;IAC/C,KAAK,CAAC,EAAE,wBAAwB,CAAC;IACjC,gIAAgI;IAChI,IAAI,CAAC,EAAE,uBAAuB,CAAC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M,WAAW,wBAAwB;IACvC,yDAAyD;IACzD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,gEAAgE;IAChE,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC,sEAAsE;IACtE,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,wDAAwD;IACxD,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,sDAAsD;IACtD,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B,qEAAqE;IACrE,OAAO,CAAC,EAAE,oBAAoB,EAAE,CAAC;CAClC;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,cAAc;IACzB;;OAEG;IACI,WAAW,EAAE,kBAAkB,CAAC;IACvC,8BAA8B;IACvB,SAAS,EAAE,SAAS,CAAC;IAC5B,iEAAiE;IAC1D,MAAM,EAAE,oBAAoB,CAAC;IACpC,8IAA8I;IACvI,MAAM,EAAE,OAAO,CAAC;IACvB,iDAAiD;IAC1C,KAAK,CAAC,EAAE,mBAAmB,CAAC;IACnC,0CAA0C;IACnC,OAAO,CAAC,EAAE,oBAAoB,EAAE,CAAC;IAExC,OAAO;IASP,oCAAoC;WACtB,MAAM,CAAC,IAAI,CAAC,EAAE,wBAAwB,GAAG,cAAc;IAYrE;;OAEG;WACW,QAAQ,CAAC,KAAK,EAAE,mBAAmB,GAAG,SAAS,GAAG,cAAc;IAgB9E;;OAEG;IACI,MAAM,IAAI,mBAAmB;IAgCpC;;;;;;;;OAQG;IACI,gBAAgB,CAAC,WAAW,EAAE,OAAO,GAAG,SAAS;IAUxD;;;OAGG;IACI,kBAAkB,CAAC,WAAW,EAAE,OAAO,GAAG,OAAO;IAyBxD,0FAA0F;IAC1F,OAAO,CAAC,eAAe;IAsBvB,0EAA0E;IACnE,MAAM,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO;CAmB9C"}
@@ -37,12 +37,15 @@ export class TextAnnotation {
37
37
  offset;
38
38
  /** The frame settings of the text annotation. */
39
39
  frame;
40
- constructor(offset, angles, textBlock, anchor, frame) {
40
+ /** The leaders of the text annotation. */
41
+ leaders;
42
+ constructor(offset, angles, textBlock, anchor, frame, leaders) {
41
43
  this.offset = offset;
42
44
  this.orientation = angles;
43
45
  this.textBlock = textBlock;
44
46
  this.anchor = anchor;
45
47
  this.frame = frame;
48
+ this.leaders = leaders;
46
49
  }
47
50
  /** Creates a new TextAnnotation. */
48
51
  static create(args) {
@@ -53,7 +56,8 @@ export class TextAnnotation {
53
56
  // If the user supplies a frame, but doesn't supply a shape, default the shape to "rectangle"
54
57
  const shape = args?.frame?.shape ?? "rectangle";
55
58
  const frame = args?.frame ? { shape, ...args.frame } : undefined;
56
- return new TextAnnotation(offset, angles, textBlock, anchor, frame);
59
+ const leaders = args?.leaders ?? undefined;
60
+ return new TextAnnotation(offset, angles, textBlock, anchor, frame, leaders);
57
61
  }
58
62
  /**
59
63
  * Creates a new TextAnnotation instance from its JSON representation.
@@ -65,6 +69,12 @@ export class TextAnnotation {
65
69
  textBlock: props?.textBlock ? TextBlock.create(props.textBlock) : undefined,
66
70
  anchor: props?.anchor ? { ...props.anchor } : undefined,
67
71
  frame: props?.frame ? { shape: "rectangle", ...props.frame } : undefined,
72
+ leaders: props?.leaders ? props.leaders.map((leader) => ({
73
+ startPoint: Point3d.fromJSON(leader.startPoint),
74
+ attachment: leader.attachment,
75
+ styleOverrides: leader.styleOverrides ?? undefined,
76
+ intermediatePoints: leader.intermediatePoints ? leader.intermediatePoints.map((point) => Point3d.fromJSON(point)) : undefined,
77
+ })) : undefined,
68
78
  });
69
79
  }
70
80
  /**
@@ -86,6 +96,12 @@ export class TextAnnotation {
86
96
  }
87
97
  // Default frame to "none"
88
98
  props.frame = this.frame ? { ...this.frame } : undefined;
99
+ props.leaders = this.leaders?.map((leader) => ({
100
+ startPoint: leader.startPoint.toJSON(),
101
+ attachment: leader.attachment,
102
+ styleOverrides: leader.styleOverrides ?? undefined,
103
+ intermediatePoints: leader.intermediatePoints ? leader.intermediatePoints.map((point) => point.toJSON()) : undefined,
104
+ })) ?? undefined;
89
105
  return props;
90
106
  }
91
107
  /** Compute the transform that positions and orients this annotation relative to its anchor point, based on the [[textBlock]]'s computed bounding box.
@@ -129,16 +145,47 @@ export class TextAnnotation {
129
145
  }
130
146
  return new Point3d(x, y, 0);
131
147
  }
148
+ /** Returns true if the leaders of this annotation are equal to the leaders of `other`. */
149
+ areLeadersEqual(leadersA, leadersB) {
150
+ if (leadersA === leadersB)
151
+ return true;
152
+ if (!leadersA || !leadersB || leadersA.length !== leadersB.length)
153
+ return false;
154
+ for (let i = 0; i < leadersA.length; ++i) {
155
+ const a = leadersA[i];
156
+ const b = leadersB[i];
157
+ if (!a.startPoint.isAlmostEqual(b.startPoint))
158
+ return false;
159
+ if (JSON.stringify(a.attachment) !== JSON.stringify(b.attachment))
160
+ return false;
161
+ if (JSON.stringify(a.styleOverrides) !== JSON.stringify(b.styleOverrides))
162
+ return false;
163
+ const pointsA = a.intermediatePoints ?? [];
164
+ const pointsB = b.intermediatePoints ?? [];
165
+ if (pointsA.length !== pointsB.length)
166
+ return false;
167
+ for (let j = 0; j < pointsA.length; ++j) {
168
+ if (!pointsA[j].isAlmostEqual(pointsB[j]))
169
+ return false;
170
+ }
171
+ }
172
+ return true;
173
+ }
132
174
  /** Returns true if this annotation is logically equivalent to `other`. */
133
175
  equals(other) {
176
+ if (this.anchor.horizontal !== other.anchor.horizontal ||
177
+ this.anchor.vertical !== other.anchor.vertical ||
178
+ !this.orientation.isAlmostEqual(other.orientation) ||
179
+ !this.offset.isAlmostEqual(other.offset) ||
180
+ !this.textBlock.equals(other.textBlock))
181
+ return false;
134
182
  const framesMatch = this.frame?.shape === other.frame?.shape
135
183
  && this.frame?.fill === other.frame?.fill
136
184
  && this.frame?.border === other.frame?.border
137
185
  && this.frame?.borderWeight === other.frame?.borderWeight;
138
- return this.anchor.horizontal === other.anchor.horizontal && this.anchor.vertical === other.anchor.vertical
139
- && this.orientation.isAlmostEqual(other.orientation) && this.offset.isAlmostEqual(other.offset)
140
- && this.textBlock.equals(other.textBlock)
141
- && framesMatch;
186
+ if (!framesMatch)
187
+ return false;
188
+ return this.areLeadersEqual(this.leaders, other.leaders);
142
189
  }
143
190
  }
144
191
  //# sourceMappingURL=TextAnnotation.js.map
@@ -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,EAAW,SAAS,EAAY,kBAAkB,EAAqB,MAAM,sBAAsB,CAAC;AACpH,OAAO,EAAE,SAAS,EAAkB,MAAM,aAAa,CAAC;AA6BxD;;EAEE;AACF,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,qBAAqB,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,kBAAkB,CAAU,CAAC;AA+DvM;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,cAAc;IACzB;;OAEG;IACI,WAAW,CAAqB;IACvC,8BAA8B;IACvB,SAAS,CAAY;IAC5B,iEAAiE;IAC1D,MAAM,CAAuB;IACpC,8IAA8I;IACvI,MAAM,CAAU;IACvB,iDAAiD;IAC1C,KAAK,CAAuB;IAEnC,YAAoB,MAAe,EAAE,MAA0B,EAAE,SAAoB,EAAE,MAA4B,EAAE,KAA2B;QAC9I,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;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAED,oCAAoC;IAC7B,MAAM,CAAC,MAAM,CAAC,IAA+B;QAClD,MAAM,MAAM,GAAG,IAAI,EA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,MAAM;eAC1C,IAAI,CAAC,KAAK,EAAE,YAAY,KAAK,KAAK,CAAC,KAAK,EAAE,YAAY,CAAC;QAE5D,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;eACtC,WAAW,CAAC;IACnB,CAAC;CACF","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 Annotation\n */\n\nimport { Point3d, Range2d, Transform, XYZProps, YawPitchRollAngles, YawPitchRollProps } from \"@itwin/core-geometry\";\nimport { TextBlock, TextBlockProps } from \"./TextBlock\";\nimport { TextStyleColor } from \"./TextStyle\";\n\n/** Describes how to compute the \"anchor point\" for a [[TextAnnotation]].\n * The anchor point is a point on or inside of the 2d bounding box enclosing the contents of the annotation's [[TextBlock]].\n * The annotation can be rotated and translated relative to the anchor point. The anchor point also serves as the snap point\n * when [AccuSnap]($frontend) is set to [SnapMode.Origin]($frontend).\n * [[TextAnnotation.computeTransform]] will align the anchor point with (0, 0).\n * @see [[TextAnnotation]] for a description of how the anchor point is computed.\n * @beta\n */\nexport interface TextAnnotationAnchor {\n /**\n * The vertical alignment of the anchor point.\n * \"top\" aligns the anchor point with the top of the text's bounding box.\n * \"middle\" aligns the anchor point with the middle of the text's bounding box.\n * \"bottom\" aligns the anchor point with the bottom of the text's bounding box.\n */\n vertical: \"top\" | \"middle\" | \"bottom\";\n\n /**\n * The horizontal alignment of the anchor point.\n * \"left\" aligns the anchor point with left side of the text's bounding box.\n * \"center\" aligns the anchor point with center of the text with's bounding box.\n * \"right\" aligns the anchor point with right side of the text's bounding box.\n */\n horizontal: \"left\" | \"center\" | \"right\";\n}\n\n/** Set of predefined shapes that can be computed and drawn around the margins of a [[TextBlock]]\n * @beta\n*/\nexport const textAnnotationFrameShapes = [\"none\", \"line\", \"rectangle\", \"circle\", \"equilateralTriangle\", \"diamond\", \"square\", \"pentagon\", \"hexagon\", \"octagon\", \"capsule\", \"roundedRectangle\"] as const;\n\n/** Describes a predefined shape that can be computed and drawn around the margins of a [[TextBlock]]\n * @beta\n*/\nexport type TextAnnotationFrameShape = typeof textAnnotationFrameShapes[number];\n\n/**\n * Describes what color to use when filling the frame around a [[TextBlock]].\n * If `background` is specified, [[GeometryParams.BackgroundFill]] will be set to `BackgroundFill.Outline`.\n * @beta\n */\nexport type TextAnnotationFillColor = TextStyleColor | \"background\";\n\n/**\n * Describes how to draw the frame around a [[TextBlock]].\n * The frame can be a simple line, a filled shape, or both.\n * @beta\n */\nexport interface TextFrameStyleProps {\n /** Shape of the frame. Default: \"rectangle\" */\n shape?: TextAnnotationFrameShape;\n /** The color to fill the shape of the text frame. This fill will is applied using [[FillDisplay.Blanking]]. Default: no fill */\n fill?: TextAnnotationFillColor;\n /** The color of the text frame's outline. Default: black */\n border?: TextStyleColor;\n /** This will be used to set the [[GeometryParams.weight]] property of the frame (in pixels). Default: 1px */\n borderWeight?: number;\n}\n\n/**\n * JSON representation of a [[TextAnnotation]].\n * @beta\n */\nexport interface TextAnnotationProps {\n /** See [[TextAnnotation.offset]]. Default: [0, 0, 0]. */\n offset?: XYZProps;\n /** See [[TextAnnotation.orientation]]. Default: no rotation. */\n orientation?: YawPitchRollProps;\n /** See [[TextAnnotation.textBlock]]. Default: an empty text block. */\n textBlock?: TextBlockProps;\n /** See [[TextAnnotation.anchor]]. Default: top-left. */\n anchor?: TextAnnotationAnchor;\n /** See [[TextAnnotation.frame]]. Default: no frame */\n frame?: TextFrameStyleProps\n}\n\n/** Arguments supplied to [[TextAnnotation.create]].\n * @beta\n */\nexport interface TextAnnotationCreateArgs {\n /** See [[TextAnnotation.offset]]. Default: (0, 0, 0). */\n offset?: Point3d;\n /** See [[TextAnnotation.orientation]]. Default: no rotation. */\n orientation?: YawPitchRollAngles;\n /** See [[TextAnnotation.textBlock]]. Default: an empty text block. */\n textBlock?: TextBlock;\n /** See [[TextAnnotation.anchor]]. Default: top-left. */\n anchor?: TextAnnotationAnchor;\n /** See [[TextAnnotation.frame]]. Default: no frame */\n frame?: TextFrameStyleProps\n}\n\n/**\n * Represents a formatted block of text positioned in 2d or 3d space.\n * [TextAnnotation2d]($backend) and [TextAnnotation3d]($backend) elements store a single TextAnnotation from which their geometric representation is generated.\n * Other types of elements may store multiple TextAnnotations, positioned relative to one another.\n * The annotation's position and orientation relative to the host element's [Placement]($common) is determined as follows:\n * - First, a bounding box is computed enclosing the contents of the [[textBlock].\n * - Then, an \"anchor point\" is computed based on the bounding box and the [[anchor]] property. The anchor point can be at one of the four corners of the box, in the middle of one of its four\n * edges, or in the center of the box.\n * - The [[orientation]] is applied to rotate the box around the anchor point.\n * - Finally, the [[offset]] is added to the anchor point to apply translation.\n * @see [appendTextAnnotationGeometry]($backend) to construct the geometry and append it to an [[ElementGeometry.Builder]].\n * @beta\n */\nexport class TextAnnotation {\n /** The rotation of the annotation.\n * @note When defining an annotation for a [TextAnnotation2d]($backend), only the `yaw` component (rotation around the Z axis) is used.\n */\n public orientation: YawPitchRollAngles;\n /** The formatted document. */\n public textBlock: TextBlock;\n /** Describes how to compute the [[textBlock]]'s anchor point. */\n public anchor: TextAnnotationAnchor;\n /** An offset applied to the anchor point that can be used to position annotations within the same geometry stream relative to one another. */\n public offset: Point3d;\n /** The frame settings of the text annotation. */\n public frame?: TextFrameStyleProps;\n\n private constructor(offset: Point3d, angles: YawPitchRollAngles, textBlock: TextBlock, anchor: TextAnnotationAnchor, frame?: TextFrameStyleProps) {\n this.offset = offset;\n this.orientation = angles;\n this.textBlock = textBlock;\n this.anchor = anchor;\n this.frame = frame\n }\n\n /** Creates a new TextAnnotation. */\n public static create(args?: TextAnnotationCreateArgs): TextAnnotation {\n const offset = args?.offset ?? new Point3d();\n const angles = args?.orientation ?? new YawPitchRollAngles();\n const textBlock = args?.textBlock ?? TextBlock.createEmpty();\n const anchor = args?.anchor ?? { vertical: \"top\", horizontal: \"left\" };\n // If the user supplies a frame, but doesn't supply a shape, default the shape to \"rectangle\"\n const shape: TextAnnotationFrameShape = args?.frame?.shape ?? \"rectangle\";\n const frame = args?.frame ? { shape, ...args.frame } : undefined;\n\n return new TextAnnotation(offset, angles, textBlock, anchor, frame);\n }\n\n /**\n * Creates a new TextAnnotation instance from its JSON representation.\n */\n public static fromJSON(props: TextAnnotationProps | undefined): TextAnnotation {\n return TextAnnotation.create({\n offset: props?.offset ? Point3d.fromJSON(props.offset) : undefined,\n orientation: props?.orientation ? YawPitchRollAngles.fromJSON(props.orientation) : undefined,\n textBlock: props?.textBlock ? TextBlock.create(props.textBlock) : undefined,\n anchor: props?.anchor ? { ...props.anchor } : undefined,\n frame: props?.frame ? { shape: \"rectangle\", ...props.frame } : undefined,\n });\n }\n\n /**\n * Converts this annotation to its JSON representation.\n */\n public toJSON(): TextAnnotationProps {\n const props: TextAnnotationProps = {};\n\n // Even if the text block is empty, we want to record its style name and overrides, e.g.,\n // so the user can pick up where they left off editing it next time.\n props.textBlock = this.textBlock.toJSON();\n\n if (!this.offset.isZero) {\n props.offset = this.offset.toJSON();\n }\n\n if (!this.orientation.isIdentity()) {\n props.orientation = this.orientation.toJSON();\n }\n\n if (this.anchor.vertical !== \"top\" || this.anchor.horizontal !== \"left\") {\n props.anchor = { ...this.anchor };\n }\n\n // Default frame to \"none\"\n props.frame = this.frame ? { ...this.frame } : undefined;\n\n return props;\n }\n\n /** Compute the transform that positions and orients this annotation relative to its anchor point, based on the [[textBlock]]'s computed bounding box.\n * The anchor point is computed as specified by this annotation's [[anchor]] setting. For example, if the text block is anchored\n * at the bottom left, then the transform will be relative to the bottom-left corner of `textBlockExtents`.\n * The text block will be rotated around the fixed anchor point according to [[orientation]], then translated by [[offset]].\n * The anchor point will coincide with (0, 0, 0) unless an [[offset]] is present.\n * @param boundingBox A box fully containing the [[textBlock]]. This range should include the margins.\n * @see [[computeAnchorPoint]] to compute the transform's anchor point.\n * @see [computeLayoutTextBlockResult]($backend) to lay out a `TextBlock`.\n */\n public computeTransform(boundingBox: Range2d): Transform {\n const anchorPt = this.computeAnchorPoint(boundingBox);\n const matrix = this.orientation.toMatrix3d();\n\n const rotation = Transform.createFixedPointAndMatrix(anchorPt, matrix);\n const translation = Transform.createTranslation(this.offset.minus(anchorPt));\n\n return translation.multiplyTransformTransform(rotation, rotation);\n }\n\n /** Compute the anchor point of this annotation as specified by [[anchor]].\n * @param boundingBox A box fully containing the [[textBlock]].\n * @see [[computeTransform]] to compute the transform relative to the anchor point.\n */\n public computeAnchorPoint(boundingBox: Range2d): Point3d {\n let x = boundingBox.low.x;\n let y = boundingBox.high.y;\n\n switch (this.anchor.horizontal) {\n case \"center\":\n x += boundingBox.xLength() / 2;\n break;\n case \"right\":\n x += boundingBox.xLength();\n break;\n }\n\n switch (this.anchor.vertical) {\n case \"middle\":\n y -= boundingBox.yLength() / 2;\n break;\n case \"bottom\":\n y -= boundingBox.yLength();\n break;\n }\n\n return new Point3d(x, y, 0);\n }\n\n /** Returns true if this annotation is logically equivalent to `other`. */\n public equals(other: TextAnnotation): boolean {\n const framesMatch = this.frame?.shape === other.frame?.shape\n && this.frame?.fill === other.frame?.fill\n && this.frame?.border === other.frame?.border\n && this.frame?.borderWeight === other.frame?.borderWeight;\n\n return this.anchor.horizontal === other.anchor.horizontal && this.anchor.vertical === other.anchor.vertical\n && this.orientation.isAlmostEqual(other.orientation) && this.offset.isAlmostEqual(other.offset)\n && this.textBlock.equals(other.textBlock)\n && framesMatch;\n }\n}\n"]}
1
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AAW,GAAG,IAAI,CAAC,KAAK,EAAE,KAAK,KAAK,KAAK,CAAC,KAAK,EAAE,KAAK;eACvD,IAAI,CAAC,KAAK,EAAE,IAAI,KAAK,KAAK,CAAC,KAAK,EAAE,IAAI;eACtC,IAAI,CAAC,KAAK,EAAE,MAAM,KAAK,KAAK,CAAC,KAAK,EAAE,MAAM;eAC1C,IAAI,CAAC,KAAK,EAAE,YAAY,KAAK,KAAK,CAAC,KAAK,EAAE,YAAY,CAAC;QAE5D,IAAI,CAAC,WAAW;YACd,OAAO,KAAK,CAAC;QAEf,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IAE3D,CAAC;CACF","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 Annotation\n */\n\nimport { Point3d, Range2d, Transform, XYZProps, YawPitchRollAngles, YawPitchRollProps } from \"@itwin/core-geometry\";\nimport { TextBlock, TextBlockProps } from \"./TextBlock\";\nimport { TextStyleColor, TextStyleSettingsProps } from \"./TextStyle\";\n\n/** Describes how to compute the \"anchor point\" for a [[TextAnnotation]].\n * The anchor point is a point on or inside of the 2d bounding box enclosing the contents of the annotation's [[TextBlock]].\n * The annotation can be rotated and translated relative to the anchor point. The anchor point also serves as the snap point\n * when [AccuSnap]($frontend) is set to [SnapMode.Origin]($frontend).\n * [[TextAnnotation.computeTransform]] will align the anchor point with (0, 0).\n * @see [[TextAnnotation]] for a description of how the anchor point is computed.\n * @beta\n */\nexport interface TextAnnotationAnchor {\n /**\n * The vertical alignment of the anchor point.\n * \"top\" aligns the anchor point with the top of the text's bounding box.\n * \"middle\" aligns the anchor point with the middle of the text's bounding box.\n * \"bottom\" aligns the anchor point with the bottom of the text's bounding box.\n */\n vertical: \"top\" | \"middle\" | \"bottom\";\n\n /**\n * The horizontal alignment of the anchor point.\n * \"left\" aligns the anchor point with left side of the text's bounding box.\n * \"center\" aligns the anchor point with center of the text with's bounding box.\n * \"right\" aligns the anchor point with right side of the text's bounding box.\n */\n horizontal: \"left\" | \"center\" | \"right\";\n}\n\n/** Set of predefined shapes that can be computed and drawn around the margins of a [[TextBlock]]\n * @beta\n*/\nexport const textAnnotationFrameShapes = [\"none\", \"line\", \"rectangle\", \"circle\", \"equilateralTriangle\", \"diamond\", \"square\", \"pentagon\", \"hexagon\", \"octagon\", \"capsule\", \"roundedRectangle\"] as const;\n\n/** Describes a predefined shape that can be computed and drawn around the margins of a [[TextBlock]]\n * @beta\n*/\nexport type TextAnnotationFrameShape = typeof textAnnotationFrameShapes[number];\n\n/**\n * Describes what color to use when filling the frame around a [[TextBlock]].\n * If `background` is specified, [[GeometryParams.BackgroundFill]] will be set to `BackgroundFill.Outline`.\n * @beta\n */\nexport type TextAnnotationFillColor = TextStyleColor | \"background\";\n\n/**\n * Describes how to draw the frame around a [[TextBlock]].\n * The frame can be a simple line, a filled shape, or both.\n * @beta\n */\nexport interface TextFrameStyleProps {\n /** Shape of the frame. Default: \"rectangle\" */\n shape?: TextAnnotationFrameShape;\n /** The color to fill the shape of the text frame. This fill will is applied using [[FillDisplay.Blanking]]. Default: no fill */\n fill?: TextAnnotationFillColor;\n /** The color of the text frame's outline. Default: black */\n border?: TextStyleColor;\n /** This will be used to set the [[GeometryParams.weight]] property of the frame (in pixels). Default: 1px */\n borderWeight?: number;\n}\n\n/**\n * Describes how to attach a [[TextAnnotationLeader]] to the frame around a [[TextBlock]].\n * Leader can be attached using one of the three modes:\n * - KeyPoint: attach to a point on the frame specified by the given curveIndex and fractional position.\n * - TextPoint: attach to a point that is projected on to the frame from the point on a particular line of text specified by [[LeaderTextPointOptions]].\n * - Nearest: attach to the point on frame that is nearest to [[TextAnnotationLeader.startPoint]].\n * @beta\n */\nexport type LeaderAttachment =\n | { mode: \"KeyPoint\"; curveIndex: number; fraction: number }\n | { mode: \"TextPoint\"; position: LeaderTextPointOptions }\n | { mode: \"Nearest\" };\n\n/**\n * Specifies the possible positions to attach a leader on the frame around a [[TextBlock]]\n * when [[TextAnnotationLeader.attachment.mode]] is set to TextPoint.\n * TopLeft : attach to a point projected onto the frame from the point on the left side of the first line of text.\n * TopRight : attach to a point projected onto the frame from the point on the right side of the first line of text.\n * BottomLeft : attach to a point projected onto the frame from the point on the left side of the last line of text.\n * BottomRight : attach to a point projected onto the frame from the point on the right side of the last line of text.\n * @beta\n */\nexport type LeaderTextPointOptions = \"TopLeft\" | \"TopRight\" | \"BottomLeft\" | \"BottomRight\"\n\n/**\n * A line that connects a [[TextAnnotation]] to a point in space relative to another element in the iModel.\n * A leader is always attached to the frame around the annotation's [[TextBlock]].\n * If the frame is not visible, the leader attaches to an invisible rectangular frame around the text block.\n * @see [[TextAnnotation.leaders]] for the leaders associated with an annotation.\n * @see [[TextStyleSettings.leader]] and [[styleOverrides]] to customize the appearance of leaders.\n * @beta\n*/\nexport interface TextAnnotationLeader {\n /** The point where the leader starts.\n * This is the point on another element where the leader points to */\n startPoint: Point3d;\n /** Describes how to attach the leader to the frame around [[textBlock]].*/\n attachment: LeaderAttachment;\n /** Optional intermediate points that the leader should pass through.\n * If not specified, the leader will be a straight line from startPoint to the point on the frame.\n * For now, intermediate points are a set of points which create additional LineSegments in the leader, but there could be intermediate shapes instead of straight LineSegments in future*/\n intermediatePoints?: Point3d[];\n /** Optional style overrides for the leader. If not specified, the leader will use the style defined by [[TextBlock.styleName]] as it is.\n * If specified, these overrides will be applied to the style.\n */\n styleOverrides?: TextStyleSettingsProps;\n}\n/**\n * JSON representation of a [[TextAnnotationLeader]].\n * @beta\n */\nexport interface TextAnnotationLeaderProps {\n /** See [[TextAnnotationLeader.startPoint]]. */\n startPoint: XYZProps;\n /** See [[TextAnnotationLeader.attachment]]. */\n attachment: LeaderAttachment;\n /** See [[TextAnnotationLeader.intermediatePoints]]. Default: no intermediate points. */\n intermediatePoints?: XYZProps[];\n /** See [[TextAnnotationLeader.styleOverrides]]. Default: no style overrides. */\n styleOverrides?: TextStyleSettingsProps;\n}\n\n/**\n\n/**\n * JSON representation of a [[TextAnnotation]].\n * @beta\n */\nexport interface TextAnnotationProps {\n /** See [[TextAnnotation.offset]]. Default: [0, 0, 0]. */\n offset?: XYZProps;\n /** See [[TextAnnotation.orientation]]. Default: no rotation. */\n orientation?: YawPitchRollProps;\n /** See [[TextAnnotation.textBlock]]. Default: an empty text block. */\n textBlock?: TextBlockProps;\n /** See [[TextAnnotation.anchor]]. Default: top-left. */\n anchor?: TextAnnotationAnchor;\n /** See [[TextAnnotation.frame]]. Default: no frame */\n frame?: TextFrameStyleProps;\n /** See [[TextAnnotation.leader]]. Default: an empty leader array */\n leaders?: TextAnnotationLeaderProps[];\n}\n\n/** Arguments supplied to [[TextAnnotation.create]].\n * @beta\n */\nexport interface TextAnnotationCreateArgs {\n /** See [[TextAnnotation.offset]]. Default: (0, 0, 0). */\n offset?: Point3d;\n /** See [[TextAnnotation.orientation]]. Default: no rotation. */\n orientation?: YawPitchRollAngles;\n /** See [[TextAnnotation.textBlock]]. Default: an empty text block. */\n textBlock?: TextBlock;\n /** See [[TextAnnotation.anchor]]. Default: top-left. */\n anchor?: TextAnnotationAnchor;\n /** See [[TextAnnotation.frame]]. Default: no frame */\n frame?: TextFrameStyleProps;\n /** See [[TextAnnotation.leader]]. Default: an empty leader array */\n leaders?: TextAnnotationLeader[];\n}\n\n/**\n * Represents a formatted block of text positioned in 2d or 3d space.\n * [TextAnnotation2d]($backend) and [TextAnnotation3d]($backend) elements store a single TextAnnotation from which their geometric representation is generated.\n * Other types of elements may store multiple TextAnnotations, positioned relative to one another.\n * The annotation's position and orientation relative to the host element's [Placement]($common) is determined as follows:\n * - First, a bounding box is computed enclosing the contents of the [[textBlock].\n * - Then, an \"anchor point\" is computed based on the bounding box and the [[anchor]] property. The anchor point can be at one of the four corners of the box, in the middle of one of its four\n * edges, or in the center of the box.\n * - The [[orientation]] is applied to rotate the box around the anchor point.\n * - Finally, the [[offset]] is added to the anchor point to apply translation.\n * @see [appendTextAnnotationGeometry]($backend) to construct the geometry and append it to an [[ElementGeometry.Builder]].\n * @beta\n */\nexport class TextAnnotation {\n /** The rotation of the annotation.\n * @note When defining an annotation for a [TextAnnotation2d]($backend), only the `yaw` component (rotation around the Z axis) is used.\n */\n public orientation: YawPitchRollAngles;\n /** The formatted document. */\n public textBlock: TextBlock;\n /** Describes how to compute the [[textBlock]]'s anchor point. */\n public anchor: TextAnnotationAnchor;\n /** An offset applied to the anchor point that can be used to position annotations within the same geometry stream relative to one another. */\n public offset: Point3d;\n /** The frame settings of the text annotation. */\n public frame?: TextFrameStyleProps;\n /** The leaders of the text annotation. */\n public leaders?: TextAnnotationLeader[];\n\n private constructor(offset: Point3d, angles: YawPitchRollAngles, textBlock: TextBlock, anchor: TextAnnotationAnchor, frame?: TextFrameStyleProps, leaders?: TextAnnotationLeader[]) {\n this.offset = offset;\n this.orientation = angles;\n this.textBlock = textBlock;\n this.anchor = anchor;\n this.frame = frame;\n this.leaders = leaders;\n }\n\n /** Creates a new TextAnnotation. */\n public static create(args?: TextAnnotationCreateArgs): TextAnnotation {\n const offset = args?.offset ?? new Point3d();\n const angles = args?.orientation ?? new YawPitchRollAngles();\n const textBlock = args?.textBlock ?? TextBlock.createEmpty();\n const anchor = args?.anchor ?? { vertical: \"top\", horizontal: \"left\" };\n // If the user supplies a frame, but doesn't supply a shape, default the shape to \"rectangle\"\n const shape: TextAnnotationFrameShape = args?.frame?.shape ?? \"rectangle\";\n const frame = args?.frame ? { shape, ...args.frame } : undefined;\n const leaders = args?.leaders ?? undefined;\n return new TextAnnotation(offset, angles, textBlock, anchor, frame, leaders);\n }\n\n /**\n * Creates a new TextAnnotation instance from its JSON representation.\n */\n public static fromJSON(props: TextAnnotationProps | undefined): TextAnnotation {\n return TextAnnotation.create({\n offset: props?.offset ? Point3d.fromJSON(props.offset) : undefined,\n orientation: props?.orientation ? YawPitchRollAngles.fromJSON(props.orientation) : undefined,\n textBlock: props?.textBlock ? TextBlock.create(props.textBlock) : undefined,\n anchor: props?.anchor ? { ...props.anchor } : undefined,\n frame: props?.frame ? { shape: \"rectangle\", ...props.frame } : undefined,\n leaders: props?.leaders ? props.leaders.map((leader) => ({\n startPoint: Point3d.fromJSON(leader.startPoint),\n attachment: leader.attachment,\n styleOverrides: leader.styleOverrides ?? undefined,\n intermediatePoints: leader.intermediatePoints ? leader.intermediatePoints.map((point) => Point3d.fromJSON(point)) : undefined,\n })) : undefined,\n });\n }\n\n /**\n * Converts this annotation to its JSON representation.\n */\n public toJSON(): TextAnnotationProps {\n const props: TextAnnotationProps = {};\n\n // Even if the text block is empty, we want to record its style name and overrides, e.g.,\n // so the user can pick up where they left off editing it next time.\n props.textBlock = this.textBlock.toJSON();\n\n if (!this.offset.isZero) {\n props.offset = this.offset.toJSON();\n }\n\n if (!this.orientation.isIdentity()) {\n props.orientation = this.orientation.toJSON();\n }\n\n if (this.anchor.vertical !== \"top\" || this.anchor.horizontal !== \"left\") {\n props.anchor = { ...this.anchor };\n }\n\n // Default frame to \"none\"\n props.frame = this.frame ? { ...this.frame } : undefined;\n\n props.leaders = this.leaders?.map((leader) => ({\n startPoint: leader.startPoint.toJSON(),\n attachment: leader.attachment,\n styleOverrides: leader.styleOverrides ?? undefined,\n intermediatePoints: leader.intermediatePoints ? leader.intermediatePoints.map((point) => point.toJSON()) : undefined,\n })) ?? undefined;\n\n return props;\n }\n\n /** Compute the transform that positions and orients this annotation relative to its anchor point, based on the [[textBlock]]'s computed bounding box.\n * The anchor point is computed as specified by this annotation's [[anchor]] setting. For example, if the text block is anchored\n * at the bottom left, then the transform will be relative to the bottom-left corner of `textBlockExtents`.\n * The text block will be rotated around the fixed anchor point according to [[orientation]], then translated by [[offset]].\n * The anchor point will coincide with (0, 0, 0) unless an [[offset]] is present.\n * @param boundingBox A box fully containing the [[textBlock]]. This range should include the margins.\n * @see [[computeAnchorPoint]] to compute the transform's anchor point.\n * @see [computeLayoutTextBlockResult]($backend) to lay out a `TextBlock`.\n */\n public computeTransform(boundingBox: Range2d): Transform {\n const anchorPt = this.computeAnchorPoint(boundingBox);\n const matrix = this.orientation.toMatrix3d();\n\n const rotation = Transform.createFixedPointAndMatrix(anchorPt, matrix);\n const translation = Transform.createTranslation(this.offset.minus(anchorPt));\n\n return translation.multiplyTransformTransform(rotation, rotation);\n }\n\n /** Compute the anchor point of this annotation as specified by [[anchor]].\n * @param boundingBox A box fully containing the [[textBlock]].\n * @see [[computeTransform]] to compute the transform relative to the anchor point.\n */\n public computeAnchorPoint(boundingBox: Range2d): Point3d {\n let x = boundingBox.low.x;\n let y = boundingBox.high.y;\n\n switch (this.anchor.horizontal) {\n case \"center\":\n x += boundingBox.xLength() / 2;\n break;\n case \"right\":\n x += boundingBox.xLength();\n break;\n }\n\n switch (this.anchor.vertical) {\n case \"middle\":\n y -= boundingBox.yLength() / 2;\n break;\n case \"bottom\":\n y -= boundingBox.yLength();\n break;\n }\n\n return new Point3d(x, y, 0);\n }\n\n /** Returns true if the leaders of this annotation are equal to the leaders of `other`. */\n private areLeadersEqual(leadersA?: TextAnnotationLeader[], leadersB?: TextAnnotationLeader[]): boolean {\n if (leadersA === leadersB) return true;\n if (!leadersA || !leadersB || leadersA.length !== leadersB.length) return false;\n\n for (let i = 0; i < leadersA.length; ++i) {\n const a = leadersA[i];\n const b = leadersB[i];\n\n if (!a.startPoint.isAlmostEqual(b.startPoint)) return false;\n if (JSON.stringify(a.attachment) !== JSON.stringify(b.attachment)) return false;\n if (JSON.stringify(a.styleOverrides) !== JSON.stringify(b.styleOverrides)) return false;\n\n const pointsA = a.intermediatePoints ?? [];\n const pointsB = b.intermediatePoints ?? [];\n if (pointsA.length !== pointsB.length) return false;\n for (let j = 0; j < pointsA.length; ++j) {\n if (!pointsA[j].isAlmostEqual(pointsB[j])) return false;\n }\n }\n return true;\n }\n\n /** Returns true if this annotation is logically equivalent to `other`. */\n public equals(other: TextAnnotation): boolean {\n if (this.anchor.horizontal !== other.anchor.horizontal ||\n this.anchor.vertical !== other.anchor.vertical ||\n !this.orientation.isAlmostEqual(other.orientation) ||\n !this.offset.isAlmostEqual(other.offset) ||\n !this.textBlock.equals(other.textBlock))\n return false;\n\n const framesMatch = this.frame?.shape === other.frame?.shape\n && this.frame?.fill === other.frame?.fill\n && this.frame?.border === other.frame?.border\n && this.frame?.borderWeight === other.frame?.borderWeight;\n\n if (!framesMatch)\n return false;\n\n return this.areLeadersEqual(this.leaders, other.leaders);\n\n }\n}\n"]}
@@ -13,6 +13,35 @@ export type StackedFractionType = "horizontal" | "diagonal";
13
13
  * @beta
14
14
  */
15
15
  export type TextStyleColor = ColorDefProps | "subcategory";
16
+ /** Properties describing the appearance of [[TextAnnotationLeader]] in a [[TextAnnotation]].
17
+ * Used when producing geometry for [[TextAnnotation]].
18
+ * @beta
19
+ */
20
+ export interface TextLeaderStyleProps {
21
+ /** The color of the leader.
22
+ * Default: "subcategory".
23
+ */
24
+ color?: TextStyleColor;
25
+ /** Whether to use an elbow in the leader.
26
+ * Default: false
27
+ */
28
+ wantElbow?: boolean;
29
+ /** Multiplier used to compute length of the elbow in the leader.
30
+ * The elbowLength is computed in meters as elbowLength * [[lineHeight]].
31
+ * Default: 1.0
32
+ */
33
+ elbowLength?: number;
34
+ /** Multiplier to compute height of the leader terminator.
35
+ * The terminator height is computed in meters as terminatorHeight * [[lineHeight]].
36
+ * Default: 1.0
37
+ */
38
+ terminatorHeightFactor?: number;
39
+ /** Multiplier to compute width of the leader terminator.
40
+ * The terminator width is computed in meters as terminatorWidth * [[lineHeight]].
41
+ * Default: 1.0
42
+ */
43
+ terminatorWidthFactor?: number;
44
+ }
16
45
  /** Serves both as the JSON representation of a [[TextStyleSettings]], and a way for a [[TextBlockComponent]] to selectively override aspects of a [[TextStyle]]'s properties.
17
46
  * @beta
18
47
  */
@@ -80,6 +109,11 @@ export interface TextStyleSettingsProps {
80
109
  * Default: 1.0
81
110
  */
82
111
  widthFactor?: number;
112
+ /** Properties describing appearance of leaders in a [[TextAnnotation]]
113
+ * Used when producing geometry for [[TextAnnotation]]
114
+ * Default: {color:"subcategory", wantElbow:"false",elbowLength:1, terminatorWidthFactor:1, terminatorHeightFactor:1}.
115
+ */
116
+ leader?: TextLeaderStyleProps;
83
117
  /** The size (in meters) used to calculate the tab stops in a run.
84
118
  * These are equally spaced from the left edge of the TextBlock.
85
119
  * Default: 4 meters.
@@ -137,6 +171,10 @@ export declare class TextStyleSettings {
137
171
  readonly superScriptScale: number;
138
172
  /** Multiplier used to compute the width of each glyph, relative to [[lineHeight]]. */
139
173
  readonly widthFactor: number;
174
+ /** Properties describing appearance of leaders in a [[TextAnnotation]].
175
+ * Used when producing geometry for [[TextAnnotation]].
176
+ */
177
+ readonly leader: Readonly<Required<TextLeaderStyleProps>>;
140
178
  /** The size (in meters) used to calculate the tab stops in a run.
141
179
  * These are equally spaced from the left edge of the TextBlock. Default is 4 meters.
142
180
  */
@@ -151,6 +189,11 @@ export declare class TextStyleSettings {
151
189
  /** Create settings from their JSON representation. */
152
190
  static fromJSON(props?: TextStyleSettingsProps): TextStyleSettings;
153
191
  toJSON(): TextStyleSettingsProps;
192
+ /** Compare two [[TextLeaderStyleProps]] for equality.
193
+ * @param other The other leader style properties to compare against.
194
+ * @returns true if the two leader styles are equal, false otherwise.
195
+ */
196
+ leaderEquals(other: TextLeaderStyleProps): boolean;
154
197
  equals(other: TextStyleSettings): boolean;
155
198
  }
156
199
  /** The JSON representation of a [[TextStyle]].
@@ -1 +1 @@
1
- {"version":3,"file":"TextStyle.d.ts","sourceRoot":"","sources":["../../../src/annotation/TextStyle.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,YAAY,GAAG,UAAU,CAAC;AAE5D;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,aAAa,GAA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AEpC,qEAAqE;IACrE,OAAc,YAAY,EAAE,QAAQ,CAAC,QAAQ,CAAC,sBAAsB,CAAC,CAAC,CAuBpE;IAEF,kDAAkD;IAClD,OAAc,QAAQ,EAAE,iBAAiB,CAA6B;IAEtE,OAAO;IA8BP,uGAAuG;IAChG,KAAK,CAAC,YAAY,CAAC,EAAE,sBAAsB,GAAG,iBAAiB;IAItE,sDAAsD;WACxC,QAAQ,CAAC,KAAK,CAAC,EAAE,sBAAsB,GAAG,iBAAiB;IAIlE,MAAM,IAAI,sBAAsB;IAGvC;;;OAGG;IACI,YAAY,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO;IAMlD,MAAM,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO;CAUjD;AAKD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,4IAA4I;IAC5I,QAAQ,CAAC,EAAE,sBAAsB,CAAC;CACnC;AAED;;;;GAIG;AACH,qBAAa,SAAS;IACpB,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,QAAQ,EAAE,iBAAiB,CAAC;IAE5C,OAAO;IAKP,mDAAmD;WACrC,QAAQ,CAAC,IAAI,EAAE,cAAc,GAAG,SAAS;IAIvD,0BAA0B;WACZ,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,iBAAiB,GAAG,SAAS;IAI1E,sIAAsI;IAC/H,KAAK,CAAC,eAAe,EAAE,sBAAsB,GAAG,SAAS;IAIzD,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO;CAGzC"}
@@ -56,6 +56,10 @@ export class TextStyleSettings {
56
56
  superScriptScale;
57
57
  /** Multiplier used to compute the width of each glyph, relative to [[lineHeight]]. */
58
58
  widthFactor;
59
+ /** Properties describing appearance of leaders in a [[TextAnnotation]].
60
+ * Used when producing geometry for [[TextAnnotation]].
61
+ */
62
+ leader;
59
63
  /** The size (in meters) used to calculate the tab stops in a run.
60
64
  * These are equally spaced from the left edge of the TextBlock. Default is 4 meters.
61
65
  */
@@ -76,6 +80,13 @@ export class TextStyleSettings {
76
80
  superScriptOffsetFactor: 0.5,
77
81
  superScriptScale: 2 / 3,
78
82
  widthFactor: 1,
83
+ leader: {
84
+ color: "subcategory",
85
+ wantElbow: false,
86
+ elbowLength: 1.0,
87
+ terminatorHeightFactor: 1.0,
88
+ terminatorWidthFactor: 1.0,
89
+ },
79
90
  tabInterval: 4,
80
91
  };
81
92
  /** Settings initialized to all default values. */
@@ -98,6 +109,14 @@ export class TextStyleSettings {
98
109
  this.superScriptOffsetFactor = props.superScriptOffsetFactor ?? defaults.superScriptOffsetFactor;
99
110
  this.superScriptScale = props.superScriptScale ?? defaults.superScriptScale;
100
111
  this.widthFactor = props.widthFactor ?? defaults.widthFactor;
112
+ const leader = {
113
+ color: props.leader?.color ?? defaults.leader.color,
114
+ wantElbow: props.leader?.wantElbow ?? defaults.leader.wantElbow,
115
+ elbowLength: props.leader?.elbowLength ?? defaults.leader.elbowLength,
116
+ terminatorHeightFactor: props.leader?.terminatorHeightFactor ?? defaults.leader.terminatorHeightFactor,
117
+ terminatorWidthFactor: props.leader?.terminatorWidthFactor ?? defaults.leader.terminatorWidthFactor,
118
+ };
119
+ this.leader = Object.freeze(leader);
101
120
  this.tabInterval = props.tabInterval ?? defaults.tabInterval;
102
121
  }
103
122
  /** Create a copy of these settings, modified according to the properties defined by `alteredProps`. */
@@ -111,14 +130,24 @@ export class TextStyleSettings {
111
130
  toJSON() {
112
131
  return { ...this };
113
132
  }
133
+ /** Compare two [[TextLeaderStyleProps]] for equality.
134
+ * @param other The other leader style properties to compare against.
135
+ * @returns true if the two leader styles are equal, false otherwise.
136
+ */
137
+ leaderEquals(other) {
138
+ return this.leader.color === other.color && this.leader.wantElbow === other.wantElbow
139
+ && this.leader.elbowLength === other.elbowLength && this.leader.terminatorHeightFactor === other.terminatorHeightFactor
140
+ && this.leader.terminatorWidthFactor === other.terminatorWidthFactor;
141
+ }
114
142
  equals(other) {
115
143
  return this.color === other.color && this.fontName === other.fontName
116
144
  && this.lineHeight === other.lineHeight && this.lineSpacingFactor === other.lineSpacingFactor && this.widthFactor === other.widthFactor
117
145
  && this.isBold === other.isBold && this.isItalic === other.isItalic && this.isUnderlined === other.isUnderlined
118
146
  && this.stackedFractionType === other.stackedFractionType && this.stackedFractionScale === other.stackedFractionScale
119
147
  && this.subScriptOffsetFactor === other.subScriptOffsetFactor && this.subScriptScale === other.subScriptScale
120
- && this.superScriptOffsetFactor === other.superScriptOffsetFactor && this.superScriptScale === other.superScriptScale
121
- && this.tabInterval === other.tabInterval;
148
+ && this.superScriptOffsetFactor === other.superScriptOffsetFactor
149
+ && this.superScriptScale === other.superScriptScale
150
+ && this.tabInterval === other.tabInterval && this.leaderEquals(other.leader);
122
151
  }
123
152
  }
124
153
  Object.freeze(TextStyleSettings.defaultProps);
@@ -1 +1 @@
1
- {"version":3,"file":"TextStyle.js","sourceRoot":"","sources":["../../../src/annotation/TextStyle.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AA2FH;;;;;GAKG;AACH,MAAM,OAAO,iBAAiB;IAC5B,6BAA6B;IACb,KAAK,CAAiB;IACtC;OACG;IACa,QAAQ,CAAS;IACjC;;;OAGG;IACa,UAAU,CAAS;IACnC;;OAEG;IACa,iBAAiB,CAAS;IAC1C,kFAAkF;IAClE,MAAM,CAAU;IAChC,sFAAsF;IACtE,QAAQ,CAAU;IAClC,2EAA2E;IAC3D,YAAY,CAAU;IACtC;;OAEG;IACa,oBAAoB,CAAS;IAC7C,oFAAoF;IACpE,mBAAmB,CAAsB;IACzD;;OAEG;IACa,qBAAqB,CAAS;IAC9C;;OAEG;IACa,cAAc,CAAS;IACvC;;OAEG;IACa,uBAAuB,CAAS;IAChD;;OAEG;IACa,gBAAgB,CAAS;IACzC,sFAAsF;IACtE,WAAW,CAAS;IACpC;;OAEG;IACa,WAAW,CAAS;IAEpC,qE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nB,MAAM,CAAC,MAAM,CAAC,IAAY,EAAE,QAA2B;QAC5D,OAAO,IAAI,SAAS,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACvC,CAAC;IAED,sIAAsI;IAC/H,KAAK,CAAC,eAAuC;QAClD,OAAO,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC;IAC3E,CAAC;IAEM,MAAM,CAAC,KAAgB;QAC5B,OAAO,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC1E,CAAC;CACF","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 Annotation\n */\n\nimport { ColorDefProps } from \"../ColorDef\";\n\n/** Specifies how to separate the numerator and denominator of a [[FractionRun]], by either a horizontal or diagonal bar.\n * @see [[TextStyleSettingsProps.stackedFractionType]] and [[TextStyleSettings.stackedFractionType]].\n * @beta\n */\nexport type StackedFractionType = \"horizontal\" | \"diagonal\";\n\n/** Describes the color in which to draw the text in a [[TextRun]].\n * \"subcategory\" indicates that the text should be drawn using the color of the [SubCategory]($backend) specified by the [GeometryStream]($docs/learning/common/GeometryStream.md) hosting the\n * text.\n * @beta\n */\nexport type TextStyleColor = ColorDefProps | \"subcategory\";\n\n/** Serves both as the JSON representation of a [[TextStyleSettings]], and a way for a [[TextBlockComponent]] to selectively override aspects of a [[TextStyle]]'s properties.\n * @beta\n */\nexport interface TextStyleSettingsProps {\n /** The color of the text.\n * Default: \"subcategory\".\n */\n color?: TextStyleColor;\n /** The name of a font stored in a [Workspace]($backend), used to draw the contents of a [[TextRun]].\n * Default: \"\" (an invalid font name).\n */\n fontName?: string;\n /** The height each line of text, in meters. Many other settings use the line height as the basis for computing their own values.\n * For example, the height and offset from baseline of a subscript [[TextRun]] are computed as lineHeight * [[subScriptScale]] and\n * lineHeight * [[subScriptOffsetFactor]], respectively.\n * Default: 1.0. */\n lineHeight?: number;\n /** Multiplier used to compute the vertical distance between two lines of text.\n * The distance is computed in meters as lineSpacingFactor * [[lineHeight]].\n * Default: 0.5.\n */\n lineSpacingFactor?: number;\n /** Specifies whether the content of a [[TextRun]] should be rendered **bold**.\n * Default: false.\n */\n isBold?: boolean;\n /** Specifies whether the content of a [[TextRun]] should be rendered in *italics*.\n * Default: false.\n */\n isItalic?: boolean;\n /** Specifies whether the content of a [[TextRun]] should be underlined.\n * Default: false.\n */\n isUnderlined?: boolean;\n /** Multiplier used to compute the height of both the numerator and denominator of a [[FractionRun]].\n * The height is computed in meters as stackedFractionScale * [[lineHeight]].\n * Default: 0.7.\n */\n stackedFractionScale?: number;\n /** Specifies how to separate the numerator and denominator of a [[FractionRun]].\n * Default: \"horizontal\".\n */\n stackedFractionType?: StackedFractionType;\n /** Multiplier used to compute the vertical offset from the baseline for a subscript [[TextRun]].\n * The offset is computed in meters as subScriptOffsetFactor * [[lineHeight]].\n * Default: -0.15.\n */\n subScriptOffsetFactor?: number;\n /** Multiplier used to compute the height of a subscript [[TextRun]].\n * The height is computed as subScriptScale * [[lineHeight]].\n * Default: 2/3\n */\n subScriptScale?: number;\n /** Multiplier used to compute the vertical offset from the baseline for a super [[TextRun]].\n * The offset is computed in meters as superScriptOffsetFactor * [[lineHeight]].\n * Default: -0.5.\n */\n superScriptOffsetFactor?: number;\n /** Multiplier used to compute the height of a superscript [[TextRun]].\n * The height is computed as superScriptScale * [[lineHeight]].\n * Default: 2/3\n */\n superScriptScale?: number;\n /** A scale applied to the width of each glyph.\n * Default: 1.0\n */\n widthFactor?: number;\n /** The size (in meters) used to calculate the tab stops in a run.\n * These are equally spaced from the left edge of the TextBlock.\n * Default: 4 meters.\n */\n tabInterval?: number;\n}\n\n/** A description of the formatting to be applied to a [[TextBlockComponent]].\n * Named instances of these settings can be stored as [[TextStyle]]s in a [Workspace]($backend).\n * @note This is an immutable type. Use [[clone]] to create a modified copy.\n * @see [[TextStyleSettingsProps]] for documentation of each of the settings.\n * @beta\n */\nexport class TextStyleSettings {\n /** The color of the text. */\n public readonly color: TextStyleColor;\n /** The name of a font stored in a [Workspace]($backend), used to draw the contents of a [[TextRun]].\n */\n public readonly fontName: string;\n /** The height each line of text, in meters. Many other settings use the line height as the basis for computing their own values.\n * For example, the height and offset from baseline of a subscript [[TextRun]] are computed as lineHeight * [[subScriptScale]] and\n * lineHeight * [[subScriptOffsetFactor]], respectively.\n */\n public readonly lineHeight: number;\n /** Multiplier used to compute the vertical distance between two lines of text.\n * The distance is computed in meters as lineSpacingFactor * [[lineHeight]].\n */\n public readonly lineSpacingFactor: number;\n /** Specifies whether the content of a [[TextRun]] should be rendered **bold**. */\n public readonly isBold: boolean;\n /** Specifies whether the content of a [[TextRun]] should be rendered in *italics*. */\n public readonly isItalic: boolean;\n /** Specifies whether the content of a [[TextRun]] should be underlined. */\n public readonly isUnderlined: boolean;\n /** Multiplier used to compute the height of both the numerator and denominator of a [[FractionRun]].\n * The height is computed in meters as stackedFractionScale * [[lineHeight]].\n */\n public readonly stackedFractionScale: number;\n /** Specifies how to separate the numerator and denominator of a [[FractionRun]]. */\n public readonly stackedFractionType: StackedFractionType;\n /** Multiplier used to compute the vertical offset from the baseline for a subscript [[TextRun]].\n * The offset is computed in meters as subScriptOffsetFactor * [[lineHeight]].\n */\n public readonly subScriptOffsetFactor: number;\n /** Multiplier used to compute the height of a subscript [[TextRun]].\n * The height is computed as subScriptScale * [[lineHeight]].\n */\n public readonly subScriptScale: number;\n /** Multiplier used to compute the vertical offset from the baseline for a super [[TextRun]].\n * The offset is computed in meters as superScriptOffsetFactor * [[lineHeight]].\n */\n public readonly superScriptOffsetFactor: number;\n /** Multiplier used to compute the height of a superscript [[TextRun]].\n * The height is computed as superScriptScale * [[lineHeight]].\n */\n public readonly superScriptScale: number;\n /** Multiplier used to compute the width of each glyph, relative to [[lineHeight]]. */\n public readonly widthFactor: number;\n /** The size (in meters) used to calculate the tab stops in a run.\n * These are equally spaced from the left edge of the TextBlock. Default is 4 meters.\n */\n public readonly tabInterval: number;\n\n /** A fully-populated JSON representation of the default settings. */\n public static defaultProps: Readonly<Required<TextStyleSettingsProps>> = {\n color: \"subcategory\",\n fontName: \"\",\n lineHeight: 1,\n lineSpacingFactor: 0.5,\n isBold: false,\n isItalic: false,\n isUnderlined: false,\n stackedFractionScale: 0.7,\n stackedFractionType: \"horizontal\",\n subScriptOffsetFactor: -0.15,\n subScriptScale: 2 / 3,\n superScriptOffsetFactor: 0.5,\n superScriptScale: 2 / 3,\n widthFactor: 1,\n tabInterval: 4,\n };\n\n /** Settings initialized to all default values. */\n public static defaults: TextStyleSettings = new TextStyleSettings({ });\n\n private constructor(props: TextStyleSettingsProps, defaults?: Required<TextStyleSettingsProps>) {\n if (!defaults) {\n defaults = TextStyleSettings.defaultProps;\n }\n\n this.color = props.color ?? defaults.color;\n this.fontName = props.fontName ?? defaults.fontName;\n this.lineHeight = props.lineHeight ?? defaults.lineHeight;\n this.lineSpacingFactor = props.lineSpacingFactor ?? defaults.lineSpacingFactor;\n this.isBold = props.isBold ?? defaults.isBold;\n this.isItalic = props.isItalic ?? defaults.isItalic;\n this.isUnderlined = props.isUnderlined ?? defaults.isUnderlined;\n this.stackedFractionScale = props.stackedFractionScale ?? defaults.stackedFractionScale;\n this.stackedFractionType = props.stackedFractionType ?? defaults.stackedFractionType;\n this.subScriptOffsetFactor = props.subScriptOffsetFactor ?? defaults.subScriptOffsetFactor;\n this.subScriptScale = props.subScriptScale ?? defaults.subScriptScale;\n this.superScriptOffsetFactor = props.superScriptOffsetFactor ?? defaults.superScriptOffsetFactor;\n this.superScriptScale = props.superScriptScale ?? defaults.superScriptScale;\n this.widthFactor = props.widthFactor ?? defaults.widthFactor;\n this.tabInterval = props.tabInterval ?? defaults.tabInterval;\n }\n\n /** Create a copy of these settings, modified according to the properties defined by `alteredProps`. */\n public clone(alteredProps?: TextStyleSettingsProps): TextStyleSettings {\n return alteredProps ? new TextStyleSettings(alteredProps, this) : this;\n }\n\n /** Create settings from their JSON representation. */\n public static fromJSON(props?: TextStyleSettingsProps): TextStyleSettings {\n return props ? new TextStyleSettings(props) : TextStyleSettings.defaults;\n }\n\n public toJSON(): TextStyleSettingsProps {\n return { ...this };\n }\n\n public equals(other: TextStyleSettings): boolean {\n return this.color === other.color && this.fontName === other.fontName\n && this.lineHeight === other.lineHeight && this.lineSpacingFactor === other.lineSpacingFactor && this.widthFactor === other.widthFactor\n && this.isBold === other.isBold && this.isItalic === other.isItalic && this.isUnderlined === other.isUnderlined\n && this.stackedFractionType === other.stackedFractionType && this.stackedFractionScale === other.stackedFractionScale\n && this.subScriptOffsetFactor === other.subScriptOffsetFactor && this.subScriptScale === other.subScriptScale\n && this.superScriptOffsetFactor === other.superScriptOffsetFactor && this.superScriptScale === other.superScriptScale\n && this.tabInterval === other.tabInterval;\n }\n}\n\nObject.freeze(TextStyleSettings.defaultProps);\nObject.freeze(TextStyleSettings.defaults);\n\n/** The JSON representation of a [[TextStyle]].\n * @beta\n */\nexport interface TextStyleProps {\n /** The name of the style. */\n name: string;\n /** The settings defined for the style. Any omitted properties will use their default values, as described by [[TextStyleSettingsProps]]. */\n settings?: TextStyleSettingsProps;\n}\n\n/** A named, immutable [[TextStyleSettings]] stored in a [Workspace]($backend).\n * @see [[TextBlockComponent.styleName]] to define the text style for a component of a [[TextBlock]].\n * @note This is an immutable type. Use [[clone]] to create a modified copy.\n * @beta\n */\nexport class TextStyle {\n public readonly name: string;\n public readonly settings: TextStyleSettings;\n\n private constructor(name: string, settings: TextStyleSettings) {\n this.name = name;\n this.settings = settings;\n }\n\n /** Create a style from its JSON representation. */\n public static fromJSON(json: TextStyleProps): TextStyle {\n return TextStyle.create(json.name, TextStyleSettings.fromJSON(json.settings));\n }\n\n /** Create a new style. */\n public static create(name: string, settings: TextStyleSettings): TextStyle {\n return new TextStyle(name, settings);\n }\n\n /** Create a copy of this style with the same name, and settings modified according to the properties defined by `alteredSettings`. */\n public clone(alteredSettings: TextStyleSettingsProps): TextStyle {\n return TextStyle.create(this.name, this.settings.clone(alteredSettings));\n }\n\n public equals(other: TextStyle): boolean {\n return this.name === other.name && this.settings.equals(other.settings);\n }\n}\n\n"]}
1
+ {"version":3,"file":"TextStyle.js","sourceRoot":"","sources":["../../../src/annotation/TextStyle.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AA+HH;;;;;GAKG;AACH,MAAM,OAAO,iBAAiB;IAC5B,6BAA6B;IACb,KAAK,CAAiB;IACtC;OACG;IACa,QAAQ,CAAS;IACjC;;;OAGG;IACa,UAAU,CAAS;IACnC;;OAEG;IACa,iBAAiB,CAAS;IAC1C,kFAAkF;IAClE,MAAM,CAAU;IAChC,sFAAsF;IACtE,QAAQ,CAAU;IAClC,2EAA2E;IAC3D,YAAY,CAAU;IACtC;;OAEG;IACa,oBAAoB,CAAS;IAC7C,oFAAoF;IACpE,mBAAmB,CAAsB;IACzD;;OAEG;IACa,qBAAqB,CAAS;IAC9C;;OAEG;IACa,cAAc,CAAS;IACvC;;OAEG;IACa,uBAAuB,CAAS;IAChD;;OAEG;IACa,gBAAgB,CAAS;IACzC,sFAAsF;IACtE,WAAW,CAAS;IACpC;;OAEG;IACa,MAAM,CAA2C;IACjE;;OAEG;IACa,WAAW,CAAS;IAEpC,qEAAqE;IAC9D,MAAM,CAAC,YAAY,GAA+C;QACvE,KAAK,EAAE,aAAa;QACpB,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,CAAC;QACb,iBAAiB,EAAE,GAAG;QACtB,MAAM,EAAE,KAAK;QACb,QAAQ,EAAE,KAAK;QACf,YAAY,EAAE,KAAK;QACnB,oBAAoB,EAAE,GAAG;QACzB,mBAAmB,EAAE,YAAY;QACjC,qBAAqB,E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IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC1E,CAAC;CACF","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 Annotation\n */\n\nimport { ColorDefProps } from \"../ColorDef\";\n\n/** Specifies how to separate the numerator and denominator of a [[FractionRun]], by either a horizontal or diagonal bar.\n * @see [[TextStyleSettingsProps.stackedFractionType]] and [[TextStyleSettings.stackedFractionType]].\n * @beta\n */\nexport type StackedFractionType = \"horizontal\" | \"diagonal\";\n\n/** Describes the color in which to draw the text in a [[TextRun]].\n * \"subcategory\" indicates that the text should be drawn using the color of the [SubCategory]($backend) specified by the [GeometryStream]($docs/learning/common/GeometryStream.md) hosting the\n * text.\n * @beta\n */\nexport type TextStyleColor = ColorDefProps | \"subcategory\";\n\n/** Properties describing the appearance of [[TextAnnotationLeader]] in a [[TextAnnotation]].\n * Used when producing geometry for [[TextAnnotation]].\n * @beta\n */\nexport interface TextLeaderStyleProps {\n /** The color of the leader.\n * Default: \"subcategory\".\n */\n color?: TextStyleColor;\n /** Whether to use an elbow in the leader.\n * Default: false\n */\n wantElbow?: boolean;\n /** Multiplier used to compute length of the elbow in the leader.\n * The elbowLength is computed in meters as elbowLength * [[lineHeight]].\n * Default: 1.0\n */\n elbowLength?: number;\n /** Multiplier to compute height of the leader terminator.\n * The terminator height is computed in meters as terminatorHeight * [[lineHeight]].\n * Default: 1.0\n */\n terminatorHeightFactor?: number;\n /** Multiplier to compute width of the leader terminator.\n * The terminator width is computed in meters as terminatorWidth * [[lineHeight]].\n * Default: 1.0\n */\n terminatorWidthFactor?: number;\n}\n\n/** Serves both as the JSON representation of a [[TextStyleSettings]], and a way for a [[TextBlockComponent]] to selectively override aspects of a [[TextStyle]]'s properties.\n * @beta\n */\nexport interface TextStyleSettingsProps {\n /** The color of the text.\n * Default: \"subcategory\".\n */\n color?: TextStyleColor;\n /** The name of a font stored in a [Workspace]($backend), used to draw the contents of a [[TextRun]].\n * Default: \"\" (an invalid font name).\n */\n fontName?: string;\n /** The height each line of text, in meters. Many other settings use the line height as the basis for computing their own values.\n * For example, the height and offset from baseline of a subscript [[TextRun]] are computed as lineHeight * [[subScriptScale]] and\n * lineHeight * [[subScriptOffsetFactor]], respectively.\n * Default: 1.0. */\n lineHeight?: number;\n /** Multiplier used to compute the vertical distance between two lines of text.\n * The distance is computed in meters as lineSpacingFactor * [[lineHeight]].\n * Default: 0.5.\n */\n lineSpacingFactor?: number;\n /** Specifies whether the content of a [[TextRun]] should be rendered **bold**.\n * Default: false.\n */\n isBold?: boolean;\n /** Specifies whether the content of a [[TextRun]] should be rendered in *italics*.\n * Default: false.\n */\n isItalic?: boolean;\n /** Specifies whether the content of a [[TextRun]] should be underlined.\n * Default: false.\n */\n isUnderlined?: boolean;\n /** Multiplier used to compute the height of both the numerator and denominator of a [[FractionRun]].\n * The height is computed in meters as stackedFractionScale * [[lineHeight]].\n * Default: 0.7.\n */\n stackedFractionScale?: number;\n /** Specifies how to separate the numerator and denominator of a [[FractionRun]].\n * Default: \"horizontal\".\n */\n stackedFractionType?: StackedFractionType;\n /** Multiplier used to compute the vertical offset from the baseline for a subscript [[TextRun]].\n * The offset is computed in meters as subScriptOffsetFactor * [[lineHeight]].\n * Default: -0.15.\n */\n subScriptOffsetFactor?: number;\n /** Multiplier used to compute the height of a subscript [[TextRun]].\n * The height is computed as subScriptScale * [[lineHeight]].\n * Default: 2/3\n */\n subScriptScale?: number;\n /** Multiplier used to compute the vertical offset from the baseline for a super [[TextRun]].\n * The offset is computed in meters as superScriptOffsetFactor * [[lineHeight]].\n * Default: -0.5.\n */\n superScriptOffsetFactor?: number;\n /** Multiplier used to compute the height of a superscript [[TextRun]].\n * The height is computed as superScriptScale * [[lineHeight]].\n * Default: 2/3\n */\n superScriptScale?: number;\n /** A scale applied to the width of each glyph.\n * Default: 1.0\n */\n widthFactor?: number;\n\n /** Properties describing appearance of leaders in a [[TextAnnotation]]\n * Used when producing geometry for [[TextAnnotation]]\n * Default: {color:\"subcategory\", wantElbow:\"false\",elbowLength:1, terminatorWidthFactor:1, terminatorHeightFactor:1}.\n */\n leader?: TextLeaderStyleProps;\n /** The size (in meters) used to calculate the tab stops in a run.\n * These are equally spaced from the left edge of the TextBlock.\n * Default: 4 meters.\n */\n tabInterval?: number;\n}\n\n/** A description of the formatting to be applied to a [[TextBlockComponent]].\n * Named instances of these settings can be stored as [[TextStyle]]s in a [Workspace]($backend).\n * @note This is an immutable type. Use [[clone]] to create a modified copy.\n * @see [[TextStyleSettingsProps]] for documentation of each of the settings.\n * @beta\n */\nexport class TextStyleSettings {\n /** The color of the text. */\n public readonly color: TextStyleColor;\n /** The name of a font stored in a [Workspace]($backend), used to draw the contents of a [[TextRun]].\n */\n public readonly fontName: string;\n /** The height each line of text, in meters. Many other settings use the line height as the basis for computing their own values.\n * For example, the height and offset from baseline of a subscript [[TextRun]] are computed as lineHeight * [[subScriptScale]] and\n * lineHeight * [[subScriptOffsetFactor]], respectively.\n */\n public readonly lineHeight: number;\n /** Multiplier used to compute the vertical distance between two lines of text.\n * The distance is computed in meters as lineSpacingFactor * [[lineHeight]].\n */\n public readonly lineSpacingFactor: number;\n /** Specifies whether the content of a [[TextRun]] should be rendered **bold**. */\n public readonly isBold: boolean;\n /** Specifies whether the content of a [[TextRun]] should be rendered in *italics*. */\n public readonly isItalic: boolean;\n /** Specifies whether the content of a [[TextRun]] should be underlined. */\n public readonly isUnderlined: boolean;\n /** Multiplier used to compute the height of both the numerator and denominator of a [[FractionRun]].\n * The height is computed in meters as stackedFractionScale * [[lineHeight]].\n */\n public readonly stackedFractionScale: number;\n /** Specifies how to separate the numerator and denominator of a [[FractionRun]]. */\n public readonly stackedFractionType: StackedFractionType;\n /** Multiplier used to compute the vertical offset from the baseline for a subscript [[TextRun]].\n * The offset is computed in meters as subScriptOffsetFactor * [[lineHeight]].\n */\n public readonly subScriptOffsetFactor: number;\n /** Multiplier used to compute the height of a subscript [[TextRun]].\n * The height is computed as subScriptScale * [[lineHeight]].\n */\n public readonly subScriptScale: number;\n /** Multiplier used to compute the vertical offset from the baseline for a super [[TextRun]].\n * The offset is computed in meters as superScriptOffsetFactor * [[lineHeight]].\n */\n public readonly superScriptOffsetFactor: number;\n /** Multiplier used to compute the height of a superscript [[TextRun]].\n * The height is computed as superScriptScale * [[lineHeight]].\n */\n public readonly superScriptScale: number;\n /** Multiplier used to compute the width of each glyph, relative to [[lineHeight]]. */\n public readonly widthFactor: number;\n /** Properties describing appearance of leaders in a [[TextAnnotation]].\n * Used when producing geometry for [[TextAnnotation]].\n */\n public readonly leader: Readonly<Required<TextLeaderStyleProps>>;\n /** The size (in meters) used to calculate the tab stops in a run.\n * These are equally spaced from the left edge of the TextBlock. Default is 4 meters.\n */\n public readonly tabInterval: number;\n\n /** A fully-populated JSON representation of the default settings. */\n public static defaultProps: Readonly<Required<TextStyleSettingsProps>> = {\n color: \"subcategory\",\n fontName: \"\",\n lineHeight: 1,\n lineSpacingFactor: 0.5,\n isBold: false,\n isItalic: false,\n isUnderlined: false,\n stackedFractionScale: 0.7,\n stackedFractionType: \"horizontal\",\n subScriptOffsetFactor: -0.15,\n subScriptScale: 2 / 3,\n superScriptOffsetFactor: 0.5,\n superScriptScale: 2 / 3,\n widthFactor: 1,\n leader: {\n color: \"subcategory\",\n wantElbow: false,\n elbowLength: 1.0,\n terminatorHeightFactor: 1.0,\n terminatorWidthFactor: 1.0,\n },\n tabInterval: 4,\n };\n\n /** Settings initialized to all default values. */\n public static defaults: TextStyleSettings = new TextStyleSettings({});\n\n private constructor(props: TextStyleSettingsProps, defaults?: Required<TextStyleSettingsProps>) {\n if (!defaults) {\n defaults = TextStyleSettings.defaultProps;\n }\n\n this.color = props.color ?? defaults.color;\n this.fontName = props.fontName ?? defaults.fontName;\n this.lineHeight = props.lineHeight ?? defaults.lineHeight;\n this.lineSpacingFactor = props.lineSpacingFactor ?? defaults.lineSpacingFactor;\n this.isBold = props.isBold ?? defaults.isBold;\n this.isItalic = props.isItalic ?? defaults.isItalic;\n this.isUnderlined = props.isUnderlined ?? defaults.isUnderlined;\n this.stackedFractionScale = props.stackedFractionScale ?? defaults.stackedFractionScale;\n this.stackedFractionType = props.stackedFractionType ?? defaults.stackedFractionType;\n this.subScriptOffsetFactor = props.subScriptOffsetFactor ?? defaults.subScriptOffsetFactor;\n this.subScriptScale = props.subScriptScale ?? defaults.subScriptScale;\n this.superScriptOffsetFactor = props.superScriptOffsetFactor ?? defaults.superScriptOffsetFactor;\n this.superScriptScale = props.superScriptScale ?? defaults.superScriptScale;\n this.widthFactor = props.widthFactor ?? defaults.widthFactor;\n const leader = {\n color: props.leader?.color ?? defaults.leader.color,\n wantElbow: props.leader?.wantElbow ?? defaults.leader.wantElbow,\n elbowLength: props.leader?.elbowLength ?? defaults.leader.elbowLength,\n terminatorHeightFactor: props.leader?.terminatorHeightFactor ?? defaults.leader.terminatorHeightFactor,\n terminatorWidthFactor: props.leader?.terminatorWidthFactor ?? defaults.leader.terminatorWidthFactor,\n }\n this.leader = Object.freeze(leader) as Readonly<Required<TextLeaderStyleProps>>;\n this.tabInterval = props.tabInterval ?? defaults.tabInterval;\n }\n\n /** Create a copy of these settings, modified according to the properties defined by `alteredProps`. */\n public clone(alteredProps?: TextStyleSettingsProps): TextStyleSettings {\n return alteredProps ? new TextStyleSettings(alteredProps, this) : this;\n }\n\n /** Create settings from their JSON representation. */\n public static fromJSON(props?: TextStyleSettingsProps): TextStyleSettings {\n return props ? new TextStyleSettings(props) : TextStyleSettings.defaults;\n }\n\n public toJSON(): TextStyleSettingsProps {\n return { ...this };\n }\n /** Compare two [[TextLeaderStyleProps]] for equality.\n * @param other The other leader style properties to compare against.\n * @returns true if the two leader styles are equal, false otherwise.\n */\n public leaderEquals(other: TextLeaderStyleProps): boolean {\n return this.leader.color === other.color && this.leader.wantElbow === other.wantElbow\n && this.leader.elbowLength === other.elbowLength && this.leader.terminatorHeightFactor === other.terminatorHeightFactor\n && this.leader.terminatorWidthFactor === other.terminatorWidthFactor;\n }\n\n public equals(other: TextStyleSettings): boolean {\n return this.color === other.color && this.fontName === other.fontName\n && this.lineHeight === other.lineHeight && this.lineSpacingFactor === other.lineSpacingFactor && this.widthFactor === other.widthFactor\n && this.isBold === other.isBold && this.isItalic === other.isItalic && this.isUnderlined === other.isUnderlined\n && this.stackedFractionType === other.stackedFractionType && this.stackedFractionScale === other.stackedFractionScale\n && this.subScriptOffsetFactor === other.subScriptOffsetFactor && this.subScriptScale === other.subScriptScale\n && this.superScriptOffsetFactor === other.superScriptOffsetFactor\n && this.superScriptScale === other.superScriptScale\n && this.tabInterval === other.tabInterval && this.leaderEquals(other.leader);\n }\n}\n\nObject.freeze(TextStyleSettings.defaultProps);\nObject.freeze(TextStyleSettings.defaults);\n\n/** The JSON representation of a [[TextStyle]].\n * @beta\n */\nexport interface TextStyleProps {\n /** The name of the style. */\n name: string;\n /** The settings defined for the style. Any omitted properties will use their default values, as described by [[TextStyleSettingsProps]]. */\n settings?: TextStyleSettingsProps;\n}\n\n/** A named, immutable [[TextStyleSettings]] stored in a [Workspace]($backend).\n * @see [[TextBlockComponent.styleName]] to define the text style for a component of a [[TextBlock]].\n * @note This is an immutable type. Use [[clone]] to create a modified copy.\n * @beta\n */\nexport class TextStyle {\n public readonly name: string;\n public readonly settings: TextStyleSettings;\n\n private constructor(name: string, settings: TextStyleSettings) {\n this.name = name;\n this.settings = settings;\n }\n\n /** Create a style from its JSON representation. */\n public static fromJSON(json: TextStyleProps): TextStyle {\n return TextStyle.create(json.name, TextStyleSettings.fromJSON(json.settings));\n }\n\n /** Create a new style. */\n public static create(name: string, settings: TextStyleSettings): TextStyle {\n return new TextStyle(name, settings);\n }\n\n /** Create a copy of this style with the same name, and settings modified according to the properties defined by `alteredSettings`. */\n public clone(alteredSettings: TextStyleSettingsProps): TextStyle {\n return TextStyle.create(this.name, this.settings.clone(alteredSettings));\n }\n\n public equals(other: TextStyle): boolean {\n return this.name === other.name && this.settings.equals(other.settings);\n }\n}\n\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/core-common",
3
- "version": "5.1.0-dev.56",
3
+ "version": "5.1.0-dev.58",
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": "5.1.0-dev.56",
31
- "@itwin/core-geometry": "5.1.0-dev.56"
30
+ "@itwin/core-bentley": "5.1.0-dev.58",
31
+ "@itwin/core-geometry": "5.1.0-dev.58"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@itwin/eslint-plugin": "5.0.0-dev.1",
@@ -42,9 +42,9 @@
42
42
  "rimraf": "^6.0.1",
43
43
  "typescript": "~5.6.2",
44
44
  "vitest": "^3.0.6",
45
- "@itwin/build-tools": "5.1.0-dev.56",
46
- "@itwin/core-geometry": "5.1.0-dev.56",
47
- "@itwin/core-bentley": "5.1.0-dev.56"
45
+ "@itwin/build-tools": "5.1.0-dev.58",
46
+ "@itwin/core-geometry": "5.1.0-dev.58",
47
+ "@itwin/core-bentley": "5.1.0-dev.58"
48
48
  },
49
49
  "nyc": {
50
50
  "extends": "./node_modules/@itwin/build-tools/.nycrc",