@itwin/core-frontend 4.0.0-dev.72 → 4.0.0-dev.75

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/lib/cjs/DisplayStyleState.d.ts +35 -53
  2. package/lib/cjs/DisplayStyleState.d.ts.map +1 -1
  3. package/lib/cjs/DisplayStyleState.js +51 -101
  4. package/lib/cjs/DisplayStyleState.js.map +1 -1
  5. package/lib/cjs/DrawingViewState.d.ts.map +1 -1
  6. package/lib/cjs/DrawingViewState.js +1 -2
  7. package/lib/cjs/DrawingViewState.js.map +1 -1
  8. package/lib/cjs/IModelApp.d.ts +1 -3
  9. package/lib/cjs/IModelApp.d.ts.map +1 -1
  10. package/lib/cjs/IModelApp.js +1 -3
  11. package/lib/cjs/IModelApp.js.map +1 -1
  12. package/lib/cjs/IModelConnection.d.ts.map +1 -1
  13. package/lib/cjs/IModelConnection.js +4 -6
  14. package/lib/cjs/IModelConnection.js.map +1 -1
  15. package/lib/cjs/SheetViewState.d.ts.map +1 -1
  16. package/lib/cjs/SheetViewState.js +1 -2
  17. package/lib/cjs/SheetViewState.js.map +1 -1
  18. package/lib/cjs/ViewCreator2d.d.ts.map +1 -1
  19. package/lib/cjs/ViewCreator2d.js +2 -4
  20. package/lib/cjs/ViewCreator2d.js.map +1 -1
  21. package/lib/cjs/ViewCreator3d.d.ts.map +1 -1
  22. package/lib/cjs/ViewCreator3d.js +1 -2
  23. package/lib/cjs/ViewCreator3d.js.map +1 -1
  24. package/lib/cjs/Viewport.d.ts +22 -11
  25. package/lib/cjs/Viewport.d.ts.map +1 -1
  26. package/lib/cjs/Viewport.js +60 -12
  27. package/lib/cjs/Viewport.js.map +1 -1
  28. package/lib/cjs/tile/RealityTile.d.ts +12 -5
  29. package/lib/cjs/tile/RealityTile.d.ts.map +1 -1
  30. package/lib/cjs/tile/RealityTile.js +149 -57
  31. package/lib/cjs/tile/RealityTile.js.map +1 -1
  32. package/lib/cjs/tile/RealityTileTree.d.ts +1 -3
  33. package/lib/cjs/tile/RealityTileTree.d.ts.map +1 -1
  34. package/lib/cjs/tile/RealityTileTree.js +8 -21
  35. package/lib/cjs/tile/RealityTileTree.js.map +1 -1
  36. package/lib/cjs/tile/TileUsageMarker.d.ts +4 -0
  37. package/lib/cjs/tile/TileUsageMarker.d.ts.map +1 -1
  38. package/lib/cjs/tile/TileUsageMarker.js +9 -1
  39. package/lib/cjs/tile/TileUsageMarker.js.map +1 -1
  40. package/lib/cjs/tile/map/MapFeatureInfo.d.ts.map +1 -1
  41. package/lib/cjs/tile/map/MapFeatureInfo.js.map +1 -1
  42. package/lib/cjs/tile/map/MapLayerAuthentication.d.ts.map +1 -1
  43. package/lib/cjs/tile/map/MapLayerAuthentication.js.map +1 -1
  44. package/lib/cjs/tile/map/MapLayerFormatRegistry.d.ts +15 -8
  45. package/lib/cjs/tile/map/MapLayerFormatRegistry.d.ts.map +1 -1
  46. package/lib/cjs/tile/map/MapLayerFormatRegistry.js +12 -7
  47. package/lib/cjs/tile/map/MapLayerFormatRegistry.js.map +1 -1
  48. package/lib/cjs/tile/map/MapLayerImageryProvider.d.ts +23 -6
  49. package/lib/cjs/tile/map/MapLayerImageryProvider.d.ts.map +1 -1
  50. package/lib/cjs/tile/map/MapLayerImageryProvider.js +24 -8
  51. package/lib/cjs/tile/map/MapLayerImageryProvider.js.map +1 -1
  52. package/lib/cjs/tile/map/MapLayerSources.d.ts +4 -5
  53. package/lib/cjs/tile/map/MapLayerSources.d.ts.map +1 -1
  54. package/lib/cjs/tile/map/MapLayerSources.js +3 -4
  55. package/lib/cjs/tile/map/MapLayerSources.js.map +1 -1
  56. package/lib/cjs/tile/map/MapTile.d.ts +3 -1
  57. package/lib/cjs/tile/map/MapTile.d.ts.map +1 -1
  58. package/lib/cjs/tile/map/MapTile.js +4 -0
  59. package/lib/cjs/tile/map/MapTile.js.map +1 -1
  60. package/lib/cjs/tile/map/MapTiledGraphicsProvider.d.ts +4 -3
  61. package/lib/cjs/tile/map/MapTiledGraphicsProvider.d.ts.map +1 -1
  62. package/lib/cjs/tile/map/MapTiledGraphicsProvider.js +4 -4
  63. package/lib/cjs/tile/map/MapTiledGraphicsProvider.js.map +1 -1
  64. package/lib/cjs/tools/ElementSetTool.d.ts.map +1 -1
  65. package/lib/cjs/tools/ElementSetTool.js +1 -2
  66. package/lib/cjs/tools/ElementSetTool.js.map +1 -1
  67. package/lib/esm/DisplayStyleState.d.ts +35 -53
  68. package/lib/esm/DisplayStyleState.d.ts.map +1 -1
  69. package/lib/esm/DisplayStyleState.js +54 -104
  70. package/lib/esm/DisplayStyleState.js.map +1 -1
  71. package/lib/esm/DrawingViewState.d.ts.map +1 -1
  72. package/lib/esm/DrawingViewState.js +1 -2
  73. package/lib/esm/DrawingViewState.js.map +1 -1
  74. package/lib/esm/IModelApp.d.ts +1 -3
  75. package/lib/esm/IModelApp.d.ts.map +1 -1
  76. package/lib/esm/IModelApp.js +1 -3
  77. package/lib/esm/IModelApp.js.map +1 -1
  78. package/lib/esm/IModelConnection.d.ts.map +1 -1
  79. package/lib/esm/IModelConnection.js +4 -6
  80. package/lib/esm/IModelConnection.js.map +1 -1
  81. package/lib/esm/SheetViewState.d.ts.map +1 -1
  82. package/lib/esm/SheetViewState.js +1 -2
  83. package/lib/esm/SheetViewState.js.map +1 -1
  84. package/lib/esm/ViewCreator2d.d.ts.map +1 -1
  85. package/lib/esm/ViewCreator2d.js +2 -4
  86. package/lib/esm/ViewCreator2d.js.map +1 -1
  87. package/lib/esm/ViewCreator3d.d.ts.map +1 -1
  88. package/lib/esm/ViewCreator3d.js +1 -2
  89. package/lib/esm/ViewCreator3d.js.map +1 -1
  90. package/lib/esm/Viewport.d.ts +22 -11
  91. package/lib/esm/Viewport.d.ts.map +1 -1
  92. package/lib/esm/Viewport.js +63 -15
  93. package/lib/esm/Viewport.js.map +1 -1
  94. package/lib/esm/tile/RealityTile.d.ts +12 -5
  95. package/lib/esm/tile/RealityTile.d.ts.map +1 -1
  96. package/lib/esm/tile/RealityTile.js +149 -57
  97. package/lib/esm/tile/RealityTile.js.map +1 -1
  98. package/lib/esm/tile/RealityTileTree.d.ts +1 -3
  99. package/lib/esm/tile/RealityTileTree.d.ts.map +1 -1
  100. package/lib/esm/tile/RealityTileTree.js +11 -24
  101. package/lib/esm/tile/RealityTileTree.js.map +1 -1
  102. package/lib/esm/tile/TileUsageMarker.d.ts +4 -0
  103. package/lib/esm/tile/TileUsageMarker.d.ts.map +1 -1
  104. package/lib/esm/tile/TileUsageMarker.js +9 -1
  105. package/lib/esm/tile/TileUsageMarker.js.map +1 -1
  106. package/lib/esm/tile/map/MapFeatureInfo.d.ts.map +1 -1
  107. package/lib/esm/tile/map/MapFeatureInfo.js.map +1 -1
  108. package/lib/esm/tile/map/MapLayerAuthentication.d.ts.map +1 -1
  109. package/lib/esm/tile/map/MapLayerAuthentication.js.map +1 -1
  110. package/lib/esm/tile/map/MapLayerFormatRegistry.d.ts +15 -8
  111. package/lib/esm/tile/map/MapLayerFormatRegistry.d.ts.map +1 -1
  112. package/lib/esm/tile/map/MapLayerFormatRegistry.js +12 -7
  113. package/lib/esm/tile/map/MapLayerFormatRegistry.js.map +1 -1
  114. package/lib/esm/tile/map/MapLayerImageryProvider.d.ts +23 -6
  115. package/lib/esm/tile/map/MapLayerImageryProvider.d.ts.map +1 -1
  116. package/lib/esm/tile/map/MapLayerImageryProvider.js +24 -8
  117. package/lib/esm/tile/map/MapLayerImageryProvider.js.map +1 -1
  118. package/lib/esm/tile/map/MapLayerSources.d.ts +4 -5
  119. package/lib/esm/tile/map/MapLayerSources.d.ts.map +1 -1
  120. package/lib/esm/tile/map/MapLayerSources.js +3 -4
  121. package/lib/esm/tile/map/MapLayerSources.js.map +1 -1
  122. package/lib/esm/tile/map/MapTile.d.ts +3 -1
  123. package/lib/esm/tile/map/MapTile.d.ts.map +1 -1
  124. package/lib/esm/tile/map/MapTile.js +4 -0
  125. package/lib/esm/tile/map/MapTile.js.map +1 -1
  126. package/lib/esm/tile/map/MapTiledGraphicsProvider.d.ts +4 -3
  127. package/lib/esm/tile/map/MapTiledGraphicsProvider.d.ts.map +1 -1
  128. package/lib/esm/tile/map/MapTiledGraphicsProvider.js +4 -4
  129. package/lib/esm/tile/map/MapTiledGraphicsProvider.js.map +1 -1
  130. package/lib/esm/tools/ElementSetTool.d.ts.map +1 -1
  131. package/lib/esm/tools/ElementSetTool.js +1 -2
  132. package/lib/esm/tools/ElementSetTool.js.map +1 -1
  133. package/package.json +19 -19
@@ -1 +1 @@
1
- {"version":3,"file":"SheetViewState.js","sourceRoot":"","sources":["../../src/SheetViewState.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAgG;AAChG,wDAAuK;AACvK,oDAG4B;AAC5B,mEAAgE;AAChE,2DAA0D;AAE1D,4DAAsE;AAEtE,0DAAuD;AACvD,2CAAwC;AAGxC,oDAAiD;AAGjD,gEAA6D;AAE7D,yCAAsC;AACtC,2CAAwC;AACxC,+CAA4C;AAC5C,yCAAyD;AACzD,2CAA2E;AAE3E,8CAAwG;AACxG,2CAAmF;AAEnF,qBAAqB;AAErB;;GAEG;AACH,MAAM,WAAW;IAKf,YAAoB,IAAe,EAAE,MAAiB,EAAE,QAAuB;QAC7E,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC5B,CAAC;IAED,uGAAuG;IAChG,MAAM,CAAC,MAAM,CAAC,KAAa,EAAE,MAAc,EAAE,OAAyB;QAC3E,OAAO;QACP,MAAM,IAAI,GAAc;YACtB,uBAAO,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC;YACzB,uBAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;YACpB,uBAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;YACxB,uBAAO,CAAC,MA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AC,QAAQ,EAAE,KAAK,CAAC,CAAC;QAC5C,MAAM,OAAO,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC;QAExC,wCAAwC;QACxC,MAAM,MAAM,GAAG,IAAI,6BAAa,CAAC,IAAI,CAAC,CAAC;QACvC,MAAM,MAAM,GAAG,IAAA,yCAA8B,EAAC,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;QAEtH,gIAAgI;QAChI,MAAM,CAAC,YAAY,GAAG,KAAK,CAAC;QAC5B,MAAM,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;QACpC,MAAM,CAAC,kBAAkB,GAAG,IAAI,mCAAgB,CAAC,SAAS,EAAE,CAAC;QAC7D,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAE7B,uCAAuC;QACvC,IAAI,UAAU,CAAC;QACf,IAAI,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,IAAI,EAAE;YACpC,MAAM,UAAU,GAAG,0BAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;YACzE,IAAI,UAAU,CAAC,OAAO;gBACpB,UAAU,GAAG,qBAAS,CAAC,YAAY,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;SACpE;QAED,OAAO,qBAAS,CAAC,YAAY,CAAC,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;IAC7F,CAAC;IAEM,iBAAiB,CAAC,KAA8B;QACrD,IAAI,IAAI,CAAC,SAAS;YAChB,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAC5C,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 Views\r\n */\r\n\r\nimport { assert, CompressedId64Set, dispose, Id64Array, Id64String } from \"@itwin/core-bentley\";\r\nimport { Angle, ClipShape, ClipVector, Constant, Matrix3d, Point2d, Point3d, PolyfaceBuilder, Range2d, Range3d, StrokeOptions, Transform } from \"@itwin/core-geometry\";\r\nimport {\r\n AxisAlignedBox3d, ColorDef, Feature, FeatureTable, Frustum, Gradient, GraphicParams, HiddenLine, HydrateViewStateRequestProps, HydrateViewStateResponseProps, PackedFeatureTable, Placement2d, SheetProps,\r\n TextureTransparency, ViewAttachmentProps, ViewDefinition2dProps, ViewFlagOverrides, ViewStateProps,\r\n} from \"@itwin/core-common\";\r\nimport { CategorySelectorState } from \"./CategorySelectorState\";\r\nimport { DisplayStyle2dState } from \"./DisplayStyleState\";\r\nimport { IModelConnection } from \"./IModelConnection\";\r\nimport { GraphicBuilder, GraphicType } from \"./render/GraphicBuilder\";\r\nimport { RenderGraphic } from \"./render/RenderGraphic\";\r\nimport { GraphicBranch } from \"./render/GraphicBranch\";\r\nimport { Frustum2d } from \"./Frustum2d\";\r\nimport { Scene } from \"./render/Scene\";\r\nimport { Decorations } from \"./render/Decorations\";\r\nimport { MockRender } from \"./render/MockRender\";\r\nimport { RenderClipVolume } from \"./render/RenderClipVolume\";\r\nimport { RenderMemory } from \"./render/RenderMemory\";\r\nimport { FeatureSymbology } from \"./render/FeatureSymbology\";\r\nimport { DecorateContext, SceneContext } from \"./ViewContext\";\r\nimport { ViewRect } from \"./ViewRect\";\r\nimport { IModelApp } from \"./IModelApp\";\r\nimport { CoordSystem } from \"./CoordSystem\";\r\nimport { OffScreenViewport, Viewport } from \"./Viewport\";\r\nimport { AttachToViewportArgs, ViewState, ViewState2d } from \"./ViewState\";\r\nimport { DrawingViewState } from \"./DrawingViewState\";\r\nimport { createDefaultViewFlagOverrides, DisclosedTileTreeSet, TileGraphicType } from \"./tile/internal\";\r\nimport { imageBufferToPngDataUrl, openImageDataUrlInNewWindow } from \"./ImageUtil\";\r\n\r\n// cSpell:ignore ovrs\r\n\r\n/** Describes the geometry and styling of a sheet border decoration.\r\n * The sheet border decoration mimics a sheet of paper with a drop shadow.\r\n */\r\nclass SheetBorder {\r\n private _rect: Point2d[];\r\n private _shadow: Point2d[];\r\n private _gradient: Gradient.Symb;\r\n\r\n private constructor(rect: Point2d[], shadow: Point2d[], gradient: Gradient.Symb) {\r\n this._rect = rect;\r\n this._shadow = shadow;\r\n this._gradient = gradient;\r\n }\r\n\r\n /** Create a new sheet border. If a context is supplied, points are transformed to view coordinates. */\r\n public static create(width: number, height: number, context?: DecorateContext) {\r\n // Rect\r\n const rect: Point3d[] = [\r\n Point3d.create(0, height),\r\n Point3d.create(0, 0),\r\n Point3d.create(width, 0),\r\n Point3d.create(width, height),\r\n Point3d.create(0, height)];\r\n if (context) {\r\n context.viewport.worldToViewArray(rect);\r\n }\r\n\r\n // Shadow\r\n const shadowWidth = .01 * Math.sqrt(width * width + height * height);\r\n const shadow: Point3d[] = [\r\n Point3d.create(shadowWidth, 0),\r\n Point3d.create(shadowWidth, -shadowWidth),\r\n Point3d.create(width + shadowWidth, -shadowWidth),\r\n Point3d.create(width + shadowWidth, height - shadowWidth),\r\n Point3d.create(width, height - shadowWidth),\r\n Point3d.create(width, 0),\r\n Point3d.create(shadowWidth, 0),\r\n ];\r\n if (context) {\r\n context.viewport.worldToViewArray(shadow);\r\n }\r\n\r\n // Gradient\r\n const gradient = new Gradient.Symb();\r\n gradient.mode = Gradient.Mode.Linear;\r\n gradient.angle = Angle.createDegrees(-45);\r\n gradient.keys = [{ value: 0, color: ColorDef.from(25, 25, 25) }, { value: 0.5, color: ColorDef.from(150, 150, 150) }];\r\n\r\n // Copy over points\r\n const rect2d: Point2d[] = [];\r\n for (const point of rect)\r\n rect2d.push(Point2d.createFrom(point));\r\n const shadow2d: Point2d[] = [];\r\n for (const point of shadow)\r\n shadow2d.push(Point2d.createFrom(point));\r\n\r\n return new SheetBorder(rect2d, shadow2d, gradient);\r\n }\r\n\r\n public getRange(): Range2d {\r\n const range = Range2d.createArray(this._rect);\r\n const shadowRange = Range2d.createArray(this._shadow);\r\n range.extendRange(shadowRange);\r\n return range;\r\n }\r\n\r\n /** Add this border to the given GraphicBuilder. */\r\n public addToBuilder(builder: GraphicBuilder) {\r\n const lineColor = ColorDef.black;\r\n const fillColor = ColorDef.black;\r\n\r\n const params = new GraphicParams();\r\n params.fillColor = fillColor;\r\n params.gradient = this._gradient;\r\n\r\n builder.activateGraphicParams(params);\r\n builder.addShape2d(this._shadow, Frustum2d.minimumZDistance);\r\n\r\n builder.setSymbology(lineColor, fillColor, 2);\r\n builder.addLineString2d(this._rect, 0);\r\n }\r\n}\r\n\r\n/** The information required to instantiate an Attachment object. See ViewAttachmentsInfo */\r\ninterface ViewAttachmentInfo extends ViewAttachmentProps {\r\n attachedView: ViewState;\r\n}\r\n\r\n/** The information required to instantiate an ViewAttachments object to draw ViewAttachments into a sheet. The list of view attachment Ids is\r\n * supplied to SheetViewState via the constructor. The corresponding ViewAttachmentProps for each attachment are obtained asynchronously in\r\n * SheetViewState.load(). The Attachments object is created in SheetViewState.attachToViewport and disposed of in SheetViewState.detachFromViewport.\r\n */\r\nclass ViewAttachmentsInfo {\r\n private _attachments: Id64Array | ViewAttachmentInfo[];\r\n\r\n private constructor(attachments: Id64Array | ViewAttachmentInfo[]) {\r\n this._attachments = attachments;\r\n }\r\n\r\n public get isLoaded(): boolean {\r\n return 0 === this._attachments.length || \"string\" !== typeof this._attachments[0];\r\n }\r\n\r\n public get viewAttachmentProps(): Array<Readonly<ViewAttachmentProps>> {\r\n return this.isLoaded ? this._props : [];\r\n }\r\n\r\n private get _props(): ViewAttachmentInfo[] {\r\n assert(this.isLoaded);\r\n return this._attachments as ViewAttachmentInfo[];\r\n }\r\n\r\n private get _ids(): Id64Array {\r\n assert(!this.isLoaded);\r\n return this._attachments as Id64Array;\r\n }\r\n\r\n public static fromJSON(ids: Id64Array = []): ViewAttachmentsInfo {\r\n return new ViewAttachmentsInfo(ids);\r\n }\r\n\r\n public toJSON(): Id64Array {\r\n return this.isLoaded ? this._props.map((x) => x.id!) : [...this._ids];\r\n }\r\n\r\n public clone(): ViewAttachmentsInfo {\r\n // No reason to clone the array.\r\n return new ViewAttachmentsInfo(this._attachments);\r\n }\r\n\r\n public preload(options: HydrateViewStateRequestProps) {\r\n if (this.isLoaded)\r\n return;\r\n options.sheetViewAttachmentIds = CompressedId64Set.sortAndCompress(this._ids);\r\n options.viewStateLoadProps = {\r\n displayStyle: {\r\n omitScheduleScriptElementIds: !IModelApp.tileAdmin.enableFrontendScheduleScripts,\r\n compressExcludedElementIds: true,\r\n },\r\n };\r\n }\r\n\r\n public async postload(options: HydrateViewStateResponseProps, iModel: IModelConnection) {\r\n if (options.sheetViewViews === undefined)\r\n return;\r\n if (options.sheetViewAttachmentProps === undefined)\r\n return;\r\n\r\n const viewStateProps = options.sheetViewViews; // This is viewstateProps, need to turn this into ViewState\r\n const promises = [];\r\n for (const viewProps of viewStateProps) {\r\n const loadView = async () => {\r\n try {\r\n if (viewProps === undefined)\r\n return undefined;\r\n const view = await iModel.views.convertViewStatePropsToViewState(viewProps);\r\n return view;\r\n } catch {\r\n return undefined;\r\n }\r\n };\r\n promises.push(loadView());\r\n }\r\n const views = await Promise.all(promises);\r\n\r\n const attachmentProps = options.sheetViewAttachmentProps as ViewAttachmentInfo[];\r\n assert (views.length === attachmentProps.length);\r\n const attachments = [];\r\n for (let i = 0; i < views.length; i++) {\r\n const view = views[i];\r\n if (view && !(view instanceof SheetViewState)) {\r\n const props = attachmentProps[i];\r\n props.attachedView = view;\r\n attachments.push(props);\r\n }\r\n }\r\n\r\n this._attachments = attachments;\r\n }\r\n\r\n public async load(iModel: IModelConnection): Promise<void> {\r\n if (this.isLoaded)\r\n return;\r\n\r\n const attachmentProps = await iModel.elements.getProps(this._ids) as ViewAttachmentInfo[];\r\n const promises = [];\r\n for (const attachment of attachmentProps) {\r\n const loadView = async () => {\r\n try {\r\n const view = await iModel.views.load(attachment.view.id);\r\n return view;\r\n } catch {\r\n return undefined;\r\n }\r\n };\r\n\r\n promises.push(loadView());\r\n }\r\n\r\n const views = await Promise.all(promises);\r\n assert(views.length === attachmentProps.length);\r\n\r\n const attachments = [];\r\n for (let i = 0; i < views.length; i++) {\r\n const view = views[i];\r\n if (view && !(view instanceof SheetViewState)) {\r\n const props = attachmentProps[i];\r\n props.attachedView = view;\r\n attachments.push(props);\r\n }\r\n }\r\n\r\n this._attachments = attachments;\r\n }\r\n\r\n public createAttachments(sheetView: SheetViewState): ViewAttachments | undefined {\r\n return this.isLoaded ? new ViewAttachments(this._props, sheetView) : undefined;\r\n }\r\n}\r\n\r\n/** The set of view attachments to be displayed in a Viewport via a SheetViewState. Allocated when the view becomes attached to a Viewport;\r\n * disposed of when it becomes detached from the viewport.\r\n */\r\nclass ViewAttachments {\r\n private readonly _attachments: Attachment[] = [];\r\n public maxDepth = Frustum2d.minimumZDistance;\r\n\r\n public constructor(infos: ViewAttachmentInfo[], sheetView: SheetViewState) {\r\n for (const info of infos) {\r\n const drawAsRaster = info.jsonProperties?.displayOptions?.drawAsRaster || (info.attachedView.is3d() && info.attachedView.isCameraOn);\r\n const ctor = drawAsRaster ? RasterAttachment : OrthographicAttachment;\r\n const attachment = new ctor(info.attachedView, info, sheetView);\r\n this._attachments.push(attachment);\r\n this.maxDepth = Math.max(this.maxDepth, attachment.zDepth);\r\n }\r\n }\r\n\r\n public dispose(): void {\r\n for (const attachment of this._attachments)\r\n attachment.dispose();\r\n\r\n this._attachments.length = 0;\r\n }\r\n\r\n public [Symbol.iterator](): Iterator<Attachment> {\r\n return this._attachments[Symbol.iterator]();\r\n }\r\n\r\n /** For tests. */\r\n public get attachments(): Object[] {\r\n return this._attachments;\r\n }\r\n\r\n public get isEmpty(): boolean {\r\n return 0 === this._attachments.length;\r\n }\r\n\r\n public get areAllTileTreesLoaded(): boolean {\r\n return this._attachments.every((x) => x.areAllTileTreesLoaded);\r\n }\r\n\r\n public discloseTileTrees(trees: DisclosedTileTreeSet): void {\r\n for (const attachment of this._attachments)\r\n trees.disclose(attachment);\r\n }\r\n\r\n public collectStatistics(stats: RenderMemory.Statistics): void {\r\n for (const attachment of this._attachments)\r\n attachment.collectStatistics(stats);\r\n }\r\n\r\n public addToScene(context: SceneContext): void {\r\n for (const attachment of this._attachments)\r\n attachment.addToScene(context);\r\n }\r\n}\r\n\r\n/** A view of a [SheetModel]($backend).\r\n * @public\r\n * @extensions\r\n */\r\nexport class SheetViewState extends ViewState2d {\r\n /** The width and height of the sheet in world coordinates. */\r\n public readonly sheetSize: Point2d;\r\n private _attachmentsInfo: ViewAttachmentsInfo;\r\n private _attachments?: ViewAttachments;\r\n private readonly _viewedExtents: AxisAlignedBox3d;\r\n\r\n public get attachmentIds(): Id64Array {\r\n return this._attachmentsInfo.toJSON();\r\n }\r\n\r\n public static override get className() { return \"SheetViewDefinition\"; }\r\n\r\n public static override createFromProps(viewStateData: ViewStateProps, iModel: IModelConnection): SheetViewState {\r\n const cat = new CategorySelectorState(viewStateData.categorySelectorProps, iModel);\r\n const displayStyleState = new DisplayStyle2dState(viewStateData.displayStyleProps, iModel);\r\n\r\n // use \"new this\" so subclasses are correct\r\n return new this(viewStateData.viewDefinitionProps as ViewDefinition2dProps, iModel, cat, displayStyleState, viewStateData.sheetProps!, viewStateData.sheetAttachments!);\r\n }\r\n\r\n public override toProps(): ViewStateProps {\r\n const props = super.toProps();\r\n\r\n props.sheetAttachments = this._attachmentsInfo.toJSON();\r\n\r\n // For sheetProps all that is actually used is the size, so just null out everything else.\r\n const codeProps = { spec: \"\", scope: \"\", value: \"\" };\r\n props.sheetProps = {\r\n model: \"\",\r\n code: codeProps,\r\n classFullName: \"\",\r\n width: this.sheetSize.x,\r\n height: this.sheetSize.y,\r\n scale: 1,\r\n };\r\n\r\n return props;\r\n }\r\n\r\n /** Strictly for testing. @internal */\r\n public get viewAttachmentProps(): Array<Readonly<ViewAttachmentProps>> {\r\n return this._attachmentsInfo.viewAttachmentProps;\r\n }\r\n\r\n /** Strictly for testing. @internal */\r\n public get attachments(): Object[] | undefined {\r\n return this._attachments?.attachments;\r\n }\r\n\r\n /** @internal */\r\n public override isDrawingView(): this is DrawingViewState { return false; }\r\n /** @internal */\r\n public override isSheetView(): this is SheetViewState { return true; }\r\n\r\n public constructor(props: ViewDefinition2dProps, iModel: IModelConnection, categories: CategorySelectorState, displayStyle: DisplayStyle2dState, sheetProps: SheetProps, attachments: Id64Array) {\r\n super(props, iModel, categories, displayStyle);\r\n if (categories instanceof SheetViewState) {\r\n // we are coming from clone...\r\n this.sheetSize = categories.sheetSize.clone();\r\n this._attachmentsInfo = categories._attachmentsInfo.clone();\r\n this._viewedExtents = categories._viewedExtents.clone();\r\n } else {\r\n this.sheetSize = Point2d.create(sheetProps.width, sheetProps.height);\r\n this._attachmentsInfo = ViewAttachmentsInfo.fromJSON(attachments);\r\n\r\n const extents = new Range3d(0, 0, 0, this.sheetSize.x, this.sheetSize.y, 0);\r\n const margin = 1.1;\r\n extents.scaleAboutCenterInPlace(margin);\r\n this._viewedExtents = extents;\r\n }\r\n }\r\n\r\n public override getOrigin() {\r\n const origin = super.getOrigin();\r\n if (this._attachments)\r\n origin.z = -this._attachments.maxDepth;\r\n\r\n return origin;\r\n }\r\n\r\n public override getExtents() {\r\n const extents = super.getExtents();\r\n if (this._attachments)\r\n extents.z = this._attachments.maxDepth + Frustum2d.minimumZDistance;\r\n\r\n return extents;\r\n }\r\n\r\n /** Disclose *all* TileTrees currently in use by this view. This set may include trees not reported by [[forEachTileTreeRef]] - e.g., those used by view attachments, map-draped terrain, etc.\r\n * @internal override\r\n */\r\n public override discloseTileTrees(trees: DisclosedTileTreeSet): void {\r\n super.discloseTileTrees(trees);\r\n if (this._attachments)\r\n trees.disclose(this._attachments);\r\n }\r\n\r\n /** @internal */\r\n public override collectNonTileTreeStatistics(stats: RenderMemory.Statistics): void {\r\n super.collectNonTileTreeStatistics(stats);\r\n if (this._attachments)\r\n this._attachments.collectStatistics(stats);\r\n }\r\n\r\n /** @internal */\r\n public override get defaultExtentLimits() {\r\n return { min: Constant.oneMillimeter, max: this.sheetSize.magnitude() * 10 };\r\n }\r\n\r\n /** @internal */\r\n public override getViewedExtents(): AxisAlignedBox3d {\r\n return this._viewedExtents;\r\n }\r\n\r\n /** @internal */\r\n protected override preload(hydrateRequest: HydrateViewStateRequestProps): void {\r\n super.preload(hydrateRequest);\r\n this._attachmentsInfo.preload(hydrateRequest);\r\n }\r\n\r\n /** @internal */\r\n protected override async postload(hydrateResponse: HydrateViewStateResponseProps): Promise<void> {\r\n const promises = [];\r\n promises.push(super.postload(hydrateResponse));\r\n promises.push(this._attachmentsInfo.postload(hydrateResponse, this.iModel));\r\n await Promise.all(promises);\r\n }\r\n\r\n /** @internal */\r\n public override createScene(context: SceneContext): void {\r\n super.createScene(context);\r\n if (this._attachments)\r\n this._attachments.addToScene(context);\r\n }\r\n\r\n /** @internal */\r\n public override get secondaryViewports(): Iterable<Viewport> {\r\n const attachments = this._attachments;\r\n if (!attachments)\r\n return super.secondaryViewports;\r\n\r\n function* iterator() {\r\n for (const attachment of attachments!) {\r\n const vp = attachment.viewport;\r\n if (vp)\r\n yield vp;\r\n }\r\n }\r\n\r\n return {\r\n [Symbol.iterator]: () => iterator(),\r\n };\r\n }\r\n\r\n /** @internal */\r\n private async queryAttachmentIds(): Promise<Id64Array> {\r\n const ecsql = `SELECT ECInstanceId as attachmentId FROM bis.ViewAttachment WHERE model.Id=${this.baseModelId}`;\r\n const ids: string[] = [];\r\n // eslint-disable-next-line deprecation/deprecation\r\n for await (const row of this.iModel.query(ecsql))\r\n ids.push(row[0]);\r\n\r\n return ids;\r\n }\r\n\r\n /** @internal */\r\n public override async changeViewedModel(modelId: Id64String): Promise<void> {\r\n await super.changeViewedModel(modelId);\r\n const attachmentIds = await this.queryAttachmentIds();\r\n this._attachmentsInfo = ViewAttachmentsInfo.fromJSON(attachmentIds);\r\n\r\n assert(undefined === this._attachments);\r\n }\r\n\r\n /** @internal */\r\n public override attachToViewport(args: AttachToViewportArgs): void {\r\n super.attachToViewport(args);\r\n assert(undefined === this._attachments);\r\n this._attachments = this._attachmentsInfo.createAttachments(this);\r\n }\r\n\r\n /** @internal */\r\n public override detachFromViewport(): void {\r\n super.detachFromViewport();\r\n this._attachments = dispose(this._attachments);\r\n }\r\n\r\n /** @internal */\r\n public override get areAllTileTreesLoaded(): boolean {\r\n return super.areAllTileTreesLoaded && (!this._attachments || this._attachments.areAllTileTreesLoaded);\r\n }\r\n\r\n /** Create a sheet border decoration graphic. */\r\n private createBorder(width: number, height: number, context: DecorateContext): RenderGraphic {\r\n const border = SheetBorder.create(width, height, context);\r\n const builder = context.createGraphicBuilder(GraphicType.ViewBackground);\r\n border.addToBuilder(builder);\r\n return builder.finish();\r\n }\r\n\r\n /** @internal */\r\n public override decorate(context: DecorateContext): void {\r\n super.decorate(context);\r\n if (this.sheetSize !== undefined) {\r\n const border = this.createBorder(this.sheetSize.x, this.sheetSize.y, context);\r\n context.setViewBackground(border);\r\n }\r\n }\r\n\r\n /** @internal */\r\n public override computeFitRange(): Range3d {\r\n const size = this.sheetSize;\r\n if (0 >= size.x || 0 >= size.y)\r\n return super.computeFitRange();\r\n return new Range3d(0, 0, -1, size.x, size.y, 1);\r\n }\r\n}\r\n\r\n/** A mostly no-op RenderTarget for an Attachment.\r\n * its Scene and symbology overrides.\r\n */\r\nclass AttachmentTarget extends MockRender.OffScreenTarget {\r\n private readonly _attachment: OrthographicAttachment;\r\n\r\n public constructor(attachment: OrthographicAttachment) {\r\n // The dimensions don't matter - we're not drawing anything.\r\n const rect = new ViewRect(1, 1);\r\n super(IModelApp.renderSystem, rect);\r\n this._attachment = attachment;\r\n }\r\n\r\n public override changeScene(scene: Scene): void {\r\n this._attachment.scene = scene;\r\n }\r\n\r\n public override overrideFeatureSymbology(ovrs: FeatureSymbology.Overrides): void {\r\n this._attachment.symbologyOverrides = ovrs;\r\n }\r\n}\r\n\r\n/** Draws the contents of a view attachment into a sheet view. */\r\ninterface Attachment {\r\n readonly areAllTileTreesLoaded: boolean;\r\n addToScene: (context: SceneContext) => void;\r\n discloseTileTrees: (trees: DisclosedTileTreeSet) => void;\r\n readonly zDepth: number;\r\n collectStatistics: (stats: RenderMemory.Statistics) => void;\r\n viewAttachmentProps: ViewAttachmentProps;\r\n dispose(): void;\r\n readonly viewport?: Viewport;\r\n}\r\n\r\n/** Draws the contents a 2d or orthographic 3d view directly into a sheet view.\r\n * We select tiles for the view in the context of a light-weight offscreen viewport with a no-op RenderTarget, then\r\n * collect the resultant graphics and add them to the sheet view's scene.\r\n */\r\nclass OrthographicAttachment {\r\n private readonly _viewport: OffScreenViewport;\r\n private readonly _props: ViewAttachmentProps;\r\n private readonly _sheetModelId: Id64String;\r\n private readonly _viewFlagOverrides: ViewFlagOverrides;\r\n private readonly _toSheet: Transform;\r\n private readonly _fromSheet: Transform;\r\n private readonly _sizeInMeters: Point2d;\r\n private readonly _range: Range3d;\r\n private readonly _viewRect = new ViewRect(0, 0, 1, 1);\r\n private readonly _originalFrustum = new Frustum();\r\n private readonly _clipVolume?: RenderClipVolume;\r\n private readonly _hiddenLineSettings?: HiddenLine.Settings;\r\n private readonly _scale: { x: number, y: number };\r\n private _debugFeatureTable?: PackedFeatureTable;\r\n public scene?: Scene;\r\n public symbologyOverrides: FeatureSymbology.Overrides;\r\n public readonly zDepth: number;\r\n\r\n public get view(): ViewState {\r\n return this._viewport.view;\r\n }\r\n\r\n public get viewAttachmentProps() {\r\n return this._props;\r\n }\r\n\r\n public get viewport(): Viewport {\r\n return this._viewport;\r\n }\r\n\r\n public constructor(view: ViewState, props: ViewAttachmentProps, sheetView: SheetViewState) {\r\n this.symbologyOverrides = new FeatureSymbology.Overrides(view);\r\n const target = new AttachmentTarget(this);\r\n this._viewport = OffScreenViewport.createViewport(view, target, true);\r\n\r\n this._props = props;\r\n this._sheetModelId = sheetView.baseModelId;\r\n\r\n const applyClip = true; // set to false for debugging\r\n this._viewFlagOverrides = {\r\n ...view.viewFlags,\r\n clipVolume: applyClip,\r\n lighting: false,\r\n shadows: false,\r\n };\r\n\r\n const placement = Placement2d.fromJSON(props.placement);\r\n const range = placement.calculateRange();\r\n this._range = range;\r\n this._sizeInMeters = new Point2d(range.xLength(), range.yLength());\r\n\r\n // Compute transform from attached view's world coordinates to sheet's world coordinates.\r\n // NB: We obtain the extents and origin from the *viewport* not the *view* - they may have been adjusted by the viewport.\r\n const applySkew = true; // set to false for debugging\r\n const skew = applySkew ? view.getAspectRatioSkew() : 1;\r\n const extents = this._viewport.viewingSpace.viewDelta.clone();\r\n const zDepth = Math.abs(extents.z);\r\n const scaleX = this._sizeInMeters.x / Math.abs(extents.x);\r\n const scaleY = skew * this._sizeInMeters.y / Math.abs(extents.y);\r\n this._scale = { x: 1 / scaleX, y: 1 / scaleY };\r\n\r\n const zBias = Frustum2d.depthFromDisplayPriority(props.jsonProperties?.displayPriority ?? 0);\r\n this.zDepth = 1.01 * (zDepth - zBias); // give a little padding so that geometry right up against far plane doesn't get clipped.\r\n\r\n // View origin is at the *back* of the view. Align *front* of view based on display priority.\r\n const viewRot = view.getRotation();\r\n const viewOrg = viewRot.multiplyVector(this._viewport.viewingSpace.viewOrigin);\r\n viewOrg.z += zDepth;\r\n viewRot.multiplyTransposeVectorInPlace(viewOrg);\r\n\r\n const matrix = Matrix3d.createScale(scaleX, scaleY, 1);\r\n matrix.multiplyMatrixMatrix(viewRot, matrix);\r\n const origin = Matrix3d.xyzMinusMatrixTimesXYZ(viewOrg, matrix, viewOrg);\r\n const attachmentOrigin = Point3d.createFrom(placement.origin);\r\n attachmentOrigin.z = zBias;\r\n const viewOrgToAttachment = attachmentOrigin.minus(viewOrg);\r\n origin.addInPlace(viewOrgToAttachment);\r\n this._toSheet = Transform.createRefs(origin, matrix);\r\n this._fromSheet = this._toSheet.inverse()!;\r\n\r\n // If the attached view is a section drawing, it may itself have an attached spatial view with a clip.\r\n // The clip needs to be transformed into sheet space.\r\n if (view.isDrawingView())\r\n this._viewport.drawingToSheetTransform = this._toSheet;\r\n\r\n // ###TODO? If we also apply the attachment's clip to the attached view, we may get additional culling during tile selection.\r\n // However the attached view's frustum is already clipped by intersection with sheet view's frustum, and additional clipping planes\r\n // introduce additional computation, so possibly not worth it.\r\n\r\n // Transform the view's clip (if any) to sheet space\r\n let viewClip = view.viewFlags.clipVolume ? view.getViewClip()?.clone() : undefined;\r\n if (viewClip)\r\n viewClip.transformInPlace(this._toSheet);\r\n else\r\n viewClip = ClipVector.createEmpty();\r\n\r\n let sheetClip;\r\n if (undefined !== props.jsonProperties?.clip)\r\n sheetClip = ClipVector.fromJSON(props.jsonProperties?.clip);\r\n\r\n if (sheetClip && sheetClip.isValid) {\r\n // Clip to view attachment's clip. NB: clip is in sheet coordinate space.\r\n for (const clip of sheetClip.clips)\r\n viewClip.clips.push(clip);\r\n } else {\r\n // Clip to view attachment's bounding box\r\n viewClip.appendShape([\r\n Point3d.create(this._range.low.x, this._range.low.y),\r\n Point3d.create(this._range.high.x, this._range.low.y),\r\n Point3d.create(this._range.high.x, this._range.high.y),\r\n Point3d.create(this._range.low.x, this._range.high.y),\r\n ]);\r\n }\r\n\r\n this._clipVolume = IModelApp.renderSystem.createClipVolume(viewClip);\r\n\r\n // Save off the original frustum (potentially adjusted by viewport).\r\n this._viewport.setupFromView();\r\n this._viewport.viewingSpace.getFrustum(CoordSystem.World, true, this._originalFrustum);\r\n\r\n const applyHiddenLineSettings = true; // for debugging edge display, set to false...\r\n const style = view.displayStyle;\r\n if (style.is3d() && applyHiddenLineSettings)\r\n this._hiddenLineSettings = style.settings.hiddenLineSettings;\r\n }\r\n\r\n public dispose(): void {\r\n this._viewport.dispose();\r\n }\r\n\r\n public discloseTileTrees(trees: DisclosedTileTreeSet): void {\r\n trees.disclose(this._viewport);\r\n }\r\n\r\n public addToScene(context: SceneContext): void {\r\n if (context.viewport.freezeScene)\r\n return;\r\n\r\n if (!context.viewport.view.viewsCategory(this._props.category))\r\n return;\r\n\r\n const wantBounds = context.viewport.wantViewAttachmentBoundaries;\r\n const wantClipShapes = context.viewport.wantViewAttachmentClipShapes;\r\n if (wantBounds || wantClipShapes) {\r\n const builder = context.createSceneGraphicBuilder();\r\n if (wantBounds) {\r\n builder.setSymbology(ColorDef.red, ColorDef.red, 2);\r\n builder.addRangeBox(this._range);\r\n }\r\n\r\n if (wantClipShapes && this._clipVolume) {\r\n builder.setSymbology(ColorDef.blue, ColorDef.blue, 2);\r\n for (const prim of this._clipVolume.clipVector.clips) {\r\n if (!(prim instanceof ClipShape))\r\n continue; // ###TODO handle non-shape primitives, if any such ever encountered\r\n\r\n const pts = [];\r\n const tf = prim.transformFromClip;\r\n for (const pt of prim.polygon) {\r\n const tfPt = tf ? tf.multiplyPoint3d(pt) : pt;\r\n pts.push(new Point2d(tfPt.x, tfPt.y));\r\n }\r\n\r\n builder.addLineString2d(pts, 0);\r\n }\r\n }\r\n\r\n // Put into a Batch so that we can see tooltip with attachment Id on mouseover.\r\n const batch = context.target.renderSystem.createBatch(builder.finish(), this.getDebugFeatureTable(), this._range);\r\n context.outputGraphic(batch);\r\n }\r\n\r\n if (!context.viewport.wantViewAttachments)\r\n return;\r\n\r\n // Pixel size used to compute size of ViewRect so that tiles of appropriate LOD are selected.\r\n const pixelSize = context.viewport.getPixelSizeAtPoint();\r\n if (0 === pixelSize)\r\n return;\r\n\r\n // Adjust attached view frustum based on intersection with sheet view frustum.\r\n const attachFrustum = this._originalFrustum.transformBy(this._toSheet);\r\n const attachFrustumRange = attachFrustum.toRange();\r\n const sheetFrustum = context.viewport.getWorldFrustum();\r\n const sheetFrustumRange = sheetFrustum.toRange();\r\n const intersect = attachFrustumRange.intersect(sheetFrustumRange);\r\n if (intersect.isNull)\r\n return;\r\n\r\n attachFrustum.initFromRange(intersect);\r\n attachFrustum.transformBy(this._fromSheet, attachFrustum);\r\n this._viewport.setupViewFromFrustum(attachFrustum);\r\n\r\n // Adjust view rect based on size of attachment on screen so that tiles of appropriate LOD are selected.\r\n const width = this._sizeInMeters.x * intersect.xLength() / attachFrustumRange.xLength();\r\n const height = this._sizeInMeters.y * intersect.yLength() / attachFrustumRange.yLength();\r\n this._viewRect.width = Math.max(1, Math.round(width / pixelSize));\r\n this._viewRect.height = Math.max(1, Math.round(height / pixelSize));\r\n this._viewport.setRect(this._viewRect);\r\n\r\n // Propagate settings from on-screen viewport.\r\n this._viewport.debugBoundingBoxes = context.viewport.debugBoundingBoxes;\r\n this._viewport.setTileSizeModifier(context.viewport.tileSizeModifier);\r\n\r\n // Create the scene.\r\n this._viewport.renderFrame();\r\n\r\n const scene = this.scene;\r\n if (!scene)\r\n return;\r\n\r\n // Extract scene graphics and insert into on-screen scene context.\r\n const options = {\r\n clipVolume: this._clipVolume,\r\n hline: this._hiddenLineSettings,\r\n frustum: {\r\n is3d: this.view.is3d(),\r\n scale: this._scale,\r\n },\r\n };\r\n\r\n const outputGraphics = (source: RenderGraphic[]) => {\r\n if (0 === source.length)\r\n return;\r\n\r\n const graphics = new GraphicBranch();\r\n graphics.setViewFlagOverrides(this._viewFlagOverrides);\r\n graphics.symbologyOverrides = this.symbologyOverrides;\r\n\r\n for (const graphic of source)\r\n graphics.entries.push(graphic);\r\n\r\n const branch = context.createGraphicBranch(graphics, this._toSheet, options);\r\n context.outputGraphic(branch);\r\n };\r\n\r\n outputGraphics(scene.foreground);\r\n context.withGraphicType(TileGraphicType.BackgroundMap, () => outputGraphics(scene.background));\r\n context.withGraphicType(TileGraphicType.Overlay, () => outputGraphics(scene.overlay));\r\n\r\n // Report tile statistics to sheet view's viewport.\r\n const tileAdmin = IModelApp.tileAdmin;\r\n const selectedAndReady = tileAdmin.getTilesForUser(this._viewport);\r\n const requested = tileAdmin.getRequestsForUser(this._viewport);\r\n tileAdmin.addExternalTilesForUser(context.viewport, {\r\n requested: requested?.size ?? 0,\r\n selected: selectedAndReady?.selected.size ?? 0,\r\n ready: selectedAndReady?.ready.size ?? 0,\r\n });\r\n }\r\n\r\n private getDebugFeatureTable(): PackedFeatureTable {\r\n if (this._debugFeatureTable)\r\n return this._debugFeatureTable;\r\n\r\n const featureTable = new FeatureTable(1, this._sheetModelId);\r\n featureTable.insert(new Feature(this._props.id));\r\n this._debugFeatureTable = PackedFeatureTable.pack(featureTable);\r\n return this._debugFeatureTable;\r\n }\r\n\r\n public get areAllTileTreesLoaded(): boolean {\r\n return this.view.areAllTileTreesLoaded;\r\n }\r\n\r\n public collectStatistics(_stats: RenderMemory.Statistics): void {\r\n // Handled by discloseTileTrees()\r\n }\r\n}\r\n\r\nfunction createRasterAttachmentViewport(_view: ViewState, _rect: ViewRect, _attachment: RasterAttachment): OffScreenViewport {\r\n class RasterAttachmentViewport extends OffScreenViewport {\r\n private _sceneContext?: SceneContext;\r\n private _isSceneReady = false;\r\n private readonly _attachment: RasterAttachment;\r\n\r\n public constructor(view: ViewState, rect: ViewRect, attachment: RasterAttachment) {\r\n super(IModelApp.renderSystem.createOffscreenTarget(rect));\r\n this._attachment = attachment;\r\n this._isAspectRatioLocked = true;\r\n this.changeView(view);\r\n }\r\n\r\n public override createSceneContext(): SceneContext {\r\n assert(!this._isSceneReady);\r\n\r\n this._sceneContext = super.createSceneContext();\r\n return this._sceneContext;\r\n }\r\n\r\n public override renderFrame(): void {\r\n assert(!this._isSceneReady);\r\n\r\n this.clearSceneContext();\r\n super.renderFrame();\r\n\r\n if (undefined !== this._sceneContext) {\r\n this._isSceneReady = !this._sceneContext.hasMissingTiles && this.view.areAllTileTreesLoaded;\r\n if (this._isSceneReady)\r\n this._attachment.produceGraphics(this._sceneContext);\r\n\r\n this._sceneContext = undefined;\r\n }\r\n }\r\n\r\n private clearSceneContext(): void {\r\n this._sceneContext = undefined;\r\n }\r\n\r\n public override addDecorations(_decorations: Decorations): void {\r\n // ###TODO: skybox, ground plane, possibly grid. DecorateContext requires a ScreenViewport...\r\n }\r\n }\r\n\r\n return new RasterAttachmentViewport(_view, _rect, _attachment);\r\n}\r\n\r\n/** Draws a 3d view with camera enabled into a sheet view by producing an image of the view's contents offscreen. */\r\nclass RasterAttachment {\r\n private readonly _props: ViewAttachmentProps;\r\n private readonly _placement: Placement2d;\r\n private readonly _transform: Transform;\r\n public readonly zDepth: number;\r\n private _viewport?: OffScreenViewport;\r\n private _graphics?: RenderGraphic;\r\n\r\n public constructor(view: ViewState, props: ViewAttachmentProps, sheetView: SheetViewState) {\r\n // Render to a 2048x2048 view rect. Scale in Y to preserve aspect ratio.\r\n const maxSize = 2048;\r\n const rect = new ViewRect(0, 0, maxSize, maxSize);\r\n const height = maxSize * view.getAspectRatio() * view.getAspectRatioSkew();\r\n const skew = maxSize / height;\r\n view.setAspectRatioSkew(skew);\r\n\r\n if (true !== props.jsonProperties?.displayOptions?.preserveBackground) {\r\n // Make background color 100% transparent so that Viewport.readImageBuffer() will discard transparent pixels.\r\n const bgColor = sheetView.displayStyle.backgroundColor.withAlpha(0);\r\n view.displayStyle.backgroundColor = bgColor;\r\n }\r\n\r\n this._viewport = createRasterAttachmentViewport(view, rect, this);\r\n this._props = props;\r\n this._placement = Placement2d.fromJSON(props.placement);\r\n this._transform = this._placement.transform;\r\n this.zDepth = Frustum2d.depthFromDisplayPriority(props.jsonProperties?.displayPriority ?? 0);\r\n }\r\n\r\n public dispose(): void {\r\n this._viewport?.dispose();\r\n }\r\n\r\n public get viewAttachmentProps() {\r\n return this._props;\r\n }\r\n\r\n public get viewport(): Viewport | undefined {\r\n return this._viewport;\r\n }\r\n\r\n public get areAllTileTreesLoaded() {\r\n return this._viewport?.areAllTileTreesLoaded ?? true;\r\n }\r\n\r\n public addToScene(context: SceneContext): void {\r\n // ###TODO: check viewport.wantViewAttachmentClipShapes\r\n if (!context.viewport.view.viewsCategory(this._props.category))\r\n return;\r\n\r\n if (context.viewport.wantViewAttachmentBoundaries) {\r\n const builder = context.createSceneGraphicBuilder(this._transform);\r\n builder.setSymbology(ColorDef.red, ColorDef.red, 2);\r\n builder.addRangeBox(Range3d.createRange2d(this._placement.bbox));\r\n context.outputGraphic(builder.finish());\r\n }\r\n\r\n if (!context.viewport.wantViewAttachments)\r\n return;\r\n\r\n if (this._graphics) {\r\n context.outputGraphic(this._graphics);\r\n return;\r\n }\r\n\r\n if (undefined === this._viewport)\r\n return;\r\n\r\n this._viewport.debugBoundingBoxes = context.viewport.debugBoundingBoxes;\r\n this._viewport.setTileSizeModifier(context.viewport.tileSizeModifier);\r\n\r\n this._viewport.renderFrame();\r\n if (this._graphics)\r\n context.outputGraphic(this._graphics);\r\n }\r\n\r\n public discloseTileTrees(trees: DisclosedTileTreeSet) {\r\n if (this._viewport)\r\n trees.disclose(this._viewport);\r\n }\r\n\r\n public produceGraphics(context: SceneContext): void {\r\n assert(context.viewport === this._viewport);\r\n this._graphics = this.createGraphics(this._viewport);\r\n this._viewport = dispose(this._viewport);\r\n\r\n if (undefined !== this._graphics)\r\n context.outputGraphic(this._graphics);\r\n }\r\n\r\n private createGraphics(vp: Viewport): RenderGraphic | undefined {\r\n // Create a texture from the contents of the view.\r\n const image = vp.readImageBuffer({ upsideDown: true });\r\n if (undefined === image)\r\n return undefined;\r\n\r\n const debugImage = false; // set to true to open a window displaying the captured image.\r\n if (debugImage) {\r\n const url = imageBufferToPngDataUrl(image, false);\r\n if (url)\r\n openImageDataUrlInNewWindow(url, \"Attachment\");\r\n }\r\n\r\n const texture = IModelApp.renderSystem.createTexture({\r\n image: { source: image, transparency: TextureTransparency.Opaque },\r\n });\r\n if (!texture)\r\n return undefined;\r\n\r\n // Create a material for the texture\r\n const graphicParams = new GraphicParams();\r\n graphicParams.material = IModelApp.renderSystem.createRenderMaterial({ textureMapping: { texture } });\r\n\r\n // Apply the texture to a rectangular polyface.\r\n const depth = this.zDepth;\r\n const east = this._placement.bbox.low.x;\r\n const west = this._placement.bbox.high.x;\r\n const north = this._placement.bbox.low.y;\r\n const south = this._placement.bbox.high.y;\r\n const corners = [\r\n Point3d.create(east, north, depth),\r\n Point3d.create(west, north, depth),\r\n Point3d.create(west, south, depth),\r\n Point3d.create(east, south, depth),\r\n ];\r\n const params = [\r\n Point2d.create(0, 0),\r\n Point2d.create(1, 0),\r\n Point2d.create(1, 1),\r\n Point2d.create(0, 1),\r\n ];\r\n\r\n const strokeOptions = new StrokeOptions();\r\n strokeOptions.needParams = strokeOptions.shouldTriangulate = true;\r\n const polyfaceBuilder = PolyfaceBuilder.create(strokeOptions);\r\n polyfaceBuilder.addQuadFacet(corners, params);\r\n const polyface = polyfaceBuilder.claimPolyface();\r\n\r\n const graphicBuilder = IModelApp.renderSystem.createGraphicBuilder(Transform.createIdentity(), GraphicType.Scene, vp, this._props.id);\r\n graphicBuilder.activateGraphicParams(graphicParams);\r\n graphicBuilder.addPolyface(polyface, false);\r\n const graphic = graphicBuilder.finish();\r\n\r\n // Wrap the polyface in a GraphicBranch.\r\n const branch = new GraphicBranch(true);\r\n const vfOvrs = createDefaultViewFlagOverrides({ clipVolume: true, shadows: false, lighting: false, thematic: false });\r\n\r\n // Disable transparency - background pixels are 100% transparent so they will be discarded anyway. Other pixels are 100% opaque.\r\n vfOvrs.transparency = false;\r\n branch.setViewFlagOverrides(vfOvrs);\r\n branch.symbologyOverrides = new FeatureSymbology.Overrides();\r\n branch.entries.push(graphic);\r\n\r\n // Apply the attachment's clip, if any.\r\n let clipVolume;\r\n if (this._props.jsonProperties?.clip) {\r\n const clipVector = ClipVector.fromJSON(this._props.jsonProperties?.clip);\r\n if (clipVector.isValid)\r\n clipVolume = IModelApp.renderSystem.createClipVolume(clipVector);\r\n }\r\n\r\n return IModelApp.renderSystem.createGraphicBranch(branch, this._transform, { clipVolume });\r\n }\r\n\r\n public collectStatistics(stats: RenderMemory.Statistics): void {\r\n if (this._graphics)\r\n this._graphics.collectStatistics(stats);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"SheetViewState.js","sourceRoot":"","sources":["../../src/SheetViewState.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC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AAM,CAAC,kBAAkB,GAAG,IAAI,mCAAgB,CAAC,SAAS,EAAE,CAAC;QAC7D,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAE7B,uCAAuC;QACvC,IAAI,UAAU,CAAC;QACf,IAAI,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,IAAI,EAAE;YACpC,MAAM,UAAU,GAAG,0BAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;YACzE,IAAI,UAAU,CAAC,OAAO;gBACpB,UAAU,GAAG,qBAAS,CAAC,YAAY,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;SACpE;QAED,OAAO,qBAAS,CAAC,YAAY,CAAC,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;IAC7F,CAAC;IAEM,iBAAiB,CAAC,KAA8B;QACrD,IAAI,IAAI,CAAC,SAAS;YAChB,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAC5C,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 Views\r\n */\r\n\r\nimport { assert, CompressedId64Set, dispose, Id64Array, Id64String } from \"@itwin/core-bentley\";\r\nimport { Angle, ClipShape, ClipVector, Constant, Matrix3d, Point2d, Point3d, PolyfaceBuilder, Range2d, Range3d, StrokeOptions, Transform } from \"@itwin/core-geometry\";\r\nimport {\r\n AxisAlignedBox3d, ColorDef, Feature, FeatureTable, Frustum, Gradient, GraphicParams, HiddenLine, HydrateViewStateRequestProps, HydrateViewStateResponseProps, PackedFeatureTable, Placement2d, SheetProps,\r\n TextureTransparency, ViewAttachmentProps, ViewDefinition2dProps, ViewFlagOverrides, ViewStateProps,\r\n} from \"@itwin/core-common\";\r\nimport { CategorySelectorState } from \"./CategorySelectorState\";\r\nimport { DisplayStyle2dState } from \"./DisplayStyleState\";\r\nimport { IModelConnection } from \"./IModelConnection\";\r\nimport { GraphicBuilder, GraphicType } from \"./render/GraphicBuilder\";\r\nimport { RenderGraphic } from \"./render/RenderGraphic\";\r\nimport { GraphicBranch } from \"./render/GraphicBranch\";\r\nimport { Frustum2d } from \"./Frustum2d\";\r\nimport { Scene } from \"./render/Scene\";\r\nimport { Decorations } from \"./render/Decorations\";\r\nimport { MockRender } from \"./render/MockRender\";\r\nimport { RenderClipVolume } from \"./render/RenderClipVolume\";\r\nimport { RenderMemory } from \"./render/RenderMemory\";\r\nimport { FeatureSymbology } from \"./render/FeatureSymbology\";\r\nimport { DecorateContext, SceneContext } from \"./ViewContext\";\r\nimport { ViewRect } from \"./ViewRect\";\r\nimport { IModelApp } from \"./IModelApp\";\r\nimport { CoordSystem } from \"./CoordSystem\";\r\nimport { OffScreenViewport, Viewport } from \"./Viewport\";\r\nimport { AttachToViewportArgs, ViewState, ViewState2d } from \"./ViewState\";\r\nimport { DrawingViewState } from \"./DrawingViewState\";\r\nimport { createDefaultViewFlagOverrides, DisclosedTileTreeSet, TileGraphicType } from \"./tile/internal\";\r\nimport { imageBufferToPngDataUrl, openImageDataUrlInNewWindow } from \"./ImageUtil\";\r\n\r\n// cSpell:ignore ovrs\r\n\r\n/** Describes the geometry and styling of a sheet border decoration.\r\n * The sheet border decoration mimics a sheet of paper with a drop shadow.\r\n */\r\nclass SheetBorder {\r\n private _rect: Point2d[];\r\n private _shadow: Point2d[];\r\n private _gradient: Gradient.Symb;\r\n\r\n private constructor(rect: Point2d[], shadow: Point2d[], gradient: Gradient.Symb) {\r\n this._rect = rect;\r\n this._shadow = shadow;\r\n this._gradient = gradient;\r\n }\r\n\r\n /** Create a new sheet border. If a context is supplied, points are transformed to view coordinates. */\r\n public static create(width: number, height: number, context?: DecorateContext) {\r\n // Rect\r\n const rect: Point3d[] = [\r\n Point3d.create(0, height),\r\n Point3d.create(0, 0),\r\n Point3d.create(width, 0),\r\n Point3d.create(width, height),\r\n Point3d.create(0, height)];\r\n if (context) {\r\n context.viewport.worldToViewArray(rect);\r\n }\r\n\r\n // Shadow\r\n const shadowWidth = .01 * Math.sqrt(width * width + height * height);\r\n const shadow: Point3d[] = [\r\n Point3d.create(shadowWidth, 0),\r\n Point3d.create(shadowWidth, -shadowWidth),\r\n Point3d.create(width + shadowWidth, -shadowWidth),\r\n Point3d.create(width + shadowWidth, height - shadowWidth),\r\n Point3d.create(width, height - shadowWidth),\r\n Point3d.create(width, 0),\r\n Point3d.create(shadowWidth, 0),\r\n ];\r\n if (context) {\r\n context.viewport.worldToViewArray(shadow);\r\n }\r\n\r\n // Gradient\r\n const gradient = new Gradient.Symb();\r\n gradient.mode = Gradient.Mode.Linear;\r\n gradient.angle = Angle.createDegrees(-45);\r\n gradient.keys = [{ value: 0, color: ColorDef.from(25, 25, 25) }, { value: 0.5, color: ColorDef.from(150, 150, 150) }];\r\n\r\n // Copy over points\r\n const rect2d: Point2d[] = [];\r\n for (const point of rect)\r\n rect2d.push(Point2d.createFrom(point));\r\n const shadow2d: Point2d[] = [];\r\n for (const point of shadow)\r\n shadow2d.push(Point2d.createFrom(point));\r\n\r\n return new SheetBorder(rect2d, shadow2d, gradient);\r\n }\r\n\r\n public getRange(): Range2d {\r\n const range = Range2d.createArray(this._rect);\r\n const shadowRange = Range2d.createArray(this._shadow);\r\n range.extendRange(shadowRange);\r\n return range;\r\n }\r\n\r\n /** Add this border to the given GraphicBuilder. */\r\n public addToBuilder(builder: GraphicBuilder) {\r\n const lineColor = ColorDef.black;\r\n const fillColor = ColorDef.black;\r\n\r\n const params = new GraphicParams();\r\n params.fillColor = fillColor;\r\n params.gradient = this._gradient;\r\n\r\n builder.activateGraphicParams(params);\r\n builder.addShape2d(this._shadow, Frustum2d.minimumZDistance);\r\n\r\n builder.setSymbology(lineColor, fillColor, 2);\r\n builder.addLineString2d(this._rect, 0);\r\n }\r\n}\r\n\r\n/** The information required to instantiate an Attachment object. See ViewAttachmentsInfo */\r\ninterface ViewAttachmentInfo extends ViewAttachmentProps {\r\n attachedView: ViewState;\r\n}\r\n\r\n/** The information required to instantiate an ViewAttachments object to draw ViewAttachments into a sheet. The list of view attachment Ids is\r\n * supplied to SheetViewState via the constructor. The corresponding ViewAttachmentProps for each attachment are obtained asynchronously in\r\n * SheetViewState.load(). The Attachments object is created in SheetViewState.attachToViewport and disposed of in SheetViewState.detachFromViewport.\r\n */\r\nclass ViewAttachmentsInfo {\r\n private _attachments: Id64Array | ViewAttachmentInfo[];\r\n\r\n private constructor(attachments: Id64Array | ViewAttachmentInfo[]) {\r\n this._attachments = attachments;\r\n }\r\n\r\n public get isLoaded(): boolean {\r\n return 0 === this._attachments.length || \"string\" !== typeof this._attachments[0];\r\n }\r\n\r\n public get viewAttachmentProps(): Array<Readonly<ViewAttachmentProps>> {\r\n return this.isLoaded ? this._props : [];\r\n }\r\n\r\n private get _props(): ViewAttachmentInfo[] {\r\n assert(this.isLoaded);\r\n return this._attachments as ViewAttachmentInfo[];\r\n }\r\n\r\n private get _ids(): Id64Array {\r\n assert(!this.isLoaded);\r\n return this._attachments as Id64Array;\r\n }\r\n\r\n public static fromJSON(ids: Id64Array = []): ViewAttachmentsInfo {\r\n return new ViewAttachmentsInfo(ids);\r\n }\r\n\r\n public toJSON(): Id64Array {\r\n return this.isLoaded ? this._props.map((x) => x.id!) : [...this._ids];\r\n }\r\n\r\n public clone(): ViewAttachmentsInfo {\r\n // No reason to clone the array.\r\n return new ViewAttachmentsInfo(this._attachments);\r\n }\r\n\r\n public preload(options: HydrateViewStateRequestProps) {\r\n if (this.isLoaded)\r\n return;\r\n options.sheetViewAttachmentIds = CompressedId64Set.sortAndCompress(this._ids);\r\n options.viewStateLoadProps = {\r\n displayStyle: {\r\n omitScheduleScriptElementIds: !IModelApp.tileAdmin.enableFrontendScheduleScripts,\r\n compressExcludedElementIds: true,\r\n },\r\n };\r\n }\r\n\r\n public async postload(options: HydrateViewStateResponseProps, iModel: IModelConnection) {\r\n if (options.sheetViewViews === undefined)\r\n return;\r\n if (options.sheetViewAttachmentProps === undefined)\r\n return;\r\n\r\n const viewStateProps = options.sheetViewViews; // This is viewstateProps, need to turn this into ViewState\r\n const promises = [];\r\n for (const viewProps of viewStateProps) {\r\n const loadView = async () => {\r\n try {\r\n if (viewProps === undefined)\r\n return undefined;\r\n const view = await iModel.views.convertViewStatePropsToViewState(viewProps);\r\n return view;\r\n } catch {\r\n return undefined;\r\n }\r\n };\r\n promises.push(loadView());\r\n }\r\n const views = await Promise.all(promises);\r\n\r\n const attachmentProps = options.sheetViewAttachmentProps as ViewAttachmentInfo[];\r\n assert(views.length === attachmentProps.length);\r\n const attachments = [];\r\n for (let i = 0; i < views.length; i++) {\r\n const view = views[i];\r\n if (view && !(view instanceof SheetViewState)) {\r\n const props = attachmentProps[i];\r\n props.attachedView = view;\r\n attachments.push(props);\r\n }\r\n }\r\n\r\n this._attachments = attachments;\r\n }\r\n\r\n public async load(iModel: IModelConnection): Promise<void> {\r\n if (this.isLoaded)\r\n return;\r\n\r\n const attachmentProps = await iModel.elements.getProps(this._ids) as ViewAttachmentInfo[];\r\n const promises = [];\r\n for (const attachment of attachmentProps) {\r\n const loadView = async () => {\r\n try {\r\n const view = await iModel.views.load(attachment.view.id);\r\n return view;\r\n } catch {\r\n return undefined;\r\n }\r\n };\r\n\r\n promises.push(loadView());\r\n }\r\n\r\n const views = await Promise.all(promises);\r\n assert(views.length === attachmentProps.length);\r\n\r\n const attachments = [];\r\n for (let i = 0; i < views.length; i++) {\r\n const view = views[i];\r\n if (view && !(view instanceof SheetViewState)) {\r\n const props = attachmentProps[i];\r\n props.attachedView = view;\r\n attachments.push(props);\r\n }\r\n }\r\n\r\n this._attachments = attachments;\r\n }\r\n\r\n public createAttachments(sheetView: SheetViewState): ViewAttachments | undefined {\r\n return this.isLoaded ? new ViewAttachments(this._props, sheetView) : undefined;\r\n }\r\n}\r\n\r\n/** The set of view attachments to be displayed in a Viewport via a SheetViewState. Allocated when the view becomes attached to a Viewport;\r\n * disposed of when it becomes detached from the viewport.\r\n */\r\nclass ViewAttachments {\r\n private readonly _attachments: Attachment[] = [];\r\n public maxDepth = Frustum2d.minimumZDistance;\r\n\r\n public constructor(infos: ViewAttachmentInfo[], sheetView: SheetViewState) {\r\n for (const info of infos) {\r\n const drawAsRaster = info.jsonProperties?.displayOptions?.drawAsRaster || (info.attachedView.is3d() && info.attachedView.isCameraOn);\r\n const ctor = drawAsRaster ? RasterAttachment : OrthographicAttachment;\r\n const attachment = new ctor(info.attachedView, info, sheetView);\r\n this._attachments.push(attachment);\r\n this.maxDepth = Math.max(this.maxDepth, attachment.zDepth);\r\n }\r\n }\r\n\r\n public dispose(): void {\r\n for (const attachment of this._attachments)\r\n attachment.dispose();\r\n\r\n this._attachments.length = 0;\r\n }\r\n\r\n public [Symbol.iterator](): Iterator<Attachment> {\r\n return this._attachments[Symbol.iterator]();\r\n }\r\n\r\n /** For tests. */\r\n public get attachments(): Object[] {\r\n return this._attachments;\r\n }\r\n\r\n public get isEmpty(): boolean {\r\n return 0 === this._attachments.length;\r\n }\r\n\r\n public get areAllTileTreesLoaded(): boolean {\r\n return this._attachments.every((x) => x.areAllTileTreesLoaded);\r\n }\r\n\r\n public discloseTileTrees(trees: DisclosedTileTreeSet): void {\r\n for (const attachment of this._attachments)\r\n trees.disclose(attachment);\r\n }\r\n\r\n public collectStatistics(stats: RenderMemory.Statistics): void {\r\n for (const attachment of this._attachments)\r\n attachment.collectStatistics(stats);\r\n }\r\n\r\n public addToScene(context: SceneContext): void {\r\n for (const attachment of this._attachments)\r\n attachment.addToScene(context);\r\n }\r\n}\r\n\r\n/** A view of a [SheetModel]($backend).\r\n * @public\r\n * @extensions\r\n */\r\nexport class SheetViewState extends ViewState2d {\r\n /** The width and height of the sheet in world coordinates. */\r\n public readonly sheetSize: Point2d;\r\n private _attachmentsInfo: ViewAttachmentsInfo;\r\n private _attachments?: ViewAttachments;\r\n private readonly _viewedExtents: AxisAlignedBox3d;\r\n\r\n public get attachmentIds(): Id64Array {\r\n return this._attachmentsInfo.toJSON();\r\n }\r\n\r\n public static override get className() { return \"SheetViewDefinition\"; }\r\n\r\n public static override createFromProps(viewStateData: ViewStateProps, iModel: IModelConnection): SheetViewState {\r\n const cat = new CategorySelectorState(viewStateData.categorySelectorProps, iModel);\r\n const displayStyleState = new DisplayStyle2dState(viewStateData.displayStyleProps, iModel);\r\n\r\n // use \"new this\" so subclasses are correct\r\n return new this(viewStateData.viewDefinitionProps as ViewDefinition2dProps, iModel, cat, displayStyleState, viewStateData.sheetProps!, viewStateData.sheetAttachments!);\r\n }\r\n\r\n public override toProps(): ViewStateProps {\r\n const props = super.toProps();\r\n\r\n props.sheetAttachments = this._attachmentsInfo.toJSON();\r\n\r\n // For sheetProps all that is actually used is the size, so just null out everything else.\r\n const codeProps = { spec: \"\", scope: \"\", value: \"\" };\r\n props.sheetProps = {\r\n model: \"\",\r\n code: codeProps,\r\n classFullName: \"\",\r\n width: this.sheetSize.x,\r\n height: this.sheetSize.y,\r\n scale: 1,\r\n };\r\n\r\n return props;\r\n }\r\n\r\n /** Strictly for testing. @internal */\r\n public get viewAttachmentProps(): Array<Readonly<ViewAttachmentProps>> {\r\n return this._attachmentsInfo.viewAttachmentProps;\r\n }\r\n\r\n /** Strictly for testing. @internal */\r\n public get attachments(): Object[] | undefined {\r\n return this._attachments?.attachments;\r\n }\r\n\r\n /** @internal */\r\n public override isDrawingView(): this is DrawingViewState { return false; }\r\n /** @internal */\r\n public override isSheetView(): this is SheetViewState { return true; }\r\n\r\n public constructor(props: ViewDefinition2dProps, iModel: IModelConnection, categories: CategorySelectorState, displayStyle: DisplayStyle2dState, sheetProps: SheetProps, attachments: Id64Array) {\r\n super(props, iModel, categories, displayStyle);\r\n if (categories instanceof SheetViewState) {\r\n // we are coming from clone...\r\n this.sheetSize = categories.sheetSize.clone();\r\n this._attachmentsInfo = categories._attachmentsInfo.clone();\r\n this._viewedExtents = categories._viewedExtents.clone();\r\n } else {\r\n this.sheetSize = Point2d.create(sheetProps.width, sheetProps.height);\r\n this._attachmentsInfo = ViewAttachmentsInfo.fromJSON(attachments);\r\n\r\n const extents = new Range3d(0, 0, 0, this.sheetSize.x, this.sheetSize.y, 0);\r\n const margin = 1.1;\r\n extents.scaleAboutCenterInPlace(margin);\r\n this._viewedExtents = extents;\r\n }\r\n }\r\n\r\n public override getOrigin() {\r\n const origin = super.getOrigin();\r\n if (this._attachments)\r\n origin.z = -this._attachments.maxDepth;\r\n\r\n return origin;\r\n }\r\n\r\n public override getExtents() {\r\n const extents = super.getExtents();\r\n if (this._attachments)\r\n extents.z = this._attachments.maxDepth + Frustum2d.minimumZDistance;\r\n\r\n return extents;\r\n }\r\n\r\n /** Disclose *all* TileTrees currently in use by this view. This set may include trees not reported by [[forEachTileTreeRef]] - e.g., those used by view attachments, map-draped terrain, etc.\r\n * @internal override\r\n */\r\n public override discloseTileTrees(trees: DisclosedTileTreeSet): void {\r\n super.discloseTileTrees(trees);\r\n if (this._attachments)\r\n trees.disclose(this._attachments);\r\n }\r\n\r\n /** @internal */\r\n public override collectNonTileTreeStatistics(stats: RenderMemory.Statistics): void {\r\n super.collectNonTileTreeStatistics(stats);\r\n if (this._attachments)\r\n this._attachments.collectStatistics(stats);\r\n }\r\n\r\n /** @internal */\r\n public override get defaultExtentLimits() {\r\n return { min: Constant.oneMillimeter, max: this.sheetSize.magnitude() * 10 };\r\n }\r\n\r\n /** @internal */\r\n public override getViewedExtents(): AxisAlignedBox3d {\r\n return this._viewedExtents;\r\n }\r\n\r\n /** @internal */\r\n protected override preload(hydrateRequest: HydrateViewStateRequestProps): void {\r\n super.preload(hydrateRequest);\r\n this._attachmentsInfo.preload(hydrateRequest);\r\n }\r\n\r\n /** @internal */\r\n protected override async postload(hydrateResponse: HydrateViewStateResponseProps): Promise<void> {\r\n const promises = [];\r\n promises.push(super.postload(hydrateResponse));\r\n promises.push(this._attachmentsInfo.postload(hydrateResponse, this.iModel));\r\n await Promise.all(promises);\r\n }\r\n\r\n /** @internal */\r\n public override createScene(context: SceneContext): void {\r\n super.createScene(context);\r\n if (this._attachments)\r\n this._attachments.addToScene(context);\r\n }\r\n\r\n /** @internal */\r\n public override get secondaryViewports(): Iterable<Viewport> {\r\n const attachments = this._attachments;\r\n if (!attachments)\r\n return super.secondaryViewports;\r\n\r\n function* iterator() {\r\n for (const attachment of attachments!) {\r\n const vp = attachment.viewport;\r\n if (vp)\r\n yield vp;\r\n }\r\n }\r\n\r\n return {\r\n [Symbol.iterator]: () => iterator(),\r\n };\r\n }\r\n\r\n /** @internal */\r\n private async queryAttachmentIds(): Promise<Id64Array> {\r\n const ecsql = `SELECT ECInstanceId as attachmentId FROM bis.ViewAttachment WHERE model.Id=${this.baseModelId}`;\r\n const ids: string[] = [];\r\n for await (const row of this.iModel.createQueryReader(ecsql))\r\n ids.push(row[0]);\r\n\r\n return ids;\r\n }\r\n\r\n /** @internal */\r\n public override async changeViewedModel(modelId: Id64String): Promise<void> {\r\n await super.changeViewedModel(modelId);\r\n const attachmentIds = await this.queryAttachmentIds();\r\n this._attachmentsInfo = ViewAttachmentsInfo.fromJSON(attachmentIds);\r\n\r\n assert(undefined === this._attachments);\r\n }\r\n\r\n /** @internal */\r\n public override attachToViewport(args: AttachToViewportArgs): void {\r\n super.attachToViewport(args);\r\n assert(undefined === this._attachments);\r\n this._attachments = this._attachmentsInfo.createAttachments(this);\r\n }\r\n\r\n /** @internal */\r\n public override detachFromViewport(): void {\r\n super.detachFromViewport();\r\n this._attachments = dispose(this._attachments);\r\n }\r\n\r\n /** @internal */\r\n public override get areAllTileTreesLoaded(): boolean {\r\n return super.areAllTileTreesLoaded && (!this._attachments || this._attachments.areAllTileTreesLoaded);\r\n }\r\n\r\n /** Create a sheet border decoration graphic. */\r\n private createBorder(width: number, height: number, context: DecorateContext): RenderGraphic {\r\n const border = SheetBorder.create(width, height, context);\r\n const builder = context.createGraphicBuilder(GraphicType.ViewBackground);\r\n border.addToBuilder(builder);\r\n return builder.finish();\r\n }\r\n\r\n /** @internal */\r\n public override decorate(context: DecorateContext): void {\r\n super.decorate(context);\r\n if (this.sheetSize !== undefined) {\r\n const border = this.createBorder(this.sheetSize.x, this.sheetSize.y, context);\r\n context.setViewBackground(border);\r\n }\r\n }\r\n\r\n /** @internal */\r\n public override computeFitRange(): Range3d {\r\n const size = this.sheetSize;\r\n if (0 >= size.x || 0 >= size.y)\r\n return super.computeFitRange();\r\n return new Range3d(0, 0, -1, size.x, size.y, 1);\r\n }\r\n}\r\n\r\n/** A mostly no-op RenderTarget for an Attachment.\r\n * its Scene and symbology overrides.\r\n */\r\nclass AttachmentTarget extends MockRender.OffScreenTarget {\r\n private readonly _attachment: OrthographicAttachment;\r\n\r\n public constructor(attachment: OrthographicAttachment) {\r\n // The dimensions don't matter - we're not drawing anything.\r\n const rect = new ViewRect(1, 1);\r\n super(IModelApp.renderSystem, rect);\r\n this._attachment = attachment;\r\n }\r\n\r\n public override changeScene(scene: Scene): void {\r\n this._attachment.scene = scene;\r\n }\r\n\r\n public override overrideFeatureSymbology(ovrs: FeatureSymbology.Overrides): void {\r\n this._attachment.symbologyOverrides = ovrs;\r\n }\r\n}\r\n\r\n/** Draws the contents of a view attachment into a sheet view. */\r\ninterface Attachment {\r\n readonly areAllTileTreesLoaded: boolean;\r\n addToScene: (context: SceneContext) => void;\r\n discloseTileTrees: (trees: DisclosedTileTreeSet) => void;\r\n readonly zDepth: number;\r\n collectStatistics: (stats: RenderMemory.Statistics) => void;\r\n viewAttachmentProps: ViewAttachmentProps;\r\n dispose(): void;\r\n readonly viewport?: Viewport;\r\n}\r\n\r\n/** Draws the contents a 2d or orthographic 3d view directly into a sheet view.\r\n * We select tiles for the view in the context of a light-weight offscreen viewport with a no-op RenderTarget, then\r\n * collect the resultant graphics and add them to the sheet view's scene.\r\n */\r\nclass OrthographicAttachment {\r\n private readonly _viewport: OffScreenViewport;\r\n private readonly _props: ViewAttachmentProps;\r\n private readonly _sheetModelId: Id64String;\r\n private readonly _viewFlagOverrides: ViewFlagOverrides;\r\n private readonly _toSheet: Transform;\r\n private readonly _fromSheet: Transform;\r\n private readonly _sizeInMeters: Point2d;\r\n private readonly _range: Range3d;\r\n private readonly _viewRect = new ViewRect(0, 0, 1, 1);\r\n private readonly _originalFrustum = new Frustum();\r\n private readonly _clipVolume?: RenderClipVolume;\r\n private readonly _hiddenLineSettings?: HiddenLine.Settings;\r\n private readonly _scale: { x: number, y: number };\r\n private _debugFeatureTable?: PackedFeatureTable;\r\n public scene?: Scene;\r\n public symbologyOverrides: FeatureSymbology.Overrides;\r\n public readonly zDepth: number;\r\n\r\n public get view(): ViewState {\r\n return this._viewport.view;\r\n }\r\n\r\n public get viewAttachmentProps() {\r\n return this._props;\r\n }\r\n\r\n public get viewport(): Viewport {\r\n return this._viewport;\r\n }\r\n\r\n public constructor(view: ViewState, props: ViewAttachmentProps, sheetView: SheetViewState) {\r\n this.symbologyOverrides = new FeatureSymbology.Overrides(view);\r\n const target = new AttachmentTarget(this);\r\n this._viewport = OffScreenViewport.createViewport(view, target, true);\r\n\r\n this._props = props;\r\n this._sheetModelId = sheetView.baseModelId;\r\n\r\n const applyClip = true; // set to false for debugging\r\n this._viewFlagOverrides = {\r\n ...view.viewFlags,\r\n clipVolume: applyClip,\r\n lighting: false,\r\n shadows: false,\r\n };\r\n\r\n const placement = Placement2d.fromJSON(props.placement);\r\n const range = placement.calculateRange();\r\n this._range = range;\r\n this._sizeInMeters = new Point2d(range.xLength(), range.yLength());\r\n\r\n // Compute transform from attached view's world coordinates to sheet's world coordinates.\r\n // NB: We obtain the extents and origin from the *viewport* not the *view* - they may have been adjusted by the viewport.\r\n const applySkew = true; // set to false for debugging\r\n const skew = applySkew ? view.getAspectRatioSkew() : 1;\r\n const extents = this._viewport.viewingSpace.viewDelta.clone();\r\n const zDepth = Math.abs(extents.z);\r\n const scaleX = this._sizeInMeters.x / Math.abs(extents.x);\r\n const scaleY = skew * this._sizeInMeters.y / Math.abs(extents.y);\r\n this._scale = { x: 1 / scaleX, y: 1 / scaleY };\r\n\r\n const zBias = Frustum2d.depthFromDisplayPriority(props.jsonProperties?.displayPriority ?? 0);\r\n this.zDepth = 1.01 * (zDepth - zBias); // give a little padding so that geometry right up against far plane doesn't get clipped.\r\n\r\n // View origin is at the *back* of the view. Align *front* of view based on display priority.\r\n const viewRot = view.getRotation();\r\n const viewOrg = viewRot.multiplyVector(this._viewport.viewingSpace.viewOrigin);\r\n viewOrg.z += zDepth;\r\n viewRot.multiplyTransposeVectorInPlace(viewOrg);\r\n\r\n const matrix = Matrix3d.createScale(scaleX, scaleY, 1);\r\n matrix.multiplyMatrixMatrix(viewRot, matrix);\r\n const origin = Matrix3d.xyzMinusMatrixTimesXYZ(viewOrg, matrix, viewOrg);\r\n const attachmentOrigin = Point3d.createFrom(placement.origin);\r\n attachmentOrigin.z = zBias;\r\n const viewOrgToAttachment = attachmentOrigin.minus(viewOrg);\r\n origin.addInPlace(viewOrgToAttachment);\r\n this._toSheet = Transform.createRefs(origin, matrix);\r\n this._fromSheet = this._toSheet.inverse()!;\r\n\r\n // If the attached view is a section drawing, it may itself have an attached spatial view with a clip.\r\n // The clip needs to be transformed into sheet space.\r\n if (view.isDrawingView())\r\n this._viewport.drawingToSheetTransform = this._toSheet;\r\n\r\n // ###TODO? If we also apply the attachment's clip to the attached view, we may get additional culling during tile selection.\r\n // However the attached view's frustum is already clipped by intersection with sheet view's frustum, and additional clipping planes\r\n // introduce additional computation, so possibly not worth it.\r\n\r\n // Transform the view's clip (if any) to sheet space\r\n let viewClip = view.viewFlags.clipVolume ? view.getViewClip()?.clone() : undefined;\r\n if (viewClip)\r\n viewClip.transformInPlace(this._toSheet);\r\n else\r\n viewClip = ClipVector.createEmpty();\r\n\r\n let sheetClip;\r\n if (undefined !== props.jsonProperties?.clip)\r\n sheetClip = ClipVector.fromJSON(props.jsonProperties?.clip);\r\n\r\n if (sheetClip && sheetClip.isValid) {\r\n // Clip to view attachment's clip. NB: clip is in sheet coordinate space.\r\n for (const clip of sheetClip.clips)\r\n viewClip.clips.push(clip);\r\n } else {\r\n // Clip to view attachment's bounding box\r\n viewClip.appendShape([\r\n Point3d.create(this._range.low.x, this._range.low.y),\r\n Point3d.create(this._range.high.x, this._range.low.y),\r\n Point3d.create(this._range.high.x, this._range.high.y),\r\n Point3d.create(this._range.low.x, this._range.high.y),\r\n ]);\r\n }\r\n\r\n this._clipVolume = IModelApp.renderSystem.createClipVolume(viewClip);\r\n\r\n // Save off the original frustum (potentially adjusted by viewport).\r\n this._viewport.setupFromView();\r\n this._viewport.viewingSpace.getFrustum(CoordSystem.World, true, this._originalFrustum);\r\n\r\n const applyHiddenLineSettings = true; // for debugging edge display, set to false...\r\n const style = view.displayStyle;\r\n if (style.is3d() && applyHiddenLineSettings)\r\n this._hiddenLineSettings = style.settings.hiddenLineSettings;\r\n }\r\n\r\n public dispose(): void {\r\n this._viewport.dispose();\r\n }\r\n\r\n public discloseTileTrees(trees: DisclosedTileTreeSet): void {\r\n trees.disclose(this._viewport);\r\n }\r\n\r\n public addToScene(context: SceneContext): void {\r\n if (context.viewport.freezeScene)\r\n return;\r\n\r\n if (!context.viewport.view.viewsCategory(this._props.category))\r\n return;\r\n\r\n const wantBounds = context.viewport.wantViewAttachmentBoundaries;\r\n const wantClipShapes = context.viewport.wantViewAttachmentClipShapes;\r\n if (wantBounds || wantClipShapes) {\r\n const builder = context.createSceneGraphicBuilder();\r\n if (wantBounds) {\r\n builder.setSymbology(ColorDef.red, ColorDef.red, 2);\r\n builder.addRangeBox(this._range);\r\n }\r\n\r\n if (wantClipShapes && this._clipVolume) {\r\n builder.setSymbology(ColorDef.blue, ColorDef.blue, 2);\r\n for (const prim of this._clipVolume.clipVector.clips) {\r\n if (!(prim instanceof ClipShape))\r\n continue; // ###TODO handle non-shape primitives, if any such ever encountered\r\n\r\n const pts = [];\r\n const tf = prim.transformFromClip;\r\n for (const pt of prim.polygon) {\r\n const tfPt = tf ? tf.multiplyPoint3d(pt) : pt;\r\n pts.push(new Point2d(tfPt.x, tfPt.y));\r\n }\r\n\r\n builder.addLineString2d(pts, 0);\r\n }\r\n }\r\n\r\n // Put into a Batch so that we can see tooltip with attachment Id on mouseover.\r\n const batch = context.target.renderSystem.createBatch(builder.finish(), this.getDebugFeatureTable(), this._range);\r\n context.outputGraphic(batch);\r\n }\r\n\r\n if (!context.viewport.wantViewAttachments)\r\n return;\r\n\r\n // Pixel size used to compute size of ViewRect so that tiles of appropriate LOD are selected.\r\n const pixelSize = context.viewport.getPixelSizeAtPoint();\r\n if (0 === pixelSize)\r\n return;\r\n\r\n // Adjust attached view frustum based on intersection with sheet view frustum.\r\n const attachFrustum = this._originalFrustum.transformBy(this._toSheet);\r\n const attachFrustumRange = attachFrustum.toRange();\r\n const sheetFrustum = context.viewport.getWorldFrustum();\r\n const sheetFrustumRange = sheetFrustum.toRange();\r\n const intersect = attachFrustumRange.intersect(sheetFrustumRange);\r\n if (intersect.isNull)\r\n return;\r\n\r\n attachFrustum.initFromRange(intersect);\r\n attachFrustum.transformBy(this._fromSheet, attachFrustum);\r\n this._viewport.setupViewFromFrustum(attachFrustum);\r\n\r\n // Adjust view rect based on size of attachment on screen so that tiles of appropriate LOD are selected.\r\n const width = this._sizeInMeters.x * intersect.xLength() / attachFrustumRange.xLength();\r\n const height = this._sizeInMeters.y * intersect.yLength() / attachFrustumRange.yLength();\r\n this._viewRect.width = Math.max(1, Math.round(width / pixelSize));\r\n this._viewRect.height = Math.max(1, Math.round(height / pixelSize));\r\n this._viewport.setRect(this._viewRect);\r\n\r\n // Propagate settings from on-screen viewport.\r\n this._viewport.debugBoundingBoxes = context.viewport.debugBoundingBoxes;\r\n this._viewport.setTileSizeModifier(context.viewport.tileSizeModifier);\r\n\r\n // Create the scene.\r\n this._viewport.renderFrame();\r\n\r\n const scene = this.scene;\r\n if (!scene)\r\n return;\r\n\r\n // Extract scene graphics and insert into on-screen scene context.\r\n const options = {\r\n clipVolume: this._clipVolume,\r\n hline: this._hiddenLineSettings,\r\n frustum: {\r\n is3d: this.view.is3d(),\r\n scale: this._scale,\r\n },\r\n };\r\n\r\n const outputGraphics = (source: RenderGraphic[]) => {\r\n if (0 === source.length)\r\n return;\r\n\r\n const graphics = new GraphicBranch();\r\n graphics.setViewFlagOverrides(this._viewFlagOverrides);\r\n graphics.symbologyOverrides = this.symbologyOverrides;\r\n\r\n for (const graphic of source)\r\n graphics.entries.push(graphic);\r\n\r\n const branch = context.createGraphicBranch(graphics, this._toSheet, options);\r\n context.outputGraphic(branch);\r\n };\r\n\r\n outputGraphics(scene.foreground);\r\n context.withGraphicType(TileGraphicType.BackgroundMap, () => outputGraphics(scene.background));\r\n context.withGraphicType(TileGraphicType.Overlay, () => outputGraphics(scene.overlay));\r\n\r\n // Report tile statistics to sheet view's viewport.\r\n const tileAdmin = IModelApp.tileAdmin;\r\n const selectedAndReady = tileAdmin.getTilesForUser(this._viewport);\r\n const requested = tileAdmin.getRequestsForUser(this._viewport);\r\n tileAdmin.addExternalTilesForUser(context.viewport, {\r\n requested: requested?.size ?? 0,\r\n selected: selectedAndReady?.selected.size ?? 0,\r\n ready: selectedAndReady?.ready.size ?? 0,\r\n });\r\n }\r\n\r\n private getDebugFeatureTable(): PackedFeatureTable {\r\n if (this._debugFeatureTable)\r\n return this._debugFeatureTable;\r\n\r\n const featureTable = new FeatureTable(1, this._sheetModelId);\r\n featureTable.insert(new Feature(this._props.id));\r\n this._debugFeatureTable = PackedFeatureTable.pack(featureTable);\r\n return this._debugFeatureTable;\r\n }\r\n\r\n public get areAllTileTreesLoaded(): boolean {\r\n return this.view.areAllTileTreesLoaded;\r\n }\r\n\r\n public collectStatistics(_stats: RenderMemory.Statistics): void {\r\n // Handled by discloseTileTrees()\r\n }\r\n}\r\n\r\nfunction createRasterAttachmentViewport(_view: ViewState, _rect: ViewRect, _attachment: RasterAttachment): OffScreenViewport {\r\n class RasterAttachmentViewport extends OffScreenViewport {\r\n private _sceneContext?: SceneContext;\r\n private _isSceneReady = false;\r\n private readonly _attachment: RasterAttachment;\r\n\r\n public constructor(view: ViewState, rect: ViewRect, attachment: RasterAttachment) {\r\n super(IModelApp.renderSystem.createOffscreenTarget(rect));\r\n this._attachment = attachment;\r\n this._isAspectRatioLocked = true;\r\n this.changeView(view);\r\n }\r\n\r\n public override createSceneContext(): SceneContext {\r\n assert(!this._isSceneReady);\r\n\r\n this._sceneContext = super.createSceneContext();\r\n return this._sceneContext;\r\n }\r\n\r\n public override renderFrame(): void {\r\n assert(!this._isSceneReady);\r\n\r\n this.clearSceneContext();\r\n super.renderFrame();\r\n\r\n if (undefined !== this._sceneContext) {\r\n this._isSceneReady = !this._sceneContext.hasMissingTiles && this.view.areAllTileTreesLoaded;\r\n if (this._isSceneReady)\r\n this._attachment.produceGraphics(this._sceneContext);\r\n\r\n this._sceneContext = undefined;\r\n }\r\n }\r\n\r\n private clearSceneContext(): void {\r\n this._sceneContext = undefined;\r\n }\r\n\r\n public override addDecorations(_decorations: Decorations): void {\r\n // ###TODO: skybox, ground plane, possibly grid. DecorateContext requires a ScreenViewport...\r\n }\r\n }\r\n\r\n return new RasterAttachmentViewport(_view, _rect, _attachment);\r\n}\r\n\r\n/** Draws a 3d view with camera enabled into a sheet view by producing an image of the view's contents offscreen. */\r\nclass RasterAttachment {\r\n private readonly _props: ViewAttachmentProps;\r\n private readonly _placement: Placement2d;\r\n private readonly _transform: Transform;\r\n public readonly zDepth: number;\r\n private _viewport?: OffScreenViewport;\r\n private _graphics?: RenderGraphic;\r\n\r\n public constructor(view: ViewState, props: ViewAttachmentProps, sheetView: SheetViewState) {\r\n // Render to a 2048x2048 view rect. Scale in Y to preserve aspect ratio.\r\n const maxSize = 2048;\r\n const rect = new ViewRect(0, 0, maxSize, maxSize);\r\n const height = maxSize * view.getAspectRatio() * view.getAspectRatioSkew();\r\n const skew = maxSize / height;\r\n view.setAspectRatioSkew(skew);\r\n\r\n if (true !== props.jsonProperties?.displayOptions?.preserveBackground) {\r\n // Make background color 100% transparent so that Viewport.readImageBuffer() will discard transparent pixels.\r\n const bgColor = sheetView.displayStyle.backgroundColor.withAlpha(0);\r\n view.displayStyle.backgroundColor = bgColor;\r\n }\r\n\r\n this._viewport = createRasterAttachmentViewport(view, rect, this);\r\n this._props = props;\r\n this._placement = Placement2d.fromJSON(props.placement);\r\n this._transform = this._placement.transform;\r\n this.zDepth = Frustum2d.depthFromDisplayPriority(props.jsonProperties?.displayPriority ?? 0);\r\n }\r\n\r\n public dispose(): void {\r\n this._viewport?.dispose();\r\n }\r\n\r\n public get viewAttachmentProps() {\r\n return this._props;\r\n }\r\n\r\n public get viewport(): Viewport | undefined {\r\n return this._viewport;\r\n }\r\n\r\n public get areAllTileTreesLoaded() {\r\n return this._viewport?.areAllTileTreesLoaded ?? true;\r\n }\r\n\r\n public addToScene(context: SceneContext): void {\r\n // ###TODO: check viewport.wantViewAttachmentClipShapes\r\n if (!context.viewport.view.viewsCategory(this._props.category))\r\n return;\r\n\r\n if (context.viewport.wantViewAttachmentBoundaries) {\r\n const builder = context.createSceneGraphicBuilder(this._transform);\r\n builder.setSymbology(ColorDef.red, ColorDef.red, 2);\r\n builder.addRangeBox(Range3d.createRange2d(this._placement.bbox));\r\n context.outputGraphic(builder.finish());\r\n }\r\n\r\n if (!context.viewport.wantViewAttachments)\r\n return;\r\n\r\n if (this._graphics) {\r\n context.outputGraphic(this._graphics);\r\n return;\r\n }\r\n\r\n if (undefined === this._viewport)\r\n return;\r\n\r\n this._viewport.debugBoundingBoxes = context.viewport.debugBoundingBoxes;\r\n this._viewport.setTileSizeModifier(context.viewport.tileSizeModifier);\r\n\r\n this._viewport.renderFrame();\r\n if (this._graphics)\r\n context.outputGraphic(this._graphics);\r\n }\r\n\r\n public discloseTileTrees(trees: DisclosedTileTreeSet) {\r\n if (this._viewport)\r\n trees.disclose(this._viewport);\r\n }\r\n\r\n public produceGraphics(context: SceneContext): void {\r\n assert(context.viewport === this._viewport);\r\n this._graphics = this.createGraphics(this._viewport);\r\n this._viewport = dispose(this._viewport);\r\n\r\n if (undefined !== this._graphics)\r\n context.outputGraphic(this._graphics);\r\n }\r\n\r\n private createGraphics(vp: Viewport): RenderGraphic | undefined {\r\n // Create a texture from the contents of the view.\r\n const image = vp.readImageBuffer({ upsideDown: true });\r\n if (undefined === image)\r\n return undefined;\r\n\r\n const debugImage = false; // set to true to open a window displaying the captured image.\r\n if (debugImage) {\r\n const url = imageBufferToPngDataUrl(image, false);\r\n if (url)\r\n openImageDataUrlInNewWindow(url, \"Attachment\");\r\n }\r\n\r\n const texture = IModelApp.renderSystem.createTexture({\r\n image: { source: image, transparency: TextureTransparency.Opaque },\r\n });\r\n if (!texture)\r\n return undefined;\r\n\r\n // Create a material for the texture\r\n const graphicParams = new GraphicParams();\r\n graphicParams.material = IModelApp.renderSystem.createRenderMaterial({ textureMapping: { texture } });\r\n\r\n // Apply the texture to a rectangular polyface.\r\n const depth = this.zDepth;\r\n const east = this._placement.bbox.low.x;\r\n const west = this._placement.bbox.high.x;\r\n const north = this._placement.bbox.low.y;\r\n const south = this._placement.bbox.high.y;\r\n const corners = [\r\n Point3d.create(east, north, depth),\r\n Point3d.create(west, north, depth),\r\n Point3d.create(west, south, depth),\r\n Point3d.create(east, south, depth),\r\n ];\r\n const params = [\r\n Point2d.create(0, 0),\r\n Point2d.create(1, 0),\r\n Point2d.create(1, 1),\r\n Point2d.create(0, 1),\r\n ];\r\n\r\n const strokeOptions = new StrokeOptions();\r\n strokeOptions.needParams = strokeOptions.shouldTriangulate = true;\r\n const polyfaceBuilder = PolyfaceBuilder.create(strokeOptions);\r\n polyfaceBuilder.addQuadFacet(corners, params);\r\n const polyface = polyfaceBuilder.claimPolyface();\r\n\r\n const graphicBuilder = IModelApp.renderSystem.createGraphicBuilder(Transform.createIdentity(), GraphicType.Scene, vp, this._props.id);\r\n graphicBuilder.activateGraphicParams(graphicParams);\r\n graphicBuilder.addPolyface(polyface, false);\r\n const graphic = graphicBuilder.finish();\r\n\r\n // Wrap the polyface in a GraphicBranch.\r\n const branch = new GraphicBranch(true);\r\n const vfOvrs = createDefaultViewFlagOverrides({ clipVolume: true, shadows: false, lighting: false, thematic: false });\r\n\r\n // Disable transparency - background pixels are 100% transparent so they will be discarded anyway. Other pixels are 100% opaque.\r\n vfOvrs.transparency = false;\r\n branch.setViewFlagOverrides(vfOvrs);\r\n branch.symbologyOverrides = new FeatureSymbology.Overrides();\r\n branch.entries.push(graphic);\r\n\r\n // Apply the attachment's clip, if any.\r\n let clipVolume;\r\n if (this._props.jsonProperties?.clip) {\r\n const clipVector = ClipVector.fromJSON(this._props.jsonProperties?.clip);\r\n if (clipVector.isValid)\r\n clipVolume = IModelApp.renderSystem.createClipVolume(clipVector);\r\n }\r\n\r\n return IModelApp.renderSystem.createGraphicBranch(branch, this._transform, { clipVolume });\r\n }\r\n\r\n public collectStatistics(stats: RenderMemory.Statistics): void {\r\n if (this._graphics)\r\n this._graphics.collectStatistics(stats);\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ViewCreator2d.d.ts","sourceRoot":"","sources":["../../src/ViewCreator2d.ts"],"names":[],"mappings":"AAKA;;GAEG;AAOH,OAAO,EAAa,UAAU,EAAgB,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EACwB,QAAQ,EAEtC,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD,OAAO,EAAE,SAAS,EAAe,MAAM,aAAa,CAAC;AAErD;;;EAGE;AACF,MAAM,WAAW,oBAAoB;IACnC,4GAA4G;IAC5G,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uDAAuD;IACvD,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,uKAAuK;IACvK,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,aAAa;I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CAAC,OAAO;IAP3B,OAAO,CAAC,MAAM,CAAC,oBAAoB,CAA6E;IAChH,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAmC;IAEpE;;;OAGG;gBACiB,OAAO,EAAE,gBAAgB;IAE7C;;;;;OAKG;IACU,kBAAkB,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,SAAS,CAAC;IAYxG;;;;OAIG;YACW,sBAAsB;IAiBpC;;;;;;OAMG;YACW,kBAAkB;IAehC;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAO5B;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAO1B;;;;OAIG;IACH,OAAO,CAAC,qBAAqB,CA8E3B;IAEF;;;;OAIG;YACW,kBAAkB;IAsBhC;;;;QAII;YACU,cAAc;IAuB5B;;;OAGG;YACW,6BAA6B;IAQ3C;;OAEG;YACW,iBAAiB;IAQ/B;;;OAGG;YACW,oBAAoB;IAQlC;;;OAGG;IACH,OAAO,CAAC,aAAa,CAMnB;CACH"}
@@ -118,8 +118,7 @@ class ViewCreator2d {
118
118
  */
119
119
  this._executeQuery = async (query) => {
120
120
  const rows = [];
121
- // eslint-disable-next-line deprecation/deprecation
122
- for await (const row of this._imodel.query(query, undefined, { rowFormat: core_common_1.QueryRowFormat.UseJsPropertyNames }))
121
+ for await (const row of this._imodel.createQueryReader(query, undefined, { rowFormat: core_common_1.QueryRowFormat.UseJsPropertyNames }))
123
122
  rows.push(row.id);
124
123
  return rows;
125
124
  };
@@ -207,8 +206,7 @@ class ViewCreator2d {
207
206
  async _addSheetViewProps(modelId, props) {
208
207
  let width = 0;
209
208
  let height = 0;
210
- // eslint-disable-next-line deprecation/deprecation
211
- for await (const row of this._imodel.query(`SELECT Width, Height FROM bis.Sheet WHERE ECInstanceId = ?`, core_common_1.QueryBinder.from([modelId]), { rowFormat: core_common_1.QueryRowFormat.UseJsPropertyNames })) {
209
+ for await (const row of this._imodel.createQueryReader(`SELECT Width, Height FROM bis.Sheet WHERE ECInstanceId = ?`, core_common_1.QueryBinder.from([modelId]), { rowFormat: core_common_1.QueryRowFormat.UseJsPropertyNames })) {
212
210
  width = row.width;
213
211
  height = row.height;
214
212
  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,sDAA0E;AAC1E,oDAG4B;AAC5B,wDAA+C;AAC/C,yDAAsD;AAGtD,6CAA4F;AAC5F,qDAAkD;AAgBlD;;;;;;;;;;;GAWG;AACH,MAAa,aAAa;IAMxB;;;OAGG;IACH,YAAoB,OAAyB;QAAzB,YAAO,GAAP,OAAO,CAAkB;QAsF7C;;;;WAIG;QACK,0BAAqB,GAAG,KAAK,EAAE,OAAmB,EAAE,OAA8B,EAA2B,EAAE;YACrH,oCAAoC;YACpC,MAAM,YAAY,GAAG,oBAAM,CAAC,YAAY,CAAC;YACzC,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAElD,gDAAgD;YAChD,MAAM,OAAO,GAAa,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,sBAAQ,CAAC,KAAK,CAAC;YAE9E,gBAAgB;YAChB,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;YACnE,MAAM,YAAY,GAAG,uBAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;YAC9D,IAAI,OAAO,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;YACjC,IAAI,OAAO,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;YACjC,IAAI,MAAM,GAAG,YAAY,CAAC,OAAO,EAAE,CAAC;YACpC,I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G,MAAM,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAE1D,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,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;;AA5QD,sCAAsC;AACvB,kCAAoB,GAAG,CAAC,8BAAiB,CAAC,aAAa,EAAE,qCAAwB,CAAC,aAAa,CAAC,AAA5E,CAA6E;AACjG,gCAAkB,GAAG,CAAC,4BAAe,CAAC,aAAa,CAAC,AAAlC,CAAmC;AAJzD,sCAAa","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 * @extensions\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 * @extensions\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.queryExtents(modelId);\r\n const modelExtents = Range3d.fromJSON(modelProps[0]?.extents);\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:DisplayStyle2d\",\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 // eslint-disable-next-line deprecation/deprecation\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 // eslint-disable-next-line deprecation/deprecation\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"]}
1
+ {"version":3,"file":"ViewCreator2d.js","sourceRoot":"","sources":["../../src/ViewCreator2d.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH;;;EAGE;AAEF,sDAA0E;AAC1E,oDAG4B;AAC5B,wDAA+C;AAC/C,yDAAsD;AAGtD,6CAA4F;AAC5F,qDAAkD;AAgBlD;;;;;;;;;;;GAWG;AACH,MAAa,aAAa;IAMxB;;;OAGG;IACH,YAAoB,OAAyB;QAAzB,YAAO,GAAP,OAAO,CAAkB;QAsF7C;;;;WAIG;QACK,0BAAqB,GAAG,KAAK,EAAE,OAAmB,EAAE,OAA8B,EAA2B,EAAE;YACrH,oCAAoC;YACpC,MAAM,YAAY,GAAG,oBAAM,CAAC,YAAY,CAAC;YACzC,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAElD,gDAAgD;YAChD,MAAM,OAAO,GAAa,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,sBAAQ,CAAC,KAAK,CAAC;YAE9E,gBAAgB;YAChB,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;YACnE,MAAM,YAAY,GAAG,uBAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;YAC9D,IAAI,OAAO,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;YACjC,IAAI,OAAO,GAAG,YAAY,CA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AAK,GAAG,sEAAsE,OAAO,gCAAgC,CAAC;QAC5H,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAE1D,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,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,8BAAiB,CAAC,aAAa,EAAE,qCAAwB,CAAC,aAAa,CAAC,AAA5E,CAA6E;AACjG,gCAAkB,GAAG,CAAC,4BAAe,CAAC,aAAa,CAAC,AAAlC,CAAmC;AAJzD,sCAAa","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 * @extensions\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 * @extensions\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.queryExtents(modelId);\r\n const modelExtents = Range3d.fromJSON(modelProps[0]?.extents);\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:DisplayStyle2d\",\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.createQueryReader(`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.createQueryReader(query, undefined, { rowFormat: QueryRowFormat.UseJsPropertyNames }))\r\n rows.push(row.id);\r\n\r\n return rows;\r\n };\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ViewCreator3d.d.ts","sourceRoot":"","sources":["../../src/ViewCreator3d.ts"],"names":[],"mappings":"AAKA;;GAEG;AAOH,OAAO,EAAgC,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAM/E,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC;;;EAGE;AACF,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,mDAAmD;IACnD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,8DAA8D;IAC9D,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;;;OAOG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAED;;;;;;;;;GASG;AACH,qBAAa,aAAa;IAKZ,OAAO,CAAC,OAAO;IAJ3B;;;OAGG;gBACiB,OAAO,EAAE,gBAAgB;IAE7C;;;;;OAKG;IACU,iBAAiB,CAAC,OAAO,CAAC,EAAE,oBAAoB,EAAE,QAAQ,CAAC,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC;IA2B3G;;;;OAIG;YACW,qBAAqB;IAkGnC;;;OAGG;YACW,cAAc;IAwB5B;;OAEG;YACW,iBAAiB;IAwB/B;;OAEG;IACH,OAAO,CAAC,aAAa,CAOnB;CACH"}
1
+ {"version":3,"file":"ViewCreator3d.d.ts","sourceRoot":"","sources":["../../src/ViewCreator3d.ts"],"names":[],"mappings":"AAKA;;GAEG;AAOH,OAAO,EAAgC,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAM/E,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC;;;EAGE;AACF,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,mDAAmD;IACnD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,8DAA8D;IAC9D,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;;;OAOG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAED;;;;;;;;;GASG;AACH,qBAAa,aAAa;IAKZ,OAAO,CAAC,OAAO;IAJ3B;;;OAGG;gBACiB,OAAO,EAAE,gBAAgB;IAE7C;;;;;OAKG;IACU,iBAAiB,CAAC,OAAO,CAAC,EAAE,oBAAoB,EAAE,QAAQ,CAAC,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC;IA2B3G;;;;OAIG;YACW,qBAAqB;IAkGnC;;;OAGG;YACW,cAAc;IAwB5B;;OAEG;YACW,iBAAiB;IAwB/B;;OAEG;IACH,OAAO,CAAC,aAAa,CAMnB;CACH"}
@@ -38,8 +38,7 @@ class ViewCreator3d {
38
38
  */
39
39
  this._executeQuery = async (query) => {
40
40
  const rows = [];
41
- // eslint-disable-next-line deprecation/deprecation
42
- for await (const row of this._imodel.query(query, undefined, { rowFormat: core_common_1.QueryRowFormat.UseJsPropertyNames }))
41
+ for await (const row of this._imodel.createQueryReader(query, undefined, { rowFormat: core_common_1.QueryRowFormat.UseJsPropertyNames }))
43
42
  rows.push(row.id);
44
43
  return rows;
45
44
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ViewCreator3d.js","sourceRoot":"","sources":["../../src/ViewCreator3d.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH;;;EAGE;AAEF,sDAA+E;AAC/E,oDAG4B;AAC5B,wDAA+C;AAI/C,yDAAsD;AAkCtD;;;;;;;;;GASG;AACH,MAAa,aAAa;IACxB;;;OAGG;IACH,YAAoB,OAAyB;QAAzB,YAAO,GAAP,OAAO,CAAkB;QAiM7C;;WAEG;QACK,kBAAa,GAAG,KAAK,EAAE,KAAa,EAAE,EAAE;YAC9C,MAAM,IAAI,GAAG,EAAE,CAAC;YAChB,mDAAmD;YACnD,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,4BAAc,CAAC,kBAAkB,EAAE,CAAC;gBAC5G,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAEpB,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;IA3M+C,CAAC;IAElD;;;;;OAKG;IACI,KAAK,CAAC,iBAAiB,CAAC,OAA8B,EAAE,QAAuB;QACpF,MAAM,eAAe,GAA2B,MAAM,oCAAsB,CAAC,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,wBAAwB,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,EACrL,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAC,QAAQ,EAAE,gCAAiB,CAAC,eAAe,CAAC,QAAQ,CA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CAAC;QACnC,MAAM,CAAC,IAAI,GAAG,mCAAgB,CAAC,aAAa,CAAC;QAC7C,MAAM,CAAC,KAAK,GAAG,gBAAgB,MAAM,EAAE,CAAC;QAExC,iCAAiC;QACjC,MAAM,SAAS,GAAG,MAAM,oCAAsB,CAAC,SAAS,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,MAAM,CAAC,CAAC;QACjH,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;YAC1B,oCAAoC;YACpC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC;YAC9E,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;gBACvB,OAAO,SAAS,CAAC;YAEnB,MAAM,eAAe,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAgC,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACrH,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC;gBAC9B,OAAO,SAAS,CAAC;YAEnB,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SAC9B;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CAaF;AAjND,sCAiNC","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 3D default view for an iModel.\r\nEither takes in a list of modelIds, or displays all 3D models by default.\r\n*/\r\n\r\nimport { CompressedId64Set, Id64Array, Id64String } from \"@itwin/core-bentley\";\r\nimport {\r\n Camera, CategorySelectorProps, Code, CustomViewState3dProps, DisplayStyle3dProps, Environment, IModel, IModelReadRpcInterface, ModelSelectorProps,\r\n QueryRowFormat, RenderMode, ViewDefinition3dProps, ViewQueryParams, ViewStateProps,\r\n} from \"@itwin/core-common\";\r\nimport { Range3d } from \"@itwin/core-geometry\";\r\nimport { StandardViewId } from \"./StandardView\";\r\nimport { IModelConnection } from \"./IModelConnection\";\r\nimport { ViewState } from \"./ViewState\";\r\nimport { SpatialViewState } from \"./SpatialViewState\";\r\n\r\n/** Options for creating a [[ViewState3d]] via [[ViewCreator3d]].\r\n * @public\r\n * @extensions\r\n*/\r\nexport interface ViewCreator3dOptions {\r\n /** Turn the [[Camera]] on to produce a perspective view.\r\n * Default: true\r\n */\r\n cameraOn?: boolean;\r\n /** Enables display of a [[SkyBox]] in the view. */\r\n skyboxOn?: boolean;\r\n /** Orients the view to one of the standard view rotations. */\r\n standardViewId?: StandardViewId;\r\n /** Merge in props from a persistent \"seed\" view obtained from the iModel.\r\n * @note The selection of the seed view is somewhat arbitrary, and the contents and styling of that view are unpredictable, so this option is not recommended.\r\n */\r\n useSeedView?: boolean;\r\n /** The desired aspect ratio of the [[Viewport]] in which the view is to be displayed.\r\n * This is used to adjust the view's frustum so that the viewed models are better centered within the viewport.\r\n */\r\n vpAspect?: number;\r\n /** Indicates that geometry belonging to every [SubCategory]($backend) should be visible within the view.\r\n * Each subcategory has a [SubCategoryAppearance]($common) that specifies how its geometry is displayed. This includes a [SubCategoryAppearance.invisible]($common) property that,\r\n * when set to `true`, indicates the geometry should not be displayed at all. A view can override the appearances of any subcategories using a [SubCategoryOverride]($common).\r\n * If `allSubCategoriesVisible` is `true`, [[ViewCreator3d]] will apply such an override to every viewed subcategory to change [SubCategoryOverride.invisible]($common) to `false`, making\r\n * every subcategory visible.\r\n * @note Subcategories are typically set to invisible by default for a reason.\r\n * Forcing them all to be visible may produce undesirable results, such as z-fighting between geometry on different subcategories that are not intended to be viewed together.\r\n */\r\n allSubCategoriesVisible?: boolean;\r\n}\r\n\r\n/**\r\n * API for creating a 3D default [[ViewState3d]] for an iModel. @see [[ViewCreator2d]] to create a view for a 2d model.\r\n * Example usage:\r\n * ```ts\r\n * const viewCreator = new ViewCreator3d(imodel);\r\n * const defaultView = await viewCreator.createDefaultView({skyboxOn: true});\r\n * ```\r\n * @public\r\n * @extensions\r\n */\r\nexport class ViewCreator3d {\r\n /**\r\n * Constructs a ViewCreator3d 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 a default [[ViewState3d]] based on the model ids passed in. If no model ids are passed in, all 3D models in the iModel are used.\r\n * @param [options] Options for creating the view.\r\n * @param [modelIds] Ids of models to display in the view.\r\n * @throws [IModelError]($common) If no 3d models are found in the iModel.\r\n */\r\n public async createDefaultView(options?: ViewCreator3dOptions, modelIds?: Id64String[]): Promise<ViewState> {\r\n const serializedProps: CustomViewState3dProps = await IModelReadRpcInterface.getClientForRouting(this._imodel.routingContext.token).getCustomViewState3dData(this._imodel.getRpcProps(),\r\n modelIds === undefined ? {} : {modelIds: CompressedId64Set.sortAndCompress(modelIds)});\r\n const props = await this._createViewStateProps(\r\n CompressedId64Set.decompressArray(serializedProps.modelIds),\r\n CompressedId64Set.decompressArray(serializedProps.categoryIds),\r\n Range3d.fromJSON(serializedProps.modelExtents),\r\n options);\r\n\r\n const viewState = SpatialViewState.createFromProps(props, this._imodel);\r\n try {\r\n await viewState.load();\r\n } catch {\r\n }\r\n\r\n if (options?.standardViewId)\r\n viewState.setStandardRotation(options.standardViewId);\r\n\r\n if (options?.allSubCategoriesVisible)\r\n viewState.displayStyle.enableAllLoadedSubCategories(viewState.categorySelector.categories);\r\n\r\n const range = viewState.computeFitRange();\r\n viewState.lookAtVolume(range, options?.vpAspect);\r\n\r\n return viewState;\r\n }\r\n\r\n /**\r\n * Generates a view state props object for creating a view. Merges display styles with a seed view if the options.useSeedView is true\r\n * @param models Models to put in view props\r\n * @param options view creation options like camera On and skybox On\r\n */\r\n private async _createViewStateProps(models: Id64Array, categories: Id64Array, modelExtents: Range3d, options?: ViewCreator3dOptions): Promise<ViewStateProps> {\r\n // Use dictionary model in all props\r\n const dictionaryId = IModel.dictionaryId;\r\n\r\n if (modelExtents.isNull)\r\n modelExtents.setFrom(this._imodel.projectExtents);\r\n\r\n let originX = modelExtents.low.x;\r\n let originY = modelExtents.low.y;\r\n const originZ = modelExtents.low.z;\r\n let deltaX = modelExtents.xLength();\r\n let deltaY = modelExtents.yLength();\r\n const deltaZ = modelExtents.zLength();\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 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 modelSelectorProps: ModelSelectorProps = {\r\n models,\r\n code: Code.createEmpty(),\r\n model: dictionaryId,\r\n classFullName: \"BisCore:ModelSelector\",\r\n };\r\n\r\n const cameraData = new Camera();\r\n const cameraOn = options?.cameraOn !== false;\r\n const viewDefinitionProps: ViewDefinition3dProps = {\r\n categorySelectorId: \"\",\r\n displayStyleId: \"\",\r\n code: Code.createEmpty(),\r\n model: dictionaryId,\r\n origin: { x: originX, y: originY, z: originZ },\r\n extents: { x: deltaX, y: deltaY, z: deltaZ },\r\n classFullName: \"BisCore:SpatialViewDefinition\",\r\n cameraOn,\r\n camera: {\r\n lens: cameraData.lens.toJSON(),\r\n focusDist: cameraData.focusDist,\r\n eye: cameraData.eye.toJSON(),\r\n },\r\n };\r\n\r\n const displayStyleProps: DisplayStyle3dProps = {\r\n code: Code.createEmpty(),\r\n model: dictionaryId,\r\n classFullName: \"BisCore:DisplayStyle3d\",\r\n jsonProperties: {\r\n styles: {\r\n viewflags: {\r\n renderMode: RenderMode.SmoothShade,\r\n noSourceLights: false,\r\n noCameraLights: false,\r\n noSolarLight: false,\r\n noConstruct: true,\r\n noTransp: false,\r\n visEdges: false,\r\n backgroundMap: this._imodel.isGeoLocated,\r\n },\r\n environment:\r\n options !== undefined &&\r\n options.skyboxOn !== undefined &&\r\n options.skyboxOn\r\n ? Environment.defaults.withDisplay({ sky: true }).toJSON()\r\n : undefined,\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 };\r\n\r\n // merge seed view props if needed\r\n return options?.useSeedView ? this._mergeSeedView(viewStateProps) : viewStateProps;\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 default 3D views in the iModel\r\n * @param viewStateProps Input view props to be merged\r\n */\r\n private async _mergeSeedView(viewStateProps: ViewStateProps): Promise<ViewStateProps> {\r\n const viewId = await this._getDefaultViewId();\r\n // Handle iModels without any default view id\r\n if (viewId === undefined)\r\n return viewStateProps;\r\n\r\n const seedViewState = (await this._imodel.views.load(viewId) as SpatialViewState);\r\n const seedViewStateProps = {\r\n categorySelectorProps: seedViewState.categorySelector.toJSON(),\r\n modelSelectorProps: seedViewState.modelSelector.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 ...viewStateProps.displayStyleProps.jsonProperties!.styles,\r\n };\r\n }\r\n\r\n return { ...seedViewStateProps, ...viewStateProps, displayStyleProps: mergedDisplayProps };\r\n }\r\n\r\n /**\r\n * Get ID of default view.\r\n */\r\n private async _getDefaultViewId(): Promise<Id64String | undefined> {\r\n const viewId = await this._imodel.views.queryDefaultViewId();\r\n const params: ViewQueryParams = {};\r\n params.from = SpatialViewState.classFullName;\r\n params.where = `ECInstanceId=${viewId}`;\r\n\r\n // Check validity of default view\r\n const viewProps = await IModelReadRpcInterface.getClient().queryElementProps(this._imodel.getRpcProps(), params);\r\n if (viewProps.length === 0) {\r\n // Return the first view we can find\r\n const viewList = await this._imodel.views.getViewList({ wantPrivate: false });\r\n if (viewList.length === 0)\r\n return undefined;\r\n\r\n const spatialViewList = viewList.filter((value: IModelConnection.ViewSpec) => value.class.indexOf(\"Spatial\") !== -1);\r\n if (spatialViewList.length === 0)\r\n return undefined;\r\n\r\n return spatialViewList[0].id;\r\n }\r\n\r\n return viewId;\r\n }\r\n\r\n /**\r\n * Helper function to execute ECSql queries.\r\n */\r\n private _executeQuery = async (query: string) => {\r\n const rows = [];\r\n // eslint-disable-next-line deprecation/deprecation\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"]}
1
+ {"version":3,"file":"ViewCreator3d.js","sourceRoot":"","sources":["../../src/ViewCreator3d.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH;;;EAGE;AAEF,sDAA+E;AAC/E,oDAG4B;AAC5B,wDAA+C;AAI/C,yDAAsD;AAkCtD;;;;;;;;;GASG;AACH,MAAa,aAAa;IACxB;;;OAGG;IACH,YAAoB,OAAyB;QAAzB,YAAO,GAAP,OAAO,CAAkB;QAiM7C;;WAEG;QACK,kBAAa,GAAG,KAAK,EAAE,KAAa,EAAE,EAAE;YAC9C,MAAM,IAAI,GAAG,EAAE,CAAC;YAChB,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC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AC,CAAC,CAAC,CAAC;YACrH,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC;gBAC9B,OAAO,SAAS,CAAC;YAEnB,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SAC9B;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CAYF;AAhND,sCAgNC","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 3D default view for an iModel.\r\nEither takes in a list of modelIds, or displays all 3D models by default.\r\n*/\r\n\r\nimport { CompressedId64Set, Id64Array, Id64String } from \"@itwin/core-bentley\";\r\nimport {\r\n Camera, CategorySelectorProps, Code, CustomViewState3dProps, DisplayStyle3dProps, Environment, IModel, IModelReadRpcInterface, ModelSelectorProps,\r\n QueryRowFormat, RenderMode, ViewDefinition3dProps, ViewQueryParams, ViewStateProps,\r\n} from \"@itwin/core-common\";\r\nimport { Range3d } from \"@itwin/core-geometry\";\r\nimport { StandardViewId } from \"./StandardView\";\r\nimport { IModelConnection } from \"./IModelConnection\";\r\nimport { ViewState } from \"./ViewState\";\r\nimport { SpatialViewState } from \"./SpatialViewState\";\r\n\r\n/** Options for creating a [[ViewState3d]] via [[ViewCreator3d]].\r\n * @public\r\n * @extensions\r\n*/\r\nexport interface ViewCreator3dOptions {\r\n /** Turn the [[Camera]] on to produce a perspective view.\r\n * Default: true\r\n */\r\n cameraOn?: boolean;\r\n /** Enables display of a [[SkyBox]] in the view. */\r\n skyboxOn?: boolean;\r\n /** Orients the view to one of the standard view rotations. */\r\n standardViewId?: StandardViewId;\r\n /** Merge in props from a persistent \"seed\" view obtained from the iModel.\r\n * @note The selection of the seed view is somewhat arbitrary, and the contents and styling of that view are unpredictable, so this option is not recommended.\r\n */\r\n useSeedView?: boolean;\r\n /** The desired aspect ratio of the [[Viewport]] in which the view is to be displayed.\r\n * This is used to adjust the view's frustum so that the viewed models are better centered within the viewport.\r\n */\r\n vpAspect?: number;\r\n /** Indicates that geometry belonging to every [SubCategory]($backend) should be visible within the view.\r\n * Each subcategory has a [SubCategoryAppearance]($common) that specifies how its geometry is displayed. This includes a [SubCategoryAppearance.invisible]($common) property that,\r\n * when set to `true`, indicates the geometry should not be displayed at all. A view can override the appearances of any subcategories using a [SubCategoryOverride]($common).\r\n * If `allSubCategoriesVisible` is `true`, [[ViewCreator3d]] will apply such an override to every viewed subcategory to change [SubCategoryOverride.invisible]($common) to `false`, making\r\n * every subcategory visible.\r\n * @note Subcategories are typically set to invisible by default for a reason.\r\n * Forcing them all to be visible may produce undesirable results, such as z-fighting between geometry on different subcategories that are not intended to be viewed together.\r\n */\r\n allSubCategoriesVisible?: boolean;\r\n}\r\n\r\n/**\r\n * API for creating a 3D default [[ViewState3d]] for an iModel. @see [[ViewCreator2d]] to create a view for a 2d model.\r\n * Example usage:\r\n * ```ts\r\n * const viewCreator = new ViewCreator3d(imodel);\r\n * const defaultView = await viewCreator.createDefaultView({skyboxOn: true});\r\n * ```\r\n * @public\r\n * @extensions\r\n */\r\nexport class ViewCreator3d {\r\n /**\r\n * Constructs a ViewCreator3d 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 a default [[ViewState3d]] based on the model ids passed in. If no model ids are passed in, all 3D models in the iModel are used.\r\n * @param [options] Options for creating the view.\r\n * @param [modelIds] Ids of models to display in the view.\r\n * @throws [IModelError]($common) If no 3d models are found in the iModel.\r\n */\r\n public async createDefaultView(options?: ViewCreator3dOptions, modelIds?: Id64String[]): Promise<ViewState> {\r\n const serializedProps: CustomViewState3dProps = await IModelReadRpcInterface.getClientForRouting(this._imodel.routingContext.token).getCustomViewState3dData(this._imodel.getRpcProps(),\r\n modelIds === undefined ? {} : { modelIds: CompressedId64Set.sortAndCompress(modelIds) });\r\n const props = await this._createViewStateProps(\r\n CompressedId64Set.decompressArray(serializedProps.modelIds),\r\n CompressedId64Set.decompressArray(serializedProps.categoryIds),\r\n Range3d.fromJSON(serializedProps.modelExtents),\r\n options);\r\n\r\n const viewState = SpatialViewState.createFromProps(props, this._imodel);\r\n try {\r\n await viewState.load();\r\n } catch {\r\n }\r\n\r\n if (options?.standardViewId)\r\n viewState.setStandardRotation(options.standardViewId);\r\n\r\n if (options?.allSubCategoriesVisible)\r\n viewState.displayStyle.enableAllLoadedSubCategories(viewState.categorySelector.categories);\r\n\r\n const range = viewState.computeFitRange();\r\n viewState.lookAtVolume(range, options?.vpAspect);\r\n\r\n return viewState;\r\n }\r\n\r\n /**\r\n * Generates a view state props object for creating a view. Merges display styles with a seed view if the options.useSeedView is true\r\n * @param models Models to put in view props\r\n * @param options view creation options like camera On and skybox On\r\n */\r\n private async _createViewStateProps(models: Id64Array, categories: Id64Array, modelExtents: Range3d, options?: ViewCreator3dOptions): Promise<ViewStateProps> {\r\n // Use dictionary model in all props\r\n const dictionaryId = IModel.dictionaryId;\r\n\r\n if (modelExtents.isNull)\r\n modelExtents.setFrom(this._imodel.projectExtents);\r\n\r\n let originX = modelExtents.low.x;\r\n let originY = modelExtents.low.y;\r\n const originZ = modelExtents.low.z;\r\n let deltaX = modelExtents.xLength();\r\n let deltaY = modelExtents.yLength();\r\n const deltaZ = modelExtents.zLength();\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 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 modelSelectorProps: ModelSelectorProps = {\r\n models,\r\n code: Code.createEmpty(),\r\n model: dictionaryId,\r\n classFullName: \"BisCore:ModelSelector\",\r\n };\r\n\r\n const cameraData = new Camera();\r\n const cameraOn = options?.cameraOn !== false;\r\n const viewDefinitionProps: ViewDefinition3dProps = {\r\n categorySelectorId: \"\",\r\n displayStyleId: \"\",\r\n code: Code.createEmpty(),\r\n model: dictionaryId,\r\n origin: { x: originX, y: originY, z: originZ },\r\n extents: { x: deltaX, y: deltaY, z: deltaZ },\r\n classFullName: \"BisCore:SpatialViewDefinition\",\r\n cameraOn,\r\n camera: {\r\n lens: cameraData.lens.toJSON(),\r\n focusDist: cameraData.focusDist,\r\n eye: cameraData.eye.toJSON(),\r\n },\r\n };\r\n\r\n const displayStyleProps: DisplayStyle3dProps = {\r\n code: Code.createEmpty(),\r\n model: dictionaryId,\r\n classFullName: \"BisCore:DisplayStyle3d\",\r\n jsonProperties: {\r\n styles: {\r\n viewflags: {\r\n renderMode: RenderMode.SmoothShade,\r\n noSourceLights: false,\r\n noCameraLights: false,\r\n noSolarLight: false,\r\n noConstruct: true,\r\n noTransp: false,\r\n visEdges: false,\r\n backgroundMap: this._imodel.isGeoLocated,\r\n },\r\n environment:\r\n options !== undefined &&\r\n options.skyboxOn !== undefined &&\r\n options.skyboxOn\r\n ? Environment.defaults.withDisplay({ sky: true }).toJSON()\r\n : undefined,\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 };\r\n\r\n // merge seed view props if needed\r\n return options?.useSeedView ? this._mergeSeedView(viewStateProps) : viewStateProps;\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 default 3D views in the iModel\r\n * @param viewStateProps Input view props to be merged\r\n */\r\n private async _mergeSeedView(viewStateProps: ViewStateProps): Promise<ViewStateProps> {\r\n const viewId = await this._getDefaultViewId();\r\n // Handle iModels without any default view id\r\n if (viewId === undefined)\r\n return viewStateProps;\r\n\r\n const seedViewState = (await this._imodel.views.load(viewId) as SpatialViewState);\r\n const seedViewStateProps = {\r\n categorySelectorProps: seedViewState.categorySelector.toJSON(),\r\n modelSelectorProps: seedViewState.modelSelector.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 ...viewStateProps.displayStyleProps.jsonProperties!.styles,\r\n };\r\n }\r\n\r\n return { ...seedViewStateProps, ...viewStateProps, displayStyleProps: mergedDisplayProps };\r\n }\r\n\r\n /**\r\n * Get ID of default view.\r\n */\r\n private async _getDefaultViewId(): Promise<Id64String | undefined> {\r\n const viewId = await this._imodel.views.queryDefaultViewId();\r\n const params: ViewQueryParams = {};\r\n params.from = SpatialViewState.classFullName;\r\n params.where = `ECInstanceId=${viewId}`;\r\n\r\n // Check validity of default view\r\n const viewProps = await IModelReadRpcInterface.getClient().queryElementProps(this._imodel.getRpcProps(), params);\r\n if (viewProps.length === 0) {\r\n // Return the first view we can find\r\n const viewList = await this._imodel.views.getViewList({ wantPrivate: false });\r\n if (viewList.length === 0)\r\n return undefined;\r\n\r\n const spatialViewList = viewList.filter((value: IModelConnection.ViewSpec) => value.class.indexOf(\"Spatial\") !== -1);\r\n if (spatialViewList.length === 0)\r\n return undefined;\r\n\r\n return spatialViewList[0].id;\r\n }\r\n\r\n return viewId;\r\n }\r\n\r\n /**\r\n * Helper function to execute ECSql queries.\r\n */\r\n private _executeQuery = async (query: string) => {\r\n const rows = [];\r\n for await (const row of this._imodel.createQueryReader(query, undefined, { rowFormat: QueryRowFormat.UseJsPropertyNames }))\r\n rows.push(row.id);\r\n\r\n return rows;\r\n };\r\n}\r\n"]}