@itwin/core-frontend 5.4.0-dev.6 → 5.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +70 -1
- package/lib/cjs/IModelApp.d.ts +12 -0
- package/lib/cjs/IModelApp.d.ts.map +1 -1
- package/lib/cjs/IModelApp.js +9 -0
- package/lib/cjs/IModelApp.js.map +1 -1
- package/lib/cjs/IModelConnection.d.ts.map +1 -1
- package/lib/cjs/IModelConnection.js +6 -2
- package/lib/cjs/IModelConnection.js.map +1 -1
- package/lib/cjs/SheetViewState.d.ts +7 -5
- package/lib/cjs/SheetViewState.d.ts.map +1 -1
- package/lib/cjs/SheetViewState.js +52 -683
- package/lib/cjs/SheetViewState.js.map +1 -1
- package/lib/cjs/internal/SheetViewAttachments.d.ts +57 -0
- package/lib/cjs/internal/SheetViewAttachments.d.ts.map +1 -0
- package/lib/cjs/internal/SheetViewAttachments.js +336 -0
- package/lib/cjs/internal/SheetViewAttachments.js.map +1 -0
- package/lib/cjs/internal/ViewAttachmentRenderer.d.ts +32 -0
- package/lib/cjs/internal/ViewAttachmentRenderer.d.ts.map +1 -0
- package/lib/cjs/internal/ViewAttachmentRenderer.js +462 -0
- package/lib/cjs/internal/ViewAttachmentRenderer.js.map +1 -0
- package/lib/cjs/internal/render/webgl/SceneCompositor.js +1 -1
- package/lib/cjs/internal/render/webgl/SceneCompositor.js.map +1 -1
- package/lib/cjs/internal/render/webgl/ShaderBuilder.d.ts.map +1 -1
- package/lib/cjs/internal/render/webgl/ShaderBuilder.js +8 -1
- package/lib/cjs/internal/render/webgl/ShaderBuilder.js.map +1 -1
- package/lib/cjs/properties/AngleDescription.js +4 -4
- package/lib/cjs/properties/AngleDescription.js.map +1 -1
- package/lib/cjs/properties/LengthDescription.js +9 -9
- package/lib/cjs/properties/LengthDescription.js.map +1 -1
- package/lib/cjs/quantity-formatting/QuantityFormatter.d.ts.map +1 -1
- package/lib/cjs/quantity-formatting/QuantityFormatter.js +9 -8
- package/lib/cjs/quantity-formatting/QuantityFormatter.js.map +1 -1
- package/lib/cjs/tools/EventController.js +1 -1
- package/lib/cjs/tools/EventController.js.map +1 -1
- package/lib/cjs/tools/MeasureTool.js +21 -21
- package/lib/cjs/tools/MeasureTool.js.map +1 -1
- package/lib/esm/IModelApp.d.ts +12 -0
- package/lib/esm/IModelApp.d.ts.map +1 -1
- package/lib/esm/IModelApp.js +9 -0
- package/lib/esm/IModelApp.js.map +1 -1
- package/lib/esm/IModelConnection.d.ts.map +1 -1
- package/lib/esm/IModelConnection.js +7 -3
- package/lib/esm/IModelConnection.js.map +1 -1
- package/lib/esm/SheetViewState.d.ts +7 -5
- package/lib/esm/SheetViewState.d.ts.map +1 -1
- package/lib/esm/SheetViewState.js +55 -686
- package/lib/esm/SheetViewState.js.map +1 -1
- package/lib/esm/internal/SheetViewAttachments.d.ts +57 -0
- package/lib/esm/internal/SheetViewAttachments.d.ts.map +1 -0
- package/lib/esm/internal/SheetViewAttachments.js +332 -0
- package/lib/esm/internal/SheetViewAttachments.js.map +1 -0
- package/lib/esm/internal/ViewAttachmentRenderer.d.ts +32 -0
- package/lib/esm/internal/ViewAttachmentRenderer.d.ts.map +1 -0
- package/lib/esm/internal/ViewAttachmentRenderer.js +459 -0
- package/lib/esm/internal/ViewAttachmentRenderer.js.map +1 -0
- package/lib/esm/internal/render/webgl/SceneCompositor.js +1 -1
- package/lib/esm/internal/render/webgl/SceneCompositor.js.map +1 -1
- package/lib/esm/internal/render/webgl/ShaderBuilder.d.ts.map +1 -1
- package/lib/esm/internal/render/webgl/ShaderBuilder.js +8 -1
- package/lib/esm/internal/render/webgl/ShaderBuilder.js.map +1 -1
- package/lib/esm/properties/AngleDescription.js +4 -4
- package/lib/esm/properties/AngleDescription.js.map +1 -1
- package/lib/esm/properties/LengthDescription.js +9 -9
- package/lib/esm/properties/LengthDescription.js.map +1 -1
- package/lib/esm/quantity-formatting/QuantityFormatter.d.ts.map +1 -1
- package/lib/esm/quantity-formatting/QuantityFormatter.js +9 -8
- package/lib/esm/quantity-formatting/QuantityFormatter.js.map +1 -1
- package/lib/esm/tools/EventController.js +1 -1
- package/lib/esm/tools/EventController.js.map +1 -1
- package/lib/esm/tools/MeasureTool.js +21 -21
- package/lib/esm/tools/MeasureTool.js.map +1 -1
- package/lib/public/scripts/parse-imdl-worker.js +1 -1
- package/lib/workers/webpack/parse-imdl-worker.js +1 -1
- package/package.json +21 -21
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SheetViewAttachments.js","sourceRoot":"","sources":["../../../src/internal/SheetViewAttachments.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAyE,WAAW,EAAuB,MAAM,oBAAoB,CAAC;AAE7I,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,aAAa,EAAc,MAAM,qBAAqB,CAAC;AAE3F,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,4BAA4B,EAA0B,MAAM,0BAA0B,CAAC;AAChG,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAqBzC,gEAAgE;AAChE,MAAM,gBAAgB;IACpB,qDAAqD;IAC7C,MAAM,CAAC,SAAS,CAAe;IAEhC,MAAM,CAAC,GAAG;QACf,OAAO,IAAI,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,gBAAgB,EAAE,CAAC,CAAC;IACrE,CAAC;IAED,gBAAwB,CAAC;IAElB,KAAK;QACV,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,OAAO,KAAW,CAAC;IAEnB,KAAK,CAAC,QAAQ;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAW,aAAa;QACtB,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AAED,8EAA8E;AAC9E,MAAM,aAAa;IACA,IAAI,CAAe;IAEpC,YAAmB,GAAiB;QAClC,IAAI,CAA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a;QACnB,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC;QAChC,MAAM,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC;QAC3B,MAAM,CAAC,SAAS,KAAK,IAAI,CAAC,UAAU,CAAC,CAAC;QAEtC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC,gBAAgB,CAAC;QAE5C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;QAC/B,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO;QACT,CAAC;QAED,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;YACnC,MAAM,QAAQ,GAAG,4BAA4B,CAAC;gBAC5C,GAAG,IAAI;gBACP,KAAK,EAAE,IAAI;gBACX,IAAI,EAAE,IAAI,CAAC,YAAY;aACxB,CAAC,CAAC;YACH,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;YAC3D,OAAO,QAAQ,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,CAAC,SAAS;QAChB,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;gBACvC,MAAM,QAAQ,CAAC;YACjB,CAAC;QACH,CAAC;IACH,CAAC;IAEO,gBAAgB,CAAC,EAAc;QACrC,OAAO,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,mBAAmB,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IACvE,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 { ColorDef, HydrateViewStateRequestProps, HydrateViewStateResponseProps, Placement2d, ViewAttachmentProps } from \"@itwin/core-common\";\r\nimport { ComputeDisplayTransformArgs, GetAttachmentViewportArgs, ViewState } from \"../ViewState\";\r\nimport { assert, CompressedId64Set, expectDefined, Id64String } from \"@itwin/core-bentley\";\r\nimport { IModelConnection } from \"../IModelConnection\";\r\nimport { IModelApp } from \"../IModelApp\";\r\nimport { createViewAttachmentRenderer, ViewAttachmentRenderer } from \"./ViewAttachmentRenderer\";\r\nimport { Frustum2d } from \"../Frustum2d\";\r\nimport { Range3d, Transform } from \"@itwin/core-geometry\";\r\nimport { SceneContext } from \"../ViewContext\";\r\nimport { Viewport } from \"../Viewport\";\r\nimport { RenderMemory } from \"../render/RenderMemory\";\r\nimport { DisclosedTileTreeSet } from \"../tile/internal\";\r\n\r\n/** Represents the current state of the view attachments to be displayed by a SheetViewAttachments. */\r\ninterface Attachments {\r\n clone(iModel: IModelConnection): Attachments;\r\n preload(request: HydrateViewStateRequestProps): void;\r\n postload(response: HydrateViewStateResponseProps, iModel: IModelConnection): Promise<Attachments>;\r\n readonly infos?: ViewAttachmentInfo[];\r\n readonly attachmentIds: readonly string[];\r\n}\r\n\r\n/** The properties describing a view attachment, plus the ViewState created from them. */\r\ninterface ViewAttachmentInfo extends ViewAttachmentProps {\r\n attachedView: ViewState;\r\n}\r\n\r\n/** Stateless state for a sheet that has no view attachments. */\r\nclass EmptyAttachments implements Attachments {\r\n // We only need one instance of this stateless class.\r\n private static _instance?: Attachments;\r\n\r\n public static get(): Attachments {\r\n return this._instance ?? (this._instance = new EmptyAttachments());\r\n }\r\n\r\n private constructor() { }\r\n\r\n public clone(): Attachments {\r\n return this;\r\n }\r\n\r\n public preload(): void { }\r\n\r\n public async postload(): Promise<Attachments> {\r\n return this;\r\n }\r\n\r\n public get attachmentIds() {\r\n return [];\r\n }\r\n}\r\n\r\n/** Holds the element Ids of the view attachments to be loaded for display. */\r\nclass AttachmentIds implements Attachments {\r\n private readonly _ids: Id64String[];\r\n\r\n public constructor(ids: Id64String[]) {\r\n this._ids = ids;\r\n }\r\n\r\n public get attachmentIds() {\r\n return this._ids;\r\n }\r\n\r\n public clone(): Attachments {\r\n return new AttachmentIds([...this._ids]);\r\n }\r\n\r\n public preload(request: HydrateViewStateRequestProps): void {\r\n request.sheetViewAttachmentIds = CompressedId64Set.sortAndCompress(this._ids);\r\n request.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(response: HydrateViewStateResponseProps, iModel: IModelConnection): Promise<Attachments> {\r\n if (undefined === response.sheetViewViews || undefined === response.sheetViewAttachmentProps) {\r\n return this;\r\n }\r\n\r\n const viewStateProps = response.sheetViewViews;\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\r\n const views = await Promise.all(promises);\r\n\r\n const attachmentProps = response.sheetViewAttachmentProps as ViewAttachmentInfo[];\r\n assert(views.length === attachmentProps.length);\r\n const infos = [];\r\n for (let i = 0; i < views.length; i++) {\r\n const view = views[i];\r\n if (view && !(view.isSheetView())) {\r\n const props = attachmentProps[i];\r\n props.attachedView = view;\r\n infos.push(props);\r\n }\r\n }\r\n\r\n return new AttachmentInfos(infos);\r\n }\r\n}\r\n\r\n/** Fully loaded view attachments. */\r\nclass AttachmentInfos implements Attachments {\r\n public readonly infos: ViewAttachmentInfo[];\r\n\r\n public constructor(infos: ViewAttachmentInfo[]) {\r\n this.infos = infos;\r\n }\r\n\r\n public get attachmentIds() {\r\n return this.infos.map((x) => expectDefined(x.id));\r\n }\r\n\r\n public clone(iModel: IModelConnection): Attachments {\r\n const infos = this.infos.map((info) => {\r\n return {\r\n ...info,\r\n attachedView: info.attachedView.clone(iModel),\r\n };\r\n });\r\n\r\n return new AttachmentInfos(infos);\r\n }\r\n\r\n public preload(): void {\r\n // already loaded.\r\n }\r\n\r\n public async postload(): Promise<Attachments> {\r\n // already loaded.\r\n return this;\r\n }\r\n}\r\n\r\n/** Reloads the attachments after a change to the database. */\r\nasync function reloadAttachments(sheetModelId: Id64String, iModel: IModelConnection): Promise<Attachments> {\r\n const ecsql = `SELECT ECInstanceId as attachmentId FROM bis.ViewAttachment WHERE model.Id=${sheetModelId}`;\r\n const ids: string[] = [];\r\n for await (const row of iModel.createQueryReader(ecsql)) {\r\n ids.push(row[0]);\r\n }\r\n\r\n const attachmentProps = await iModel.elements.getProps(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 infos = [];\r\n for (let i = 0; i < views.length; i++) {\r\n const view = views[i];\r\n if (view && !view.isSheetView()) {\r\n const props = attachmentProps[i];\r\n props.attachedView = view;\r\n infos.push(props);\r\n }\r\n }\r\n\r\n return new AttachmentInfos(infos);\r\n}\r\n\r\nfunction disposeRenderers(renderers: ViewAttachmentRenderer[] | undefined) {\r\n if (renderers) {\r\n for (const renderer of renderers) {\r\n renderer[Symbol.dispose]();\r\n }\r\n }\r\n}\r\n\r\n/** Manages the set of ViewAttachment elements to be rendered by a SheetViewState.\r\n * Takes care of reloading them after ViewAttachment elements are modified, deleted, or inserted.\r\n */\r\nexport class SheetViewAttachments implements Disposable {\r\n private _impl: Attachments;\r\n private _reload?: Promise<Attachments>;\r\n private _maxDepth = Frustum2d.minimumZDistance;\r\n private _rendererArgs?: { sheetModelId: Id64String, backgroundColor: ColorDef };\r\n private _renderers?: ViewAttachmentRenderer[];\r\n\r\n public get maxDepth(): number {\r\n return this._maxDepth;\r\n }\r\n\r\n public *getSecondaryViewports(): Iterable<Viewport> {\r\n if (this._renderers) {\r\n for (const renderer of this._renderers) {\r\n if (renderer.viewport) {\r\n yield renderer.viewport;\r\n }\r\n }\r\n }\r\n }\r\n\r\n private constructor(impl: Attachments) {\r\n this._impl = impl;\r\n }\r\n\r\n public [Symbol.dispose](): void {\r\n disposeRenderers(this._renderers);\r\n this._renderers = this._rendererArgs = undefined;\r\n this._reload = undefined;\r\n }\r\n\r\n public static create(attachmentIds: Id64String[]): SheetViewAttachments {\r\n const impl = attachmentIds.length === 0 ? EmptyAttachments.get() : new AttachmentIds([...attachmentIds]);\r\n return new this(impl);\r\n }\r\n\r\n public get attachmentIds(): readonly string[] {\r\n return this._impl.attachmentIds;\r\n }\r\n\r\n public clone(iModel: IModelConnection): SheetViewAttachments {\r\n return new SheetViewAttachments(this._impl.clone(iModel));\r\n }\r\n\r\n public preload(request: HydrateViewStateRequestProps): void {\r\n this._impl.preload(request);\r\n }\r\n\r\n public async postload(response: HydrateViewStateResponseProps, iModel: IModelConnection): Promise<void> {\r\n this._impl = await this._impl.postload(response, iModel);\r\n }\r\n\r\n public async reload(sheetModelId: Id64String, iModel: IModelConnection): Promise<void> {\r\n const renderers = this._renderers;\r\n const reload = this._reload = reloadAttachments(sheetModelId, iModel);\r\n const impl = await this._reload;\r\n\r\n // We keep the previous renderers until reloading completes, to avoid drawing a blank view while waiting.\r\n // Afterward, always destroy the previous renderers.\r\n disposeRenderers(renderers);\r\n\r\n // If reload was not called again while we waited...\r\n if (this._reload === reload) {\r\n this._impl = impl;\r\n this._reload = this._renderers = undefined;\r\n\r\n if (this._rendererArgs) {\r\n // We are attached to a Viewport - reload the renderers.\r\n this.loadRenderers();\r\n }\r\n }\r\n }\r\n\r\n public attachToViewport(args: {\r\n backgroundColor: ColorDef,\r\n sheetModelId: Id64String,\r\n }): void {\r\n assert(undefined === this._renderers);\r\n assert(undefined === this._rendererArgs);\r\n\r\n this._rendererArgs = args;\r\n this.loadRenderers();\r\n }\r\n\r\n public detachFromViewport(): void {\r\n assert(undefined !== this._rendererArgs);\r\n this._rendererArgs = undefined;\r\n\r\n disposeRenderers(this._renderers);\r\n this._renderers = undefined;\r\n }\r\n\r\n public areAllTileTreesLoaded(displayedExtents: Range3d): boolean {\r\n if (this._reload) {\r\n return false;\r\n } else if (!this._renderers) {\r\n return true;\r\n }\r\n\r\n return this._renderers.every((renderer) => {\r\n const attachmentRange = Placement2d.fromJSON(renderer.viewAttachmentProps.placement).calculateRange();\r\n return !attachmentRange.intersectsRangeXY(displayedExtents) || renderer.areAllTileTreesLoaded;\r\n });\r\n }\r\n\r\n public discloseTileTrees(trees: DisclosedTileTreeSet): void {\r\n for (const renderer of this.renderers()) {\r\n trees.disclose(renderer);\r\n }\r\n }\r\n\r\n public collectStatistics(stats: RenderMemory.Statistics): void {\r\n for (const renderer of this.renderers()) {\r\n renderer.collectStatistics(stats);\r\n }\r\n }\r\n\r\n public addToScene(context: SceneContext): void {\r\n for (const renderer of this.renderers()) {\r\n renderer.addToScene(context);\r\n }\r\n }\r\n\r\n public getAttachmentViewport(args: GetAttachmentViewportArgs): Viewport | undefined {\r\n const renderer = args.viewAttachmentId ? this.findRendererById(args.viewAttachmentId) : undefined;\r\n if (!renderer) {\r\n return undefined;\r\n }\r\n\r\n return args.inSectionDrawingAttachment ? renderer.viewport?.view.getAttachmentViewport({ inSectionDrawingAttachment: true }) : renderer.viewport;\r\n }\r\n\r\n public computeDisplayTransform(args: ComputeDisplayTransformArgs): Transform | undefined {\r\n const renderer = undefined !== args.viewAttachmentId ? this.findRendererById(args.viewAttachmentId) : undefined;\r\n const ortho = renderer?.ortho;\r\n const sheetTransform = ortho?.toSheet;\r\n if (!sheetTransform) {\r\n return undefined;\r\n }\r\n\r\n const sectionTransform = args.inSectionDrawingAttachment ? ortho.view.computeDisplayTransform(args) : undefined;\r\n if (!sectionTransform) {\r\n return sheetTransform.clone(args.output);\r\n }\r\n\r\n return sheetTransform.multiplyTransformTransform(sectionTransform, args.output);\r\n }\r\n\r\n /** Strictly for tests. */\r\n public areAllAttachmentsLoaded(): boolean {\r\n return !this._reload && (!this._renderers || this._renderers.every((x) => x.areAllTileTreesLoaded));\r\n }\r\n\r\n /** Strictly for tests. */\r\n public get attachments(): object[] | undefined {\r\n return this._renderers;\r\n }\r\n\r\n /** Strictly for tests. */\r\n public get attachmentProps(): Array<Readonly<ViewAttachmentProps>> {\r\n const infos = this._impl.infos;\r\n if (!infos) {\r\n return [];\r\n }\r\n\r\n return infos.map((x) => {\r\n return {\r\n ...x,\r\n attachedView: undefined,\r\n };\r\n });\r\n }\r\n\r\n /** Strictly for tests. */\r\n public get attachmentInfos(): readonly Id64String[] | Array<{ attachedView: ViewState }> {\r\n const infos = this._impl.infos;\r\n return infos ?? this._impl.attachmentIds;\r\n }\r\n\r\n private loadRenderers(): void {\r\n const args = this._rendererArgs;\r\n assert(undefined !== args);\r\n assert(undefined === this._renderers);\r\n\r\n this._maxDepth = Frustum2d.minimumZDistance;\r\n\r\n const infos = this._impl.infos;\r\n if (!infos) {\r\n return;\r\n }\r\n\r\n this._renderers = infos.map((info) => {\r\n const renderer = createViewAttachmentRenderer({\r\n ...args,\r\n props: info,\r\n view: info.attachedView,\r\n });\r\n this._maxDepth = Math.max(this._maxDepth, renderer.zDepth);\r\n return renderer;\r\n });\r\n }\r\n\r\n private *renderers(): Iterable<ViewAttachmentRenderer> {\r\n if (this._renderers) {\r\n for (const renderer of this._renderers) {\r\n yield renderer;\r\n }\r\n }\r\n }\r\n\r\n private findRendererById(id: Id64String): ViewAttachmentRenderer | undefined {\r\n return this._renderers?.find((x) => x.viewAttachmentProps.id === id);\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Views
|
|
3
|
+
*/
|
|
4
|
+
import { ColorDef, ViewAttachmentProps } from "@itwin/core-common";
|
|
5
|
+
import { ViewState } from "../ViewState";
|
|
6
|
+
import { Viewport } from "../Viewport";
|
|
7
|
+
import { RenderMemory } from "../render/RenderMemory";
|
|
8
|
+
import { DisclosedTileTreeSet } from "../tile/internal";
|
|
9
|
+
import { SceneContext } from "../ViewContext";
|
|
10
|
+
import { Id64String } from "@itwin/core-bentley";
|
|
11
|
+
import { Transform } from "@itwin/core-geometry";
|
|
12
|
+
/** Draws the contents of a view attachment into a sheet view. */
|
|
13
|
+
export interface ViewAttachmentRenderer extends Disposable {
|
|
14
|
+
readonly areAllTileTreesLoaded: boolean;
|
|
15
|
+
addToScene: (context: SceneContext) => void;
|
|
16
|
+
discloseTileTrees: (trees: DisclosedTileTreeSet) => void;
|
|
17
|
+
readonly zDepth: number;
|
|
18
|
+
collectStatistics: (stats: RenderMemory.Statistics) => void;
|
|
19
|
+
viewAttachmentProps: ViewAttachmentProps;
|
|
20
|
+
readonly viewport?: Viewport;
|
|
21
|
+
readonly ortho?: {
|
|
22
|
+
readonly toSheet: Transform;
|
|
23
|
+
readonly view: ViewState;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export declare function createViewAttachmentRenderer(args: {
|
|
27
|
+
view: ViewState;
|
|
28
|
+
backgroundColor: ColorDef;
|
|
29
|
+
sheetModelId: Id64String;
|
|
30
|
+
props: ViewAttachmentProps;
|
|
31
|
+
}): ViewAttachmentRenderer;
|
|
32
|
+
//# sourceMappingURL=ViewAttachmentRenderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ViewAttachmentRenderer.d.ts","sourceRoot":"","sources":["../../../src/internal/ViewAttachmentRenderer.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAmH,mBAAmB,EAAqB,MAAM,oBAAoB,CAAC;AAIvM,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAqB,QAAQ,EAAE,MAAM,aAAa,CAAC;AAQ1D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EAAE,oBAAoB,EAAmB,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAkC,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EAA8F,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAG7I,iEAAiE;AACjE,MAAM,WAAW,sBAAuB,SAAQ,UAAU;IACxD,QAAQ,CAAC,qBAAqB,EAAE,OAAO,CAAC;IACxC,UAAU,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC;IAC5C,iBAAiB,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,CAAC;IACzD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,CAAC,KAAK,EAAE,YAAY,CAAC,UAAU,KAAK,IAAI,CAAC;IAC5D,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAC7B,QAAQ,CAAC,KAAK,CAAC,EAAE;QACf,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;QAC5B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;KAC1B,CAAC;CACH;AAED,wBAAgB,4BAA4B,CAAC,IAAI,EAAE;IACjD,IAAI,EAAE,SAAS,CAAC;IAChB,eAAe,EAAE,QAAQ,CAAC;IAC1B,YAAY,EAAE,UAAU,CAAC;IACzB,KAAK,EAAE,mBAAmB,CAAC;CAC5B,GAAG,sBAAsB,CAOzB"}
|
|
@@ -0,0 +1,459 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/** @packageDocumentation
|
|
6
|
+
* @module Views
|
|
7
|
+
*/
|
|
8
|
+
import { ColorDef, Feature, FeatureTable, Frustum, GraphicParams, PackedFeatureTable, Placement2d, TextureTransparency } from "@itwin/core-common";
|
|
9
|
+
import { CoordSystem } from "../CoordSystem";
|
|
10
|
+
import { Frustum2d } from "../Frustum2d";
|
|
11
|
+
import { IModelApp } from "../IModelApp";
|
|
12
|
+
import { OffScreenViewport } from "../Viewport";
|
|
13
|
+
import { imageBufferToPngDataUrl, openImageDataUrlInNewWindow } from "../common/ImageUtil";
|
|
14
|
+
import { ViewRect } from "../common/ViewRect";
|
|
15
|
+
import { GraphicType } from "../common/render/GraphicType";
|
|
16
|
+
import { FeatureSymbology } from "../render/FeatureSymbology";
|
|
17
|
+
import { GraphicBranch } from "../render/GraphicBranch";
|
|
18
|
+
import { TileGraphicType } from "../tile/internal";
|
|
19
|
+
import { MockRender } from "./render/MockRender";
|
|
20
|
+
import { assert, dispose, expectDefined } from "@itwin/core-bentley";
|
|
21
|
+
import { ClipShape, ClipVector, Matrix3d, Point2d, Point3d, PolyfaceBuilder, Range3d, StrokeOptions, Transform } from "@itwin/core-geometry";
|
|
22
|
+
import { createDefaultViewFlagOverrides } from "./tile/ViewFlagOverrides";
|
|
23
|
+
export function createViewAttachmentRenderer(args) {
|
|
24
|
+
const { props, view } = args;
|
|
25
|
+
if (props.jsonProperties?.displayOptions?.drawAsRaster || (view.is3d() && view.isCameraOn)) {
|
|
26
|
+
return new RasterAttachment(view, props, args.backgroundColor);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
return new OrthographicAttachment(view, props, args.sheetModelId);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/** A mostly no-op RenderTarget for an OrthographicAttachment. */
|
|
33
|
+
class AttachmentTarget extends MockRender.OffScreenTarget {
|
|
34
|
+
_attachment;
|
|
35
|
+
constructor(attachment) {
|
|
36
|
+
// The dimensions don't matter - we're not drawing anything.
|
|
37
|
+
const rect = new ViewRect(1, 1);
|
|
38
|
+
super(IModelApp.renderSystem, rect);
|
|
39
|
+
this._attachment = attachment;
|
|
40
|
+
}
|
|
41
|
+
changeScene(scene) {
|
|
42
|
+
this._attachment.scene = scene;
|
|
43
|
+
}
|
|
44
|
+
overrideFeatureSymbology(ovrs) {
|
|
45
|
+
this._attachment.symbologyOverrides = ovrs;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/** Draws the contents a 2d or orthographic 3d view directly into a sheet view.
|
|
49
|
+
* We select tiles for the view in the context of a light-weight offscreen viewport with a no-op RenderTarget, then
|
|
50
|
+
* collect the resultant graphics and add them to the sheet view's scene.
|
|
51
|
+
*/
|
|
52
|
+
class OrthographicAttachment {
|
|
53
|
+
_viewport;
|
|
54
|
+
_props;
|
|
55
|
+
_sheetModelId;
|
|
56
|
+
_viewFlagOverrides;
|
|
57
|
+
_toSheet;
|
|
58
|
+
_fromSheet;
|
|
59
|
+
_sizeInMeters;
|
|
60
|
+
_range;
|
|
61
|
+
_viewRect = new ViewRect(0, 0, 1, 1);
|
|
62
|
+
_originalFrustum = new Frustum();
|
|
63
|
+
_clipVolume;
|
|
64
|
+
_hiddenLineSettings;
|
|
65
|
+
_scale;
|
|
66
|
+
_debugFeatureTable;
|
|
67
|
+
scene;
|
|
68
|
+
symbologyOverrides;
|
|
69
|
+
zDepth;
|
|
70
|
+
get view() {
|
|
71
|
+
return this._viewport.view;
|
|
72
|
+
}
|
|
73
|
+
get viewAttachmentProps() {
|
|
74
|
+
return this._props;
|
|
75
|
+
}
|
|
76
|
+
get viewport() {
|
|
77
|
+
return this._viewport;
|
|
78
|
+
}
|
|
79
|
+
constructor(view, props, sheetModelId) {
|
|
80
|
+
this.symbologyOverrides = new FeatureSymbology.Overrides(view);
|
|
81
|
+
const target = new AttachmentTarget(this);
|
|
82
|
+
this._viewport = OffScreenViewport.createViewport(view, target, true);
|
|
83
|
+
this._props = props;
|
|
84
|
+
this._sheetModelId = sheetModelId;
|
|
85
|
+
const applyClip = true; // set to false for debugging
|
|
86
|
+
this._viewFlagOverrides = {
|
|
87
|
+
...view.viewFlags,
|
|
88
|
+
clipVolume: applyClip,
|
|
89
|
+
lighting: false,
|
|
90
|
+
shadows: false,
|
|
91
|
+
};
|
|
92
|
+
const placement = Placement2d.fromJSON(props.placement);
|
|
93
|
+
const range = placement.calculateRange();
|
|
94
|
+
this._range = range;
|
|
95
|
+
this._sizeInMeters = new Point2d(range.xLength(), range.yLength());
|
|
96
|
+
// Compute transform from attached view's world coordinates to sheet's world coordinates.
|
|
97
|
+
// NB: We obtain the extents and origin from the *viewport* not the *view* - they may have been adjusted by the viewport.
|
|
98
|
+
const applySkew = true; // set to false for debugging
|
|
99
|
+
const skew = applySkew ? view.getAspectRatioSkew() : 1;
|
|
100
|
+
const extents = this._viewport.viewingSpace.viewDelta.clone();
|
|
101
|
+
const zDepth = Math.abs(extents.z);
|
|
102
|
+
const scaleX = this._sizeInMeters.x / Math.abs(extents.x);
|
|
103
|
+
const scaleY = skew * this._sizeInMeters.y / Math.abs(extents.y);
|
|
104
|
+
this._scale = { x: 1 / scaleX, y: 1 / scaleY };
|
|
105
|
+
const zBias = Frustum2d.depthFromDisplayPriority(props.jsonProperties?.displayPriority ?? 0);
|
|
106
|
+
this.zDepth = 1.01 * (zDepth - zBias); // give a little padding so that geometry right up against far plane doesn't get clipped.
|
|
107
|
+
// View origin is at the *back* of the view. Align *front* of view based on display priority.
|
|
108
|
+
const viewRot = view.getRotation();
|
|
109
|
+
const viewOrg = viewRot.multiplyVector(this._viewport.viewingSpace.viewOrigin);
|
|
110
|
+
viewOrg.z += zDepth;
|
|
111
|
+
viewRot.multiplyTransposeVectorInPlace(viewOrg);
|
|
112
|
+
const matrix = Matrix3d.createScale(scaleX, scaleY, 1);
|
|
113
|
+
matrix.multiplyMatrixMatrix(viewRot, matrix);
|
|
114
|
+
const origin = Matrix3d.xyzMinusMatrixTimesXYZ(viewOrg, matrix, viewOrg);
|
|
115
|
+
const attachmentOrigin = Point3d.createFrom(placement.origin);
|
|
116
|
+
attachmentOrigin.z = zBias;
|
|
117
|
+
const viewOrgToAttachment = attachmentOrigin.minus(viewOrg);
|
|
118
|
+
origin.addInPlace(viewOrgToAttachment);
|
|
119
|
+
this._toSheet = Transform.createRefs(origin, matrix);
|
|
120
|
+
this._fromSheet = expectDefined(this._toSheet.inverse());
|
|
121
|
+
// If the attached view is a section drawing, it may itself have an attached spatial view with a clip.
|
|
122
|
+
// The clip needs to be transformed into sheet space.
|
|
123
|
+
if (view.isDrawingView())
|
|
124
|
+
this._viewport.drawingToSheetTransform = this._toSheet;
|
|
125
|
+
// ###TODO? If we also apply the attachment's clip to the attached view, we may get additional culling during tile selection.
|
|
126
|
+
// However the attached view's frustum is already clipped by intersection with sheet view's frustum, and additional clipping planes
|
|
127
|
+
// introduce additional computation, so possibly not worth it.
|
|
128
|
+
// Transform the view's clip (if any) to sheet space
|
|
129
|
+
let viewClip = view.viewFlags.clipVolume ? view.getViewClip()?.clone() : undefined;
|
|
130
|
+
if (viewClip)
|
|
131
|
+
viewClip.transformInPlace(this._toSheet);
|
|
132
|
+
else
|
|
133
|
+
viewClip = ClipVector.createEmpty();
|
|
134
|
+
let sheetClip;
|
|
135
|
+
if (undefined !== props.jsonProperties?.clip)
|
|
136
|
+
sheetClip = ClipVector.fromJSON(props.jsonProperties?.clip);
|
|
137
|
+
if (sheetClip && sheetClip.isValid) {
|
|
138
|
+
// Clip to view attachment's clip. NB: clip is in sheet coordinate space.
|
|
139
|
+
for (const clip of sheetClip.clips)
|
|
140
|
+
viewClip.clips.push(clip);
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
// Clip to view attachment's bounding box
|
|
144
|
+
viewClip.appendShape([
|
|
145
|
+
Point3d.create(this._range.low.x, this._range.low.y),
|
|
146
|
+
Point3d.create(this._range.high.x, this._range.low.y),
|
|
147
|
+
Point3d.create(this._range.high.x, this._range.high.y),
|
|
148
|
+
Point3d.create(this._range.low.x, this._range.high.y),
|
|
149
|
+
]);
|
|
150
|
+
}
|
|
151
|
+
this._clipVolume = IModelApp.renderSystem.createClipVolume(viewClip);
|
|
152
|
+
// Save off the original frustum (potentially adjusted by viewport).
|
|
153
|
+
this._viewport.setupFromView();
|
|
154
|
+
this._viewport.viewingSpace.getFrustum(CoordSystem.World, true, this._originalFrustum);
|
|
155
|
+
const applyHiddenLineSettings = true; // for debugging edge display, set to false...
|
|
156
|
+
const style = view.displayStyle;
|
|
157
|
+
if (style.is3d() && applyHiddenLineSettings)
|
|
158
|
+
this._hiddenLineSettings = style.settings.hiddenLineSettings;
|
|
159
|
+
}
|
|
160
|
+
[Symbol.dispose]() {
|
|
161
|
+
this._viewport[Symbol.dispose]();
|
|
162
|
+
}
|
|
163
|
+
discloseTileTrees(trees) {
|
|
164
|
+
trees.disclose(this._viewport);
|
|
165
|
+
}
|
|
166
|
+
addToScene(context) {
|
|
167
|
+
if (context.viewport.freezeScene)
|
|
168
|
+
return;
|
|
169
|
+
if (!context.viewport.view.viewsCategory(this._props.category))
|
|
170
|
+
return;
|
|
171
|
+
const wantBounds = context.viewport.wantViewAttachmentBoundaries;
|
|
172
|
+
const wantClipShapes = context.viewport.wantViewAttachmentClipShapes;
|
|
173
|
+
if (wantBounds || wantClipShapes) {
|
|
174
|
+
const builder = context.createSceneGraphicBuilder();
|
|
175
|
+
if (wantBounds) {
|
|
176
|
+
builder.setSymbology(ColorDef.red, ColorDef.red, 2);
|
|
177
|
+
builder.addRangeBox(this._range);
|
|
178
|
+
}
|
|
179
|
+
if (wantClipShapes && this._clipVolume) {
|
|
180
|
+
builder.setSymbology(ColorDef.blue, ColorDef.blue, 2);
|
|
181
|
+
for (const prim of this._clipVolume.clipVector.clips) {
|
|
182
|
+
if (!(prim instanceof ClipShape))
|
|
183
|
+
continue; // ###TODO handle non-shape primitives, if any such ever encountered
|
|
184
|
+
const pts = [];
|
|
185
|
+
const tf = prim.transformFromClip;
|
|
186
|
+
for (const pt of prim.polygon) {
|
|
187
|
+
const tfPt = tf ? tf.multiplyPoint3d(pt) : pt;
|
|
188
|
+
pts.push(new Point2d(tfPt.x, tfPt.y));
|
|
189
|
+
}
|
|
190
|
+
builder.addLineString2d(pts, 0);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
// Put into a Batch so that we can see tooltip with attachment Id on mouseover.
|
|
194
|
+
const batch = context.target.renderSystem.createBatch(builder.finish(), this.getDebugFeatureTable(), this._range);
|
|
195
|
+
context.outputGraphic(batch);
|
|
196
|
+
}
|
|
197
|
+
if (!context.viewport.wantViewAttachments)
|
|
198
|
+
return;
|
|
199
|
+
// Pixel size used to compute size of ViewRect so that tiles of appropriate LOD are selected.
|
|
200
|
+
const pixelSize = context.viewport.getPixelSizeAtPoint();
|
|
201
|
+
if (0 === pixelSize)
|
|
202
|
+
return;
|
|
203
|
+
// Adjust attached view frustum based on intersection with sheet view frustum.
|
|
204
|
+
const attachFrustum = this._originalFrustum.transformBy(this._toSheet);
|
|
205
|
+
const attachFrustumRange = attachFrustum.toRange();
|
|
206
|
+
const sheetFrustum = context.viewport.getWorldFrustum();
|
|
207
|
+
const sheetFrustumRange = sheetFrustum.toRange();
|
|
208
|
+
const intersect = attachFrustumRange.intersect(sheetFrustumRange);
|
|
209
|
+
if (intersect.isNull)
|
|
210
|
+
return;
|
|
211
|
+
attachFrustum.initFromRange(intersect);
|
|
212
|
+
attachFrustum.transformBy(this._fromSheet, attachFrustum);
|
|
213
|
+
this._viewport.setupViewFromFrustum(attachFrustum);
|
|
214
|
+
// Adjust view rect based on size of attachment on screen so that tiles of appropriate LOD are selected.
|
|
215
|
+
const width = this._sizeInMeters.x * intersect.xLength() / attachFrustumRange.xLength();
|
|
216
|
+
const height = this._sizeInMeters.y * intersect.yLength() / attachFrustumRange.yLength();
|
|
217
|
+
this._viewRect.width = Math.max(1, Math.round(width / pixelSize));
|
|
218
|
+
this._viewRect.height = Math.max(1, Math.round(height / pixelSize));
|
|
219
|
+
this._viewport.setRect(this._viewRect);
|
|
220
|
+
// Propagate settings from on-screen viewport.
|
|
221
|
+
this._viewport.debugBoundingBoxes = context.viewport.debugBoundingBoxes;
|
|
222
|
+
this._viewport.setTileSizeModifier(context.viewport.tileSizeModifier);
|
|
223
|
+
// Create the scene.
|
|
224
|
+
this._viewport.renderFrame();
|
|
225
|
+
const scene = this.scene;
|
|
226
|
+
if (!scene)
|
|
227
|
+
return;
|
|
228
|
+
// Extract scene graphics and insert into on-screen scene context.
|
|
229
|
+
const options = {
|
|
230
|
+
viewAttachmentId: this._props.id,
|
|
231
|
+
clipVolume: this._clipVolume,
|
|
232
|
+
hline: this._hiddenLineSettings,
|
|
233
|
+
frustum: {
|
|
234
|
+
is3d: this.view.is3d(),
|
|
235
|
+
scale: this._scale,
|
|
236
|
+
},
|
|
237
|
+
};
|
|
238
|
+
const outputGraphics = (source) => {
|
|
239
|
+
if (0 === source.length)
|
|
240
|
+
return;
|
|
241
|
+
const graphics = new GraphicBranch();
|
|
242
|
+
graphics.setViewFlagOverrides(this._viewFlagOverrides);
|
|
243
|
+
graphics.symbologyOverrides = this.symbologyOverrides;
|
|
244
|
+
for (const graphic of source)
|
|
245
|
+
graphics.entries.push(graphic);
|
|
246
|
+
const branch = context.createGraphicBranch(graphics, this._toSheet, options);
|
|
247
|
+
context.outputGraphic(branch);
|
|
248
|
+
};
|
|
249
|
+
outputGraphics(scene.foreground);
|
|
250
|
+
context.withGraphicType(TileGraphicType.BackgroundMap, () => outputGraphics(scene.background));
|
|
251
|
+
context.withGraphicType(TileGraphicType.Overlay, () => outputGraphics(scene.overlay));
|
|
252
|
+
// Report tile statistics to sheet view's viewport.
|
|
253
|
+
const tileAdmin = IModelApp.tileAdmin;
|
|
254
|
+
const selectedAndReady = tileAdmin.getTilesForUser(this._viewport);
|
|
255
|
+
const requested = tileAdmin.getRequestsForUser(this._viewport);
|
|
256
|
+
tileAdmin.addExternalTilesForUser(context.viewport, {
|
|
257
|
+
requested: requested?.size ?? 0,
|
|
258
|
+
selected: selectedAndReady?.selected.size ?? 0,
|
|
259
|
+
ready: selectedAndReady?.ready.size ?? 0,
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
getDebugFeatureTable() {
|
|
263
|
+
if (this._debugFeatureTable)
|
|
264
|
+
return this._debugFeatureTable;
|
|
265
|
+
const featureTable = new FeatureTable(1, this._sheetModelId);
|
|
266
|
+
featureTable.insert(new Feature(this._props.id));
|
|
267
|
+
this._debugFeatureTable = PackedFeatureTable.pack(featureTable);
|
|
268
|
+
return this._debugFeatureTable;
|
|
269
|
+
}
|
|
270
|
+
get areAllTileTreesLoaded() {
|
|
271
|
+
return this.view.areAllTileTreesLoaded;
|
|
272
|
+
}
|
|
273
|
+
collectStatistics(_stats) {
|
|
274
|
+
// Handled by discloseTileTrees()
|
|
275
|
+
}
|
|
276
|
+
get ortho() {
|
|
277
|
+
return {
|
|
278
|
+
toSheet: this._toSheet,
|
|
279
|
+
view: this.view,
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
function createRasterAttachmentViewport(_view, _rect, _attachment) {
|
|
284
|
+
class RasterAttachmentViewport extends OffScreenViewport {
|
|
285
|
+
_sceneContext;
|
|
286
|
+
_isSceneReady = false;
|
|
287
|
+
_attachment;
|
|
288
|
+
constructor(view, rect, attachment) {
|
|
289
|
+
super(IModelApp.renderSystem.createOffscreenTarget(rect));
|
|
290
|
+
this._attachment = attachment;
|
|
291
|
+
this._isAspectRatioLocked = true;
|
|
292
|
+
this.changeView(view);
|
|
293
|
+
}
|
|
294
|
+
createSceneContext() {
|
|
295
|
+
assert(!this._isSceneReady);
|
|
296
|
+
this._sceneContext = super.createSceneContext();
|
|
297
|
+
return this._sceneContext;
|
|
298
|
+
}
|
|
299
|
+
renderFrame() {
|
|
300
|
+
assert(!this._isSceneReady);
|
|
301
|
+
this.clearSceneContext();
|
|
302
|
+
super.renderFrame();
|
|
303
|
+
if (undefined !== this._sceneContext) {
|
|
304
|
+
this._isSceneReady = !this._sceneContext.hasMissingTiles && this.view.areAllTileTreesLoaded;
|
|
305
|
+
if (this._isSceneReady)
|
|
306
|
+
this._attachment.produceGraphics(this._sceneContext);
|
|
307
|
+
this._sceneContext = undefined;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
clearSceneContext() {
|
|
311
|
+
this._sceneContext = undefined;
|
|
312
|
+
}
|
|
313
|
+
addDecorations() {
|
|
314
|
+
// ###TODO: skybox, ground plane, possibly grid. DecorateContext requires a ScreenViewport...
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
return new RasterAttachmentViewport(_view, _rect, _attachment);
|
|
318
|
+
}
|
|
319
|
+
/** Draws a 3d view (usually with camera enabled) into a sheet view by producing an image of the view's contents offscreen. */
|
|
320
|
+
class RasterAttachment {
|
|
321
|
+
_props;
|
|
322
|
+
_placement;
|
|
323
|
+
_transform;
|
|
324
|
+
zDepth;
|
|
325
|
+
_viewport;
|
|
326
|
+
_graphics;
|
|
327
|
+
constructor(view, props, bgColor) {
|
|
328
|
+
// Render to a 2048x2048 view rect. Scale in Y to preserve aspect ratio.
|
|
329
|
+
const maxSize = 2048;
|
|
330
|
+
const rect = new ViewRect(0, 0, maxSize, maxSize);
|
|
331
|
+
const height = maxSize * view.getAspectRatio() * view.getAspectRatioSkew();
|
|
332
|
+
const skew = maxSize / height;
|
|
333
|
+
view.setAspectRatioSkew(skew);
|
|
334
|
+
if (true !== props.jsonProperties?.displayOptions?.preserveBackground) {
|
|
335
|
+
// Make background color 100% transparent so that Viewport.readImageBuffer() will discard transparent pixels.
|
|
336
|
+
view.displayStyle.backgroundColor = bgColor.withAlpha(0);
|
|
337
|
+
}
|
|
338
|
+
this._viewport = createRasterAttachmentViewport(view, rect, this);
|
|
339
|
+
this._props = props;
|
|
340
|
+
this._placement = Placement2d.fromJSON(props.placement);
|
|
341
|
+
this._transform = this._placement.transform;
|
|
342
|
+
this.zDepth = Frustum2d.depthFromDisplayPriority(props.jsonProperties?.displayPriority ?? 0);
|
|
343
|
+
}
|
|
344
|
+
[Symbol.dispose]() {
|
|
345
|
+
this._viewport?.[Symbol.dispose]();
|
|
346
|
+
}
|
|
347
|
+
get viewAttachmentProps() {
|
|
348
|
+
return this._props;
|
|
349
|
+
}
|
|
350
|
+
get viewport() {
|
|
351
|
+
return this._viewport;
|
|
352
|
+
}
|
|
353
|
+
get areAllTileTreesLoaded() {
|
|
354
|
+
return this._viewport?.areAllTileTreesLoaded ?? true;
|
|
355
|
+
}
|
|
356
|
+
addToScene(context) {
|
|
357
|
+
// ###TODO: check viewport.wantViewAttachmentClipShapes
|
|
358
|
+
if (!context.viewport.view.viewsCategory(this._props.category))
|
|
359
|
+
return;
|
|
360
|
+
if (context.viewport.wantViewAttachmentBoundaries) {
|
|
361
|
+
const builder = context.createSceneGraphicBuilder(this._transform);
|
|
362
|
+
builder.setSymbology(ColorDef.red, ColorDef.red, 2);
|
|
363
|
+
builder.addRangeBox(Range3d.createRange2d(this._placement.bbox));
|
|
364
|
+
context.outputGraphic(builder.finish());
|
|
365
|
+
}
|
|
366
|
+
if (!context.viewport.wantViewAttachments)
|
|
367
|
+
return;
|
|
368
|
+
if (this._graphics) {
|
|
369
|
+
context.outputGraphic(this._graphics);
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
if (undefined === this._viewport)
|
|
373
|
+
return;
|
|
374
|
+
this._viewport.debugBoundingBoxes = context.viewport.debugBoundingBoxes;
|
|
375
|
+
this._viewport.setTileSizeModifier(context.viewport.tileSizeModifier);
|
|
376
|
+
this._viewport.renderFrame();
|
|
377
|
+
if (this._graphics)
|
|
378
|
+
context.outputGraphic(this._graphics);
|
|
379
|
+
}
|
|
380
|
+
discloseTileTrees(trees) {
|
|
381
|
+
if (this._viewport)
|
|
382
|
+
trees.disclose(this._viewport);
|
|
383
|
+
}
|
|
384
|
+
produceGraphics(context) {
|
|
385
|
+
assert(context.viewport === this._viewport);
|
|
386
|
+
this._graphics = this.createGraphics(this._viewport);
|
|
387
|
+
this._viewport = dispose(this._viewport);
|
|
388
|
+
if (undefined !== this._graphics)
|
|
389
|
+
context.outputGraphic(this._graphics);
|
|
390
|
+
}
|
|
391
|
+
createGraphics(vp) {
|
|
392
|
+
// Create a texture from the contents of the view.
|
|
393
|
+
const image = vp.readImageBuffer({ upsideDown: true });
|
|
394
|
+
if (undefined === image)
|
|
395
|
+
return undefined;
|
|
396
|
+
const debugImage = false; // set to true to open a window displaying the captured image.
|
|
397
|
+
if (debugImage) {
|
|
398
|
+
const url = imageBufferToPngDataUrl(image, false);
|
|
399
|
+
if (url)
|
|
400
|
+
openImageDataUrlInNewWindow(url, "Attachment");
|
|
401
|
+
}
|
|
402
|
+
const texture = IModelApp.renderSystem.createTexture({
|
|
403
|
+
image: { source: image, transparency: TextureTransparency.Opaque },
|
|
404
|
+
});
|
|
405
|
+
if (!texture)
|
|
406
|
+
return undefined;
|
|
407
|
+
// Create a material for the texture
|
|
408
|
+
const graphicParams = new GraphicParams();
|
|
409
|
+
graphicParams.material = IModelApp.renderSystem.createRenderMaterial({ textureMapping: { texture } });
|
|
410
|
+
// Apply the texture to a rectangular polyface.
|
|
411
|
+
const depth = this.zDepth;
|
|
412
|
+
const east = this._placement.bbox.low.x;
|
|
413
|
+
const west = this._placement.bbox.high.x;
|
|
414
|
+
const north = this._placement.bbox.low.y;
|
|
415
|
+
const south = this._placement.bbox.high.y;
|
|
416
|
+
const corners = [
|
|
417
|
+
Point3d.create(east, north, depth),
|
|
418
|
+
Point3d.create(west, north, depth),
|
|
419
|
+
Point3d.create(west, south, depth),
|
|
420
|
+
Point3d.create(east, south, depth),
|
|
421
|
+
];
|
|
422
|
+
const params = [
|
|
423
|
+
Point2d.create(0, 0),
|
|
424
|
+
Point2d.create(1, 0),
|
|
425
|
+
Point2d.create(1, 1),
|
|
426
|
+
Point2d.create(0, 1),
|
|
427
|
+
];
|
|
428
|
+
const strokeOptions = new StrokeOptions();
|
|
429
|
+
strokeOptions.needParams = strokeOptions.shouldTriangulate = true;
|
|
430
|
+
const polyfaceBuilder = PolyfaceBuilder.create(strokeOptions);
|
|
431
|
+
polyfaceBuilder.addQuadFacet(corners, params);
|
|
432
|
+
const polyface = polyfaceBuilder.claimPolyface();
|
|
433
|
+
const graphicBuilder = IModelApp.renderSystem.createGraphicBuilder(Transform.createIdentity(), GraphicType.Scene, vp, this._props.id);
|
|
434
|
+
graphicBuilder.activateGraphicParams(graphicParams);
|
|
435
|
+
graphicBuilder.addPolyface(polyface, false);
|
|
436
|
+
const graphic = graphicBuilder.finish();
|
|
437
|
+
// Wrap the polyface in a GraphicBranch.
|
|
438
|
+
const branch = new GraphicBranch(true);
|
|
439
|
+
const vfOvrs = createDefaultViewFlagOverrides({ clipVolume: true, shadows: false, lighting: false, thematic: false });
|
|
440
|
+
// Disable transparency - background pixels are 100% transparent so they will be discarded anyway. Other pixels are 100% opaque.
|
|
441
|
+
vfOvrs.transparency = false;
|
|
442
|
+
branch.setViewFlagOverrides(vfOvrs);
|
|
443
|
+
branch.symbologyOverrides = new FeatureSymbology.Overrides();
|
|
444
|
+
branch.entries.push(graphic);
|
|
445
|
+
// Apply the attachment's clip, if any.
|
|
446
|
+
let clipVolume;
|
|
447
|
+
if (this._props.jsonProperties?.clip) {
|
|
448
|
+
const clipVector = ClipVector.fromJSON(this._props.jsonProperties?.clip);
|
|
449
|
+
if (clipVector.isValid)
|
|
450
|
+
clipVolume = IModelApp.renderSystem.createClipVolume(clipVector);
|
|
451
|
+
}
|
|
452
|
+
return IModelApp.renderSystem.createGraphicBranch(branch, this._transform, { clipVolume });
|
|
453
|
+
}
|
|
454
|
+
collectStatistics(stats) {
|
|
455
|
+
if (this._graphics)
|
|
456
|
+
this._graphics.collectStatistics(stats);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
//# sourceMappingURL=ViewAttachmentRenderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":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SAAS,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 { ColorDef, Feature, FeatureTable, Frustum, GraphicParams, HiddenLine, PackedFeatureTable, Placement2d, TextureTransparency, ViewAttachmentProps, ViewFlagOverrides } from \"@itwin/core-common\";\r\nimport { CoordSystem } from \"../CoordSystem\";\r\nimport { Frustum2d } from \"../Frustum2d\";\r\nimport { IModelApp } from \"../IModelApp\";\r\nimport { ViewState } from \"../ViewState\";\r\nimport { OffScreenViewport, Viewport } from \"../Viewport\";\r\nimport { imageBufferToPngDataUrl, openImageDataUrlInNewWindow } from \"../common/ImageUtil\";\r\nimport { ViewRect } from \"../common/ViewRect\";\r\nimport { GraphicType } from \"../common/render/GraphicType\";\r\nimport { FeatureSymbology } from \"../render/FeatureSymbology\";\r\nimport { GraphicBranch } from \"../render/GraphicBranch\";\r\nimport { RenderClipVolume } from \"../render/RenderClipVolume\";\r\nimport { RenderGraphic } from \"../render/RenderGraphic\";\r\nimport { RenderMemory } from \"../render/RenderMemory\";\r\nimport { Scene } from \"../render/Scene\";\r\nimport { DisclosedTileTreeSet, TileGraphicType } from \"../tile/internal\";\r\nimport { SceneContext } from \"../ViewContext\";\r\nimport { MockRender } from \"./render/MockRender\";\r\nimport { assert, dispose, expectDefined, Id64String } from \"@itwin/core-bentley\";\r\nimport { ClipShape, ClipVector, Matrix3d, Point2d, Point3d, PolyfaceBuilder, Range3d, StrokeOptions, Transform } from \"@itwin/core-geometry\";\r\nimport { createDefaultViewFlagOverrides } from \"./tile/ViewFlagOverrides\";\r\n\r\n/** Draws the contents of a view attachment into a sheet view. */\r\nexport interface ViewAttachmentRenderer extends Disposable {\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 readonly viewport?: Viewport;\r\n readonly ortho?: {\r\n readonly toSheet: Transform;\r\n readonly view: ViewState;\r\n };\r\n}\r\n\r\nexport function createViewAttachmentRenderer(args: {\r\n view: ViewState,\r\n backgroundColor: ColorDef,\r\n sheetModelId: Id64String,\r\n props: ViewAttachmentProps,\r\n}): ViewAttachmentRenderer {\r\n const { props, view } = args;\r\n if (props.jsonProperties?.displayOptions?.drawAsRaster || (view.is3d() && view.isCameraOn)) {\r\n return new RasterAttachment(view, props, args.backgroundColor);\r\n } else {\r\n return new OrthographicAttachment(view, props, args.sheetModelId);\r\n }\r\n}\r\n\r\n/** A mostly no-op RenderTarget for an OrthographicAttachment. */\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 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, sheetModelId: Id64String) {\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 = sheetModelId;\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 = expectDefined(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 [Symbol.dispose](): void {\r\n this._viewport[Symbol.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 viewAttachmentId: this._props.id,\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 public get ortho() {\r\n return {\r\n toSheet: this._toSheet,\r\n view: this.view,\r\n }\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(): 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 (usually 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, bgColor: ColorDef) {\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 view.displayStyle.backgroundColor = bgColor.withAlpha(0);\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 [Symbol.dispose](): void {\r\n this._viewport?.[Symbol.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\r\n"]}
|