@itwin/core-backend 5.2.0-dev.8 → 5.3.0-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/CHANGELOG.md +31 -1
  2. package/lib/cjs/BackendHubAccess.d.ts +2 -0
  3. package/lib/cjs/BackendHubAccess.d.ts.map +1 -1
  4. package/lib/cjs/BackendHubAccess.js.map +1 -1
  5. package/lib/cjs/BackendLoggerCategory.d.ts +6 -0
  6. package/lib/cjs/BackendLoggerCategory.d.ts.map +1 -1
  7. package/lib/cjs/BackendLoggerCategory.js +6 -0
  8. package/lib/cjs/BackendLoggerCategory.js.map +1 -1
  9. package/lib/cjs/BriefcaseManager.d.ts +57 -3
  10. package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
  11. package/lib/cjs/BriefcaseManager.js +151 -42
  12. package/lib/cjs/BriefcaseManager.js.map +1 -1
  13. package/lib/cjs/CloudSqlite.d.ts +4 -0
  14. package/lib/cjs/CloudSqlite.d.ts.map +1 -1
  15. package/lib/cjs/CloudSqlite.js.map +1 -1
  16. package/lib/cjs/ECDb.d.ts +8 -0
  17. package/lib/cjs/ECDb.d.ts.map +1 -1
  18. package/lib/cjs/ECDb.js +22 -0
  19. package/lib/cjs/ECDb.js.map +1 -1
  20. package/lib/cjs/IModelDb.d.ts +54 -3
  21. package/lib/cjs/IModelDb.d.ts.map +1 -1
  22. package/lib/cjs/IModelDb.js +87 -9
  23. package/lib/cjs/IModelDb.js.map +1 -1
  24. package/lib/cjs/IModelHost.d.ts +11 -1
  25. package/lib/cjs/IModelHost.d.ts.map +1 -1
  26. package/lib/cjs/IModelHost.js +5 -0
  27. package/lib/cjs/IModelHost.js.map +1 -1
  28. package/lib/cjs/IModelIncrementalSchemaLocater.d.ts +1 -5
  29. package/lib/cjs/IModelIncrementalSchemaLocater.d.ts.map +1 -1
  30. package/lib/cjs/IModelIncrementalSchemaLocater.js +0 -6
  31. package/lib/cjs/IModelIncrementalSchemaLocater.js.map +1 -1
  32. package/lib/cjs/SqliteChangesetReader.d.ts +8 -0
  33. package/lib/cjs/SqliteChangesetReader.d.ts.map +1 -1
  34. package/lib/cjs/SqliteChangesetReader.js +11 -0
  35. package/lib/cjs/SqliteChangesetReader.js.map +1 -1
  36. package/lib/cjs/StashManager.d.ts +175 -0
  37. package/lib/cjs/StashManager.d.ts.map +1 -0
  38. package/lib/cjs/StashManager.js +306 -0
  39. package/lib/cjs/StashManager.js.map +1 -0
  40. package/lib/cjs/TxnManager.d.ts +226 -15
  41. package/lib/cjs/TxnManager.d.ts.map +1 -1
  42. package/lib/cjs/TxnManager.js +249 -23
  43. package/lib/cjs/TxnManager.js.map +1 -1
  44. package/lib/cjs/annotations/ElementDrivesTextAnnotation.d.ts +10 -1
  45. package/lib/cjs/annotations/ElementDrivesTextAnnotation.d.ts.map +1 -1
  46. package/lib/cjs/annotations/ElementDrivesTextAnnotation.js +15 -6
  47. package/lib/cjs/annotations/ElementDrivesTextAnnotation.js.map +1 -1
  48. package/lib/cjs/annotations/LeaderGeometry.d.ts +3 -2
  49. package/lib/cjs/annotations/LeaderGeometry.d.ts.map +1 -1
  50. package/lib/cjs/annotations/LeaderGeometry.js +5 -4
  51. package/lib/cjs/annotations/LeaderGeometry.js.map +1 -1
  52. package/lib/cjs/annotations/TextAnnotationElement.d.ts +52 -24
  53. package/lib/cjs/annotations/TextAnnotationElement.d.ts.map +1 -1
  54. package/lib/cjs/annotations/TextAnnotationElement.js +49 -59
  55. package/lib/cjs/annotations/TextAnnotationElement.js.map +1 -1
  56. package/lib/cjs/annotations/TextAnnotationGeometry.d.ts +2 -0
  57. package/lib/cjs/annotations/TextAnnotationGeometry.d.ts.map +1 -1
  58. package/lib/cjs/annotations/TextAnnotationGeometry.js +26 -19
  59. package/lib/cjs/annotations/TextAnnotationGeometry.js.map +1 -1
  60. package/lib/cjs/annotations/TextBlockGeometry.d.ts.map +1 -1
  61. package/lib/cjs/annotations/TextBlockGeometry.js +8 -0
  62. package/lib/cjs/annotations/TextBlockGeometry.js.map +1 -1
  63. package/lib/cjs/annotations/TextBlockLayout.d.ts +49 -36
  64. package/lib/cjs/annotations/TextBlockLayout.d.ts.map +1 -1
  65. package/lib/cjs/annotations/TextBlockLayout.js +204 -135
  66. package/lib/cjs/annotations/TextBlockLayout.js.map +1 -1
  67. package/lib/cjs/internal/ChannelAdmin.js +1 -1
  68. package/lib/cjs/internal/ChannelAdmin.js.map +1 -1
  69. package/lib/cjs/internal/Symbols.d.ts +1 -0
  70. package/lib/cjs/internal/Symbols.d.ts.map +1 -1
  71. package/lib/cjs/internal/Symbols.js +2 -1
  72. package/lib/cjs/internal/Symbols.js.map +1 -1
  73. package/lib/cjs/internal/annotations/fields.d.ts +2 -12
  74. package/lib/cjs/internal/annotations/fields.d.ts.map +1 -1
  75. package/lib/cjs/internal/annotations/fields.js +49 -45
  76. package/lib/cjs/internal/annotations/fields.js.map +1 -1
  77. package/lib/cjs/workspace/Workspace.d.ts +1 -1
  78. package/lib/cjs/workspace/Workspace.js.map +1 -1
  79. package/lib/esm/BackendHubAccess.d.ts +2 -0
  80. package/lib/esm/BackendHubAccess.d.ts.map +1 -1
  81. package/lib/esm/BackendHubAccess.js.map +1 -1
  82. package/lib/esm/BackendLoggerCategory.d.ts +6 -0
  83. package/lib/esm/BackendLoggerCategory.d.ts.map +1 -1
  84. package/lib/esm/BackendLoggerCategory.js +6 -0
  85. package/lib/esm/BackendLoggerCategory.js.map +1 -1
  86. package/lib/esm/BriefcaseManager.d.ts +57 -3
  87. package/lib/esm/BriefcaseManager.d.ts.map +1 -1
  88. package/lib/esm/BriefcaseManager.js +152 -43
  89. package/lib/esm/BriefcaseManager.js.map +1 -1
  90. package/lib/esm/CloudSqlite.d.ts +4 -0
  91. package/lib/esm/CloudSqlite.d.ts.map +1 -1
  92. package/lib/esm/CloudSqlite.js.map +1 -1
  93. package/lib/esm/ECDb.d.ts +8 -0
  94. package/lib/esm/ECDb.d.ts.map +1 -1
  95. package/lib/esm/ECDb.js +22 -0
  96. package/lib/esm/ECDb.js.map +1 -1
  97. package/lib/esm/IModelDb.d.ts +54 -3
  98. package/lib/esm/IModelDb.d.ts.map +1 -1
  99. package/lib/esm/IModelDb.js +88 -10
  100. package/lib/esm/IModelDb.js.map +1 -1
  101. package/lib/esm/IModelHost.d.ts +11 -1
  102. package/lib/esm/IModelHost.d.ts.map +1 -1
  103. package/lib/esm/IModelHost.js +5 -0
  104. package/lib/esm/IModelHost.js.map +1 -1
  105. package/lib/esm/IModelIncrementalSchemaLocater.d.ts +1 -5
  106. package/lib/esm/IModelIncrementalSchemaLocater.d.ts.map +1 -1
  107. package/lib/esm/IModelIncrementalSchemaLocater.js +0 -6
  108. package/lib/esm/IModelIncrementalSchemaLocater.js.map +1 -1
  109. package/lib/esm/SqliteChangesetReader.d.ts +8 -0
  110. package/lib/esm/SqliteChangesetReader.d.ts.map +1 -1
  111. package/lib/esm/SqliteChangesetReader.js +11 -0
  112. package/lib/esm/SqliteChangesetReader.js.map +1 -1
  113. package/lib/esm/StashManager.d.ts +175 -0
  114. package/lib/esm/StashManager.d.ts.map +1 -0
  115. package/lib/esm/StashManager.js +301 -0
  116. package/lib/esm/StashManager.js.map +1 -0
  117. package/lib/esm/TxnManager.d.ts +226 -15
  118. package/lib/esm/TxnManager.d.ts.map +1 -1
  119. package/lib/esm/TxnManager.js +247 -21
  120. package/lib/esm/TxnManager.js.map +1 -1
  121. package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts +10 -1
  122. package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts.map +1 -1
  123. package/lib/esm/annotations/ElementDrivesTextAnnotation.js +13 -5
  124. package/lib/esm/annotations/ElementDrivesTextAnnotation.js.map +1 -1
  125. package/lib/esm/annotations/LeaderGeometry.d.ts +3 -2
  126. package/lib/esm/annotations/LeaderGeometry.d.ts.map +1 -1
  127. package/lib/esm/annotations/LeaderGeometry.js +5 -4
  128. package/lib/esm/annotations/LeaderGeometry.js.map +1 -1
  129. package/lib/esm/annotations/TextAnnotationElement.d.ts +52 -24
  130. package/lib/esm/annotations/TextAnnotationElement.d.ts.map +1 -1
  131. package/lib/esm/annotations/TextAnnotationElement.js +51 -61
  132. package/lib/esm/annotations/TextAnnotationElement.js.map +1 -1
  133. package/lib/esm/annotations/TextAnnotationGeometry.d.ts +2 -0
  134. package/lib/esm/annotations/TextAnnotationGeometry.d.ts.map +1 -1
  135. package/lib/esm/annotations/TextAnnotationGeometry.js +26 -19
  136. package/lib/esm/annotations/TextAnnotationGeometry.js.map +1 -1
  137. package/lib/esm/annotations/TextBlockGeometry.d.ts.map +1 -1
  138. package/lib/esm/annotations/TextBlockGeometry.js +8 -0
  139. package/lib/esm/annotations/TextBlockGeometry.js.map +1 -1
  140. package/lib/esm/annotations/TextBlockLayout.d.ts +49 -36
  141. package/lib/esm/annotations/TextBlockLayout.d.ts.map +1 -1
  142. package/lib/esm/annotations/TextBlockLayout.js +205 -136
  143. package/lib/esm/annotations/TextBlockLayout.js.map +1 -1
  144. package/lib/esm/internal/ChannelAdmin.js +1 -1
  145. package/lib/esm/internal/ChannelAdmin.js.map +1 -1
  146. package/lib/esm/internal/Symbols.d.ts +1 -0
  147. package/lib/esm/internal/Symbols.d.ts.map +1 -1
  148. package/lib/esm/internal/Symbols.js +1 -0
  149. package/lib/esm/internal/Symbols.js.map +1 -1
  150. package/lib/esm/internal/annotations/fields.d.ts +2 -12
  151. package/lib/esm/internal/annotations/fields.d.ts.map +1 -1
  152. package/lib/esm/internal/annotations/fields.js +51 -47
  153. package/lib/esm/internal/annotations/fields.js.map +1 -1
  154. package/lib/esm/test/AnnotationTestUtils.d.ts +5 -1
  155. package/lib/esm/test/AnnotationTestUtils.d.ts.map +1 -1
  156. package/lib/esm/test/AnnotationTestUtils.js +6 -1
  157. package/lib/esm/test/AnnotationTestUtils.js.map +1 -1
  158. package/lib/esm/test/annotations/Fields.test.js +163 -46
  159. package/lib/esm/test/annotations/Fields.test.js.map +1 -1
  160. package/lib/esm/test/annotations/LeaderGeometry.test.js +12 -10
  161. package/lib/esm/test/annotations/LeaderGeometry.test.js.map +1 -1
  162. package/lib/esm/test/annotations/TextAnnotation.test.js +299 -43
  163. package/lib/esm/test/annotations/TextAnnotation.test.js.map +1 -1
  164. package/lib/esm/test/annotations/TextBlock.test.js +453 -86
  165. package/lib/esm/test/annotations/TextBlock.test.js.map +1 -1
  166. package/lib/esm/test/assets/IncrementalSchemaLocater/configs/simple.config.d.ts +46 -0
  167. package/lib/esm/test/assets/IncrementalSchemaLocater/configs/simple.config.d.ts.map +1 -1
  168. package/lib/esm/test/assets/IncrementalSchemaLocater/configs/simple.config.js +20 -2
  169. package/lib/esm/test/assets/IncrementalSchemaLocater/configs/simple.config.js.map +1 -1
  170. package/lib/esm/test/ecdb/ECDb.test.js +71 -1
  171. package/lib/esm/test/ecdb/ECDb.test.js.map +1 -1
  172. package/lib/esm/test/hubaccess/Rebase.test.d.ts +2 -0
  173. package/lib/esm/test/hubaccess/Rebase.test.d.ts.map +1 -0
  174. package/lib/esm/test/hubaccess/Rebase.test.js +640 -0
  175. package/lib/esm/test/hubaccess/Rebase.test.js.map +1 -0
  176. package/lib/esm/test/incrementalSchemaLocater/ECSqlQueries.test.js +20 -20
  177. package/lib/esm/test/incrementalSchemaLocater/ECSqlQueries.test.js.map +1 -1
  178. package/lib/esm/test/incrementalSchemaLocater/IncrementalLoading.test.js +3 -3
  179. package/lib/esm/test/incrementalSchemaLocater/IncrementalLoading.test.js.map +1 -1
  180. package/lib/esm/test/incrementalSchemaLocater/utils/TestSqlSchemaLocater.d.ts +16 -1
  181. package/lib/esm/test/incrementalSchemaLocater/utils/TestSqlSchemaLocater.d.ts.map +1 -1
  182. package/lib/esm/test/incrementalSchemaLocater/utils/TestSqlSchemaLocater.js +47 -0
  183. package/lib/esm/test/incrementalSchemaLocater/utils/TestSqlSchemaLocater.js.map +1 -1
  184. package/lib/esm/test/standalone/ChangeMerge.test.js +15 -19
  185. package/lib/esm/test/standalone/ChangeMerge.test.js.map +1 -1
  186. package/lib/esm/test/standalone/ChangesetReader.test.js +131 -1
  187. package/lib/esm/test/standalone/ChangesetReader.test.js.map +1 -1
  188. package/lib/esm/test/standalone/MergeConflict.test.js +3 -3
  189. package/lib/esm/test/standalone/MergeConflict.test.js.map +1 -1
  190. package/lib/esm/workspace/Workspace.d.ts +1 -1
  191. package/lib/esm/workspace/Workspace.js.map +1 -1
  192. package/package.json +13 -13
@@ -1,11 +1,45 @@
1
1
  /** @packageDocumentation
2
2
  * @module Elements
3
3
  */
4
- import { AnnotationTextStyleProps, Code, CodeProps, CodeScopeProps, EntityReferenceSet, Placement2dProps, Placement3dProps, TextAnnotation, TextAnnotation2dProps, TextAnnotation3dProps, TextAnnotationProps, TextStyleSettings, TextStyleSettingsProps } from "@itwin/core-common";
4
+ import { AnnotationTextStyleProps, Code, CodeProps, CodeScopeProps, Placement2dProps, Placement3dProps, TextAnnotation, TextAnnotation2dProps, TextAnnotation3dProps, TextAnnotationProps, TextStyleSettings, TextStyleSettingsProps } from "@itwin/core-common";
5
5
  import { IModelDb } from "../IModelDb";
6
6
  import { AnnotationElement2d, DefinitionElement, GraphicalElement3d, OnElementIdArg, OnElementPropsArg } from "../Element";
7
7
  import { Id64String } from "@itwin/core-bentley";
8
- import { TextBlockAndId } from "./ElementDrivesTextAnnotation";
8
+ import { TextAnnotationUsesTextStyleByDefault, TextBlockAndId } from "./ElementDrivesTextAnnotation";
9
+ /** Arguments supplied when creating a [[TextAnnotation2d]].
10
+ * @beta
11
+ */
12
+ export interface TextAnnotation2dCreateArgs {
13
+ /** The category ID for the annotation. */
14
+ category: Id64String;
15
+ /** The model ID where the annotation will be placed. */
16
+ model: Id64String;
17
+ /** The placement properties for the annotation. */
18
+ placement: Placement2dProps;
19
+ /** The default text style ID for the annotation. */
20
+ defaultTextStyleId?: Id64String;
21
+ /** Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation2d`. Essentially an empty element if not provided. */
22
+ textAnnotationData?: TextAnnotationProps;
23
+ /** Optional code for the element. */
24
+ code?: CodeProps;
25
+ }
26
+ /** Arguments supplied when creating a [[TextAnnotation3d]].
27
+ * @beta
28
+ */
29
+ export interface TextAnnotation3dCreateArgs {
30
+ /** The category ID for the annotation. */
31
+ category: Id64String;
32
+ /** The model ID where the annotation will be placed. */
33
+ model: Id64String;
34
+ /** The placement properties for the annotation. */
35
+ placement: Placement3dProps;
36
+ /** The default text style ID for the annotation. */
37
+ defaultTextStyleId?: Id64String;
38
+ /** Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation3d`. Essentially an empty element if not provided. */
39
+ textAnnotationData?: TextAnnotationProps;
40
+ /** Optional code for the element. */
41
+ code?: CodeProps;
42
+ }
9
43
  /** An element that displays textual content within a 2d model.
10
44
  * The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.
11
45
  * @see [[setAnnotation]] to change the textual content.
@@ -14,6 +48,11 @@ import { TextBlockAndId } from "./ElementDrivesTextAnnotation";
14
48
  export declare class TextAnnotation2d extends AnnotationElement2d {
15
49
  /** @internal */
16
50
  static get className(): string;
51
+ /**
52
+ * The default [[AnnotationTextStyle]] used by the TextAnnotation2d.
53
+ * @beta
54
+ */
55
+ defaultTextStyle?: TextAnnotationUsesTextStyleByDefault;
17
56
  /** Optional string containing the data associated with the text annotation. */
18
57
  private _textAnnotationData?;
19
58
  /** Extract the textual content, if present.
@@ -37,13 +76,10 @@ export declare class TextAnnotation2d extends AnnotationElement2d {
37
76
  toJSON(): TextAnnotation2dProps;
38
77
  /** Creates a new `TextAnnotation2d` instance with the specified properties.
39
78
  * @param iModelDb The iModel.
40
- * @param category The category ID for the annotation.
41
- * @param model The model ID where the annotation will be placed.
42
- * @param placement The placement properties for the annotation.
43
- * @param textAnnotationData Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation2d`. Essentially an empty element if not provided.
44
- * @param code Optional code for the element.
79
+ * @param arg The arguments for creating the TextAnnotation2d.
80
+ * @beta
45
81
  */
46
- static create(iModelDb: IModelDb, category: Id64String, model: Id64String, placement: Placement2dProps, textAnnotationData?: TextAnnotationProps, code?: CodeProps): TextAnnotation2d;
82
+ static create(iModelDb: IModelDb, arg: TextAnnotation2dCreateArgs): TextAnnotation2d;
47
83
  /**
48
84
  * Updates the geometry of the TextAnnotation2d on insert.
49
85
  * @inheritdoc
@@ -61,11 +97,6 @@ export declare class TextAnnotation2d extends AnnotationElement2d {
61
97
  * It only does this if the `elementGeometryBuilderParams` is not already set and if there is actually a text annotation to produce geometry for.
62
98
  */
63
99
  protected static updateGeometry(iModelDb: IModelDb, props: TextAnnotation2dProps): void;
64
- /**
65
- * Collects reference IDs used by this `TextAnnotation2d`.
66
- * @inheritdoc
67
- */
68
- protected collectReferenceIds(ids: EntityReferenceSet): void;
69
100
  /** @internal */
70
101
  getTextBlocks(): Iterable<TextBlockAndId>;
71
102
  /** @internal */
@@ -83,6 +114,11 @@ export declare class TextAnnotation2d extends AnnotationElement2d {
83
114
  export declare class TextAnnotation3d extends GraphicalElement3d {
84
115
  /** @internal */
85
116
  static get className(): string;
117
+ /**
118
+ * The default [[AnnotationTextStyle]] used by the TextAnnotation3d.
119
+ * @beta
120
+ */
121
+ defaultTextStyle?: TextAnnotationUsesTextStyleByDefault;
86
122
  /** Optional string containing the data associated with the text annotation. */
87
123
  private _textAnnotationData?;
88
124
  /** Extract the textual content, if present.
@@ -105,13 +141,10 @@ export declare class TextAnnotation3d extends GraphicalElement3d {
105
141
  toJSON(): TextAnnotation3dProps;
106
142
  /** Creates a new `TextAnnotation3d` instance with the specified properties.
107
143
  * @param iModelDb The iModel.
108
- * @param category The category ID for the annotation.
109
- * @param model The model ID where the annotation will be placed.
110
- * @param placement The placement properties for the annotation.
111
- * @param textAnnotationData Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation3d`. Essentially an empty element if not provided.
112
- * @param code Optional code for the element.
144
+ * @param arg The arguments for creating the TextAnnotation3d.
145
+ * @beta
113
146
  */
114
- static create(iModelDb: IModelDb, category: Id64String, model: Id64String, placement: Placement3dProps, textAnnotationData?: TextAnnotationProps, code?: CodeProps): TextAnnotation3d;
147
+ static create(iModelDb: IModelDb, arg: TextAnnotation3dCreateArgs): TextAnnotation3d;
115
148
  /**
116
149
  * Updates the geometry of the TextAnnotation3d on insert.
117
150
  * @inheritdoc
@@ -129,11 +162,6 @@ export declare class TextAnnotation3d extends GraphicalElement3d {
129
162
  * It only does this if the `elementGeometryBuilderParams` is not already set and if there is actually a text annotation to produce geometry for.
130
163
  */
131
164
  protected static updateGeometry(iModelDb: IModelDb, props: TextAnnotation3dProps): void;
132
- /**
133
- * Collects reference IDs used by this `TextAnnotation3d`.
134
- * @inheritdoc
135
- */
136
- protected collectReferenceIds(ids: EntityReferenceSet): void;
137
165
  /** @internal */
138
166
  getTextBlocks(): Iterable<TextBlockAndId>;
139
167
  /** @internal */
@@ -1 +1 @@
1
- {"version":3,"file":"TextAnnotationElement.d.ts","sourceRoot":"","sources":["../../../src/annotations/TextAnnotationElement.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,wBAAwB,EAAe,IAAI,EAAE,SAAS,EAAE,cAAc,EAA2D,kBAAkB,EAAe,gBAAgB,EAAe,gBAAgB,EAAkB,cAAc,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACrY,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC3H,OAAO,EAAU,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGzD,OAAO,EAA+B,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAsB5F;;;;GAIG;AACH,qBAAa,gBAAiB,SAAQ,mBAAmB;IACvD,gB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,MAAM,EAAE,QAAQ,CAAC,EAAE,sBAAsB,EAAE,WAAW,CAAC,EAAE,MAAM;IAW7I;;;OAGG;IACa,MAAM,IAAI,wBAAwB;IAOlD,oFAAoF;WACtE,QAAQ,CAAC,KAAK,EAAE,wBAAwB,EAAE,MAAM,EAAE,QAAQ,GAAG,mBAAmB;IAI9F;;;;OAIG;qBACuB,QAAQ,CAAC,GAAG,EAAE,iBAAiB,GAAG,IAAI;IAKhE;;;;OAIG;qBACuB,QAAQ,CAAC,GAAG,EAAE,iBAAiB,GAAG,IAAI;IAKhE,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAU/B,OAAO,CAAC,MAAM,CAAC,sBAAsB;CAQtC"}
@@ -6,11 +6,11 @@
6
6
  * @module Elements
7
7
  */
8
8
  import { BisCodeSpec, Code, ElementGeometry, Placement2d, Placement3d, TextAnnotation, TextStyleSettings } from "@itwin/core-common";
9
- import { AnnotationElement2d, DefinitionElement, GraphicalElement3d } from "../Element";
9
+ import { AnnotationElement2d, DefinitionElement, Drawing, GraphicalElement3d } from "../Element";
10
10
  import { assert } from "@itwin/core-bentley";
11
11
  import { layoutTextBlock, TextStyleResolver } from "./TextBlockLayout";
12
12
  import { appendTextAnnotationGeometry } from "./TextAnnotationGeometry";
13
- import { ElementDrivesTextAnnotation } from "./ElementDrivesTextAnnotation";
13
+ import { ElementDrivesTextAnnotation, TextAnnotationUsesTextStyleByDefault } from "./ElementDrivesTextAnnotation";
14
14
  function parseTextAnnotationData(json) {
15
15
  if (!json)
16
16
  return undefined;
@@ -21,13 +21,17 @@ function parseTextAnnotationData(json) {
21
21
  return undefined;
22
22
  }
23
23
  }
24
- function getElementGeometryBuilderParams(iModel, modelId, _placementProps, stringifiedAnnotationProps, categoryId, _subCategory) {
24
+ function getElementGeometryBuilderParams(iModel, modelId, _placementProps, stringifiedAnnotationProps, categoryId, textStyleId, _subCategory) {
25
25
  const annotationProps = parseTextAnnotationData(stringifiedAnnotationProps);
26
26
  const textBlock = TextAnnotation.fromJSON(annotationProps).textBlock;
27
- const textStyleResolver = new TextStyleResolver({ textBlock, iModel, modelId });
27
+ const textStyleResolver = new TextStyleResolver({ textBlock, textStyleId: textStyleId ?? "", iModel });
28
28
  const layout = layoutTextBlock({ iModel, textBlock, textStyleResolver });
29
29
  const builder = new ElementGeometry.Builder();
30
- appendTextAnnotationGeometry({ layout, textStyleResolver, annotationProps: annotationProps ?? {}, builder, categoryId });
30
+ let scaleFactor = 1;
31
+ const element = iModel.elements.getElement(modelId);
32
+ if (element instanceof Drawing)
33
+ scaleFactor = element.scaleFactor;
34
+ appendTextAnnotationGeometry({ layout, textStyleResolver, scaleFactor, annotationProps: annotationProps ?? {}, builder, categoryId });
31
35
  return { entryArray: builder.entries };
32
36
  }
33
37
  /** An element that displays textual content within a 2d model.
@@ -38,6 +42,11 @@ function getElementGeometryBuilderParams(iModel, modelId, _placementProps, strin
38
42
  export class TextAnnotation2d extends AnnotationElement2d /* implements ITextAnnotation */ {
39
43
  /** @internal */
40
44
  static get className() { return "TextAnnotation2d"; }
45
+ /**
46
+ * The default [[AnnotationTextStyle]] used by the TextAnnotation2d.
47
+ * @beta
48
+ */
49
+ defaultTextStyle;
41
50
  /** Optional string containing the data associated with the text annotation. */
42
51
  _textAnnotationData;
43
52
  /** Extract the textual content, if present.
@@ -56,6 +65,9 @@ export class TextAnnotation2d extends AnnotationElement2d /* implements ITextAnn
56
65
  }
57
66
  constructor(props, iModel) {
58
67
  super(props, iModel);
68
+ if (props.defaultTextStyle) {
69
+ this.defaultTextStyle = new TextAnnotationUsesTextStyleByDefault(props.defaultTextStyle.id);
70
+ }
59
71
  this._textAnnotationData = props.textAnnotationData;
60
72
  }
61
73
  /** Creates a new instance of `TextAnnotation2d` from its JSON representation. */
@@ -72,28 +84,26 @@ export class TextAnnotation2d extends AnnotationElement2d /* implements ITextAnn
72
84
  const props = super.toJSON();
73
85
  props.textAnnotationData = this._textAnnotationData;
74
86
  if (this._textAnnotationData) {
75
- props.elementGeometryBuilderParams = getElementGeometryBuilderParams(this.iModel, this.model, this.placement, this._textAnnotationData, this.category);
87
+ props.elementGeometryBuilderParams = getElementGeometryBuilderParams(this.iModel, this.model, this.placement, this._textAnnotationData, this.category, this.defaultTextStyle ? this.defaultTextStyle.id : undefined);
76
88
  }
77
89
  return props;
78
90
  }
79
91
  /** Creates a new `TextAnnotation2d` instance with the specified properties.
80
92
  * @param iModelDb The iModel.
81
- * @param category The category ID for the annotation.
82
- * @param model The model ID where the annotation will be placed.
83
- * @param placement The placement properties for the annotation.
84
- * @param textAnnotationData Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation2d`. Essentially an empty element if not provided.
85
- * @param code Optional code for the element.
93
+ * @param arg The arguments for creating the TextAnnotation2d.
94
+ * @beta
86
95
  */
87
- static create(iModelDb, category, model, placement, textAnnotationData, code) {
88
- const props = {
96
+ static create(iModelDb, arg) {
97
+ const elementProps = {
89
98
  classFullName: this.classFullName,
90
- textAnnotationData: JSON.stringify(textAnnotationData),
91
- placement,
92
- model,
93
- category,
94
- code: code ?? Code.createEmpty(),
99
+ textAnnotationData: JSON.stringify(arg.textAnnotationData),
100
+ defaultTextStyle: arg.defaultTextStyleId ? new TextAnnotationUsesTextStyleByDefault(arg.defaultTextStyleId).toJSON() : undefined,
101
+ placement: arg.placement,
102
+ model: arg.model,
103
+ category: arg.category,
104
+ code: arg.code ?? Code.createEmpty(),
95
105
  };
96
- return new this(props, iModelDb);
106
+ return new this(elementProps, iModelDb);
97
107
  }
98
108
  /**
99
109
  * Updates the geometry of the TextAnnotation2d on insert.
@@ -121,20 +131,7 @@ export class TextAnnotation2d extends AnnotationElement2d /* implements ITextAnn
121
131
  if (props.elementGeometryBuilderParams || !props.textAnnotationData) {
122
132
  return;
123
133
  }
124
- props.elementGeometryBuilderParams = getElementGeometryBuilderParams(iModelDb, props.model, props.placement ?? Placement2d.fromJSON(), props.textAnnotationData, props.category);
125
- }
126
- /**
127
- * Collects reference IDs used by this `TextAnnotation2d`.
128
- * @inheritdoc
129
- */
130
- collectReferenceIds(ids) {
131
- super.collectReferenceIds(ids);
132
- const annotation = this.getAnnotation();
133
- if (!annotation) {
134
- return;
135
- }
136
- if (annotation.textBlock.styleId)
137
- ids.addElement(annotation.textBlock.styleId);
134
+ props.elementGeometryBuilderParams = getElementGeometryBuilderParams(iModelDb, props.model, props.placement ?? Placement2d.fromJSON(), props.textAnnotationData, props.category, props.defaultTextStyle ? props.defaultTextStyle.id : undefined);
138
135
  }
139
136
  /** @internal */
140
137
  getTextBlocks() {
@@ -163,6 +160,11 @@ export class TextAnnotation2d extends AnnotationElement2d /* implements ITextAnn
163
160
  export class TextAnnotation3d extends GraphicalElement3d /* implements ITextAnnotation */ {
164
161
  /** @internal */
165
162
  static get className() { return "TextAnnotation3d"; }
163
+ /**
164
+ * The default [[AnnotationTextStyle]] used by the TextAnnotation3d.
165
+ * @beta
166
+ */
167
+ defaultTextStyle;
166
168
  /** Optional string containing the data associated with the text annotation. */
167
169
  _textAnnotationData;
168
170
  /** Extract the textual content, if present.
@@ -181,6 +183,9 @@ export class TextAnnotation3d extends GraphicalElement3d /* implements ITextAnno
181
183
  }
182
184
  constructor(props, iModel) {
183
185
  super(props, iModel);
186
+ if (props.defaultTextStyle) {
187
+ this.defaultTextStyle = new TextAnnotationUsesTextStyleByDefault(props.defaultTextStyle.id);
188
+ }
184
189
  this._textAnnotationData = props.textAnnotationData;
185
190
  }
186
191
  /** Creates a new instance of `TextAnnotation3d` from its JSON representation. */
@@ -196,28 +201,26 @@ export class TextAnnotation3d extends GraphicalElement3d /* implements ITextAnno
196
201
  const props = super.toJSON();
197
202
  props.textAnnotationData = this._textAnnotationData;
198
203
  if (this._textAnnotationData) {
199
- props.elementGeometryBuilderParams = getElementGeometryBuilderParams(this.iModel, this.model, this.placement, this._textAnnotationData, this.category);
204
+ props.elementGeometryBuilderParams = getElementGeometryBuilderParams(this.iModel, this.model, this.placement, this._textAnnotationData, this.category, this.defaultTextStyle ? this.defaultTextStyle.id : undefined);
200
205
  }
201
206
  return props;
202
207
  }
203
208
  /** Creates a new `TextAnnotation3d` instance with the specified properties.
204
209
  * @param iModelDb The iModel.
205
- * @param category The category ID for the annotation.
206
- * @param model The model ID where the annotation will be placed.
207
- * @param placement The placement properties for the annotation.
208
- * @param textAnnotationData Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation3d`. Essentially an empty element if not provided.
209
- * @param code Optional code for the element.
210
+ * @param arg The arguments for creating the TextAnnotation3d.
211
+ * @beta
210
212
  */
211
- static create(iModelDb, category, model, placement, textAnnotationData, code) {
212
- const props = {
213
+ static create(iModelDb, arg) {
214
+ const elementProps = {
213
215
  classFullName: this.classFullName,
214
- textAnnotationData: JSON.stringify(textAnnotationData),
215
- placement,
216
- model,
217
- category,
218
- code: code ?? Code.createEmpty(),
216
+ textAnnotationData: JSON.stringify(arg.textAnnotationData),
217
+ defaultTextStyle: arg.defaultTextStyleId ? new TextAnnotationUsesTextStyleByDefault(arg.defaultTextStyleId).toJSON() : undefined,
218
+ placement: arg.placement,
219
+ model: arg.model,
220
+ category: arg.category,
221
+ code: arg.code ?? Code.createEmpty(),
219
222
  };
220
- return new this(props, iModelDb);
223
+ return new this(elementProps, iModelDb);
221
224
  }
222
225
  /**
223
226
  * Updates the geometry of the TextAnnotation3d on insert.
@@ -245,20 +248,7 @@ export class TextAnnotation3d extends GraphicalElement3d /* implements ITextAnno
245
248
  if (props.elementGeometryBuilderParams || !props.textAnnotationData) {
246
249
  return;
247
250
  }
248
- props.elementGeometryBuilderParams = getElementGeometryBuilderParams(iModelDb, props.model, props.placement ?? Placement3d.fromJSON(), props.textAnnotationData, props.category);
249
- }
250
- /**
251
- * Collects reference IDs used by this `TextAnnotation3d`.
252
- * @inheritdoc
253
- */
254
- collectReferenceIds(ids) {
255
- super.collectReferenceIds(ids);
256
- const annotation = this.getAnnotation();
257
- if (!annotation) {
258
- return;
259
- }
260
- if (annotation.textBlock.styleId)
261
- ids.addElement(annotation.textBlock.styleId);
251
+ props.elementGeometryBuilderParams = getElementGeometryBuilderParams(iModelDb, props.model, props.placement ?? Placement3d.fromJSON(), props.textAnnotationData, props.category, props.defaultTextStyle ? props.defaultTextStyle.id : undefined);
262
252
  }
263
253
  /** @internal */
264
254
  getTextBlocks() {
@@ -1 +1 @@
1
- {"version":3,"file":"TextAnnotationElement.js","sourceRoot":"","sources":["../../../src/annotations/TextAnnotationElement.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAA4B,WAAW,EAAE,IAAI,EAAuC,eAAe,EAAoD,WAAW,EAAoB,WAAW,EAAoC,cAAc,EAAqE,iBAAiB,EAA0B,MAAM,oBAAoB,CAAC;AAErY,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,kBAAkB,EAAqC,MAAM,YAAY,CAAC;AAC3H,OAAO,EAAE,MAAM,EAAc,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,2BAA2B,EAAkB,MAAM,+BAA+B,CAAC;AAE5F,SAAS,uBAAuB,CAAC,IAAwB;IACvD,IAAI,CAAC,IAAI;QAAE,OAAO,SAAS,CAAC;IAC5B,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,SAAS,+BAA+B,CAAC,MAAgB,EAAE,OAAmB,EAAE,eAA+B,EAAE,0BAAkC,EAAE,UAAsB,EAAE,YAAyB;IACpM,MAAM,eAAe,GAAG,uBAAuB,CAAC,0BAA0B,CAAC,CAAC;IAC5E,MAAM,SAAS,GAAG,cAAc,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,SAAS,CAAC;IACrE,MAAM,iBAAiB,GAA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,KAAiC,CAAC,CAAC;IAC/D,CAAC;IAED;;;;OAIG;IACO,MAAM,CAAU,QAAQ,CAAC,GAAsB;QACvD,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,KAAiC,CAAC,CAAC;IAC/D,CAAC;IAEO,MAAM,CAAC,gBAAgB,CAAC,KAA+B;QAC7D,MAAM,YAAY,GAAG,mBAAmB,CAAC,sBAAsB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAChF,IAAI,CAAC,YAAY;YAAE,OAAO;QAC1B,MAAM,QAAQ,GAAG,iBAAiB,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QAC1D,MAAM,MAAM,GAAG,QAAQ,CAAC,mBAAmB,EAAE,CAAC;QAC9C,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,yCAAyC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAChF,CAAC;IACH,CAAC;IAEO,MAAM,CAAC,sBAAsB,CAAC,IAAwB;QAC5D,IAAI,CAAC,IAAI;YAAE,OAAO,SAAS,CAAC;QAC5B,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,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 Elements\n */\n\nimport { AnnotationTextStyleProps, BisCodeSpec, Code, CodeProps, CodeScopeProps, CodeSpec, ElementGeometry, ElementGeometryBuilderParams, EntityReferenceSet, Placement2d, Placement2dProps, Placement3d, Placement3dProps, PlacementProps, TextAnnotation, TextAnnotation2dProps, TextAnnotation3dProps, TextAnnotationProps, TextStyleSettings, TextStyleSettingsProps } from \"@itwin/core-common\";\nimport { IModelDb } from \"../IModelDb\";\nimport { AnnotationElement2d, DefinitionElement, GraphicalElement3d, OnElementIdArg, OnElementPropsArg } from \"../Element\";\nimport { assert, Id64String } from \"@itwin/core-bentley\";\nimport { layoutTextBlock, TextStyleResolver } from \"./TextBlockLayout\";\nimport { appendTextAnnotationGeometry } from \"./TextAnnotationGeometry\";\nimport { ElementDrivesTextAnnotation, TextBlockAndId } from \"./ElementDrivesTextAnnotation\";\n\nfunction parseTextAnnotationData(json: string | undefined): TextAnnotationProps | undefined {\n if (!json) return undefined;\n try {\n return JSON.parse(json);\n } catch {\n return undefined;\n }\n}\n\nfunction getElementGeometryBuilderParams(iModel: IModelDb, modelId: Id64String, _placementProps: PlacementProps, stringifiedAnnotationProps: string, categoryId: Id64String, _subCategory?: Id64String): ElementGeometryBuilderParams {\n const annotationProps = parseTextAnnotationData(stringifiedAnnotationProps);\n const textBlock = TextAnnotation.fromJSON(annotationProps).textBlock;\n const textStyleResolver = new TextStyleResolver({textBlock, iModel, modelId});\n const layout = layoutTextBlock({ iModel, textBlock, textStyleResolver });\n const builder = new ElementGeometry.Builder();\n appendTextAnnotationGeometry({ layout, textStyleResolver, annotationProps: annotationProps ?? {}, builder, categoryId })\n\n return { entryArray: builder.entries };\n}\n\n/** An element that displays textual content within a 2d model.\n * The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.\n * @see [[setAnnotation]] to change the textual content.\n * @public @preview\n */\nexport class TextAnnotation2d extends AnnotationElement2d /* implements ITextAnnotation */ {\n /** @internal */\n public static override get className(): string { return \"TextAnnotation2d\"; }\n /** Optional string containing the data associated with the text annotation. */\n private _textAnnotationData?: string;\n\n /** Extract the textual content, if present.\n * @see [[setAnnotation]] to change it.\n */\n public getAnnotation(): TextAnnotation | undefined {\n const textAnnotationProps = parseTextAnnotationData(this._textAnnotationData);\n return textAnnotationProps ? TextAnnotation.fromJSON(textAnnotationProps) : undefined;\n }\n\n /** Change the textual content of the `TextAnnotation2d`.\n * @see [[getAnnotation]] to extract the current annotation.\n * @param annotation The new annotation\n */\n public setAnnotation(annotation: TextAnnotation) {\n this._textAnnotationData = annotation ? JSON.stringify(annotation.toJSON()) : undefined;\n }\n\n protected constructor(props: TextAnnotation2dProps, iModel: IModelDb) {\n super(props, iModel);\n this._textAnnotationData = props.textAnnotationData;\n }\n\n /** Creates a new instance of `TextAnnotation2d` from its JSON representation. */\n public static fromJSON(props: TextAnnotation2dProps, iModel: IModelDb): TextAnnotation2d {\n return new TextAnnotation2d(props, iModel);\n }\n\n /**\n * Converts the current `TextAnnotation2d` instance to its JSON representation.\n * It also computes the `elementGeometryBuilderParams` property used to create the GeometryStream.\n\n * @inheritdoc\n */\n public override toJSON(): TextAnnotation2dProps {\n const props = super.toJSON() as TextAnnotation2dProps;\n props.textAnnotationData = this._textAnnotationData;\n if (this._textAnnotationData) {\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(this.iModel, this.model, this.placement, this._textAnnotationData, this.category);\n }\n\n return props;\n }\n\n /** Creates a new `TextAnnotation2d` instance with the specified properties.\n * @param iModelDb The iModel.\n * @param category The category ID for the annotation.\n * @param model The model ID where the annotation will be placed.\n * @param placement The placement properties for the annotation.\n * @param textAnnotationData Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation2d`. Essentially an empty element if not provided.\n * @param code Optional code for the element.\n */\n public static create(iModelDb: IModelDb, category: Id64String, model: Id64String, placement: Placement2dProps, textAnnotationData?: TextAnnotationProps, code?: CodeProps): TextAnnotation2d {\n const props: TextAnnotation2dProps = {\n classFullName: this.classFullName,\n textAnnotationData: JSON.stringify(textAnnotationData),\n placement,\n model,\n category,\n code: code ?? Code.createEmpty(),\n }\n return new this(props, iModelDb);\n }\n\n /**\n * Updates the geometry of the TextAnnotation2d on insert.\n * @inheritdoc\n * @beta\n */\n protected static override onInsert(arg: OnElementPropsArg): void {\n super.onInsert(arg);\n this.updateGeometry(arg.iModel, arg.props as TextAnnotation2dProps);\n }\n\n /**\n * Updates the geometry of the TextAnnotation2d on update.\n * @inheritdoc\n * @beta\n */\n protected static override onUpdate(arg: OnElementPropsArg): void {\n super.onUpdate(arg);\n this.updateGeometry(arg.iModel, arg.props as TextAnnotation2dProps);\n }\n\n /**\n * Populates the `elementGeometryBuilderParams` property in the [TextAnnotation2dProps]($common).\n * It only does this if the `elementGeometryBuilderParams` is not already set and if there is actually a text annotation to produce geometry for.\n */\n protected static updateGeometry(iModelDb: IModelDb, props: TextAnnotation2dProps): void {\n if (props.elementGeometryBuilderParams || !props.textAnnotationData) {\n return;\n }\n\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(iModelDb, props.model, props.placement ?? Placement2d.fromJSON(), props.textAnnotationData, props.category);\n }\n\n /**\n * Collects reference IDs used by this `TextAnnotation2d`.\n * @inheritdoc\n */\n protected override collectReferenceIds(ids: EntityReferenceSet): void {\n super.collectReferenceIds(ids);\n const annotation = this.getAnnotation();\n if (!annotation) {\n return;\n }\n if (annotation.textBlock.styleId)\n ids.addElement(annotation.textBlock.styleId);\n }\n\n /** @internal */\n public getTextBlocks(): Iterable<TextBlockAndId> {\n return getTextBlocks(this);\n }\n\n /** @internal */\n public updateTextBlocks(textBlocks: TextBlockAndId[]): void {\n return updateTextBlocks(this, textBlocks);\n }\n\n /** @internal */\n public static override onInserted(arg: OnElementIdArg): void {\n super.onInserted(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n\n /** @internal */\n public static override onUpdated(arg: OnElementIdArg): void {\n super.onUpdated(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n}\n\n/** An element that displays textual content within a 3d model.\n * The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.\n * @see [[setAnnotation]] to change the textual content.\n * @public @preview\n */\nexport class TextAnnotation3d extends GraphicalElement3d /* implements ITextAnnotation */ {\n /** @internal */\n public static override get className(): string { return \"TextAnnotation3d\"; }\n /** Optional string containing the data associated with the text annotation. */\n private _textAnnotationData?: string;\n\n /** Extract the textual content, if present.\n * @see [[setAnnotation]] to change it.\n */\n public getAnnotation(): TextAnnotation | undefined {\n const textAnnotationProps = parseTextAnnotationData(this._textAnnotationData);\n return textAnnotationProps ? TextAnnotation.fromJSON(textAnnotationProps) : undefined;\n }\n\n /** Change the textual content of the `TextAnnotation3d`.\n * @see [[getAnnotation]] to extract the current annotation.\n * @param annotation The new annotation\n */\n public setAnnotation(annotation: TextAnnotation) {\n this._textAnnotationData = annotation ? JSON.stringify(annotation.toJSON()) : undefined;\n }\n\n protected constructor(props: TextAnnotation3dProps, iModel: IModelDb) {\n super(props, iModel);\n this._textAnnotationData = props.textAnnotationData;\n }\n\n /** Creates a new instance of `TextAnnotation3d` from its JSON representation. */\n public static fromJSON(props: TextAnnotation3dProps, iModel: IModelDb): TextAnnotation3d {\n return new TextAnnotation3d(props, iModel);\n }\n\n /**\n * Converts the current `TextAnnotation3d` instance to its JSON representation.\n * It also computes the `elementGeometryBuilderParams` property used to create the GeometryStream.\n * @inheritdoc\n */\n public override toJSON(): TextAnnotation3dProps {\n const props = super.toJSON() as TextAnnotation3dProps;\n props.textAnnotationData = this._textAnnotationData;\n if (this._textAnnotationData) {\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(this.iModel, this.model, this.placement, this._textAnnotationData, this.category);\n }\n\n return props;\n }\n\n /** Creates a new `TextAnnotation3d` instance with the specified properties.\n * @param iModelDb The iModel.\n * @param category The category ID for the annotation.\n * @param model The model ID where the annotation will be placed.\n * @param placement The placement properties for the annotation.\n * @param textAnnotationData Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation3d`. Essentially an empty element if not provided.\n * @param code Optional code for the element.\n */\n public static create(iModelDb: IModelDb, category: Id64String, model: Id64String, placement: Placement3dProps, textAnnotationData?: TextAnnotationProps, code?: CodeProps): TextAnnotation3d {\n const props: TextAnnotation3dProps = {\n classFullName: this.classFullName,\n textAnnotationData: JSON.stringify(textAnnotationData),\n placement,\n model,\n category,\n code: code ?? Code.createEmpty(),\n }\n return new this(props, iModelDb);\n }\n\n /**\n * Updates the geometry of the TextAnnotation3d on insert.\n * @inheritdoc\n * @beta\n */\n protected static override onInsert(arg: OnElementPropsArg): void {\n super.onInsert(arg);\n this.updateGeometry(arg.iModel, arg.props as TextAnnotation3dProps);\n }\n\n /**\n * Updates the geometry of the TextAnnotation3d on update.\n * @inheritdoc\n * @beta\n */\n protected static override onUpdate(arg: OnElementPropsArg): void {\n super.onUpdate(arg);\n this.updateGeometry(arg.iModel, arg.props as TextAnnotation3dProps);\n }\n\n /**\n * Populates the `elementGeometryBuilderParams` property in the [TextAnnotation3dProps]($common).\n * It only does this if the `elementGeometryBuilderParams` is not already set and if there is actually a text annotation to produce geometry for.\n */\n protected static updateGeometry(iModelDb: IModelDb, props: TextAnnotation3dProps): void {\n if (props.elementGeometryBuilderParams || !props.textAnnotationData) {\n return;\n }\n\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(iModelDb, props.model, props.placement ?? Placement3d.fromJSON(), props.textAnnotationData, props.category);\n }\n\n /**\n * Collects reference IDs used by this `TextAnnotation3d`.\n * @inheritdoc\n */\n protected override collectReferenceIds(ids: EntityReferenceSet): void {\n super.collectReferenceIds(ids);\n const annotation = this.getAnnotation();\n if (!annotation) {\n return;\n }\n if (annotation.textBlock.styleId)\n ids.addElement(annotation.textBlock.styleId);\n }\n\n /** @internal */\n public getTextBlocks(): Iterable<TextBlockAndId> {\n return getTextBlocks(this);\n }\n\n /** @internal */\n public updateTextBlocks(textBlocks: TextBlockAndId[]): void {\n return updateTextBlocks(this, textBlocks);\n }\n\n /** @internal */\n public static override onInserted(arg: OnElementIdArg): void {\n super.onInserted(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n\n /** @internal */\n public static override onUpdated(arg: OnElementIdArg): void {\n super.onUpdated(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n}\n\nfunction getTextBlocks(elem: TextAnnotation2d | TextAnnotation3d): Iterable<TextBlockAndId> {\n const annotation = elem.getAnnotation();\n return annotation ? [{ textBlock: annotation.textBlock, id: undefined }] : [];\n}\n\nfunction updateTextBlocks(elem: TextAnnotation2d | TextAnnotation3d, textBlocks: TextBlockAndId[]): void {\n assert(textBlocks.length === 1);\n assert(textBlocks[0].id === undefined);\n\n const annotation = elem.getAnnotation();\n if (!annotation) {\n // We must obtain the TextBlockAndId from the element in the first place, so the only way we could end up here is if\n // somebody removed the text annotation after we called getTextBlocks. That's gotta be a mistake.\n throw new Error(\"Text annotation element has no text\");\n }\n\n annotation.textBlock = textBlocks[0].textBlock;\n\n elem.setAnnotation(annotation);\n elem.update();\n}\n\n/**\n * The definition element that holds text style information.\n * The style is stored as a [TextStyleSettings]($common).\n * @beta\n */\nexport class AnnotationTextStyle extends DefinitionElement {\n /** @internal */\n public static override get className(): string { return \"AnnotationTextStyle\"; }\n /**\n * Optional text describing the `AnnotationTextStyle`.\n */\n public description?: string;\n /**\n * The text style settings for the `AnnotationTextStyle`.\n * @see [[TextStyleSettings]] for more information.\n */\n public settings: TextStyleSettings;\n\n protected constructor(props: AnnotationTextStyleProps, iModel: IModelDb) {\n super(props, iModel);\n this.description = props.description;\n const settingsProps = AnnotationTextStyle.parseTextStyleSettings(props.settings);\n this.settings = TextStyleSettings.fromJSON(settingsProps);\n }\n\n /**\n * Creates a Code for an `AnnotationTextStyle` given a name that is meant to be unique within the scope of the specified DefinitionModel.\n *\n * @param iModel - The IModelDb.\n * @param definitionModelId - The ID of the DefinitionModel that contains the AnnotationTextStyle and provides the scope for its name.\n * @param name - The AnnotationTextStyle name.\n */\n public static createCode(iModel: IModelDb, definitionModelId: CodeScopeProps, name: string): Code {\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.annotationTextStyle);\n return new Code({ spec: codeSpec.id, scope: definitionModelId, value: name });\n }\n\n /**\n * Creates a new instance of `AnnotationTextStyle` with the specified properties.\n *\n * @param iModelDb - The iModelDb.\n * @param definitionModelId - The ID of the [[DefinitionModel]].\n * @param name - The name to assign to the `AnnotationTextStyle`.\n * @param settings - Optional text style settings used to create the `AnnotationTextStyle`. Default settings will be used if not provided.\n * @param description - Optional description for the `AnnotationTextStyle`.\n */\n public static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string, settings?: TextStyleSettingsProps, description?: string) {\n const props: AnnotationTextStyleProps = {\n classFullName: this.classFullName,\n model: definitionModelId,\n code: this.createCode(iModelDb, definitionModelId, name).toJSON(),\n description,\n settings: JSON.stringify(settings),\n }\n return new this(props, iModelDb);\n }\n\n /**\n * Converts the current `AnnotationTextStyle` instance to its JSON representation.\n * @inheritdoc\n */\n public override toJSON(): AnnotationTextStyleProps {\n const props = super.toJSON() as AnnotationTextStyleProps;\n props.description = this.description;\n props.settings = JSON.stringify(this.settings.toJSON());\n return props;\n }\n\n /** Creates a new instance of `AnnotationTextStyle` from its JSON representation. */\n public static fromJSON(props: AnnotationTextStyleProps, iModel: IModelDb): AnnotationTextStyle {\n return new AnnotationTextStyle(props, iModel);\n }\n\n /**\n * Validates that the AnnotationTextStyle's settings are valid before insert.\n * @inheritdoc\n * @beta\n */\n protected static override onInsert(arg: OnElementPropsArg): void {\n super.onInsert(arg);\n this.validateSettings(arg.props as AnnotationTextStyleProps);\n }\n\n /**\n * Validates that the AnnotationTextStyle's settings are valid before update.\n * @inheritdoc\n * @beta\n */\n protected static override onUpdate(arg: OnElementPropsArg): void {\n super.onUpdate(arg);\n this.validateSettings(arg.props as AnnotationTextStyleProps);\n }\n\n private static validateSettings(props: AnnotationTextStyleProps): void {\n const settingProps = AnnotationTextStyle.parseTextStyleSettings(props.settings);\n if (!settingProps) return;\n const settings = TextStyleSettings.fromJSON(settingProps);\n const errors = settings.getValidationErrors();\n if (errors.length > 0) {\n throw new Error(`Invalid AnnotationTextStyle settings: ${errors.join(\", \")}`);\n }\n }\n\n private static parseTextStyleSettings(json: string | undefined): TextStyleSettingsProps | undefined {\n if (!json) return undefined;\n try {\n return JSON.parse(json);\n } catch {\n return undefined;\n }\n }\n}\n\n\n"]}
1
+ {"version":3,"file":"TextAnnotationElement.js","sourceRoot":"","sources":["../../../src/annotations/TextAnnotationElement.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAA4B,WAAW,EAAE,IAAI,EAAuC,eAAe,EAAgC,WAAW,EAAoB,WAAW,EAAoC,cAAc,EAAqE,iBAAiB,EAA0B,MAAM,oBAAoB,CAAC;AAEjX,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,OAAO,EAAE,kBAAkB,EAAqC,MAAM,YAAY,CAAC;AACpI,OAAO,EAAE,MAAM,EAAc,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,2BAA2B,EAAE,oCAAoC,EAAkB,MAAM,+BAA+B,CAAC;AAElI,SAAS,uBAAuB,CAAC,IAAwB;IACvD,IAAI,CAAC,IAAI;QAAE,OAAO,SAAS,CAAC;IAC5B,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,SAAS,+BAA+B,CAAC,MAAgB,EAAE,OAAmB,EAAE,eAA+B,EAAE,0BAAkC,EAAE,UAAsB,EAAE,WAAwB,EAAE,YAAyB;IAC9N,MAAM,eAAe,GAAG,uBAAuB,CAAC,0BAA0B,CAAC,CAAC;IAC5E,MAAM,SAAS,GAAG,cAAc,CAAC,QAAQ,CAAC,eAAe,C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D,MAAM,MAAM,GAAG,QAAQ,CAAC,mBAAmB,EAAE,CAAC;QAC9C,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,yCAAyC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAChF,CAAC;IACH,CAAC;IAEO,MAAM,CAAC,sBAAsB,CAAC,IAAwB;QAC5D,IAAI,CAAC,IAAI;YAAE,OAAO,SAAS,CAAC;QAC5B,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,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 Elements\n */\n\nimport { AnnotationTextStyleProps, BisCodeSpec, Code, CodeProps, CodeScopeProps, CodeSpec, ElementGeometry, ElementGeometryBuilderParams, Placement2d, Placement2dProps, Placement3d, Placement3dProps, PlacementProps, TextAnnotation, TextAnnotation2dProps, TextAnnotation3dProps, TextAnnotationProps, TextStyleSettings, TextStyleSettingsProps } from \"@itwin/core-common\";\nimport { IModelDb } from \"../IModelDb\";\nimport { AnnotationElement2d, DefinitionElement, Drawing, GraphicalElement3d, OnElementIdArg, OnElementPropsArg } from \"../Element\";\nimport { assert, Id64String } from \"@itwin/core-bentley\";\nimport { layoutTextBlock, TextStyleResolver } from \"./TextBlockLayout\";\nimport { appendTextAnnotationGeometry } from \"./TextAnnotationGeometry\";\nimport { ElementDrivesTextAnnotation, TextAnnotationUsesTextStyleByDefault, TextBlockAndId } from \"./ElementDrivesTextAnnotation\";\n\nfunction parseTextAnnotationData(json: string | undefined): TextAnnotationProps | undefined {\n if (!json) return undefined;\n try {\n return JSON.parse(json);\n } catch {\n return undefined;\n }\n}\n\nfunction getElementGeometryBuilderParams(iModel: IModelDb, modelId: Id64String, _placementProps: PlacementProps, stringifiedAnnotationProps: string, categoryId: Id64String, textStyleId?: Id64String, _subCategory?: Id64String): ElementGeometryBuilderParams {\n const annotationProps = parseTextAnnotationData(stringifiedAnnotationProps);\n const textBlock = TextAnnotation.fromJSON(annotationProps).textBlock;\n const textStyleResolver = new TextStyleResolver({textBlock, textStyleId: textStyleId ?? \"\", iModel});\n const layout = layoutTextBlock({ iModel, textBlock, textStyleResolver });\n const builder = new ElementGeometry.Builder();\n let scaleFactor = 1;\n const element = iModel.elements.getElement(modelId);\n if (element instanceof Drawing)\n scaleFactor = element.scaleFactor;\n appendTextAnnotationGeometry({ layout, textStyleResolver, scaleFactor, annotationProps: annotationProps ?? {}, builder, categoryId });\n\n return { entryArray: builder.entries };\n}\n\n/** Arguments supplied when creating a [[TextAnnotation2d]].\n * @beta\n */\nexport interface TextAnnotation2dCreateArgs {\n /** The category ID for the annotation. */\n category: Id64String;\n /** The model ID where the annotation will be placed. */\n model: Id64String;\n /** The placement properties for the annotation. */\n placement: Placement2dProps;\n /** The default text style ID for the annotation. */\n defaultTextStyleId?: Id64String;\n /** Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation2d`. Essentially an empty element if not provided. */\n textAnnotationData?: TextAnnotationProps;\n /** Optional code for the element. */\n code?: CodeProps;\n}\n\n/** Arguments supplied when creating a [[TextAnnotation3d]].\n * @beta\n */\nexport interface TextAnnotation3dCreateArgs {\n /** The category ID for the annotation. */\n category: Id64String;\n /** The model ID where the annotation will be placed. */\n model: Id64String;\n /** The placement properties for the annotation. */\n placement: Placement3dProps;\n /** The default text style ID for the annotation. */\n defaultTextStyleId?: Id64String;\n /** Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation3d`. Essentially an empty element if not provided. */\n textAnnotationData?: TextAnnotationProps;\n /** Optional code for the element. */\n code?: CodeProps;\n}\n\n/** An element that displays textual content within a 2d model.\n * The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.\n * @see [[setAnnotation]] to change the textual content.\n * @public @preview\n */\nexport class TextAnnotation2d extends AnnotationElement2d /* implements ITextAnnotation */ {\n /** @internal */\n public static override get className(): string { return \"TextAnnotation2d\"; }\n /**\n * The default [[AnnotationTextStyle]] used by the TextAnnotation2d.\n * @beta\n */\n public defaultTextStyle?: TextAnnotationUsesTextStyleByDefault;\n /** Optional string containing the data associated with the text annotation. */\n private _textAnnotationData?: string;\n\n /** Extract the textual content, if present.\n * @see [[setAnnotation]] to change it.\n */\n public getAnnotation(): TextAnnotation | undefined {\n const textAnnotationProps = parseTextAnnotationData(this._textAnnotationData);\n return textAnnotationProps ? TextAnnotation.fromJSON(textAnnotationProps) : undefined;\n }\n\n /** Change the textual content of the `TextAnnotation2d`.\n * @see [[getAnnotation]] to extract the current annotation.\n * @param annotation The new annotation\n */\n public setAnnotation(annotation: TextAnnotation) {\n this._textAnnotationData = annotation ? JSON.stringify(annotation.toJSON()) : undefined;\n }\n\n protected constructor(props: TextAnnotation2dProps, iModel: IModelDb) {\n super(props, iModel);\n if (props.defaultTextStyle) {\n this.defaultTextStyle = new TextAnnotationUsesTextStyleByDefault(props.defaultTextStyle.id);\n }\n this._textAnnotationData = props.textAnnotationData;\n }\n\n /** Creates a new instance of `TextAnnotation2d` from its JSON representation. */\n public static fromJSON(props: TextAnnotation2dProps, iModel: IModelDb): TextAnnotation2d {\n return new TextAnnotation2d(props, iModel);\n }\n\n /**\n * Converts the current `TextAnnotation2d` instance to its JSON representation.\n * It also computes the `elementGeometryBuilderParams` property used to create the GeometryStream.\n\n * @inheritdoc\n */\n public override toJSON(): TextAnnotation2dProps {\n const props = super.toJSON() as TextAnnotation2dProps;\n props.textAnnotationData = this._textAnnotationData;\n if (this._textAnnotationData) {\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(this.iModel, this.model, this.placement, this._textAnnotationData, this.category, this.defaultTextStyle ? this.defaultTextStyle.id : undefined);\n }\n\n return props;\n }\n\n /** Creates a new `TextAnnotation2d` instance with the specified properties.\n * @param iModelDb The iModel.\n * @param arg The arguments for creating the TextAnnotation2d.\n * @beta\n */\n public static create(iModelDb: IModelDb, arg: TextAnnotation2dCreateArgs): TextAnnotation2d {\n const elementProps: TextAnnotation2dProps = {\n classFullName: this.classFullName,\n textAnnotationData: JSON.stringify(arg.textAnnotationData),\n defaultTextStyle: arg.defaultTextStyleId ? new TextAnnotationUsesTextStyleByDefault(arg.defaultTextStyleId).toJSON() : undefined,\n placement: arg.placement,\n model: arg.model,\n category: arg.category,\n code: arg.code ?? Code.createEmpty(),\n };\n return new this(elementProps, iModelDb);\n }\n\n /**\n * Updates the geometry of the TextAnnotation2d on insert.\n * @inheritdoc\n * @beta\n */\n protected static override onInsert(arg: OnElementPropsArg): void {\n super.onInsert(arg);\n this.updateGeometry(arg.iModel, arg.props as TextAnnotation2dProps);\n }\n\n /**\n * Updates the geometry of the TextAnnotation2d on update.\n * @inheritdoc\n * @beta\n */\n protected static override onUpdate(arg: OnElementPropsArg): void {\n super.onUpdate(arg);\n this.updateGeometry(arg.iModel, arg.props as TextAnnotation2dProps);\n }\n\n /**\n * Populates the `elementGeometryBuilderParams` property in the [TextAnnotation2dProps]($common).\n * It only does this if the `elementGeometryBuilderParams` is not already set and if there is actually a text annotation to produce geometry for.\n */\n protected static updateGeometry(iModelDb: IModelDb, props: TextAnnotation2dProps): void {\n if (props.elementGeometryBuilderParams || !props.textAnnotationData) {\n return;\n }\n\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(iModelDb, props.model, props.placement ?? Placement2d.fromJSON(), props.textAnnotationData, props.category, props.defaultTextStyle ? props.defaultTextStyle.id : undefined);\n }\n\n /** @internal */\n public getTextBlocks(): Iterable<TextBlockAndId> {\n return getTextBlocks(this);\n }\n\n /** @internal */\n public updateTextBlocks(textBlocks: TextBlockAndId[]): void {\n return updateTextBlocks(this, textBlocks);\n }\n\n /** @internal */\n public static override onInserted(arg: OnElementIdArg): void {\n super.onInserted(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n\n /** @internal */\n public static override onUpdated(arg: OnElementIdArg): void {\n super.onUpdated(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n}\n\n/** An element that displays textual content within a 3d model.\n * The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.\n * @see [[setAnnotation]] to change the textual content.\n * @public @preview\n */\nexport class TextAnnotation3d extends GraphicalElement3d /* implements ITextAnnotation */ {\n /** @internal */\n public static override get className(): string { return \"TextAnnotation3d\"; }\n /**\n * The default [[AnnotationTextStyle]] used by the TextAnnotation3d.\n * @beta\n */\n public defaultTextStyle?: TextAnnotationUsesTextStyleByDefault;\n /** Optional string containing the data associated with the text annotation. */\n private _textAnnotationData?: string;\n\n /** Extract the textual content, if present.\n * @see [[setAnnotation]] to change it.\n */\n public getAnnotation(): TextAnnotation | undefined {\n const textAnnotationProps = parseTextAnnotationData(this._textAnnotationData);\n return textAnnotationProps ? TextAnnotation.fromJSON(textAnnotationProps) : undefined;\n }\n\n /** Change the textual content of the `TextAnnotation3d`.\n * @see [[getAnnotation]] to extract the current annotation.\n * @param annotation The new annotation\n */\n public setAnnotation(annotation: TextAnnotation) {\n this._textAnnotationData = annotation ? JSON.stringify(annotation.toJSON()) : undefined;\n }\n\n protected constructor(props: TextAnnotation3dProps, iModel: IModelDb) {\n super(props, iModel);\n if (props.defaultTextStyle) {\n this.defaultTextStyle = new TextAnnotationUsesTextStyleByDefault(props.defaultTextStyle.id);\n }\n this._textAnnotationData = props.textAnnotationData;\n }\n\n /** Creates a new instance of `TextAnnotation3d` from its JSON representation. */\n public static fromJSON(props: TextAnnotation3dProps, iModel: IModelDb): TextAnnotation3d {\n return new TextAnnotation3d(props, iModel);\n }\n\n /**\n * Converts the current `TextAnnotation3d` instance to its JSON representation.\n * It also computes the `elementGeometryBuilderParams` property used to create the GeometryStream.\n * @inheritdoc\n */\n public override toJSON(): TextAnnotation3dProps {\n const props = super.toJSON() as TextAnnotation3dProps;\n props.textAnnotationData = this._textAnnotationData;\n if (this._textAnnotationData) {\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(this.iModel, this.model, this.placement, this._textAnnotationData, this.category, this.defaultTextStyle ? this.defaultTextStyle.id : undefined);\n }\n\n return props;\n }\n\n /** Creates a new `TextAnnotation3d` instance with the specified properties.\n * @param iModelDb The iModel.\n * @param arg The arguments for creating the TextAnnotation3d.\n * @beta\n */\n public static create(iModelDb: IModelDb, arg: TextAnnotation3dCreateArgs): TextAnnotation3d {\n const elementProps: TextAnnotation3dProps = {\n classFullName: this.classFullName,\n textAnnotationData: JSON.stringify(arg.textAnnotationData),\n defaultTextStyle: arg.defaultTextStyleId ? new TextAnnotationUsesTextStyleByDefault(arg.defaultTextStyleId).toJSON() : undefined,\n placement: arg.placement,\n model: arg.model,\n category: arg.category,\n code: arg.code ?? Code.createEmpty(),\n };\n return new this(elementProps, iModelDb);\n }\n\n /**\n * Updates the geometry of the TextAnnotation3d on insert.\n * @inheritdoc\n * @beta\n */\n protected static override onInsert(arg: OnElementPropsArg): void {\n super.onInsert(arg);\n this.updateGeometry(arg.iModel, arg.props as TextAnnotation3dProps);\n }\n\n /**\n * Updates the geometry of the TextAnnotation3d on update.\n * @inheritdoc\n * @beta\n */\n protected static override onUpdate(arg: OnElementPropsArg): void {\n super.onUpdate(arg);\n this.updateGeometry(arg.iModel, arg.props as TextAnnotation3dProps);\n }\n\n /**\n * Populates the `elementGeometryBuilderParams` property in the [TextAnnotation3dProps]($common).\n * It only does this if the `elementGeometryBuilderParams` is not already set and if there is actually a text annotation to produce geometry for.\n */\n protected static updateGeometry(iModelDb: IModelDb, props: TextAnnotation3dProps): void {\n if (props.elementGeometryBuilderParams || !props.textAnnotationData) {\n return;\n }\n\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(iModelDb, props.model, props.placement ?? Placement3d.fromJSON(), props.textAnnotationData, props.category, props.defaultTextStyle ? props.defaultTextStyle.id : undefined);\n }\n\n /** @internal */\n public getTextBlocks(): Iterable<TextBlockAndId> {\n return getTextBlocks(this);\n }\n\n /** @internal */\n public updateTextBlocks(textBlocks: TextBlockAndId[]): void {\n return updateTextBlocks(this, textBlocks);\n }\n\n /** @internal */\n public static override onInserted(arg: OnElementIdArg): void {\n super.onInserted(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n\n /** @internal */\n public static override onUpdated(arg: OnElementIdArg): void {\n super.onUpdated(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n}\n\nfunction getTextBlocks(elem: TextAnnotation2d | TextAnnotation3d): Iterable<TextBlockAndId> {\n const annotation = elem.getAnnotation();\n return annotation ? [{ textBlock: annotation.textBlock, id: undefined }] : [];\n}\n\nfunction updateTextBlocks(elem: TextAnnotation2d | TextAnnotation3d, textBlocks: TextBlockAndId[]): void {\n assert(textBlocks.length === 1);\n assert(textBlocks[0].id === undefined);\n\n const annotation = elem.getAnnotation();\n if (!annotation) {\n // We must obtain the TextBlockAndId from the element in the first place, so the only way we could end up here is if\n // somebody removed the text annotation after we called getTextBlocks. That's gotta be a mistake.\n throw new Error(\"Text annotation element has no text\");\n }\n\n annotation.textBlock = textBlocks[0].textBlock;\n\n elem.setAnnotation(annotation);\n elem.update();\n}\n\n/**\n * The definition element that holds text style information.\n * The style is stored as a [TextStyleSettings]($common).\n * @beta\n */\nexport class AnnotationTextStyle extends DefinitionElement {\n /** @internal */\n public static override get className(): string { return \"AnnotationTextStyle\"; }\n /**\n * Optional text describing the `AnnotationTextStyle`.\n */\n public description?: string;\n /**\n * The text style settings for the `AnnotationTextStyle`.\n * @see [[TextStyleSettings]] for more information.\n */\n public settings: TextStyleSettings;\n\n protected constructor(props: AnnotationTextStyleProps, iModel: IModelDb) {\n super(props, iModel);\n this.description = props.description;\n const settingsProps = AnnotationTextStyle.parseTextStyleSettings(props.settings);\n this.settings = TextStyleSettings.fromJSON(settingsProps);\n }\n\n /**\n * Creates a Code for an `AnnotationTextStyle` given a name that is meant to be unique within the scope of the specified DefinitionModel.\n *\n * @param iModel - The IModelDb.\n * @param definitionModelId - The ID of the DefinitionModel that contains the AnnotationTextStyle and provides the scope for its name.\n * @param name - The AnnotationTextStyle name.\n */\n public static createCode(iModel: IModelDb, definitionModelId: CodeScopeProps, name: string): Code {\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.annotationTextStyle);\n return new Code({ spec: codeSpec.id, scope: definitionModelId, value: name });\n }\n\n /**\n * Creates a new instance of `AnnotationTextStyle` with the specified properties.\n *\n * @param iModelDb - The iModelDb.\n * @param definitionModelId - The ID of the [[DefinitionModel]].\n * @param name - The name to assign to the `AnnotationTextStyle`.\n * @param settings - Optional text style settings used to create the `AnnotationTextStyle`. Default settings will be used if not provided.\n * @param description - Optional description for the `AnnotationTextStyle`.\n */\n public static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string, settings?: TextStyleSettingsProps, description?: string) {\n const props: AnnotationTextStyleProps = {\n classFullName: this.classFullName,\n model: definitionModelId,\n code: this.createCode(iModelDb, definitionModelId, name).toJSON(),\n description,\n settings: JSON.stringify(settings),\n }\n return new this(props, iModelDb);\n }\n\n /**\n * Converts the current `AnnotationTextStyle` instance to its JSON representation.\n * @inheritdoc\n */\n public override toJSON(): AnnotationTextStyleProps {\n const props = super.toJSON() as AnnotationTextStyleProps;\n props.description = this.description;\n props.settings = JSON.stringify(this.settings.toJSON());\n return props;\n }\n\n /** Creates a new instance of `AnnotationTextStyle` from its JSON representation. */\n public static fromJSON(props: AnnotationTextStyleProps, iModel: IModelDb): AnnotationTextStyle {\n return new AnnotationTextStyle(props, iModel);\n }\n\n /**\n * Validates that the AnnotationTextStyle's settings are valid before insert.\n * @inheritdoc\n * @beta\n */\n protected static override onInsert(arg: OnElementPropsArg): void {\n super.onInsert(arg);\n this.validateSettings(arg.props as AnnotationTextStyleProps);\n }\n\n /**\n * Validates that the AnnotationTextStyle's settings are valid before update.\n * @inheritdoc\n * @beta\n */\n protected static override onUpdate(arg: OnElementPropsArg): void {\n super.onUpdate(arg);\n this.validateSettings(arg.props as AnnotationTextStyleProps);\n }\n\n private static validateSettings(props: AnnotationTextStyleProps): void {\n const settingProps = AnnotationTextStyle.parseTextStyleSettings(props.settings);\n if (!settingProps) return;\n const settings = TextStyleSettings.fromJSON(settingProps);\n const errors = settings.getValidationErrors();\n if (errors.length > 0) {\n throw new Error(`Invalid AnnotationTextStyle settings: ${errors.join(\", \")}`);\n }\n }\n\n private static parseTextStyleSettings(json: string | undefined): TextStyleSettingsProps | undefined {\n if (!json) return undefined;\n try {\n return JSON.parse(json);\n } catch {\n return undefined;\n }\n }\n}\n\n\n"]}
@@ -16,6 +16,8 @@ export interface AppendTextAnnotationGeometryArgs {
16
16
  layout: TextBlockLayout;
17
17
  /** [[TextStyleResolver]] used to get styling and scale information for creating geometry. */
18
18
  textStyleResolver: TextStyleResolver;
19
+ /** The scale factor to apply to the annotation. Usually comes from the `scaleFactor` of a [[Drawing]] element. */
20
+ scaleFactor: number;
19
21
  /** Builder that will be added to in place */
20
22
  builder: ElementGeometry.Builder;
21
23
  /** The category the element will belong to. This will passed into the [[GeometryParams]] */
@@ -1 +1 @@
1
- {"version":3,"file":"TextAnnotationGeometry.d.ts","sourceRoot":"","sources":["../../../src/annotations/TextAnnotationGeometry.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAY,eAAe,EAA+C,mBAAmB,EAAqB,MAAM,oBAAoB,CAAC;AACpJ,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEvE,OAAO,EAAQ,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAKvD;;;;GAIG;AACH,MAAM,WAAW,gCAAgC;IAC/C,4GAA4G;IAC5G,eAAe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,CA8B7F"}
@@ -17,7 +17,7 @@ import { appendLeadersToBuilder } from "./LeaderGeometry";
17
17
  */
18
18
  export function appendTextAnnotationGeometry(props) {
19
19
  const annotation = TextAnnotation.fromJSON(props.annotationProps);
20
- const transform = annotation.computeTransform(props.layout.range, props.textStyleResolver.scaleFactor);
20
+ const transform = annotation.computeTransform(props.layout.range, props.scaleFactor);
21
21
  let result = true;
22
22
  // Construct the TextBlockGeometry
23
23
  const params = new GeometryParams(props.categoryId, props.subCategoryId);
@@ -29,7 +29,7 @@ export function appendTextAnnotationGeometry(props) {
29
29
  }
30
30
  // Construct the leader geometry
31
31
  if (annotation.leaders && annotation.leaders.length > 0) {
32
- result = result && appendLeadersToBuilder(props.builder, annotation.leaders, props.layout, transform.clone(), params, props.textStyleResolver);
32
+ result = result && appendLeadersToBuilder(props.builder, annotation.leaders, props.layout, transform.clone(), params, props.textStyleResolver, props.scaleFactor);
33
33
  }
34
34
  // Construct the debug geometry
35
35
  if (props.wantDebugGeometry) {
@@ -96,8 +96,7 @@ function debugSnapPoints(builder, style, range, transform) {
96
96
  */
97
97
  function debugRunLayout(builder, layout, documentTransform) {
98
98
  let result = true; // Tracks if all geometry was appended successfully
99
- let color = ColorDef.black; // Current color for the run type
100
- let lastColor = color; // Last color used, to minimize param changes
99
+ let lastColor = ColorDef.black; // Last color used, to minimize param changes
101
100
  // Map run types to debug colors
102
101
  const colors = {
103
102
  "text": ColorDef.fromString("orange"),
@@ -105,28 +104,36 @@ function debugRunLayout(builder, layout, documentTransform) {
105
104
  "fraction": ColorDef.fromString("green"),
106
105
  "tab": ColorDef.fromString("aquamarine"),
107
106
  "field": ColorDef.fromString("purple"),
107
+ "marker": ColorDef.fromString("pink"),
108
+ };
109
+ const drawBox = (run, lineTransform, newColor) => {
110
+ // Only change geometry params if the color changes
111
+ if (lastColor !== newColor) {
112
+ const colorParams = new GeometryParams(Id64.invalid);
113
+ colorParams.lineColor = newColor;
114
+ colorParams.weight = run.source.type === "linebreak" ? 3 : undefined;
115
+ result = result && builder.appendGeometryParamsChange(colorParams);
116
+ lastColor = newColor;
117
+ }
118
+ // Apply the line's offset to the run's offset
119
+ const runTrans = Transform.createTranslationXYZ(run.offsetFromLine.x, run.offsetFromLine.y, 0);
120
+ lineTransform.multiplyTransformTransform(runTrans, runTrans);
121
+ // Draw the enclosing range for the run
122
+ const runCorners = run.range.corners3d(true);
123
+ runTrans.multiplyPoint3dArrayInPlace(runCorners);
124
+ result = result && builder.appendGeometryQuery(LineString3d.create(runCorners));
108
125
  };
109
126
  layout.lines.forEach(line => {
110
127
  // Apply the line's offset transform
111
128
  const lineTrans = Transform.createTranslationXYZ(line.offsetFromDocument.x, line.offsetFromDocument.y, 0);
112
129
  documentTransform.multiplyTransformTransform(lineTrans, lineTrans);
130
+ if (line.marker) {
131
+ drawBox(line.marker, lineTrans, colors.marker);
132
+ }
113
133
  line.runs.forEach(run => {
114
134
  // Determine color for this run type
115
- color = colors[run.source.type] ?? ColorDef.black;
116
- // Only change geometry params if the color changes
117
- if (!lastColor.equals(color)) {
118
- const colorParams = new GeometryParams(Id64.invalid);
119
- colorParams.lineColor = color;
120
- result = result && builder.appendGeometryParamsChange(colorParams);
121
- lastColor = color;
122
- }
123
- // Apply the line's offset to the run's offset
124
- const runTrans = Transform.createTranslationXYZ(run.offsetFromLine.x, run.offsetFromLine.y, 0);
125
- lineTrans.multiplyTransformTransform(runTrans, runTrans);
126
- // Draw the enclosing range for the run
127
- const runCorners = run.range.corners3d(true);
128
- runTrans.multiplyPoint3dArrayInPlace(runCorners);
129
- result = result && builder.appendGeometryQuery(LineString3d.create(runCorners));
135
+ const color = colors[run.source.type] ?? ColorDef.black;
136
+ drawBox(run, lineTrans, color);
130
137
  });
131
138
  });
132
139
  return result;