@itwin/core-frontend 3.0.0-dev.128 → 3.0.0-dev.133
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/lib/cjs/DisplayStyleState.d.ts +0 -3
- package/lib/cjs/DisplayStyleState.d.ts.map +1 -1
- package/lib/cjs/DisplayStyleState.js +0 -5
- package/lib/cjs/DisplayStyleState.js.map +1 -1
- package/lib/cjs/DrawingViewState.js +1 -1
- package/lib/cjs/DrawingViewState.js.map +1 -1
- package/lib/cjs/IModelConnection.d.ts +3 -5
- package/lib/cjs/IModelConnection.d.ts.map +1 -1
- package/lib/cjs/IModelConnection.js +5 -10
- package/lib/cjs/IModelConnection.js.map +1 -1
- package/lib/cjs/RenderScheduleState.d.ts +2 -0
- package/lib/cjs/RenderScheduleState.d.ts.map +1 -1
- package/lib/cjs/RenderScheduleState.js +10 -5
- package/lib/cjs/RenderScheduleState.js.map +1 -1
- package/lib/cjs/SpatialViewState.d.ts +8 -0
- package/lib/cjs/SpatialViewState.d.ts.map +1 -1
- package/lib/cjs/SpatialViewState.js +10 -0
- package/lib/cjs/SpatialViewState.js.map +1 -1
- package/lib/cjs/SubCategoriesCache.js +1 -1
- package/lib/cjs/SubCategoriesCache.js.map +1 -1
- package/lib/cjs/ViewContext.d.ts +3 -1
- package/lib/cjs/ViewContext.d.ts.map +1 -1
- package/lib/cjs/ViewContext.js +4 -0
- package/lib/cjs/ViewContext.js.map +1 -1
- package/lib/cjs/ViewCreator2d.js +2 -2
- package/lib/cjs/ViewCreator2d.js.map +1 -1
- package/lib/cjs/ViewCreator3d.js +1 -1
- package/lib/cjs/ViewCreator3d.js.map +1 -1
- package/lib/cjs/render/GraphicBranch.d.ts +18 -2
- package/lib/cjs/render/GraphicBranch.d.ts.map +1 -1
- package/lib/cjs/render/GraphicBranch.js +9 -1
- package/lib/cjs/render/GraphicBranch.js.map +1 -1
- package/lib/cjs/render/RenderSystem.d.ts +7 -0
- package/lib/cjs/render/RenderSystem.d.ts.map +1 -1
- package/lib/cjs/render/RenderSystem.js +9 -0
- package/lib/cjs/render/RenderSystem.js.map +1 -1
- package/lib/cjs/render/RenderTarget.d.ts +7 -0
- package/lib/cjs/render/RenderTarget.d.ts.map +1 -1
- package/lib/cjs/render/RenderTarget.js.map +1 -1
- package/lib/cjs/render/webgl/DrawCommand.d.ts +0 -1
- package/lib/cjs/render/webgl/DrawCommand.d.ts.map +1 -1
- package/lib/cjs/render/webgl/DrawCommand.js.map +1 -1
- package/lib/cjs/render/webgl/Graphic.d.ts +13 -0
- package/lib/cjs/render/webgl/Graphic.d.ts.map +1 -1
- package/lib/cjs/render/webgl/Graphic.js +41 -3
- package/lib/cjs/render/webgl/Graphic.js.map +1 -1
- package/lib/cjs/render/webgl/RenderCommands.d.ts +4 -0
- package/lib/cjs/render/webgl/RenderCommands.d.ts.map +1 -1
- package/lib/cjs/render/webgl/RenderCommands.js +27 -1
- package/lib/cjs/render/webgl/RenderCommands.js.map +1 -1
- package/lib/cjs/render/webgl/System.d.ts +1 -0
- package/lib/cjs/render/webgl/System.d.ts.map +1 -1
- package/lib/cjs/render/webgl/System.js +3 -0
- package/lib/cjs/render/webgl/System.js.map +1 -1
- package/lib/cjs/render/webgl/Target.d.ts +11 -0
- package/lib/cjs/render/webgl/Target.d.ts.map +1 -1
- package/lib/cjs/render/webgl/Target.js +19 -0
- package/lib/cjs/render/webgl/Target.js.map +1 -1
- package/lib/cjs/tile/DynamicIModelTile.js +7 -1
- package/lib/cjs/tile/DynamicIModelTile.js.map +1 -1
- package/lib/cjs/tile/IModelTile.d.ts.map +1 -1
- package/lib/cjs/tile/IModelTile.js +8 -2
- package/lib/cjs/tile/IModelTile.js.map +1 -1
- package/lib/cjs/tile/IModelTileTree.d.ts +5 -0
- package/lib/cjs/tile/IModelTileTree.d.ts.map +1 -1
- package/lib/cjs/tile/IModelTileTree.js +15 -0
- package/lib/cjs/tile/IModelTileTree.js.map +1 -1
- package/lib/cjs/tile/ImdlReader.d.ts +18 -1
- package/lib/cjs/tile/ImdlReader.d.ts.map +1 -1
- package/lib/cjs/tile/ImdlReader.js +51 -26
- package/lib/cjs/tile/ImdlReader.js.map +1 -1
- package/lib/cjs/tile/PrimaryTileTree.d.ts +14 -5
- package/lib/cjs/tile/PrimaryTileTree.d.ts.map +1 -1
- package/lib/cjs/tile/PrimaryTileTree.js +65 -11
- package/lib/cjs/tile/PrimaryTileTree.js.map +1 -1
- package/lib/cjs/tile/Tile.d.ts.map +1 -1
- package/lib/cjs/tile/Tile.js +5 -1
- package/lib/cjs/tile/Tile.js.map +1 -1
- package/lib/cjs/tile/TileDrawArgs.d.ts +11 -0
- package/lib/cjs/tile/TileDrawArgs.d.ts.map +1 -1
- package/lib/cjs/tile/TileDrawArgs.js +6 -1
- package/lib/cjs/tile/TileDrawArgs.js.map +1 -1
- package/lib/cjs/tile/TileTreeReference.d.ts +2 -0
- package/lib/cjs/tile/TileTreeReference.d.ts.map +1 -1
- package/lib/cjs/tile/TileTreeReference.js +5 -0
- package/lib/cjs/tile/TileTreeReference.js.map +1 -1
- package/lib/cjs/tools/ElementSetTool.js +1 -1
- package/lib/cjs/tools/ElementSetTool.js.map +1 -1
- package/lib/esm/DisplayStyleState.d.ts +0 -3
- package/lib/esm/DisplayStyleState.d.ts.map +1 -1
- package/lib/esm/DisplayStyleState.js +0 -5
- package/lib/esm/DisplayStyleState.js.map +1 -1
- package/lib/esm/DrawingViewState.js +1 -1
- package/lib/esm/DrawingViewState.js.map +1 -1
- package/lib/esm/IModelConnection.d.ts +3 -5
- package/lib/esm/IModelConnection.d.ts.map +1 -1
- package/lib/esm/IModelConnection.js +5 -10
- package/lib/esm/IModelConnection.js.map +1 -1
- package/lib/esm/RenderScheduleState.d.ts +2 -0
- package/lib/esm/RenderScheduleState.d.ts.map +1 -1
- package/lib/esm/RenderScheduleState.js +8 -4
- package/lib/esm/RenderScheduleState.js.map +1 -1
- package/lib/esm/SpatialViewState.d.ts +8 -0
- package/lib/esm/SpatialViewState.d.ts.map +1 -1
- package/lib/esm/SpatialViewState.js +10 -0
- package/lib/esm/SpatialViewState.js.map +1 -1
- package/lib/esm/SubCategoriesCache.js +1 -1
- package/lib/esm/SubCategoriesCache.js.map +1 -1
- package/lib/esm/ViewContext.d.ts +3 -1
- package/lib/esm/ViewContext.d.ts.map +1 -1
- package/lib/esm/ViewContext.js +4 -0
- package/lib/esm/ViewContext.js.map +1 -1
- package/lib/esm/ViewCreator2d.js +2 -2
- package/lib/esm/ViewCreator2d.js.map +1 -1
- package/lib/esm/ViewCreator3d.js +1 -1
- package/lib/esm/ViewCreator3d.js.map +1 -1
- package/lib/esm/render/GraphicBranch.d.ts +18 -2
- package/lib/esm/render/GraphicBranch.d.ts.map +1 -1
- package/lib/esm/render/GraphicBranch.js +8 -0
- package/lib/esm/render/GraphicBranch.js.map +1 -1
- package/lib/esm/render/RenderSystem.d.ts +7 -0
- package/lib/esm/render/RenderSystem.d.ts.map +1 -1
- package/lib/esm/render/RenderSystem.js +9 -0
- package/lib/esm/render/RenderSystem.js.map +1 -1
- package/lib/esm/render/RenderTarget.d.ts +7 -0
- package/lib/esm/render/RenderTarget.d.ts.map +1 -1
- package/lib/esm/render/RenderTarget.js.map +1 -1
- package/lib/esm/render/webgl/DrawCommand.d.ts +0 -1
- package/lib/esm/render/webgl/DrawCommand.d.ts.map +1 -1
- package/lib/esm/render/webgl/DrawCommand.js.map +1 -1
- package/lib/esm/render/webgl/Graphic.d.ts +13 -0
- package/lib/esm/render/webgl/Graphic.d.ts.map +1 -1
- package/lib/esm/render/webgl/Graphic.js +39 -2
- package/lib/esm/render/webgl/Graphic.js.map +1 -1
- package/lib/esm/render/webgl/RenderCommands.d.ts +4 -0
- package/lib/esm/render/webgl/RenderCommands.d.ts.map +1 -1
- package/lib/esm/render/webgl/RenderCommands.js +27 -1
- package/lib/esm/render/webgl/RenderCommands.js.map +1 -1
- package/lib/esm/render/webgl/System.d.ts +1 -0
- package/lib/esm/render/webgl/System.d.ts.map +1 -1
- package/lib/esm/render/webgl/System.js +4 -1
- package/lib/esm/render/webgl/System.js.map +1 -1
- package/lib/esm/render/webgl/Target.d.ts +11 -0
- package/lib/esm/render/webgl/Target.d.ts.map +1 -1
- package/lib/esm/render/webgl/Target.js +19 -0
- package/lib/esm/render/webgl/Target.js.map +1 -1
- package/lib/esm/tile/DynamicIModelTile.js +7 -1
- package/lib/esm/tile/DynamicIModelTile.js.map +1 -1
- package/lib/esm/tile/IModelTile.d.ts.map +1 -1
- package/lib/esm/tile/IModelTile.js +8 -2
- package/lib/esm/tile/IModelTile.js.map +1 -1
- package/lib/esm/tile/IModelTileTree.d.ts +5 -0
- package/lib/esm/tile/IModelTileTree.d.ts.map +1 -1
- package/lib/esm/tile/IModelTileTree.js +15 -0
- package/lib/esm/tile/IModelTileTree.js.map +1 -1
- package/lib/esm/tile/ImdlReader.d.ts +18 -1
- package/lib/esm/tile/ImdlReader.d.ts.map +1 -1
- package/lib/esm/tile/ImdlReader.js +53 -28
- package/lib/esm/tile/ImdlReader.js.map +1 -1
- package/lib/esm/tile/PrimaryTileTree.d.ts +14 -5
- package/lib/esm/tile/PrimaryTileTree.d.ts.map +1 -1
- package/lib/esm/tile/PrimaryTileTree.js +65 -11
- package/lib/esm/tile/PrimaryTileTree.js.map +1 -1
- package/lib/esm/tile/Tile.d.ts.map +1 -1
- package/lib/esm/tile/Tile.js +5 -1
- package/lib/esm/tile/Tile.js.map +1 -1
- package/lib/esm/tile/TileDrawArgs.d.ts +11 -0
- package/lib/esm/tile/TileDrawArgs.d.ts.map +1 -1
- package/lib/esm/tile/TileDrawArgs.js +6 -1
- package/lib/esm/tile/TileDrawArgs.js.map +1 -1
- package/lib/esm/tile/TileTreeReference.d.ts +2 -0
- package/lib/esm/tile/TileTreeReference.d.ts.map +1 -1
- package/lib/esm/tile/TileTreeReference.js +5 -0
- package/lib/esm/tile/TileTreeReference.js.map +1 -1
- package/lib/esm/tools/ElementSetTool.js +1 -1
- package/lib/esm/tools/ElementSetTool.js.map +1 -1
- package/package.json +22 -22
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpatialViewState.js","sourceRoot":"","sources":["../../src/SpatialViewState.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAc,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAY,OAAO,EAAU,MAAM,sBAAsB,CAAC;AAE3E,OAAO,EAAE,0BAA0B,EAAuB,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAI1D,OAAO,EAAwB,WAAW,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAqB,MAAM,iBAAiB,CAAC;AAE/E;;;GAGG;AACH,MAAM,OAAO,gBAAiB,SAAQ,WAAW;IAmE/C,YAAY,KAAiC,EAAE,MAAwB,EAAE,IAA2B,EAAE,YAAiC,EAAE,aAAiC;QACxK,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;QA9D1B,sCAAiC,GAAmB,EAAE,CAAC;QAExE;;WAEG;QACa,0BAAqB,GAAG,IAAI,OAAO,EAAc,CAAC;QA0DhE,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;QACpC,IAAI,IAAI,YAAY,gBAAgB,EAAE,aAAa;YACjD,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;QAEnD,IAAI,CAAC,SAAS,GAAG,yBAAyB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC1D,CAAC;IAzED,gBAAgB;IACT,MAAM,KAAc,SAAS,KAAK,OAAO,uBAAuB,CAAC,CAAC,CAAC;IAW1E,IAA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IAAI,CAAC,gCAAgC,EAAE,CAAC;IAC1C,CAAC;IAEO,8BAA8B;QACpC,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC;QACnD,MAAM,IAAI,GAAG,GAAG,EAAE;YAChB,IAAI,CAAC,wBAAwB,EAAE,CAAC;YAChC,IAAI,CAAC,qBAAqB,CAAC,UAAU,EAAE,CAAC;QAC1C,CAAC,CAAC;QAEF,IAAI,CAAC,iCAAiC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;QAC9E,IAAI,CAAC,iCAAiC,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;QAChF,IAAI,CAAC,iCAAiC,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;IAClF,CAAC;IAEO,gCAAgC;QACtC,IAAI,CAAC,iCAAiC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QAC3D,IAAI,CAAC,iCAAiC,CAAC,MAAM,GAAG,CAAC,CAAC;IACpD,CAAC;CACF;AACD;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,gBAAgB;IACzD,gBAAgB;IACT,MAAM,KAAc,SAAS,KAAK,OAAO,4BAA4B,CAAC,CAAC,CAAC;IAE/E,YAAY,KAAiC,EAAE,MAAwB,EAAE,UAAiC,EAAE,YAAiC,EAAE,aAAiC,IAAI,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IAEpO,cAAc,KAAc,OAAO,KAAK,CAAC,CAAC,CAAC;CAC5D","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 Views\r\n */\r\n\r\nimport { BeEvent, Id64String } from \"@itwin/core-bentley\";\r\nimport { Constant, Matrix3d, Range3d, XYAndZ } from \"@itwin/core-geometry\";\r\nimport { AxisAlignedBox3d, SpatialViewDefinitionProps, ViewStateProps } from \"@itwin/core-common\";\r\nimport { AuxCoordSystemSpatialState, AuxCoordSystemState } from \"./AuxCoordSys\";\r\nimport { ModelSelectorState } from \"./ModelSelectorState\";\r\nimport { CategorySelectorState } from \"./CategorySelectorState\";\r\nimport { DisplayStyle3dState } from \"./DisplayStyleState\";\r\nimport { GeometricModel3dState, GeometricModelState } from \"./ModelState\";\r\nimport { SceneContext } from \"./ViewContext\";\r\nimport { IModelConnection } from \"./IModelConnection\";\r\nimport { AttachToViewportArgs, ViewState3d } from \"./ViewState\";\r\nimport { SpatialTileTreeReferences, TileTreeReference } from \"./tile/internal\";\r\n\r\n/** Defines a view of one or more SpatialModels.\r\n * The list of viewed models is stored in the ModelSelector.\r\n * @public\r\n */\r\nexport class SpatialViewState extends ViewState3d {\r\n /** @internal */\r\n public static override get className() { return \"SpatialViewDefinition\"; }\r\n\r\n private readonly _treeRefs: SpatialTileTreeReferences;\r\n private _modelSelector: ModelSelectorState;\r\n private readonly _unregisterModelSelectorListeners: VoidFunction[] = [];\r\n\r\n /** An event raised when the set of models viewed by this view changes, *only* if the view is attached to a [[Viewport]].\r\n * @public\r\n */\r\n public readonly onViewedModelsChanged = new BeEvent<() => void>();\r\n\r\n public get modelSelector(): ModelSelectorState {\r\n return this._modelSelector;\r\n }\r\n\r\n public set modelSelector(selector: ModelSelectorState) {\r\n if (selector === this.modelSelector)\r\n return;\r\n\r\n const isAttached = this.isAttachedToViewport;\r\n this.unregisterModelSelectorListeners();\r\n\r\n this._modelSelector = selector;\r\n\r\n if (isAttached) {\r\n this.registerModelSelectorListeners();\r\n this.onViewedModelsChanged.raiseEvent();\r\n }\r\n }\r\n\r\n /** Create a new *blank* SpatialViewState. The returned SpatialViewState will nave non-persistent empty [[CategorySelectorState]] and [[ModelSelectorState]],\r\n * and a non-persistent [[DisplayStyle3dState]] with default values for all of its components. Generally after creating a blank SpatialViewState,\r\n * callers will modify the state to suit specific needs.\r\n * @param iModel The IModelConnection for the new SpatialViewState\r\n * @param origin The origin for the new SpatialViewState\r\n * @param extents The extents for the new SpatialViewState\r\n * @param rotation The rotation of the new SpatialViewState. If undefined, use top view.\r\n * @public\r\n */\r\n public static createBlank(iModel: IModelConnection, origin: XYAndZ, extents: XYAndZ, rotation?: Matrix3d): SpatialViewState {\r\n const blank = {} as any;\r\n const cat = new CategorySelectorState(blank, iModel);\r\n const modelSelectorState = new ModelSelectorState(blank, iModel);\r\n const displayStyleState = new DisplayStyle3dState(blank, iModel);\r\n const view = new this(blank, iModel, cat, displayStyleState, modelSelectorState);\r\n view.setOrigin(origin);\r\n view.setExtents(extents);\r\n if (undefined !== rotation)\r\n view.setRotation(rotation);\r\n return view;\r\n }\r\n\r\n public static override createFromProps(props: ViewStateProps, iModel: IModelConnection): SpatialViewState {\r\n const cat = new CategorySelectorState(props.categorySelectorProps, iModel);\r\n const displayStyleState = new DisplayStyle3dState(props.displayStyleProps, iModel);\r\n const modelSelectorState = new ModelSelectorState(props.modelSelectorProps!, iModel);\r\n return new this(props.viewDefinitionProps as SpatialViewDefinitionProps, iModel, cat, displayStyleState, modelSelectorState);\r\n }\r\n\r\n public override toProps(): ViewStateProps {\r\n const props = super.toProps();\r\n props.modelSelectorProps = this.modelSelector.toJSON();\r\n return props;\r\n }\r\n\r\n constructor(props: SpatialViewDefinitionProps, iModel: IModelConnection, arg3: CategorySelectorState, displayStyle: DisplayStyle3dState, modelSelector: ModelSelectorState) {\r\n super(props, iModel, arg3, displayStyle);\r\n this._modelSelector = modelSelector;\r\n if (arg3 instanceof SpatialViewState) // from clone\r\n this._modelSelector = arg3.modelSelector.clone();\r\n\r\n this._treeRefs = SpatialTileTreeReferences.create(this);\r\n }\r\n\r\n /** @internal */\r\n public override isSpatialView(): this is SpatialViewState { return true; }\r\n\r\n public override equals(other: this): boolean { return super.equals(other) && this.modelSelector.equals(other.modelSelector); }\r\n\r\n public override createAuxCoordSystem(acsName: string): AuxCoordSystemState { return AuxCoordSystemSpatialState.createNew(acsName, this.iModel); }\r\n public get defaultExtentLimits() { return { min: Constant.oneMillimeter, max: 3 * Constant.diameterOfEarth }; } // Increased max by 3X to support globe mode.\r\n\r\n /** @internal */\r\n public markModelSelectorChanged(): void {\r\n this._treeRefs.update();\r\n }\r\n\r\n /** Get world-space viewed extents based on the iModel's project extents. */\r\n protected getDisplayedExtents(): AxisAlignedBox3d {\r\n const extents = Range3d.fromJSON<AxisAlignedBox3d>(this.iModel.displayedExtents);\r\n extents.scaleAboutCenterInPlace(1.0001); // projectExtents. lying smack up against the extents is not excluded by frustum...\r\n extents.extendRange(this.getGroundExtents());\r\n return extents;\r\n }\r\n\r\n /** Compute world-space range appropriate for fitting the view. If that range is null, use the displayed extents. */\r\n public computeFitRange(): AxisAlignedBox3d {\r\n // Loop over the current models in the model selector with loaded tile trees and union their ranges\r\n const range = new Range3d();\r\n this.forEachTileTreeRef((ref) => {\r\n ref.unionFitRange(range);\r\n });\r\n\r\n if (range.isNull)\r\n range.setFrom(this.getDisplayedExtents());\r\n\r\n range.ensureMinLengths(1.0);\r\n\r\n return range;\r\n }\r\n\r\n public getViewedExtents(): AxisAlignedBox3d {\r\n const extents = this.getDisplayedExtents();\r\n\r\n // Some displayed tile trees may have a transform applied that takes them outside of the displayed extents.\r\n extents.extendRange(this.computeFitRange());\r\n\r\n return extents;\r\n }\r\n\r\n public override toJSON(): SpatialViewDefinitionProps {\r\n const val = super.toJSON() as SpatialViewDefinitionProps;\r\n val.modelSelectorId = this.modelSelector.id;\r\n return val;\r\n }\r\n public override async load(): Promise<void> {\r\n await super.load();\r\n return this.modelSelector.load();\r\n }\r\n public viewsModel(modelId: Id64String): boolean { return this.modelSelector.containsModel(modelId); }\r\n public clearViewedModels() { this.modelSelector.models.clear(); }\r\n public addViewedModel(id: Id64String) { this.modelSelector.addModels(id); }\r\n public removeViewedModel(id: Id64String) { this.modelSelector.dropModels(id); }\r\n\r\n public forEachModel(func: (model: GeometricModelState) => void) {\r\n for (const modelId of this.modelSelector.models) {\r\n const model = this.iModel.models.getLoaded(modelId);\r\n if (undefined !== model && undefined !== model.asGeometricModel3d)\r\n func(model as GeometricModel3dState);\r\n }\r\n }\r\n\r\n /** @internal */\r\n public override forEachModelTreeRef(func: (treeRef: TileTreeReference) => void): void {\r\n for (const ref of this._treeRefs)\r\n func(ref);\r\n }\r\n\r\n /** @internal */\r\n public override createScene(context: SceneContext): void {\r\n super.createScene(context);\r\n context.textureDrapes.forEach((drape) => drape.collectGraphics(context));\r\n context.viewport.target.updateSolarShadows(this.getDisplayStyle3d().wantShadows ? context : undefined);\r\n }\r\n\r\n /** @internal */\r\n public override attachToViewport(args: AttachToViewportArgs): void {\r\n super.attachToViewport(args);\r\n this.registerModelSelectorListeners();\r\n }\r\n\r\n /** @internal */\r\n public override detachFromViewport(): void {\r\n super.detachFromViewport();\r\n this.unregisterModelSelectorListeners();\r\n }\r\n\r\n private registerModelSelectorListeners(): void {\r\n const models = this.modelSelector.observableModels;\r\n const func = () => {\r\n this.markModelSelectorChanged();\r\n this.onViewedModelsChanged.raiseEvent();\r\n };\r\n\r\n this._unregisterModelSelectorListeners.push(models.onAdded.addListener(func));\r\n this._unregisterModelSelectorListeners.push(models.onDeleted.addListener(func));\r\n this._unregisterModelSelectorListeners.push(models.onCleared.addListener(func));\r\n }\r\n\r\n private unregisterModelSelectorListeners(): void {\r\n this._unregisterModelSelectorListeners.forEach((f) => f());\r\n this._unregisterModelSelectorListeners.length = 0;\r\n }\r\n}\r\n/** Defines a spatial view that displays geometry on the image plane using a parallel orthographic projection.\r\n * @public\r\n */\r\nexport class OrthographicViewState extends SpatialViewState {\r\n /** @internal */\r\n public static override get className() { return \"OrthographicViewDefinition\"; }\r\n\r\n constructor(props: SpatialViewDefinitionProps, iModel: IModelConnection, categories: CategorySelectorState, displayStyle: DisplayStyle3dState, modelSelector: ModelSelectorState) { super(props, iModel, categories, displayStyle, modelSelector); }\r\n\r\n public override supportsCamera(): boolean { return false; }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"SpatialViewState.js","sourceRoot":"","sources":["../../src/SpatialViewState.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAc,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAY,OAAO,EAAU,MAAM,sBAAsB,CAAC;AAE3E,OAAO,EAAE,0BAA0B,EAAuB,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAI1D,OAAO,EAAwB,WAAW,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAqB,MAAM,iBAAiB,CAAC;AAE/E;;;GAGG;AACH,MAAM,OAAO,gBAAiB,SAAQ,WAAW;IAmE/C,YAAY,KAAiC,EAAE,MAAwB,EAAE,IAA2B,EAAE,YAAiC,EAAE,aAAiC;QACxK,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;QA9D1B,sCAAiC,GAAmB,EAAE,CAAC;QAExE;;WAEG;QACa,0BAAqB,GAAG,IAAI,OAAO,EAAc,CAAC;QA0DhE,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;QACpC,IAAI,IAAI,YAAY,gBAAgB,EAAE,aAAa;YACjD,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;QAEnD,IAAI,CAAC,SAAS,GAAG,yBAAyB,CAAC,MAA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MAAwB,EAAE,UAAiC,EAAE,YAAiC,EAAE,aAAiC,IAAI,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IAEpO,cAAc,KAAc,OAAO,KAAK,CAAC,CAAC,CAAC;CAC5D","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 Views\r\n */\r\n\r\nimport { BeEvent, Id64String } from \"@itwin/core-bentley\";\r\nimport { Constant, Matrix3d, Range3d, XYAndZ } from \"@itwin/core-geometry\";\r\nimport { AxisAlignedBox3d, SpatialViewDefinitionProps, ViewStateProps } from \"@itwin/core-common\";\r\nimport { AuxCoordSystemSpatialState, AuxCoordSystemState } from \"./AuxCoordSys\";\r\nimport { ModelSelectorState } from \"./ModelSelectorState\";\r\nimport { CategorySelectorState } from \"./CategorySelectorState\";\r\nimport { DisplayStyle3dState } from \"./DisplayStyleState\";\r\nimport { GeometricModel3dState, GeometricModelState } from \"./ModelState\";\r\nimport { SceneContext } from \"./ViewContext\";\r\nimport { IModelConnection } from \"./IModelConnection\";\r\nimport { AttachToViewportArgs, ViewState3d } from \"./ViewState\";\r\nimport { SpatialTileTreeReferences, TileTreeReference } from \"./tile/internal\";\r\n\r\n/** Defines a view of one or more SpatialModels.\r\n * The list of viewed models is stored in the ModelSelector.\r\n * @public\r\n */\r\nexport class SpatialViewState extends ViewState3d {\r\n /** @internal */\r\n public static override get className() { return \"SpatialViewDefinition\"; }\r\n\r\n private readonly _treeRefs: SpatialTileTreeReferences;\r\n private _modelSelector: ModelSelectorState;\r\n private readonly _unregisterModelSelectorListeners: VoidFunction[] = [];\r\n\r\n /** An event raised when the set of models viewed by this view changes, *only* if the view is attached to a [[Viewport]].\r\n * @public\r\n */\r\n public readonly onViewedModelsChanged = new BeEvent<() => void>();\r\n\r\n public get modelSelector(): ModelSelectorState {\r\n return this._modelSelector;\r\n }\r\n\r\n public set modelSelector(selector: ModelSelectorState) {\r\n if (selector === this.modelSelector)\r\n return;\r\n\r\n const isAttached = this.isAttachedToViewport;\r\n this.unregisterModelSelectorListeners();\r\n\r\n this._modelSelector = selector;\r\n\r\n if (isAttached) {\r\n this.registerModelSelectorListeners();\r\n this.onViewedModelsChanged.raiseEvent();\r\n }\r\n }\r\n\r\n /** Create a new *blank* SpatialViewState. The returned SpatialViewState will nave non-persistent empty [[CategorySelectorState]] and [[ModelSelectorState]],\r\n * and a non-persistent [[DisplayStyle3dState]] with default values for all of its components. Generally after creating a blank SpatialViewState,\r\n * callers will modify the state to suit specific needs.\r\n * @param iModel The IModelConnection for the new SpatialViewState\r\n * @param origin The origin for the new SpatialViewState\r\n * @param extents The extents for the new SpatialViewState\r\n * @param rotation The rotation of the new SpatialViewState. If undefined, use top view.\r\n * @public\r\n */\r\n public static createBlank(iModel: IModelConnection, origin: XYAndZ, extents: XYAndZ, rotation?: Matrix3d): SpatialViewState {\r\n const blank = {} as any;\r\n const cat = new CategorySelectorState(blank, iModel);\r\n const modelSelectorState = new ModelSelectorState(blank, iModel);\r\n const displayStyleState = new DisplayStyle3dState(blank, iModel);\r\n const view = new this(blank, iModel, cat, displayStyleState, modelSelectorState);\r\n view.setOrigin(origin);\r\n view.setExtents(extents);\r\n if (undefined !== rotation)\r\n view.setRotation(rotation);\r\n return view;\r\n }\r\n\r\n public static override createFromProps(props: ViewStateProps, iModel: IModelConnection): SpatialViewState {\r\n const cat = new CategorySelectorState(props.categorySelectorProps, iModel);\r\n const displayStyleState = new DisplayStyle3dState(props.displayStyleProps, iModel);\r\n const modelSelectorState = new ModelSelectorState(props.modelSelectorProps!, iModel);\r\n return new this(props.viewDefinitionProps as SpatialViewDefinitionProps, iModel, cat, displayStyleState, modelSelectorState);\r\n }\r\n\r\n public override toProps(): ViewStateProps {\r\n const props = super.toProps();\r\n props.modelSelectorProps = this.modelSelector.toJSON();\r\n return props;\r\n }\r\n\r\n constructor(props: SpatialViewDefinitionProps, iModel: IModelConnection, arg3: CategorySelectorState, displayStyle: DisplayStyle3dState, modelSelector: ModelSelectorState) {\r\n super(props, iModel, arg3, displayStyle);\r\n this._modelSelector = modelSelector;\r\n if (arg3 instanceof SpatialViewState) // from clone\r\n this._modelSelector = arg3.modelSelector.clone();\r\n\r\n this._treeRefs = SpatialTileTreeReferences.create(this);\r\n }\r\n\r\n /** @internal */\r\n public override isSpatialView(): this is SpatialViewState { return true; }\r\n\r\n public override equals(other: this): boolean { return super.equals(other) && this.modelSelector.equals(other.modelSelector); }\r\n\r\n public override createAuxCoordSystem(acsName: string): AuxCoordSystemState { return AuxCoordSystemSpatialState.createNew(acsName, this.iModel); }\r\n public get defaultExtentLimits() { return { min: Constant.oneMillimeter, max: 3 * Constant.diameterOfEarth }; } // Increased max by 3X to support globe mode.\r\n\r\n /** @internal */\r\n public markModelSelectorChanged(): void {\r\n this._treeRefs.update();\r\n }\r\n\r\n /** Get world-space viewed extents based on the iModel's project extents. */\r\n protected getDisplayedExtents(): AxisAlignedBox3d {\r\n const extents = Range3d.fromJSON<AxisAlignedBox3d>(this.iModel.displayedExtents);\r\n extents.scaleAboutCenterInPlace(1.0001); // projectExtents. lying smack up against the extents is not excluded by frustum...\r\n extents.extendRange(this.getGroundExtents());\r\n return extents;\r\n }\r\n\r\n /** Compute world-space range appropriate for fitting the view. If that range is null, use the displayed extents. */\r\n public computeFitRange(): AxisAlignedBox3d {\r\n // Loop over the current models in the model selector with loaded tile trees and union their ranges\r\n const range = new Range3d();\r\n this.forEachTileTreeRef((ref) => {\r\n ref.unionFitRange(range);\r\n });\r\n\r\n if (range.isNull)\r\n range.setFrom(this.getDisplayedExtents());\r\n\r\n range.ensureMinLengths(1.0);\r\n\r\n return range;\r\n }\r\n\r\n public getViewedExtents(): AxisAlignedBox3d {\r\n const extents = this.getDisplayedExtents();\r\n\r\n // Some displayed tile trees may have a transform applied that takes them outside of the displayed extents.\r\n extents.extendRange(this.computeFitRange());\r\n\r\n return extents;\r\n }\r\n\r\n public override toJSON(): SpatialViewDefinitionProps {\r\n const val = super.toJSON() as SpatialViewDefinitionProps;\r\n val.modelSelectorId = this.modelSelector.id;\r\n return val;\r\n }\r\n public override async load(): Promise<void> {\r\n await super.load();\r\n return this.modelSelector.load();\r\n }\r\n public viewsModel(modelId: Id64String): boolean { return this.modelSelector.containsModel(modelId); }\r\n public clearViewedModels() { this.modelSelector.models.clear(); }\r\n public addViewedModel(id: Id64String) { this.modelSelector.addModels(id); }\r\n public removeViewedModel(id: Id64String) { this.modelSelector.dropModels(id); }\r\n\r\n public forEachModel(func: (model: GeometricModelState) => void) {\r\n for (const modelId of this.modelSelector.models) {\r\n const model = this.iModel.models.getLoaded(modelId);\r\n if (undefined !== model && undefined !== model.asGeometricModel3d)\r\n func(model as GeometricModel3dState);\r\n }\r\n }\r\n\r\n /** @internal */\r\n public override forEachModelTreeRef(func: (treeRef: TileTreeReference) => void): void {\r\n for (const ref of this._treeRefs)\r\n func(ref);\r\n }\r\n\r\n /** @internal */\r\n public override createScene(context: SceneContext): void {\r\n super.createScene(context);\r\n context.textureDrapes.forEach((drape) => drape.collectGraphics(context));\r\n context.viewport.target.updateSolarShadows(this.getDisplayStyle3d().wantShadows ? context : undefined);\r\n }\r\n\r\n /** @internal */\r\n public override attachToViewport(args: AttachToViewportArgs): void {\r\n super.attachToViewport(args);\r\n this.registerModelSelectorListeners();\r\n }\r\n\r\n /** @internal */\r\n public override detachFromViewport(): void {\r\n super.detachFromViewport();\r\n this.unregisterModelSelectorListeners();\r\n }\r\n\r\n /** Chiefly for debugging: change the \"deactivated\" state of one or more tile tree references. Deactivated references are\r\n * omitted when iterating the references, so e.g. their graphics are omitted from the scene.\r\n * @param modelIds The Ids of one or more models whose tile tree references are to be affected. If omitted, all models are affected.\r\n * @param deactivated True to deactivate the specified references, false to reactivate them, undefined to invert each one's current state.\r\n * @param which The references to be affected as either a broad category or one or more indices of animated references.\r\n * @internal\r\n */\r\n public setTileTreeReferencesDeactivated(modelIds: Id64String | Id64String[] | undefined, deactivated: boolean | undefined, which: \"all\" | \"animated\" | \"primary\" | \"section\" | number[]): void {\r\n this._treeRefs.setDeactivated(modelIds, deactivated, which);\r\n }\r\n\r\n private registerModelSelectorListeners(): void {\r\n const models = this.modelSelector.observableModels;\r\n const func = () => {\r\n this.markModelSelectorChanged();\r\n this.onViewedModelsChanged.raiseEvent();\r\n };\r\n\r\n this._unregisterModelSelectorListeners.push(models.onAdded.addListener(func));\r\n this._unregisterModelSelectorListeners.push(models.onDeleted.addListener(func));\r\n this._unregisterModelSelectorListeners.push(models.onCleared.addListener(func));\r\n }\r\n\r\n private unregisterModelSelectorListeners(): void {\r\n this._unregisterModelSelectorListeners.forEach((f) => f());\r\n this._unregisterModelSelectorListeners.length = 0;\r\n }\r\n}\r\n/** Defines a spatial view that displays geometry on the image plane using a parallel orthographic projection.\r\n * @public\r\n */\r\nexport class OrthographicViewState extends SpatialViewState {\r\n /** @internal */\r\n public static override get className() { return \"OrthographicViewDefinition\"; }\r\n\r\n constructor(props: SpatialViewDefinitionProps, iModel: IModelConnection, categories: CategorySelectorState, displayStyle: DisplayStyle3dState, modelSelector: ModelSelectorState) { super(props, iModel, categories, displayStyle, modelSelector); }\r\n\r\n public override supportsCamera(): boolean { return false; }\r\n}\r\n"]}
|
|
@@ -100,7 +100,7 @@ export class SubCategoriesCache {
|
|
|
100
100
|
return undefined;
|
|
101
101
|
try {
|
|
102
102
|
const ecsql = this._ecsql[this._curECSqlIndex];
|
|
103
|
-
for await (const row of this._imodel.query(ecsql, undefined, QueryRowFormat.UseJsPropertyNames)) {
|
|
103
|
+
for await (const row of this._imodel.query(ecsql, undefined, { rowFormat: QueryRowFormat.UseJsPropertyNames })) {
|
|
104
104
|
this._result.push(row);
|
|
105
105
|
if (this.wasCanceled)
|
|
106
106
|
return undefined;
|
|
@@ -1 +1 @@
|
|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AI,EAAE,CAAC;qBACV;yBAAM;wBACL,kFAAkF;wBAClF,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;qBAClC;iBACF;YACH,CAAC,CAAC,CAAC;QACL,CAAC;QAEO,QAAQ,CAAC,WAAoB,EAAE,IAAe;YACpD,MAAM,CAAC,SAAS,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAC;YACpC,MAAM,CAAC,SAAS,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAC;YAEpC,IAAI,SAAS,KAAK,IAAI,CAAC,KAAK,EAAE;gBAC5B,2DAA2D;gBAC3D,sJAAsJ;gBACtJ,iIAAiI;gBACjI,IAAI,CAAC,KAAK,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;aACpE;iBAAM;gBACL,mGAAmG;gBACnG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC5B,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;oBACjD,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;aAC1C;QACH,CAAC;KACF;IAvGY,wBAAK,QAuGjB,CAAA;AACH,CAAC,EAvLgB,kBAAkB,KAAlB,kBAAkB,QAuLlC","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\r\nimport { assert, Id64, Id64Arg, Id64Set, Id64String } from \"@itwin/core-bentley\";\r\nimport { QueryRowFormat, SubCategoryAppearance } from \"@itwin/core-common\";\r\nimport { IModelConnection } from \"./IModelConnection\";\r\n\r\n/** A cancelable paginated request for subcategory information.\r\n * @see SubCategoriesCache\r\n * @internal\r\n */\r\nexport interface SubCategoriesRequest {\r\n /** The Ids of any categories which were requested but were not yet loaded. */\r\n readonly missingCategoryIds: Id64Set;\r\n /** A promise which resolves to true when all of the requested categories have been loaded, or to false if not all categories were loaded.\r\n * Categories may fail to load if the request is explicitly canceled or if the IModelConnection is closed before all categories are loaded.\r\n */\r\n readonly promise: Promise<boolean>;\r\n /** Cancels the request. */\r\n cancel(): void;\r\n}\r\n\r\nconst invalidCategoryIdEntry = new Set<string>();\r\n\r\n/** A cache of information about the subcategories contained within an [[IModelConnection]]. It is populated on demand.\r\n * @internal\r\n */\r\nexport class SubCategoriesCache {\r\n private readonly _byCategoryId = new Map<string, Id64Set>();\r\n private readonly _appearances = new Map<string, SubCategoryAppearance>();\r\n private readonly _imodel: IModelConnection;\r\n\r\n public constructor(imodel: IModelConnection) { this._imodel = imodel; }\r\n\r\n /** Get the Ids of all subcategories belonging to the category with the specified Id, or undefined if no such information is present. */\r\n public getSubCategories(categoryId: string): Id64Set | undefined { return this._byCategoryId.get(categoryId); }\r\n\r\n /** Get the base appearance of the subcategory with the specified Id, or undefined if no such information is present. */\r\n public getSubCategoryAppearance(subCategoryId: Id64String): SubCategoryAppearance | undefined { return this._appearances.get(subCategoryId.toString()); }\r\n\r\n /** Request that the subcategory information for all of the specified categories is loaded.\r\n * If all such information has already been loaded, returns undefined.\r\n * Otherwise, dispatches an asynchronous request to load those categories which are not already loaded and returns a cancellable request object\r\n * containing the corresponding promise and the set of categories still to be loaded.\r\n */\r\n public load(categoryIds: Id64Arg): SubCategoriesRequest | undefined {\r\n let missing: Id64Set | undefined;\r\n for (const catId of Id64.iterable(categoryIds)) {\r\n if (undefined === this._byCategoryId.get(catId)) {\r\n if (undefined === missing)\r\n missing = new Set<string>();\r\n\r\n missing.add(catId);\r\n }\r\n }\r\n\r\n if (undefined === missing)\r\n return undefined;\r\n\r\n const request = new SubCategoriesCache.Request(missing, this._imodel);\r\n const promise = request.dispatch().then((result?: SubCategoriesCache.Result) => {\r\n if (undefined !== result)\r\n this.processResults(result, missing!);\r\n\r\n return !request.wasCanceled;\r\n });\r\n\r\n return {\r\n missingCategoryIds: missing,\r\n promise,\r\n cancel: () => request.cancel(),\r\n };\r\n }\r\n\r\n public clear(): void {\r\n this._byCategoryId.clear();\r\n this._appearances.clear();\r\n }\r\n\r\n public onIModelConnectionClose(): void {\r\n this.clear();\r\n }\r\n\r\n private static createSubCategoryAppearance(json?: any) {\r\n let props: SubCategoryAppearance.Props | undefined;\r\n if (\"string\" === typeof json && 0 < json.length)\r\n props = JSON.parse(json);\r\n\r\n return new SubCategoryAppearance(props);\r\n }\r\n\r\n private processResults(result: SubCategoriesCache.Result, missing: Id64Set): void {\r\n for (const row of result)\r\n this.add(row.parentId, row.id, SubCategoriesCache.createSubCategoryAppearance(row.appearance));\r\n\r\n // Ensure that any category Ids which returned no results (e.g., non-existent category, invalid Id, etc) are still recorded so they are not repeatedly re-requested\r\n for (const id of missing)\r\n if (undefined === this._byCategoryId.get(id))\r\n this._byCategoryId.set(id, invalidCategoryIdEntry);\r\n }\r\n\r\n private add(categoryId: string, subCategoryId: string, appearance: SubCategoryAppearance) {\r\n let set = this._byCategoryId.get(categoryId);\r\n if (undefined === set)\r\n this._byCategoryId.set(categoryId, set = new Set<string>());\r\n\r\n set.add(subCategoryId);\r\n this._appearances.set(subCategoryId, appearance);\r\n }\r\n}\r\n\r\n/** This namespace and the types within it are exported strictly for use in tests.\r\n * @internal\r\n */\r\nexport namespace SubCategoriesCache { // eslint-disable-line no-redeclare\r\n export interface ResultRow {\r\n parentId: Id64String;\r\n id: Id64String;\r\n appearance: SubCategoryAppearance.Props;\r\n }\r\n\r\n export type Result = ResultRow[];\r\n\r\n export class Request {\r\n private readonly _imodel: IModelConnection;\r\n private readonly _ecsql: string[] = [];\r\n private readonly _result: Result = [];\r\n private _canceled = false;\r\n private _curECSqlIndex = 0;\r\n\r\n public get wasCanceled() { return this._canceled || this._imodel.isClosed; }\r\n\r\n public constructor(categoryIds: Set<string>, imodel: IModelConnection, maxCategoriesPerQuery = 200) {\r\n this._imodel = imodel;\r\n\r\n const catIds = [...categoryIds];\r\n while (catIds.length !== 0) {\r\n const end = (catIds.length > maxCategoriesPerQuery) ? maxCategoriesPerQuery : catIds.length;\r\n const where = catIds.splice(0, end).join(\",\");\r\n this._ecsql.push(`SELECT ECInstanceId as id, Parent.Id as parentId, Properties as appearance FROM BisCore.SubCategory WHERE Parent.Id IN (${where})`);\r\n }\r\n }\r\n\r\n public cancel() { this._canceled = true; }\r\n\r\n public async dispatch(): Promise<Result | undefined> {\r\n if (this.wasCanceled || this._curECSqlIndex >= this._ecsql.length) // handle case of empty category Id set...\r\n return undefined;\r\n\r\n try {\r\n const ecsql = this._ecsql[this._curECSqlIndex];\r\n for await (const row of this._imodel.query(ecsql, undefined, QueryRowFormat.UseJsPropertyNames)) {\r\n this._result.push(row as ResultRow);\r\n if (this.wasCanceled)\r\n return undefined;\r\n }\r\n } catch {\r\n // ###TODO: detect cases in which retry is warranted\r\n // Note that currently, if we succeed in obtaining some pages of results and fail to retrieve another page, we will end up processing the\r\n // incomplete results. Since we're not retrying, that's the best we can do.\r\n }\r\n\r\n // Finished with current ECSql query. Dispatch the next if one exists.\r\n if (++this._curECSqlIndex < this._ecsql.length) {\r\n if (this.wasCanceled)\r\n return undefined;\r\n else\r\n return this.dispatch();\r\n }\r\n\r\n // Even if we were canceled, we've retrieved all the rows. Might as well process them to prevent another request for some of the same rows from being enqueued.\r\n return this._result;\r\n }\r\n }\r\n\r\n export type QueueFunc = () => void;\r\n\r\n export class QueueEntry {\r\n public readonly categoryIds: Id64Set;\r\n public readonly funcs: QueueFunc[];\r\n\r\n public constructor(categoryIds: Id64Set, func: QueueFunc) {\r\n this.categoryIds = categoryIds;\r\n this.funcs = [func];\r\n }\r\n }\r\n\r\n /** A \"queue\" of SubCategoriesRequests, which consists of between 0 and 2 entries. Each entry specifies the set of category IDs to be loaded and a list of functions to be executed\r\n * when loading is completed. This is used to enforce ordering of operations upon subcategories despite the need to asynchronously load them. It incidentally also provides an\r\n * opportunity to reduce the number of backend requests by batching consecutive requests.\r\n * Chiefly used by [[Viewport]].\r\n * @internal\r\n */\r\n export class Queue {\r\n /* NB: Members marked protected for use in tests only. */\r\n protected _current?: QueueEntry;\r\n protected _next?: QueueEntry;\r\n protected _request?: SubCategoriesRequest;\r\n protected _disposed = false;\r\n\r\n /** Push a request onto the queue. The requested categories will be loaded if necessary, and then\r\n * the supplied function will be invoked. Any previously-pushed requests are guaranteed to be processed before this one.\r\n */\r\n public push(cache: SubCategoriesCache, categoryIds: Id64Arg, func: QueueFunc): void {\r\n if (this._disposed)\r\n return;\r\n else if (undefined === this._current)\r\n this.pushCurrent(cache, categoryIds, func);\r\n else\r\n this.pushNext(categoryIds, func);\r\n }\r\n\r\n /** Cancel all requests and empty the queue. */\r\n public dispose(): void {\r\n if (undefined !== this._request) {\r\n assert(undefined !== this._current);\r\n this._request.cancel();\r\n this._request = undefined;\r\n }\r\n\r\n this._current = this._next = undefined;\r\n this._disposed = true;\r\n }\r\n\r\n public get isEmpty(): boolean {\r\n return undefined === this._current && undefined === this._next;\r\n }\r\n\r\n private pushCurrent(cache: SubCategoriesCache, categoryIds: Id64Arg, func: QueueFunc): void {\r\n assert(undefined === this._next);\r\n assert(undefined === this._current);\r\n assert(undefined === this._request);\r\n\r\n this._request = cache.load(categoryIds);\r\n if (undefined === this._request) {\r\n // All requested categories are already loaded.\r\n func();\r\n return;\r\n } else {\r\n // We need to load the requested categories before invoking the function.\r\n this.processCurrent(cache, new QueueEntry(Id64.toIdSet(categoryIds, true), func));\r\n }\r\n }\r\n\r\n private processCurrent(cache: SubCategoriesCache, entry: QueueEntry): void {\r\n assert(undefined !== this._request);\r\n assert(undefined === this._current);\r\n assert(undefined === this._next);\r\n\r\n this._current = entry;\r\n this._request.promise.then((completed: boolean) => { // eslint-disable-line @typescript-eslint/no-floating-promises\r\n if (this._disposed)\r\n return;\r\n\r\n // Invoke all the functions which were awaiting this set of categories.\r\n assert(undefined !== this._current);\r\n if (completed)\r\n for (const func of this._current.funcs)\r\n func();\r\n\r\n this._request = undefined;\r\n this._current = undefined;\r\n\r\n // If we have more requests, process them.\r\n const next = this._next;\r\n this._next = undefined;\r\n if (undefined !== next) {\r\n this._request = cache.load(next.categoryIds);\r\n if (undefined === this._request) {\r\n // All categories loaded.\r\n for (const func of next.funcs)\r\n func();\r\n } else {\r\n // We need to load the requested categories before invoking the pending functions.\r\n this.processCurrent(cache, next);\r\n }\r\n }\r\n });\r\n }\r\n\r\n private pushNext(categoryIds: Id64Arg, func: QueueFunc): void {\r\n assert(undefined !== this._current);\r\n assert(undefined !== this._request);\r\n\r\n if (undefined === this._next) {\r\n // We have a request currently in process and none pending.\r\n // We could potentially determine that this request doesn't require any categories that are not already loaded or being loaded by the current request.\r\n // But we will find that out (synchronously) when current request completes, unless more requests come in. Probably not worth it.\r\n this._next = new QueueEntry(Id64.toIdSet(categoryIds, true), func);\r\n } else {\r\n // We have a request currently in process, and one or more pending. Append this one to the pending.\r\n this._next.funcs.push(func);\r\n for (const categoryId of Id64.iterable(categoryIds))\r\n this._next.categoryIds.add(categoryId);\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"SubCategoriesCache.js","sourceRoot":"","sources":["../../src/SubCategoriesCache.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,MAAM,EAAE,IAAI,EAAgC,MAAM,qBAAqB,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAkB3E,MAAM,sBAAsB,GAAG,IAAI,GAAG,EAAU,CAAC;AAEjD;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAK7B,YAAmB,MAAwB;QAJ1B,kBAAa,GAAG,IAAI,GAAG,EAAmB,CAAC;QAC3C,iBAAY,GAAG,IAAI,GAAG,EAAiC,CAAC;QAG1B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IAAC,CAAC;IAE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AAO,CAAC,WAAW,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;aACpE;iBAAM;gBACL,mGAAmG;gBACnG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC5B,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;oBACjD,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;aAC1C;QACH,CAAC;KACF;IAvGY,wBAAK,QAuGjB,CAAA;AACH,CAAC,EAvLgB,kBAAkB,KAAlB,kBAAkB,QAuLlC","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\r\nimport { assert, Id64, Id64Arg, Id64Set, Id64String } from \"@itwin/core-bentley\";\r\nimport { QueryRowFormat, SubCategoryAppearance } from \"@itwin/core-common\";\r\nimport { IModelConnection } from \"./IModelConnection\";\r\n\r\n/** A cancelable paginated request for subcategory information.\r\n * @see SubCategoriesCache\r\n * @internal\r\n */\r\nexport interface SubCategoriesRequest {\r\n /** The Ids of any categories which were requested but were not yet loaded. */\r\n readonly missingCategoryIds: Id64Set;\r\n /** A promise which resolves to true when all of the requested categories have been loaded, or to false if not all categories were loaded.\r\n * Categories may fail to load if the request is explicitly canceled or if the IModelConnection is closed before all categories are loaded.\r\n */\r\n readonly promise: Promise<boolean>;\r\n /** Cancels the request. */\r\n cancel(): void;\r\n}\r\n\r\nconst invalidCategoryIdEntry = new Set<string>();\r\n\r\n/** A cache of information about the subcategories contained within an [[IModelConnection]]. It is populated on demand.\r\n * @internal\r\n */\r\nexport class SubCategoriesCache {\r\n private readonly _byCategoryId = new Map<string, Id64Set>();\r\n private readonly _appearances = new Map<string, SubCategoryAppearance>();\r\n private readonly _imodel: IModelConnection;\r\n\r\n public constructor(imodel: IModelConnection) { this._imodel = imodel; }\r\n\r\n /** Get the Ids of all subcategories belonging to the category with the specified Id, or undefined if no such information is present. */\r\n public getSubCategories(categoryId: string): Id64Set | undefined { return this._byCategoryId.get(categoryId); }\r\n\r\n /** Get the base appearance of the subcategory with the specified Id, or undefined if no such information is present. */\r\n public getSubCategoryAppearance(subCategoryId: Id64String): SubCategoryAppearance | undefined { return this._appearances.get(subCategoryId.toString()); }\r\n\r\n /** Request that the subcategory information for all of the specified categories is loaded.\r\n * If all such information has already been loaded, returns undefined.\r\n * Otherwise, dispatches an asynchronous request to load those categories which are not already loaded and returns a cancellable request object\r\n * containing the corresponding promise and the set of categories still to be loaded.\r\n */\r\n public load(categoryIds: Id64Arg): SubCategoriesRequest | undefined {\r\n let missing: Id64Set | undefined;\r\n for (const catId of Id64.iterable(categoryIds)) {\r\n if (undefined === this._byCategoryId.get(catId)) {\r\n if (undefined === missing)\r\n missing = new Set<string>();\r\n\r\n missing.add(catId);\r\n }\r\n }\r\n\r\n if (undefined === missing)\r\n return undefined;\r\n\r\n const request = new SubCategoriesCache.Request(missing, this._imodel);\r\n const promise = request.dispatch().then((result?: SubCategoriesCache.Result) => {\r\n if (undefined !== result)\r\n this.processResults(result, missing!);\r\n\r\n return !request.wasCanceled;\r\n });\r\n\r\n return {\r\n missingCategoryIds: missing,\r\n promise,\r\n cancel: () => request.cancel(),\r\n };\r\n }\r\n\r\n public clear(): void {\r\n this._byCategoryId.clear();\r\n this._appearances.clear();\r\n }\r\n\r\n public onIModelConnectionClose(): void {\r\n this.clear();\r\n }\r\n\r\n private static createSubCategoryAppearance(json?: any) {\r\n let props: SubCategoryAppearance.Props | undefined;\r\n if (\"string\" === typeof json && 0 < json.length)\r\n props = JSON.parse(json);\r\n\r\n return new SubCategoryAppearance(props);\r\n }\r\n\r\n private processResults(result: SubCategoriesCache.Result, missing: Id64Set): void {\r\n for (const row of result)\r\n this.add(row.parentId, row.id, SubCategoriesCache.createSubCategoryAppearance(row.appearance));\r\n\r\n // Ensure that any category Ids which returned no results (e.g., non-existent category, invalid Id, etc) are still recorded so they are not repeatedly re-requested\r\n for (const id of missing)\r\n if (undefined === this._byCategoryId.get(id))\r\n this._byCategoryId.set(id, invalidCategoryIdEntry);\r\n }\r\n\r\n private add(categoryId: string, subCategoryId: string, appearance: SubCategoryAppearance) {\r\n let set = this._byCategoryId.get(categoryId);\r\n if (undefined === set)\r\n this._byCategoryId.set(categoryId, set = new Set<string>());\r\n\r\n set.add(subCategoryId);\r\n this._appearances.set(subCategoryId, appearance);\r\n }\r\n}\r\n\r\n/** This namespace and the types within it are exported strictly for use in tests.\r\n * @internal\r\n */\r\nexport namespace SubCategoriesCache { // eslint-disable-line no-redeclare\r\n export interface ResultRow {\r\n parentId: Id64String;\r\n id: Id64String;\r\n appearance: SubCategoryAppearance.Props;\r\n }\r\n\r\n export type Result = ResultRow[];\r\n\r\n export class Request {\r\n private readonly _imodel: IModelConnection;\r\n private readonly _ecsql: string[] = [];\r\n private readonly _result: Result = [];\r\n private _canceled = false;\r\n private _curECSqlIndex = 0;\r\n\r\n public get wasCanceled() { return this._canceled || this._imodel.isClosed; }\r\n\r\n public constructor(categoryIds: Set<string>, imodel: IModelConnection, maxCategoriesPerQuery = 200) {\r\n this._imodel = imodel;\r\n\r\n const catIds = [...categoryIds];\r\n while (catIds.length !== 0) {\r\n const end = (catIds.length > maxCategoriesPerQuery) ? maxCategoriesPerQuery : catIds.length;\r\n const where = catIds.splice(0, end).join(\",\");\r\n this._ecsql.push(`SELECT ECInstanceId as id, Parent.Id as parentId, Properties as appearance FROM BisCore.SubCategory WHERE Parent.Id IN (${where})`);\r\n }\r\n }\r\n\r\n public cancel() { this._canceled = true; }\r\n\r\n public async dispatch(): Promise<Result | undefined> {\r\n if (this.wasCanceled || this._curECSqlIndex >= this._ecsql.length) // handle case of empty category Id set...\r\n return undefined;\r\n\r\n try {\r\n const ecsql = this._ecsql[this._curECSqlIndex];\r\n for await (const row of this._imodel.query(ecsql, undefined, { rowFormat: QueryRowFormat.UseJsPropertyNames })) {\r\n this._result.push(row as ResultRow);\r\n if (this.wasCanceled)\r\n return undefined;\r\n }\r\n } catch {\r\n // ###TODO: detect cases in which retry is warranted\r\n // Note that currently, if we succeed in obtaining some pages of results and fail to retrieve another page, we will end up processing the\r\n // incomplete results. Since we're not retrying, that's the best we can do.\r\n }\r\n\r\n // Finished with current ECSql query. Dispatch the next if one exists.\r\n if (++this._curECSqlIndex < this._ecsql.length) {\r\n if (this.wasCanceled)\r\n return undefined;\r\n else\r\n return this.dispatch();\r\n }\r\n\r\n // Even if we were canceled, we've retrieved all the rows. Might as well process them to prevent another request for some of the same rows from being enqueued.\r\n return this._result;\r\n }\r\n }\r\n\r\n export type QueueFunc = () => void;\r\n\r\n export class QueueEntry {\r\n public readonly categoryIds: Id64Set;\r\n public readonly funcs: QueueFunc[];\r\n\r\n public constructor(categoryIds: Id64Set, func: QueueFunc) {\r\n this.categoryIds = categoryIds;\r\n this.funcs = [func];\r\n }\r\n }\r\n\r\n /** A \"queue\" of SubCategoriesRequests, which consists of between 0 and 2 entries. Each entry specifies the set of category IDs to be loaded and a list of functions to be executed\r\n * when loading is completed. This is used to enforce ordering of operations upon subcategories despite the need to asynchronously load them. It incidentally also provides an\r\n * opportunity to reduce the number of backend requests by batching consecutive requests.\r\n * Chiefly used by [[Viewport]].\r\n * @internal\r\n */\r\n export class Queue {\r\n /* NB: Members marked protected for use in tests only. */\r\n protected _current?: QueueEntry;\r\n protected _next?: QueueEntry;\r\n protected _request?: SubCategoriesRequest;\r\n protected _disposed = false;\r\n\r\n /** Push a request onto the queue. The requested categories will be loaded if necessary, and then\r\n * the supplied function will be invoked. Any previously-pushed requests are guaranteed to be processed before this one.\r\n */\r\n public push(cache: SubCategoriesCache, categoryIds: Id64Arg, func: QueueFunc): void {\r\n if (this._disposed)\r\n return;\r\n else if (undefined === this._current)\r\n this.pushCurrent(cache, categoryIds, func);\r\n else\r\n this.pushNext(categoryIds, func);\r\n }\r\n\r\n /** Cancel all requests and empty the queue. */\r\n public dispose(): void {\r\n if (undefined !== this._request) {\r\n assert(undefined !== this._current);\r\n this._request.cancel();\r\n this._request = undefined;\r\n }\r\n\r\n this._current = this._next = undefined;\r\n this._disposed = true;\r\n }\r\n\r\n public get isEmpty(): boolean {\r\n return undefined === this._current && undefined === this._next;\r\n }\r\n\r\n private pushCurrent(cache: SubCategoriesCache, categoryIds: Id64Arg, func: QueueFunc): void {\r\n assert(undefined === this._next);\r\n assert(undefined === this._current);\r\n assert(undefined === this._request);\r\n\r\n this._request = cache.load(categoryIds);\r\n if (undefined === this._request) {\r\n // All requested categories are already loaded.\r\n func();\r\n return;\r\n } else {\r\n // We need to load the requested categories before invoking the function.\r\n this.processCurrent(cache, new QueueEntry(Id64.toIdSet(categoryIds, true), func));\r\n }\r\n }\r\n\r\n private processCurrent(cache: SubCategoriesCache, entry: QueueEntry): void {\r\n assert(undefined !== this._request);\r\n assert(undefined === this._current);\r\n assert(undefined === this._next);\r\n\r\n this._current = entry;\r\n this._request.promise.then((completed: boolean) => { // eslint-disable-line @typescript-eslint/no-floating-promises\r\n if (this._disposed)\r\n return;\r\n\r\n // Invoke all the functions which were awaiting this set of categories.\r\n assert(undefined !== this._current);\r\n if (completed)\r\n for (const func of this._current.funcs)\r\n func();\r\n\r\n this._request = undefined;\r\n this._current = undefined;\r\n\r\n // If we have more requests, process them.\r\n const next = this._next;\r\n this._next = undefined;\r\n if (undefined !== next) {\r\n this._request = cache.load(next.categoryIds);\r\n if (undefined === this._request) {\r\n // All categories loaded.\r\n for (const func of next.funcs)\r\n func();\r\n } else {\r\n // We need to load the requested categories before invoking the pending functions.\r\n this.processCurrent(cache, next);\r\n }\r\n }\r\n });\r\n }\r\n\r\n private pushNext(categoryIds: Id64Arg, func: QueueFunc): void {\r\n assert(undefined !== this._current);\r\n assert(undefined !== this._request);\r\n\r\n if (undefined === this._next) {\r\n // We have a request currently in process and none pending.\r\n // We could potentially determine that this request doesn't require any categories that are not already loaded or being loaded by the current request.\r\n // But we will find that out (synchronously) when current request completes, unless more requests come in. Probably not worth it.\r\n this._next = new QueueEntry(Id64.toIdSet(categoryIds, true), func);\r\n } else {\r\n // We have a request currently in process, and one or more pending. Append this one to the pending.\r\n this._next.funcs.push(func);\r\n for (const categoryId of Id64.iterable(categoryIds))\r\n this._next.categoryIds.add(categoryId);\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
package/lib/esm/ViewContext.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { GraphicBranch, GraphicBranchOptions } from "./render/GraphicBranch";
|
|
|
12
12
|
import { GraphicBuilder, GraphicType, ViewportGraphicBuilderOptions } from "./render/GraphicBuilder";
|
|
13
13
|
import { RenderGraphic } from "./render/RenderGraphic";
|
|
14
14
|
import { RenderPlanarClassifier } from "./render/RenderPlanarClassifier";
|
|
15
|
-
import { RenderTextureDrape } from "./render/RenderSystem";
|
|
15
|
+
import { RenderSystem, RenderTextureDrape } from "./render/RenderSystem";
|
|
16
16
|
import { RenderTarget } from "./render/RenderTarget";
|
|
17
17
|
import { Scene } from "./render/Scene";
|
|
18
18
|
import { SpatialClassifierTileTreeReference, Tile, TileGraphicType, TileTreeReference } from "./tile/internal";
|
|
@@ -34,6 +34,8 @@ export declare class RenderContext {
|
|
|
34
34
|
getPixelSizeAtPoint(inPoint?: Point3d): number;
|
|
35
35
|
/** The [[Viewport]] associated with this context. */
|
|
36
36
|
get viewport(): Viewport;
|
|
37
|
+
/** The [[RenderSystem]] being used to produce graphics for this context. */
|
|
38
|
+
get renderSystem(): RenderSystem;
|
|
37
39
|
/** @internal */
|
|
38
40
|
get target(): RenderTarget;
|
|
39
41
|
/** @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewContext.d.ts","sourceRoot":"","sources":["../../src/ViewContext.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAU,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EACL,QAA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AG,IAAI;IAclD,6IAA6I;IACtI,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAU1C,gBAAgB;IACT,mBAAmB,IAAI,IAAI;IAIlC,gBAAgB;IACT,mBAAmB,CAAC,iBAAiB,EAAE,UAAU,EAAE,cAAc,CAAC,EAAE,kCAAkC,EAAE,cAAc,CAAC,EAAE,mBAAmB,GAAG,sBAAsB,GAAG,SAAS;IAexL,gBAAgB;IACT,2BAA2B,CAAC,OAAO,EAAE,UAAU;IAItD,gBAAgB;IACT,wBAAwB,CAAC,aAAa,EAAE,iBAAiB,EAAE,YAAY,EAAE,OAAO,GAAG,SAAS,GAAG,kBAAkB,GAAG,SAAS;IAoBpI,gBAAgB;IACT,uBAAuB,CAAC,OAAO,EAAE,UAAU;IAIlD,gBAAgB;IACT,eAAe,CAAC,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,IAAI,GAAG,IAAI;IASrE,+DAA+D;IAC/D,IAAW,QAAQ,oBAAoC;IACvD,2EAA2E;IAC3E,IAAW,kBAAkB,oBAAoC;IACjE,gFAAgF;IAChF,IAAW,eAAe,oBAAiC;IAC3D,gBAAgB;IAChB,IAAW,iBAAiB,wCAA2C;IACvE,gBAAgB;IAChB,IAAW,aAAa,oCAAuC;IAE/D,gBAAgB;IACT,mBAAmB,CAAC,UAAU,EAAE,iBAAiB,EAAE,OAAO,EAAE,UAAU,GAAG,IAAI;CAGrF"}
|
package/lib/esm/ViewContext.js
CHANGED
|
@@ -30,6 +30,10 @@ export class RenderContext {
|
|
|
30
30
|
get viewport() {
|
|
31
31
|
return this._viewport;
|
|
32
32
|
}
|
|
33
|
+
/** The [[RenderSystem]] being used to produce graphics for this context. */
|
|
34
|
+
get renderSystem() {
|
|
35
|
+
return this.target.renderSystem;
|
|
36
|
+
}
|
|
33
37
|
/** @internal */
|
|
34
38
|
get target() { return this.viewport.target; }
|
|
35
39
|
/** @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3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IAC/B,CAAC;IAED,+DAA+D;IAC/D,IAAW,QAAQ,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;IACvD,2EAA2E;IAC3E,IAAW,kBAAkB,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;IACjE,gFAAgF;IAChF,IAAW,eAAe,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAC3D,gBAAgB;IAChB,IAAW,iBAAiB,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC;IACvE,gBAAgB;IAChB,IAAW,aAAa,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;IAE/D,gBAAgB;IACT,mBAAmB,CAAC,UAA6B,EAAE,OAAmB;QAC3E,IAAI,CAAC,KAAK,CAAC,gBAAgB,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC;IACxD,CAAC;CACF","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 Rendering\r\n */\r\n\r\nimport { assert, Id64String } from \"@itwin/core-bentley\";\r\nimport {\r\n Matrix3d, Point2d,\r\n Point3d, Range1d, Transform, XAndY,\r\n} from \"@itwin/core-geometry\";\r\nimport { Frustum, FrustumPlanes, SpatialClassifier, ViewFlags } from \"@itwin/core-common\";\r\nimport { CachedDecoration, DecorationsCache } from \"./DecorationsCache\";\r\nimport { IModelApp } from \"./IModelApp\";\r\nimport { PlanarClipMaskState } from \"./PlanarClipMaskState\";\r\nimport { CanvasDecoration } from \"./render/CanvasDecoration\";\r\nimport { Decorations } from \"./render/Decorations\";\r\nimport { GraphicBranch, GraphicBranchOptions } from \"./render/GraphicBranch\";\r\nimport { GraphicBuilder, GraphicType, ViewportGraphicBuilderOptions } from \"./render/GraphicBuilder\";\r\nimport { GraphicList, RenderGraphic } from \"./render/RenderGraphic\";\r\nimport { RenderPlanarClassifier } from \"./render/RenderPlanarClassifier\";\r\nimport { RenderTextureDrape } from \"./render/RenderSystem\";\r\nimport { RenderTarget } from \"./render/RenderTarget\";\r\nimport { Scene } from \"./render/Scene\";\r\nimport { SpatialClassifierTileTreeReference, Tile, TileGraphicType, TileLoadStatus, TileTreeReference } from \"./tile/internal\";\r\nimport { ViewingSpace } from \"./ViewingSpace\";\r\nimport { ELEMENT_MARKED_FOR_REMOVAL, ScreenViewport, Viewport, ViewportDecorator } from \"./Viewport\";\r\n\r\n/** Provides context for producing [[RenderGraphic]]s for drawing within a [[Viewport]].\r\n * @public\r\n */\r\nexport class RenderContext {\r\n /** ViewFlags extracted from the context's [[Viewport]]. */\r\n public readonly viewFlags: ViewFlags;\r\n private readonly _viewport: Viewport;\r\n /** Frustum extracted from the context's [[Viewport]]. */\r\n public readonly frustum: Frustum;\r\n /** Frustum planes extracted from the context's [[Viewport]]. */\r\n public readonly frustumPlanes: FrustumPlanes;\r\n\r\n constructor(vp: Viewport, frustum?: Frustum) {\r\n this._viewport = vp;\r\n this.viewFlags = vp.viewFlags;\r\n this.frustum = frustum ? frustum : vp.getFrustum();\r\n this.frustumPlanes = new FrustumPlanes(this.frustum);\r\n }\r\n\r\n /** Given a point in world coordinates, determine approximately how many pixels it occupies on screen based on this context's frustum. */\r\n public getPixelSizeAtPoint(inPoint?: Point3d): number {\r\n return this.viewport.viewingSpace.getPixelSizeAtPoint(inPoint);\r\n }\r\n\r\n /** The [[Viewport]] associated with this context. */\r\n public get viewport(): Viewport {\r\n return this._viewport;\r\n }\r\n\r\n /** @internal */\r\n public get target(): RenderTarget { return this.viewport.target; }\r\n\r\n /** @internal */\r\n protected _createGraphicBuilder(options: Omit<ViewportGraphicBuilderOptions, \"viewport\">): GraphicBuilder {\r\n return this.target.createGraphicBuilder({ ...options, viewport: this.viewport });\r\n }\r\n\r\n /** Create a builder for creating a [[GraphicType.Scene]] [[RenderGraphic]] for rendering within this context's [[Viewport]].\r\n * @param transform the local-to-world transform in which the builder's geometry is to be defined.\r\n * @returns A builder for creating a [[GraphicType.Scene]] [[RenderGraphic]] for rendering within this context's [[Viewport]].\r\n */\r\n public createSceneGraphicBuilder(transform?: Transform): GraphicBuilder {\r\n return this._createGraphicBuilder({ type: GraphicType.Scene, placement: transform });\r\n }\r\n\r\n /** Create a graphic from a [[GraphicBranch]]. */\r\n public createGraphicBranch(branch: GraphicBranch, location: Transform, opts?: GraphicBranchOptions): RenderGraphic {\r\n return this.target.renderSystem.createGraphicBranch(branch, location, opts);\r\n }\r\n\r\n /** Create a [[RenderGraphic]] which groups a set of graphics into a node in a scene graph, applying to each a transform and optional clip volume and symbology overrides.\r\n * @param branch Contains the group of graphics and the symbology overrides.\r\n * @param location the local-to-world transform applied to the grouped graphics.\r\n * @returns A RenderGraphic suitable for drawing the scene graph node within this context's [[Viewport]].\r\n * @see [[RenderSystem.createBranch]]\r\n */\r\n public createBranch(branch: GraphicBranch, location: Transform): RenderGraphic { return this.createGraphicBranch(branch, location); }\r\n\r\n /** Given the size of a logical pixel in meters, convert it to the size of a physical pixel in meters, if [[RenderSystem.dpiAwareLOD]] is `true`.\r\n * Used when computing LOD for graphics.\r\n * @internal\r\n */\r\n public adjustPixelSizeForLOD(cssPixelSize: number): number {\r\n return this.viewport.target.adjustPixelSizeForLOD(cssPixelSize);\r\n }\r\n}\r\n\r\n/** Provides context for an [[InteractiveTool]] to display decorations representing its current state.\r\n * @see [[InteractiveTool.onDynamicFrame]]\r\n * @public\r\n */\r\nexport class DynamicsContext extends RenderContext {\r\n private _dynamics?: GraphicList;\r\n\r\n /** Add a graphic to the list of dynamic graphics to be drawn in this context's [[Viewport]]. */\r\n public addGraphic(graphic: RenderGraphic) {\r\n if (undefined === this._dynamics)\r\n this._dynamics = [];\r\n this._dynamics.push(graphic);\r\n }\r\n\r\n /** @internal */\r\n public changeDynamics(): void {\r\n this.viewport.changeDynamics(this._dynamics);\r\n }\r\n\r\n /** Create a builder for producing a [[RenderGraphic]] appropriate for rendering within this context's [[Viewport]].\r\n * @param options Options describing how to create the builder.\r\n * @returns A builder that produces a [[RenderGraphic]].\r\n */\r\n public createGraphic(options: Omit<ViewportGraphicBuilderOptions, \"viewport\">): GraphicBuilder {\r\n return this._createGraphicBuilder(options);\r\n }\r\n}\r\n\r\n/** Provides context for a [[ViewportDecorator]] to add [[Decorations]] to be rendered within a [[Viewport]].\r\n * @public\r\n */\r\nexport class DecorateContext extends RenderContext {\r\n private readonly _decorations: Decorations;\r\n private readonly _cache: DecorationsCache;\r\n private _curCacheableDecorator?: ViewportDecorator;\r\n\r\n /** The [[ScreenViewport]] in which this context's [[Decorations]] will be drawn. */\r\n public override get viewport(): ScreenViewport {\r\n return super.viewport as ScreenViewport;\r\n }\r\n\r\n /** @internal */\r\n constructor(vp: ScreenViewport, decorations: Decorations, cache: DecorationsCache) {\r\n super(vp);\r\n this._decorations = decorations;\r\n this._cache = cache;\r\n }\r\n\r\n /** Create a builder for creating a [[RenderGraphic]] of the specified type appropriate for rendering within this context's [[Viewport]].\r\n * @param type The type of builder to create.\r\n * @param transform the local-to-world transform in which the builder's geometry is to be defined.\r\n * @param id If the decoration is to be pickable, a unique identifier to associate with the resultant [[RenderGraphic]].\r\n * @returns A builder for creating a [[RenderGraphic]] of the specified type appropriate for rendering within this context's [[Viewport]].\r\n * @see [[IModelConnection.transientIds]] for obtaining an ID for a pickable decoration.\r\n * @see [[createGraphic]] for more options.\r\n */\r\n public createGraphicBuilder(type: GraphicType, transform?: Transform, id?: Id64String): GraphicBuilder {\r\n return this.createGraphic({ type, placement: transform, pickable: undefined !== id ? { id } : undefined });\r\n }\r\n\r\n /** Create a builder for producing a [[RenderGraphic]] appropriate for rendering within this context's [[Viewport]].\r\n * @param options Options describing how to create the builder.\r\n * @returns A builder that produces a [[RenderGraphic]].\r\n */\r\n public createGraphic(options: Omit<ViewportGraphicBuilderOptions, \"viewport\">): GraphicBuilder {\r\n return this._createGraphicBuilder(options);\r\n }\r\n\r\n /** @internal */\r\n public addFromDecorator(decorator: ViewportDecorator): void {\r\n assert(undefined === this._curCacheableDecorator);\r\n try {\r\n if (decorator.useCachedDecorations) {\r\n const cached = this._cache.get(decorator);\r\n if (cached) {\r\n this.restoreCache(cached);\r\n return;\r\n }\r\n\r\n this._curCacheableDecorator = decorator;\r\n }\r\n\r\n decorator.decorate(this);\r\n } finally {\r\n this._curCacheableDecorator = undefined;\r\n }\r\n }\r\n\r\n /** Restores decorations onto this context from the specified array of cached decorations. */\r\n private restoreCache(cachedDecorations: CachedDecoration[]) {\r\n cachedDecorations.forEach((cachedDecoration) => {\r\n switch (cachedDecoration.type) {\r\n case \"graphic\":\r\n this.addDecoration(cachedDecoration.graphicType, cachedDecoration.graphicOwner);\r\n break;\r\n case \"canvas\":\r\n this.addCanvasDecoration(cachedDecoration.canvasDecoration, cachedDecoration.atFront);\r\n break;\r\n case \"html\":\r\n this.addHtmlDecoration(cachedDecoration.htmlElement);\r\n break;\r\n }\r\n });\r\n }\r\n\r\n private _appendToCache(decoration: CachedDecoration) {\r\n assert(undefined !== this._curCacheableDecorator);\r\n this._cache.add(this._curCacheableDecorator, decoration);\r\n }\r\n\r\n /** Calls [[GraphicBuilder.finish]] on the supplied builder to obtain a [[RenderGraphic]], then adds the graphic to the appropriate list of\r\n * [[Decorations]].\r\n * @param builder The builder from which to extract the graphic.\r\n * @note The builder should not be used after calling this method.\r\n */\r\n public addDecorationFromBuilder(builder: GraphicBuilder) {\r\n this.addDecoration(builder.type, builder.finish());\r\n }\r\n\r\n /** Adds a graphic to the set of [[Decorations]] to be drawn in this context's [[ScreenViewport]].\r\n * @param The type of the graphic, which determines to which list of decorations it is added.\r\n * @param decoration The decoration graphic to add.\r\n * @note The type must match the type with which the [[RenderGraphic]]'s [[GraphicBuilder]] was constructed.\r\n * @see [[DecorateContext.addDecorationFromBuilder]] for a more convenient API.\r\n */\r\n public addDecoration(type: GraphicType, decoration: RenderGraphic) {\r\n if (this._curCacheableDecorator) {\r\n const graphicOwner = this.target.renderSystem.createGraphicOwner(decoration);\r\n this._appendToCache({ type: \"graphic\", graphicOwner, graphicType: type });\r\n decoration = graphicOwner;\r\n }\r\n\r\n switch (type) {\r\n case GraphicType.Scene:\r\n if (undefined === this._decorations.normal)\r\n this._decorations.normal = [];\r\n this._decorations.normal.push(decoration);\r\n break;\r\n\r\n case GraphicType.WorldDecoration:\r\n if (!this._decorations.world)\r\n this._decorations.world = [];\r\n this._decorations.world.push(decoration);\r\n break;\r\n\r\n case GraphicType.WorldOverlay:\r\n if (!this._decorations.worldOverlay)\r\n this._decorations.worldOverlay = [];\r\n this._decorations.worldOverlay.push(decoration);\r\n break;\r\n\r\n case GraphicType.ViewOverlay:\r\n if (!this._decorations.viewOverlay)\r\n this._decorations.viewOverlay = [];\r\n this._decorations.viewOverlay.push(decoration);\r\n break;\r\n\r\n case GraphicType.ViewBackground:\r\n this.setViewBackground(decoration);\r\n break;\r\n }\r\n }\r\n\r\n /** Add a [[CanvasDecoration]] to be drawn in this context's [[ScreenViewport]]. */\r\n public addCanvasDecoration(decoration: CanvasDecoration, atFront = false) {\r\n if (this._curCacheableDecorator)\r\n this._appendToCache({ type: \"canvas\", canvasDecoration: decoration, atFront });\r\n\r\n if (undefined === this._decorations.canvasDecorations)\r\n this._decorations.canvasDecorations = [];\r\n\r\n const list = this._decorations.canvasDecorations;\r\n if (0 === list.length || true === atFront)\r\n list.push(decoration);\r\n else\r\n list.unshift(decoration);\r\n }\r\n\r\n /** Add an HTMLElement to be drawn as a decoration in this context's [[ScreenViewport]]. */\r\n public addHtmlDecoration(decoration: HTMLElement) {\r\n if (this._curCacheableDecorator)\r\n this._appendToCache({ type: \"html\", htmlElement: decoration });\r\n\r\n // an element decoration being added might already be on the decorationDiv, just marked for removal\r\n if (decoration[ELEMENT_MARKED_FOR_REMOVAL]) {\r\n decoration[ELEMENT_MARKED_FOR_REMOVAL] = false;\r\n } else if (decoration.parentElement !== this.viewport.decorationDiv) {\r\n this.viewport.decorationDiv.appendChild(decoration);\r\n }\r\n }\r\n\r\n /** @internal */\r\n public drawStandardGrid(gridOrigin: Point3d, rMatrix: Matrix3d, spacing: XAndY, gridsPerRef: number, _isoGrid: boolean = false, _fixedRepetitions?: Point2d): void {\r\n const vp = this.viewport;\r\n\r\n if (vp.viewingGlobe)\r\n return;\r\n\r\n const color = vp.getContrastToBackgroundColor();\r\n const planarGrid = this.viewport.target.renderSystem.createPlanarGrid(vp.getFrustum(), { origin: gridOrigin, rMatrix, spacing, gridsPerRef, color });\r\n if (planarGrid) {\r\n this.addDecoration(GraphicType.WorldDecoration, planarGrid);\r\n }\r\n }\r\n\r\n /** Display skyBox graphic that encompasses entire scene and rotates with camera.\r\n * @see [[RenderSystem.createSkyBox]].\r\n */\r\n public setSkyBox(graphic: RenderGraphic) {\r\n this._decorations.skyBox = graphic;\r\n }\r\n\r\n /** Set the graphic to be displayed behind all other geometry as the background of this context's [[ScreenViewport]]. */\r\n public setViewBackground(graphic: RenderGraphic) {\r\n this._decorations.viewBackground = graphic;\r\n }\r\n}\r\n\r\n/** Context used to create the scene to be drawn in a [[Viewport]]. The scene consists of a set of [[RenderGraphic]]s produced by the\r\n * [[TileTree]]s visible within the viewport. Creating the scene may result in the enqueueing of requests for [[Tile]] content which\r\n * should be displayed in the viewport but are not yet loaded.\r\n * @public\r\n */\r\nexport class SceneContext extends RenderContext {\r\n private _missingChildTiles = false;\r\n /** The graphics comprising the scene. */\r\n public readonly scene = new Scene();\r\n\r\n /** @internal */\r\n public readonly missingTiles = new Set<Tile>();\r\n\r\n /** @internal */\r\n public markChildrenLoading(): void {\r\n this._missingChildTiles = true;\r\n }\r\n\r\n /** @internal */\r\n public get hasMissingTiles(): boolean {\r\n return this._missingChildTiles || this.missingTiles.size > 0;\r\n }\r\n\r\n private _viewingSpace?: ViewingSpace;\r\n private _graphicType: TileGraphicType = TileGraphicType.Scene;\r\n\r\n public constructor(vp: Viewport, frustum?: Frustum) {\r\n super(vp, frustum);\r\n }\r\n\r\n /** The viewed volume containing the scene. */\r\n public get viewingSpace(): ViewingSpace {\r\n return undefined !== this._viewingSpace ? this._viewingSpace : this.viewport.viewingSpace;\r\n }\r\n\r\n /** @internal */\r\n public get graphicType() { return this._graphicType; }\r\n\r\n /** Add the specified graphic to the scene. */\r\n public outputGraphic(graphic: RenderGraphic): void {\r\n switch (this._graphicType) {\r\n case TileGraphicType.BackgroundMap:\r\n this.backgroundGraphics.push(graphic);\r\n break;\r\n case TileGraphicType.Overlay:\r\n this.overlayGraphics.push(graphic);\r\n break;\r\n default:\r\n this.graphics.push(graphic);\r\n break;\r\n }\r\n }\r\n\r\n /** Indicate that the specified tile is desired for the scene but is not yet ready. A request to load its contents will later be enqueued. */\r\n public insertMissingTile(tile: Tile): void {\r\n switch (tile.loadStatus) {\r\n case TileLoadStatus.NotLoaded:\r\n case TileLoadStatus.Queued:\r\n case TileLoadStatus.Loading:\r\n this.missingTiles.add(tile);\r\n break;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public requestMissingTiles(): void {\r\n IModelApp.tileAdmin.requestTiles(this.viewport, this.missingTiles);\r\n }\r\n\r\n /** @internal */\r\n public addPlanarClassifier(classifiedModelId: Id64String, classifierTree?: SpatialClassifierTileTreeReference, planarClipMask?: PlanarClipMaskState): RenderPlanarClassifier | undefined {\r\n // Target may have the classifier from a previous frame; if not we must create one.\r\n let classifier = this.viewport.target.getPlanarClassifier(classifiedModelId);\r\n if (undefined === classifier)\r\n classifier = this.viewport.target.createPlanarClassifier(classifierTree?.activeClassifier);\r\n\r\n // Either way, we need to collect the graphics to draw for this frame, and record that we did so.\r\n if (undefined !== classifier) {\r\n this.planarClassifiers.set(classifiedModelId, classifier);\r\n classifier.setSource(classifierTree, planarClipMask);\r\n }\r\n\r\n return classifier;\r\n }\r\n\r\n /** @internal */\r\n public getPlanarClassifierForModel(modelId: Id64String) {\r\n return this.planarClassifiers.get(modelId);\r\n }\r\n\r\n /** @internal */\r\n public addBackgroundDrapedModel(drapedTreeRef: TileTreeReference, _heightRange: Range1d | undefined): RenderTextureDrape | undefined {\r\n const drapedTree = drapedTreeRef.treeOwner.tileTree;\r\n if (undefined === drapedTree)\r\n return undefined;\r\n\r\n const id = drapedTree.modelId;\r\n let drape = this.getTextureDrapeForModel(id);\r\n if (undefined !== drape)\r\n return drape;\r\n\r\n drape = this.viewport.target.getTextureDrape(id);\r\n if (undefined === drape && this.viewport.backgroundDrapeMap)\r\n drape = this.viewport.target.renderSystem.createBackgroundMapDrape(drapedTreeRef, this.viewport.backgroundDrapeMap);\r\n\r\n if (undefined !== drape)\r\n this.textureDrapes.set(id, drape);\r\n\r\n return drape;\r\n }\r\n\r\n /** @internal */\r\n public getTextureDrapeForModel(modelId: Id64String) {\r\n return this.textureDrapes.get(modelId);\r\n }\r\n\r\n /** @internal */\r\n public withGraphicType(type: TileGraphicType, func: () => void): void {\r\n const prevType = this._graphicType;\r\n this._graphicType = type;\r\n\r\n func();\r\n\r\n this._graphicType = prevType;\r\n }\r\n\r\n /** The graphics in the scene that will be drawn with depth. */\r\n public get graphics() { return this.scene.foreground; }\r\n /** The graphics that will be drawn behind everything else in the scene. */\r\n public get backgroundGraphics() { return this.scene.background; }\r\n /** The graphics that will be drawn in front of everything else in the scene. */\r\n public get overlayGraphics() { return this.scene.overlay; }\r\n /** @internal */\r\n public get planarClassifiers() { return this.scene.planarClassifiers; }\r\n /** @internal */\r\n public get textureDrapes() { return this.scene.textureDrapes; }\r\n\r\n /** @internal */\r\n public setVolumeClassifier(classifier: SpatialClassifier, modelId: Id64String): void {\r\n this.scene.volumeClassifier = { classifier, modelId };\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"ViewContext.js","sourceRoot":"","sources":["../../src/ViewContext.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAA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A+D;IAC/D,IAAW,QAAQ,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;IACvD,2EAA2E;IAC3E,IAAW,kBAAkB,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;IACjE,gFAAgF;IAChF,IAAW,eAAe,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAC3D,gBAAgB;IAChB,IAAW,iBAAiB,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC;IACvE,gBAAgB;IAChB,IAAW,aAAa,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;IAE/D,gBAAgB;IACT,mBAAmB,CAAC,UAA6B,EAAE,OAAmB;QAC3E,IAAI,CAAC,KAAK,CAAC,gBAAgB,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC;IACxD,CAAC;CACF","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 Rendering\r\n */\r\n\r\nimport { assert, Id64String } from \"@itwin/core-bentley\";\nimport {\r\n Matrix3d, Point2d,\r\n Point3d, Range1d, Transform, XAndY,\r\n} from \"@itwin/core-geometry\";\nimport { Frustum, FrustumPlanes, SpatialClassifier, ViewFlags } from \"@itwin/core-common\";\nimport { CachedDecoration, DecorationsCache } from \"./DecorationsCache\";\r\nimport { IModelApp } from \"./IModelApp\";\r\nimport { PlanarClipMaskState } from \"./PlanarClipMaskState\";\r\nimport { CanvasDecoration } from \"./render/CanvasDecoration\";\r\nimport { Decorations } from \"./render/Decorations\";\r\nimport { GraphicBranch, GraphicBranchOptions } from \"./render/GraphicBranch\";\r\nimport { GraphicBuilder, GraphicType, ViewportGraphicBuilderOptions } from \"./render/GraphicBuilder\";\nimport { GraphicList, RenderGraphic } from \"./render/RenderGraphic\";\r\nimport { RenderPlanarClassifier } from \"./render/RenderPlanarClassifier\";\r\nimport { RenderSystem, RenderTextureDrape } from \"./render/RenderSystem\";\r\nimport { RenderTarget } from \"./render/RenderTarget\";\r\nimport { Scene } from \"./render/Scene\";\r\nimport { SpatialClassifierTileTreeReference, Tile, TileGraphicType, TileLoadStatus, TileTreeReference } from \"./tile/internal\";\r\nimport { ViewingSpace } from \"./ViewingSpace\";\r\nimport { ELEMENT_MARKED_FOR_REMOVAL, ScreenViewport, Viewport, ViewportDecorator } from \"./Viewport\";\r\n\r\n/** Provides context for producing [[RenderGraphic]]s for drawing within a [[Viewport]].\r\n * @public\r\n */\r\nexport class RenderContext {\r\n /** ViewFlags extracted from the context's [[Viewport]]. */\r\n public readonly viewFlags: ViewFlags;\r\n private readonly _viewport: Viewport;\r\n /** Frustum extracted from the context's [[Viewport]]. */\r\n public readonly frustum: Frustum;\r\n /** Frustum planes extracted from the context's [[Viewport]]. */\r\n public readonly frustumPlanes: FrustumPlanes;\r\n\r\n constructor(vp: Viewport, frustum?: Frustum) {\r\n this._viewport = vp;\r\n this.viewFlags = vp.viewFlags;\n this.frustum = frustum ? frustum : vp.getFrustum();\r\n this.frustumPlanes = new FrustumPlanes(this.frustum);\r\n }\r\n\r\n /** Given a point in world coordinates, determine approximately how many pixels it occupies on screen based on this context's frustum. */\r\n public getPixelSizeAtPoint(inPoint?: Point3d): number {\r\n return this.viewport.viewingSpace.getPixelSizeAtPoint(inPoint);\r\n }\r\n\r\n /** The [[Viewport]] associated with this context. */\r\n public get viewport(): Viewport {\r\n return this._viewport;\r\n }\r\n\r\n /** The [[RenderSystem]] being used to produce graphics for this context. */\r\n public get renderSystem(): RenderSystem {\r\n return this.target.renderSystem;\r\n }\r\n\r\n /** @internal */\r\n public get target(): RenderTarget { return this.viewport.target; }\r\n\r\n /** @internal */\r\n protected _createGraphicBuilder(options: Omit<ViewportGraphicBuilderOptions, \"viewport\">): GraphicBuilder {\n return this.target.createGraphicBuilder({ ...options, viewport: this.viewport });\r\n }\r\n\r\n /** Create a builder for creating a [[GraphicType.Scene]] [[RenderGraphic]] for rendering within this context's [[Viewport]].\r\n * @param transform the local-to-world transform in which the builder's geometry is to be defined.\r\n * @returns A builder for creating a [[GraphicType.Scene]] [[RenderGraphic]] for rendering within this context's [[Viewport]].\r\n */\r\n public createSceneGraphicBuilder(transform?: Transform): GraphicBuilder {\r\n return this._createGraphicBuilder({ type: GraphicType.Scene, placement: transform });\r\n }\r\n\r\n /** Create a graphic from a [[GraphicBranch]]. */\r\n public createGraphicBranch(branch: GraphicBranch, location: Transform, opts?: GraphicBranchOptions): RenderGraphic {\r\n return this.target.renderSystem.createGraphicBranch(branch, location, opts);\r\n }\r\n\r\n /** Create a [[RenderGraphic]] which groups a set of graphics into a node in a scene graph, applying to each a transform and optional clip volume and symbology overrides.\r\n * @param branch Contains the group of graphics and the symbology overrides.\r\n * @param location the local-to-world transform applied to the grouped graphics.\r\n * @returns A RenderGraphic suitable for drawing the scene graph node within this context's [[Viewport]].\r\n * @see [[RenderSystem.createBranch]]\r\n */\r\n public createBranch(branch: GraphicBranch, location: Transform): RenderGraphic { return this.createGraphicBranch(branch, location); }\r\n\r\n /** Given the size of a logical pixel in meters, convert it to the size of a physical pixel in meters, if [[RenderSystem.dpiAwareLOD]] is `true`.\r\n * Used when computing LOD for graphics.\r\n * @internal\r\n */\r\n public adjustPixelSizeForLOD(cssPixelSize: number): number {\r\n return this.viewport.target.adjustPixelSizeForLOD(cssPixelSize);\r\n }\r\n}\r\n\r\n/** Provides context for an [[InteractiveTool]] to display decorations representing its current state.\r\n * @see [[InteractiveTool.onDynamicFrame]]\r\n * @public\r\n */\r\nexport class DynamicsContext extends RenderContext {\r\n private _dynamics?: GraphicList;\r\n\r\n /** Add a graphic to the list of dynamic graphics to be drawn in this context's [[Viewport]]. */\r\n public addGraphic(graphic: RenderGraphic) {\r\n if (undefined === this._dynamics)\r\n this._dynamics = [];\r\n this._dynamics.push(graphic);\r\n }\r\n\r\n /** @internal */\r\n public changeDynamics(): void {\r\n this.viewport.changeDynamics(this._dynamics);\r\n }\r\n\r\n /** Create a builder for producing a [[RenderGraphic]] appropriate for rendering within this context's [[Viewport]].\r\n * @param options Options describing how to create the builder.\r\n * @returns A builder that produces a [[RenderGraphic]].\r\n */\r\n public createGraphic(options: Omit<ViewportGraphicBuilderOptions, \"viewport\">): GraphicBuilder {\n return this._createGraphicBuilder(options);\r\n }\r\n}\r\n\r\n/** Provides context for a [[ViewportDecorator]] to add [[Decorations]] to be rendered within a [[Viewport]].\r\n * @public\r\n */\r\nexport class DecorateContext extends RenderContext {\r\n private readonly _decorations: Decorations;\r\n private readonly _cache: DecorationsCache;\r\n private _curCacheableDecorator?: ViewportDecorator;\r\n\r\n /** The [[ScreenViewport]] in which this context's [[Decorations]] will be drawn. */\r\n public override get viewport(): ScreenViewport {\r\n return super.viewport as ScreenViewport;\r\n }\r\n\r\n /** @internal */\r\n constructor(vp: ScreenViewport, decorations: Decorations, cache: DecorationsCache) {\r\n super(vp);\r\n this._decorations = decorations;\r\n this._cache = cache;\r\n }\r\n\r\n /** Create a builder for creating a [[RenderGraphic]] of the specified type appropriate for rendering within this context's [[Viewport]].\r\n * @param type The type of builder to create.\r\n * @param transform the local-to-world transform in which the builder's geometry is to be defined.\r\n * @param id If the decoration is to be pickable, a unique identifier to associate with the resultant [[RenderGraphic]].\r\n * @returns A builder for creating a [[RenderGraphic]] of the specified type appropriate for rendering within this context's [[Viewport]].\r\n * @see [[IModelConnection.transientIds]] for obtaining an ID for a pickable decoration.\r\n * @see [[createGraphic]] for more options.\r\n */\r\n public createGraphicBuilder(type: GraphicType, transform?: Transform, id?: Id64String): GraphicBuilder {\r\n return this.createGraphic({ type, placement: transform, pickable: undefined !== id ? { id } : undefined });\r\n }\r\n\r\n /** Create a builder for producing a [[RenderGraphic]] appropriate for rendering within this context's [[Viewport]].\r\n * @param options Options describing how to create the builder.\r\n * @returns A builder that produces a [[RenderGraphic]].\r\n */\r\n public createGraphic(options: Omit<ViewportGraphicBuilderOptions, \"viewport\">): GraphicBuilder {\n return this._createGraphicBuilder(options);\r\n }\r\n\r\n /** @internal */\r\n public addFromDecorator(decorator: ViewportDecorator): void {\r\n assert(undefined === this._curCacheableDecorator);\r\n try {\r\n if (decorator.useCachedDecorations) {\r\n const cached = this._cache.get(decorator);\r\n if (cached) {\r\n this.restoreCache(cached);\r\n return;\r\n }\r\n\r\n this._curCacheableDecorator = decorator;\r\n }\r\n\r\n decorator.decorate(this);\r\n } finally {\r\n this._curCacheableDecorator = undefined;\r\n }\r\n }\r\n\r\n /** Restores decorations onto this context from the specified array of cached decorations. */\r\n private restoreCache(cachedDecorations: CachedDecoration[]) {\r\n cachedDecorations.forEach((cachedDecoration) => {\r\n switch (cachedDecoration.type) {\r\n case \"graphic\":\r\n this.addDecoration(cachedDecoration.graphicType, cachedDecoration.graphicOwner);\r\n break;\r\n case \"canvas\":\r\n this.addCanvasDecoration(cachedDecoration.canvasDecoration, cachedDecoration.atFront);\r\n break;\r\n case \"html\":\r\n this.addHtmlDecoration(cachedDecoration.htmlElement);\r\n break;\r\n }\r\n });\r\n }\r\n\r\n private _appendToCache(decoration: CachedDecoration) {\r\n assert(undefined !== this._curCacheableDecorator);\r\n this._cache.add(this._curCacheableDecorator, decoration);\r\n }\r\n\r\n /** Calls [[GraphicBuilder.finish]] on the supplied builder to obtain a [[RenderGraphic]], then adds the graphic to the appropriate list of\r\n * [[Decorations]].\r\n * @param builder The builder from which to extract the graphic.\r\n * @note The builder should not be used after calling this method.\r\n */\r\n public addDecorationFromBuilder(builder: GraphicBuilder) {\r\n this.addDecoration(builder.type, builder.finish());\r\n }\r\n\r\n /** Adds a graphic to the set of [[Decorations]] to be drawn in this context's [[ScreenViewport]].\r\n * @param The type of the graphic, which determines to which list of decorations it is added.\r\n * @param decoration The decoration graphic to add.\r\n * @note The type must match the type with which the [[RenderGraphic]]'s [[GraphicBuilder]] was constructed.\r\n * @see [[DecorateContext.addDecorationFromBuilder]] for a more convenient API.\r\n */\r\n public addDecoration(type: GraphicType, decoration: RenderGraphic) {\r\n if (this._curCacheableDecorator) {\r\n const graphicOwner = this.target.renderSystem.createGraphicOwner(decoration);\r\n this._appendToCache({ type: \"graphic\", graphicOwner, graphicType: type });\r\n decoration = graphicOwner;\r\n }\r\n\r\n switch (type) {\r\n case GraphicType.Scene:\r\n if (undefined === this._decorations.normal)\r\n this._decorations.normal = [];\r\n this._decorations.normal.push(decoration);\r\n break;\r\n\r\n case GraphicType.WorldDecoration:\r\n if (!this._decorations.world)\r\n this._decorations.world = [];\r\n this._decorations.world.push(decoration);\r\n break;\r\n\r\n case GraphicType.WorldOverlay:\r\n if (!this._decorations.worldOverlay)\r\n this._decorations.worldOverlay = [];\r\n this._decorations.worldOverlay.push(decoration);\r\n break;\r\n\r\n case GraphicType.ViewOverlay:\r\n if (!this._decorations.viewOverlay)\r\n this._decorations.viewOverlay = [];\r\n this._decorations.viewOverlay.push(decoration);\r\n break;\r\n\r\n case GraphicType.ViewBackground:\r\n this.setViewBackground(decoration);\r\n break;\r\n }\r\n }\r\n\r\n /** Add a [[CanvasDecoration]] to be drawn in this context's [[ScreenViewport]]. */\r\n public addCanvasDecoration(decoration: CanvasDecoration, atFront = false) {\r\n if (this._curCacheableDecorator)\r\n this._appendToCache({ type: \"canvas\", canvasDecoration: decoration, atFront });\r\n\r\n if (undefined === this._decorations.canvasDecorations)\r\n this._decorations.canvasDecorations = [];\r\n\r\n const list = this._decorations.canvasDecorations;\r\n if (0 === list.length || true === atFront)\r\n list.push(decoration);\r\n else\r\n list.unshift(decoration);\r\n }\r\n\r\n /** Add an HTMLElement to be drawn as a decoration in this context's [[ScreenViewport]]. */\r\n public addHtmlDecoration(decoration: HTMLElement) {\r\n if (this._curCacheableDecorator)\r\n this._appendToCache({ type: \"html\", htmlElement: decoration });\r\n\r\n // an element decoration being added might already be on the decorationDiv, just marked for removal\r\n if (decoration[ELEMENT_MARKED_FOR_REMOVAL]) {\r\n decoration[ELEMENT_MARKED_FOR_REMOVAL] = false;\r\n } else if (decoration.parentElement !== this.viewport.decorationDiv) {\n this.viewport.decorationDiv.appendChild(decoration);\n }\r\n }\r\n\r\n /** @internal */\r\n public drawStandardGrid(gridOrigin: Point3d, rMatrix: Matrix3d, spacing: XAndY, gridsPerRef: number, _isoGrid: boolean = false, _fixedRepetitions?: Point2d): void {\r\n const vp = this.viewport;\r\n\r\n if (vp.viewingGlobe)\r\n return;\r\n\r\n const color = vp.getContrastToBackgroundColor();\r\n const planarGrid = this.viewport.target.renderSystem.createPlanarGrid(vp.getFrustum(), { origin: gridOrigin, rMatrix, spacing, gridsPerRef, color });\r\n if (planarGrid) {\r\n this.addDecoration(GraphicType.WorldDecoration, planarGrid);\r\n }\r\n }\r\n\r\n /** Display skyBox graphic that encompasses entire scene and rotates with camera.\r\n * @see [[RenderSystem.createSkyBox]].\r\n */\r\n public setSkyBox(graphic: RenderGraphic) {\r\n this._decorations.skyBox = graphic;\r\n }\r\n\r\n /** Set the graphic to be displayed behind all other geometry as the background of this context's [[ScreenViewport]]. */\r\n public setViewBackground(graphic: RenderGraphic) {\r\n this._decorations.viewBackground = graphic;\r\n }\r\n}\r\n\r\n/** Context used to create the scene to be drawn in a [[Viewport]]. The scene consists of a set of [[RenderGraphic]]s produced by the\r\n * [[TileTree]]s visible within the viewport. Creating the scene may result in the enqueueing of requests for [[Tile]] content which\r\n * should be displayed in the viewport but are not yet loaded.\r\n * @public\r\n */\r\nexport class SceneContext extends RenderContext {\r\n private _missingChildTiles = false;\r\n /** The graphics comprising the scene. */\r\n public readonly scene = new Scene();\r\n\r\n /** @internal */\r\n public readonly missingTiles = new Set<Tile>();\r\n\r\n /** @internal */\r\n public markChildrenLoading(): void {\r\n this._missingChildTiles = true;\r\n }\r\n\r\n /** @internal */\r\n public get hasMissingTiles(): boolean {\r\n return this._missingChildTiles || this.missingTiles.size > 0;\r\n }\r\n\r\n private _viewingSpace?: ViewingSpace;\r\n private _graphicType: TileGraphicType = TileGraphicType.Scene;\r\n\r\n public constructor(vp: Viewport, frustum?: Frustum) {\r\n super(vp, frustum);\r\n }\r\n\r\n /** The viewed volume containing the scene. */\r\n public get viewingSpace(): ViewingSpace {\r\n return undefined !== this._viewingSpace ? this._viewingSpace : this.viewport.viewingSpace;\r\n }\r\n\r\n /** @internal */\r\n public get graphicType() { return this._graphicType; }\r\n\r\n /** Add the specified graphic to the scene. */\r\n public outputGraphic(graphic: RenderGraphic): void {\r\n switch (this._graphicType) {\r\n case TileGraphicType.BackgroundMap:\r\n this.backgroundGraphics.push(graphic);\r\n break;\r\n case TileGraphicType.Overlay:\r\n this.overlayGraphics.push(graphic);\r\n break;\r\n default:\r\n this.graphics.push(graphic);\r\n break;\r\n }\r\n }\r\n\r\n /** Indicate that the specified tile is desired for the scene but is not yet ready. A request to load its contents will later be enqueued. */\r\n public insertMissingTile(tile: Tile): void {\r\n switch (tile.loadStatus) {\r\n case TileLoadStatus.NotLoaded:\r\n case TileLoadStatus.Queued:\r\n case TileLoadStatus.Loading:\r\n this.missingTiles.add(tile);\r\n break;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public requestMissingTiles(): void {\r\n IModelApp.tileAdmin.requestTiles(this.viewport, this.missingTiles);\r\n }\r\n\r\n /** @internal */\r\n public addPlanarClassifier(classifiedModelId: Id64String, classifierTree?: SpatialClassifierTileTreeReference, planarClipMask?: PlanarClipMaskState): RenderPlanarClassifier | undefined {\r\n // Target may have the classifier from a previous frame; if not we must create one.\r\n let classifier = this.viewport.target.getPlanarClassifier(classifiedModelId);\r\n if (undefined === classifier)\r\n classifier = this.viewport.target.createPlanarClassifier(classifierTree?.activeClassifier);\r\n\r\n // Either way, we need to collect the graphics to draw for this frame, and record that we did so.\r\n if (undefined !== classifier) {\r\n this.planarClassifiers.set(classifiedModelId, classifier);\r\n classifier.setSource(classifierTree, planarClipMask);\r\n }\r\n\r\n return classifier;\r\n }\r\n\r\n /** @internal */\r\n public getPlanarClassifierForModel(modelId: Id64String) {\r\n return this.planarClassifiers.get(modelId);\r\n }\r\n\r\n /** @internal */\r\n public addBackgroundDrapedModel(drapedTreeRef: TileTreeReference, _heightRange: Range1d | undefined): RenderTextureDrape | undefined {\r\n const drapedTree = drapedTreeRef.treeOwner.tileTree;\r\n if (undefined === drapedTree)\r\n return undefined;\r\n\r\n const id = drapedTree.modelId;\r\n let drape = this.getTextureDrapeForModel(id);\r\n if (undefined !== drape)\r\n return drape;\r\n\r\n drape = this.viewport.target.getTextureDrape(id);\r\n if (undefined === drape && this.viewport.backgroundDrapeMap)\r\n drape = this.viewport.target.renderSystem.createBackgroundMapDrape(drapedTreeRef, this.viewport.backgroundDrapeMap);\r\n\r\n if (undefined !== drape)\r\n this.textureDrapes.set(id, drape);\r\n\r\n return drape;\r\n }\r\n\r\n /** @internal */\r\n public getTextureDrapeForModel(modelId: Id64String) {\r\n return this.textureDrapes.get(modelId);\r\n }\r\n\r\n /** @internal */\r\n public withGraphicType(type: TileGraphicType, func: () => void): void {\r\n const prevType = this._graphicType;\r\n this._graphicType = type;\r\n\r\n func();\r\n\r\n this._graphicType = prevType;\r\n }\r\n\r\n /** The graphics in the scene that will be drawn with depth. */\r\n public get graphics() { return this.scene.foreground; }\r\n /** The graphics that will be drawn behind everything else in the scene. */\r\n public get backgroundGraphics() { return this.scene.background; }\r\n /** The graphics that will be drawn in front of everything else in the scene. */\r\n public get overlayGraphics() { return this.scene.overlay; }\r\n /** @internal */\r\n public get planarClassifiers() { return this.scene.planarClassifiers; }\r\n /** @internal */\r\n public get textureDrapes() { return this.scene.textureDrapes; }\r\n\r\n /** @internal */\r\n public setVolumeClassifier(classifier: SpatialClassifier, modelId: Id64String): void {\r\n this.scene.volumeClassifier = { classifier, modelId };\r\n }\r\n}\r\n"]}
|
package/lib/esm/ViewCreator2d.js
CHANGED
|
@@ -114,7 +114,7 @@ export class ViewCreator2d {
|
|
|
114
114
|
*/
|
|
115
115
|
this._executeQuery = async (query) => {
|
|
116
116
|
const rows = [];
|
|
117
|
-
for await (const row of this._imodel.query(query, undefined, QueryRowFormat.UseJsPropertyNames))
|
|
117
|
+
for await (const row of this._imodel.query(query, undefined, { rowFormat: QueryRowFormat.UseJsPropertyNames }))
|
|
118
118
|
rows.push(row.id);
|
|
119
119
|
return rows;
|
|
120
120
|
};
|
|
@@ -202,7 +202,7 @@ export class ViewCreator2d {
|
|
|
202
202
|
async _addSheetViewProps(modelId, props) {
|
|
203
203
|
let width = 0;
|
|
204
204
|
let height = 0;
|
|
205
|
-
for await (const row of this._imodel.query(`SELECT Width, Height FROM bis.Sheet WHERE ECInstanceId = ?`, QueryBinder.from([modelId]), QueryRowFormat.UseJsPropertyNames)) {
|
|
205
|
+
for await (const row of this._imodel.query(`SELECT Width, Height FROM bis.Sheet WHERE ECInstanceId = ?`, QueryBinder.from([modelId]), { rowFormat: QueryRowFormat.UseJsPropertyNames })) {
|
|
206
206
|
width = row.width;
|
|
207
207
|
height = row.height;
|
|
208
208
|
break;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewCreator2d.js","sourceRoot":"","sources":["../../src/ViewCreator2d.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AAEH;;;EAGE;AAEF,OAAO,EAAyB,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EACkB,IAAI,EAAE,QAAQ,EAAqB,MAAM,EAAE,WAAW,EAAsB,WAAW,EAAE,cAAc,GAE/H,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC5F,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAelD;;;;;;;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,oBAAoB,CAAC,OAAe;QAEhD,MAAM,KAAK,GAAG,gEAAgE,OAAO,EAAE,CAAC;QACxF,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAEpD,OAAO,WAAW,CAAC;IACrB,CAAC;;AA3QD,sCAAsC;AACvB,kCAAoB,GAAG,CAAC,iBAAiB,CAAC,aAAa,EAAE,wBAAwB,CAAC,aAAa,CAAC,CAAC;AACjG,gCAAkB,GAAG,CAAC,eAAe,CAAC,aAAa,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\r\n/** @packageDocumentation\r\n * @module Views\r\n */\r\n\r\n/*\r\nAPI for creating a 2D view from a given modelId and modelType (classFullName).\r\nAdditional options (such as background color) can be passed during view creation.\r\n*/\r\n\r\nimport { Id64Array, Id64String, IModelStatus } from \"@itwin/core-bentley\";\r\nimport {\r\n CategorySelectorProps, Code, ColorDef, DisplayStyleProps, IModel, IModelError, ModelSelectorProps, QueryBinder, QueryRowFormat, SheetProps,\r\n ViewDefinition2dProps, ViewStateProps,\r\n} from \"@itwin/core-common\";\r\nimport { Range3d } from \"@itwin/core-geometry\";\r\nimport { DrawingViewState } from \"./DrawingViewState\";\r\nimport { EntityState } from \"./EntityState\";\r\nimport { IModelConnection } from \"./IModelConnection\";\r\nimport { DrawingModelState, SectionDrawingModelState, SheetModelState } from \"./ModelState\";\r\nimport { SheetViewState } from \"./SheetViewState\";\r\nimport { ViewState, ViewState2d } from \"./ViewState\";\r\n\r\n/** Options for creating a [[ViewState2d]] via [[ViewCreator2d]].\r\n * @public\r\n*/\r\nexport interface ViewCreator2dOptions {\r\n /** Aspect ratio of [[Viewport]]. Required to fit contents of the model in the initial state of the view. */\r\n vpAspect?: number;\r\n /** Background color of the view (default is white). */\r\n bgColor?: ColorDef;\r\n /** Checks to see if there already is a [[ViewDefinition2d]] for the given modelId. If so, use it as the seed view, and merge its props into the final view created. */\r\n useSeedView?: boolean;\r\n}\r\n\r\n/**\r\n * API for creating a [[ViewState2d]] for a 2D model ([[GeometricModel2dState]]). @see [[ViewCreator3d]] to create a view for a 3d model.\r\n * Example usage:\r\n * ```ts\r\n * const viewCreator = new ViewCreator2d(imodel);\r\n * const models = await imodel.models.queryProps({ from: \"BisCore.GeometricModel2d\" });\r\n * if (models.length > 0)\r\n * const view = await viewCreator.createViewForModel(models[0].id!);\r\n * ```\r\n * @public\r\n */\r\nexport class ViewCreator2d {\r\n\r\n // Types of 2D models the API supports\r\n private static _drawingModelClasses = [DrawingModelState.classFullName, SectionDrawingModelState.classFullName];\r\n private static _sheetModelClasses = [SheetModelState.classFullName];\r\n\r\n /**\r\n * Constructs a ViewCreator2d using an [[IModelConnection]].\r\n * @param _imodel [[IModelConnection]] to query for categories and/or models.\r\n */\r\n constructor(private _imodel: IModelConnection) { }\r\n\r\n /**\r\n * Creates and returns view for the 2D model id passed in.\r\n * @param modelId Id of the 2D model for the view.\r\n * @param [options] Options for creating the view.\r\n * @throws [IModelError]($common) If modelType is not supported.\r\n */\r\n public async createViewForModel(modelId: Id64String, options?: ViewCreator2dOptions): Promise<ViewState> {\r\n\r\n const baseClassName = await this._getModelBaseClassName(modelId);\r\n\r\n const viewState = await this._createViewState2d(modelId, baseClassName.classFullName, options);\r\n try {\r\n await viewState.load();\r\n } catch { }\r\n\r\n return viewState;\r\n }\r\n\r\n /**\r\n * Gets model base class name from id.\r\n * @param modelId of target model.\r\n * @throws [IModelError]($common) if modelId is invalid.\r\n */\r\n private async _getModelBaseClassName(modelId: Id64String): Promise<typeof EntityState> {\r\n\r\n let baseClassName;\r\n\r\n const modelProps = await this._imodel.models.getProps(modelId);\r\n if (modelProps.length > 0) {\r\n const modelType = modelProps[0].classFullName;\r\n baseClassName = await this._imodel.findClassFor(modelType, undefined);\r\n } else\r\n throw new IModelError(IModelStatus.BadModel, \"ViewCreator2d._getModelBaseClassName: modelId is invalid\");\r\n\r\n if (baseClassName === undefined)\r\n throw new IModelError(IModelStatus.WrongClass, \"ViewCreator2d.getViewForModel: modelType is invalid\");\r\n\r\n return baseClassName;\r\n }\r\n\r\n /**\r\n * Creates view from any 2D model type (Drawing/SectionDrawing/Sheet)\r\n * @param modelId of target model.\r\n * @param modelType classFullName of target 2D model.\r\n * @param options for view creation.\r\n * @throws [IModelError]($common) if modelType is not supported.\r\n */\r\n private async _createViewState2d(modelId: Id64String, modelType: string, options?: ViewCreator2dOptions): Promise<ViewState2d> {\r\n let viewState: ViewState2d;\r\n if (this._isDrawingModelClass(modelType)) {\r\n const props = await this._createViewStateProps(modelId, options);\r\n viewState = DrawingViewState.createFromProps(props, this._imodel);\r\n } else if (this._isSheetModelClass(modelType)) {\r\n let props = await this._createViewStateProps(modelId, options);\r\n props = await this._addSheetViewProps(modelId, props);\r\n viewState = SheetViewState.createFromProps(props, this._imodel);\r\n } else\r\n throw new IModelError(IModelStatus.WrongClass, \"ViewCreator2d._createViewState2d: modelType not supported\");\r\n\r\n return viewState;\r\n }\r\n\r\n /**\r\n * Checks to see if given model is of [[DrawingModelState]].\r\n * @param modelType classFullName of model.\r\n */\r\n private _isDrawingModelClass(modelType: string) {\r\n if (ViewCreator2d._drawingModelClasses.includes(modelType)) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * Checks to see if given model is of [[SheetModelState]].\r\n * @param modelType classFullName of model.\r\n */\r\n private _isSheetModelClass(modelType: string) {\r\n if (ViewCreator2d._sheetModelClasses.includes(modelType)) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * Creates ViewStateProps for the model. ViewStateProps are composed of the 4 sets of Props below.\r\n * @param modelId of target model.\r\n * @param options for view creation.\r\n */\r\n private _createViewStateProps = async (modelId: Id64String, options?: ViewCreator2dOptions): Promise<ViewStateProps> => {\r\n // Use dictionary model in all props\r\n const dictionaryId = IModel.dictionaryId;\r\n const categories = await this._getAllCategories();\r\n\r\n // Get bg color from options or default to white\r\n const bgColor: ColorDef = options?.bgColor ? options.bgColor : ColorDef.white;\r\n\r\n // model extents\r\n const modelProps = await this._imodel.models.queryModelRanges(modelId);\r\n const modelExtents = Range3d.fromJSON(modelProps[0]);\r\n let originX = modelExtents.low.x;\r\n let originY = modelExtents.low.y;\r\n let deltaX = modelExtents.xLength();\r\n let deltaY = modelExtents.yLength();\r\n\r\n // if vp aspect given, update model extents to fit view\r\n if (options?.vpAspect) {\r\n const modelAspect = deltaY / deltaX;\r\n\r\n if (modelAspect > options.vpAspect) {\r\n const xFix = deltaY / options.vpAspect;\r\n originX = originX - xFix / 2;\r\n deltaX = deltaX + xFix;\r\n } else if (modelAspect < options.vpAspect) {\r\n const yFix = deltaX * options.vpAspect;\r\n originY = originY - yFix / 2;\r\n deltaY = deltaY + yFix;\r\n }\r\n }\r\n\r\n const modelSelectorProps: ModelSelectorProps = {\r\n models: [modelId],\r\n code: Code.createEmpty(),\r\n model: dictionaryId,\r\n classFullName: \"BisCore:ModelSelector\",\r\n };\r\n\r\n const categorySelectorProps: CategorySelectorProps = {\r\n categories,\r\n code: Code.createEmpty(),\r\n model: dictionaryId,\r\n classFullName: \"BisCore:CategorySelector\",\r\n };\r\n\r\n const viewDefinitionProps: ViewDefinition2dProps = {\r\n baseModelId: modelId,\r\n categorySelectorId: \"\",\r\n displayStyleId: \"\",\r\n origin: { x: originX, y: originY },\r\n delta: { x: deltaX, y: deltaY },\r\n angle: { radians: 0 },\r\n code: Code.createEmpty(),\r\n model: dictionaryId,\r\n classFullName: \"BisCore:ViewDefinition2d\",\r\n };\r\n\r\n const displayStyleProps: DisplayStyleProps = {\r\n code: Code.createEmpty(),\r\n model: dictionaryId,\r\n classFullName: \"BisCore:DisplayStyle\",\r\n jsonProperties: {\r\n styles: {\r\n backgroundColor: bgColor.tbgr,\r\n },\r\n },\r\n };\r\n\r\n const viewStateProps: ViewStateProps = {\r\n displayStyleProps,\r\n categorySelectorProps,\r\n modelSelectorProps,\r\n viewDefinitionProps,\r\n modelExtents,\r\n };\r\n\r\n // merge seed view props if needed\r\n return options?.useSeedView ? this._mergeSeedView(modelId, viewStateProps) : viewStateProps;\r\n };\r\n\r\n /**\r\n * Adds Sheet view props to given view props.\r\n * @param modelId of target model.\r\n * @param props input ViewStateProps.\r\n */\r\n private async _addSheetViewProps(modelId: Id64String, props: ViewStateProps) {\r\n let width = 0;\r\n let height = 0;\r\n for await (const row of this._imodel.query(`SELECT Width, Height FROM bis.Sheet WHERE ECInstanceId = ?`, QueryBinder.from([modelId]), QueryRowFormat.UseJsPropertyNames)) {\r\n width = row.width as number;\r\n height = row.height as number;\r\n break;\r\n }\r\n const sheetProps: SheetProps = {\r\n model: modelId,\r\n code: { spec: \"\", scope: \"\" },\r\n classFullName: \"DrawingSheetModel\",\r\n height,\r\n width,\r\n };\r\n\r\n props.sheetAttachments = await this._getSheetAttachments(modelId);\r\n props.sheetProps = sheetProps;\r\n\r\n return props;\r\n }\r\n\r\n /**\r\n * Merges a seed view in the iModel with the passed view state props. It will be a no-op if there are no 2D views for target model.\r\n * @param modelId of target model.\r\n * @param props Input view props to be merged\r\n */\r\n private async _mergeSeedView(modelId: Id64String, props: ViewStateProps): Promise<ViewStateProps> {\r\n const viewDefinitionId = await this._getViewDefinitionsIdForModel(modelId);\r\n // Return incase no viewDefinition found.\r\n if (viewDefinitionId === undefined)\r\n return props;\r\n\r\n const seedViewState = (await this._imodel.views.load(viewDefinitionId));\r\n const seedViewStateProps: ViewStateProps = {\r\n categorySelectorProps: seedViewState.categorySelector.toJSON(),\r\n viewDefinitionProps: seedViewState.toJSON(),\r\n displayStyleProps: seedViewState.displayStyle.toJSON(),\r\n };\r\n const mergedDisplayProps = seedViewStateProps.displayStyleProps;\r\n if (mergedDisplayProps.jsonProperties !== undefined) {\r\n mergedDisplayProps.jsonProperties.styles = {\r\n ...mergedDisplayProps.jsonProperties.styles,\r\n ...props.displayStyleProps.jsonProperties!.styles,\r\n };\r\n }\r\n\r\n return { ...seedViewStateProps, ...props, displayStyleProps: mergedDisplayProps };\r\n }\r\n\r\n /**\r\n * Get all view definitions for a given model.\r\n * @param modelId of target model.\r\n */\r\n private async _getViewDefinitionsIdForModel(modelId: Id64String): Promise<Id64String | undefined> {\r\n\r\n const query = `SELECT ECInstanceId from Bis.ViewDefinition2D WHERE BaseModel.Id = ${modelId} AND isPrivate = false LIMIT 1`;\r\n const viewDefinitionsId = await this._executeQuery(query);\r\n\r\n return (viewDefinitionsId.length) > 0 ? viewDefinitionsId[0] : undefined;\r\n }\r\n\r\n /**\r\n * Get all drawing categories\r\n */\r\n private async _getAllCategories(): Promise<Id64Array> {\r\n\r\n const query = \"SELECT ECInstanceId from BisCore.DrawingCategory\";\r\n const categories = await this._executeQuery(query);\r\n\r\n return categories;\r\n }\r\n\r\n /**\r\n * Get all sheet attachments\r\n * @param modelId of target model.\r\n */\r\n private async _getSheetAttachments(modelId: string): Promise<Id64Array> {\r\n\r\n const query = `SELECT ECInstanceId FROM Bis.ViewAttachment WHERE Model.Id = ${modelId}`;\r\n const attachments = await this._executeQuery(query);\r\n\r\n return attachments;\r\n }\r\n\r\n /**\r\n * Helper function to execute ECSql queries.\r\n * @param query statement to execute.\r\n */\r\n private _executeQuery = async (query: string) => {\r\n const rows = [];\r\n for await (const row of this._imodel.query(query, undefined, QueryRowFormat.UseJsPropertyNames))\r\n rows.push(row.id);\r\n\r\n return rows;\r\n };\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"ViewCreator2d.js","sourceRoot":"","sources":["../../src/ViewCreator2d.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AAEH;;;EAGE;AAEF,OAAO,EAAyB,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EACkB,IAAI,EAAE,QAAQ,EAAqB,MAAM,EAAE,WAAW,EAAsB,WAAW,EAAE,cAAc,GAE/H,MAAM,oBAAoB,C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AAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC3E,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,iBAAiB;QAE7B,MAAM,KAAK,GAAG,kDAAkD,CAAC;QACjE,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAEnD,OAAO,UAAU,CAAC;IACpB,CAAC;IAED;;;OAGG;IACK,KAAK,CAAC,oBAAoB,CAAC,OAAe;QAEhD,MAAM,KAAK,GAAG,gEAAgE,OAAO,EAAE,CAAC;QACxF,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAEpD,OAAO,WAAW,CAAC;IACrB,CAAC;;AA3QD,sCAAsC;AACvB,kCAAoB,GAAG,CAAC,iBAAiB,CAAC,aAAa,EAAE,wBAAwB,CAAC,aAAa,CAAC,CAAC;AACjG,gCAAkB,GAAG,CAAC,eAAe,CAAC,aAAa,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\r\n/** @packageDocumentation\r\n * @module Views\r\n */\r\n\r\n/*\r\nAPI for creating a 2D view from a given modelId and modelType (classFullName).\r\nAdditional options (such as background color) can be passed during view creation.\r\n*/\r\n\r\nimport { Id64Array, Id64String, IModelStatus } from \"@itwin/core-bentley\";\r\nimport {\r\n CategorySelectorProps, Code, ColorDef, DisplayStyleProps, IModel, IModelError, ModelSelectorProps, QueryBinder, QueryRowFormat, SheetProps,\r\n ViewDefinition2dProps, ViewStateProps,\r\n} from \"@itwin/core-common\";\r\nimport { Range3d } from \"@itwin/core-geometry\";\r\nimport { DrawingViewState } from \"./DrawingViewState\";\r\nimport { EntityState } from \"./EntityState\";\r\nimport { IModelConnection } from \"./IModelConnection\";\r\nimport { DrawingModelState, SectionDrawingModelState, SheetModelState } from \"./ModelState\";\r\nimport { SheetViewState } from \"./SheetViewState\";\r\nimport { ViewState, ViewState2d } from \"./ViewState\";\r\n\r\n/** Options for creating a [[ViewState2d]] via [[ViewCreator2d]].\r\n * @public\r\n*/\r\nexport interface ViewCreator2dOptions {\r\n /** Aspect ratio of [[Viewport]]. Required to fit contents of the model in the initial state of the view. */\r\n vpAspect?: number;\r\n /** Background color of the view (default is white). */\r\n bgColor?: ColorDef;\r\n /** Checks to see if there already is a [[ViewDefinition2d]] for the given modelId. If so, use it as the seed view, and merge its props into the final view created. */\r\n useSeedView?: boolean;\r\n}\r\n\r\n/**\r\n * API for creating a [[ViewState2d]] for a 2D model ([[GeometricModel2dState]]). @see [[ViewCreator3d]] to create a view for a 3d model.\r\n * Example usage:\r\n * ```ts\r\n * const viewCreator = new ViewCreator2d(imodel);\r\n * const models = await imodel.models.queryProps({ from: \"BisCore.GeometricModel2d\" });\r\n * if (models.length > 0)\r\n * const view = await viewCreator.createViewForModel(models[0].id!);\r\n * ```\r\n * @public\r\n */\r\nexport class ViewCreator2d {\r\n\r\n // Types of 2D models the API supports\r\n private static _drawingModelClasses = [DrawingModelState.classFullName, SectionDrawingModelState.classFullName];\r\n private static _sheetModelClasses = [SheetModelState.classFullName];\r\n\r\n /**\r\n * Constructs a ViewCreator2d using an [[IModelConnection]].\r\n * @param _imodel [[IModelConnection]] to query for categories and/or models.\r\n */\r\n constructor(private _imodel: IModelConnection) { }\r\n\r\n /**\r\n * Creates and returns view for the 2D model id passed in.\r\n * @param modelId Id of the 2D model for the view.\r\n * @param [options] Options for creating the view.\r\n * @throws [IModelError]($common) If modelType is not supported.\r\n */\r\n public async createViewForModel(modelId: Id64String, options?: ViewCreator2dOptions): Promise<ViewState> {\r\n\r\n const baseClassName = await this._getModelBaseClassName(modelId);\r\n\r\n const viewState = await this._createViewState2d(modelId, baseClassName.classFullName, options);\r\n try {\r\n await viewState.load();\r\n } catch { }\r\n\r\n return viewState;\r\n }\r\n\r\n /**\r\n * Gets model base class name from id.\r\n * @param modelId of target model.\r\n * @throws [IModelError]($common) if modelId is invalid.\r\n */\r\n private async _getModelBaseClassName(modelId: Id64String): Promise<typeof EntityState> {\r\n\r\n let baseClassName;\r\n\r\n const modelProps = await this._imodel.models.getProps(modelId);\r\n if (modelProps.length > 0) {\r\n const modelType = modelProps[0].classFullName;\r\n baseClassName = await this._imodel.findClassFor(modelType, undefined);\r\n } else\r\n throw new IModelError(IModelStatus.BadModel, \"ViewCreator2d._getModelBaseClassName: modelId is invalid\");\r\n\r\n if (baseClassName === undefined)\r\n throw new IModelError(IModelStatus.WrongClass, \"ViewCreator2d.getViewForModel: modelType is invalid\");\r\n\r\n return baseClassName;\r\n }\r\n\r\n /**\r\n * Creates view from any 2D model type (Drawing/SectionDrawing/Sheet)\r\n * @param modelId of target model.\r\n * @param modelType classFullName of target 2D model.\r\n * @param options for view creation.\r\n * @throws [IModelError]($common) if modelType is not supported.\r\n */\r\n private async _createViewState2d(modelId: Id64String, modelType: string, options?: ViewCreator2dOptions): Promise<ViewState2d> {\r\n let viewState: ViewState2d;\r\n if (this._isDrawingModelClass(modelType)) {\r\n const props = await this._createViewStateProps(modelId, options);\r\n viewState = DrawingViewState.createFromProps(props, this._imodel);\r\n } else if (this._isSheetModelClass(modelType)) {\r\n let props = await this._createViewStateProps(modelId, options);\r\n props = await this._addSheetViewProps(modelId, props);\r\n viewState = SheetViewState.createFromProps(props, this._imodel);\r\n } else\r\n throw new IModelError(IModelStatus.WrongClass, \"ViewCreator2d._createViewState2d: modelType not supported\");\r\n\r\n return viewState;\r\n }\r\n\r\n /**\r\n * Checks to see if given model is of [[DrawingModelState]].\r\n * @param modelType classFullName of model.\r\n */\r\n private _isDrawingModelClass(modelType: string) {\r\n if (ViewCreator2d._drawingModelClasses.includes(modelType)) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * Checks to see if given model is of [[SheetModelState]].\r\n * @param modelType classFullName of model.\r\n */\r\n private _isSheetModelClass(modelType: string) {\r\n if (ViewCreator2d._sheetModelClasses.includes(modelType)) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * Creates ViewStateProps for the model. ViewStateProps are composed of the 4 sets of Props below.\r\n * @param modelId of target model.\r\n * @param options for view creation.\r\n */\r\n private _createViewStateProps = async (modelId: Id64String, options?: ViewCreator2dOptions): Promise<ViewStateProps> => {\r\n // Use dictionary model in all props\r\n const dictionaryId = IModel.dictionaryId;\r\n const categories = await this._getAllCategories();\r\n\r\n // Get bg color from options or default to white\r\n const bgColor: ColorDef = options?.bgColor ? options.bgColor : ColorDef.white;\r\n\r\n // model extents\r\n const modelProps = await this._imodel.models.queryModelRanges(modelId);\r\n const modelExtents = Range3d.fromJSON(modelProps[0]);\r\n let originX = modelExtents.low.x;\r\n let originY = modelExtents.low.y;\r\n let deltaX = modelExtents.xLength();\r\n let deltaY = modelExtents.yLength();\r\n\r\n // if vp aspect given, update model extents to fit view\r\n if (options?.vpAspect) {\r\n const modelAspect = deltaY / deltaX;\r\n\r\n if (modelAspect > options.vpAspect) {\r\n const xFix = deltaY / options.vpAspect;\r\n originX = originX - xFix / 2;\r\n deltaX = deltaX + xFix;\r\n } else if (modelAspect < options.vpAspect) {\r\n const yFix = deltaX * options.vpAspect;\r\n originY = originY - yFix / 2;\r\n deltaY = deltaY + yFix;\r\n }\r\n }\r\n\r\n const modelSelectorProps: ModelSelectorProps = {\r\n models: [modelId],\r\n code: Code.createEmpty(),\r\n model: dictionaryId,\r\n classFullName: \"BisCore:ModelSelector\",\r\n };\r\n\r\n const categorySelectorProps: CategorySelectorProps = {\r\n categories,\r\n code: Code.createEmpty(),\r\n model: dictionaryId,\r\n classFullName: \"BisCore:CategorySelector\",\r\n };\r\n\r\n const viewDefinitionProps: ViewDefinition2dProps = {\r\n baseModelId: modelId,\r\n categorySelectorId: \"\",\r\n displayStyleId: \"\",\r\n origin: { x: originX, y: originY },\r\n delta: { x: deltaX, y: deltaY },\r\n angle: { radians: 0 },\r\n code: Code.createEmpty(),\r\n model: dictionaryId,\r\n classFullName: \"BisCore:ViewDefinition2d\",\r\n };\r\n\r\n const displayStyleProps: DisplayStyleProps = {\r\n code: Code.createEmpty(),\r\n model: dictionaryId,\r\n classFullName: \"BisCore:DisplayStyle\",\r\n jsonProperties: {\r\n styles: {\r\n backgroundColor: bgColor.tbgr,\r\n },\r\n },\r\n };\r\n\r\n const viewStateProps: ViewStateProps = {\r\n displayStyleProps,\r\n categorySelectorProps,\r\n modelSelectorProps,\r\n viewDefinitionProps,\r\n modelExtents,\r\n };\r\n\r\n // merge seed view props if needed\r\n return options?.useSeedView ? this._mergeSeedView(modelId, viewStateProps) : viewStateProps;\r\n };\r\n\r\n /**\r\n * Adds Sheet view props to given view props.\r\n * @param modelId of target model.\r\n * @param props input ViewStateProps.\r\n */\r\n private async _addSheetViewProps(modelId: Id64String, props: ViewStateProps) {\r\n let width = 0;\r\n let height = 0;\r\n for await (const row of this._imodel.query(`SELECT Width, Height FROM bis.Sheet WHERE ECInstanceId = ?`, QueryBinder.from([modelId]), { rowFormat: QueryRowFormat.UseJsPropertyNames })) {\r\n width = row.width as number;\r\n height = row.height as number;\r\n break;\r\n }\r\n const sheetProps: SheetProps = {\r\n model: modelId,\r\n code: { spec: \"\", scope: \"\" },\r\n classFullName: \"DrawingSheetModel\",\r\n height,\r\n width,\r\n };\r\n\r\n props.sheetAttachments = await this._getSheetAttachments(modelId);\r\n props.sheetProps = sheetProps;\r\n\r\n return props;\r\n }\r\n\r\n /**\r\n * Merges a seed view in the iModel with the passed view state props. It will be a no-op if there are no 2D views for target model.\r\n * @param modelId of target model.\r\n * @param props Input view props to be merged\r\n */\r\n private async _mergeSeedView(modelId: Id64String, props: ViewStateProps): Promise<ViewStateProps> {\r\n const viewDefinitionId = await this._getViewDefinitionsIdForModel(modelId);\r\n // Return incase no viewDefinition found.\r\n if (viewDefinitionId === undefined)\r\n return props;\r\n\r\n const seedViewState = (await this._imodel.views.load(viewDefinitionId));\r\n const seedViewStateProps: ViewStateProps = {\r\n categorySelectorProps: seedViewState.categorySelector.toJSON(),\r\n viewDefinitionProps: seedViewState.toJSON(),\r\n displayStyleProps: seedViewState.displayStyle.toJSON(),\r\n };\r\n const mergedDisplayProps = seedViewStateProps.displayStyleProps;\r\n if (mergedDisplayProps.jsonProperties !== undefined) {\r\n mergedDisplayProps.jsonProperties.styles = {\r\n ...mergedDisplayProps.jsonProperties.styles,\r\n ...props.displayStyleProps.jsonProperties!.styles,\r\n };\r\n }\r\n\r\n return { ...seedViewStateProps, ...props, displayStyleProps: mergedDisplayProps };\r\n }\r\n\r\n /**\r\n * Get all view definitions for a given model.\r\n * @param modelId of target model.\r\n */\r\n private async _getViewDefinitionsIdForModel(modelId: Id64String): Promise<Id64String | undefined> {\r\n\r\n const query = `SELECT ECInstanceId from Bis.ViewDefinition2D WHERE BaseModel.Id = ${modelId} AND isPrivate = false LIMIT 1`;\r\n const viewDefinitionsId = await this._executeQuery(query);\r\n\r\n return (viewDefinitionsId.length) > 0 ? viewDefinitionsId[0] : undefined;\r\n }\r\n\r\n /**\r\n * Get all drawing categories\r\n */\r\n private async _getAllCategories(): Promise<Id64Array> {\r\n\r\n const query = \"SELECT ECInstanceId from BisCore.DrawingCategory\";\r\n const categories = await this._executeQuery(query);\r\n\r\n return categories;\r\n }\r\n\r\n /**\r\n * Get all sheet attachments\r\n * @param modelId of target model.\r\n */\r\n private async _getSheetAttachments(modelId: string): Promise<Id64Array> {\r\n\r\n const query = `SELECT ECInstanceId FROM Bis.ViewAttachment WHERE Model.Id = ${modelId}`;\r\n const attachments = await this._executeQuery(query);\r\n\r\n return attachments;\r\n }\r\n\r\n /**\r\n * Helper function to execute ECSql queries.\r\n * @param query statement to execute.\r\n */\r\n private _executeQuery = async (query: string) => {\r\n const rows = [];\r\n for await (const row of this._imodel.query(query, undefined, { rowFormat: QueryRowFormat.UseJsPropertyNames }))\r\n rows.push(row.id);\r\n\r\n return rows;\r\n };\r\n}\r\n"]}
|
package/lib/esm/ViewCreator3d.js
CHANGED
|
@@ -26,7 +26,7 @@ export class ViewCreator3d {
|
|
|
26
26
|
*/
|
|
27
27
|
this._executeQuery = async (query) => {
|
|
28
28
|
const rows = [];
|
|
29
|
-
for await (const row of this._imodel.query(query, undefined, QueryRowFormat.UseJsPropertyNames))
|
|
29
|
+
for await (const row of this._imodel.query(query, undefined, { rowFormat: QueryRowFormat.UseJsPropertyNames }))
|
|
30
30
|
rows.push(row.id);
|
|
31
31
|
return rows;
|
|
32
32
|
};
|