@itwin/core-backend 5.4.0-dev.4 → 5.4.0-dev.6

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 (396) hide show
  1. package/lib/cjs/BackendHubAccess.js.map +1 -1
  2. package/lib/cjs/BackendLoggerCategory.js.map +1 -1
  3. package/lib/cjs/BisCoreSchema.js.map +1 -1
  4. package/lib/cjs/BlobContainerService.js.map +1 -1
  5. package/lib/cjs/BriefcaseManager.js.map +1 -1
  6. package/lib/cjs/CatalogDb.js.map +1 -1
  7. package/lib/cjs/Category.js.map +1 -1
  8. package/lib/cjs/ChangeSummaryManager.js +2 -2
  9. package/lib/cjs/ChangeSummaryManager.js.map +1 -1
  10. package/lib/cjs/ChangedElementsDb.js.map +1 -1
  11. package/lib/cjs/ChangesetECAdaptor.js +248 -248
  12. package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
  13. package/lib/cjs/ChannelControl.js.map +1 -1
  14. package/lib/cjs/CheckpointManager.js.map +1 -1
  15. package/lib/cjs/ClassRegistry.js +5 -5
  16. package/lib/cjs/ClassRegistry.js.map +1 -1
  17. package/lib/cjs/CloudSqlite.js.map +1 -1
  18. package/lib/cjs/CodeService.js.map +1 -1
  19. package/lib/cjs/CodeSpecs.js.map +1 -1
  20. package/lib/cjs/ConcurrentQuery.js.map +1 -1
  21. package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
  22. package/lib/cjs/DevTools.js.map +1 -1
  23. package/lib/cjs/DisplayStyle.js.map +1 -1
  24. package/lib/cjs/ECDb.js.map +1 -1
  25. package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
  26. package/lib/cjs/ECSqlStatement.js.map +1 -1
  27. package/lib/cjs/Element.js.map +1 -1
  28. package/lib/cjs/ElementAspect.js.map +1 -1
  29. package/lib/cjs/ElementGraphics.js.map +1 -1
  30. package/lib/cjs/ElementTreeWalker.js.map +1 -1
  31. package/lib/cjs/Entity.js.map +1 -1
  32. package/lib/cjs/EntityReferences.js.map +1 -1
  33. package/lib/cjs/ExportGraphics.js.map +1 -1
  34. package/lib/cjs/ExternalSource.js.map +1 -1
  35. package/lib/cjs/FontFile.js.map +1 -1
  36. package/lib/cjs/GeoCoordConfig.js.map +1 -1
  37. package/lib/cjs/GeographicCRSServices.js.map +1 -1
  38. package/lib/cjs/GeometrySummary.js +47 -47
  39. package/lib/cjs/GeometrySummary.js.map +1 -1
  40. package/lib/cjs/IModelDb.js +8 -8
  41. package/lib/cjs/IModelDb.js.map +1 -1
  42. package/lib/cjs/IModelDbFonts.js.map +1 -1
  43. package/lib/cjs/IModelElementCloneContext.js.map +1 -1
  44. package/lib/cjs/IModelHost.js.map +1 -1
  45. package/lib/cjs/IModelIncrementalSchemaLocater.js.map +1 -1
  46. package/lib/cjs/IModelJsFs.js.map +1 -1
  47. package/lib/cjs/ImageSourceConversion.js.map +1 -1
  48. package/lib/cjs/IpcHost.js.map +1 -1
  49. package/lib/cjs/LineStyle.js.map +1 -1
  50. package/lib/cjs/LocalHub.js +1 -1
  51. package/lib/cjs/LocalHub.js.map +1 -1
  52. package/lib/cjs/LocalhostIpcHost.js.map +1 -1
  53. package/lib/cjs/LockControl.js.map +1 -1
  54. package/lib/cjs/Material.js.map +1 -1
  55. package/lib/cjs/Model.js.map +1 -1
  56. package/lib/cjs/NativeAppStorage.js.map +1 -1
  57. package/lib/cjs/NativeHost.js.map +1 -1
  58. package/lib/cjs/NavigationRelationship.js.map +1 -1
  59. package/lib/cjs/PromiseMemoizer.js.map +1 -1
  60. package/lib/cjs/PropertyStore.js.map +1 -1
  61. package/lib/cjs/Relationship.js.map +1 -1
  62. package/lib/cjs/RpcBackend.js.map +1 -1
  63. package/lib/cjs/SQLiteDb.js.map +1 -1
  64. package/lib/cjs/Schema.js.map +1 -1
  65. package/lib/cjs/SchemaSync.js.map +1 -1
  66. package/lib/cjs/SchemaUtils.js.map +1 -1
  67. package/lib/cjs/SheetIndex.js.map +1 -1
  68. package/lib/cjs/SqliteChangesetReader.js.map +1 -1
  69. package/lib/cjs/SqliteStatement.js.map +1 -1
  70. package/lib/cjs/StashManager.js.map +1 -1
  71. package/lib/cjs/Texture.js.map +1 -1
  72. package/lib/cjs/TileStorage.js.map +1 -1
  73. package/lib/cjs/TxnManager.js.map +1 -1
  74. package/lib/cjs/ViewDefinition.js.map +1 -1
  75. package/lib/cjs/ViewStateHydrator.js.map +1 -1
  76. package/lib/cjs/ViewStore.js.map +1 -1
  77. package/lib/cjs/annotations/ElementDrivesTextAnnotation.d.ts +14 -0
  78. package/lib/cjs/annotations/ElementDrivesTextAnnotation.d.ts.map +1 -1
  79. package/lib/cjs/annotations/ElementDrivesTextAnnotation.js +32 -19
  80. package/lib/cjs/annotations/ElementDrivesTextAnnotation.js.map +1 -1
  81. package/lib/cjs/annotations/FrameGeometry.js.map +1 -1
  82. package/lib/cjs/annotations/LeaderGeometry.js.map +1 -1
  83. package/lib/cjs/annotations/TextAnnotationElement.js.map +1 -1
  84. package/lib/cjs/annotations/TextAnnotationGeometry.js.map +1 -1
  85. package/lib/cjs/annotations/TextBlockGeometry.js.map +1 -1
  86. package/lib/cjs/annotations/TextBlockLayout.d.ts.map +1 -1
  87. package/lib/cjs/annotations/TextBlockLayout.js +2 -1
  88. package/lib/cjs/annotations/TextBlockLayout.js.map +1 -1
  89. package/lib/cjs/assets/IModelChange.02.00.00.ecschema.xml +90 -90
  90. package/lib/cjs/assets/Settings/Schemas/Base.Schema.json +32 -32
  91. package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +27 -27
  92. package/lib/cjs/assets/Settings/Schemas/Workspace.Schema.json +94 -94
  93. package/lib/cjs/assets/Settings/backend.setting.json5 +21 -21
  94. package/lib/cjs/core-backend.js.map +1 -1
  95. package/lib/cjs/domains/FunctionalElements.js.map +1 -1
  96. package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
  97. package/lib/cjs/domains/GenericElements.js.map +1 -1
  98. package/lib/cjs/domains/GenericSchema.js.map +1 -1
  99. package/lib/cjs/internal/ChangesetConflictArgs.js.map +1 -1
  100. package/lib/cjs/internal/ChannelAdmin.js.map +1 -1
  101. package/lib/cjs/internal/ElementLRUCache.js.map +1 -1
  102. package/lib/cjs/internal/FontFileImpl.js.map +1 -1
  103. package/lib/cjs/internal/HubMock.js.map +1 -1
  104. package/lib/cjs/internal/IModelDbFontsImpl.js.map +1 -1
  105. package/lib/cjs/internal/NativePlatform.js.map +1 -1
  106. package/lib/cjs/internal/NoLocks.js.map +1 -1
  107. package/lib/cjs/internal/ServerBasedLocks.js.map +1 -1
  108. package/lib/cjs/internal/Symbols.js.map +1 -1
  109. package/lib/cjs/internal/annotations/fields.d.ts +3 -2
  110. package/lib/cjs/internal/annotations/fields.d.ts.map +1 -1
  111. package/lib/cjs/internal/annotations/fields.js +12 -5
  112. package/lib/cjs/internal/annotations/fields.js.map +1 -1
  113. package/lib/cjs/internal/cross-package.js.map +1 -1
  114. package/lib/cjs/internal/workspace/SettingsImpl.js.map +1 -1
  115. package/lib/cjs/internal/workspace/SettingsSchemasImpl.js.map +1 -1
  116. package/lib/cjs/internal/workspace/WorkspaceImpl.js.map +1 -1
  117. package/lib/cjs/internal/workspace/WorkspaceSqliteDb.js.map +1 -1
  118. package/lib/cjs/rpc/multipart.js.map +1 -1
  119. package/lib/cjs/rpc/tracing.js.map +1 -1
  120. package/lib/cjs/rpc/web/logging.js.map +1 -1
  121. package/lib/cjs/rpc/web/request.js.map +1 -1
  122. package/lib/cjs/rpc/web/response.js.map +1 -1
  123. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js.map +1 -1
  124. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  125. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
  126. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  127. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
  128. package/lib/cjs/workspace/Settings.js.map +1 -1
  129. package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
  130. package/lib/cjs/workspace/Workspace.js.map +1 -1
  131. package/lib/cjs/workspace/WorkspaceEditor.js.map +1 -1
  132. package/lib/esm/BackendHubAccess.js.map +1 -1
  133. package/lib/esm/BackendLoggerCategory.js.map +1 -1
  134. package/lib/esm/BisCoreSchema.js.map +1 -1
  135. package/lib/esm/BlobContainerService.js.map +1 -1
  136. package/lib/esm/BriefcaseManager.js.map +1 -1
  137. package/lib/esm/CatalogDb.js.map +1 -1
  138. package/lib/esm/Category.js.map +1 -1
  139. package/lib/esm/ChangeSummaryManager.js +2 -2
  140. package/lib/esm/ChangeSummaryManager.js.map +1 -1
  141. package/lib/esm/ChangedElementsDb.js.map +1 -1
  142. package/lib/esm/ChangesetECAdaptor.js +248 -248
  143. package/lib/esm/ChangesetECAdaptor.js.map +1 -1
  144. package/lib/esm/ChannelControl.js.map +1 -1
  145. package/lib/esm/CheckpointManager.js.map +1 -1
  146. package/lib/esm/ClassRegistry.js +5 -5
  147. package/lib/esm/ClassRegistry.js.map +1 -1
  148. package/lib/esm/CloudSqlite.js.map +1 -1
  149. package/lib/esm/CodeService.js.map +1 -1
  150. package/lib/esm/CodeSpecs.js.map +1 -1
  151. package/lib/esm/ConcurrentQuery.js.map +1 -1
  152. package/lib/esm/CustomViewState3dCreator.js.map +1 -1
  153. package/lib/esm/DevTools.js.map +1 -1
  154. package/lib/esm/DisplayStyle.js.map +1 -1
  155. package/lib/esm/ECDb.js.map +1 -1
  156. package/lib/esm/ECSchemaXmlContext.js.map +1 -1
  157. package/lib/esm/ECSqlStatement.js.map +1 -1
  158. package/lib/esm/Element.js.map +1 -1
  159. package/lib/esm/ElementAspect.js.map +1 -1
  160. package/lib/esm/ElementGraphics.js.map +1 -1
  161. package/lib/esm/ElementTreeWalker.js.map +1 -1
  162. package/lib/esm/Entity.js.map +1 -1
  163. package/lib/esm/EntityReferences.js.map +1 -1
  164. package/lib/esm/ExportGraphics.js.map +1 -1
  165. package/lib/esm/ExternalSource.js.map +1 -1
  166. package/lib/esm/FontFile.js.map +1 -1
  167. package/lib/esm/GeoCoordConfig.js.map +1 -1
  168. package/lib/esm/GeographicCRSServices.js.map +1 -1
  169. package/lib/esm/GeometrySummary.js +47 -47
  170. package/lib/esm/GeometrySummary.js.map +1 -1
  171. package/lib/esm/IModelDb.js +8 -8
  172. package/lib/esm/IModelDb.js.map +1 -1
  173. package/lib/esm/IModelDbFonts.js.map +1 -1
  174. package/lib/esm/IModelElementCloneContext.js.map +1 -1
  175. package/lib/esm/IModelHost.js.map +1 -1
  176. package/lib/esm/IModelIncrementalSchemaLocater.js.map +1 -1
  177. package/lib/esm/IModelJsFs.js.map +1 -1
  178. package/lib/esm/ImageSourceConversion.js.map +1 -1
  179. package/lib/esm/IpcHost.js.map +1 -1
  180. package/lib/esm/LineStyle.js.map +1 -1
  181. package/lib/esm/LocalHub.js +1 -1
  182. package/lib/esm/LocalHub.js.map +1 -1
  183. package/lib/esm/LocalhostIpcHost.js.map +1 -1
  184. package/lib/esm/LockControl.js.map +1 -1
  185. package/lib/esm/Material.js.map +1 -1
  186. package/lib/esm/Model.js.map +1 -1
  187. package/lib/esm/NativeAppStorage.js.map +1 -1
  188. package/lib/esm/NativeHost.js.map +1 -1
  189. package/lib/esm/NavigationRelationship.js.map +1 -1
  190. package/lib/esm/PromiseMemoizer.js.map +1 -1
  191. package/lib/esm/PropertyStore.js.map +1 -1
  192. package/lib/esm/Relationship.js.map +1 -1
  193. package/lib/esm/RpcBackend.js.map +1 -1
  194. package/lib/esm/SQLiteDb.js.map +1 -1
  195. package/lib/esm/Schema.js.map +1 -1
  196. package/lib/esm/SchemaSync.js.map +1 -1
  197. package/lib/esm/SchemaUtils.js.map +1 -1
  198. package/lib/esm/SheetIndex.js.map +1 -1
  199. package/lib/esm/SqliteChangesetReader.js.map +1 -1
  200. package/lib/esm/SqliteStatement.js.map +1 -1
  201. package/lib/esm/StashManager.js.map +1 -1
  202. package/lib/esm/Texture.js.map +1 -1
  203. package/lib/esm/TileStorage.js.map +1 -1
  204. package/lib/esm/TxnManager.js.map +1 -1
  205. package/lib/esm/ViewDefinition.js.map +1 -1
  206. package/lib/esm/ViewStateHydrator.js.map +1 -1
  207. package/lib/esm/ViewStore.js.map +1 -1
  208. package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts +14 -0
  209. package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts.map +1 -1
  210. package/lib/esm/annotations/ElementDrivesTextAnnotation.js +33 -20
  211. package/lib/esm/annotations/ElementDrivesTextAnnotation.js.map +1 -1
  212. package/lib/esm/annotations/FrameGeometry.js.map +1 -1
  213. package/lib/esm/annotations/LeaderGeometry.js.map +1 -1
  214. package/lib/esm/annotations/TextAnnotationElement.js.map +1 -1
  215. package/lib/esm/annotations/TextAnnotationGeometry.js.map +1 -1
  216. package/lib/esm/annotations/TextBlockGeometry.js.map +1 -1
  217. package/lib/esm/annotations/TextBlockLayout.d.ts.map +1 -1
  218. package/lib/esm/annotations/TextBlockLayout.js +2 -1
  219. package/lib/esm/annotations/TextBlockLayout.js.map +1 -1
  220. package/lib/esm/core-backend.js.map +1 -1
  221. package/lib/esm/domains/FunctionalElements.js.map +1 -1
  222. package/lib/esm/domains/FunctionalSchema.js.map +1 -1
  223. package/lib/esm/domains/GenericElements.js.map +1 -1
  224. package/lib/esm/domains/GenericSchema.js.map +1 -1
  225. package/lib/esm/internal/ChangesetConflictArgs.js.map +1 -1
  226. package/lib/esm/internal/ChannelAdmin.js.map +1 -1
  227. package/lib/esm/internal/ElementLRUCache.js.map +1 -1
  228. package/lib/esm/internal/FontFileImpl.js.map +1 -1
  229. package/lib/esm/internal/HubMock.js.map +1 -1
  230. package/lib/esm/internal/IModelDbFontsImpl.js.map +1 -1
  231. package/lib/esm/internal/NativePlatform.js.map +1 -1
  232. package/lib/esm/internal/NoLocks.js.map +1 -1
  233. package/lib/esm/internal/ServerBasedLocks.js.map +1 -1
  234. package/lib/esm/internal/Symbols.js.map +1 -1
  235. package/lib/esm/internal/annotations/fields.d.ts +3 -2
  236. package/lib/esm/internal/annotations/fields.d.ts.map +1 -1
  237. package/lib/esm/internal/annotations/fields.js +11 -5
  238. package/lib/esm/internal/annotations/fields.js.map +1 -1
  239. package/lib/esm/internal/cross-package.js.map +1 -1
  240. package/lib/esm/internal/workspace/SettingsImpl.js.map +1 -1
  241. package/lib/esm/internal/workspace/SettingsSchemasImpl.js.map +1 -1
  242. package/lib/esm/internal/workspace/WorkspaceImpl.js.map +1 -1
  243. package/lib/esm/internal/workspace/WorkspaceSqliteDb.js.map +1 -1
  244. package/lib/esm/rpc/multipart.js.map +1 -1
  245. package/lib/esm/rpc/tracing.js.map +1 -1
  246. package/lib/esm/rpc/web/logging.js.map +1 -1
  247. package/lib/esm/rpc/web/request.js.map +1 -1
  248. package/lib/esm/rpc/web/response.js.map +1 -1
  249. package/lib/esm/rpc-impl/DevToolsRpcImpl.js.map +1 -1
  250. package/lib/esm/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  251. package/lib/esm/rpc-impl/IModelTileRpcImpl.js.map +1 -1
  252. package/lib/esm/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  253. package/lib/esm/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
  254. package/lib/esm/test/AdvancedEqual.js.map +1 -1
  255. package/lib/esm/test/AnnotationTestUtils.js.map +1 -1
  256. package/lib/esm/test/AttachDb.test.js +11 -11
  257. package/lib/esm/test/AttachDb.test.js.map +1 -1
  258. package/lib/esm/test/ElementDrivesElement.test.js +23 -23
  259. package/lib/esm/test/ElementDrivesElement.test.js.map +1 -1
  260. package/lib/esm/test/ElementLRUCache.test.js.map +1 -1
  261. package/lib/esm/test/GeometryTestUtil.js.map +1 -1
  262. package/lib/esm/test/IModelHost.test.js.map +1 -1
  263. package/lib/esm/test/IModelTestUtils.js.map +1 -1
  264. package/lib/esm/test/ImageSourceConversion.test.js.map +1 -1
  265. package/lib/esm/test/IpcHost.test.js.map +1 -1
  266. package/lib/esm/test/KnownTestLocations.js.map +1 -1
  267. package/lib/esm/test/PrintElementTree.js.map +1 -1
  268. package/lib/esm/test/PropertyDb.test.js.map +1 -1
  269. package/lib/esm/test/RevisionUtility.js.map +1 -1
  270. package/lib/esm/test/SchemaUtils.test.js +25 -25
  271. package/lib/esm/test/SchemaUtils.test.js.map +1 -1
  272. package/lib/esm/test/SequentialLogMatcher.js.map +1 -1
  273. package/lib/esm/test/TestChangeSetUtility.js.map +1 -1
  274. package/lib/esm/test/TestUtils.js.map +1 -1
  275. package/lib/esm/test/annotations/Fields.test.js +53 -53
  276. package/lib/esm/test/annotations/Fields.test.js.map +1 -1
  277. package/lib/esm/test/annotations/FrameGeometry.test.js.map +1 -1
  278. package/lib/esm/test/annotations/LeaderGeometry.test.js.map +1 -1
  279. package/lib/esm/test/annotations/TextAnnotation.test.js +3 -1
  280. package/lib/esm/test/annotations/TextAnnotation.test.js.map +1 -1
  281. package/lib/esm/test/annotations/TextBlock.test.js.map +1 -1
  282. package/lib/esm/test/assets/IncrementalSchemaLocater/configs/old.config.js.map +1 -1
  283. package/lib/esm/test/assets/IncrementalSchemaLocater/configs/simple.config.js.map +1 -1
  284. package/lib/esm/test/categories/Category.test.js.map +1 -1
  285. package/lib/esm/test/codespec/CodeSpec.test.js.map +1 -1
  286. package/lib/esm/test/ecdb/CTE.test.js +88 -88
  287. package/lib/esm/test/ecdb/CTE.test.js.map +1 -1
  288. package/lib/esm/test/ecdb/ConcurrentQuery.test.js +15 -15
  289. package/lib/esm/test/ecdb/ConcurrentQuery.test.js.map +1 -1
  290. package/lib/esm/test/ecdb/ConcurrentQueryLoad.test.js +15 -15
  291. package/lib/esm/test/ecdb/ConcurrentQueryLoad.test.js.map +1 -1
  292. package/lib/esm/test/ecdb/ECDb.test.js +72 -72
  293. package/lib/esm/test/ecdb/ECDb.test.js.map +1 -1
  294. package/lib/esm/test/ecdb/ECDbTestHelper.js.map +1 -1
  295. package/lib/esm/test/ecdb/ECSchemaXmlContext.test.js.map +1 -1
  296. package/lib/esm/test/ecdb/ECSqlAst.test.js +65 -65
  297. package/lib/esm/test/ecdb/ECSqlAst.test.js.map +1 -1
  298. package/lib/esm/test/ecdb/ECSqlQuery.test.js.map +1 -1
  299. package/lib/esm/test/ecdb/ECSqlReader.test.js +16 -16
  300. package/lib/esm/test/ecdb/ECSqlReader.test.js.map +1 -1
  301. package/lib/esm/test/ecdb/ECSqlStatement.test.js +332 -332
  302. package/lib/esm/test/ecdb/ECSqlStatement.test.js.map +1 -1
  303. package/lib/esm/test/ecdb/SqliteStatement.test.js.map +1 -1
  304. package/lib/esm/test/ecsql/dataset/ECSqlDatasets.js.map +1 -1
  305. package/lib/esm/test/ecsql/src/ECSqlTestGenerator.js +21 -21
  306. package/lib/esm/test/ecsql/src/ECSqlTestGenerator.js.map +1 -1
  307. package/lib/esm/test/ecsql/src/ECSqlTestParser.js.map +1 -1
  308. package/lib/esm/test/ecsql/src/ECSqlTestRunner.test.js.map +1 -1
  309. package/lib/esm/test/element/DeleteDefinitionElements.test.js.map +1 -1
  310. package/lib/esm/test/element/ElementAspect.test.js +22 -22
  311. package/lib/esm/test/element/ElementAspect.test.js.map +1 -1
  312. package/lib/esm/test/element/ElementDependencyGraph.test.js.map +1 -1
  313. package/lib/esm/test/element/ElementRoundTrip.test.js +139 -139
  314. package/lib/esm/test/element/ElementRoundTrip.test.js.map +1 -1
  315. package/lib/esm/test/element/ExcludedElements.test.js.map +1 -1
  316. package/lib/esm/test/element/ExternalSource.test.js.map +1 -1
  317. package/lib/esm/test/element/NullStructArray.test.js +13 -13
  318. package/lib/esm/test/element/NullStructArray.test.js.map +1 -1
  319. package/lib/esm/test/element/ProjectInformationRecord.test.js.map +1 -1
  320. package/lib/esm/test/element/SheetInformationAspect.test.js.map +1 -1
  321. package/lib/esm/test/element/UrlLink.test.js.map +1 -1
  322. package/lib/esm/test/font/FontFile.test.js.map +1 -1
  323. package/lib/esm/test/font/IModelDbFonts.test.js.map +1 -1
  324. package/lib/esm/test/hubaccess/ApplyChangeset.test.js +32 -32
  325. package/lib/esm/test/hubaccess/ApplyChangeset.test.js.map +1 -1
  326. package/lib/esm/test/hubaccess/BriefcaseManager.test.js.map +1 -1
  327. package/lib/esm/test/hubaccess/CheckpointManager.test.js.map +1 -1
  328. package/lib/esm/test/hubaccess/Rebase.test.js +97 -41
  329. package/lib/esm/test/hubaccess/Rebase.test.js.map +1 -1
  330. package/lib/esm/test/imageData.js.map +1 -1
  331. package/lib/esm/test/imodel/Code.test.js.map +1 -1
  332. package/lib/esm/test/imodel/ElementTreeWalker.test.js.map +1 -1
  333. package/lib/esm/test/imodel/GetTextureImage.test.js.map +1 -1
  334. package/lib/esm/test/imodel/IModel.test.js +44 -44
  335. package/lib/esm/test/imodel/IModel.test.js.map +1 -1
  336. package/lib/esm/test/imodel/ProjectExtents.test.js.map +1 -1
  337. package/lib/esm/test/imodel/SchemaXmlImport.test.js.map +1 -1
  338. package/lib/esm/test/incrementalSchemaLocater/ECSqlQueries.test.js.map +1 -1
  339. package/lib/esm/test/incrementalSchemaLocater/IncrementalLoading.test.js.map +1 -1
  340. package/lib/esm/test/incrementalSchemaLocater/utils/IModelSchemaLocater.js.map +1 -1
  341. package/lib/esm/test/incrementalSchemaLocater/utils/IncrementalTestHelper.js.map +1 -1
  342. package/lib/esm/test/incrementalSchemaLocater/utils/TestSqlSchemaLocater.js.map +1 -1
  343. package/lib/esm/test/index.js.map +1 -1
  344. package/lib/esm/test/misc/DevTools.test.js.map +1 -1
  345. package/lib/esm/test/misc/EntitySubClasses.test.js.map +1 -1
  346. package/lib/esm/test/misc/GeoServices.test.js.map +1 -1
  347. package/lib/esm/test/misc/PromiseMemoizer.test.js.map +1 -1
  348. package/lib/esm/test/native/DgnDbWorker.test.js.map +1 -1
  349. package/lib/esm/test/rpc/response.test.js.map +1 -1
  350. package/lib/esm/test/schema/ClassRegistry.test.js +99 -99
  351. package/lib/esm/test/schema/ClassRegistry.test.js.map +1 -1
  352. package/lib/esm/test/schema/FunctionalDomain.test.js.map +1 -1
  353. package/lib/esm/test/schema/GenericDomain.test.js.map +1 -1
  354. package/lib/esm/test/schema/IModelSchemaContext.test.js.map +1 -1
  355. package/lib/esm/test/sheetindex/SheetIndex.test.js.map +1 -1
  356. package/lib/esm/test/standalone/ChangeMerge.test.js.map +1 -1
  357. package/lib/esm/test/standalone/ChangesetReader.test.js +124 -124
  358. package/lib/esm/test/standalone/ChangesetReader.test.js.map +1 -1
  359. package/lib/esm/test/standalone/CustomViewState3dCreator.test.js.map +1 -1
  360. package/lib/esm/test/standalone/DisplayStyle.test.js.map +1 -1
  361. package/lib/esm/test/standalone/Drawing.test.js.map +1 -1
  362. package/lib/esm/test/standalone/ElementGraphics.test.js.map +1 -1
  363. package/lib/esm/test/standalone/ElementMesh.test.js.map +1 -1
  364. package/lib/esm/test/standalone/ExportGraphics.test.js +14 -14
  365. package/lib/esm/test/standalone/ExportGraphics.test.js.map +1 -1
  366. package/lib/esm/test/standalone/GeometryChangeEvents.test.js.map +1 -1
  367. package/lib/esm/test/standalone/GeometryStream.test.js.map +1 -1
  368. package/lib/esm/test/standalone/HubMock.test.js.map +1 -1
  369. package/lib/esm/test/standalone/IModelLimits.test.js.map +1 -1
  370. package/lib/esm/test/standalone/IModelWrite.test.js +27 -27
  371. package/lib/esm/test/standalone/IModelWrite.test.js.map +1 -1
  372. package/lib/esm/test/standalone/InlineGeometryPartReferences.test.js.map +1 -1
  373. package/lib/esm/test/standalone/MergeConflict.test.js.map +1 -1
  374. package/lib/esm/test/standalone/NativeAppStorage.test.js.map +1 -1
  375. package/lib/esm/test/standalone/RenderMaterialElement.test.js.map +1 -1
  376. package/lib/esm/test/standalone/RenderTimeline.test.js.map +1 -1
  377. package/lib/esm/test/standalone/SQLiteDb.test.js.map +1 -1
  378. package/lib/esm/test/standalone/SchemaUtils.test.js.map +1 -1
  379. package/lib/esm/test/standalone/SectionDrawing.test.js.map +1 -1
  380. package/lib/esm/test/standalone/ServerBasedLocks.test.js.map +1 -1
  381. package/lib/esm/test/standalone/Setting.test.js.map +1 -1
  382. package/lib/esm/test/standalone/Settings.test.js.map +1 -1
  383. package/lib/esm/test/standalone/SettingsSchemas.test.js.map +1 -1
  384. package/lib/esm/test/standalone/SnapshotDb.test.js.map +1 -1
  385. package/lib/esm/test/standalone/Texture.test.js.map +1 -1
  386. package/lib/esm/test/standalone/TileCache.test.js.map +1 -1
  387. package/lib/esm/test/standalone/TileTree.test.js.map +1 -1
  388. package/lib/esm/test/standalone/TxnManager.test.js.map +1 -1
  389. package/lib/esm/test/standalone/ViewDefinition.test.js.map +1 -1
  390. package/lib/esm/test/standalone/ViewStoreDb.test.js.map +1 -1
  391. package/lib/esm/test/standalone/Workspace.test.js.map +1 -1
  392. package/lib/esm/workspace/Settings.js.map +1 -1
  393. package/lib/esm/workspace/SettingsSchemas.js.map +1 -1
  394. package/lib/esm/workspace/Workspace.js.map +1 -1
  395. package/lib/esm/workspace/WorkspaceEditor.js.map +1 -1
  396. package/package.json +13 -13
@@ -1 +1 @@
1
- {"version":3,"file":"ElementDrivesTextAnnotation.d.ts","sourceRoot":"","sources":["../../../src/annotations/ElementDrivesTextAnnotation.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,SAAS,EAA8B,MAAM,oBAAoB,CAAC;AAC9G,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,OAAO,EAAkB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAEzE;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,sBAAsB;IACtB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,gIAAgI;IAChI,QAAQ,CAAC,EAAE,EAAE,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D;;;OAGG;WACW,uBAAuB,CAAC,mBAAmB,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,GAAG,IAAI;IAqE9F;;;OAGG;WACW,cAAc,CAAC,IAAI,EAAE,kBAAkB,GAAG,MAAM;IAI9D;;;OAGG;WACW,WAAW,CAAC,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,yBAAyB,GAAG,IAAI;CAwB5F;AAED;;GAEG;AACH,qBAAa,oCAAqC,SAAQ,cAAc;IACtE,OAAc,aAAa,SAAkD;gBAC1D,qBAAqB,EAAE,UAAU,EAAE,YAAY,GAAE,MAA2D;CAGhI"}
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import { RelatedElement, traverseTextBlockComponent } from "@itwin/core-common";
9
9
  import { ElementDrivesElement } from "../Relationship";
10
- import { updateElementFields } from "../internal/annotations/fields";
10
+ import { createUpdateContext, updateAllFields, updateElementFields, updateFields } from "../internal/annotations/fields";
11
11
  import { DbResult, Id64 } from "@itwin/core-bentley";
12
12
  import { ECVersion } from "@itwin/ecschema-metadata";
13
13
  // ElementDrivesTextAnnotation was introduced in this version of BisCore - iModels with earlier versions cannot support field dependencies.
@@ -41,17 +41,13 @@ export class ElementDrivesTextAnnotation extends ElementDrivesElement {
41
41
  * update when the source element changes.
42
42
  */
43
43
  static isSupportedForIModel(iModel) {
44
- const bisCoreVersion = iModel.querySchemaVersionNumbers("BisCore");
45
- return undefined !== bisCoreVersion && bisCoreVersion.compare(minBisCoreVersion) >= 0;
44
+ return iModel.meetsMinimumSchemaVersion("BisCore", minBisCoreVersion);
46
45
  }
47
46
  /** Examines all of the [FieldRun]($common)s within the specified [[ITextAnnotation]] and ensures that the appropriate
48
47
  * `ElementDrivesTextAnnotation` relationships exist between the fields' source elements and this target element.
49
48
  * It also deletes any stale relationships left over from fields that were deleted or whose source elements changed.
50
49
  */
51
50
  static updateFieldDependencies(annotationElementId, iModel) {
52
- if (!ElementDrivesTextAnnotation.isSupportedForIModel(iModel)) {
53
- return;
54
- }
55
51
  const annotationElement = iModel.elements.tryGetElement(annotationElementId);
56
52
  if (!annotationElement || !isITextAnnotation(annotationElement)) {
57
53
  return;
@@ -69,27 +65,37 @@ export class ElementDrivesTextAnnotation extends ElementDrivesElement {
69
65
  }
70
66
  const sourceToRelationship = new Map();
71
67
  const blocks = annotationElement.getTextBlocks();
68
+ let haveFields = false;
72
69
  for (const block of blocks) {
73
70
  for (const { child } of traverseTextBlockComponent(block.textBlock)) {
74
- if (child.type === "field" && isValidSourceId(child.propertyHost.elementId)) {
75
- sourceToRelationship.set(child.propertyHost.elementId, null);
71
+ if (child.type === "field") {
72
+ haveFields = true;
73
+ if (isValidSourceId(child.propertyHost.elementId)) {
74
+ sourceToRelationship.set(child.propertyHost.elementId, null);
75
+ }
76
76
  }
77
77
  }
78
78
  }
79
+ if (haveFields) {
80
+ iModel.requireMinimumSchemaVersion("BisCore", minBisCoreVersion, "Text fields");
81
+ updateAllFields(annotationElementId, iModel);
82
+ }
79
83
  const staleRelationships = new Set();
80
- // eslint-disable-next-line @typescript-eslint/no-deprecated
81
- annotationElement.iModel.withPreparedStatement(`SELECT ECInstanceId, SourceECInstanceId FROM BisCore.ElementDrivesTextAnnotation WHERE TargetECInstanceId=${annotationElement.id}`, (stmt) => {
82
- while (DbResult.BE_SQLITE_ROW === stmt.step()) {
83
- const relationshipId = stmt.getValue(0).getId();
84
- const sourceId = stmt.getValue(1).getId();
85
- if (sourceToRelationship.has(sourceId)) {
86
- sourceToRelationship.set(sourceId, relationshipId);
87
- }
88
- else {
89
- staleRelationships.add(relationshipId);
84
+ if (this.isSupportedForIModel(iModel)) {
85
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
86
+ annotationElement.iModel.withPreparedStatement(`SELECT ECInstanceId, SourceECInstanceId FROM BisCore.ElementDrivesTextAnnotation WHERE TargetECInstanceId=${annotationElement.id}`, (stmt) => {
87
+ while (DbResult.BE_SQLITE_ROW === stmt.step()) {
88
+ const relationshipId = stmt.getValue(0).getId();
89
+ const sourceId = stmt.getValue(1).getId();
90
+ if (sourceToRelationship.has(sourceId)) {
91
+ sourceToRelationship.set(sourceId, relationshipId);
92
+ }
93
+ else {
94
+ staleRelationships.add(relationshipId);
95
+ }
90
96
  }
91
- }
92
- });
97
+ });
98
+ }
93
99
  for (const [sourceId, relationshipId] of sourceToRelationship) {
94
100
  if (relationshipId === null) {
95
101
  ElementDrivesTextAnnotation.create(annotationElement.iModel, sourceId, annotationElement.id).insert();
@@ -100,6 +106,13 @@ export class ElementDrivesTextAnnotation extends ElementDrivesElement {
100
106
  annotationElement.iModel.relationships.deleteInstances(staleRelationshipProps);
101
107
  }
102
108
  }
109
+ /** Recompute the display strings of all [FieldRun]($common)s in a [TextBlock]($common).
110
+ * @returns the number of fields whose display strings were modified.
111
+ * @throws Error if evaluation of any field fails.
112
+ */
113
+ static evaluateFields(args) {
114
+ return updateFields(args.block, createUpdateContext(undefined, args.iModel, false));
115
+ }
103
116
  /** When copying an [[ITextAnnotation]] from one iModel into another, remaps the element Ids in any [FieldPropertyHost]($common) within the cloned element
104
117
  * so that they refer to elements in the `context`'s target iModel, and sets any Ids that cannot be remapped to [Id64.invalid]($bentley).
105
118
  * Implementations of `ITextAnnotation` should invoke this function from their implementations of [[Element.onCloned]].
@@ -1 +1 @@
1
- {"version":3,"file":"ElementDrivesTextAnnotation.js","sourceRoot":"","sources":["../../../src/annotations/ElementDrivesTextAnnotation.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAgC,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAC9G,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAGvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAc,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAgBrD,2IAA2I;AA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AK,CAAC,aAAa,EAAE,EAAE,CAAC;YAC1C,IAAI,UAAU,GAAG,KAAK,CAAC;YACvB,KAAK,MAAM,EAAE,KAAK,EAAE,IAAI,0BAA0B,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;gBACpE,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;oBAC3B,KAAK,CAAC,YAAY,CAAC,SAAS,GAAG,OAAO,CAAC,mBAAmB,CAAC,KAAK,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;oBACzF,UAAU,GAAG,IAAI,CAAC;gBACpB,CAAC;YACH,CAAC;YAED,IAAI,UAAU,EAAE,CAAC;gBACf,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC;QAED,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7B,KAAK,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,oCAAqC,SAAQ,cAAc;IAC/D,MAAM,CAAC,aAAa,GAAG,8CAA8C,CAAC;IAC7E,YAAmB,qBAAiC,EAAE,eAAuB,oCAAoC,CAAC,aAAa;QAC7H,KAAK,CAAC,EAAE,EAAE,EAAE,qBAAqB,EAAE,YAAY,EAAE,CAAC,CAAC;IACrD,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Elements\n */\n\nimport { RelatedElement, RelationshipProps, TextBlock, traverseTextBlockComponent } from \"@itwin/core-common\";\nimport { ElementDrivesElement } from \"../Relationship\";\nimport { IModelDb } from \"../IModelDb\";\nimport { Element } from \"../Element\";\nimport { updateElementFields } from \"../internal/annotations/fields\";\nimport { DbResult, Id64, Id64String } from \"@itwin/core-bentley\";\nimport { ECVersion } from \"@itwin/ecschema-metadata\";\nimport { IModelElementCloneContext } from \"../IModelElementCloneContext\";\n\n/** Describes one of potentially many [TextBlock]($common)s hosted by an [[ITextAnnotation]].\n * For example, a [[TextAnnotation2d]] hosts only a single text block, but an element representing a table may\n * host one text block for each cell in the table, in which case it might use the combination of row and column\n * as the [[id]] for each text block.\n * @beta\n */\nexport interface TextBlockAndId {\n /** The text block. */\n readonly textBlock: TextBlock;\n /** An opaque identifier that allows the [[ITextAnnotation]] to discern which of its hosted text blocks is being referred to. */\n readonly id: unknown;\n}\n\n// ElementDrivesTextAnnotation was introduced in this version of BisCore - iModels with earlier versions cannot support field dependencies.\nconst minBisCoreVersion = new ECVersion(1, 0, 22);\n\n/** Interface implemented by [[GeometricElement]] subclasses whose schemas declare them to implement the mix-in `BisCore:ITextAnnotation`.\n * Such elements may host any number of [TextBlock]($common)s. `ITextAnnotation` provides a uniform way to interact with text regardless of\n * the type of element to which it belongs.\n * @beta\n */\nexport interface ITextAnnotation {\n /** The default [[AnnotationTextStyle]] used by the text annotation. */\n defaultTextStyle?: TextAnnotationUsesTextStyleByDefault;\n /** Obtain a collection of all of the [TextBlock]($common)s hosted by this element. */\n getTextBlocks(): Iterable<TextBlockAndId>;\n /** Update the element in-memory to replace the contents of the specified [TextBlock]($common)s. */\n updateTextBlocks(textBlocks: TextBlockAndId[]): void;\n}\n\n/** Returns `true` if the specified `element` implements [[ITextAnnotation]].\n * @beta\n */\nexport function isITextAnnotation(element: Element): element is ITextAnnotation & Element {\n return [\"getTextBlocks\", \"updateTextBlocks\"].every((x) => x in element && typeof (element as any)[x] === \"function\");\n}\n\n/** A relationship in which the source element hosts one or more properties that are displayed by a target [[ITextAnnotation]] element.\n * This relationship is used to automatically update the [FieldRun]($common)s contained in the target element when the source element is modified.\n * An [[ITextAnnotation]] element should invoke [[updateFieldDependencies]] from its [[Element.onInserted]] and [[Element.onUpdated]] functions to\n * establish or update the relationships required for the [FieldRun]($common)s it contains.\n * @note This relationship was introduced in version 01.00.22 of the BisCore schema. [FieldRun]($common)s created in iModels that have not been upgraded to\n * that version or newer will not automatically update. Use [[isSupportedForIModel]] to check.\n * @beta\n */\nexport class ElementDrivesTextAnnotation extends ElementDrivesElement {\n public static override get className(): string { return \"ElementDrivesTextAnnotation\"; }\n\n /** @internal */\n public static override onRootChanged(props: RelationshipProps, iModel: IModelDb): void {\n updateElementFields(props, iModel, false);\n }\n\n /** @internal */\n public static override onDeletedDependency(props: RelationshipProps, iModel: IModelDb): void {\n updateElementFields(props, iModel, true);\n }\n\n /** Returns true if `iModel` contains a version of the BisCore schema new enough to support this relationship.\n * If not, the schema should be updated before inserting any [FieldRun]($common)s, or those runs will not\n * update when the source element changes.\n */\n public static isSupportedForIModel(iModel: IModelDb): boolean {\n const bisCoreVersion = iModel.querySchemaVersionNumbers(\"BisCore\");\n return undefined !== bisCoreVersion && bisCoreVersion.compare(minBisCoreVersion) >= 0;\n }\n\n /** Examines all of the [FieldRun]($common)s within the specified [[ITextAnnotation]] and ensures that the appropriate\n * `ElementDrivesTextAnnotation` relationships exist between the fields' source elements and this target element.\n * It also deletes any stale relationships left over from fields that were deleted or whose source elements changed.\n */\n public static updateFieldDependencies(annotationElementId: Id64String, iModel: IModelDb): void {\n if (!ElementDrivesTextAnnotation.isSupportedForIModel(iModel)) {\n return;\n }\n\n const annotationElement = iModel.elements.tryGetElement<Element>(annotationElementId);\n if (!annotationElement || !isITextAnnotation(annotationElement)) {\n return;\n }\n\n // The native layer will allow us to insert relationships to invalid or non-existent source elements...errors will arise later. Prevent it.\n function isValidSourceId(id: Id64String): boolean {\n if (!Id64.isValidId64(id)) {\n return false;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return iModel.withPreparedStatement(\"SELECT CodeValue FROM BisCore.Element WHERE ECInstanceId=?\", (stmt) => {\n stmt.bindId(1, id);\n return DbResult.BE_SQLITE_ROW === stmt.step();\n });\n }\n\n const sourceToRelationship = new Map<Id64String, Id64String | null>();\n const blocks = annotationElement.getTextBlocks();\n\n for (const block of blocks) {\n for (const { child } of traverseTextBlockComponent(block.textBlock)) {\n if (child.type === \"field\" && isValidSourceId(child.propertyHost.elementId)) {\n sourceToRelationship.set(child.propertyHost.elementId, null);\n }\n }\n }\n\n const staleRelationships = new Set<Id64String>();\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n annotationElement.iModel.withPreparedStatement(`SELECT ECInstanceId, SourceECInstanceId FROM BisCore.ElementDrivesTextAnnotation WHERE TargetECInstanceId=${annotationElement.id}`, (stmt) => {\n while (DbResult.BE_SQLITE_ROW === stmt.step()) {\n const relationshipId = stmt.getValue(0).getId();\n const sourceId = stmt.getValue(1).getId();\n if (sourceToRelationship.has(sourceId)) {\n sourceToRelationship.set(sourceId, relationshipId);\n } else {\n staleRelationships.add(relationshipId);\n }\n }\n });\n\n for (const [sourceId, relationshipId] of sourceToRelationship) {\n if (relationshipId === null) {\n ElementDrivesTextAnnotation.create(annotationElement.iModel, sourceId, annotationElement.id).insert();\n }\n }\n\n if (staleRelationships.size > 0) {\n const staleRelationshipProps = Array.from(staleRelationships).map(relationshipId =>\n annotationElement.iModel.relationships.getInstanceProps(\"BisCore.ElementDrivesTextAnnotation\", relationshipId)\n );\n annotationElement.iModel.relationships.deleteInstances(staleRelationshipProps);\n }\n }\n\n /** When copying an [[ITextAnnotation]] from one iModel into another, remaps the element Ids in any [FieldPropertyHost]($common) within the cloned element\n * so that they refer to elements in the `context`'s target iModel, and sets any Ids that cannot be remapped to [Id64.invalid]($bentley).\n * Implementations of `ITextAnnotation` should invoke this function from their implementations of [[Element.onCloned]].\n */\n public static remapFields(clone: ITextAnnotation, context: IModelElementCloneContext): void {\n if (!context.isBetweenIModels) {\n return;\n }\n\n const updatedBlocks = [];\n for (const block of clone.getTextBlocks()) {\n let anyUpdated = false;\n for (const { child } of traverseTextBlockComponent(block.textBlock)) {\n if (child.type === \"field\") {\n child.propertyHost.elementId = context.findTargetElementId(child.propertyHost.elementId);\n anyUpdated = true;\n }\n }\n\n if (anyUpdated) {\n updatedBlocks.push(block);\n }\n }\n\n if (updatedBlocks.length > 0) {\n clone.updateTextBlocks(updatedBlocks);\n }\n }\n}\n\n/** Relationship indicating that the [[AnnotationTextStyle]] is being used as the default style for the [[ITextAnnotation]].\n * @beta\n */\nexport class TextAnnotationUsesTextStyleByDefault extends RelatedElement {\n public static classFullName = \"BisCore:TextAnnotationUsesTextStyleByDefault\";\n public constructor(annotationTextStyleId: Id64String, relClassName: string = TextAnnotationUsesTextStyleByDefault.classFullName) {\n super({ id: annotationTextStyleId, relClassName });\n }\n}\n"]}
1
+ {"version":3,"file":"ElementDrivesTextAnnotation.js","sourceRoot":"","sources":["../../../src/annotations/ElementDrivesTextAnnotation.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAgC,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAC9G,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAGvD,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACzH,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAc,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAgBrD,2IAA2I;AAC3I,MAAM,iBAAiB,GAAG,IAAI,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;AAgBlD;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAgB;IAChD,OAAO,CAAC,eAAe,EAAE,kBAAkB,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,OAAO,IAAI,OAAQ,OAAe,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC;AACvH,CAAC;AAYD;;;;;;;GAOG;AACH,MAAM,OAAO,2BAA4B,SAAQ,oBAA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1C,IAAI,UAAU,GAAG,KAAK,CAAC;YACvB,KAAK,MAAM,EAAE,KAAK,EAAE,IAAI,0BAA0B,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;gBACpE,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;oBAC3B,KAAK,CAAC,YAAY,CAAC,SAAS,GAAG,OAAO,CAAC,mBAAmB,CAAC,KAAK,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;oBACzF,UAAU,GAAG,IAAI,CAAC;gBACpB,CAAC;YACH,CAAC;YAED,IAAI,UAAU,EAAE,CAAC;gBACf,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC;QAED,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7B,KAAK,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,oCAAqC,SAAQ,cAAc;IAC/D,MAAM,CAAC,aAAa,GAAG,8CAA8C,CAAC;IAC7E,YAAmB,qBAAiC,EAAE,eAAuB,oCAAoC,CAAC,aAAa;QAC7H,KAAK,CAAC,EAAE,EAAE,EAAE,qBAAqB,EAAE,YAAY,EAAE,CAAC,CAAC;IACrD,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Elements\r\n */\r\n\r\nimport { RelatedElement, RelationshipProps, TextBlock, traverseTextBlockComponent } from \"@itwin/core-common\";\r\nimport { ElementDrivesElement } from \"../Relationship\";\r\nimport { IModelDb } from \"../IModelDb\";\r\nimport { Element } from \"../Element\";\r\nimport { createUpdateContext, updateAllFields, updateElementFields, updateFields } from \"../internal/annotations/fields\";\r\nimport { DbResult, Id64, Id64String } from \"@itwin/core-bentley\";\r\nimport { ECVersion } from \"@itwin/ecschema-metadata\";\r\nimport { IModelElementCloneContext } from \"../IModelElementCloneContext\";\r\n\r\n/** Describes one of potentially many [TextBlock]($common)s hosted by an [[ITextAnnotation]].\r\n * For example, a [[TextAnnotation2d]] hosts only a single text block, but an element representing a table may\r\n * host one text block for each cell in the table, in which case it might use the combination of row and column\r\n * as the [[id]] for each text block.\r\n * @beta\r\n */\r\nexport interface TextBlockAndId {\r\n /** The text block. */\r\n readonly textBlock: TextBlock;\r\n /** An opaque identifier that allows the [[ITextAnnotation]] to discern which of its hosted text blocks is being referred to. */\r\n readonly id: unknown;\r\n}\r\n\r\n// ElementDrivesTextAnnotation was introduced in this version of BisCore - iModels with earlier versions cannot support field dependencies.\r\nconst minBisCoreVersion = new ECVersion(1, 0, 22);\r\n\r\n/** Interface implemented by [[GeometricElement]] subclasses whose schemas declare them to implement the mix-in `BisCore:ITextAnnotation`.\r\n * Such elements may host any number of [TextBlock]($common)s. `ITextAnnotation` provides a uniform way to interact with text regardless of\r\n * the type of element to which it belongs.\r\n * @beta\r\n */\r\nexport interface ITextAnnotation {\r\n /** The default [[AnnotationTextStyle]] used by the text annotation. */\r\n defaultTextStyle?: TextAnnotationUsesTextStyleByDefault;\r\n /** Obtain a collection of all of the [TextBlock]($common)s hosted by this element. */\r\n getTextBlocks(): Iterable<TextBlockAndId>;\r\n /** Update the element in-memory to replace the contents of the specified [TextBlock]($common)s. */\r\n updateTextBlocks(textBlocks: TextBlockAndId[]): void;\r\n}\r\n\r\n/** Returns `true` if the specified `element` implements [[ITextAnnotation]].\r\n * @beta\r\n */\r\nexport function isITextAnnotation(element: Element): element is ITextAnnotation & Element {\r\n return [\"getTextBlocks\", \"updateTextBlocks\"].every((x) => x in element && typeof (element as any)[x] === \"function\");\r\n}\r\n\r\n/** Arguments supplied to [[ElementDrivesTextAnnotation.evaluateFields]].\r\n * @beta\r\n */\r\nexport interface EvaluateFieldsArgs {\r\n /** The text block whose fields are to be evaluated. */\r\n block: TextBlock;\r\n /** The iModel containing the elements supplying the display strings for the fields in [[block]]. */\r\n iModel: IModelDb;\r\n}\r\n\r\n/** A relationship in which the source element hosts one or more properties that are displayed by a target [[ITextAnnotation]] element.\r\n * This relationship is used to automatically update the [FieldRun]($common)s contained in the target element when the source element is modified.\r\n * An [[ITextAnnotation]] element should invoke [[updateFieldDependencies]] from its [[Element.onInserted]] and [[Element.onUpdated]] functions to\r\n * establish or update the relationships required for the [FieldRun]($common)s it contains.\r\n * @note This relationship was introduced in version 01.00.22 of the BisCore schema. [FieldRun]($common)s created in iModels that have not been upgraded to\r\n * that version or newer will not automatically update. Use [[isSupportedForIModel]] to check.\r\n * @beta\r\n */\r\nexport class ElementDrivesTextAnnotation extends ElementDrivesElement {\r\n public static override get className(): string { return \"ElementDrivesTextAnnotation\"; }\r\n\r\n /** @internal */\r\n public static override onRootChanged(props: RelationshipProps, iModel: IModelDb): void {\r\n updateElementFields(props, iModel, false);\r\n }\r\n\r\n /** @internal */\r\n public static override onDeletedDependency(props: RelationshipProps, iModel: IModelDb): void {\r\n updateElementFields(props, iModel, true);\r\n }\r\n\r\n /** Returns true if `iModel` contains a version of the BisCore schema new enough to support this relationship.\r\n * If not, the schema should be updated before inserting any [FieldRun]($common)s, or those runs will not\r\n * update when the source element changes.\r\n */\r\n public static isSupportedForIModel(iModel: IModelDb): boolean {\r\n return iModel.meetsMinimumSchemaVersion(\"BisCore\", minBisCoreVersion);\r\n }\r\n\r\n /** Examines all of the [FieldRun]($common)s within the specified [[ITextAnnotation]] and ensures that the appropriate\r\n * `ElementDrivesTextAnnotation` relationships exist between the fields' source elements and this target element.\r\n * It also deletes any stale relationships left over from fields that were deleted or whose source elements changed.\r\n */\r\n public static updateFieldDependencies(annotationElementId: Id64String, iModel: IModelDb): void {\r\n const annotationElement = iModel.elements.tryGetElement<Element>(annotationElementId);\r\n if (!annotationElement || !isITextAnnotation(annotationElement)) {\r\n return;\r\n }\r\n\r\n // The native layer will allow us to insert relationships to invalid or non-existent source elements...errors will arise later. Prevent it.\r\n function isValidSourceId(id: Id64String): boolean {\r\n if (!Id64.isValidId64(id)) {\r\n return false;\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n return iModel.withPreparedStatement(\"SELECT CodeValue FROM BisCore.Element WHERE ECInstanceId=?\", (stmt) => {\r\n stmt.bindId(1, id);\r\n return DbResult.BE_SQLITE_ROW === stmt.step();\r\n });\r\n }\r\n\r\n const sourceToRelationship = new Map<Id64String, Id64String | null>();\r\n const blocks = annotationElement.getTextBlocks();\r\n\r\n let haveFields = false;\r\n for (const block of blocks) {\r\n for (const { child } of traverseTextBlockComponent(block.textBlock)) {\r\n if (child.type === \"field\") {\r\n haveFields = true;\r\n if (isValidSourceId(child.propertyHost.elementId)) {\r\n sourceToRelationship.set(child.propertyHost.elementId, null);\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (haveFields) {\r\n iModel.requireMinimumSchemaVersion(\"BisCore\", minBisCoreVersion, \"Text fields\");\r\n updateAllFields(annotationElementId, iModel)\r\n }\r\n\r\n const staleRelationships = new Set<Id64String>();\r\n if (this.isSupportedForIModel(iModel)) {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n annotationElement.iModel.withPreparedStatement(`SELECT ECInstanceId, SourceECInstanceId FROM BisCore.ElementDrivesTextAnnotation WHERE TargetECInstanceId=${annotationElement.id}`, (stmt) => {\r\n while (DbResult.BE_SQLITE_ROW === stmt.step()) {\r\n const relationshipId = stmt.getValue(0).getId();\r\n const sourceId = stmt.getValue(1).getId();\r\n if (sourceToRelationship.has(sourceId)) {\r\n sourceToRelationship.set(sourceId, relationshipId);\r\n } else {\r\n staleRelationships.add(relationshipId);\r\n }\r\n }\r\n });\r\n }\r\n\r\n for (const [sourceId, relationshipId] of sourceToRelationship) {\r\n if (relationshipId === null) {\r\n ElementDrivesTextAnnotation.create(annotationElement.iModel, sourceId, annotationElement.id).insert();\r\n }\r\n }\r\n\r\n if (staleRelationships.size > 0) {\r\n const staleRelationshipProps = Array.from(staleRelationships).map(relationshipId =>\r\n annotationElement.iModel.relationships.getInstanceProps(\"BisCore.ElementDrivesTextAnnotation\", relationshipId)\r\n );\r\n annotationElement.iModel.relationships.deleteInstances(staleRelationshipProps);\r\n }\r\n }\r\n\r\n /** Recompute the display strings of all [FieldRun]($common)s in a [TextBlock]($common).\r\n * @returns the number of fields whose display strings were modified.\r\n * @throws Error if evaluation of any field fails.\r\n */\r\n public static evaluateFields(args: EvaluateFieldsArgs): number {\r\n return updateFields(args.block, createUpdateContext(undefined, args.iModel, false))\r\n }\r\n\r\n /** When copying an [[ITextAnnotation]] from one iModel into another, remaps the element Ids in any [FieldPropertyHost]($common) within the cloned element\r\n * so that they refer to elements in the `context`'s target iModel, and sets any Ids that cannot be remapped to [Id64.invalid]($bentley).\r\n * Implementations of `ITextAnnotation` should invoke this function from their implementations of [[Element.onCloned]].\r\n */\r\n public static remapFields(clone: ITextAnnotation, context: IModelElementCloneContext): void {\r\n if (!context.isBetweenIModels) {\r\n return;\r\n }\r\n\r\n const updatedBlocks = [];\r\n for (const block of clone.getTextBlocks()) {\r\n let anyUpdated = false;\r\n for (const { child } of traverseTextBlockComponent(block.textBlock)) {\r\n if (child.type === \"field\") {\r\n child.propertyHost.elementId = context.findTargetElementId(child.propertyHost.elementId);\r\n anyUpdated = true;\r\n }\r\n }\r\n\r\n if (anyUpdated) {\r\n updatedBlocks.push(block);\r\n }\r\n }\r\n\r\n if (updatedBlocks.length > 0) {\r\n clone.updateTextBlocks(updatedBlocks);\r\n }\r\n }\r\n}\r\n\r\n/** Relationship indicating that the [[AnnotationTextStyle]] is being used as the default style for the [[ITextAnnotation]].\r\n * @beta\r\n */\r\nexport class TextAnnotationUsesTextStyleByDefault extends RelatedElement {\r\n public static classFullName = \"BisCore:TextAnnotationUsesTextStyleByDefault\";\r\n public constructor(annotationTextStyleId: Id64String, relClassName: string = TextAnnotationUsesTextStyleByDefault.classFullName) {\r\n super({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AK,CAAC,MAAM,CAAC;IAC5B,kLAAkL;IAClL,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpD,kFAAkF;IAClF,MAAM,YAAY,GAAG,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;IAEtD,6CAA6C;IAC7C,MAAM,cAAc,GAAG,GAAG,GAAG,CAAC,CAAC;IAC/B,MAAM,QAAQ,GAAc,EAAE,CAAC;IAE/B,8BAA8B;IAC9B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3B,MAAM,KAAK,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC,GAAG,cAAc,GAAG,WAAW,CAAC,CAAC;QACpE,MAAM,MAAM,GAAG,QAAQ,CAAC,WAAW,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;QACzD,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1E,CAAC;IAED,oBAAoB;IACpB,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAE3B,4BAA4B;IAC5B,MAAM,KAAK,GAAG,YAAY,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAClD,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC;AACxD,CAAC,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\n\nimport { BackgroundFill, ColorDef, ElementGeometry, FillDisplay, GeometryParams, TextAnnotationFrameShape, TextFrameStyleProps } from \"@itwin/core-common\";\nimport { Angle, AngleSweep, Arc3d, LineString3d, Loop, Path, Point3d, Range2d, Transform, Vector2d } from \"@itwin/core-geometry\";\n\n/**\n * Based on the frame style, this method will construct and append [[GeometryParams]] (for line style) and a [[Loop]] (for the frame shape) to the builder.\n * @param builder that will be appended to in place\n * @param frame\n * @param range to enclose with the frame\n * @param transform that transforms the range to world coordinates\n * @returns `true` if any geometry was appended to the builder\n* @beta\n */\nexport function appendFrameToBuilder(builder: ElementGeometry.Builder, frame: TextFrameStyleProps, range: Range2d, transform: Transform, geomParams: GeometryParams): boolean {\n if (frame.shape === \"none\" || frame.shape === undefined) {\n return false;\n }\n\n const params = geomParams.clone();\n\n if (frame.fillColor === \"none\" || frame.fillColor === undefined) {\n params.fillDisplay = FillDisplay.Never;\n } else if (frame.fillColor === \"background\") {\n params.backgroundFill = BackgroundFill.Solid;\n params.fillDisplay = FillDisplay.Blanking;\n } else if (frame.fillColor !== \"subcategory\") {\n params.fillColor = ColorDef.fromJSON(frame.fillColor);\n params.lineColor = params.fillColor;\n params.fillDisplay = FillDisplay.Blanking;\n }\n\n if (frame.borderColor !== \"subcategory\") {\n params.lineColor = ColorDef.fromJSON(frame.borderColor);\n params.weight = frame.borderWeight;\n }\n\n const frameGeometry = computeFrame({ frame: frame.shape, range, transform });\n if (!builder.appendGeometryParamsChange(params) || !builder.appendGeometryQuery(frameGeometry)) {\n return false;\n }\n\n // The tile generator does not produce an outline for shapes with blanking fill. We must add the outline separately.\n if (params.fillDisplay === FillDisplay.Blanking) {\n const outlineParams = params.clone();\n outlineParams.fillDisplay = FillDisplay.Never;\n if (!builder.appendGeometryParamsChange(outlineParams) || !builder.appendGeometryQuery(frameGeometry)) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Arguments for the [[computeFrame]] method.\n * @beta\n */\nexport interface ComputeFrameArgs {\n /** Frame shape to be calculated */\n frame: Exclude<TextAnnotationFrameShape, \"none\">;\n /** Range to be enclosed */\n range: Range2d;\n /** Transform that translates and rotates the range to world coordinates */\n transform: Transform;\n}\n\n/**\n * Computes the frame geometry based on the provided frame shape and range.\n * @returns a [Loop]($geometry) or [Path]($geometry) (if it's just a line) that represents the frame geometry\n * @beta\n */\nexport function computeFrame(args: ComputeFrameArgs): Loop | Path {\n switch (args.frame) {\n case \"line\": return computeLine(args.range, args.transform);\n case \"rectangle\": return computeRectangle(args.range, args.transform);\n case \"circle\": return computeCircle(args.range, args.transform);\n case \"equilateralTriangle\": return computeTriangle(args.range, args.transform);\n case \"diamond\": return computeDiamond(args.range, args.transform);\n case \"square\": return computeSquare(args.range, args.transform);\n case \"pentagon\": return computePolygon(5, args.range, args.transform, 90);\n case \"hexagon\": return computePolygon(6, args.range, args.transform);\n case \"octagon\": return computePolygon(8, args.range, args.transform, 180 / 8); // or pi/8 in radians\n case \"capsule\": return computeCapsule(args.range, args.transform);\n case \"roundedRectangle\": return computeRoundedRectangle(args.range, args.transform);\n default: return computeRectangle(args.range, args.transform);\n }\n}\n\n/**\n * Arguments for the [[computeIntervalPoints]] method.\n * @beta\n */\nexport interface ComputeIntervalPointsArgs extends ComputeFrameArgs {\n /** A factor applied to divide each straight edge. A value of 1 will place a single point on each vertex. */\n lineIntervalFactor?: number;\n /** A factor applied to divide each straight edge. A value of 1 will place a single point on each vertex. */\n arcIntervalFactor?: number;\n}\n\n/**\n * Computes points along the edges of the frame geometry based on the provided frame shape, range, and interval factors.\n * These can be used for snapping or attaching leaders.\n * @returns an array of [[Point3d]] that represent the points along the edges of the frame geometry. Returns `undefined` if the loop created by `computeFrame` is empty.\n * @beta\n */\nexport function computeIntervalPoints({ frame, range, transform, lineIntervalFactor = 0.5, arcIntervalFactor = 0.25 }: ComputeIntervalPointsArgs): Point3d[] | undefined {\n const points: Point3d[] = [];\n const curves = computeFrame({ frame, range, transform }).collectCurvePrimitives(undefined, false, true);\n\n curves.forEach((curve) => {\n const end = curve instanceof Arc3d ? arcIntervalFactor : lineIntervalFactor;\n for (let interval = 0; interval <= 1; interval += end) {\n points.push(curve.fractionToPoint(interval));\n }\n });\n return points;\n}\n\n/** Line - currently just adds an underline. Once we have leaders, this method may change. */\nconst computeLine = (range: Range2d, transform: Transform): Path => {\n const points = [Point3d.create(range.low.x, range.low.y), Point3d.create(range.high.x, range.low.y)];\n const frame = LineString3d.createPoints(points);\n\n return Path.create(frame.cloneTransformed(transform));\n}\n\n/** Rectangle - simplest frame */\nconst computeRectangle = (range: Range2d, transform: Transform): Loop => {\n const points = range.corners3d(true);\n const frame = LineString3d.createPoints(points);\n\n return Loop.create(frame.cloneTransformed(transform));\n}\n\n/** Rounded Rectangle: each corner will be turned into an arc with the radius of the arc being the @param radiusFactor * the height (yLength) of the range */\nconst computeRoundedRectangle = (range: Range2d, transform: Transform, radiusFactor: number = 0.25): Loop => {\n const radius = range.yLength() * radiusFactor * Math.sqrt(2);\n // We're going to circumscribe the range with our rounded edges. The corners of the range will fall on 45 degree angles.\n const radiusOffsetFactor = range.yLength() * radiusFactor;\n\n // These values are the origins of the circles\n const inLeft = range.low.x + radiusOffsetFactor;\n const inRight = range.high.x - radiusOffsetFactor;\n const inBottom = range.low.y + radiusOffsetFactor;\n const inTop = range.high.y - radiusOffsetFactor\n\n // These values exist on the circles\n const exLeft = inLeft - radius;\n const exRight = inRight + radius;\n const exBottom = inBottom - radius;\n const exTop = inTop + radius;\n\n const q1 = AngleSweep.createStartEndDegrees(0, 90);\n const q2 = AngleSweep.createStartEndDegrees(90, 180);\n const q3 = AngleSweep.createStartEndDegrees(180, 270);\n const q4 = AngleSweep.createStartEndDegrees(270, 360);\n\n\n const curves = [\n LineString3d.create([Point3d.create(inRight, exTop), Point3d.create(inLeft, exTop)]), // top\n Arc3d.createXY(Point3d.create(inLeft, inTop), radius, q2), // top left\n LineString3d.create([Point3d.create(exLeft, inTop), Point3d.create(exLeft, inBottom)]), // left\n Arc3d.createXY(Point3d.create(inLeft, inBottom), radius, q3), // bottom left\n LineString3d.create([Point3d.create(inLeft, exBottom), Point3d.create(inRight, exBottom)]), // bottom\n Arc3d.createXY(Point3d.create(inRight, inBottom), radius, q4), // bottom right\n LineString3d.create([Point3d.create(exRight, inBottom), Point3d.create(exRight, inTop)]), // right\n Arc3d.createXY(Point3d.create(inRight, inTop), radius, q1), // top right\n ];\n\n return Loop.createArray(curves.map((curve) => curve.cloneTransformed(transform)))\n}\n\n\n/** Circle */\nconst computeCircle = (range: Range2d, transform: Transform): Loop => {\n const radius = range.low.distance(range.high) / 2;\n const frame = Arc3d.createXY(Point3d.createFrom(range.center), radius);\n return Loop.create(frame.cloneTransformed(transform));\n}\n\n/** Equilateral Triangle */\nconst computeTriangle = (range: Range2d, transform: Transform): Loop => {\n\n const xLength = range.xLength();\n const yLength = range.yLength();\n const center = range.center;\n const points: Point3d[] = [];\n\n const magnitude = (xLength > yLength) ? (xLength * Math.sqrt(3) + yLength) / 2 : (yLength * Math.sqrt(3) + xLength) / 2;\n\n const v1 = Vector2d.create(0, magnitude);\n const vectors = [\n v1, // top\n v1.rotateXY(Angle.createDegrees(120)), // left\n v1.rotateXY(Angle.createDegrees(240)), // right\n v1 // top\n ];\n\n vectors.forEach((v) => {\n points.push(Point3d.create(center.x + v.x, center.y + v.y));\n });\n\n const frame = LineString3d.createPoints(points);\n\n return Loop.create(frame.cloneTransformed(transform));\n}\n\n/** Diamond (square rotated 45 degrees) */\nconst computeDiamond = (range: Range2d, transform: Transform): Loop => {\n const offset = (range.xLength() + range.yLength()) / 2;\n const center = range.center;\n\n const points = [\n Point3d.createFrom({ x: center.x, y: center.y + offset }), // top\n Point3d.createFrom({ x: center.x + offset, y: center.y }), // right\n Point3d.createFrom({ x: center.x, y: center.y - offset }), // bottom\n Point3d.createFrom({ x: center.x - offset, y: center.y }), // left\n Point3d.createFrom({ x: center.x, y: center.y + offset }), // top\n ];\n\n const frame = LineString3d.createPoints(points);\n\n return Loop.create(frame.cloneTransformed(transform));\n}\n\n/** Square */\nconst computeSquare = (range: Range2d, transform: Transform): Loop => {\n\n // Extend range\n const xLength = range.xLength() / 2;\n const yLength = range.yLength() / 2;\n const center = range.center;\n if (xLength > yLength) {\n range.extendPoint({ x: center.x, y: center.y + xLength });\n range.extendPoint({ x: center.x, y: center.y - xLength });\n } else {\n range.extendPoint({ x: center.x + yLength, y: center.y });\n range.extendPoint({ x: center.x - yLength, y: center.y });\n }\n\n const points = range.corners3d(true);\n const frame = LineString3d.createPoints(points);\n\n return Loop.create(frame.cloneTransformed(transform));\n}\n\n/** Capsule (or pill shape) */\nconst computeCapsule = (range: Range2d, transform: Transform): Loop => {\n const height = range.yLength();\n const radius = height * (Math.sqrt(2) / 2);\n\n // We're going to circumscribe the range with our rounded edges. The corners of the range will fall on 45 degree angles.\n const radiusOffsetFactor = height / 2;\n\n // These values are the origins of the circles\n const inLeft = range.low.x + radiusOffsetFactor;\n const inRight = range.high.x - radiusOffsetFactor;\n const inBottom = range.low.y + radiusOffsetFactor;\n const inTop = range.high.y - radiusOffsetFactor\n\n // These values exist on the circles\n const exBottom = inBottom - radius;\n const exTop = inTop + radius;\n\n const leftHalfCircle = AngleSweep.createStartEndDegrees(90, 270);\n const rightHalfCircle = AngleSweep.createStartEndDegrees(-90, 90);\n\n const curves = [\n LineString3d.create([Point3d.create(inRight, exTop), Point3d.create(inLeft, exTop)]), // top\n Arc3d.createXY(Point3d.create(inLeft, range.center.y), radius, leftHalfCircle), // left\n LineString3d.create([Point3d.create(inLeft, exBottom), Point3d.create(inRight, exBottom)]), // bottom\n Arc3d.createXY(Point3d.create(inRight, range.center.y), radius, rightHalfCircle), // right\n ];\n\n return Loop.createArray(curves.map((curve) => curve.cloneTransformed(transform)));\n}\n\n/** Regular polygon with n sides: note, this a generic method that can be used to create any polygon, but the frame will not be as tightly encapsulating. */\nconst computePolygon = (n: number, range: Range2d, transform: Transform, angleOffset: number = 0): Loop => {\n // These are math terms: cspell:ignore inradius circumradius\n if (n < 3) throw new Error(\"A polygon must have at least 3 sides.\");\n\n // We're assuming the polygon is a regular polygon with `n` sides.\n // The center of the polygon is the center of the range.\n const center = range.center;\n // The inradius is the distance from the center to the midpoint of each side of the polygon. On our range, this coincides with the distance from the center to one of its corners.\n const inradius = range.low.distance(range.high) / 2;\n // The circumradius is the distance from the center to each vertex of the polygon.\n const circumradius = inradius / Math.cos(Math.PI / n);\n\n // The exterior angles add up to 360 degrees.\n const angleIncrement = 360 / n;\n const vertices: Point3d[] = [];\n\n // Add a point for each vertex\n for (let i = 0; i < n; i++) {\n const angle = Angle.createDegrees(i * angleIncrement + angleOffset);\n const vector = Vector2d.createPolar(circumradius, angle);\n vertices.push(Point3d.create(center.x + vector.x, center.y + vector.y));\n }\n\n // Close the polygon\n vertices.push(vertices[0]);\n\n // Finally compute the loop!\n const frame = LineString3d.createPoints(vertices);\n return Loop.create(frame.cloneTransformed(transform));\n};"]}
1
+ {"version":3,"file":"FrameGeometry.js","sourceRoot":"","sources":["../../../src/annotations/FrameGeometry.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAmB,WAAW,EAAiE,MAAM,oBAAoB,CAAC;AAC3J,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAsB,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEjI;;;;;;;;GAQG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAgC,EAAE,KAA0B,EAAE,KAAc,EAAE,SAAoB,EAAE,UAA0B;IACjK,IAAI,KAAK,CAAC,KAAK,KAAK,MAAM,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QACxD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,EAAE,CAAC;IAElC,IAAI,KAAK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C,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1E,CAAC;IAED,oBAAoB;IACpB,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAE3B,4BAA4B;IAC5B,MAAM,KAAK,GAAG,YAAY,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAClD,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC;AACxD,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module ElementGeometry\r\n */\r\n\r\n\r\nimport { BackgroundFill, ColorDef, ElementGeometry, FillDisplay, GeometryParams, TextAnnotationFrameShape, TextFrameStyleProps } from \"@itwin/core-common\";\r\nimport { Angle, AngleSweep, Arc3d, LineString3d, Loop, Path, Point3d, Range2d, Transform, Vector2d } from \"@itwin/core-geometry\";\r\n\r\n/**\r\n * Based on the frame style, this method will construct and append [[GeometryParams]] (for line style) and a [[Loop]] (for the frame shape) to the builder.\r\n * @param builder that will be appended to in place\r\n * @param frame\r\n * @param range to enclose with the frame\r\n * @param transform that transforms the range to world coordinates\r\n * @returns `true` if any geometry was appended to the builder\r\n* @beta\r\n */\r\nexport function appendFrameToBuilder(builder: ElementGeometry.Builder, frame: TextFrameStyleProps, range: Range2d, transform: Transform, geomParams: GeometryParams): boolean {\r\n if (frame.shape === \"none\" || frame.shape === undefined) {\r\n return false;\r\n }\r\n\r\n const params = geomParams.clone();\r\n\r\n if (frame.fillColor === \"none\" || frame.fillColor === undefined) {\r\n params.fillDisplay = FillDisplay.Never;\r\n } else if (frame.fillColor === \"background\") {\r\n params.backgroundFill = BackgroundFill.Solid;\r\n params.fillDisplay = FillDisplay.Blanking;\r\n } else if (frame.fillColor !== \"subcategory\") {\r\n params.fillColor = ColorDef.fromJSON(frame.fillColor);\r\n params.lineColor = params.fillColor;\r\n params.fillDisplay = FillDisplay.Blanking;\r\n }\r\n\r\n if (frame.borderColor !== \"subcategory\") {\r\n params.lineColor = ColorDef.fromJSON(frame.borderColor);\r\n params.weight = frame.borderWeight;\r\n }\r\n\r\n const frameGeometry = computeFrame({ frame: frame.shape, range, transform });\r\n if (!builder.appendGeometryParamsChange(params) || !builder.appendGeometryQuery(frameGeometry)) {\r\n return false;\r\n }\r\n\r\n // The tile generator does not produce an outline for shapes with blanking fill. We must add the outline separately.\r\n if (params.fillDisplay === FillDisplay.Blanking) {\r\n const outlineParams = params.clone();\r\n outlineParams.fillDisplay = FillDisplay.Never;\r\n if (!builder.appendGeometryParamsChange(outlineParams) || !builder.appendGeometryQuery(frameGeometry)) {\r\n return false;\r\n }\r\n }\r\n\r\n return true;\r\n}\r\n\r\n/**\r\n * Arguments for the [[computeFrame]] method.\r\n * @beta\r\n */\r\nexport interface ComputeFrameArgs {\r\n /** Frame shape to be calculated */\r\n frame: Exclude<TextAnnotationFrameShape, \"none\">;\r\n /** Range to be enclosed */\r\n range: Range2d;\r\n /** Transform that translates and rotates the range to world coordinates */\r\n transform: Transform;\r\n}\r\n\r\n/**\r\n * Computes the frame geometry based on the provided frame shape and range.\r\n * @returns a [Loop]($geometry) or [Path]($geometry) (if it's just a line) that represents the frame geometry\r\n * @beta\r\n */\r\nexport function computeFrame(args: ComputeFrameArgs): Loop | Path {\r\n switch (args.frame) {\r\n case \"line\": return computeLine(args.range, args.transform);\r\n case \"rectangle\": return computeRectangle(args.range, args.transform);\r\n case \"circle\": return computeCircle(args.range, args.transform);\r\n case \"equilateralTriangle\": return computeTriangle(args.range, args.transform);\r\n case \"diamond\": return computeDiamond(args.range, args.transform);\r\n case \"square\": return computeSquare(args.range, args.transform);\r\n case \"pentagon\": return computePolygon(5, args.range, args.transform, 90);\r\n case \"hexagon\": return computePolygon(6, args.range, args.transform);\r\n case \"octagon\": return computePolygon(8, args.range, args.transform, 180 / 8); // or pi/8 in radians\r\n case \"capsule\": return computeCapsule(args.range, args.transform);\r\n case \"roundedRectangle\": return computeRoundedRectangle(args.range, args.transform);\r\n default: return computeRectangle(args.range, args.transform);\r\n }\r\n}\r\n\r\n/**\r\n * Arguments for the [[computeIntervalPoints]] method.\r\n * @beta\r\n */\r\nexport interface ComputeIntervalPointsArgs extends ComputeFrameArgs {\r\n /** A factor applied to divide each straight edge. A value of 1 will place a single point on each vertex. */\r\n lineIntervalFactor?: number;\r\n /** A factor applied to divide each straight edge. A value of 1 will place a single point on each vertex. */\r\n arcIntervalFactor?: number;\r\n}\r\n\r\n/**\r\n * Computes points along the edges of the frame geometry based on the provided frame shape, range, and interval factors.\r\n * These can be used for snapping or attaching leaders.\r\n * @returns an array of [[Point3d]] that represent the points along the edges of the frame geometry. Returns `undefined` if the loop created by `computeFrame` is empty.\r\n * @beta\r\n */\r\nexport function computeIntervalPoints({ frame, range, transform, lineIntervalFactor = 0.5, arcIntervalFactor = 0.25 }: ComputeIntervalPointsArgs): Point3d[] | undefined {\r\n const points: Point3d[] = [];\r\n const curves = computeFrame({ frame, range, transform }).collectCurvePrimitives(undefined, false, true);\r\n\r\n curves.forEach((curve) => {\r\n const end = curve instanceof Arc3d ? arcIntervalFactor : lineIntervalFactor;\r\n for (let interval = 0; interval <= 1; interval += end) {\r\n points.push(curve.fractionToPoint(interval));\r\n }\r\n });\r\n return points;\r\n}\r\n\r\n/** Line - currently just adds an underline. Once we have leaders, this method may change. */\r\nconst computeLine = (range: Range2d, transform: Transform): Path => {\r\n const points = [Point3d.create(range.low.x, range.low.y), Point3d.create(range.high.x, range.low.y)];\r\n const frame = LineString3d.createPoints(points);\r\n\r\n return Path.create(frame.cloneTransformed(transform));\r\n}\r\n\r\n/** Rectangle - simplest frame */\r\nconst computeRectangle = (range: Range2d, transform: Transform): Loop => {\r\n const points = range.corners3d(true);\r\n const frame = LineString3d.createPoints(points);\r\n\r\n return Loop.create(frame.cloneTransformed(transform));\r\n}\r\n\r\n/** Rounded Rectangle: each corner will be turned into an arc with the radius of the arc being the @param radiusFactor * the height (yLength) of the range */\r\nconst computeRoundedRectangle = (range: Range2d, transform: Transform, radiusFactor: number = 0.25): Loop => {\r\n const radius = range.yLength() * radiusFactor * Math.sqrt(2);\r\n // We're going to circumscribe the range with our rounded edges. The corners of the range will fall on 45 degree angles.\r\n const radiusOffsetFactor = range.yLength() * radiusFactor;\r\n\r\n // These values are the origins of the circles\r\n const inLeft = range.low.x + radiusOffsetFactor;\r\n const inRight = range.high.x - radiusOffsetFactor;\r\n const inBottom = range.low.y + radiusOffsetFactor;\r\n const inTop = range.high.y - radiusOffsetFactor\r\n\r\n // These values exist on the circles\r\n const exLeft = inLeft - radius;\r\n const exRight = inRight + radius;\r\n const exBottom = inBottom - radius;\r\n const exTop = inTop + radius;\r\n\r\n const q1 = AngleSweep.createStartEndDegrees(0, 90);\r\n const q2 = AngleSweep.createStartEndDegrees(90, 180);\r\n const q3 = AngleSweep.createStartEndDegrees(180, 270);\r\n const q4 = AngleSweep.createStartEndDegrees(270, 360);\r\n\r\n\r\n const curves = [\r\n LineString3d.create([Point3d.create(inRight, exTop), Point3d.create(inLeft, exTop)]), // top\r\n Arc3d.createXY(Point3d.create(inLeft, inTop), radius, q2), // top left\r\n LineString3d.create([Point3d.create(exLeft, inTop), Point3d.create(exLeft, inBottom)]), // left\r\n Arc3d.createXY(Point3d.create(inLeft, inBottom), radius, q3), // bottom left\r\n LineString3d.create([Point3d.create(inLeft, exBottom), Point3d.create(inRight, exBottom)]), // bottom\r\n Arc3d.createXY(Point3d.create(inRight, inBottom), radius, q4), // bottom right\r\n LineString3d.create([Point3d.create(exRight, inBottom), Point3d.create(exRight, inTop)]), // right\r\n Arc3d.createXY(Point3d.create(inRight, inTop), radius, q1), // top right\r\n ];\r\n\r\n return Loop.createArray(curves.map((curve) => curve.cloneTransformed(transform)))\r\n}\r\n\r\n\r\n/** Circle */\r\nconst computeCircle = (range: Range2d, transform: Transform): Loop => {\r\n const radius = range.low.distance(range.high) / 2;\r\n const frame = Arc3d.createXY(Point3d.createFrom(range.center), radius);\r\n return Loop.create(frame.cloneTransformed(transform));\r\n}\r\n\r\n/** Equilateral Triangle */\r\nconst computeTriangle = (range: Range2d, transform: Transform): Loop => {\r\n\r\n const xLength = range.xLength();\r\n const yLength = range.yLength();\r\n const center = range.center;\r\n const points: Point3d[] = [];\r\n\r\n const magnitude = (xLength > yLength) ? (xLength * Math.sqrt(3) + yLength) / 2 : (yLength * Math.sqrt(3) + xLength) / 2;\r\n\r\n const v1 = Vector2d.create(0, magnitude);\r\n const vectors = [\r\n v1, // top\r\n v1.rotateXY(Angle.createDegrees(120)), // left\r\n v1.rotateXY(Angle.createDegrees(240)), // right\r\n v1 // top\r\n ];\r\n\r\n vectors.forEach((v) => {\r\n points.push(Point3d.create(center.x + v.x, center.y + v.y));\r\n });\r\n\r\n const frame = LineString3d.createPoints(points);\r\n\r\n return Loop.create(frame.cloneTransformed(transform));\r\n}\r\n\r\n/** Diamond (square rotated 45 degrees) */\r\nconst computeDiamond = (range: Range2d, transform: Transform): Loop => {\r\n const offset = (range.xLength() + range.yLength()) / 2;\r\n const center = range.center;\r\n\r\n const points = [\r\n Point3d.createFrom({ x: center.x, y: center.y + offset }), // top\r\n Point3d.createFrom({ x: center.x + offset, y: center.y }), // right\r\n Point3d.createFrom({ x: center.x, y: center.y - offset }), // bottom\r\n Point3d.createFrom({ x: center.x - offset, y: center.y }), // left\r\n Point3d.createFrom({ x: center.x, y: center.y + offset }), // top\r\n ];\r\n\r\n const frame = LineString3d.createPoints(points);\r\n\r\n return Loop.create(frame.cloneTransformed(transform));\r\n}\r\n\r\n/** Square */\r\nconst computeSquare = (range: Range2d, transform: Transform): Loop => {\r\n\r\n // Extend range\r\n const xLength = range.xLength() / 2;\r\n const yLength = range.yLength() / 2;\r\n const center = range.center;\r\n if (xLength > yLength) {\r\n range.extendPoint({ x: center.x, y: center.y + xLength });\r\n range.extendPoint({ x: center.x, y: center.y - xLength });\r\n } else {\r\n range.extendPoint({ x: center.x + yLength, y: center.y });\r\n range.extendPoint({ x: center.x - yLength, y: center.y });\r\n }\r\n\r\n const points = range.corners3d(true);\r\n const frame = LineString3d.createPoints(points);\r\n\r\n return Loop.create(frame.cloneTransformed(transform));\r\n}\r\n\r\n/** Capsule (or pill shape) */\r\nconst computeCapsule = (range: Range2d, transform: Transform): Loop => {\r\n const height = range.yLength();\r\n const radius = height * (Math.sqrt(2) / 2);\r\n\r\n // We're going to circumscribe the range with our rounded edges. The corners of the range will fall on 45 degree angles.\r\n const radiusOffsetFactor = height / 2;\r\n\r\n // These values are the origins of the circles\r\n const inLeft = range.low.x + radiusOffsetFactor;\r\n const inRight = range.high.x - radiusOffsetFactor;\r\n const inBottom = range.low.y + radiusOffsetFactor;\r\n const inTop = range.high.y - radiusOffsetFactor\r\n\r\n // These values exist on the circles\r\n const exBottom = inBottom - radius;\r\n const exTop = inTop + radius;\r\n\r\n const leftHalfCircle = AngleSweep.createStartEndDegrees(90, 270);\r\n const rightHalfCircle = AngleSweep.createStartEndDegrees(-90, 90);\r\n\r\n const curves = [\r\n LineString3d.create([Point3d.create(inRight, exTop), Point3d.create(inLeft, exTop)]), // top\r\n Arc3d.createXY(Point3d.create(inLeft, range.center.y), radius, leftHalfCircle), // left\r\n LineString3d.create([Point3d.create(inLeft, exBottom), Point3d.create(inRight, exBottom)]), // bottom\r\n Arc3d.createXY(Point3d.create(inRight, range.center.y), radius, rightHalfCircle), // right\r\n ];\r\n\r\n return Loop.createArray(curves.map((curve) => curve.cloneTransformed(transform)));\r\n}\r\n\r\n/** Regular polygon with n sides: note, this a generic method that can be used to create any polygon, but the frame will not be as tightly encapsulating. */\r\nconst computePolygon = (n: number, range: Range2d, transform: Transform, angleOffset: number = 0): Loop => {\r\n // These are math terms: cspell:ignore inradius circumradius\r\n if (n < 3) throw new Error(\"A polygon must have at least 3 sides.\");\r\n\r\n // We're assuming the polygon is a regular polygon with `n` sides.\r\n // The center of the polygon is the center of the range.\r\n const center = range.center;\r\n // The inradius is the distance from the center to the midpoint of each side of the polygon. On our range, this coincides with the distance from the center to one of its corners.\r\n const inradius = range.low.distance(range.high) / 2;\r\n // The circumradius is the distance from the center to each vertex of the polygon.\r\n const circumradius = inradius / Math.cos(Math.PI / n);\r\n\r\n // The exterior angles add up to 360 degrees.\r\n const angleIncrement = 360 / n;\r\n const vertices: Point3d[] = [];\r\n\r\n // Add a point for each vertex\r\n for (let i = 0; i < n; i++) {\r\n const angle = Angle.createDegrees(i * angleIncrement + angleOffset);\r\n const vector = Vector2d.createPolar(circumradius, angle);\r\n vertices.push(Point3d.create(center.x + vector.x, center.y + vector.y));\r\n }\r\n\r\n // Close the polygon\r\n vertices.push(vertices[0]);\r\n\r\n // Finally compute the loop!\r\n const frame = LineString3d.createPoints(vertices);\r\n return Loop.create(frame.cloneTransformed(transform));\r\n};"]}
@@ -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,EAAmB,WAAW,EAAgG,MAAM,oBAAoB,CAAC;AAC1K,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAkB,aAAa,EAAE,YAAY,EAAE,IAAI,EAAQ,OAAO,EAAa,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACvJ,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,CAA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------------------------------------------------------------\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 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,EAAE,UAAU,EAAkB,aAAa,EAAE,YAAY,EAAE,IAAI,EAAQ,OAAO,EAAa,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACvJ,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,qBAA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copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module ElementGeometry\r\n */\r\n\r\nimport { ColorDef, ElementGeometry, FillDisplay, GeometryParams, TextAnnotationLeader, TextFrameStyleProps, TextStyleColor, TextStyleSettings } from \"@itwin/core-common\";\r\nimport { Angle, Arc3d, CurveCurve, CurvePrimitive, LineSegment3d, LineString3d, Loop, Path, Point3d, Transform, Vector3d } from \"@itwin/core-geometry\";\r\nimport { computeFrame } from \"./FrameGeometry\";\r\nimport { TextBlockLayout, TextStyleResolver } from \"./TextBlockLayout\";\r\n\r\n/**\r\n * Constructs and appends leader lines and their terminators to the provided geometry builder for a text annotation.\r\n *\r\n * This function processes an array of `TextAnnotationLeader` objects, computes their attachment points\r\n * relative to a text frame (or a default rectangular frame if none is provided), and appends the leader\r\n * line and terminator geometry to the builder. It also applies color overrides if specified\r\n * in the leader's style overrides.\r\n *\r\n * @param builder - The geometry builder to which the leader geometries will be appended.\r\n * @param leaders - An array of leader properties.\r\n * @param layout - The layout information for the text block, including its range.\r\n * @param transform - The transform to apply to the frame and leader geometry.\r\n * @param params - The geometry parameters, such as color, to use for the leader lines.\r\n * @param textStyleResolver - Resolver for text styles, used to obtain leader styles.\r\n * @param scaleFactor - The scale factor to apply to leader dimensions, usually comes from the `scaleFactor` of a [[Drawing]] element.\r\n * @returns `true` if at least one leader with a terminator was successfully appended; otherwise, `false`.\r\n * @beta\r\n */\r\nexport function appendLeadersToBuilder(builder: ElementGeometry.Builder, leaders: TextAnnotationLeader[], layout: TextBlockLayout, transform: Transform, params: GeometryParams, textStyleResolver: TextStyleResolver, scaleFactor: number): boolean {\r\n let result = true;\r\n const scaledBlockTextHeight = textStyleResolver.blockSettings.textHeight * scaleFactor;\r\n let frame: TextFrameStyleProps | undefined = textStyleResolver.blockSettings.frame;\r\n\r\n // If there is no frame, use a rectangular frame to compute the attachmentPoints for leaders.\r\n if (frame === undefined || frame.shape === \"none\") {\r\n frame = { shape: \"rectangle\" }\r\n }\r\n if (frame.shape === undefined || frame.shape === \"none\") return false;\r\n const frameCurve = computeFrame({ frame: frame.shape, range: layout.range, transform });\r\n\r\n for (const leader of leaders) {\r\n const leaderStyle = textStyleResolver.resolveSettings(leader.styleOverrides ?? {}, true);\r\n\r\n let effectiveColor: TextStyleColor = \"subcategory\";\r\n\r\n if (leaderStyle.leader.color === \"inherit\") {\r\n effectiveColor = leaderStyle.color;\r\n } else if (leaderStyle.leader.color !== \"subcategory\") {\r\n effectiveColor = leaderStyle.leader.color;\r\n }\r\n\r\n if (effectiveColor !== \"subcategory\") {\r\n params.lineColor = ColorDef.fromJSON(effectiveColor);\r\n result = result && builder.appendGeometryParamsChange(params);\r\n }\r\n\r\n const attachmentPoint = computeLeaderAttachmentPoint(leader, frameCurve, layout, transform);\r\n if (!attachmentPoint) return false;\r\n\r\n // Leader line geometry\r\n const leaderLinePoints: Point3d[] = [];\r\n\r\n leaderLinePoints.push(leader.startPoint)\r\n\r\n leader.intermediatePoints?.forEach((point) => {\r\n leaderLinePoints.push(point);\r\n });\r\n\r\n if (leaderStyle.leader.wantElbow) {\r\n const elbowLength = leaderStyle.leader.elbowLength * scaledBlockTextHeight;\r\n const elbowDirection = computeElbowDirection(attachmentPoint, frameCurve, elbowLength);\r\n if (elbowDirection)\r\n leaderLinePoints.push(attachmentPoint.plusScaled(elbowDirection, elbowLength))\r\n }\r\n\r\n leaderLinePoints.push(attachmentPoint)\r\n\r\n const terminatorDirection = Vector3d.createStartEnd(\r\n leaderLinePoints[0], leaderLinePoints[1]\r\n ).normalize();\r\n const terminatorWidth = leaderStyle.leader.terminatorWidthFactor * scaledBlockTextHeight;\r\n // Truncate the first segment of the leader lines to account for the arrowhead size when closedArrow (hollow triangle) terminatorShape is used.\r\n if (leaderStyle.leader.terminatorShape === \"closedArrow\") {\r\n if (terminatorDirection)\r\n leaderLinePoints[0] = leaderLinePoints[0].plusScaled(terminatorDirection, terminatorWidth);\r\n }\r\n\r\n result = result && builder.appendGeometryQuery(LineString3d.create(leaderLinePoints));\r\n\r\n if (leaderStyle.leader.terminatorShape !== \"none\") {\r\n // Terminator geometry\r\n if (!terminatorDirection) continue; // Assuming leaders without terminators is a valid case.\r\n result = result && createTerminatorGeometry(builder, leader.startPoint, terminatorDirection, params, leaderStyle, scaledBlockTextHeight);\r\n\r\n }\r\n\r\n }\r\n return result;\r\n}\r\n\r\n/**\r\n * Creates the geometry for a terminator at the end of a leader line.\r\n * @param builder The geometry builder to append the terminator geometry to.\r\n * @param point The starting point of the leader line.\r\n * @param dir The direction vector of the leader line.\r\n * @param params The geometry parameters to use for the terminator.\r\n * @param textStyleSettings The text style settings to use for the terminator.\r\n * @param textHeight The height of the text block.\r\n * @returns True if the geometry was successfully created, false otherwise.\r\n * @beta\r\n */\r\nexport function createTerminatorGeometry(builder: ElementGeometry.Builder, point: Point3d, dir: Vector3d, params: GeometryParams, textStyleSettings: TextStyleSettings, textHeight: number): boolean {\r\n\r\n let result = true;\r\n const termY = dir.unitCrossProduct(Vector3d.unitZ());\r\n if (!termY) return false; // If dir is parallel to Z, we can't create a terminator\r\n const terminatorHeight = textStyleSettings.leader.terminatorHeightFactor * textHeight;\r\n const terminatorWidth = textStyleSettings.leader.terminatorWidthFactor * textHeight;\r\n const terminatorHalfHeight = terminatorHeight / 2;\r\n const basePoint = point.plusScaled(dir, terminatorWidth);\r\n const point1 = basePoint.plusScaled(termY, terminatorHalfHeight);\r\n const point2 = basePoint.plusScaled(termY.negate(), terminatorHalfHeight);\r\n\r\n // Helper function to add fill parameters\r\n const addFillParams = () => {\r\n params.fillDisplay = FillDisplay.Always;\r\n result = result && builder.appendGeometryParamsChange(params);\r\n };\r\n\r\n // Helper function to create geometry entry\r\n const addGeometry = (content: CurvePrimitive, useLoop = false) => {\r\n const finalContent = useLoop ? Loop.create(content) : content;\r\n result = result && builder.appendGeometryQuery(finalContent);\r\n };\r\n\r\n switch (textStyleSettings.leader.terminatorShape) {\r\n case \"openArrow\": {\r\n const lineString = LineString3d.create([point1, point, point2]);\r\n addGeometry(lineString);\r\n break;\r\n }\r\n\r\n case \"closedArrow\": {\r\n const lineString = LineString3d.create([point1, point, point2, point1]);\r\n addGeometry(lineString);\r\n break;\r\n }\r\n\r\n case \"closedArrowFilled\": {\r\n addFillParams();\r\n const lineString = LineString3d.create([point1, point, point2, point1]);\r\n addGeometry(lineString, true);\r\n break;\r\n }\r\n\r\n case \"circle\": {\r\n const circle = Arc3d.createXY(point, terminatorHalfHeight);\r\n addGeometry(circle);\r\n break;\r\n }\r\n\r\n case \"circleFilled\": {\r\n addFillParams();\r\n const circle = Arc3d.createXY(point, terminatorHalfHeight);\r\n addGeometry(circle, true);\r\n break;\r\n }\r\n\r\n case \"slash\": {\r\n const normalizedVector = dir.normalize();\r\n if (!normalizedVector) throw new Error(\"Invalid reference vector for slash terminator.\");\r\n\r\n const rotatedVector = normalizedVector.rotateXY(Angle.createDegrees(45));\r\n const startPoint = point.plusScaled(rotatedVector, -terminatorHalfHeight);\r\n const endPoint = point.plusScaled(rotatedVector, terminatorHalfHeight);\r\n\r\n const slashLine = LineSegment3d.create(startPoint, endPoint);\r\n addGeometry(slashLine);\r\n break;\r\n }\r\n }\r\n\r\n return result;\r\n};\r\n\r\n\r\n/**\r\n * Computes the direction vector for an \"elbow\" for leader based on the attachment point and a frame curve.\r\n * The elbow direction is determined by whether the attachment point is closer to the left or right side of the frame.\r\n * If the computed elbow would be tangent to the frame at the intersection, no elbow direction is returned.\r\n *\r\n * @param attachmentPoint - The point where the leader attaches.\r\n * @param frameCurve - The frame curve (either a Loop or Path) to which the leader is attached.\r\n * @param elbowLength - The length of the elbow segment to be created.\r\n * @returns The direction vector for the elbow, or `undefined` if the elbow would be tangent to the frame.\r\n * @beta\r\n */\r\nexport function computeElbowDirection(attachmentPoint: Point3d, frameCurve: Loop | Path, elbowLength: number): Vector3d | undefined {\r\n\r\n let elbowDirection: Vector3d | undefined;\r\n // Determine the direction based on the closest point's position relative to the frame\r\n const isCloserToLeft = Math.abs(attachmentPoint.x - frameCurve.range().low.x) < Math.abs(attachmentPoint.x - frameCurve.range().high.x);\r\n\r\n // Decide the direction: left (-X) or right (+X)\r\n elbowDirection = isCloserToLeft ? Vector3d.unitX().negate() : Vector3d.unitX();\r\n\r\n // Verify if the elbow is a tangent to the frame, if yes, do not create an elbow\r\n const elbowPoint = attachmentPoint.plusScaled(elbowDirection, elbowLength);\r\n const elbowLine = LineSegment3d.create(attachmentPoint, elbowPoint);\r\n // Find intersection points between the elbow and the frame\r\n const intersections = CurveCurve.intersectionXYZPairs(elbowLine, false, frameCurve, false);\r\n // As the elbow will intersect the frame only at one point, we can safely use the first intersection\r\n const intersection = intersections[0];\r\n const curveFraction = intersection.detailB.fraction;\r\n const derivative = intersection.detailB.curve?.fractionToPointAndDerivative(curveFraction);\r\n const tangent = derivative?.direction.normalize();\r\n const lineDirection = Vector3d.createStartEnd(elbowLine.point0Ref, elbowLine.point1Ref).normalize();\r\n if (tangent && lineDirection) {\r\n const dot = tangent.dotProduct(lineDirection);\r\n // If the tangent and line direction are aligned (dot product close to 1 or -1), it's tangent\r\n if (Math.abs(dot) > 0.999) {\r\n elbowDirection = undefined;\r\n }\r\n }\r\n return elbowDirection;\r\n}\r\n\r\n/**\r\n * Computes the attachment point for a leader line on a text annotation frame.\r\n *\r\n * The attachment point is determined based on the leader's attachment mode:\r\n * - `\"Nearest\"`: Finds the closest point on the frame curve to the leader's start point.\r\n * - `\"KeyPoint\"`: Uses a specific curve segment and fraction along that segment to determine the point.\r\n * - `\"TextPoint\"`: Calculates a point on the text layout (top/bottom, left/right) and projects it onto the frame curve.\r\n *\r\n * @param leader - The leader props.\r\n * @param frameCurve - The curve (Loop or Path) representing the annotation frame.\r\n * @param textLayout - The layout information for the text block.\r\n * @param transform - The transform applied to the text layout.\r\n * @returns The computed attachment point as a `Point3d`, or `undefined` if it cannot be determined.\r\n * @beta\r\n */\r\nexport function computeLeaderAttachmentPoint(\r\n leader: TextAnnotationLeader,\r\n frameCurve: Loop | Path,\r\n textLayout: TextBlockLayout,\r\n transform: Transform\r\n): Point3d | undefined {\r\n let attachmentPoint: Point3d | undefined;\r\n\r\n if (leader.attachment.mode === \"Nearest\") {\r\n attachmentPoint = frameCurve.closestPoint(leader.startPoint)?.point;\r\n } else if (leader.attachment.mode === \"KeyPoint\") {\r\n const curves = frameCurve.collectCurvePrimitives(undefined, false, true);\r\n const curveIndex = leader.attachment.curveIndex;\r\n const fraction = leader.attachment.fraction;\r\n if (curveIndex >= curves.length) {\r\n // If the curveIndex is invalid, use the last curve\r\n // This is a fallback to avoid out-of-bounds access\r\n attachmentPoint = curves[curves.length - 1].fractionToPoint(fraction);\r\n } else {\r\n attachmentPoint = curves[curveIndex].fractionToPoint(fraction);\r\n }\r\n } else { // attachment.mode=\"TextPoint\"\r\n let scaleDirection = transform.matrix.getColumn(0).negate(); // direction to draw a scaled line from text attachment point to find intersection point on frame\r\n let lineIndex: number;\r\n if (leader.attachment.position.includes(\"Top\")) {\r\n lineIndex = 0\r\n } else {\r\n lineIndex = textLayout.lines.length - 1\r\n }\r\n const lineRange = textLayout.lines[lineIndex].range;\r\n const lineOffset = textLayout.lines[lineIndex].offsetFromDocument;\r\n const origin = transform.multiplyPoint3d(Point3d.fromJSON(lineOffset));\r\n let attachmentPointOnText = origin.plusScaled(transform.matrix.getColumn(1), ((lineRange.yLength()) / 2));\r\n\r\n if (leader.attachment.position.includes(\"Right\")) {\r\n attachmentPointOnText = attachmentPointOnText.plusScaled(transform.matrix.getColumn(0), lineRange.xLength());\r\n scaleDirection = scaleDirection.negate();\r\n }\r\n // Find the nearest intersection point on the frame to get the correct attachment point\r\n // Extend the direction vector to create a target point far along the direction\r\n const targetPoint = attachmentPointOnText.plusScaled(scaleDirection, 1e6); // Scale the direction vector to a large value\r\n const intersectionLine = LineSegment3d.create(attachmentPointOnText, targetPoint);\r\n const closestPointDetail = CurveCurve.intersectionXYZPairs(intersectionLine, false, frameCurve, false);\r\n attachmentPoint = closestPointDetail[0]?.detailA.point;\r\n }\r\n return attachmentPoint;\r\n}"]}