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

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 (191) hide show
  1. package/CHANGELOG.md +52 -1
  2. package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
  3. package/lib/cjs/BriefcaseManager.js +14 -0
  4. package/lib/cjs/BriefcaseManager.js.map +1 -1
  5. package/lib/cjs/CloudSqlite.d.ts +2 -0
  6. package/lib/cjs/CloudSqlite.d.ts.map +1 -1
  7. package/lib/cjs/CloudSqlite.js.map +1 -1
  8. package/lib/cjs/DisplayStyle.d.ts +2 -2
  9. package/lib/cjs/DisplayStyle.d.ts.map +1 -1
  10. package/lib/cjs/DisplayStyle.js +4 -4
  11. package/lib/cjs/DisplayStyle.js.map +1 -1
  12. package/lib/cjs/ECDb.js +1 -1
  13. package/lib/cjs/ECDb.js.map +1 -1
  14. package/lib/cjs/Element.d.ts +31 -3
  15. package/lib/cjs/Element.d.ts.map +1 -1
  16. package/lib/cjs/Element.js +55 -3
  17. package/lib/cjs/Element.js.map +1 -1
  18. package/lib/cjs/ElementAspect.d.ts +24 -1
  19. package/lib/cjs/ElementAspect.d.ts.map +1 -1
  20. package/lib/cjs/ElementAspect.js +102 -1
  21. package/lib/cjs/ElementAspect.js.map +1 -1
  22. package/lib/cjs/IModelDb.d.ts +26 -3
  23. package/lib/cjs/IModelDb.d.ts.map +1 -1
  24. package/lib/cjs/IModelDb.js +60 -5
  25. package/lib/cjs/IModelDb.js.map +1 -1
  26. package/lib/cjs/IModelElementCloneContext.d.ts +1 -1
  27. package/lib/cjs/IModelElementCloneContext.d.ts.map +1 -1
  28. package/lib/cjs/IModelElementCloneContext.js +2 -2
  29. package/lib/cjs/IModelElementCloneContext.js.map +1 -1
  30. package/lib/cjs/IModelHost.d.ts +1 -2
  31. package/lib/cjs/IModelHost.d.ts.map +1 -1
  32. package/lib/cjs/IModelHost.js +9 -17
  33. package/lib/cjs/IModelHost.js.map +1 -1
  34. package/lib/cjs/Material.d.ts +1 -1
  35. package/lib/cjs/Material.d.ts.map +1 -1
  36. package/lib/cjs/Material.js +2 -2
  37. package/lib/cjs/Material.js.map +1 -1
  38. package/lib/cjs/NavigationRelationship.d.ts +15 -0
  39. package/lib/cjs/NavigationRelationship.d.ts.map +1 -1
  40. package/lib/cjs/NavigationRelationship.js +22 -1
  41. package/lib/cjs/NavigationRelationship.js.map +1 -1
  42. package/lib/cjs/Relationship.d.ts +5 -0
  43. package/lib/cjs/Relationship.d.ts.map +1 -1
  44. package/lib/cjs/Relationship.js +7 -0
  45. package/lib/cjs/Relationship.js.map +1 -1
  46. package/lib/cjs/TileStorage.d.ts +1 -1
  47. package/lib/cjs/TileStorage.d.ts.map +1 -1
  48. package/lib/cjs/TileStorage.js.map +1 -1
  49. package/lib/cjs/TxnManager.d.ts +8 -0
  50. package/lib/cjs/TxnManager.d.ts.map +1 -1
  51. package/lib/cjs/TxnManager.js +30 -2
  52. package/lib/cjs/TxnManager.js.map +1 -1
  53. package/lib/cjs/ViewDefinition.d.ts +1 -1
  54. package/lib/cjs/ViewDefinition.d.ts.map +1 -1
  55. package/lib/cjs/ViewDefinition.js +2 -2
  56. package/lib/cjs/ViewDefinition.js.map +1 -1
  57. package/lib/cjs/annotations/ElementDrivesTextAnnotation.d.ts +15 -1
  58. package/lib/cjs/annotations/ElementDrivesTextAnnotation.d.ts.map +1 -1
  59. package/lib/cjs/annotations/ElementDrivesTextAnnotation.js +36 -23
  60. package/lib/cjs/annotations/ElementDrivesTextAnnotation.js.map +1 -1
  61. package/lib/cjs/annotations/LeaderGeometry.d.ts +13 -1
  62. package/lib/cjs/annotations/LeaderGeometry.d.ts.map +1 -1
  63. package/lib/cjs/annotations/LeaderGeometry.js +88 -10
  64. package/lib/cjs/annotations/LeaderGeometry.js.map +1 -1
  65. package/lib/cjs/annotations/TextAnnotationElement.d.ts +6 -5
  66. package/lib/cjs/annotations/TextAnnotationElement.d.ts.map +1 -1
  67. package/lib/cjs/annotations/TextAnnotationElement.js +33 -14
  68. package/lib/cjs/annotations/TextAnnotationElement.js.map +1 -1
  69. package/lib/cjs/annotations/TextBlockLayout.d.ts.map +1 -1
  70. package/lib/cjs/annotations/TextBlockLayout.js +2 -1
  71. package/lib/cjs/annotations/TextBlockLayout.js.map +1 -1
  72. package/lib/cjs/internal/annotations/fields.d.ts +3 -2
  73. package/lib/cjs/internal/annotations/fields.d.ts.map +1 -1
  74. package/lib/cjs/internal/annotations/fields.js +12 -5
  75. package/lib/cjs/internal/annotations/fields.js.map +1 -1
  76. package/lib/esm/BriefcaseManager.d.ts.map +1 -1
  77. package/lib/esm/BriefcaseManager.js +14 -0
  78. package/lib/esm/BriefcaseManager.js.map +1 -1
  79. package/lib/esm/CloudSqlite.d.ts +2 -0
  80. package/lib/esm/CloudSqlite.d.ts.map +1 -1
  81. package/lib/esm/CloudSqlite.js.map +1 -1
  82. package/lib/esm/DisplayStyle.d.ts +2 -2
  83. package/lib/esm/DisplayStyle.d.ts.map +1 -1
  84. package/lib/esm/DisplayStyle.js +4 -4
  85. package/lib/esm/DisplayStyle.js.map +1 -1
  86. package/lib/esm/ECDb.js +1 -1
  87. package/lib/esm/ECDb.js.map +1 -1
  88. package/lib/esm/Element.d.ts +31 -3
  89. package/lib/esm/Element.d.ts.map +1 -1
  90. package/lib/esm/Element.js +55 -4
  91. package/lib/esm/Element.js.map +1 -1
  92. package/lib/esm/ElementAspect.d.ts +24 -1
  93. package/lib/esm/ElementAspect.d.ts.map +1 -1
  94. package/lib/esm/ElementAspect.js +101 -1
  95. package/lib/esm/ElementAspect.js.map +1 -1
  96. package/lib/esm/IModelDb.d.ts +26 -3
  97. package/lib/esm/IModelDb.d.ts.map +1 -1
  98. package/lib/esm/IModelDb.js +60 -5
  99. package/lib/esm/IModelDb.js.map +1 -1
  100. package/lib/esm/IModelElementCloneContext.d.ts +1 -1
  101. package/lib/esm/IModelElementCloneContext.d.ts.map +1 -1
  102. package/lib/esm/IModelElementCloneContext.js +2 -2
  103. package/lib/esm/IModelElementCloneContext.js.map +1 -1
  104. package/lib/esm/IModelHost.d.ts +1 -2
  105. package/lib/esm/IModelHost.d.ts.map +1 -1
  106. package/lib/esm/IModelHost.js +10 -18
  107. package/lib/esm/IModelHost.js.map +1 -1
  108. package/lib/esm/Material.d.ts +1 -1
  109. package/lib/esm/Material.d.ts.map +1 -1
  110. package/lib/esm/Material.js +2 -2
  111. package/lib/esm/Material.js.map +1 -1
  112. package/lib/esm/NavigationRelationship.d.ts +15 -0
  113. package/lib/esm/NavigationRelationship.d.ts.map +1 -1
  114. package/lib/esm/NavigationRelationship.js +19 -0
  115. package/lib/esm/NavigationRelationship.js.map +1 -1
  116. package/lib/esm/Relationship.d.ts +5 -0
  117. package/lib/esm/Relationship.d.ts.map +1 -1
  118. package/lib/esm/Relationship.js +7 -0
  119. package/lib/esm/Relationship.js.map +1 -1
  120. package/lib/esm/TileStorage.d.ts +1 -1
  121. package/lib/esm/TileStorage.d.ts.map +1 -1
  122. package/lib/esm/TileStorage.js.map +1 -1
  123. package/lib/esm/TxnManager.d.ts +8 -0
  124. package/lib/esm/TxnManager.d.ts.map +1 -1
  125. package/lib/esm/TxnManager.js +30 -2
  126. package/lib/esm/TxnManager.js.map +1 -1
  127. package/lib/esm/ViewDefinition.d.ts +1 -1
  128. package/lib/esm/ViewDefinition.d.ts.map +1 -1
  129. package/lib/esm/ViewDefinition.js +2 -2
  130. package/lib/esm/ViewDefinition.js.map +1 -1
  131. package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts +15 -1
  132. package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts.map +1 -1
  133. package/lib/esm/annotations/ElementDrivesTextAnnotation.js +37 -24
  134. package/lib/esm/annotations/ElementDrivesTextAnnotation.js.map +1 -1
  135. package/lib/esm/annotations/LeaderGeometry.d.ts +13 -1
  136. package/lib/esm/annotations/LeaderGeometry.d.ts.map +1 -1
  137. package/lib/esm/annotations/LeaderGeometry.js +89 -12
  138. package/lib/esm/annotations/LeaderGeometry.js.map +1 -1
  139. package/lib/esm/annotations/TextAnnotationElement.d.ts +6 -5
  140. package/lib/esm/annotations/TextAnnotationElement.d.ts.map +1 -1
  141. package/lib/esm/annotations/TextAnnotationElement.js +33 -14
  142. package/lib/esm/annotations/TextAnnotationElement.js.map +1 -1
  143. package/lib/esm/annotations/TextBlockLayout.d.ts.map +1 -1
  144. package/lib/esm/annotations/TextBlockLayout.js +2 -1
  145. package/lib/esm/annotations/TextBlockLayout.js.map +1 -1
  146. package/lib/esm/internal/annotations/fields.d.ts +3 -2
  147. package/lib/esm/internal/annotations/fields.d.ts.map +1 -1
  148. package/lib/esm/internal/annotations/fields.js +11 -5
  149. package/lib/esm/internal/annotations/fields.js.map +1 -1
  150. package/lib/esm/test/ElementDrivesElement.test.d.ts +93 -0
  151. package/lib/esm/test/ElementDrivesElement.test.d.ts.map +1 -0
  152. package/lib/esm/test/ElementDrivesElement.test.js +862 -0
  153. package/lib/esm/test/ElementDrivesElement.test.js.map +1 -0
  154. package/lib/esm/test/ElementLRUCache.test.js +13 -0
  155. package/lib/esm/test/ElementLRUCache.test.js.map +1 -1
  156. package/lib/esm/test/IModelHost.test.js +17 -11
  157. package/lib/esm/test/IModelHost.test.js.map +1 -1
  158. package/lib/esm/test/annotations/Fields.test.js +44 -0
  159. package/lib/esm/test/annotations/Fields.test.js.map +1 -1
  160. package/lib/esm/test/annotations/LeaderGeometry.test.js +47 -2
  161. package/lib/esm/test/annotations/LeaderGeometry.test.js.map +1 -1
  162. package/lib/esm/test/annotations/TextAnnotation.test.js +120 -31
  163. package/lib/esm/test/annotations/TextAnnotation.test.js.map +1 -1
  164. package/lib/esm/test/ecdb/ConcurrentQuery.test.js +2 -2
  165. package/lib/esm/test/ecdb/ConcurrentQuery.test.js.map +1 -1
  166. package/lib/esm/test/ecdb/ECSqlStatement.test.js +33 -2
  167. package/lib/esm/test/ecdb/ECSqlStatement.test.js.map +1 -1
  168. package/lib/esm/test/element/ProjectInformationRecord.test.d.ts +2 -0
  169. package/lib/esm/test/element/ProjectInformationRecord.test.d.ts.map +1 -0
  170. package/lib/esm/test/element/ProjectInformationRecord.test.js +80 -0
  171. package/lib/esm/test/element/ProjectInformationRecord.test.js.map +1 -0
  172. package/lib/esm/test/element/SheetInformationAspect.test.d.ts +2 -0
  173. package/lib/esm/test/element/SheetInformationAspect.test.d.ts.map +1 -0
  174. package/lib/esm/test/element/SheetInformationAspect.test.js +182 -0
  175. package/lib/esm/test/element/SheetInformationAspect.test.js.map +1 -0
  176. package/lib/esm/test/hubaccess/Rebase.test.js +169 -2
  177. package/lib/esm/test/hubaccess/Rebase.test.js.map +1 -1
  178. package/lib/esm/test/imodel/IModel.test.js +175 -2
  179. package/lib/esm/test/imodel/IModel.test.js.map +1 -1
  180. package/lib/esm/test/incrementalSchemaLocater/ECSqlQueries.test.js.map +1 -1
  181. package/lib/esm/test/standalone/ChangesetReader.test.js +63 -60
  182. package/lib/esm/test/standalone/ChangesetReader.test.js.map +1 -1
  183. package/lib/esm/test/standalone/DisplayStyle.test.js +6 -6
  184. package/lib/esm/test/standalone/DisplayStyle.test.js.map +1 -1
  185. package/lib/esm/test/standalone/ElementGraphics.test.js +75 -6
  186. package/lib/esm/test/standalone/ElementGraphics.test.js.map +1 -1
  187. package/lib/esm/test/standalone/RenderMaterialElement.test.js +4 -4
  188. package/lib/esm/test/standalone/RenderMaterialElement.test.js.map +1 -1
  189. package/lib/esm/test/standalone/TxnManager.test.js +33 -5
  190. package/lib/esm/test/standalone/TxnManager.test.js.map +1 -1
  191. package/package.json +16 -18
@@ -5,8 +5,8 @@
5
5
  /** @packageDocumentation
6
6
  * @module ElementGeometry
7
7
  */
8
- import { ColorDef } from "@itwin/core-common";
9
- import { CurveCurve, LineSegment3d, LineString3d, Point3d, Vector3d } from "@itwin/core-geometry";
8
+ import { ColorDef, FillDisplay } from "@itwin/core-common";
9
+ import { Angle, Arc3d, CurveCurve, LineSegment3d, LineString3d, Loop, Point3d, Vector3d } from "@itwin/core-geometry";
10
10
  import { computeFrame } from "./FrameGeometry";
11
11
  /**
12
12
  * Constructs and appends leader lines and their terminators to the provided geometry builder for a text annotation.
@@ -66,21 +66,98 @@ export function appendLeadersToBuilder(builder, leaders, layout, transform, para
66
66
  leaderLinePoints.push(attachmentPoint.plusScaled(elbowDirection, elbowLength));
67
67
  }
68
68
  leaderLinePoints.push(attachmentPoint);
69
- result = result && builder.appendGeometryQuery(LineString3d.create(leaderLinePoints));
70
- // Terminator geometry
71
69
  const terminatorDirection = Vector3d.createStartEnd(leaderLinePoints[0], leaderLinePoints[1]).normalize();
72
- const termY = terminatorDirection?.unitCrossProduct(Vector3d.unitZ());
73
- if (!termY || !terminatorDirection)
74
- continue; // Assuming leaders without terminators is a valid case.
75
- const terminatorHeight = leaderStyle.leader.terminatorHeightFactor * scaledBlockTextHeight;
76
70
  const terminatorWidth = leaderStyle.leader.terminatorWidthFactor * scaledBlockTextHeight;
77
- const basePoint = leader.startPoint.plusScaled(terminatorDirection, terminatorWidth);
78
- const termPointA = basePoint.plusScaled(termY, terminatorHeight);
79
- const termPointB = basePoint.plusScaled(termY.negate(), terminatorHeight);
80
- result = result && builder.appendGeometryQuery(LineString3d.create([termPointA, leader.startPoint, termPointB]));
71
+ // Truncate the first segment of the leader lines to account for the arrowhead size when closedArrow (hollow triangle) terminatorShape is used.
72
+ if (leaderStyle.leader.terminatorShape === "closedArrow") {
73
+ if (terminatorDirection)
74
+ leaderLinePoints[0] = leaderLinePoints[0].plusScaled(terminatorDirection, terminatorWidth);
75
+ }
76
+ result = result && builder.appendGeometryQuery(LineString3d.create(leaderLinePoints));
77
+ if (leaderStyle.leader.terminatorShape !== "none") {
78
+ // Terminator geometry
79
+ if (!terminatorDirection)
80
+ continue; // Assuming leaders without terminators is a valid case.
81
+ result = result && createTerminatorGeometry(builder, leader.startPoint, terminatorDirection, params, leaderStyle, scaledBlockTextHeight);
82
+ }
83
+ }
84
+ return result;
85
+ }
86
+ /**
87
+ * Creates the geometry for a terminator at the end of a leader line.
88
+ * @param builder The geometry builder to append the terminator geometry to.
89
+ * @param point The starting point of the leader line.
90
+ * @param dir The direction vector of the leader line.
91
+ * @param params The geometry parameters to use for the terminator.
92
+ * @param textStyleSettings The text style settings to use for the terminator.
93
+ * @param textHeight The height of the text block.
94
+ * @returns True if the geometry was successfully created, false otherwise.
95
+ * @beta
96
+ */
97
+ export function createTerminatorGeometry(builder, point, dir, params, textStyleSettings, textHeight) {
98
+ let result = true;
99
+ const termY = dir.unitCrossProduct(Vector3d.unitZ());
100
+ if (!termY)
101
+ return false; // If dir is parallel to Z, we can't create a terminator
102
+ const terminatorHeight = textStyleSettings.leader.terminatorHeightFactor * textHeight;
103
+ const terminatorWidth = textStyleSettings.leader.terminatorWidthFactor * textHeight;
104
+ const terminatorHalfHeight = terminatorHeight / 2;
105
+ const basePoint = point.plusScaled(dir, terminatorWidth);
106
+ const point1 = basePoint.plusScaled(termY, terminatorHalfHeight);
107
+ const point2 = basePoint.plusScaled(termY.negate(), terminatorHalfHeight);
108
+ // Helper function to add fill parameters
109
+ const addFillParams = () => {
110
+ params.fillDisplay = FillDisplay.Always;
111
+ result = result && builder.appendGeometryParamsChange(params);
112
+ };
113
+ // Helper function to create geometry entry
114
+ const addGeometry = (content, useLoop = false) => {
115
+ const finalContent = useLoop ? Loop.create(content) : content;
116
+ result = result && builder.appendGeometryQuery(finalContent);
117
+ };
118
+ switch (textStyleSettings.leader.terminatorShape) {
119
+ case "openArrow": {
120
+ const lineString = LineString3d.create([point1, point, point2]);
121
+ addGeometry(lineString);
122
+ break;
123
+ }
124
+ case "closedArrow": {
125
+ const lineString = LineString3d.create([point1, point, point2, point1]);
126
+ addGeometry(lineString);
127
+ break;
128
+ }
129
+ case "closedArrowFilled": {
130
+ addFillParams();
131
+ const lineString = LineString3d.create([point1, point, point2, point1]);
132
+ addGeometry(lineString, true);
133
+ break;
134
+ }
135
+ case "circle": {
136
+ const circle = Arc3d.createXY(point, terminatorHalfHeight);
137
+ addGeometry(circle);
138
+ break;
139
+ }
140
+ case "circleFilled": {
141
+ addFillParams();
142
+ const circle = Arc3d.createXY(point, terminatorHalfHeight);
143
+ addGeometry(circle, true);
144
+ break;
145
+ }
146
+ case "slash": {
147
+ const normalizedVector = dir.normalize();
148
+ if (!normalizedVector)
149
+ throw new Error("Invalid reference vector for slash terminator.");
150
+ const rotatedVector = normalizedVector.rotateXY(Angle.createDegrees(45));
151
+ const startPoint = point.plusScaled(rotatedVector, -terminatorHalfHeight);
152
+ const endPoint = point.plusScaled(rotatedVector, terminatorHalfHeight);
153
+ const slashLine = LineSegment3d.create(startPoint, endPoint);
154
+ addGeometry(slashLine);
155
+ break;
156
+ }
81
157
  }
82
158
  return result;
83
159
  }
160
+ ;
84
161
  /**
85
162
  * Computes the direction vector for an "elbow" for leader based on the attachment point and a frame curve.
86
163
  * The elbow direction is determined by whether the attachment point is closer to the left or right side of the frame.
@@ -1 +1 @@
1
- {"version":3,"file":"LeaderGeometry.js","sourceRoot":"","sources":["../../../src/annotations/LeaderGeometry.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAA8F,MAAM,oBAAoB,CAAC;AAC1I,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAc,OAAO,EAAa,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACzH,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/C;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAgC,EAAE,OAA+B,EAAE,MAAuB,EAAE,SAAoB,EAAE,MAAsB,EAAE,iBAAoC,EAAE,WAAmB;IACxO,IAAI,MAAM,GAAG,IAAI,CAAC;IAClB,MAAM,qBAAqB,GAAG,iBAAiB,CAAC,aAAa,CAAC,UAAU,GAAG,WAAW,CAAC;IACvF,IAAI,KAAK,GAAoC,iBAAiB,CAAC,aAA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C,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YACjD,qBAAqB,GAAG,qBAAqB,CAAC,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC;YAC7G,cAAc,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC;QAC3C,CAAC;QACD,uFAAuF;QACvF,+EAA+E;QAC/E,MAAM,WAAW,GAAG,qBAAqB,CAAC,UAAU,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC,CAAC,8CAA8C;QACzH,MAAM,gBAAgB,GAAG,aAAa,CAAC,MAAM,CAAC,qBAAqB,EAAE,WAAW,CAAC,CAAC;QAClF,MAAM,kBAAkB,GAAG,UAAU,CAAC,oBAAoB,CAAC,gBAAgB,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;QACvG,eAAe,GAAG,kBAAkB,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC;IACzD,CAAC;IACD,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ElementGeometry\n */\n\nimport { ColorDef, ElementGeometry, GeometryParams, TextAnnotationLeader, TextFrameStyleProps, TextStyleColor } from \"@itwin/core-common\";\nimport { CurveCurve, LineSegment3d, LineString3d, Loop, Path, Point3d, Transform, Vector3d } from \"@itwin/core-geometry\";\nimport { computeFrame } from \"./FrameGeometry\";\nimport { TextBlockLayout, TextStyleResolver } from \"./TextBlockLayout\";\n\n/**\n * Constructs and appends leader lines and their terminators to the provided geometry builder for a text annotation.\n *\n * This function processes an array of `TextAnnotationLeader` objects, computes their attachment points\n * relative to a text frame (or a default rectangular frame if none is provided), and appends the leader\n * line and terminator geometry to the builder. It also applies color overrides if specified\n * in the leader's style overrides.\n *\n * @param builder - The geometry builder to which the leader geometries will be appended.\n * @param leaders - An array of leader properties.\n * @param layout - The layout information for the text block, including its range.\n * @param transform - The transform to apply to the frame and leader geometry.\n * @param params - The geometry parameters, such as color, to use for the leader lines.\n * @param textStyleResolver - Resolver for text styles, used to obtain leader styles.\n * @param scaleFactor - The scale factor to apply to leader dimensions, usually comes from the `scaleFactor` of a [[Drawing]] element.\n * @returns `true` if at least one leader with a terminator was successfully appended; otherwise, `false`.\n * @beta\n */\nexport function appendLeadersToBuilder(builder: ElementGeometry.Builder, leaders: TextAnnotationLeader[], layout: TextBlockLayout, transform: Transform, params: GeometryParams, textStyleResolver: TextStyleResolver, scaleFactor: number): boolean {\n let result = true;\n const scaledBlockTextHeight = textStyleResolver.blockSettings.textHeight * scaleFactor;\n let frame: TextFrameStyleProps | undefined = textStyleResolver.blockSettings.frame;\n\n // If there is no frame, use a rectangular frame to compute the attachmentPoints for leaders.\n if (frame === undefined || frame.shape === \"none\") {\n frame = { shape: \"rectangle\" }\n }\n if (frame.shape === undefined || frame.shape === \"none\") return false;\n const frameCurve = computeFrame({ frame: frame.shape, range: layout.range, transform });\n\n for (const leader of leaders) {\n const leaderStyle = textStyleResolver.resolveSettings(leader.styleOverrides ?? {}, true);\n\n let effectiveColor: TextStyleColor = \"subcategory\";\n\n if (leaderStyle.leader.color === \"inherit\") {\n effectiveColor = leaderStyle.color;\n } else if (leaderStyle.leader.color !== \"subcategory\") {\n effectiveColor = leaderStyle.leader.color;\n }\n\n if (effectiveColor !== \"subcategory\") {\n params.lineColor = ColorDef.fromJSON(effectiveColor);\n result = result && builder.appendGeometryParamsChange(params);\n }\n\n const attachmentPoint = computeLeaderAttachmentPoint(leader, frameCurve, layout, transform);\n if (!attachmentPoint) return false;\n\n // Leader line geometry\n const leaderLinePoints: Point3d[] = [];\n\n leaderLinePoints.push(leader.startPoint)\n\n leader.intermediatePoints?.forEach((point) => {\n leaderLinePoints.push(point);\n });\n\n if (leaderStyle.leader.wantElbow) {\n const elbowLength = leaderStyle.leader.elbowLength * scaledBlockTextHeight;\n const elbowDirection = computeElbowDirection(attachmentPoint, frameCurve, elbowLength);\n if (elbowDirection)\n leaderLinePoints.push(attachmentPoint.plusScaled(elbowDirection, elbowLength))\n }\n\n leaderLinePoints.push(attachmentPoint)\n\n result = result && builder.appendGeometryQuery(LineString3d.create(leaderLinePoints));\n\n // Terminator geometry\n const terminatorDirection = Vector3d.createStartEnd(\n leaderLinePoints[0], leaderLinePoints[1]\n ).normalize();\n\n const termY = terminatorDirection?.unitCrossProduct(Vector3d.unitZ());\n if (!termY || !terminatorDirection) continue; // Assuming leaders without terminators is a valid case.\n const terminatorHeight = leaderStyle.leader.terminatorHeightFactor * scaledBlockTextHeight;\n const terminatorWidth = leaderStyle.leader.terminatorWidthFactor * scaledBlockTextHeight;\n const basePoint = leader.startPoint.plusScaled(terminatorDirection, terminatorWidth);\n const termPointA = basePoint.plusScaled(termY, terminatorHeight);\n const termPointB = basePoint.plusScaled(termY.negate(), terminatorHeight);\n result = result && builder.appendGeometryQuery(LineString3d.create([termPointA, leader.startPoint, termPointB]));\n\n }\n return result;\n}\n\n\n/**\n * Computes the direction vector for an \"elbow\" for leader based on the attachment point and a frame curve.\n * The elbow direction is determined by whether the attachment point is closer to the left or right side of the frame.\n * If the computed elbow would be tangent to the frame at the intersection, no elbow direction is returned.\n *\n * @param attachmentPoint - The point where the leader attaches.\n * @param frameCurve - The frame curve (either a Loop or Path) to which the leader is attached.\n * @param elbowLength - The length of the elbow segment to be created.\n * @returns The direction vector for the elbow, or `undefined` if the elbow would be tangent to the frame.\n * @beta\n */\nexport function computeElbowDirection(attachmentPoint: Point3d, frameCurve: Loop | Path, elbowLength: number): Vector3d | undefined {\n\n let elbowDirection: Vector3d | undefined;\n // Determine the direction based on the closest point's position relative to the frame\n const isCloserToLeft = Math.abs(attachmentPoint.x - frameCurve.range().low.x) < Math.abs(attachmentPoint.x - frameCurve.range().high.x);\n\n // Decide the direction: left (-X) or right (+X)\n elbowDirection = isCloserToLeft ? Vector3d.unitX().negate() : Vector3d.unitX();\n\n // Verify if the elbow is a tangent to the frame, if yes, do not create an elbow\n const elbowPoint = attachmentPoint.plusScaled(elbowDirection, elbowLength);\n const elbowLine = LineSegment3d.create(attachmentPoint, elbowPoint);\n // Find intersection points between the elbow and the frame\n const intersections = CurveCurve.intersectionXYZPairs(elbowLine, false, frameCurve, false);\n // As the elbow will intersect the frame only at one point, we can safely use the first intersection\n const intersection = intersections[0];\n const curveFraction = intersection.detailB.fraction;\n const derivative = intersection.detailB.curve?.fractionToPointAndDerivative(curveFraction);\n const tangent = derivative?.direction.normalize();\n const lineDirection = Vector3d.createStartEnd(elbowLine.point0Ref, elbowLine.point1Ref).normalize();\n if (tangent && lineDirection) {\n const dot = tangent.dotProduct(lineDirection);\n // If the tangent and line direction are aligned (dot product close to 1 or -1), it's tangent\n if (Math.abs(dot) > 0.999) {\n elbowDirection = undefined;\n }\n }\n return elbowDirection;\n}\n\n/**\n * Computes the attachment point for a leader line on a text annotation frame.\n *\n * The attachment point is determined based on the leader's attachment mode:\n * - `\"Nearest\"`: Finds the closest point on the frame curve to the leader's start point.\n * - `\"KeyPoint\"`: Uses a specific curve segment and fraction along that segment to determine the point.\n * - `\"TextPoint\"`: Calculates a point on the text layout (top/bottom, left/right) and projects it onto the frame curve.\n *\n * @param leader - The leader props.\n * @param frameCurve - The curve (Loop or Path) representing the annotation frame.\n * @param textLayout - The layout information for the text block.\n * @param transform - The transform applied to the text layout.\n * @returns The computed attachment point as a `Point3d`, or `undefined` if it cannot be determined.\n * @beta\n */\nexport function computeLeaderAttachmentPoint(\n leader: TextAnnotationLeader,\n frameCurve: Loop | Path,\n textLayout: TextBlockLayout,\n transform: Transform\n): Point3d | undefined {\n let attachmentPoint: Point3d | undefined;\n\n if (leader.attachment.mode === \"Nearest\") {\n attachmentPoint = frameCurve.closestPoint(leader.startPoint)?.point;\n } else if (leader.attachment.mode === \"KeyPoint\") {\n const curves = frameCurve.collectCurvePrimitives(undefined, false, true);\n const curveIndex = leader.attachment.curveIndex;\n const fraction = leader.attachment.fraction;\n if (curveIndex >= curves.length) {\n // If the curveIndex is invalid, use the last curve\n // This is a fallback to avoid out-of-bounds access\n attachmentPoint = curves[curves.length - 1].fractionToPoint(fraction);\n } else {\n attachmentPoint = curves[curveIndex].fractionToPoint(fraction);\n }\n } else { // attachment.mode=\"TextPoint\"\n let scaleDirection = transform.matrix.getColumn(0).negate(); // direction to draw a scaled line from text attachment point to find intersection point on frame\n let lineIndex: number;\n if (leader.attachment.position.includes(\"Top\")) {\n lineIndex = 0\n } else {\n lineIndex = textLayout.lines.length - 1\n }\n const lineRange = textLayout.lines[lineIndex].range;\n const lineOffset = textLayout.lines[lineIndex].offsetFromDocument;\n const origin = transform.multiplyPoint3d(Point3d.fromJSON(lineOffset));\n let attachmentPointOnText = origin.plusScaled(transform.matrix.getColumn(1), ((lineRange.yLength()) / 2));\n\n if (leader.attachment.position.includes(\"Right\")) {\n attachmentPointOnText = attachmentPointOnText.plusScaled(transform.matrix.getColumn(0), lineRange.xLength());\n scaleDirection = scaleDirection.negate();\n }\n // Find the nearest intersection point on the frame to get the correct attachment point\n // Extend the direction vector to create a target point far along the direction\n const targetPoint = attachmentPointOnText.plusScaled(scaleDirection, 1e6); // Scale the direction vector to a large value\n const intersectionLine = LineSegment3d.create(attachmentPointOnText, targetPoint);\n const closestPointDetail = CurveCurve.intersectionXYZPairs(intersectionLine, false, frameCurve, false);\n attachmentPoint = closestPointDetail[0]?.detailA.point;\n }\n return attachmentPoint;\n}"]}
1
+ {"version":3,"file":"LeaderGeometry.js","sourceRoot":"","sources":["../../../src/annotations/LeaderGeometry.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAmB,WAAW,EAAgG,MAAM,oBAAoB,CAAC;AAC1K,OAAO,EAAE,KAAK,EAAE,KAAK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,8CAA8C;QACzH,MAAM,gBAAgB,GAAG,aAAa,CAAC,MAAM,CAAC,qBAAqB,EAAE,WAAW,CAAC,CAAC;QAClF,MAAM,kBAAkB,GAAG,UAAU,CAAC,oBAAoB,CAAC,gBAAgB,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;QACvG,eAAe,GAAG,kBAAkB,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC;IACzD,CAAC;IACD,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ElementGeometry\n */\n\nimport { ColorDef, ElementGeometry, FillDisplay, GeometryParams, TextAnnotationLeader, TextFrameStyleProps, TextStyleColor, TextStyleSettings } from \"@itwin/core-common\";\nimport { Angle, Arc3d, CurveCurve, CurvePrimitive, LineSegment3d, LineString3d, Loop, Path, Point3d, Transform, Vector3d } from \"@itwin/core-geometry\";\nimport { computeFrame } from \"./FrameGeometry\";\nimport { TextBlockLayout, TextStyleResolver } from \"./TextBlockLayout\";\n\n/**\n * Constructs and appends leader lines and their terminators to the provided geometry builder for a text annotation.\n *\n * This function processes an array of `TextAnnotationLeader` objects, computes their attachment points\n * relative to a text frame (or a default rectangular frame if none is provided), and appends the leader\n * line and terminator geometry to the builder. It also applies color overrides if specified\n * in the leader's style overrides.\n *\n * @param builder - The geometry builder to which the leader geometries will be appended.\n * @param leaders - An array of leader properties.\n * @param layout - The layout information for the text block, including its range.\n * @param transform - The transform to apply to the frame and leader geometry.\n * @param params - The geometry parameters, such as color, to use for the leader lines.\n * @param textStyleResolver - Resolver for text styles, used to obtain leader styles.\n * @param scaleFactor - The scale factor to apply to leader dimensions, usually comes from the `scaleFactor` of a [[Drawing]] element.\n * @returns `true` if at least one leader with a terminator was successfully appended; otherwise, `false`.\n * @beta\n */\nexport function appendLeadersToBuilder(builder: ElementGeometry.Builder, leaders: TextAnnotationLeader[], layout: TextBlockLayout, transform: Transform, params: GeometryParams, textStyleResolver: TextStyleResolver, scaleFactor: number): boolean {\n let result = true;\n const scaledBlockTextHeight = textStyleResolver.blockSettings.textHeight * scaleFactor;\n let frame: TextFrameStyleProps | undefined = textStyleResolver.blockSettings.frame;\n\n // If there is no frame, use a rectangular frame to compute the attachmentPoints for leaders.\n if (frame === undefined || frame.shape === \"none\") {\n frame = { shape: \"rectangle\" }\n }\n if (frame.shape === undefined || frame.shape === \"none\") return false;\n const frameCurve = computeFrame({ frame: frame.shape, range: layout.range, transform });\n\n for (const leader of leaders) {\n const leaderStyle = textStyleResolver.resolveSettings(leader.styleOverrides ?? {}, true);\n\n let effectiveColor: TextStyleColor = \"subcategory\";\n\n if (leaderStyle.leader.color === \"inherit\") {\n effectiveColor = leaderStyle.color;\n } else if (leaderStyle.leader.color !== \"subcategory\") {\n effectiveColor = leaderStyle.leader.color;\n }\n\n if (effectiveColor !== \"subcategory\") {\n params.lineColor = ColorDef.fromJSON(effectiveColor);\n result = result && builder.appendGeometryParamsChange(params);\n }\n\n const attachmentPoint = computeLeaderAttachmentPoint(leader, frameCurve, layout, transform);\n if (!attachmentPoint) return false;\n\n // Leader line geometry\n const leaderLinePoints: Point3d[] = [];\n\n leaderLinePoints.push(leader.startPoint)\n\n leader.intermediatePoints?.forEach((point) => {\n leaderLinePoints.push(point);\n });\n\n if (leaderStyle.leader.wantElbow) {\n const elbowLength = leaderStyle.leader.elbowLength * scaledBlockTextHeight;\n const elbowDirection = computeElbowDirection(attachmentPoint, frameCurve, elbowLength);\n if (elbowDirection)\n leaderLinePoints.push(attachmentPoint.plusScaled(elbowDirection, elbowLength))\n }\n\n leaderLinePoints.push(attachmentPoint)\n\n const terminatorDirection = Vector3d.createStartEnd(\n leaderLinePoints[0], leaderLinePoints[1]\n ).normalize();\n const terminatorWidth = leaderStyle.leader.terminatorWidthFactor * scaledBlockTextHeight;\n // Truncate the first segment of the leader lines to account for the arrowhead size when closedArrow (hollow triangle) terminatorShape is used.\n if (leaderStyle.leader.terminatorShape === \"closedArrow\") {\n if (terminatorDirection)\n leaderLinePoints[0] = leaderLinePoints[0].plusScaled(terminatorDirection, terminatorWidth);\n }\n\n result = result && builder.appendGeometryQuery(LineString3d.create(leaderLinePoints));\n\n if (leaderStyle.leader.terminatorShape !== \"none\") {\n // Terminator geometry\n if (!terminatorDirection) continue; // Assuming leaders without terminators is a valid case.\n result = result && createTerminatorGeometry(builder, leader.startPoint, terminatorDirection, params, leaderStyle, scaledBlockTextHeight);\n\n }\n\n }\n return result;\n}\n\n/**\n * Creates the geometry for a terminator at the end of a leader line.\n * @param builder The geometry builder to append the terminator geometry to.\n * @param point The starting point of the leader line.\n * @param dir The direction vector of the leader line.\n * @param params The geometry parameters to use for the terminator.\n * @param textStyleSettings The text style settings to use for the terminator.\n * @param textHeight The height of the text block.\n * @returns True if the geometry was successfully created, false otherwise.\n * @beta\n */\nexport function createTerminatorGeometry(builder: ElementGeometry.Builder, point: Point3d, dir: Vector3d, params: GeometryParams, textStyleSettings: TextStyleSettings, textHeight: number): boolean {\n\n let result = true;\n const termY = dir.unitCrossProduct(Vector3d.unitZ());\n if (!termY) return false; // If dir is parallel to Z, we can't create a terminator\n const terminatorHeight = textStyleSettings.leader.terminatorHeightFactor * textHeight;\n const terminatorWidth = textStyleSettings.leader.terminatorWidthFactor * textHeight;\n const terminatorHalfHeight = terminatorHeight / 2;\n const basePoint = point.plusScaled(dir, terminatorWidth);\n const point1 = basePoint.plusScaled(termY, terminatorHalfHeight);\n const point2 = basePoint.plusScaled(termY.negate(), terminatorHalfHeight);\n\n // Helper function to add fill parameters\n const addFillParams = () => {\n params.fillDisplay = FillDisplay.Always;\n result = result && builder.appendGeometryParamsChange(params);\n };\n\n // Helper function to create geometry entry\n const addGeometry = (content: CurvePrimitive, useLoop = false) => {\n const finalContent = useLoop ? Loop.create(content) : content;\n result = result && builder.appendGeometryQuery(finalContent);\n };\n\n switch (textStyleSettings.leader.terminatorShape) {\n case \"openArrow\": {\n const lineString = LineString3d.create([point1, point, point2]);\n addGeometry(lineString);\n break;\n }\n\n case \"closedArrow\": {\n const lineString = LineString3d.create([point1, point, point2, point1]);\n addGeometry(lineString);\n break;\n }\n\n case \"closedArrowFilled\": {\n addFillParams();\n const lineString = LineString3d.create([point1, point, point2, point1]);\n addGeometry(lineString, true);\n break;\n }\n\n case \"circle\": {\n const circle = Arc3d.createXY(point, terminatorHalfHeight);\n addGeometry(circle);\n break;\n }\n\n case \"circleFilled\": {\n addFillParams();\n const circle = Arc3d.createXY(point, terminatorHalfHeight);\n addGeometry(circle, true);\n break;\n }\n\n case \"slash\": {\n const normalizedVector = dir.normalize();\n if (!normalizedVector) throw new Error(\"Invalid reference vector for slash terminator.\");\n\n const rotatedVector = normalizedVector.rotateXY(Angle.createDegrees(45));\n const startPoint = point.plusScaled(rotatedVector, -terminatorHalfHeight);\n const endPoint = point.plusScaled(rotatedVector, terminatorHalfHeight);\n\n const slashLine = LineSegment3d.create(startPoint, endPoint);\n addGeometry(slashLine);\n break;\n }\n\n }\n\n return result;\n};\n\n\n/**\n * Computes the direction vector for an \"elbow\" for leader based on the attachment point and a frame curve.\n * The elbow direction is determined by whether the attachment point is closer to the left or right side of the frame.\n * If the computed elbow would be tangent to the frame at the intersection, no elbow direction is returned.\n *\n * @param attachmentPoint - The point where the leader attaches.\n * @param frameCurve - The frame curve (either a Loop or Path) to which the leader is attached.\n * @param elbowLength - The length of the elbow segment to be created.\n * @returns The direction vector for the elbow, or `undefined` if the elbow would be tangent to the frame.\n * @beta\n */\nexport function computeElbowDirection(attachmentPoint: Point3d, frameCurve: Loop | Path, elbowLength: number): Vector3d | undefined {\n\n let elbowDirection: Vector3d | undefined;\n // Determine the direction based on the closest point's position relative to the frame\n const isCloserToLeft = Math.abs(attachmentPoint.x - frameCurve.range().low.x) < Math.abs(attachmentPoint.x - frameCurve.range().high.x);\n\n // Decide the direction: left (-X) or right (+X)\n elbowDirection = isCloserToLeft ? Vector3d.unitX().negate() : Vector3d.unitX();\n\n // Verify if the elbow is a tangent to the frame, if yes, do not create an elbow\n const elbowPoint = attachmentPoint.plusScaled(elbowDirection, elbowLength);\n const elbowLine = LineSegment3d.create(attachmentPoint, elbowPoint);\n // Find intersection points between the elbow and the frame\n const intersections = CurveCurve.intersectionXYZPairs(elbowLine, false, frameCurve, false);\n // As the elbow will intersect the frame only at one point, we can safely use the first intersection\n const intersection = intersections[0];\n const curveFraction = intersection.detailB.fraction;\n const derivative = intersection.detailB.curve?.fractionToPointAndDerivative(curveFraction);\n const tangent = derivative?.direction.normalize();\n const lineDirection = Vector3d.createStartEnd(elbowLine.point0Ref, elbowLine.point1Ref).normalize();\n if (tangent && lineDirection) {\n const dot = tangent.dotProduct(lineDirection);\n // If the tangent and line direction are aligned (dot product close to 1 or -1), it's tangent\n if (Math.abs(dot) > 0.999) {\n elbowDirection = undefined;\n }\n }\n return elbowDirection;\n}\n\n/**\n * Computes the attachment point for a leader line on a text annotation frame.\n *\n * The attachment point is determined based on the leader's attachment mode:\n * - `\"Nearest\"`: Finds the closest point on the frame curve to the leader's start point.\n * - `\"KeyPoint\"`: Uses a specific curve segment and fraction along that segment to determine the point.\n * - `\"TextPoint\"`: Calculates a point on the text layout (top/bottom, left/right) and projects it onto the frame curve.\n *\n * @param leader - The leader props.\n * @param frameCurve - The curve (Loop or Path) representing the annotation frame.\n * @param textLayout - The layout information for the text block.\n * @param transform - The transform applied to the text layout.\n * @returns The computed attachment point as a `Point3d`, or `undefined` if it cannot be determined.\n * @beta\n */\nexport function computeLeaderAttachmentPoint(\n leader: TextAnnotationLeader,\n frameCurve: Loop | Path,\n textLayout: TextBlockLayout,\n transform: Transform\n): Point3d | undefined {\n let attachmentPoint: Point3d | undefined;\n\n if (leader.attachment.mode === \"Nearest\") {\n attachmentPoint = frameCurve.closestPoint(leader.startPoint)?.point;\n } else if (leader.attachment.mode === \"KeyPoint\") {\n const curves = frameCurve.collectCurvePrimitives(undefined, false, true);\n const curveIndex = leader.attachment.curveIndex;\n const fraction = leader.attachment.fraction;\n if (curveIndex >= curves.length) {\n // If the curveIndex is invalid, use the last curve\n // This is a fallback to avoid out-of-bounds access\n attachmentPoint = curves[curves.length - 1].fractionToPoint(fraction);\n } else {\n attachmentPoint = curves[curveIndex].fractionToPoint(fraction);\n }\n } else { // attachment.mode=\"TextPoint\"\n let scaleDirection = transform.matrix.getColumn(0).negate(); // direction to draw a scaled line from text attachment point to find intersection point on frame\n let lineIndex: number;\n if (leader.attachment.position.includes(\"Top\")) {\n lineIndex = 0\n } else {\n lineIndex = textLayout.lines.length - 1\n }\n const lineRange = textLayout.lines[lineIndex].range;\n const lineOffset = textLayout.lines[lineIndex].offsetFromDocument;\n const origin = transform.multiplyPoint3d(Point3d.fromJSON(lineOffset));\n let attachmentPointOnText = origin.plusScaled(transform.matrix.getColumn(1), ((lineRange.yLength()) / 2));\n\n if (leader.attachment.position.includes(\"Right\")) {\n attachmentPointOnText = attachmentPointOnText.plusScaled(transform.matrix.getColumn(0), lineRange.xLength());\n scaleDirection = scaleDirection.negate();\n }\n // Find the nearest intersection point on the frame to get the correct attachment point\n // Extend the direction vector to create a target point far along the direction\n const targetPoint = attachmentPointOnText.plusScaled(scaleDirection, 1e6); // Scale the direction vector to a large value\n const intersectionLine = LineSegment3d.create(attachmentPointOnText, targetPoint);\n const closestPointDetail = CurveCurve.intersectionXYZPairs(intersectionLine, false, frameCurve, false);\n attachmentPoint = closestPointDetail[0]?.detailA.point;\n }\n return attachmentPoint;\n}"]}
@@ -137,7 +137,7 @@ export declare class TextAnnotation2d extends AnnotationElement2d {
137
137
  static onUpdated(arg: OnElementIdArg): void;
138
138
  protected collectReferenceIds(referenceIds: EntityReferenceSet): void;
139
139
  /** @internal */
140
- protected static onCloned(context: IModelElementCloneContext, srcProps: TextAnnotation2dProps, dstProps: TextAnnotation2dProps): void;
140
+ protected static onCloned(context: IModelElementCloneContext, srcProps: TextAnnotation2dProps, dstProps: TextAnnotation2dProps): Promise<void>;
141
141
  }
142
142
  /** An element that displays textual content within a 3d model.
143
143
  * The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.
@@ -225,13 +225,13 @@ export declare class TextAnnotation3d extends GraphicalElement3d {
225
225
  static onUpdated(arg: OnElementIdArg): void;
226
226
  protected collectReferenceIds(referenceIds: EntityReferenceSet): void;
227
227
  /** @internal */
228
- protected static onCloned(context: IModelElementCloneContext, srcProps: TextAnnotation3dProps, dstProps: TextAnnotation3dProps): void;
228
+ protected static onCloned(context: IModelElementCloneContext, srcProps: TextAnnotation3dProps, dstProps: TextAnnotation3dProps): Promise<void>;
229
229
  }
230
230
  /** The version of the JSON stored in `AnnotationTextStyleProps.settings` used by the code.
231
231
  * Uses the same semantics as [ECVersion]($ecschema-metadata).
232
232
  * @internal
233
233
  */
234
- export declare const TEXT_STYLE_SETTINGS_JSON_VERSION = "1.0.0";
234
+ export declare const TEXT_STYLE_SETTINGS_JSON_VERSION = "1.0.1";
235
235
  /** Arguments supplied when creating an [[AnnotationTextStyle]].
236
236
  * @beta
237
237
  */
@@ -324,9 +324,10 @@ export declare class AnnotationTextStyle extends DefinitionElement {
324
324
  * corresponding to `sourceTextStyleId`, or [Id64.invalid]($bentley) if no corresponding text style exists.
325
325
  * If a text style with the same [Code]($common) exists in the target iModel, the style Id will be remapped to refer to that style.
326
326
  * Otherwise, a copy of the style will be imported into the target iModel and its element Id returned.
327
- * Implementations of [[ITextAnnotation]] should invoke this function when implementing their [[Element._onCloned]] method.
327
+ * Implementations of [[ITextAnnotation]] should invoke this function when implementing their [[Element.onCloned]] method.
328
328
  * @throws Error if an attempt to import the text style failed.
329
329
  */
330
- static remapTextStyleId(sourceTextStyleId: Id64String, context: IModelElementCloneContext): Id64String;
330
+ static remapTextStyleId(sourceTextStyleId: Id64String, context: IModelElementCloneContext): Promise<Id64String>;
331
+ protected static onCloned(context: IModelElementCloneContext, srcProps: AnnotationTextStyleProps, dstProps: AnnotationTextStyleProps): Promise<void>;
331
332
  }
332
333
  //# sourceMappingURL=TextAnnotationElement.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TextAnnotationElement.d.ts","sourceRoot":"","sources":["../../../src/annotations/TextAnnotationElement.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,wBAAwB,EAAe,IAAI,EAAE,SAAS,EAAE,cAAc,EAA4E,kBAAkB,EAAe,gBAAgB,EAAe,gBAAgB,EAAkB,cAAc,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,sBAAsB,EAA8B,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACjc,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAW,kBAAkB,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpI,OAAO,EAAgB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAG/D,OAAO,EAA+B,oCAAoC,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAClI,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAGnF;;;EAGE;AACF,eAAO,MAAM,4BAA4B,UAAU,CAAC;AA0CpD;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa,CAAC,mBAAmB,CAAC,GAAG,SAAS,CAIhH;AAgBD;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,0CAA0C;IAC1C,QAAQ,EAAE,UAAU,CAAC;IACrB,wDAAwD;IACxD,KAAK,EAAE,UAAU,CAAC;IAClB,mDAAmD;IACnD,SAAS,EAAE,gBAAgB,C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;;;;;OAMG;WACiB,gBAAgB,CAAC,iBAAiB,EAAE,UAAU,EAAE,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,UAAU,CAAC;qBA+B5F,QAAQ,CAAC,OAAO,EAAE,yBAAyB,EAAE,QAAQ,EAAE,wBAAwB,EAAE,QAAQ,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;CAkBpK"}
@@ -222,13 +222,13 @@ export class TextAnnotation2d extends AnnotationElement2d /* implements ITextAnn
222
222
  collectReferenceIds(this, referenceIds);
223
223
  }
224
224
  /** @internal */
225
- static onCloned(context, srcProps, dstProps) {
226
- super.onCloned(context, srcProps, dstProps);
225
+ static async onCloned(context, srcProps, dstProps) {
226
+ await super.onCloned(context, srcProps, dstProps);
227
227
  const srcElem = TextAnnotation2d.fromJSON(srcProps, context.sourceDb);
228
228
  ElementDrivesTextAnnotation.remapFields(srcElem, context);
229
229
  const anno = srcElem.getAnnotation();
230
230
  dstProps.textAnnotationData = anno ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: anno.toJSON() }) : undefined;
231
- remapTextStyle(context, srcElem, dstProps);
231
+ return remapTextStyle(context, srcElem, dstProps);
232
232
  }
233
233
  }
234
234
  /** An element that displays textual content within a 3d model.
@@ -387,17 +387,17 @@ export class TextAnnotation3d extends GraphicalElement3d /* implements ITextAnno
387
387
  collectReferenceIds(this, referenceIds);
388
388
  }
389
389
  /** @internal */
390
- static onCloned(context, srcProps, dstProps) {
391
- super.onCloned(context, srcProps, dstProps);
390
+ static async onCloned(context, srcProps, dstProps) {
391
+ await super.onCloned(context, srcProps, dstProps);
392
392
  const srcElem = TextAnnotation3d.fromJSON(srcProps, context.sourceDb);
393
393
  ElementDrivesTextAnnotation.remapFields(srcElem, context);
394
394
  const anno = srcElem.getAnnotation();
395
395
  dstProps.textAnnotationData = anno ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: anno.toJSON() }) : undefined;
396
- remapTextStyle(context, srcElem, dstProps);
396
+ return remapTextStyle(context, srcElem, dstProps);
397
397
  }
398
398
  }
399
- function remapTextStyle(context, srcElem, dstProps) {
400
- const dstStyleId = AnnotationTextStyle.remapTextStyleId(srcElem.defaultTextStyle?.id ?? Id64.invalid, context);
399
+ async function remapTextStyle(context, srcElem, dstProps) {
400
+ const dstStyleId = await AnnotationTextStyle.remapTextStyleId(srcElem.defaultTextStyle?.id ?? Id64.invalid, context);
401
401
  dstProps.defaultTextStyle = Id64.isValid(dstStyleId) ? new TextAnnotationUsesTextStyleByDefault(dstStyleId).toJSON() : undefined;
402
402
  }
403
403
  function collectReferenceIds(elem, referenceIds) {
@@ -437,12 +437,16 @@ function updateTextBlocks(elem, textBlocks) {
437
437
  * Uses the same semantics as [ECVersion]($ecschema-metadata).
438
438
  * @internal
439
439
  */
440
- export const TEXT_STYLE_SETTINGS_JSON_VERSION = "1.0.0";
440
+ // 1.0.1 - Added terminatorShapes for leaders
441
+ export const TEXT_STYLE_SETTINGS_JSON_VERSION = "1.0.1";
441
442
  function migrateTextStyleSettings(oldData) {
442
443
  if (oldData.version === TEXT_STYLE_SETTINGS_JSON_VERSION)
443
444
  return oldData.data;
444
- // Place migration logic here.
445
- throw new Error(`Migration for settings from version ${oldData.version} to ${TEXT_STYLE_SETTINGS_JSON_VERSION} failed.`);
445
+ // Migrate from 1.0.0 to 1.0.1
446
+ if (oldData.data.leader && !oldData.data.leader.terminatorShape) {
447
+ oldData.data.leader.terminatorShape = TextStyleSettings.defaultProps.leader.terminatorShape;
448
+ }
449
+ return oldData.data;
446
450
  }
447
451
  /**
448
452
  * The definition element that holds text style information.
@@ -581,10 +585,10 @@ export class AnnotationTextStyle extends DefinitionElement {
581
585
  * corresponding to `sourceTextStyleId`, or [Id64.invalid]($bentley) if no corresponding text style exists.
582
586
  * If a text style with the same [Code]($common) exists in the target iModel, the style Id will be remapped to refer to that style.
583
587
  * Otherwise, a copy of the style will be imported into the target iModel and its element Id returned.
584
- * Implementations of [[ITextAnnotation]] should invoke this function when implementing their [[Element._onCloned]] method.
588
+ * Implementations of [[ITextAnnotation]] should invoke this function when implementing their [[Element.onCloned]] method.
585
589
  * @throws Error if an attempt to import the text style failed.
586
590
  */
587
- static remapTextStyleId(sourceTextStyleId, context) {
591
+ static async remapTextStyleId(sourceTextStyleId, context) {
588
592
  // No remapping necessary if there's no text style or we're not copying to a different iModel.
589
593
  if (!Id64.isValid(sourceTextStyleId) || !context.isBetweenIModels) {
590
594
  return sourceTextStyleId;
@@ -605,10 +609,25 @@ export class AnnotationTextStyle extends DefinitionElement {
605
609
  return dstStyleId;
606
610
  }
607
611
  // Copy the style into the target iModel and remap its Id.
608
- const dstStyleProps = context.cloneElement(srcStyle);
612
+ const dstStyleProps = await context.cloneElement(srcStyle);
609
613
  dstStyleId = context.targetDb.elements.insertElement(dstStyleProps);
610
614
  context.remapElement(sourceTextStyleId, dstStyleId);
611
615
  return dstStyleId;
612
616
  }
617
+ static async onCloned(context, srcProps, dstProps) {
618
+ await super.onCloned(context, srcProps, dstProps);
619
+ if (!context.isBetweenIModels) {
620
+ return;
621
+ }
622
+ const settingsProps = AnnotationTextStyle.parseTextStyleSettings(srcProps.settings);
623
+ const font = TextStyleSettings.fromJSON(settingsProps?.data).font;
624
+ const fontsToEmbed = [];
625
+ for (const file of context.sourceDb.fonts.queryEmbeddedFontFiles()) {
626
+ if (file.type === font.type && file.faces.some((face) => face.familyName === font.name)) {
627
+ fontsToEmbed.push(file);
628
+ }
629
+ }
630
+ await Promise.all(fontsToEmbed.map(async (file) => context.targetDb.fonts.embedFontFile({ file })));
631
+ }
613
632
  }
614
633
  //# sourceMappingURL=TextAnnotationElement.js.map