UNPKG

@itwin/core-frontend

Version:
845 lines • 95.1 kB
/** @packageDocumentation * @module Views */ import { BeDuration, BeEvent, Constructor, Id64, Id64Arg, Id64Set, Id64String } from "@itwin/core-bentley"; import { Angle, LowAndHighXY, LowAndHighXYZ, Map4d, Matrix3d, Plane3dByOriginAndUnitNormal, Point3d, Point4d, Range1d, Range3d, Transform, Vector3d, XAndY, XYAndZ, XYZ } from "@itwin/core-geometry"; import { AnalysisStyle, BackgroundMapProps, BackgroundMapProviderProps, BackgroundMapSettings, ClipStyle, ColorDef, DisplayStyleSettingsProps, ElementProps, FeatureAppearance, Frustum, Hilite, ImageBuffer, LightSettings, Placement, PlacementProps, SolarShadowSettings, SubCategoryAppearance, SubCategoryOverride, ViewFlags } from "@itwin/core-common"; import { AuxCoordSystemState } from "./AuxCoordSys"; import { BackgroundMapGeometry } from "./BackgroundMapGeometry"; import { ChangeFlags, MutableChangeFlags } from "./ChangeFlags"; import { CoordSystem } from "./CoordSystem"; import { DisplayStyleState } from "./DisplayStyleState"; import { ElementPicker } from "./ElementLocateManager"; import { FeatureOverrideProvider } from "./FeatureOverrideProvider"; import { HitDetail } from "./HitDetail"; import { IModelConnection } from "./IModelConnection"; import { ToolTipOptions } from "./NotificationManager"; import { PerModelCategoryVisibility } from "./PerModelCategoryVisibility"; import { Decorations } from "./render/Decorations"; import { FeatureSymbology } from "./render/FeatureSymbology"; import { FrameStats } from "./render/FrameStats"; import { Pixel } from "./render/Pixel"; import { GraphicList } from "./render/RenderGraphic"; import { RenderMemory } from "./render/RenderMemory"; import { RenderTarget } from "./render/RenderTarget"; import { StandardViewId } from "./StandardView"; import { SubCategoriesCache } from "./SubCategoriesCache"; import { DisclosedTileTreeSet, MapCartoRectangle, MapFeatureInfo, MapFeatureInfoOptions, MapLayerImageryProvider, MapLayerIndex, MapLayerInfoFromTileTree, MapTileTreeReference, MapTileTreeScaleRangeVisibility, TileBoundingBoxes, TiledGraphicsProvider, TileTreeReference, TileUser } from "./tile/internal"; import { Animator, MarginOptions, OnViewExtentsError, ViewAnimationOptions, ViewChangeOptions } from "./ViewAnimation"; import { DecorateContext, SceneContext } from "./ViewContext"; import { GlobalLocation } from "./ViewGlobalLocation"; import { ViewingSpace } from "./ViewingSpace"; import { ViewPose } from "./ViewPose"; import { ViewRect } from "./common/ViewRect"; import { ModelDisplayTransformProvider, ViewState } from "./ViewState"; import { ViewStatus } from "./ViewStatus"; import { QueryVisibleFeaturesCallback, QueryVisibleFeaturesOptions } from "./render/VisibleFeature"; import { FlashSettings } from "./FlashSettings"; /** Interface for drawing [[Decorations]] into, or on top of, a [[ScreenViewport]]. * @public */ export interface ViewportDecorator { /** Override to enable cached decorations for this decorator. * By default, a decorator is asked to recreate its decorations from scratch via its [[decorate]] method whenever the viewport's decorations are invalidated. * Decorations become invalidated for a variety of reasons, including when the scene changes and when the mouse moves. * Most decorators care only about when the scene changes, and may create decorations that are too expensive to recreate on every mouse motion. * If `useCachedDecorations` is true, then the viewport will cache the most-recently-created decorations for this decorator, and only invoke its [[decorate]] method if it has no cached decorations for it. * The cached decorations are discarded: * - Whenever the scene changes; and * - When the decorator explicitly requests it via [[Viewport.invalidateCachedDecorations]] or [[ViewManager.invalidateCachedDecorationsAllViews]]. * The decorator should invoke the latter when the criteria governing its decorations change. */ readonly useCachedDecorations?: true; /** Implement this method to add [[Decorations]] into the supplied DecorateContext. * @see [[useCachedDecorations]] to avoid unnecessarily recreating decorations. */ decorate(context: DecorateContext): void; } /** Source of depth point returned by [[Viewport.pickDepthPoint]]. * @public */ export declare enum DepthPointSource { /** Depth point from geometry within specified radius of pick point */ Geometry = 0,// eslint-disable-line @typescript-eslint/no-shadow /** Depth point from reality model within specified radius of pick point */ Model = 1, /** Depth point from ray projection to background map plane */ BackgroundMap = 2, /** Depth point from ray projection to ground plane */ GroundPlane = 3, /** Depth point from ray projection to grid plane */ Grid = 4, /** Depth point from ray projection to acs plane */ ACS = 5, /** Depth point from plane passing through view target point */ TargetPoint = 6, /** Depth point from map/terrain within specified radius of pick point */ Map = 7 } /** Options to control behavior of [[Viewport.pickDepthPoint]]. * @public */ export interface DepthPointOptions { /** If true, geometry with the "non-locatable" flag set will not be selected. */ excludeNonLocatable?: boolean; /** If true, geometry from pickable decorations will not be selected. */ excludeDecorations?: boolean; /** If true, geometry from an IModelConnection other than the one associated with the Viewport will not be selected. */ excludeExternalIModels?: boolean; } /** The minimum and maximum values for the z-depth of a rectangle of screen space. * Values are in [[CoordSystem.Npc]] so they will be between 0 and 1.0. * @public */ export interface DepthRangeNpc { /** The value closest to the back. */ minimum: number; /** The value closest to the front. */ maximum: number; } /** Options to allow changing the view rotation with zoomTo methods and ensure minimum bounding box dimensions for zoomToElements. * @public */ export interface ZoomToOptions { /** Set view rotation from standard view identifier. */ standardViewId?: StandardViewId; /** Set view rotation relative to placement of first element or props entry. */ placementRelativeId?: StandardViewId; /** Set view rotation from Matrix3d. */ viewRotation?: Matrix3d; /** Ensure minimum element-aligned bounding box dimensions in meters (3d only). */ minimumDimension?: number; } /** Options for changing the viewed Model of a 2d view via [[Viewport.changeViewedModel2d]] * @public */ export interface ChangeViewedModel2dOptions { /** If true, perform a "fit view" operation after changing to the new 2d model. */ doFit?: boolean; } /** Describes an undo or redo event for a [[Viewport]]. * @see [[Viewport.onViewUndoRedo]]. * @public */ export declare enum ViewUndoEvent { Undo = 0, Redo = 1 } /** @internal */ export declare const ELEMENT_MARKED_FOR_REMOVAL: unique symbol; declare global { interface Element { [ELEMENT_MARKED_FOR_REMOVAL]?: boolean; } } /** Payload for the [[Viewport.onFlashedIdChanged]] event indicating Ids of the currently- and/or previously-flashed objects. * @public */ export type OnFlashedIdChangedEventArgs = { readonly current: Id64String; readonly previous: Id64String; } | { readonly current: Id64String; readonly previous: undefined; } | { readonly previous: Id64String; readonly current: undefined; }; /** Arguments to [[Viewport.getPixelDataWorldPoint]]. * @public */ export interface GetPixelDataWorldPointArgs { /** The buffer containing the pixel data. @see [[Viewport.readPixels]]. */ pixels: Pixel.Buffer; /** The x coordinate of the pixel of interest, in view coordinates. */ x: number; /** The y coordinate of the pixel of interest, in view coordinates. */ y: number; /** If true, then the world point of a pixel associated with a model will preserve any transforms applied to the model at display time, * such as those supplied by a [[ModelDisplayTransformProvider]] or [PlanProjectionSettings.elevation]($common). * Otherwise, the world point will be multiplied by the inverse of any such transforms to correlate it with the model's true coordinate space. */ preserveModelDisplayTransforms?: boolean; /** If supplied, this point will be modified to store the returned point, instead of allocating a new point. */ out?: Point3d; } /** Arguments supplied to [[Viewport.readImageBuffer]]. * @public */ export interface ReadImageBufferArgs { /** The region of the viewport's [[ViewRect]] to capture. It must be fully contained within [[Viewport.viewRect]]. * If unspecified, the entirety of the viewport's view rect is captured. */ rect?: ViewRect; /** Optional dimensions to which to resize the captured image. If the aspect ratio of these dimensions does not match that of the captured image, * horizontal or vertical bars will be added to the resized image using the viewport's background color. * If unspecified, the image will not be resized. */ size?: XAndY; /** The image captured by WebGL appears "upside-down" and must be flipped to appear right-side-up; if true, this flipping will not be performed. * This provides a performance optimization for uncommon cases in which an upside-down image is actually preferred. */ upsideDown?: boolean; } /** MapLayer visibility based on its scale range definition. * @beta */ export interface MapLayerScaleRangeVisibility { /** True if map-layer is part of [[DisplayStyleState]]'s overlay map, otherwise map-layer is part of [[DisplayStyleState]]'s background map * @see [[DisplayStyleState.mapLayerAtIndex]]. */ isOverlay: boolean; /** Index of the map-layer in [[DisplayStyleState]]'s background/overlay map * @see [[DisplayStyleState.mapLayerAtIndex]]. */ index: number; /** Scale range visibility value of the map-layer */ visibility: MapTileTreeScaleRangeVisibility; } /** Arguments supplied to [[Viewport.readPixels]]. * @public * @extensions */ export interface ReadPixelsArgs { /** The function that will be invoked to process the captured pixel data. */ receiver: Pixel.Receiver; /** The region of the viewport's contents to read. If the area is empty or not contained within the [[Viewport.viewRect]], * no pixels will be read. * If omitted, the viewport's entire contents will be read. */ rect?: ViewRect; /** Specifies which aspects of each pixel to read. By default, all aspects are read. */ selector?: Pixel.Selector; /** If true, geometry with the "non-locatable" flag set will not be drawn, potentially revealing locatable geometry it would otherwise obscure. */ excludeNonLocatable?: boolean; /** An optional set of Ids of elements that should not be drawn, potentially revealing other geometry they would otherwise obscure. */ excludedElements?: Iterable<Id64String>; } /** Arguments supplied to [[Viewport.readImageToCanvas]]. * @public */ export interface ReadImageToCanvasOptions { /** If true, canvas decorations will not be included in the saved image. */ omitCanvasDecorations?: boolean; } /** A Viewport renders the contents of one or more [GeometricModel]($backend)s onto an `HTMLCanvasElement`. * * It holds a [[ViewState]] object that defines its viewing parameters; the ViewState in turn defines the [[DisplayStyleState]], * [[CategorySelectorState]], and - for [[SpatialViewState]]s - the [[ModelSelectorState]]. While a ViewState is being displayed by a Viewport, * it is considered to be "attached" to that viewport; it remains attached until the Viewport is disposed of or becomes attached to a different ViewState. * While the ViewState is attached to a Viewport, any changes made to the ViewState or its display style or category/model selectors will be automatically * reflected in the Viewport. A ViewState can be attached to no more than one Viewport at a time. * * As changes to ViewState are made, Viewports also hold a stack of *previous copies* of it, to allow * for undo/redo (i.e. *View Previous* and *View Next*) of viewing tools. * * Changes to a Viewport's state can be monitored by attaching an event listener to a variety of specific events. Most such events are * triggered only once per frame, just before the Viewport's contents are rendered. For example, if the following sequence of events occurs: * * * First frame is rendered * * ViewFlags are modified * * ViewFlags are modified again * * Second frame is rendered * * The [[Viewport.onDisplayStyleChanged]] event will be invoked exactly once, when the second frame is rendered. * * @see [[ScreenViewport]] for a viewport that can render onto the screen. * @see [[OffScreenViewport]] for a viewport that can render into an off-screen buffer. * @public * @extensions */ export declare abstract class Viewport implements Disposable, TileUser { /** Event called whenever this viewport is synchronized with its [[ViewState]]. * @note This event is invoked *very* frequently. To avoid negatively impacting performance, consider using one of the more specific Viewport events; * otherwise, avoid performing excessive computations in response to this event. * @see [[onViewportChanged]] for receiving events at more regular intervals with more specific information about what changed. * @see [[onChangeView]] for an event raised specifically when a different [[ViewState]] becomes associated with the viewport. */ readonly onViewChanged: BeEvent<(vp: Viewport) => void>; /** Event called after reversing the most recent change to the Viewport from the undo stack or reapplying the * most recently undone change to the Viewport from the redo stack. */ readonly onViewUndoRedo: BeEvent<(vp: Viewport, event: ViewUndoEvent) => void>; /** Event called on the next frame after this viewport's set of always-drawn elements changes. */ readonly onAlwaysDrawnChanged: BeEvent<(vp: Viewport) => void>; /** Event called on the next frame after this viewport's set of never-drawn elements changes. */ readonly onNeverDrawnChanged: BeEvent<(vp: Viewport) => void>; /** Event called on the next frame after this viewport's [[DisplayStyleState]] or its members change. * Aspects of the display style include [ViewFlags]($common), [SubCategoryOverride]($common)s, and [[Environment]] settings. */ readonly onDisplayStyleChanged: BeEvent<(vp: Viewport) => void>; /** Event called on the next frame after this viewport's set of displayed categories changes. */ readonly onViewedCategoriesChanged: BeEvent<(vp: Viewport) => void>; /** Event called on the next frame after this viewport's set of [[PerModelCategoryVisibility.Overrides]] changes. */ readonly onViewedCategoriesPerModelChanged: BeEvent<(vp: Viewport) => void>; /** Event called on the next frame after this viewport's set of displayed models changes. */ readonly onViewedModelsChanged: BeEvent<(vp: Viewport) => void>; /** Event called on the next frame after this viewport's [[FeatureOverrideProvider]] changes, * or the internal state of the provider changes such that the overrides needed to be recomputed. */ readonly onFeatureOverrideProviderChanged: BeEvent<(vp: Viewport) => void>; /** Event called on the next frame after this viewport's [[FeatureSymbology.Overrides]] change. */ readonly onFeatureOverridesChanged: BeEvent<(vp: Viewport) => void>; /** Event called on the next frame after any of the viewport's [[ChangeFlags]] changes. */ readonly onViewportChanged: BeEvent<(vp: Viewport, changed: ChangeFlags) => void>; /** Event invoked immediately when [[changeView]] is called to replace the current [[ViewState]] with a different one. */ readonly onChangeView: BeEvent<(vp: Viewport, previousViewState: ViewState) => void>; /** Event invoked immediately when the viewport is disposed. * @see [[Viewport.dispose]]. */ readonly onDisposed: BeEvent<(vp: Viewport) => void>; /** Event invoked after [[renderFrame]] detects that the dimensions of the viewport's [[ViewRect]] have changed. */ readonly onResized: BeEvent<(vp: Viewport) => void>; /** Event dispatched immediately after [[flashedId]] changes, supplying the Ids of the previously and/or currently-flashed objects. * @note Attempting to assign to [[flashedId]] from within the event callback will produce an exception. */ readonly onFlashedIdChanged: BeEvent<(vp: Viewport, args: OnFlashedIdChangedEventArgs) => void>; /** Event indicating when a map-layer scale range visibility change for the current viewport scale. * @beta */ readonly onMapLayerScaleRangeVisibilityChanged: BeEvent<(layerIndexes: MapLayerScaleRangeVisibility[]) => void>; /** Event invoked every time [[invalidateScene]] is called. * @note This event will be raised **very** frequently. Avoid doing significant work inside of your event listener. * @beta */ readonly onSceneInvalidated: BeEvent<(vp: Viewport) => void>; /** @internal */ protected _hasMissingTiles: boolean; /** This is initialized by a call to [[changeView]] sometime shortly after the constructor is invoked. * During that time it can be undefined. DO NOT assign directly to this member - use `setView()`. */ private _view; /** A function executed by `setView()` when `this._view` changes. */ private readonly _detachFromView; private readonly _detachFromDisplayStyle; private readonly _viewportId; private _doContinuousRendering; /** @internal */ protected _inViewChangedEvent: boolean; /** If false, indicates that [[Decorations]] should be recreated when rendering the next frame. * @note prefer to invoke [[invalidateDecorations]] rather than directly assigning to this property. */ protected _decorationsValid: boolean; /** @internal */ protected _sceneValid: boolean; /** @internal */ get sceneValid(): boolean; /** @internal */ protected _renderPlanValid: boolean; /** @internal */ get renderPlanValid(): boolean; /** @internal */ setRenderPlanValid(): void; /** @internal */ protected _controllerValid: boolean; /** @internal */ get controllerValid(): boolean; private _redrawPending; private _analysisFractionValid; /** @internal */ get analysisFractionValid(): boolean; private _timePointValid; /** @internal */ get timePointValid(): boolean; /** Strictly for tests. @internal */ setAllValid(): void; /** Mark the current set of decorations invalid, so that they will be recreated on the next render frame. * This can be useful, for example, if an external event causes one or more current decorations to become invalid and you wish to force * them to be recreated to show the changes. * @note On the next frame, the `decorate` method of all [[ViewManager.decorators]] will be called. There is no way (or need) to * invalidate individual decorations. */ invalidateDecorations(): void; /** Mark the viewport's scene as having changed, so that the next call to [[renderFrame]] will recreate it. * This method is not typically invoked directly - the scene is automatically invalidated in response to events such as moving the viewing frustum, * changing the set of viewed models, new tiles being loaded, etc. */ invalidateScene(): void; /** Mark the viewport's "render plan" as having changed, so that the next call to [[renderFrame]] will recreate it. * This method is not typically invoked directly - the render plan is automatically invalidated in response to events such as changing aspects * of the viewport's [[displayStyle]]. */ invalidateRenderPlan(): void; /** Mark the viewport's [[ViewState]] as having changed, so that the next call to [[renderFrame]] will invoke [[setupFromView]] to synchronize with the view. * This method is not typically invoked directly - the controller is automatically invalidated in response to events such as a call to [[changeView]]. * Additionally, refresh the Reality Tile Tree to reflect changes in the map layer. */ invalidateController(): void; /** @internal */ setValidScene(): void; /** Request that the Viewport redraw its contents on the next frame. This is useful when some state outside of the Viewport's control but affecting its display has changed. * For example, if the parameters affecting a screen-space effect applied to this Viewport are modified, the Viewport's contents should be redrawn to reflect the change. * @note This does not necessarily cause the viewport to recreate its scene, decorations, or anything else - it only guarantees that the contents will be repainted. */ requestRedraw(): void; private _animator?; /** @internal */ protected _changeFlags: MutableChangeFlags; private _selectionSetDirty; private readonly _perModelCategoryVisibility; private _tileSizeModifier?; /** @internal */ readonly subcategories: SubCategoriesCache.Queue; /** Time the current flash started. */ private _flashUpdateTime?; /** Current flash intensity from [0..this.flashSettings.maxIntensity] */ private _flashIntensity; /** Id of the currently flashed element. */ private _flashedElem?; /** Id of last flashed element. */ private _lastFlashedElem?; /** The Id of the most recently flashed element, if any. */ get lastFlashedElementId(): Id64String | undefined; private _wantViewAttachments; /** For debug purposes, controls whether or not view attachments are displayed in sheet views. * @internal */ get wantViewAttachments(): boolean; set wantViewAttachments(want: boolean); private _wantViewAttachmentBoundaries; /** For debug purposes, controls whether or not the boundary of each view attachment is displayed in a sheet view. * @internal */ get wantViewAttachmentBoundaries(): boolean; set wantViewAttachmentBoundaries(want: boolean); private _wantViewAttachmentClipShapes; /** For debug purposes, controls whether or not graphics representing the clipping shapes of each view attachment are displayed in a sheet view. * @internal */ get wantViewAttachmentClipShapes(): boolean; set wantViewAttachmentClipShapes(want: boolean); /** Don't allow entries in the view undo buffer unless they're separated by more than this amount of time. */ static undoDelay: BeDuration; private _debugBoundingBoxes; private _freezeScene; private _viewingSpace; private _target?; private _fadeOutActive; private _neverDrawn?; private _alwaysDrawn?; private _alwaysDrawnExclusive; private readonly _featureOverrideProviders; private readonly _tiledGraphicsProviders; private _mapTiledGraphicsProvider?; private _hilite; private _emphasis; private _flash; /** See [DisplayStyle3dSettings.lights]($common) */ get lightSettings(): LightSettings | undefined; setLightSettings(settings: LightSettings): void; /** See [DisplayStyle3dSettings.solarShadows]($common) */ get solarShadowSettings(): SolarShadowSettings | undefined; setSolarShadowSettings(settings: SolarShadowSettings): void; /** @public */ get viewingSpace(): ViewingSpace; /** This viewport's rotation matrix. */ get rotation(): Matrix3d; /** The vector between the opposite corners of this viewport's extents. */ get viewDelta(): Vector3d; /** Provides conversions between world and view coordinates. */ get worldToViewMap(): Map4d; /** Provides conversions between world and Npc (non-dimensional perspective) coordinates. */ get worldToNpcMap(): Map4d; /** @internal */ get frustFraction(): number; /** See [DisplayStyleSettings.analysisFraction]($common). */ get analysisFraction(): number; set analysisFraction(fraction: number); /** See [DisplayStyleSettings.timePoint]($common) */ get timePoint(): number | undefined; set timePoint(time: number | undefined); /** @internal */ protected readonly _viewRange: ViewRect; /** Get the rectangle of this Viewport in [[CoordSystem.View]] coordinates. * @note Do not modify the ViewRect's properties. */ abstract get viewRect(): ViewRect; /** @internal */ get isAspectRatioLocked(): boolean; /** @internal */ get target(): RenderTarget; /** Returns true if this Viewport's [[dispose]] method has been invoked. It is an error to attempt to interact with a disposed Viewport. * Typically a [[ScreenViewport]] becomes disposed as a result of a call to [[ViewManager.dropViewport]], often indirectly through the unmounting of a nine-zone UI's [[ViewportComponent]] when, e.g., switching front-stages. * @public */ get isDisposed(): boolean; /** The settings that control how elements are hilited in this Viewport. */ get hilite(): Hilite.Settings; set hilite(hilite: Hilite.Settings); /** The settings that control how emphasized elements are displayed in this Viewport. The default settings apply a thick black silhouette to the emphasized elements. * @see [FeatureAppearance.emphasized]($common). */ get emphasisSettings(): Hilite.Settings; set emphasisSettings(settings: Hilite.Settings); /** The settings that control how elements are flashed in this viewport. */ get flashSettings(): FlashSettings; set flashSettings(settings: FlashSettings); /** Determine whether the Grid display is currently enabled in this Viewport. * @return true if the grid display is on. */ get isGridOn(): boolean; /** Flags controlling aspects of how the contents of this viewport are rendered. * @see [DisplayStyleSettings.viewFlags]($common). */ get viewFlags(): ViewFlags; set viewFlags(viewFlags: ViewFlags); /** See [[ViewState.displayStyle]] */ get displayStyle(): DisplayStyleState; set displayStyle(style: DisplayStyleState); /** Selectively override aspects of this viewport's display style. * @see [DisplayStyleSettings.applyOverrides]($common) */ overrideDisplayStyle(overrides: DisplayStyleSettingsProps): void; /** See [DisplayStyleSettings.clipStyle]($common) */ get clipStyle(): ClipStyle; set clipStyle(style: ClipStyle); /** Sets the number of [MSAA]($docs/learning/display/MSAA.md) samples for this viewport. * The number of samples is a power of two. Values of 1 or less indicates anti-aliasing should be disabled. Non-power-of-two values are rounded * down to the nearest power of two. The maximum number of samples supported depends upon the client's graphics hardware capabilities. Higher values produce * a higher-quality image but also may also reduce framerate. * @see [[ViewManager.setAntialiasingAllViews]] to adjust the number of samples for all viewports. */ get antialiasSamples(): number; set antialiasSamples(numSamples: number); /** return true if viewing globe (globeMode is 3D and eye location is far above globe * @alpha */ get viewingGlobe(): boolean; /** Remove any [[SubCategoryOverride]] for the specified subcategory. * @param id The Id of the subcategory. * @see [[overrideSubCategory]] */ dropSubCategoryOverride(id: Id64String): void; /** Override the symbology of geometry belonging to a specific subcategory when rendered within this viewport. * @param id The Id of the subcategory. * @param ovr The symbology overrides to apply to all geometry belonging to the specified subcategory. * @see [[dropSubCategoryOverride]] */ overrideSubCategory(id: Id64String, ovr: SubCategoryOverride): void; /** Query the symbology overrides applied to geometry belonging to a specific subcategory when rendered within this viewport. * @param id The Id of the subcategory. * @return The symbology overrides applied to all geometry belonging to the specified subcategory, or undefined if no such overrides exist. * @see [[overrideSubCategory]] */ getSubCategoryOverride(id: Id64String): SubCategoryOverride | undefined; /** Query the symbology with which geometry belonging to a specific subcategory is rendered within this viewport. * Every [[SubCategory]] defines a base symbology independent of any [[Viewport]]. * If a [[SubCategoryOverride]] has been applied to the subcategory within the context of this [[Viewport]], it will be applied to the subcategory's base symbology. * @param id The Id of the subcategory. * @return The symbology of the subcategory within this viewport, including any overrides. * @see [[overrideSubCategory]] */ getSubCategoryAppearance(id: Id64String): SubCategoryAppearance; /** Determine whether geometry belonging to a specific SubCategory is visible in this viewport, assuming the containing Category is displayed. * @param id The Id of the subcategory * @returns true if the subcategory is visible in this viewport. * @note Because this function does not know the Id of the containing Category, it does not check if the Category is enabled for display. The caller should check that separately if he knows the Id of the Category. */ isSubCategoryVisible(id: Id64String): boolean; /** Override the appearance of a model when rendered within this viewport. * @param id The Id of the model. * @param ovr The symbology overrides to apply to all geometry belonging to the specified subcategory. * @see [DisplayStyleSettings.overrideModelAppearance]($common) */ overrideModelAppearance(id: Id64String, ovr: FeatureAppearance): void; /** Remove any model appearance override for the specified model. * @param id The Id of the model. * @see [DisplayStyleSettings.dropModelAppearanceOverride]($common) */ dropModelAppearanceOverride(id: Id64String): void; /** Some changes may or may not require us to invalidate the scene. * Specifically, when shadows are enabled or we are displaying view attachments, the following changes may affect the visibility or transparency of elements or features: * - Viewed categories and subcategories; * - Always/never drawn elements * - Symbology overrides. */ private maybeInvalidateScene; /** Enable or disable display of elements belonging to a set of categories specified by Id. * Visibility of individual subcategories belonging to a category can be controlled separately through the use of [[SubCategoryOverride]]s. * By default, enabling display of a category does not affect display of subcategories thereof which have been overridden to be invisible. * @param categories The Id(s) of the categories to which the change should be applied. No other categories will be affected. * @param display Whether or not elements on the specified categories should be displayed in the viewport. * @param enableAllSubCategories Specifies that when enabling display for a category, all of its subcategories should also be displayed even if they are overridden to be invisible. */ changeCategoryDisplay(categories: Id64Arg, display: boolean, enableAllSubCategories?: boolean): void; private updateSubCategories; private enableAllSubCategories; /** @internal */ getSubCategories(categoryId: Id64String): Id64Set | undefined; /** Change the visibility of geometry belonging to the specified subcategory when displayed in this viewport. * @param subCategoryId The Id of the subcategory * @param display: True to make geometry belonging to the subcategory visible within this viewport, false to make it invisible. */ changeSubCategoryDisplay(subCategoryId: Id64String, display: boolean): void; /** The settings controlling how a background map is displayed within a view. * @see [[ViewFlags.backgroundMap]] for toggling display of the map on or off. * @see [DisplayStyleSettings.backgroundMap]($common) */ get backgroundMapSettings(): BackgroundMapSettings; set backgroundMapSettings(settings: BackgroundMapSettings); /** See [[DisplayStyleState.changeBackgroundMapProps]] */ changeBackgroundMapProps(props: BackgroundMapProps): void; /** See [[DisplayStyleState.changeBackgroundMapProvider]] */ changeBackgroundMapProvider(props: BackgroundMapProviderProps): void; /** A reference to the [[TileTree]] used to display the background map in this viewport, if the background map is being displayed. */ get backgroundMapTileTreeReference(): TileTreeReference | undefined; /** @internal */ get backgroundMap(): MapTileTreeReference | undefined; /** @internal */ get overlayMap(): MapTileTreeReference | undefined; /** @internal */ get backgroundDrapeMap(): MapTileTreeReference | undefined; /** Return the imagery provider for the provided map-layer index. * @param mapLayerIndex the [[MapLayerIndex]] of the map layer. * @beta */ getMapLayerImageryProvider(mapLayerIndex: MapLayerIndex): MapLayerImageryProvider | undefined; /** Return the map-layer scale range visibility for the provided map-layer index. * @param mapLayerIndex the [[MapLayerIndex]] of the map layer. * @see [[DisplayStyleState.mapLayerAtIndex]]. * @beta */ getMapLayerScaleRangeVisibility(mapLayerIndex: MapLayerIndex): MapTileTreeScaleRangeVisibility; /** Return a list of map-layers indexes matching a given MapTile tree Id and a layer imagery tree id. * Note: A imagery tree can be shared for multiple map-layers. * @internal */ getMapLayerIndexesFromIds(mapTreeId: Id64String, layerTreeId: Id64String): MapLayerIndex[]; /** Returns the cartographic range of a map layer. * @param mapLayerIndex the [[MapLayerIndex]] of the map layer. */ getMapLayerRange(mapLayerIndex: MapLayerIndex): Promise<MapCartoRectangle | undefined>; /** Changes viewport to include range of a map layer. * @param mapLayerIndex the [[MapLayerIndex]] of the map layer. * @param vp the viewport. */ viewMapLayerRange(mapLayerIndex: MapLayerIndex, vp: ScreenViewport): Promise<boolean>; /** Fully reset a map-layer tile tree; by calling this, the map-layer will to go through initialize process again, and all previously fetched tile will be lost. * @beta */ resetMapLayer(mapLayerIndex: MapLayerIndex): void; /** Returns true if this Viewport is currently displaying the model with the specified Id. */ viewsModel(modelId: Id64String): boolean; /** Attempt to change the 2d Model this Viewport is displaying, if its ViewState is a ViewState2d. * @param baseModelId The Id of the new 2d Model to be displayed. * @param options options that determine how the new view is displayed * @note This function *only works* if the viewport is viewing a [[ViewState2d]], otherwise it does nothing. Also note that * the Model of baseModelId should be the same type (Drawing or Sheet) as the current view. * @note this method clones the current ViewState2d and sets its baseModelId to the supplied value. The DisplayStyle and CategorySelector remain unchanged. */ changeViewedModel2d(baseModelId: Id64String, options?: ChangeViewedModel2dOptions & ViewChangeOptions & MarginOptions): Promise<void>; /** Attempt to replace the set of models currently viewed by this viewport, if it is displaying a SpatialView * @param modelIds The Ids of the models to be displayed. * @returns false if this Viewport is not viewing a [[SpatialViewState]] * @note This function *only works* if the viewport is viewing a [[SpatialViewState]], otherwise it does nothing. * @note This function *does not load* any models. If any of the supplied `modelIds` refers to a model that has not been loaded, no graphics will be loaded+displayed in the viewport for that model. * @see [[replaceViewedModels]] for a similar function that also ensures the requested models are loaded. */ changeViewedModels(modelIds: Id64Arg): boolean; /** Attempt to replace the set of models currently viewed by this viewport, if it is displaying a SpatialView * @param modelIds The Ids of the models to be displayed. * @note This function *only works* if the viewport is viewing a [[SpatialViewState]], otherwise it does nothing. * @note If any of the requested models is not yet loaded this function will asynchronously load them before updating the set of displayed models. */ replaceViewedModels(modelIds: Id64Arg): Promise<void>; /** Add or remove a set of models from those models currently displayed in this viewport. * @param modelIds The Ids of the models to add or remove. * @param display Whether or not to display the specified models in the viewport. * @returns false if this Viewport is not viewing a [[SpatialViewState]] * @note This function *only works* if the viewport is viewing a [[SpatialViewState]], otherwise it does nothing. * @note This function *does not load* any models. If `display` is `true` and any of the supplied `models` refers to a model that has not been loaded, no graphics will be loaded+displayed in the viewport for that model. * @see [[addViewedModels]] for a similar function that also ensures the requested models are loaded. */ changeModelDisplay(models: Id64Arg, display: boolean): boolean; /** Adds a set of models to the set of those currently displayed in this viewport. * @param modelIds The Ids of the models to add or remove. * @param display Whether or not to display the specified models in the viewport. * @note This function *only works* if the viewport is viewing a [[SpatialViewState]], otherwise it does nothing. * @note If any of the requested models is not yet loaded this function will asynchronously load them before updating the set of displayed models. */ addViewedModels(models: Id64Arg): Promise<void>; /** Determines what type (if any) of debug graphics will be displayed to visualize [[Tile]] volumes. Chiefly for debugging. * @see [[TileBoundingBoxes]] */ get debugBoundingBoxes(): TileBoundingBoxes; set debugBoundingBoxes(boxes: TileBoundingBoxes); /** When true, the scene will never be recreated. Chiefly for debugging purposes. * @internal */ get freezeScene(): boolean; set freezeScene(freeze: boolean); /** The iModel of this Viewport */ get iModel(): IModelConnection; /** @internal */ get isPointAdjustmentRequired(): boolean; /** @internal */ get isSnapAdjustmentRequired(): boolean; /** @internal */ get isContextRotationRequired(): boolean; /** Enables or disables "fade-out" mode. When this mode is enabled, transparent graphics are rendered with a flat alpha weight, * causing them to appear de-emphasized. This is typically used in contexts in which a handful of elements are to be emphasized in the view, * while the rest of the graphics are drawn transparently. */ get isFadeOutActive(): boolean; set isFadeOutActive(active: boolean); /** Obtain a tooltip from the map layer or reality model, if any, identified by the specified [[HitDetail]]. * @see [[ElementLocateManager]] */ getToolTip(hit: HitDetail): Promise<HTMLElement | string>; /** Obtain feature information from a map layer model, if any, identified by the specified [[HitDetail]]. * @see [[ElementLocateManager]] * @see [[MapFeatureInfo]] * @beta */ getMapFeatureInfo(hit: HitDetail, options?: MapFeatureInfoOptions): Promise<MapFeatureInfo>; /** If this event has one or more listeners, collection of timing statistics related to rendering frames is enabled. Frame statistics will be received by the listeners whenever a frame is finished rendering. * @note The timing data collected using this event only collects the amount of time spent on the CPU. Due to performance considerations, time spent on the GPU is not collected. Therefore, these statistics are not a direct mapping to user experience. * @note In order to avoid interfering with the rendering loop, take care to avoid performing any intensive tasks in your event listeners. * @see [[FrameStats]] * @alpha */ readonly onFrameStats: BeEvent<(frameStats: Readonly<FrameStats>) => void>; private _frameStatsCollector; /** A function invoked once, after the constructor, to initialize the viewport's state. * Subclasses can use this perform additional initialization, as the viewport's constructor is not directly invokable. */ protected initialize(): void; /** @internal because subclasses must derive from ScreenViewport or OffScreenviewport. */ protected constructor(target: RenderTarget); [Symbol.dispose](): void; /** @deprecated in 5.0 - will not be removed until after 2026-06-13. Use [Symbol.dispose] instead. */ dispose(): void; private setView; /** @internal Invoked when the viewport becomes associated with a new ViewState to register event listeners with the view * and allow the ViewState to set up internal state that is only relevant when associated with a Viewport. * Also invoked after changing OffScreenViewport.drawingToSheetTransform. * @internal */ protected attachToView(): void; private registerViewListeners; private registerDisplayStyleListeners; /** @internal Invoked when the viewport becomes associated with a new ViewState to unregister event listeners for * the previous ViewState and allow the previous ViewState to clean up any internal state that is only relevant while * associated with a Viewport. * Also invoked after changing OffScreenViewport.drawingToSheetTransform. * @internal */ protected detachFromView(): void; private detachFromDisplayStyle; /** Enables or disables continuous rendering. Ideally, during each render frame a Viewport will do as little work as possible. * To make that possible, the viewport keeps track of what has changed about its internal state from one frame to the next. * For example, if the view frustum has not changed since the previous frame, it is likely that the viewport does not need to be * re-rendered at all. * * In some circumstances, it is desirable to bypass the logic that limits the amount of work performed each frame. A primary example * is a viewport that has some animations applied to it, or when diagnostic information like frames-per-second is being monitored. * * @note An application which enables continuous rendering should disable it as soon as it is no longer needed. */ get continuousRendering(): boolean; set continuousRendering(contRend: boolean); /** A unique integer Id assigned to this Viewport upon construction. * It can be useful for comparing and sorting Viewport objects inside of collections like [SortedArray]($core-bentley). */ get viewportId(): number; /** The ViewState for this Viewport */ get view(): ViewState; /** @internal */ get pixelsPerInch(): number; /** @internal */ get backgroundMapGeometry(): BackgroundMapGeometry | undefined; /** Ids of a set of elements which should not be rendered within this view. * @note Do not modify this set directly - use [[setNeverDrawn]] or [[clearNeverDrawn]] instead. * @note This set takes precedence over the [[alwaysDrawn]] set - if an element is present in both sets, it is never drawn. */ get neverDrawn(): Id64Set | undefined; /** Ids of a set of elements which should always be rendered within this view, regardless of category and subcategory visibility. * If the [[isAlwaysDrawnExclusive]] flag is also set, *only* those elements in this set will be drawn. * @note Do not modify this set directly - use [[setAlwaysDrawn]] or [[clearAlwaysDrawn]] instead. * @note The [[neverDrawn]] set takes precedence - if an element is present in both sets, it is never drawn. */ get alwaysDrawn(): Id64Set | undefined; /** Clear the set of always-drawn elements. * @see [[alwaysDrawn]] */ clearAlwaysDrawn(): void; /** Clear the set of never-drawn elements. * @see [[neverDrawn]] */ clearNeverDrawn(): void; /** Specify the Ids of a set of elements which should never be rendered within this view. * @see [[neverDrawn]]. */ setNeverDrawn(ids: Id64Set): void; /** Specify the Ids of a set of elements which should always be rendered within this view, regardless of category and subcategory visibility. * @param ids The Ids of the elements to always draw. * @param exclusive If true, *only* the specified elements will be drawn. * @see [[alwaysDrawn]] * @see [[isAlwaysDrawnExclusive]] */ setAlwaysDrawn(ids: Id64Set, exclusive?: boolean): void; /** Returns true if the set of elements in the [[alwaysDrawn]] set are the *only* elements rendered within this view. */ get isAlwaysDrawnExclusive(): boolean; /** Allows visibility of categories within this viewport to be overridden on a per-model basis. */ get perModelCategoryVisibility(): PerModelCategoryVisibility.Overrides; /** Adds visibility overrides for any subcategories whose visibility differs from that defined by the view's * category selector in the context of specific models. * @internal */ addModelSubCategoryVisibilityOverrides(fs: FeatureSymbology.Overrides, ovrs: Id64.Uint32Map<Id64.Uint32Set>): void; /** Add a [[FeatureOverrideProvider]] to customize the appearance of [[Feature]]s within the viewport. * The provider will be invoked whenever the overrides are determined to need updating. * The overrides can be explicitly marked as needing a refresh by calling [[Viewport.setFeatureOverrideProviderChanged]]. This is typically called when * the internal state of the provider changes such that the computed overrides must also change. * @note A Viewport can have any number of FeatureOverrideProviders. No attempt is made to resolve conflicts between two different providers overriding the same Feature. * @param provider The provider to register. * @returns true if the provider was registered, or false if the provider was already registered. * @see [[dropFeatureOverrideProvider]] to remove the provider. * @see [[findFeatureOverrideProvider]] to find an existing provider. * @see [[FeatureSymbology.Overrides]]. */ addFeatureOverrideProvider(provider: FeatureOverrideProvider): boolean; /** Removes the specified FeatureOverrideProvider from the viewport. * @param provider The provider to drop. * @returns true if the provider was dropped, or false if it was not registered. * @see [[addFeatureOverrideProvider]]. */ dropFeatureOverrideProvider(provider: FeatureOverrideProvider): boolean; /** Locate the first registered FeatureOverrideProvider matching the supplied criterion. * @param predicate A function that will be invoked for each provider currently registered with the viewport, returning true to accept the provider. * @returns The first registered provider that matches the predicate, or undefined if no providers match the predicate. * @see [[findFeatureOverrideProviderOfType]] to locate a provider of a specific class. * @see [[addFeatureOverrideProvider]] to register a provider. */ findFeatureOverrideProvider(predicate: (provider: FeatureOverrideProvider) => boolean): FeatureOverrideProvider | undefined; /** The list of [[FeatureOverrideProvider]]s registered with this viewport. * @see [[addFeatureOverrideProvider]] to register a new provider. * @see [[dropFeatureOverrideProvider]] to unregister a provider. * @see [[findFeatureOverrideProvider]] or [[findFeatureOverrideProviderOfType]] to find a registered provider. */ get featureOverrideProviders(): Iterable<FeatureOverrideProvider>; /** Locate the first registered FeatureOverrideProvider of the specified class. For example, to locate a registered [[EmphasizeElements]] provider: * ```ts * const provider: EmphasizeElements = viewport.findFeatureOverrideProviderOfType<EmphasizeElements>(EmphasizeElements); * ``` * @see [[findFeatureOverrideProvider]] to locate a registered provider matching any arbitrary criterion. */ findFeatureOverrideProviderOfType<T>(type: Constructor<T>): T | undefined; /** @internal */ addFeatureOverrides(ovrs: FeatureSymbology.Overrides): void; /** Notifies this viewport that the internal state of its [[FeatureOverrideProvider]] has changed such that its * [[FeatureSymbology.Overrides]] should be recomputed. */ setFeatureOverrideProviderChanged(): void; /** Notifies this viewport that a change in application state requires its [[FeatureSymbology.Overrides]] to be recomputed. * @note The viewport monitors various events to automatically detect when the overrides should be recomputed. This method * is only needed for changes that are not observable by the viewport itself. */ invalidateSymbologyOverrides(): void; /** The [[TiledGraphicsProvider]]s currently registered with this viewport. * @see [[addTiledGraphicsProvider]]. */ get tiledGraphicsProviders(): Iterable<TiledGraphicsProvider>; /** @internal */ protected tiledGraphi