@itwin/core-backend 5.5.0-dev.2 → 5.5.0-dev.5
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.
- package/CHANGELOG.md +19 -1
- package/lib/cjs/BackendHubAccess.js.map +1 -1
- package/lib/cjs/BackendLoggerCategory.js.map +1 -1
- package/lib/cjs/BisCoreSchema.js.map +1 -1
- package/lib/cjs/BlobContainerService.js.map +1 -1
- package/lib/cjs/BriefcaseManager.js.map +1 -1
- package/lib/cjs/CatalogDb.js.map +1 -1
- package/lib/cjs/Category.js.map +1 -1
- package/lib/cjs/ChangeSummaryManager.js +2 -2
- package/lib/cjs/ChangeSummaryManager.js.map +1 -1
- package/lib/cjs/ChangedElementsDb.js.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.js +248 -248
- package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
- package/lib/cjs/ChannelControl.js.map +1 -1
- package/lib/cjs/CheckpointManager.js.map +1 -1
- package/lib/cjs/ClassRegistry.js +5 -5
- package/lib/cjs/ClassRegistry.js.map +1 -1
- package/lib/cjs/CloudSqlite.js.map +1 -1
- package/lib/cjs/CodeService.js.map +1 -1
- package/lib/cjs/CodeSpecs.js.map +1 -1
- package/lib/cjs/ConcurrentQuery.js.map +1 -1
- package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
- package/lib/cjs/DevTools.js.map +1 -1
- package/lib/cjs/DisplayStyle.js.map +1 -1
- package/lib/cjs/ECDb.js.map +1 -1
- package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
- package/lib/cjs/ECSqlStatement.js.map +1 -1
- package/lib/cjs/Element.js.map +1 -1
- package/lib/cjs/ElementAspect.js.map +1 -1
- package/lib/cjs/ElementGraphics.js.map +1 -1
- package/lib/cjs/ElementTreeWalker.js.map +1 -1
- package/lib/cjs/Entity.js.map +1 -1
- package/lib/cjs/EntityReferences.js.map +1 -1
- package/lib/cjs/ExportGraphics.js.map +1 -1
- package/lib/cjs/ExternalSource.js.map +1 -1
- package/lib/cjs/FontFile.js.map +1 -1
- package/lib/cjs/GeoCoordConfig.js.map +1 -1
- package/lib/cjs/GeographicCRSServices.js.map +1 -1
- package/lib/cjs/GeometrySummary.js +47 -47
- package/lib/cjs/GeometrySummary.js.map +1 -1
- package/lib/cjs/IModelDb.js +8 -8
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/IModelDbFonts.js.map +1 -1
- package/lib/cjs/IModelElementCloneContext.js.map +1 -1
- package/lib/cjs/IModelHost.js.map +1 -1
- package/lib/cjs/IModelIncrementalSchemaLocater.js.map +1 -1
- package/lib/cjs/IModelJsFs.js.map +1 -1
- package/lib/cjs/ImageSourceConversion.js.map +1 -1
- package/lib/cjs/IpcHost.js.map +1 -1
- package/lib/cjs/LineStyle.js.map +1 -1
- package/lib/cjs/LocalHub.js +1 -1
- package/lib/cjs/LocalHub.js.map +1 -1
- package/lib/cjs/LocalhostIpcHost.js.map +1 -1
- package/lib/cjs/LockControl.js.map +1 -1
- package/lib/cjs/Material.js.map +1 -1
- package/lib/cjs/Model.js.map +1 -1
- package/lib/cjs/NativeAppStorage.js.map +1 -1
- package/lib/cjs/NativeHost.js.map +1 -1
- package/lib/cjs/NavigationRelationship.js.map +1 -1
- package/lib/cjs/PromiseMemoizer.js.map +1 -1
- package/lib/cjs/PropertyStore.js.map +1 -1
- package/lib/cjs/Relationship.js.map +1 -1
- package/lib/cjs/RpcBackend.js.map +1 -1
- package/lib/cjs/SQLiteDb.js.map +1 -1
- package/lib/cjs/Schema.js.map +1 -1
- package/lib/cjs/SchemaSync.js.map +1 -1
- package/lib/cjs/SchemaUtils.js.map +1 -1
- package/lib/cjs/SheetIndex.js.map +1 -1
- package/lib/cjs/SqliteChangesetReader.js.map +1 -1
- package/lib/cjs/SqliteStatement.js.map +1 -1
- package/lib/cjs/StashManager.js.map +1 -1
- package/lib/cjs/Texture.js.map +1 -1
- package/lib/cjs/TileStorage.js.map +1 -1
- package/lib/cjs/TxnManager.js.map +1 -1
- package/lib/cjs/ViewDefinition.js.map +1 -1
- package/lib/cjs/ViewStateHydrator.js.map +1 -1
- package/lib/cjs/ViewStore.js.map +1 -1
- package/lib/cjs/annotations/ElementDrivesTextAnnotation.js.map +1 -1
- package/lib/cjs/annotations/FrameGeometry.js.map +1 -1
- package/lib/cjs/annotations/LeaderGeometry.js.map +1 -1
- package/lib/cjs/annotations/TextAnnotationElement.js.map +1 -1
- package/lib/cjs/annotations/TextAnnotationGeometry.js.map +1 -1
- package/lib/cjs/annotations/TextBlockGeometry.js.map +1 -1
- package/lib/cjs/annotations/TextBlockLayout.js.map +1 -1
- package/lib/cjs/assets/IModelChange.02.00.00.ecschema.xml +90 -90
- package/lib/cjs/assets/Settings/Schemas/Base.Schema.json +32 -32
- package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +27 -27
- package/lib/cjs/assets/Settings/Schemas/Workspace.Schema.json +94 -94
- package/lib/cjs/assets/Settings/backend.setting.json5 +21 -21
- package/lib/cjs/core-backend.js.map +1 -1
- package/lib/cjs/domains/FunctionalElements.js.map +1 -1
- package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
- package/lib/cjs/domains/GenericElements.js.map +1 -1
- package/lib/cjs/domains/GenericSchema.js.map +1 -1
- package/lib/cjs/internal/ChangesetConflictArgs.js.map +1 -1
- package/lib/cjs/internal/ChannelAdmin.js.map +1 -1
- package/lib/cjs/internal/ElementLRUCache.js.map +1 -1
- package/lib/cjs/internal/FontFileImpl.js.map +1 -1
- package/lib/cjs/internal/HubMock.js.map +1 -1
- package/lib/cjs/internal/IModelDbFontsImpl.js.map +1 -1
- package/lib/cjs/internal/NativePlatform.js.map +1 -1
- package/lib/cjs/internal/NoLocks.js.map +1 -1
- package/lib/cjs/internal/OnlineStatus.js.map +1 -1
- package/lib/cjs/internal/ServerBasedLocks.js.map +1 -1
- package/lib/cjs/internal/Symbols.js.map +1 -1
- package/lib/cjs/internal/annotations/fields.js.map +1 -1
- package/lib/cjs/internal/cross-package.js.map +1 -1
- package/lib/cjs/internal/workspace/SettingsImpl.js.map +1 -1
- package/lib/cjs/internal/workspace/SettingsSchemasImpl.js.map +1 -1
- package/lib/cjs/internal/workspace/WorkspaceImpl.js.map +1 -1
- package/lib/cjs/internal/workspace/WorkspaceSqliteDb.js.map +1 -1
- package/lib/cjs/rpc/multipart.js.map +1 -1
- package/lib/cjs/rpc/tracing.js.map +1 -1
- package/lib/cjs/rpc/web/logging.js.map +1 -1
- package/lib/cjs/rpc/web/request.js.map +1 -1
- package/lib/cjs/rpc/web/response.js.map +1 -1
- package/lib/cjs/rpc-impl/DevToolsRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
- package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
- package/lib/cjs/workspace/Settings.js.map +1 -1
- package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
- package/lib/cjs/workspace/Workspace.js.map +1 -1
- package/lib/cjs/workspace/WorkspaceEditor.js.map +1 -1
- package/lib/esm/BackendHubAccess.js.map +1 -1
- package/lib/esm/BackendLoggerCategory.js.map +1 -1
- package/lib/esm/BisCoreSchema.js.map +1 -1
- package/lib/esm/BlobContainerService.js.map +1 -1
- package/lib/esm/BriefcaseManager.js.map +1 -1
- package/lib/esm/CatalogDb.js.map +1 -1
- package/lib/esm/Category.js.map +1 -1
- package/lib/esm/ChangeSummaryManager.js +2 -2
- package/lib/esm/ChangeSummaryManager.js.map +1 -1
- package/lib/esm/ChangedElementsDb.js.map +1 -1
- package/lib/esm/ChangesetECAdaptor.js +248 -248
- package/lib/esm/ChangesetECAdaptor.js.map +1 -1
- package/lib/esm/ChannelControl.js.map +1 -1
- package/lib/esm/CheckpointManager.js.map +1 -1
- package/lib/esm/ClassRegistry.js +5 -5
- package/lib/esm/ClassRegistry.js.map +1 -1
- package/lib/esm/CloudSqlite.js.map +1 -1
- package/lib/esm/CodeService.js.map +1 -1
- package/lib/esm/CodeSpecs.js.map +1 -1
- package/lib/esm/ConcurrentQuery.js.map +1 -1
- package/lib/esm/CustomViewState3dCreator.js.map +1 -1
- package/lib/esm/DevTools.js.map +1 -1
- package/lib/esm/DisplayStyle.js.map +1 -1
- package/lib/esm/ECDb.js.map +1 -1
- package/lib/esm/ECSchemaXmlContext.js.map +1 -1
- package/lib/esm/ECSqlStatement.js.map +1 -1
- package/lib/esm/Element.js.map +1 -1
- package/lib/esm/ElementAspect.js.map +1 -1
- package/lib/esm/ElementGraphics.js.map +1 -1
- package/lib/esm/ElementTreeWalker.js.map +1 -1
- package/lib/esm/Entity.js.map +1 -1
- package/lib/esm/EntityReferences.js.map +1 -1
- package/lib/esm/ExportGraphics.js.map +1 -1
- package/lib/esm/ExternalSource.js.map +1 -1
- package/lib/esm/FontFile.js.map +1 -1
- package/lib/esm/GeoCoordConfig.js.map +1 -1
- package/lib/esm/GeographicCRSServices.js.map +1 -1
- package/lib/esm/GeometrySummary.js +47 -47
- package/lib/esm/GeometrySummary.js.map +1 -1
- package/lib/esm/IModelDb.js +8 -8
- package/lib/esm/IModelDb.js.map +1 -1
- package/lib/esm/IModelDbFonts.js.map +1 -1
- package/lib/esm/IModelElementCloneContext.js.map +1 -1
- package/lib/esm/IModelHost.js.map +1 -1
- package/lib/esm/IModelIncrementalSchemaLocater.js.map +1 -1
- package/lib/esm/IModelJsFs.js.map +1 -1
- package/lib/esm/ImageSourceConversion.js.map +1 -1
- package/lib/esm/IpcHost.js.map +1 -1
- package/lib/esm/LineStyle.js.map +1 -1
- package/lib/esm/LocalHub.js +1 -1
- package/lib/esm/LocalHub.js.map +1 -1
- package/lib/esm/LocalhostIpcHost.js.map +1 -1
- package/lib/esm/LockControl.js.map +1 -1
- package/lib/esm/Material.js.map +1 -1
- package/lib/esm/Model.js.map +1 -1
- package/lib/esm/NativeAppStorage.js.map +1 -1
- package/lib/esm/NativeHost.js.map +1 -1
- package/lib/esm/NavigationRelationship.js.map +1 -1
- package/lib/esm/PromiseMemoizer.js.map +1 -1
- package/lib/esm/PropertyStore.js.map +1 -1
- package/lib/esm/Relationship.js.map +1 -1
- package/lib/esm/RpcBackend.js.map +1 -1
- package/lib/esm/SQLiteDb.js.map +1 -1
- package/lib/esm/Schema.js.map +1 -1
- package/lib/esm/SchemaSync.js.map +1 -1
- package/lib/esm/SchemaUtils.js.map +1 -1
- package/lib/esm/SheetIndex.js.map +1 -1
- package/lib/esm/SqliteChangesetReader.js.map +1 -1
- package/lib/esm/SqliteStatement.js.map +1 -1
- package/lib/esm/StashManager.js.map +1 -1
- package/lib/esm/Texture.js.map +1 -1
- package/lib/esm/TileStorage.js.map +1 -1
- package/lib/esm/TxnManager.js.map +1 -1
- package/lib/esm/ViewDefinition.js.map +1 -1
- package/lib/esm/ViewStateHydrator.js.map +1 -1
- package/lib/esm/ViewStore.js.map +1 -1
- package/lib/esm/annotations/ElementDrivesTextAnnotation.js.map +1 -1
- package/lib/esm/annotations/FrameGeometry.js.map +1 -1
- package/lib/esm/annotations/LeaderGeometry.js.map +1 -1
- package/lib/esm/annotations/TextAnnotationElement.js.map +1 -1
- package/lib/esm/annotations/TextAnnotationGeometry.js.map +1 -1
- package/lib/esm/annotations/TextBlockGeometry.js.map +1 -1
- package/lib/esm/annotations/TextBlockLayout.js.map +1 -1
- package/lib/esm/core-backend.js.map +1 -1
- package/lib/esm/domains/FunctionalElements.js.map +1 -1
- package/lib/esm/domains/FunctionalSchema.js.map +1 -1
- package/lib/esm/domains/GenericElements.js.map +1 -1
- package/lib/esm/domains/GenericSchema.js.map +1 -1
- package/lib/esm/internal/ChangesetConflictArgs.js.map +1 -1
- package/lib/esm/internal/ChannelAdmin.js.map +1 -1
- package/lib/esm/internal/ElementLRUCache.js.map +1 -1
- package/lib/esm/internal/FontFileImpl.js.map +1 -1
- package/lib/esm/internal/HubMock.js.map +1 -1
- package/lib/esm/internal/IModelDbFontsImpl.js.map +1 -1
- package/lib/esm/internal/NativePlatform.js.map +1 -1
- package/lib/esm/internal/NoLocks.js.map +1 -1
- package/lib/esm/internal/OnlineStatus.js.map +1 -1
- package/lib/esm/internal/ServerBasedLocks.js.map +1 -1
- package/lib/esm/internal/Symbols.js.map +1 -1
- package/lib/esm/internal/annotations/fields.js.map +1 -1
- package/lib/esm/internal/cross-package.js.map +1 -1
- package/lib/esm/internal/workspace/SettingsImpl.js.map +1 -1
- package/lib/esm/internal/workspace/SettingsSchemasImpl.js.map +1 -1
- package/lib/esm/internal/workspace/WorkspaceImpl.js.map +1 -1
- package/lib/esm/internal/workspace/WorkspaceSqliteDb.js.map +1 -1
- package/lib/esm/rpc/multipart.js.map +1 -1
- package/lib/esm/rpc/tracing.js.map +1 -1
- package/lib/esm/rpc/web/logging.js.map +1 -1
- package/lib/esm/rpc/web/request.js.map +1 -1
- package/lib/esm/rpc/web/response.js.map +1 -1
- package/lib/esm/rpc-impl/DevToolsRpcImpl.js.map +1 -1
- package/lib/esm/rpc-impl/IModelReadRpcImpl.js.map +1 -1
- package/lib/esm/rpc-impl/IModelTileRpcImpl.js.map +1 -1
- package/lib/esm/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
- package/lib/esm/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
- package/lib/esm/test/AdvancedEqual.js.map +1 -1
- package/lib/esm/test/AnnotationTestUtils.js.map +1 -1
- package/lib/esm/test/AttachDb.test.js +11 -11
- package/lib/esm/test/AttachDb.test.js.map +1 -1
- package/lib/esm/test/ElementDrivesElement.test.js +23 -23
- package/lib/esm/test/ElementDrivesElement.test.js.map +1 -1
- package/lib/esm/test/ElementLRUCache.test.js.map +1 -1
- package/lib/esm/test/GeometryTestUtil.js.map +1 -1
- package/lib/esm/test/IModelHost.test.js.map +1 -1
- package/lib/esm/test/IModelTestUtils.js.map +1 -1
- package/lib/esm/test/ImageSourceConversion.test.js.map +1 -1
- package/lib/esm/test/IpcHost.test.js.map +1 -1
- package/lib/esm/test/KnownTestLocations.js.map +1 -1
- package/lib/esm/test/PrintElementTree.js.map +1 -1
- package/lib/esm/test/PropertyDb.test.js.map +1 -1
- package/lib/esm/test/RevisionUtility.js.map +1 -1
- package/lib/esm/test/SchemaUtils.test.js +25 -25
- package/lib/esm/test/SchemaUtils.test.js.map +1 -1
- package/lib/esm/test/SequentialLogMatcher.js.map +1 -1
- package/lib/esm/test/TestChangeSetUtility.js.map +1 -1
- package/lib/esm/test/TestUtils.js.map +1 -1
- package/lib/esm/test/annotations/Fields.test.js +53 -53
- package/lib/esm/test/annotations/Fields.test.js.map +1 -1
- package/lib/esm/test/annotations/FrameGeometry.test.js.map +1 -1
- package/lib/esm/test/annotations/LeaderGeometry.test.js.map +1 -1
- package/lib/esm/test/annotations/TextAnnotation.test.js.map +1 -1
- package/lib/esm/test/annotations/TextBlock.test.js.map +1 -1
- package/lib/esm/test/assets/IncrementalSchemaLocater/configs/old.config.js.map +1 -1
- package/lib/esm/test/assets/IncrementalSchemaLocater/configs/simple.config.js +5 -5
- package/lib/esm/test/assets/IncrementalSchemaLocater/configs/simple.config.js.map +1 -1
- package/lib/esm/test/categories/Category.test.js.map +1 -1
- package/lib/esm/test/codespec/CodeSpec.test.js.map +1 -1
- package/lib/esm/test/ecdb/CTE.test.js +88 -88
- package/lib/esm/test/ecdb/CTE.test.js.map +1 -1
- package/lib/esm/test/ecdb/ConcurrentQuery.test.js +15 -15
- package/lib/esm/test/ecdb/ConcurrentQuery.test.js.map +1 -1
- package/lib/esm/test/ecdb/ConcurrentQueryLoad.test.js +15 -15
- package/lib/esm/test/ecdb/ConcurrentQueryLoad.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECDb.test.js +72 -72
- package/lib/esm/test/ecdb/ECDb.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECDbTestHelper.js.map +1 -1
- package/lib/esm/test/ecdb/ECSchemaXmlContext.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECSqlAst.test.js +65 -65
- package/lib/esm/test/ecdb/ECSqlAst.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECSqlQuery.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECSqlReader.test.js +16 -16
- package/lib/esm/test/ecdb/ECSqlReader.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECSqlStatement.test.js +332 -332
- package/lib/esm/test/ecdb/ECSqlStatement.test.js.map +1 -1
- package/lib/esm/test/ecdb/SqliteStatement.test.js.map +1 -1
- package/lib/esm/test/ecsql/dataset/ECSqlDatasets.js.map +1 -1
- package/lib/esm/test/ecsql/src/ECSqlTestGenerator.js +21 -21
- package/lib/esm/test/ecsql/src/ECSqlTestGenerator.js.map +1 -1
- package/lib/esm/test/ecsql/src/ECSqlTestParser.js.map +1 -1
- package/lib/esm/test/ecsql/src/ECSqlTestRunner.test.js.map +1 -1
- package/lib/esm/test/element/DeleteDefinitionElements.test.js.map +1 -1
- package/lib/esm/test/element/ElementAspect.test.js +22 -22
- package/lib/esm/test/element/ElementAspect.test.js.map +1 -1
- package/lib/esm/test/element/ElementDependencyGraph.test.js.map +1 -1
- package/lib/esm/test/element/ElementRoundTrip.test.js +139 -139
- package/lib/esm/test/element/ElementRoundTrip.test.js.map +1 -1
- package/lib/esm/test/element/ExcludedElements.test.js.map +1 -1
- package/lib/esm/test/element/ExternalSource.test.js.map +1 -1
- package/lib/esm/test/element/NullStructArray.test.js +13 -13
- package/lib/esm/test/element/NullStructArray.test.js.map +1 -1
- package/lib/esm/test/element/ProjectInformationRecord.test.js.map +1 -1
- package/lib/esm/test/element/SheetInformationAspect.test.js.map +1 -1
- package/lib/esm/test/element/UrlLink.test.js.map +1 -1
- package/lib/esm/test/font/FontFile.test.js.map +1 -1
- package/lib/esm/test/font/IModelDbFonts.test.js.map +1 -1
- package/lib/esm/test/hubaccess/ApplyChangeset.test.js +32 -32
- package/lib/esm/test/hubaccess/ApplyChangeset.test.js.map +1 -1
- package/lib/esm/test/hubaccess/BriefcaseManager.test.js.map +1 -1
- package/lib/esm/test/hubaccess/CheckpointManager.test.js.map +1 -1
- package/lib/esm/test/hubaccess/Rebase.test.js +40 -40
- package/lib/esm/test/hubaccess/Rebase.test.js.map +1 -1
- package/lib/esm/test/imageData.js.map +1 -1
- package/lib/esm/test/imodel/Code.test.js.map +1 -1
- package/lib/esm/test/imodel/ElementTreeWalker.test.js.map +1 -1
- package/lib/esm/test/imodel/GetTextureImage.test.js.map +1 -1
- package/lib/esm/test/imodel/IModel.test.js +44 -44
- package/lib/esm/test/imodel/IModel.test.js.map +1 -1
- package/lib/esm/test/imodel/ProjectExtents.test.js.map +1 -1
- package/lib/esm/test/imodel/SchemaXmlImport.test.js.map +1 -1
- package/lib/esm/test/incrementalSchemaLocater/ECSqlQueries.test.js +432 -198
- package/lib/esm/test/incrementalSchemaLocater/ECSqlQueries.test.js.map +1 -1
- package/lib/esm/test/incrementalSchemaLocater/IncrementalLoading.test.js +272 -190
- package/lib/esm/test/incrementalSchemaLocater/IncrementalLoading.test.js.map +1 -1
- package/lib/esm/test/incrementalSchemaLocater/TestContext.d.ts +27 -0
- package/lib/esm/test/incrementalSchemaLocater/TestContext.d.ts.map +1 -0
- package/lib/esm/test/incrementalSchemaLocater/TestContext.js +136 -0
- package/lib/esm/test/incrementalSchemaLocater/TestContext.js.map +1 -0
- package/lib/esm/test/index.js.map +1 -1
- package/lib/esm/test/misc/DevTools.test.js.map +1 -1
- package/lib/esm/test/misc/EntitySubClasses.test.js.map +1 -1
- package/lib/esm/test/misc/GeoServices.test.js.map +1 -1
- package/lib/esm/test/misc/PromiseMemoizer.test.js.map +1 -1
- package/lib/esm/test/native/DgnDbWorker.test.js.map +1 -1
- package/lib/esm/test/rpc/response.test.js.map +1 -1
- package/lib/esm/test/schema/ClassRegistry.test.js +99 -99
- package/lib/esm/test/schema/ClassRegistry.test.js.map +1 -1
- package/lib/esm/test/schema/FunctionalDomain.test.js.map +1 -1
- package/lib/esm/test/schema/GenericDomain.test.js.map +1 -1
- package/lib/esm/test/schema/IModelSchemaContext.test.js.map +1 -1
- package/lib/esm/test/sheetindex/SheetIndex.test.js.map +1 -1
- package/lib/esm/test/standalone/ChangeMerge.test.js.map +1 -1
- package/lib/esm/test/standalone/ChangesetReader.test.js +346 -127
- package/lib/esm/test/standalone/ChangesetReader.test.js.map +1 -1
- package/lib/esm/test/standalone/CustomViewState3dCreator.test.js.map +1 -1
- package/lib/esm/test/standalone/DisplayStyle.test.js.map +1 -1
- package/lib/esm/test/standalone/Drawing.test.js.map +1 -1
- package/lib/esm/test/standalone/ElementGraphics.test.js.map +1 -1
- package/lib/esm/test/standalone/ElementMesh.test.js.map +1 -1
- package/lib/esm/test/standalone/ExportGraphics.test.js +14 -14
- package/lib/esm/test/standalone/ExportGraphics.test.js.map +1 -1
- package/lib/esm/test/standalone/GeometryChangeEvents.test.js.map +1 -1
- package/lib/esm/test/standalone/GeometryStream.test.js.map +1 -1
- package/lib/esm/test/standalone/HubMock.test.js.map +1 -1
- package/lib/esm/test/standalone/IModelLimits.test.js.map +1 -1
- package/lib/esm/test/standalone/IModelWrite.test.js +27 -27
- package/lib/esm/test/standalone/IModelWrite.test.js.map +1 -1
- package/lib/esm/test/standalone/InlineGeometryPartReferences.test.js.map +1 -1
- package/lib/esm/test/standalone/MergeConflict.test.js.map +1 -1
- package/lib/esm/test/standalone/NativeAppStorage.test.js.map +1 -1
- package/lib/esm/test/standalone/RenderMaterialElement.test.js.map +1 -1
- package/lib/esm/test/standalone/RenderTimeline.test.js.map +1 -1
- package/lib/esm/test/standalone/SQLiteDb.test.js.map +1 -1
- package/lib/esm/test/standalone/SchemaUtils.test.js.map +1 -1
- package/lib/esm/test/standalone/SectionDrawing.test.js.map +1 -1
- package/lib/esm/test/standalone/ServerBasedLocks.test.js.map +1 -1
- package/lib/esm/test/standalone/Setting.test.js.map +1 -1
- package/lib/esm/test/standalone/Settings.test.js.map +1 -1
- package/lib/esm/test/standalone/SettingsSchemas.test.js.map +1 -1
- package/lib/esm/test/standalone/SnapshotDb.test.js.map +1 -1
- package/lib/esm/test/standalone/Texture.test.js.map +1 -1
- package/lib/esm/test/standalone/TileCache.test.js.map +1 -1
- package/lib/esm/test/standalone/TileTree.test.js.map +1 -1
- package/lib/esm/test/standalone/TxnManager.test.js.map +1 -1
- package/lib/esm/test/standalone/ViewDefinition.test.js.map +1 -1
- package/lib/esm/test/standalone/ViewStoreDb.test.js.map +1 -1
- package/lib/esm/test/standalone/Workspace.test.js.map +1 -1
- package/lib/esm/workspace/Settings.js.map +1 -1
- package/lib/esm/workspace/SettingsSchemas.js.map +1 -1
- package/lib/esm/workspace/Workspace.js.map +1 -1
- package/lib/esm/workspace/WorkspaceEditor.js.map +1 -1
- package/package.json +14 -14
- package/lib/esm/test/incrementalSchemaLocater/utils/IModelSchemaLocater.d.ts +0 -11
- package/lib/esm/test/incrementalSchemaLocater/utils/IModelSchemaLocater.d.ts.map +0 -1
- package/lib/esm/test/incrementalSchemaLocater/utils/IModelSchemaLocater.js +0 -36
- package/lib/esm/test/incrementalSchemaLocater/utils/IModelSchemaLocater.js.map +0 -1
- package/lib/esm/test/incrementalSchemaLocater/utils/IncrementalTestHelper.d.ts +0 -20
- package/lib/esm/test/incrementalSchemaLocater/utils/IncrementalTestHelper.d.ts.map +0 -1
- package/lib/esm/test/incrementalSchemaLocater/utils/IncrementalTestHelper.js +0 -126
- package/lib/esm/test/incrementalSchemaLocater/utils/IncrementalTestHelper.js.map +0 -1
- package/lib/esm/test/incrementalSchemaLocater/utils/TestSqlSchemaLocater.d.ts +0 -24
- package/lib/esm/test/incrementalSchemaLocater/utils/TestSqlSchemaLocater.d.ts.map +0 -1
- package/lib/esm/test/incrementalSchemaLocater/utils/TestSqlSchemaLocater.js +0 -67
- package/lib/esm/test/incrementalSchemaLocater/utils/TestSqlSchemaLocater.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementDrivesTextAnnotation.js","sourceRoot":"","sources":["../../../src/annotations/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C;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 { createUpdateContext, updateAllFields, updateElementFields, updateFields } 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/** Arguments supplied to [[ElementDrivesTextAnnotation.evaluateFields]].\n * @beta\n */\nexport interface EvaluateFieldsArgs {\n /** The text block whose fields are to be evaluated. */\n block: TextBlock;\n /** The iModel containing the elements supplying the display strings for the fields in [[block]]. */\n iModel: IModelDb;\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 return iModel.meetsMinimumSchemaVersion(\"BisCore\", minBisCoreVersion);\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 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 let haveFields = false;\n for (const block of blocks) {\n for (const { child } of traverseTextBlockComponent(block.textBlock)) {\n if (child.type === \"field\") {\n haveFields = true;\n if (isValidSourceId(child.propertyHost.elementId)) {\n sourceToRelationship.set(child.propertyHost.elementId, null);\n }\n }\n }\n }\n\n if (haveFields) {\n iModel.requireMinimumSchemaVersion(\"BisCore\", minBisCoreVersion, \"Text fields\");\n updateAllFields(annotationElementId, iModel)\n }\n\n const staleRelationships = new Set<Id64String>();\n if (this.isSupportedForIModel(iModel)) {\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\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 /** Recompute the display strings of all [FieldRun]($common)s in a [TextBlock]($common).\n * @returns the number of fields whose display strings were modified.\n * @throws Error if evaluation of any field fails.\n */\n public static evaluateFields(args: EvaluateFieldsArgs): number {\n return updateFields(args.block, createUpdateContext(undefined, args.iModel, false))\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,oBAAoB;IAC5D,MAAM,KAAc,SAAS,KAAa,OAAO,6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AK,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({ id: annotationTextStyleId, relClassName });\r\n }\r\n}\r\n"]}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B,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,CAAC,SAAS,KAAK,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,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,CAAC;I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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,q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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\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}"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextAnnotationElement.js","sourceRoot":"","sources":["../../../src/annotations/TextAnnotationElement.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAA4B,WAAW,EAAE,IAAI,EAAwD,eAAe,EAAoD,WAAW,EAAoB,WAAW,EAAoC,cAAc,EAAqE,iBAAiB,EAA0B,0BAA0B,EAAiB,MAAM,oBAAoB,CAAC;AAEjc,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,OAAO,EAAE,kBAAkB,EAAqC,MAAM,YAAY,CAAC;AACpI,OAAO,EAAE,MAAM,EAAE,IAAI,EAAc,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,2BAA2B,EAAE,oCAAoC,EAAkB,MAAM,+BAA+B,CAAC;AAGlI,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC;;;EAGE;AACF,MAAM,CAAC,MAAM,4BAA4B,GAAG,OAAO,CAAC;AAEpD,SAAS,+BAA+B,CACtC,IAAY,EACZ,cAA+B,EAC/B,OAAqC;IAErC,IAAI,MAAM,CAAC;IACX,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAqB,CAAC;IAChD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAC/B,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC;QACvD,MAAM,IAA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AU,CAAC,CAAC;QACpD,OAAO,UAAU,CAAC;IACpB,CAAC;IAES,MAAM,CAAU,KAAK,CAAC,QAAQ,CAAC,OAAkC,EAAE,QAAkC,EAAE,QAAkC;QACjJ,MAAM,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAClD,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC;YAC9B,OAAO;QACT,CAAC;QAED,MAAM,aAAa,GAAG,mBAAmB,CAAC,sBAAsB,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACpF,MAAM,IAAI,GAAG,iBAAiB,CAAC,QAAQ,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC;QAElE,MAAM,YAAY,GAAG,EAAE,CAAC;QACxB,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,sBAAsB,EAAE,EAAE,CAAC;YACnE,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,KAAK,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBACxF,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;QAED,MAAM,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACtG,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 { AnnotationTextStyleProps, BisCodeSpec, Code, CodeProps, CodeScopeProps, CodeSpec, ECVersionString, ElementGeometry, ElementGeometryBuilderParams, EntityReferenceSet, Placement2d, Placement2dProps, Placement3d, Placement3dProps, PlacementProps, TextAnnotation, TextAnnotation2dProps, TextAnnotation3dProps, TextAnnotationProps, TextStyleSettings, TextStyleSettingsProps, traverseTextBlockComponent, VersionedJSON } from \"@itwin/core-common\";\nimport { IModelDb } from \"../IModelDb\";\nimport { AnnotationElement2d, DefinitionElement, Drawing, GraphicalElement3d, OnElementIdArg, OnElementPropsArg } from \"../Element\";\nimport { assert, Id64, Id64String } from \"@itwin/core-bentley\";\nimport { layoutTextBlock, TextStyleResolver } from \"./TextBlockLayout\";\nimport { appendTextAnnotationGeometry } from \"./TextAnnotationGeometry\";\nimport { ElementDrivesTextAnnotation, TextAnnotationUsesTextStyleByDefault, TextBlockAndId } from \"./ElementDrivesTextAnnotation\";\nimport { IModelElementCloneContext } from \"../IModelElementCloneContext\";\nimport { CustomHandledProperty, DeserializeEntityArgs, ECSqlRow } from \"../Entity\";\nimport * as semver from \"semver\";\n\n/** The version of the JSON stored in `TextAnnotation2d/3dProps.textAnnotationData` used by the code.\n * Uses the same semantics as [ECVersion]($ecschema-metadata).\n * @internal\n*/\nexport const TEXT_ANNOTATION_JSON_VERSION = \"1.0.0\";\n\nfunction validateAndMigrateVersionedJSON<T>(\n json: string,\n currentVersion: ECVersionString,\n migrate: (old: VersionedJSON<T>) => T\n): VersionedJSON<T> | undefined {\n let parsed;\n try {\n parsed = JSON.parse(json) as VersionedJSON<T>;\n } catch {\n return undefined;\n }\n\n const version = parsed.version;\n if (typeof version !== \"string\" || !semver.valid(version))\n throw new Error(\"JSON version is missing or invalid.\");\n\n if (typeof parsed.data !== \"object\" || parsed.data === null)\n throw new Error(\"JSON data is missing or invalid.\");\n\n // Newer\n if (semver.gt(version, currentVersion))\n throw new Error(`JSON version ${parsed.version} is newer than supported version ${currentVersion}. Application update required to understand data.`);\n\n // Older\n if (semver.lt(version, currentVersion)) {\n parsed.data = migrate(parsed);\n parsed.version = currentVersion;\n }\n\n return parsed;\n}\n\nfunction migrateTextAnnotationData(oldData: VersionedJSON<TextAnnotationProps>): TextAnnotationProps {\n if (oldData.version === TEXT_ANNOTATION_JSON_VERSION) return oldData.data;\n\n // Place migration logic here.\n\n throw new Error(`Migration for textAnnotationData from version ${oldData.version} to ${TEXT_ANNOTATION_JSON_VERSION} failed.`);\n}\n\n/** Parses, validates, and potentially migrates the text annotation data from a JSON string.\n * @internal\n */\nexport function parseTextAnnotationData(json: string | undefined): VersionedJSON<TextAnnotationProps> | undefined {\n if (!json) return undefined;\n\n return validateAndMigrateVersionedJSON<TextAnnotationProps>(json, TEXT_ANNOTATION_JSON_VERSION, migrateTextAnnotationData);\n}\n\nfunction getElementGeometryBuilderParams(iModel: IModelDb, modelId: Id64String, categoryId: Id64String, _placementProps: PlacementProps, annotationProps?: TextAnnotationProps, textStyleId?: Id64String, _subCategory?: Id64String): ElementGeometryBuilderParams {\n const textBlock = TextAnnotation.fromJSON(annotationProps).textBlock;\n const textStyleResolver = new TextStyleResolver({ textBlock, textStyleId: textStyleId ?? \"\", iModel });\n const layout = layoutTextBlock({ iModel, textBlock, textStyleResolver });\n const builder = new ElementGeometry.Builder();\n let scaleFactor = 1;\n const element = iModel.elements.getElement(modelId);\n if (element instanceof Drawing)\n scaleFactor = element.scaleFactor;\n appendTextAnnotationGeometry({ layout, textStyleResolver, scaleFactor, annotationProps: annotationProps ?? {}, builder, categoryId });\n\n return { entryArray: builder.entries };\n}\n\n/** Arguments supplied when creating a [[TextAnnotation2d]].\n * @beta\n */\nexport interface TextAnnotation2dCreateArgs {\n /** The category ID for the annotation. */\n category: Id64String;\n /** The model ID where the annotation will be placed. */\n model: Id64String;\n /** The placement properties for the annotation. */\n placement: Placement2dProps;\n /** The default text style ID for the annotation. */\n defaultTextStyleId?: Id64String;\n /** Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation2d`. Essentially an empty element if not provided. */\n textAnnotationProps?: TextAnnotationProps;\n /** Optional code for the element. */\n code?: CodeProps;\n}\n\n/** Arguments supplied when creating a [[TextAnnotation3d]].\n * @beta\n */\nexport interface TextAnnotation3dCreateArgs {\n /** The category ID for the annotation. */\n category: Id64String;\n /** The model ID where the annotation will be placed. */\n model: Id64String;\n /** The placement properties for the annotation. */\n placement: Placement3dProps;\n /** The default text style ID for the annotation. */\n defaultTextStyleId?: Id64String;\n /** Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation3d`. Essentially an empty element if not provided. */\n textAnnotationProps?: TextAnnotationProps;\n /** Optional code for the element. */\n code?: CodeProps;\n}\n\n/** An element that displays textual content within a 2d model.\n * The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.\n * @see [[setAnnotation]] to change the textual content.\n * @public @preview\n */\nexport class TextAnnotation2d extends AnnotationElement2d /* implements ITextAnnotation */ {\n /** @internal */\n public static override get className(): string { return \"TextAnnotation2d\"; }\n /**\n * The default [[AnnotationTextStyle]] used by the TextAnnotation2d.\n * @beta\n */\n public defaultTextStyle?: TextAnnotationUsesTextStyleByDefault;\n /** The data associated with the text annotation. */\n private _textAnnotationProps?: TextAnnotationProps;\n\n /** Extract the textual content, if present.\n * @see [[setAnnotation]] to change it.\n */\n public getAnnotation(): TextAnnotation | undefined {\n return this._textAnnotationProps ? TextAnnotation.fromJSON(this._textAnnotationProps) : undefined;\n }\n\n /** Change the textual content of the `TextAnnotation2d`.\n * @see [[getAnnotation]] to extract the current annotation.\n * @param annotation The new annotation\n */\n public setAnnotation(annotation: TextAnnotation) {\n this._textAnnotationProps = annotation.toJSON();\n }\n\n protected constructor(props: TextAnnotation2dProps, iModel: IModelDb) {\n super(props, iModel);\n if (props.defaultTextStyle) {\n this.defaultTextStyle = new TextAnnotationUsesTextStyleByDefault(props.defaultTextStyle.id);\n }\n this._textAnnotationProps = parseTextAnnotationData(props.textAnnotationData)?.data;\n }\n\n /** Creates a new instance of `TextAnnotation2d` from its JSON representation. */\n public static fromJSON(props: TextAnnotation2dProps, iModel: IModelDb): TextAnnotation2d {\n return new TextAnnotation2d(props, iModel);\n }\n\n /**\n * Converts the current `TextAnnotation2d` instance to its JSON representation.\n * It also computes the `elementGeometryBuilderParams` property used to create the GeometryStream.\n * @inheritdoc\n */\n public override toJSON(): TextAnnotation2dProps {\n const props = super.toJSON() as TextAnnotation2dProps;\n props.textAnnotationData = this._textAnnotationProps ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: this._textAnnotationProps }) : undefined;\n if (this._textAnnotationProps) {\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(this.iModel, this.model, this.category, this.placement, this._textAnnotationProps, this.defaultTextStyle ? this.defaultTextStyle.id : undefined);\n }\n\n return props;\n }\n\n /** Creates a new `TextAnnotation2d` instance with the specified properties.\n * @param iModelDb The iModel.\n * @param arg The arguments for creating the TextAnnotation2d.\n * @beta\n */\n public static create(iModelDb: IModelDb, arg: TextAnnotation2dCreateArgs): TextAnnotation2d {\n const elementProps: TextAnnotation2dProps = {\n classFullName: this.classFullName,\n textAnnotationData: arg.textAnnotationProps ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: arg.textAnnotationProps }) : undefined,\n defaultTextStyle: arg.defaultTextStyleId ? new TextAnnotationUsesTextStyleByDefault(arg.defaultTextStyleId).toJSON() : undefined,\n placement: arg.placement,\n model: arg.model,\n category: arg.category,\n code: arg.code ?? Code.createEmpty(),\n };\n return new this(elementProps, iModelDb);\n }\n\n /**\n * Updates the geometry of the TextAnnotation2d on insert and validates version.\n * @inheritdoc\n * @beta\n */\n protected static override onInsert(arg: OnElementPropsArg): void {\n super.onInsert(arg);\n this.validateVersionAndUpdateGeometry(arg);\n }\n\n /**\n * Updates the geometry of the TextAnnotation2d on update and validates version.\n * @inheritdoc\n * @beta\n */\n protected static override onUpdate(arg: OnElementPropsArg): void {\n super.onUpdate(arg);\n this.validateVersionAndUpdateGeometry(arg);\n }\n\n /**\n * Populates the `elementGeometryBuilderParams` property in the [TextAnnotation2dProps]($common).\n * Only does this if the `elementGeometryBuilderParams` is not already set and if there is actually a text annotation to produce geometry for.\n * Also, validates the version of the text annotation data and migrates it if necessary.\n * @beta\n */\n protected static validateVersionAndUpdateGeometry(arg: OnElementPropsArg): void {\n const props = arg.props as TextAnnotation2dProps;\n const textAnnotationData = parseTextAnnotationData(props.textAnnotationData);\n if (!props.elementGeometryBuilderParams && textAnnotationData) {\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(arg.iModel, props.model, props.category, props.placement ?? Placement2d.fromJSON(), textAnnotationData.data, props.defaultTextStyle?.id);\n }\n }\n\n /**\n * TextAnnotation2d custom HandledProps include 'textAnnotationData'.\n * @inheritdoc\n * @internal\n */\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"textAnnotationData\", source: \"Class\" },\n ];\n\n /**\n * TextAnnotation2d deserializes 'textAnnotationData'.\n * @inheritdoc\n * @beta\n */\n public static override deserialize(props: DeserializeEntityArgs): TextAnnotation2dProps {\n const elProps = super.deserialize(props) as TextAnnotation2dProps;\n const textAnnotationData = parseTextAnnotationData(props.row.textAnnotationData);\n if (textAnnotationData) {\n elProps.textAnnotationData = JSON.stringify(textAnnotationData);\n }\n return elProps;\n }\n\n /**\n * TextAnnotation2d serializes 'textAnnotationData'.\n * @inheritdoc\n * @beta\n */\n public static override serialize(props: TextAnnotation2dProps, iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, iModel);\n if (props.textAnnotationData !== undefined) {\n inst.textAnnotationData = props.textAnnotationData;\n }\n return inst;\n }\n\n /** @internal */\n public getTextBlocks(): Iterable<TextBlockAndId> {\n return getTextBlocks(this);\n }\n\n /** @internal */\n public updateTextBlocks(textBlocks: TextBlockAndId[]): void {\n return updateTextBlocks(this, textBlocks);\n }\n\n /** @internal */\n public static override onInserted(arg: OnElementIdArg): void {\n super.onInserted(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n\n /** @internal */\n public static override onUpdated(arg: OnElementIdArg): void {\n super.onUpdated(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\n super.collectReferenceIds(referenceIds);\n collectReferenceIds(this, referenceIds);\n }\n\n /** @internal */\n protected static override async onCloned(context: IModelElementCloneContext, srcProps: TextAnnotation2dProps, dstProps: TextAnnotation2dProps): Promise<void> {\n await super.onCloned(context, srcProps, dstProps);\n\n const srcElem = TextAnnotation2d.fromJSON(srcProps, context.sourceDb);\n ElementDrivesTextAnnotation.remapFields(srcElem, context);\n const anno = srcElem.getAnnotation();\n dstProps.textAnnotationData = anno ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: anno.toJSON() }) : undefined;\n\n return remapTextStyle(context, srcElem, dstProps);\n }\n}\n\n/** An element that displays textual content within a 3d model.\n * The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.\n * @see [[setAnnotation]] to change the textual content.\n * @public @preview\n */\nexport class TextAnnotation3d extends GraphicalElement3d /* implements ITextAnnotation */ {\n /** @internal */\n public static override get className(): string { return \"TextAnnotation3d\"; }\n /**\n * The default [[AnnotationTextStyle]] used by the TextAnnotation3d.\n * @beta\n */\n public defaultTextStyle?: TextAnnotationUsesTextStyleByDefault;\n /** The data associated with the text annotation. */\n private _textAnnotationProps?: TextAnnotationProps;\n\n /** Extract the textual content, if present.\n * @see [[setAnnotation]] to change it.\n */\n public getAnnotation(): TextAnnotation | undefined {\n return this._textAnnotationProps ? TextAnnotation.fromJSON(this._textAnnotationProps) : undefined;\n }\n\n /** Change the textual content of the `TextAnnotation3d`.\n * @see [[getAnnotation]] to extract the current annotation.\n * @param annotation The new annotation\n */\n public setAnnotation(annotation: TextAnnotation) {\n this._textAnnotationProps = annotation.toJSON();\n }\n\n protected constructor(props: TextAnnotation3dProps, iModel: IModelDb) {\n super(props, iModel);\n if (props.defaultTextStyle) {\n this.defaultTextStyle = new TextAnnotationUsesTextStyleByDefault(props.defaultTextStyle.id);\n }\n this._textAnnotationProps = parseTextAnnotationData(props.textAnnotationData)?.data;\n }\n\n /** Creates a new instance of `TextAnnotation3d` from its JSON representation. */\n public static fromJSON(props: TextAnnotation3dProps, iModel: IModelDb): TextAnnotation3d {\n return new TextAnnotation3d(props, iModel);\n }\n\n /**\n * Converts the current `TextAnnotation3d` instance to its JSON representation.\n * It also computes the `elementGeometryBuilderParams` property used to create the GeometryStream.\n * @inheritdoc\n */\n public override toJSON(): TextAnnotation3dProps {\n const props = super.toJSON() as TextAnnotation3dProps;\n props.textAnnotationData = this._textAnnotationProps ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: this._textAnnotationProps }) : undefined;\n if (this._textAnnotationProps) {\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(this.iModel, this.model, this.category, this.placement, this._textAnnotationProps, this.defaultTextStyle ? this.defaultTextStyle.id : undefined);\n }\n\n return props;\n }\n\n /** Creates a new `TextAnnotation3d` instance with the specified properties.\n * @param iModelDb The iModel.\n * @param arg The arguments for creating the TextAnnotation3d.\n * @beta\n */\n public static create(iModelDb: IModelDb, arg: TextAnnotation3dCreateArgs): TextAnnotation3d {\n const elementProps: TextAnnotation3dProps = {\n classFullName: this.classFullName,\n textAnnotationData: arg.textAnnotationProps ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: arg.textAnnotationProps }) : undefined,\n defaultTextStyle: arg.defaultTextStyleId ? new TextAnnotationUsesTextStyleByDefault(arg.defaultTextStyleId).toJSON() : undefined,\n placement: arg.placement,\n model: arg.model,\n category: arg.category,\n code: arg.code ?? Code.createEmpty(),\n };\n return new this(elementProps, iModelDb);\n }\n\n /**\n * Updates the geometry of the TextAnnotation3d on insert and validates version..\n * @inheritdoc\n * @beta\n */\n protected static override onInsert(arg: OnElementPropsArg): void {\n super.onInsert(arg);\n this.validateVersionAndUpdateGeometry(arg);\n }\n\n /**\n * Updates the geometry of the TextAnnotation3d on update and validates version..\n * @inheritdoc\n * @beta\n */\n protected static override onUpdate(arg: OnElementPropsArg): void {\n super.onUpdate(arg);\n this.validateVersionAndUpdateGeometry(arg);\n }\n\n /**\n * Populates the `elementGeometryBuilderParams` property in the [TextAnnotation3dProps]($common).\n * Only does this if the `elementGeometryBuilderParams` is not already set and if there is actually a text annotation to produce geometry for.\n * Also, validates the version of the text annotation data and migrates it if necessary.\n * @beta\n */\n protected static validateVersionAndUpdateGeometry(arg: OnElementPropsArg): void {\n const props = arg.props as TextAnnotation3dProps;\n const textAnnotationData = parseTextAnnotationData(props.textAnnotationData);\n if (!props.elementGeometryBuilderParams && textAnnotationData) {\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(arg.iModel, props.model, props.category, props.placement ?? Placement3d.fromJSON(), textAnnotationData.data, props.defaultTextStyle?.id);\n }\n }\n\n /**\n * TextAnnotation3d custom HandledProps include 'textAnnotationData'.\n * @inheritdoc\n * @internal\n */\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"textAnnotationData\", source: \"Class\" },\n ];\n\n /**\n * TextAnnotation3d deserializes 'textAnnotationData'.\n * @inheritdoc\n * @beta\n */\n public static override deserialize(props: DeserializeEntityArgs): TextAnnotation3dProps {\n const elProps = super.deserialize(props) as TextAnnotation3dProps;\n const textAnnotationData = parseTextAnnotationData(props.row.textAnnotationData);\n if (textAnnotationData) {\n elProps.textAnnotationData = JSON.stringify(textAnnotationData);\n }\n return elProps;\n }\n\n /**\n * TextAnnotation3d serializes 'textAnnotationData'.\n * @inheritdoc\n * @beta\n */\n public static override serialize(props: TextAnnotation3dProps, iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, iModel);\n if (props.textAnnotationData !== undefined) {\n inst.textAnnotationData = props.textAnnotationData;\n }\n return inst;\n }\n\n /** @internal */\n public getTextBlocks(): Iterable<TextBlockAndId> {\n return getTextBlocks(this);\n }\n\n /** @internal */\n public updateTextBlocks(textBlocks: TextBlockAndId[]): void {\n return updateTextBlocks(this, textBlocks);\n }\n\n /** @internal */\n public static override onInserted(arg: OnElementIdArg): void {\n super.onInserted(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n\n /** @internal */\n public static override onUpdated(arg: OnElementIdArg): void {\n super.onUpdated(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\n super.collectReferenceIds(referenceIds);\n collectReferenceIds(this, referenceIds);\n }\n\n /** @internal */\n protected static override async onCloned(context: IModelElementCloneContext, srcProps: TextAnnotation3dProps, dstProps: TextAnnotation3dProps): Promise<void> {\n await super.onCloned(context, srcProps, dstProps);\n\n const srcElem = TextAnnotation3d.fromJSON(srcProps, context.sourceDb);\n ElementDrivesTextAnnotation.remapFields(srcElem, context);\n const anno = srcElem.getAnnotation();\n dstProps.textAnnotationData = anno ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: anno.toJSON() }) : undefined;\n\n return remapTextStyle(context, srcElem, dstProps);\n }\n}\n\nasync function remapTextStyle(\n context: IModelElementCloneContext,\n srcElem: TextAnnotation2d | TextAnnotation3d,\n dstProps: TextAnnotation2dProps | TextAnnotation3dProps\n): Promise<void> {\n const dstStyleId = await AnnotationTextStyle.remapTextStyleId(srcElem.defaultTextStyle?.id ?? Id64.invalid, context);\n dstProps.defaultTextStyle = Id64.isValid(dstStyleId) ? new TextAnnotationUsesTextStyleByDefault(dstStyleId).toJSON() : undefined;\n}\n\nfunction collectReferenceIds(elem: TextAnnotation2d | TextAnnotation3d, referenceIds: EntityReferenceSet): void {\n const style = elem.defaultTextStyle?.id;\n if (style && Id64.isValidId64(style)) {\n referenceIds.addElement(style);\n }\n\n const block = elem.getAnnotation()?.textBlock;\n if (block) {\n for (const { child } of traverseTextBlockComponent(block)) {\n if (child.type === \"field\") {\n const hostId = child.propertyHost.elementId;\n if (Id64.isValidId64(hostId)) {\n referenceIds.addElement(hostId);\n }\n }\n }\n }\n}\n\nfunction getTextBlocks(elem: TextAnnotation2d | TextAnnotation3d): Iterable<TextBlockAndId> {\n const annotation = elem.getAnnotation();\n return annotation ? [{ textBlock: annotation.textBlock, id: undefined }] : [];\n}\n\nfunction updateTextBlocks(elem: TextAnnotation2d | TextAnnotation3d, textBlocks: TextBlockAndId[]): void {\n assert(textBlocks.length === 1);\n assert(textBlocks[0].id === undefined);\n\n const annotation = elem.getAnnotation();\n if (!annotation) {\n // We must obtain the TextBlockAndId from the element in the first place, so the only way we could end up here is if\n // somebody removed the text annotation after we called getTextBlocks. That's gotta be a mistake.\n throw new Error(\"Text annotation element has no text\");\n }\n\n annotation.textBlock = textBlocks[0].textBlock;\n\n elem.setAnnotation(annotation);\n}\n\n/** The version of the JSON stored in `AnnotationTextStyleProps.settings` used by the code.\n * Uses the same semantics as [ECVersion]($ecschema-metadata).\n * @internal\n*/\n// 1.0.1 - Added terminatorShapes for leaders\nexport const TEXT_STYLE_SETTINGS_JSON_VERSION = \"1.0.1\";\n\nfunction migrateTextStyleSettings(oldData: VersionedJSON<TextStyleSettingsProps>): TextStyleSettingsProps {\n if (oldData.version === TEXT_STYLE_SETTINGS_JSON_VERSION) return oldData.data;\n\n // Migrate from 1.0.0 to 1.0.1\n if (oldData.data.leader && !oldData.data.leader.terminatorShape) {\n oldData.data.leader.terminatorShape = TextStyleSettings.defaultProps.leader.terminatorShape;\n }\n return oldData.data;\n\n}\n\n/** Arguments supplied when creating an [[AnnotationTextStyle]].\n * @beta\n */\nexport interface TextStyleCreateArgs {\n /** The ID of the [[DefinitionModel]]. */\n definitionModelId: Id64String;\n /** The name to assign to the [[AnnotationTextStyle]]. */\n name: string;\n /** Optional text style settings used to create the [[AnnotationTextStyle]]. Default settings will be used if not provided. */\n settings?: TextStyleSettingsProps;\n /** Optional description for the [[AnnotationTextStyle]]. */\n description?: string;\n}\n\n/**\n * The definition element that holds text style information.\n * The style is stored as a [TextStyleSettings]($common).\n * @beta\n */\nexport class AnnotationTextStyle extends DefinitionElement {\n /** @internal */\n public static override get className(): string { return \"AnnotationTextStyle\"; }\n /**\n * Optional text describing the `AnnotationTextStyle`.\n */\n public description?: string;\n /**\n * The text style settings for the `AnnotationTextStyle`.\n * @see [[TextStyleSettings]] for more information.\n */\n public settings: TextStyleSettings;\n\n protected constructor(props: AnnotationTextStyleProps, iModel: IModelDb) {\n super(props, iModel);\n this.description = props.description;\n const settingsProps = AnnotationTextStyle.parseTextStyleSettings(props.settings);\n this.settings = TextStyleSettings.fromJSON(settingsProps?.data);\n }\n\n /**\n * Creates a Code for an `AnnotationTextStyle` given a name that is meant to be unique within the scope of the specified DefinitionModel.\n *\n * @param iModel - The IModelDb.\n * @param definitionModelId - The ID of the DefinitionModel that contains the AnnotationTextStyle and provides the scope for its name.\n * @param name - The AnnotationTextStyle name.\n * @beta\n */\n public static createCode(iModel: IModelDb, definitionModelId: CodeScopeProps, name: string): Code {\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.annotationTextStyle);\n return new Code({ spec: codeSpec.id, scope: definitionModelId, value: name });\n }\n\n /**\n * Creates a new instance of `AnnotationTextStyle` with the specified properties.\n *\n * @param iModelDb - The iModelDb.\n * @param arg - The arguments for creating the AnnotationTextStyle.\n * @beta\n */\n public static create(iModelDb: IModelDb, arg: TextStyleCreateArgs): AnnotationTextStyle {\n const props: AnnotationTextStyleProps = {\n classFullName: this.classFullName,\n model: arg.definitionModelId,\n code: this.createCode(iModelDb, arg.definitionModelId, arg.name).toJSON(),\n description: arg.description,\n settings: arg.settings ? JSON.stringify({ version: TEXT_STYLE_SETTINGS_JSON_VERSION, data: arg.settings }) : undefined,\n }\n return new this(props, iModelDb);\n }\n\n /**\n * Converts the current `AnnotationTextStyle` instance to its JSON representation.\n * @inheritdoc\n */\n public override toJSON(): AnnotationTextStyleProps {\n const props = super.toJSON() as AnnotationTextStyleProps;\n props.description = this.description;\n props.settings = JSON.stringify({ version: TEXT_STYLE_SETTINGS_JSON_VERSION, data: this.settings.toJSON() });\n return props;\n }\n\n /** Creates a new instance of `AnnotationTextStyle` from its JSON representation. */\n public static fromJSON(props: AnnotationTextStyleProps, iModel: IModelDb): AnnotationTextStyle {\n return new AnnotationTextStyle(props, iModel);\n }\n\n /**\n * Validates that the AnnotationTextStyle's settings are valid before insert.\n * @inheritdoc\n * @beta\n */\n protected static override onInsert(arg: OnElementPropsArg): void {\n super.onInsert(arg);\n this.validateSettings(arg.props as AnnotationTextStyleProps);\n }\n\n /**\n * Validates that the AnnotationTextStyle's settings are valid before update.\n * @inheritdoc\n * @beta\n */\n protected static override onUpdate(arg: OnElementPropsArg): void {\n super.onUpdate(arg);\n this.validateSettings(arg.props as AnnotationTextStyleProps);\n }\n\n private static validateSettings(props: AnnotationTextStyleProps): void {\n const settingProps = AnnotationTextStyle.parseTextStyleSettings(props.settings);\n if (!settingProps) return;\n const settings = TextStyleSettings.fromJSON(settingProps.data);\n const errors = settings.getValidationErrors();\n if (errors.length > 0) {\n throw new Error(`Invalid AnnotationTextStyle settings: ${errors.join(\", \")}`);\n }\n }\n\n /**\n * AnnotationTextStyle custom HandledProps include 'settings'.\n * @inheritdoc\n * @beta\n */\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"settings\", source: \"Class\" },\n ];\n\n /**\n * AnnotationTextStyle deserializes 'settings'.\n * @inheritdoc\n * @beta\n */\n public static override deserialize(props: DeserializeEntityArgs): AnnotationTextStyleProps {\n const elProps = super.deserialize(props) as AnnotationTextStyleProps;\n const settings = this.parseTextStyleSettings(props.row.settings);\n if (settings) {\n elProps.settings = JSON.stringify(settings);\n }\n return elProps;\n }\n\n /**\n * AnnotationTextStyle serializes 'settings'.\n * @inheritdoc\n * @beta\n */\n public static override serialize(props: AnnotationTextStyleProps, iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, iModel);\n if (props.settings !== undefined) {\n inst.settings = props.settings;\n }\n return inst;\n }\n\n /** Parses, validates, and potentially migrates the text style settings data from a JSON string. */\n private static parseTextStyleSettings(json: string | undefined): VersionedJSON<TextStyleSettingsProps> | undefined {\n if (!json) return undefined;\n return validateAndMigrateVersionedJSON<TextStyleSettingsProps>(json, TEXT_STYLE_SETTINGS_JSON_VERSION, migrateTextStyleSettings);\n }\n\n /** When copying an element from one iModel to another, returns the Id of the AnnotationTextStyle in the `context`'s target iModel\n * corresponding to `sourceTextStyleId`, or [Id64.invalid]($bentley) if no corresponding text style exists.\n * If a text style with the same [Code]($common) exists in the target iModel, the style Id will be remapped to refer to that style.\n * Otherwise, a copy of the style will be imported into the target iModel and its element Id returned.\n * Implementations of [[ITextAnnotation]] should invoke this function when implementing their [[Element.onCloned]] method.\n * @throws Error if an attempt to import the text style failed.\n */\n public static async remapTextStyleId(sourceTextStyleId: Id64String, context: IModelElementCloneContext): Promise<Id64String> {\n // No remapping necessary if there's no text style or we're not copying to a different iModel.\n if (!Id64.isValid(sourceTextStyleId) || !context.isBetweenIModels) {\n return sourceTextStyleId;\n }\n\n // If the style's already been remapped, we're finished.\n let dstStyleId: Id64String | undefined = context.findTargetElementId(sourceTextStyleId);\n if (Id64.isValid(dstStyleId)) {\n return dstStyleId;\n }\n\n // Look up the style. It really ought to exist.\n const srcStyle = context.sourceDb.elements.tryGetElement<AnnotationTextStyle>(sourceTextStyleId);\n if (!srcStyle) {\n return Id64.invalid;\n }\n\n // If a style with the same code exists in the target iModel, remap to that one.\n dstStyleId = context.targetDb.elements.queryElementIdByCode(srcStyle.code);\n if (undefined !== dstStyleId) {\n return dstStyleId;\n }\n\n // Copy the style into the target iModel and remap its Id.\n const dstStyleProps = await context.cloneElement(srcStyle);\n dstStyleId = context.targetDb.elements.insertElement(dstStyleProps);\n context.remapElement(sourceTextStyleId, dstStyleId);\n return dstStyleId;\n }\n\n protected static override async onCloned(context: IModelElementCloneContext, srcProps: AnnotationTextStyleProps, dstProps: AnnotationTextStyleProps): Promise<void> {\n await super.onCloned(context, srcProps, dstProps);\n if (!context.isBetweenIModels) {\n return;\n }\n\n const settingsProps = AnnotationTextStyle.parseTextStyleSettings(srcProps.settings);\n const font = TextStyleSettings.fromJSON(settingsProps?.data).font;\n\n const fontsToEmbed = [];\n for (const file of context.sourceDb.fonts.queryEmbeddedFontFiles()) {\n if (file.type === font.type && file.faces.some((face) => face.familyName === font.name)) {\n fontsToEmbed.push(file);\n }\n }\n\n await Promise.all(fontsToEmbed.map(async (file) => context.targetDb.fonts.embedFontFile({ file })));\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TextAnnotationElement.js","sourceRoot":"","sources":["../../../src/annotations/TextAnnotationElement.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAA4B,WAAW,EAAE,IAAI,EAAwD,eAAe,EAAoD,WAAW,EAAoB,WAAW,EAAoC,cAAc,EAAqE,iBAAiB,EAA0B,0BAA0B,EAAiB,MAAM,oBAAoB,CAAC;AAEjc,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,OAAO,EAAE,kBAAkB,EAAqC,MAAM,YAAY,CAAC;AACpI,OAAO,EAAE,MAAM,EAAE,IAAI,EAAc,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,2BAA2B,EAAE,oCAAoC,EAAkB,MAAM,+BAA+B,CAAC;AAGlI,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC;;;EAGE;AACF,MAAM,CAAC,MAAM,4BAA4B,GAAG,OAAO,CAAC;AAEpD,SAAS,+BAA+B,CACtC,IAAY,EACZ,cAA+B,EAC/B,OAAqC;IAErC,IAAI,MAAM,CAAC;IACX,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IA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E,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACtG,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 { AnnotationTextStyleProps, BisCodeSpec, Code, CodeProps, CodeScopeProps, CodeSpec, ECVersionString, ElementGeometry, ElementGeometryBuilderParams, EntityReferenceSet, Placement2d, Placement2dProps, Placement3d, Placement3dProps, PlacementProps, TextAnnotation, TextAnnotation2dProps, TextAnnotation3dProps, TextAnnotationProps, TextStyleSettings, TextStyleSettingsProps, traverseTextBlockComponent, VersionedJSON } from \"@itwin/core-common\";\r\nimport { IModelDb } from \"../IModelDb\";\r\nimport { AnnotationElement2d, DefinitionElement, Drawing, GraphicalElement3d, OnElementIdArg, OnElementPropsArg } from \"../Element\";\r\nimport { assert, Id64, Id64String } from \"@itwin/core-bentley\";\r\nimport { layoutTextBlock, TextStyleResolver } from \"./TextBlockLayout\";\r\nimport { appendTextAnnotationGeometry } from \"./TextAnnotationGeometry\";\r\nimport { ElementDrivesTextAnnotation, TextAnnotationUsesTextStyleByDefault, TextBlockAndId } from \"./ElementDrivesTextAnnotation\";\r\nimport { IModelElementCloneContext } from \"../IModelElementCloneContext\";\r\nimport { CustomHandledProperty, DeserializeEntityArgs, ECSqlRow } from \"../Entity\";\r\nimport * as semver from \"semver\";\r\n\r\n/** The version of the JSON stored in `TextAnnotation2d/3dProps.textAnnotationData` used by the code.\r\n * Uses the same semantics as [ECVersion]($ecschema-metadata).\r\n * @internal\r\n*/\r\nexport const TEXT_ANNOTATION_JSON_VERSION = \"1.0.0\";\r\n\r\nfunction validateAndMigrateVersionedJSON<T>(\r\n json: string,\r\n currentVersion: ECVersionString,\r\n migrate: (old: VersionedJSON<T>) => T\r\n): VersionedJSON<T> | undefined {\r\n let parsed;\r\n try {\r\n parsed = JSON.parse(json) as VersionedJSON<T>;\r\n } catch {\r\n return undefined;\r\n }\r\n\r\n const version = parsed.version;\r\n if (typeof version !== \"string\" || !semver.valid(version))\r\n throw new Error(\"JSON version is missing or invalid.\");\r\n\r\n if (typeof parsed.data !== \"object\" || parsed.data === null)\r\n throw new Error(\"JSON data is missing or invalid.\");\r\n\r\n // Newer\r\n if (semver.gt(version, currentVersion))\r\n throw new Error(`JSON version ${parsed.version} is newer than supported version ${currentVersion}. Application update required to understand data.`);\r\n\r\n // Older\r\n if (semver.lt(version, currentVersion)) {\r\n parsed.data = migrate(parsed);\r\n parsed.version = currentVersion;\r\n }\r\n\r\n return parsed;\r\n}\r\n\r\nfunction migrateTextAnnotationData(oldData: VersionedJSON<TextAnnotationProps>): TextAnnotationProps {\r\n if (oldData.version === TEXT_ANNOTATION_JSON_VERSION) return oldData.data;\r\n\r\n // Place migration logic here.\r\n\r\n throw new Error(`Migration for textAnnotationData from version ${oldData.version} to ${TEXT_ANNOTATION_JSON_VERSION} failed.`);\r\n}\r\n\r\n/** Parses, validates, and potentially migrates the text annotation data from a JSON string.\r\n * @internal\r\n */\r\nexport function parseTextAnnotationData(json: string | undefined): VersionedJSON<TextAnnotationProps> | undefined {\r\n if (!json) return undefined;\r\n\r\n return validateAndMigrateVersionedJSON<TextAnnotationProps>(json, TEXT_ANNOTATION_JSON_VERSION, migrateTextAnnotationData);\r\n}\r\n\r\nfunction getElementGeometryBuilderParams(iModel: IModelDb, modelId: Id64String, categoryId: Id64String, _placementProps: PlacementProps, annotationProps?: TextAnnotationProps, textStyleId?: Id64String, _subCategory?: Id64String): ElementGeometryBuilderParams {\r\n const textBlock = TextAnnotation.fromJSON(annotationProps).textBlock;\r\n const textStyleResolver = new TextStyleResolver({ textBlock, textStyleId: textStyleId ?? \"\", iModel });\r\n const layout = layoutTextBlock({ iModel, textBlock, textStyleResolver });\r\n const builder = new ElementGeometry.Builder();\r\n let scaleFactor = 1;\r\n const element = iModel.elements.getElement(modelId);\r\n if (element instanceof Drawing)\r\n scaleFactor = element.scaleFactor;\r\n appendTextAnnotationGeometry({ layout, textStyleResolver, scaleFactor, annotationProps: annotationProps ?? {}, builder, categoryId });\r\n\r\n return { entryArray: builder.entries };\r\n}\r\n\r\n/** Arguments supplied when creating a [[TextAnnotation2d]].\r\n * @beta\r\n */\r\nexport interface TextAnnotation2dCreateArgs {\r\n /** The category ID for the annotation. */\r\n category: Id64String;\r\n /** The model ID where the annotation will be placed. */\r\n model: Id64String;\r\n /** The placement properties for the annotation. */\r\n placement: Placement2dProps;\r\n /** The default text style ID for the annotation. */\r\n defaultTextStyleId?: Id64String;\r\n /** Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation2d`. Essentially an empty element if not provided. */\r\n textAnnotationProps?: TextAnnotationProps;\r\n /** Optional code for the element. */\r\n code?: CodeProps;\r\n}\r\n\r\n/** Arguments supplied when creating a [[TextAnnotation3d]].\r\n * @beta\r\n */\r\nexport interface TextAnnotation3dCreateArgs {\r\n /** The category ID for the annotation. */\r\n category: Id64String;\r\n /** The model ID where the annotation will be placed. */\r\n model: Id64String;\r\n /** The placement properties for the annotation. */\r\n placement: Placement3dProps;\r\n /** The default text style ID for the annotation. */\r\n defaultTextStyleId?: Id64String;\r\n /** Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation3d`. Essentially an empty element if not provided. */\r\n textAnnotationProps?: TextAnnotationProps;\r\n /** Optional code for the element. */\r\n code?: CodeProps;\r\n}\r\n\r\n/** An element that displays textual content within a 2d model.\r\n * The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.\r\n * @see [[setAnnotation]] to change the textual content.\r\n * @public @preview\r\n */\r\nexport class TextAnnotation2d extends AnnotationElement2d /* implements ITextAnnotation */ {\r\n /** @internal */\r\n public static override get className(): string { return \"TextAnnotation2d\"; }\r\n /**\r\n * The default [[AnnotationTextStyle]] used by the TextAnnotation2d.\r\n * @beta\r\n */\r\n public defaultTextStyle?: TextAnnotationUsesTextStyleByDefault;\r\n /** The data associated with the text annotation. */\r\n private _textAnnotationProps?: TextAnnotationProps;\r\n\r\n /** Extract the textual content, if present.\r\n * @see [[setAnnotation]] to change it.\r\n */\r\n public getAnnotation(): TextAnnotation | undefined {\r\n return this._textAnnotationProps ? TextAnnotation.fromJSON(this._textAnnotationProps) : undefined;\r\n }\r\n\r\n /** Change the textual content of the `TextAnnotation2d`.\r\n * @see [[getAnnotation]] to extract the current annotation.\r\n * @param annotation The new annotation\r\n */\r\n public setAnnotation(annotation: TextAnnotation) {\r\n this._textAnnotationProps = annotation.toJSON();\r\n }\r\n\r\n protected constructor(props: TextAnnotation2dProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n if (props.defaultTextStyle) {\r\n this.defaultTextStyle = new TextAnnotationUsesTextStyleByDefault(props.defaultTextStyle.id);\r\n }\r\n this._textAnnotationProps = parseTextAnnotationData(props.textAnnotationData)?.data;\r\n }\r\n\r\n /** Creates a new instance of `TextAnnotation2d` from its JSON representation. */\r\n public static fromJSON(props: TextAnnotation2dProps, iModel: IModelDb): TextAnnotation2d {\r\n return new TextAnnotation2d(props, iModel);\r\n }\r\n\r\n /**\r\n * Converts the current `TextAnnotation2d` instance to its JSON representation.\r\n * It also computes the `elementGeometryBuilderParams` property used to create the GeometryStream.\r\n * @inheritdoc\r\n */\r\n public override toJSON(): TextAnnotation2dProps {\r\n const props = super.toJSON() as TextAnnotation2dProps;\r\n props.textAnnotationData = this._textAnnotationProps ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: this._textAnnotationProps }) : undefined;\r\n if (this._textAnnotationProps) {\r\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(this.iModel, this.model, this.category, this.placement, this._textAnnotationProps, this.defaultTextStyle ? this.defaultTextStyle.id : undefined);\r\n }\r\n\r\n return props;\r\n }\r\n\r\n /** Creates a new `TextAnnotation2d` instance with the specified properties.\r\n * @param iModelDb The iModel.\r\n * @param arg The arguments for creating the TextAnnotation2d.\r\n * @beta\r\n */\r\n public static create(iModelDb: IModelDb, arg: TextAnnotation2dCreateArgs): TextAnnotation2d {\r\n const elementProps: TextAnnotation2dProps = {\r\n classFullName: this.classFullName,\r\n textAnnotationData: arg.textAnnotationProps ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: arg.textAnnotationProps }) : undefined,\r\n defaultTextStyle: arg.defaultTextStyleId ? new TextAnnotationUsesTextStyleByDefault(arg.defaultTextStyleId).toJSON() : undefined,\r\n placement: arg.placement,\r\n model: arg.model,\r\n category: arg.category,\r\n code: arg.code ?? Code.createEmpty(),\r\n };\r\n return new this(elementProps, iModelDb);\r\n }\r\n\r\n /**\r\n * Updates the geometry of the TextAnnotation2d on insert and validates version.\r\n * @inheritdoc\r\n * @beta\r\n */\r\n protected static override onInsert(arg: OnElementPropsArg): void {\r\n super.onInsert(arg);\r\n this.validateVersionAndUpdateGeometry(arg);\r\n }\r\n\r\n /**\r\n * Updates the geometry of the TextAnnotation2d on update and validates version.\r\n * @inheritdoc\r\n * @beta\r\n */\r\n protected static override onUpdate(arg: OnElementPropsArg): void {\r\n super.onUpdate(arg);\r\n this.validateVersionAndUpdateGeometry(arg);\r\n }\r\n\r\n /**\r\n * Populates the `elementGeometryBuilderParams` property in the [TextAnnotation2dProps]($common).\r\n * Only does this if the `elementGeometryBuilderParams` is not already set and if there is actually a text annotation to produce geometry for.\r\n * Also, validates the version of the text annotation data and migrates it if necessary.\r\n * @beta\r\n */\r\n protected static validateVersionAndUpdateGeometry(arg: OnElementPropsArg): void {\r\n const props = arg.props as TextAnnotation2dProps;\r\n const textAnnotationData = parseTextAnnotationData(props.textAnnotationData);\r\n if (!props.elementGeometryBuilderParams && textAnnotationData) {\r\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(arg.iModel, props.model, props.category, props.placement ?? Placement2d.fromJSON(), textAnnotationData.data, props.defaultTextStyle?.id);\r\n }\r\n }\r\n\r\n /**\r\n * TextAnnotation2d custom HandledProps include 'textAnnotationData'.\r\n * @inheritdoc\r\n * @internal\r\n */\r\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\r\n { propertyName: \"textAnnotationData\", source: \"Class\" },\r\n ];\r\n\r\n /**\r\n * TextAnnotation2d deserializes 'textAnnotationData'.\r\n * @inheritdoc\r\n * @beta\r\n */\r\n public static override deserialize(props: DeserializeEntityArgs): TextAnnotation2dProps {\r\n const elProps = super.deserialize(props) as TextAnnotation2dProps;\r\n const textAnnotationData = parseTextAnnotationData(props.row.textAnnotationData);\r\n if (textAnnotationData) {\r\n elProps.textAnnotationData = JSON.stringify(textAnnotationData);\r\n }\r\n return elProps;\r\n }\r\n\r\n /**\r\n * TextAnnotation2d serializes 'textAnnotationData'.\r\n * @inheritdoc\r\n * @beta\r\n */\r\n public static override serialize(props: TextAnnotation2dProps, iModel: IModelDb): ECSqlRow {\r\n const inst = super.serialize(props, iModel);\r\n if (props.textAnnotationData !== undefined) {\r\n inst.textAnnotationData = props.textAnnotationData;\r\n }\r\n return inst;\r\n }\r\n\r\n /** @internal */\r\n public getTextBlocks(): Iterable<TextBlockAndId> {\r\n return getTextBlocks(this);\r\n }\r\n\r\n /** @internal */\r\n public updateTextBlocks(textBlocks: TextBlockAndId[]): void {\r\n return updateTextBlocks(this, textBlocks);\r\n }\r\n\r\n /** @internal */\r\n public static override onInserted(arg: OnElementIdArg): void {\r\n super.onInserted(arg);\r\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\r\n }\r\n\r\n /** @internal */\r\n public static override onUpdated(arg: OnElementIdArg): void {\r\n super.onUpdated(arg);\r\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\r\n }\r\n\r\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\r\n super.collectReferenceIds(referenceIds);\r\n collectReferenceIds(this, referenceIds);\r\n }\r\n\r\n /** @internal */\r\n protected static override async onCloned(context: IModelElementCloneContext, srcProps: TextAnnotation2dProps, dstProps: TextAnnotation2dProps): Promise<void> {\r\n await super.onCloned(context, srcProps, dstProps);\r\n\r\n const srcElem = TextAnnotation2d.fromJSON(srcProps, context.sourceDb);\r\n ElementDrivesTextAnnotation.remapFields(srcElem, context);\r\n const anno = srcElem.getAnnotation();\r\n dstProps.textAnnotationData = anno ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: anno.toJSON() }) : undefined;\r\n\r\n return remapTextStyle(context, srcElem, dstProps);\r\n }\r\n}\r\n\r\n/** An element that displays textual content within a 3d model.\r\n * The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.\r\n * @see [[setAnnotation]] to change the textual content.\r\n * @public @preview\r\n */\r\nexport class TextAnnotation3d extends GraphicalElement3d /* implements ITextAnnotation */ {\r\n /** @internal */\r\n public static override get className(): string { return \"TextAnnotation3d\"; }\r\n /**\r\n * The default [[AnnotationTextStyle]] used by the TextAnnotation3d.\r\n * @beta\r\n */\r\n public defaultTextStyle?: TextAnnotationUsesTextStyleByDefault;\r\n /** The data associated with the text annotation. */\r\n private _textAnnotationProps?: TextAnnotationProps;\r\n\r\n /** Extract the textual content, if present.\r\n * @see [[setAnnotation]] to change it.\r\n */\r\n public getAnnotation(): TextAnnotation | undefined {\r\n return this._textAnnotationProps ? TextAnnotation.fromJSON(this._textAnnotationProps) : undefined;\r\n }\r\n\r\n /** Change the textual content of the `TextAnnotation3d`.\r\n * @see [[getAnnotation]] to extract the current annotation.\r\n * @param annotation The new annotation\r\n */\r\n public setAnnotation(annotation: TextAnnotation) {\r\n this._textAnnotationProps = annotation.toJSON();\r\n }\r\n\r\n protected constructor(props: TextAnnotation3dProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n if (props.defaultTextStyle) {\r\n this.defaultTextStyle = new TextAnnotationUsesTextStyleByDefault(props.defaultTextStyle.id);\r\n }\r\n this._textAnnotationProps = parseTextAnnotationData(props.textAnnotationData)?.data;\r\n }\r\n\r\n /** Creates a new instance of `TextAnnotation3d` from its JSON representation. */\r\n public static fromJSON(props: TextAnnotation3dProps, iModel: IModelDb): TextAnnotation3d {\r\n return new TextAnnotation3d(props, iModel);\r\n }\r\n\r\n /**\r\n * Converts the current `TextAnnotation3d` instance to its JSON representation.\r\n * It also computes the `elementGeometryBuilderParams` property used to create the GeometryStream.\r\n * @inheritdoc\r\n */\r\n public override toJSON(): TextAnnotation3dProps {\r\n const props = super.toJSON() as TextAnnotation3dProps;\r\n props.textAnnotationData = this._textAnnotationProps ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: this._textAnnotationProps }) : undefined;\r\n if (this._textAnnotationProps) {\r\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(this.iModel, this.model, this.category, this.placement, this._textAnnotationProps, this.defaultTextStyle ? this.defaultTextStyle.id : undefined);\r\n }\r\n\r\n return props;\r\n }\r\n\r\n /** Creates a new `TextAnnotation3d` instance with the specified properties.\r\n * @param iModelDb The iModel.\r\n * @param arg The arguments for creating the TextAnnotation3d.\r\n * @beta\r\n */\r\n public static create(iModelDb: IModelDb, arg: TextAnnotation3dCreateArgs): TextAnnotation3d {\r\n const elementProps: TextAnnotation3dProps = {\r\n classFullName: this.classFullName,\r\n textAnnotationData: arg.textAnnotationProps ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: arg.textAnnotationProps }) : undefined,\r\n defaultTextStyle: arg.defaultTextStyleId ? new TextAnnotationUsesTextStyleByDefault(arg.defaultTextStyleId).toJSON() : undefined,\r\n placement: arg.placement,\r\n model: arg.model,\r\n category: arg.category,\r\n code: arg.code ?? Code.createEmpty(),\r\n };\r\n return new this(elementProps, iModelDb);\r\n }\r\n\r\n /**\r\n * Updates the geometry of the TextAnnotation3d on insert and validates version..\r\n * @inheritdoc\r\n * @beta\r\n */\r\n protected static override onInsert(arg: OnElementPropsArg): void {\r\n super.onInsert(arg);\r\n this.validateVersionAndUpdateGeometry(arg);\r\n }\r\n\r\n /**\r\n * Updates the geometry of the TextAnnotation3d on update and validates version..\r\n * @inheritdoc\r\n * @beta\r\n */\r\n protected static override onUpdate(arg: OnElementPropsArg): void {\r\n super.onUpdate(arg);\r\n this.validateVersionAndUpdateGeometry(arg);\r\n }\r\n\r\n /**\r\n * Populates the `elementGeometryBuilderParams` property in the [TextAnnotation3dProps]($common).\r\n * Only does this if the `elementGeometryBuilderParams` is not already set and if there is actually a text annotation to produce geometry for.\r\n * Also, validates the version of the text annotation data and migrates it if necessary.\r\n * @beta\r\n */\r\n protected static validateVersionAndUpdateGeometry(arg: OnElementPropsArg): void {\r\n const props = arg.props as TextAnnotation3dProps;\r\n const textAnnotationData = parseTextAnnotationData(props.textAnnotationData);\r\n if (!props.elementGeometryBuilderParams && textAnnotationData) {\r\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(arg.iModel, props.model, props.category, props.placement ?? Placement3d.fromJSON(), textAnnotationData.data, props.defaultTextStyle?.id);\r\n }\r\n }\r\n\r\n /**\r\n * TextAnnotation3d custom HandledProps include 'textAnnotationData'.\r\n * @inheritdoc\r\n * @internal\r\n */\r\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\r\n { propertyName: \"textAnnotationData\", source: \"Class\" },\r\n ];\r\n\r\n /**\r\n * TextAnnotation3d deserializes 'textAnnotationData'.\r\n * @inheritdoc\r\n * @beta\r\n */\r\n public static override deserialize(props: DeserializeEntityArgs): TextAnnotation3dProps {\r\n const elProps = super.deserialize(props) as TextAnnotation3dProps;\r\n const textAnnotationData = parseTextAnnotationData(props.row.textAnnotationData);\r\n if (textAnnotationData) {\r\n elProps.textAnnotationData = JSON.stringify(textAnnotationData);\r\n }\r\n return elProps;\r\n }\r\n\r\n /**\r\n * TextAnnotation3d serializes 'textAnnotationData'.\r\n * @inheritdoc\r\n * @beta\r\n */\r\n public static override serialize(props: TextAnnotation3dProps, iModel: IModelDb): ECSqlRow {\r\n const inst = super.serialize(props, iModel);\r\n if (props.textAnnotationData !== undefined) {\r\n inst.textAnnotationData = props.textAnnotationData;\r\n }\r\n return inst;\r\n }\r\n\r\n /** @internal */\r\n public getTextBlocks(): Iterable<TextBlockAndId> {\r\n return getTextBlocks(this);\r\n }\r\n\r\n /** @internal */\r\n public updateTextBlocks(textBlocks: TextBlockAndId[]): void {\r\n return updateTextBlocks(this, textBlocks);\r\n }\r\n\r\n /** @internal */\r\n public static override onInserted(arg: OnElementIdArg): void {\r\n super.onInserted(arg);\r\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\r\n }\r\n\r\n /** @internal */\r\n public static override onUpdated(arg: OnElementIdArg): void {\r\n super.onUpdated(arg);\r\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\r\n }\r\n\r\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\r\n super.collectReferenceIds(referenceIds);\r\n collectReferenceIds(this, referenceIds);\r\n }\r\n\r\n /** @internal */\r\n protected static override async onCloned(context: IModelElementCloneContext, srcProps: TextAnnotation3dProps, dstProps: TextAnnotation3dProps): Promise<void> {\r\n await super.onCloned(context, srcProps, dstProps);\r\n\r\n const srcElem = TextAnnotation3d.fromJSON(srcProps, context.sourceDb);\r\n ElementDrivesTextAnnotation.remapFields(srcElem, context);\r\n const anno = srcElem.getAnnotation();\r\n dstProps.textAnnotationData = anno ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: anno.toJSON() }) : undefined;\r\n\r\n return remapTextStyle(context, srcElem, dstProps);\r\n }\r\n}\r\n\r\nasync function remapTextStyle(\r\n context: IModelElementCloneContext,\r\n srcElem: TextAnnotation2d | TextAnnotation3d,\r\n dstProps: TextAnnotation2dProps | TextAnnotation3dProps\r\n): Promise<void> {\r\n const dstStyleId = await AnnotationTextStyle.remapTextStyleId(srcElem.defaultTextStyle?.id ?? Id64.invalid, context);\r\n dstProps.defaultTextStyle = Id64.isValid(dstStyleId) ? new TextAnnotationUsesTextStyleByDefault(dstStyleId).toJSON() : undefined;\r\n}\r\n\r\nfunction collectReferenceIds(elem: TextAnnotation2d | TextAnnotation3d, referenceIds: EntityReferenceSet): void {\r\n const style = elem.defaultTextStyle?.id;\r\n if (style && Id64.isValidId64(style)) {\r\n referenceIds.addElement(style);\r\n }\r\n\r\n const block = elem.getAnnotation()?.textBlock;\r\n if (block) {\r\n for (const { child } of traverseTextBlockComponent(block)) {\r\n if (child.type === \"field\") {\r\n const hostId = child.propertyHost.elementId;\r\n if (Id64.isValidId64(hostId)) {\r\n referenceIds.addElement(hostId);\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\nfunction getTextBlocks(elem: TextAnnotation2d | TextAnnotation3d): Iterable<TextBlockAndId> {\r\n const annotation = elem.getAnnotation();\r\n return annotation ? [{ textBlock: annotation.textBlock, id: undefined }] : [];\r\n}\r\n\r\nfunction updateTextBlocks(elem: TextAnnotation2d | TextAnnotation3d, textBlocks: TextBlockAndId[]): void {\r\n assert(textBlocks.length === 1);\r\n assert(textBlocks[0].id === undefined);\r\n\r\n const annotation = elem.getAnnotation();\r\n if (!annotation) {\r\n // We must obtain the TextBlockAndId from the element in the first place, so the only way we could end up here is if\r\n // somebody removed the text annotation after we called getTextBlocks. That's gotta be a mistake.\r\n throw new Error(\"Text annotation element has no text\");\r\n }\r\n\r\n annotation.textBlock = textBlocks[0].textBlock;\r\n\r\n elem.setAnnotation(annotation);\r\n}\r\n\r\n/** The version of the JSON stored in `AnnotationTextStyleProps.settings` used by the code.\r\n * Uses the same semantics as [ECVersion]($ecschema-metadata).\r\n * @internal\r\n*/\r\n// 1.0.1 - Added terminatorShapes for leaders\r\nexport const TEXT_STYLE_SETTINGS_JSON_VERSION = \"1.0.1\";\r\n\r\nfunction migrateTextStyleSettings(oldData: VersionedJSON<TextStyleSettingsProps>): TextStyleSettingsProps {\r\n if (oldData.version === TEXT_STYLE_SETTINGS_JSON_VERSION) return oldData.data;\r\n\r\n // Migrate from 1.0.0 to 1.0.1\r\n if (oldData.data.leader && !oldData.data.leader.terminatorShape) {\r\n oldData.data.leader.terminatorShape = TextStyleSettings.defaultProps.leader.terminatorShape;\r\n }\r\n return oldData.data;\r\n\r\n}\r\n\r\n/** Arguments supplied when creating an [[AnnotationTextStyle]].\r\n * @beta\r\n */\r\nexport interface TextStyleCreateArgs {\r\n /** The ID of the [[DefinitionModel]]. */\r\n definitionModelId: Id64String;\r\n /** The name to assign to the [[AnnotationTextStyle]]. */\r\n name: string;\r\n /** Optional text style settings used to create the [[AnnotationTextStyle]]. Default settings will be used if not provided. */\r\n settings?: TextStyleSettingsProps;\r\n /** Optional description for the [[AnnotationTextStyle]]. */\r\n description?: string;\r\n}\r\n\r\n/**\r\n * The definition element that holds text style information.\r\n * The style is stored as a [TextStyleSettings]($common).\r\n * @beta\r\n */\r\nexport class AnnotationTextStyle extends DefinitionElement {\r\n /** @internal */\r\n public static override get className(): string { return \"AnnotationTextStyle\"; }\r\n /**\r\n * Optional text describing the `AnnotationTextStyle`.\r\n */\r\n public description?: string;\r\n /**\r\n * The text style settings for the `AnnotationTextStyle`.\r\n * @see [[TextStyleSettings]] for more information.\r\n */\r\n public settings: TextStyleSettings;\r\n\r\n protected constructor(props: AnnotationTextStyleProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.description = props.description;\r\n const settingsProps = AnnotationTextStyle.parseTextStyleSettings(props.settings);\r\n this.settings = TextStyleSettings.fromJSON(settingsProps?.data);\r\n }\r\n\r\n /**\r\n * Creates a Code for an `AnnotationTextStyle` given a name that is meant to be unique within the scope of the specified DefinitionModel.\r\n *\r\n * @param iModel - The IModelDb.\r\n * @param definitionModelId - The ID of the DefinitionModel that contains the AnnotationTextStyle and provides the scope for its name.\r\n * @param name - The AnnotationTextStyle name.\r\n * @beta\r\n */\r\n public static createCode(iModel: IModelDb, definitionModelId: CodeScopeProps, name: string): Code {\r\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.annotationTextStyle);\r\n return new Code({ spec: codeSpec.id, scope: definitionModelId, value: name });\r\n }\r\n\r\n /**\r\n * Creates a new instance of `AnnotationTextStyle` with the specified properties.\r\n *\r\n * @param iModelDb - The iModelDb.\r\n * @param arg - The arguments for creating the AnnotationTextStyle.\r\n * @beta\r\n */\r\n public static create(iModelDb: IModelDb, arg: TextStyleCreateArgs): AnnotationTextStyle {\r\n const props: AnnotationTextStyleProps = {\r\n classFullName: this.classFullName,\r\n model: arg.definitionModelId,\r\n code: this.createCode(iModelDb, arg.definitionModelId, arg.name).toJSON(),\r\n description: arg.description,\r\n settings: arg.settings ? JSON.stringify({ version: TEXT_STYLE_SETTINGS_JSON_VERSION, data: arg.settings }) : undefined,\r\n }\r\n return new this(props, iModelDb);\r\n }\r\n\r\n /**\r\n * Converts the current `AnnotationTextStyle` instance to its JSON representation.\r\n * @inheritdoc\r\n */\r\n public override toJSON(): AnnotationTextStyleProps {\r\n const props = super.toJSON() as AnnotationTextStyleProps;\r\n props.description = this.description;\r\n props.settings = JSON.stringify({ version: TEXT_STYLE_SETTINGS_JSON_VERSION, data: this.settings.toJSON() });\r\n return props;\r\n }\r\n\r\n /** Creates a new instance of `AnnotationTextStyle` from its JSON representation. */\r\n public static fromJSON(props: AnnotationTextStyleProps, iModel: IModelDb): AnnotationTextStyle {\r\n return new AnnotationTextStyle(props, iModel);\r\n }\r\n\r\n /**\r\n * Validates that the AnnotationTextStyle's settings are valid before insert.\r\n * @inheritdoc\r\n * @beta\r\n */\r\n protected static override onInsert(arg: OnElementPropsArg): void {\r\n super.onInsert(arg);\r\n this.validateSettings(arg.props as AnnotationTextStyleProps);\r\n }\r\n\r\n /**\r\n * Validates that the AnnotationTextStyle's settings are valid before update.\r\n * @inheritdoc\r\n * @beta\r\n */\r\n protected static override onUpdate(arg: OnElementPropsArg): void {\r\n super.onUpdate(arg);\r\n this.validateSettings(arg.props as AnnotationTextStyleProps);\r\n }\r\n\r\n private static validateSettings(props: AnnotationTextStyleProps): void {\r\n const settingProps = AnnotationTextStyle.parseTextStyleSettings(props.settings);\r\n if (!settingProps) return;\r\n const settings = TextStyleSettings.fromJSON(settingProps.data);\r\n const errors = settings.getValidationErrors();\r\n if (errors.length > 0) {\r\n throw new Error(`Invalid AnnotationTextStyle settings: ${errors.join(\", \")}`);\r\n }\r\n }\r\n\r\n /**\r\n * AnnotationTextStyle custom HandledProps include 'settings'.\r\n * @inheritdoc\r\n * @beta\r\n */\r\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\r\n { propertyName: \"settings\", source: \"Class\" },\r\n ];\r\n\r\n /**\r\n * AnnotationTextStyle deserializes 'settings'.\r\n * @inheritdoc\r\n * @beta\r\n */\r\n public static override deserialize(props: DeserializeEntityArgs): AnnotationTextStyleProps {\r\n const elProps = super.deserialize(props) as AnnotationTextStyleProps;\r\n const settings = this.parseTextStyleSettings(props.row.settings);\r\n if (settings) {\r\n elProps.settings = JSON.stringify(settings);\r\n }\r\n return elProps;\r\n }\r\n\r\n /**\r\n * AnnotationTextStyle serializes 'settings'.\r\n * @inheritdoc\r\n * @beta\r\n */\r\n public static override serialize(props: AnnotationTextStyleProps, iModel: IModelDb): ECSqlRow {\r\n const inst = super.serialize(props, iModel);\r\n if (props.settings !== undefined) {\r\n inst.settings = props.settings;\r\n }\r\n return inst;\r\n }\r\n\r\n /** Parses, validates, and potentially migrates the text style settings data from a JSON string. */\r\n private static parseTextStyleSettings(json: string | undefined): VersionedJSON<TextStyleSettingsProps> | undefined {\r\n if (!json) return undefined;\r\n return validateAndMigrateVersionedJSON<TextStyleSettingsProps>(json, TEXT_STYLE_SETTINGS_JSON_VERSION, migrateTextStyleSettings);\r\n }\r\n\r\n /** When copying an element from one iModel to another, returns the Id of the AnnotationTextStyle in the `context`'s target iModel\r\n * corresponding to `sourceTextStyleId`, or [Id64.invalid]($bentley) if no corresponding text style exists.\r\n * If a text style with the same [Code]($common) exists in the target iModel, the style Id will be remapped to refer to that style.\r\n * Otherwise, a copy of the style will be imported into the target iModel and its element Id returned.\r\n * Implementations of [[ITextAnnotation]] should invoke this function when implementing their [[Element.onCloned]] method.\r\n * @throws Error if an attempt to import the text style failed.\r\n */\r\n public static async remapTextStyleId(sourceTextStyleId: Id64String, context: IModelElementCloneContext): Promise<Id64String> {\r\n // No remapping necessary if there's no text style or we're not copying to a different iModel.\r\n if (!Id64.isValid(sourceTextStyleId) || !context.isBetweenIModels) {\r\n return sourceTextStyleId;\r\n }\r\n\r\n // If the style's already been remapped, we're finished.\r\n let dstStyleId: Id64String | undefined = context.findTargetElementId(sourceTextStyleId);\r\n if (Id64.isValid(dstStyleId)) {\r\n return dstStyleId;\r\n }\r\n\r\n // Look up the style. It really ought to exist.\r\n const srcStyle = context.sourceDb.elements.tryGetElement<AnnotationTextStyle>(sourceTextStyleId);\r\n if (!srcStyle) {\r\n return Id64.invalid;\r\n }\r\n\r\n // If a style with the same code exists in the target iModel, remap to that one.\r\n dstStyleId = context.targetDb.elements.queryElementIdByCode(srcStyle.code);\r\n if (undefined !== dstStyleId) {\r\n return dstStyleId;\r\n }\r\n\r\n // Copy the style into the target iModel and remap its Id.\r\n const dstStyleProps = await context.cloneElement(srcStyle);\r\n dstStyleId = context.targetDb.elements.insertElement(dstStyleProps);\r\n context.remapElement(sourceTextStyleId, dstStyleId);\r\n return dstStyleId;\r\n }\r\n\r\n protected static override async onCloned(context: IModelElementCloneContext, srcProps: AnnotationTextStyleProps, dstProps: AnnotationTextStyleProps): Promise<void> {\r\n await super.onCloned(context, srcProps, dstProps);\r\n if (!context.isBetweenIModels) {\r\n return;\r\n }\r\n\r\n const settingsProps = AnnotationTextStyle.parseTextStyleSettings(srcProps.settings);\r\n const font = TextStyleSettings.fromJSON(settingsProps?.data).font;\r\n\r\n const fontsToEmbed = [];\r\n for (const file of context.sourceDb.fonts.queryEmbeddedFontFiles()) {\r\n if (file.type === font.type && file.faces.some((face) => face.familyName === font.name)) {\r\n fontsToEmbed.push(file);\r\n }\r\n }\r\n\r\n await Promise.all(fontsToEmbed.map(async (file) => context.targetDb.fonts.embedFontFile({ file })));\r\n }\r\n}\r\n"]}
|