UNPKG

@itwin/core-frontend

Version:
401 lines 20.8 kB
/** @packageDocumentation * @module Views */ import { BeEvent, Id64Arg, Id64String } from "@itwin/core-bentley"; import { Range1d, Vector3d } from "@itwin/core-geometry"; import { BackgroundMapProps, BackgroundMapProviderProps, BackgroundMapSettings, BaseLayerSettings, ColorDef, ContextRealityModelProps, DisplayStyle3dSettings, DisplayStyleProps, DisplayStyleSettings, Environment, FeatureAppearance, GlobeMode, LightSettings, MapLayerProps, MapLayerSettings, MapSubLayerProps, RenderSchedule, RenderTimelineProps, SolarShadowSettings, SubCategoryOverride, SubLayerId, ViewFlags } from "@itwin/core-common"; import { BackgroundMapGeometry } from "./BackgroundMapGeometry"; import { ContextRealityModelState } from "./ContextRealityModelState"; import { ElementState } from "./EntityState"; import { IModelConnection } from "./IModelConnection"; import { PlanarClipMaskState } from "./PlanarClipMaskState"; import { MapLayerIndex, TileTreeReference } from "./tile/internal"; import { _onScheduleScriptReferenceChanged, _scheduleScriptReference } from './common/internal/Symbols'; /** @internal */ export declare class TerrainDisplayOverrides { wantSkirts?: boolean; wantNormals?: boolean; produceGeometry?: boolean; } /** Options controlling display of [OpenStreetMap Buildings](https://cesium.com/platform/cesium-ion/content/cesium-osm-buildings/). * @see [[DisplayStyleState.setOSMBuildingDisplay]]. * @public * @extensions */ export interface OsmBuildingDisplayOptions { /** If defined, enables or disables display of the buildings by attaching or detaching the OpenStreetMap Buildings reality model. */ onOff?: boolean; /** If defined, overrides aspects of the appearance of the OpenStreetMap building meshes. */ appearanceOverrides?: FeatureAppearance; } /** A DisplayStyle defines the parameters for 'styling' the contents of a [[ViewState]]. * @public * @extensions */ export declare abstract class DisplayStyleState extends ElementState implements DisplayStyleProps { static get className(): string; private _ellipsoidMapGeometry; private _attachedRealityModelPlanarClipMasks; /** @internal */ protected _queryRenderTimelinePropsPromise?: Promise<RenderTimelineProps | undefined>; private _assigningScript; /** Event raised just before the [[scheduleScriptReference]] property is changed. * @internal as of 5.0, use [[onScheduleScriptChanged]]. */ readonly [_onScheduleScriptReferenceChanged]: BeEvent<(newScriptReference: RenderSchedule.ScriptReference | undefined) => void>; private _scriptReference?; /** Event raised when schedule script edits are made, providing changed element IDs and the editing scope. * @beta */ readonly onScheduleEditingChanged: BeEvent<(changes: RenderSchedule.EditingChanges[]) => void>; /** Event raised when schedule script edits are committed (finalized). * @beta */ readonly onScheduleEditingCommitted: BeEvent<() => void>; /** Event raised just before the [[scheduleScript]] property is changed. */ readonly onScheduleScriptChanged: BeEvent<(newScript: RenderSchedule.Script | undefined) => void>; /** Event raised just after [[setOSMBuildingDisplay]] changes the enabled state of the OSM buildings. */ readonly onOSMBuildingDisplayChanged: BeEvent<(osmBuildingDisplayEnabled: boolean) => void>; /** The container for this display style's settings. */ abstract get settings(): DisplayStyleSettings; /** @internal */ abstract overrideTerrainDisplay(): TerrainDisplayOverrides | undefined; /** Construct a new DisplayStyleState from its JSON representation. * @param props JSON representation of the display style. * @param iModel IModelConnection containing the display style. * @param source If the constructor is being invoked from [[EntityState.clone]], the display style that is being cloned. */ constructor(props: DisplayStyleProps, iModel: IModelConnection, source?: DisplayStyleState); /** Ensures all of the data required by the display style is loaded. This method is invoked for you by [[ViewState.load]], but if * you obtain a display style by some other means you should `await` this method before using the display style. */ load(): Promise<void>; private loadScriptReferenceFromScript; private loadScriptReferenceFromTimeline; /** @internal */ protected queryRenderTimelineProps(timelineId: Id64String): Promise<RenderTimelineProps | undefined>; /** @internal */ get displayTerrain(): boolean; /** @internal */ get globeMode(): GlobeMode; /** Settings controlling how the base map is displayed within a view. * The base map can be provided by any map imagery source or set to be a single color. */ get backgroundMapBase(): BaseLayerSettings; set backgroundMapBase(base: BaseLayerSettings); /** The settings controlling how a background map is displayed within a view. * @see [[ViewFlags.backgroundMap]] for toggling display of the map on or off. */ get backgroundMapSettings(): BackgroundMapSettings; set backgroundMapSettings(settings: BackgroundMapSettings); /** Modify a subset of the background map display settings. * @param name props JSON representation of the properties to change. Any properties not present will retain their current values in `this.backgroundMapSettings`. * @see [[ViewFlags.backgroundMap]] for toggling display of the map. * @see [[changeBackgroundMapProvider]] to change the type of map imagery displayed. * * Example that changes only the elevation, leaving the provider and type unchanged: * ``` ts * style.changeBackgroundMapProps({ groundBias: 16.2 }); * ``` * @public */ changeBackgroundMapProps(props: BackgroundMapProps): void; /** Change aspects of the [BackgroundMapProvider]($common) from which background map imagery is obtained. * Any properties not explicitly specified by `props` will retain their current values. * @public */ changeBackgroundMapProvider(props: BackgroundMapProviderProps): void; /** Call a function for each reality model attached to this display style. * @see [DisplayStyleSettings.contextRealityModels]($common). */ forEachRealityModel(func: (model: ContextRealityModelState) => void): void; private getRealityModels; /** Iterate over the reality models attached to this display style. */ get realityModels(): Iterable<ContextRealityModelState>; /** @internal */ getTileTreeRefs(): Iterable<TileTreeReference>; /** Performs logical comparison against another display style. Two display styles are logically equivalent if they have the same name, Id, and settings. * @param other The display style to which to compare. * @returns true if the specified display style is logically equivalent to this display style - i.e., both styles have the same values for all of their settings. */ equalState(other: DisplayStyleState): boolean; /** The name of this DisplayStyle */ get name(): string; /** Change the Id of the [RenderTimeline]($backend) element that hosts the [RenderSchedule.Script]($common) to be applied by this display style for * animating the contents of the view, and update [[scheduleScript]] using the script associated with the [RenderTimeline]($backend) element. * @see [DisplayStyleSettings.renderTimeline]($common). */ changeRenderTimeline(timelineId: Id64String | undefined): Promise<void>; /** * Begins or updates a schedule script editing session for the current display style. * During an editing session, changes to the schedule script are applied incrementally * using temporary dynamic tiles, allowing for interactive preview of visual changes like color, * transforms, visibility, and cutting planes — without requiring a full tile tree reload. * * Calling this method multiple times will update the current editing session with new script changes. * When all edits are complete, you must invoke [[commitScheduleEditing]] to finalize the session and * trigger a full tile tree refresh with the committed script. * * @note You cannot use schedule script editing while a @see [[GraphicalEditingScope]] is active. * * Example: * ```ts * [[include:ScheduleScript_editingMode]] * ``` * * @beta */ setScheduleEditing(newScript: RenderSchedule.Script): void; /** * Finalizes a script editing session previously started with [[setScheduleEditing]]. * This applies all pending script changes and triggers a full tile tree reload to reflect them in the viewport. * After this call, the schedule script is considered committed and editing mode ends. * * @see [[setScheduleEditing]] to begin a schedule script editing session. * @beta */ commitScheduleEditing(): void; /** The [RenderSchedule.Script]($common) that animates the contents of the view, if any. * @see [[changeRenderTimeline]] to change the script. */ get scheduleScript(): RenderSchedule.Script | undefined; set scheduleScript(script: RenderSchedule.Script | undefined); /** The [RenderSchedule.Script]($common) that animates the contents of the view, if any, along with the Id of the element that hosts the script. * @note The host element may be a [RenderTimeline]($backend) or a [DisplayStyle]($backend). * @internal */ get [_scheduleScriptReference](): RenderSchedule.ScriptReference | undefined; /** Attach a [ContextRealityModel]($common) to this display style. * @see [DisplayStyleSettings.contextRealityModels]($common). * @see [ContextRealityModels.add]($common) */ attachRealityModel(props: ContextRealityModelProps): ContextRealityModelState; /** Detach the first [ContextRealityModel]($common) that matches the specified name and url. * @see [DisplayStyleSettings.contextRealityModels]($common) * @see [ContextRealityModels.delete]($common) */ detachRealityModelByNameAndUrl(name: string, url: string): boolean; /** Get the [[ContextRealityModelState]] that displays the OpenStreetMap worldwide building layer, if enabled. * @see [[setOSMBuildingDisplay]] */ getOSMBuildingRealityModel(): ContextRealityModelState | undefined; /** Set the display of the OpenStreetMap worldwide building layer in this display style by attaching or detaching the reality model displaying the buildings. * The OSM buildings are displayed from a reality model aggregated and served from Cesium ion.<(https://cesium.com/content/cesium-osm-buildings/> * The options [[OsmBuildingDisplayOptions]] control the display and appearance overrides. */ setOSMBuildingDisplay(options: OsmBuildingDisplayOptions): boolean; /** Return if a context reality model is attached. * @see [[ContextRealityModelProps]]. */ hasAttachedRealityModel(name: string, url: string): boolean; /** @internal */ getMapLayers(isOverlay: boolean): MapLayerSettings[]; /** Attach a map layer to display style. * @param Settings representing the map layer. * @param mapLayerIndex the [[MapLayerIndex]] where the map layer should be attached. * @public */ attachMapLayer(options: { settings: MapLayerSettings; mapLayerIndex: MapLayerIndex; }): void; /** * @param mapLayerIndex the [[MapLayerIndex]] where the map layer should be attached. * @internal */ attachMapLayerProps(options: { props: MapLayerProps; mapLayerIndex: MapLayerIndex; }): void; /** @internal */ hasAttachedMapLayer(name: string, source: string, isOverlay: boolean): boolean; /** @internal */ detachMapLayerByNameAndSource(name: string, source: string, isOverlay: boolean): void; /** Detach map layer at index (-1 to remove all layers) * @param mapLayerIndex the [[MapLayerIndex]] of the map layer to detach. * @public */ detachMapLayerByIndex(mapLayerIndex: MapLayerIndex): void; /** * Lookup a maplayer index by name and source. * @param name Name of of the layer. * @param source Unique string identifying the layer. * @param isOverlay true if layer is overlay, otherwise layer is background. Defaults to false. * @public * */ findMapLayerIndexByNameAndSource(name: string, source: string, isOverlay: boolean): number; /** Return the map layer settings for a map layer at the provided index. * @param mapLayerIndex the [[MapLayerIndex]] of the map layer. * @public */ mapLayerAtIndex(mapLayerIndex: MapLayerIndex): MapLayerSettings | undefined; /** Return map base transparency as a number between 0 and 1. * @public */ get baseMapTransparency(): number; /** Change the map base transparency as a number between 0 and 1. * @public */ changeBaseMapTransparency(transparency: number): void; /** Modify a subset of a map layer settings. * @param props props JSON representation of the properties to change. Any properties not present will retain their current values. * @param mapLayerIndex the [[MapLayerIndex]] where the map layer should be inserted. * * Example that changes only the visibility of the first overlay map layer. * ``` ts * style.changeMapLayerProps({ visible: false }, 0, false); * ``` * @public */ changeMapLayerProps(props: Partial<MapLayerProps>, mapLayerIndex: MapLayerIndex): void; /** Change the credentials for a map layer. * @param mapLayerIndex the [[MapLayerIndex]] of the map layer to change the credentials of. * @public */ changeMapLayerCredentials(mapLayerIndex: MapLayerIndex, userName?: string, password?: string): void; /** Modify a subset of a sub-layer settings. * @param props props JSON representation of the properties to change. Any properties not present will retain their current values. * @param subLayerId Id of the sub-layer that should be modified. * @param mapLayerIndex the [[MapLayerIndex]] of the map layer that contains the sub-layer to be modified. * * @public */ changeMapSubLayerProps(props: Partial<MapSubLayerProps>, subLayerId: SubLayerId, mapLayerIndex: MapLayerIndex): void; private _synchBackgroundMapImagery; /** Move map layer to top. * @param mapLayerIndex the [[MapLayerIndex]] of the map layer to move. * @public * */ moveMapLayerToTop(mapLayerIndex: MapLayerIndex): void; /** Move map layer to bottom. * @param mapLayerIndex the [[MapLayerIndex]] of the map layer to move. * @public */ moveMapLayerToBottom(mapLayerIndex: MapLayerIndex): void; /** Reorder map layers * @param fromIndex index of map layer to move * @param toIndex insert index. If equal to length of map array the map layer is moved to end of array. * @param isOverlay true if map-layer is part of the overlay map, otherwise it is part of the background map. * @public */ moveMapLayerToIndex(fromIndex: number, toIndex: number, isOverlay: boolean): void; /** Flags controlling various aspects of the display style. * @see [DisplayStyleSettings.viewFlags]($common) */ get viewFlags(): ViewFlags; set viewFlags(flags: ViewFlags); /** The background color for this DisplayStyle */ get backgroundColor(): ColorDef; set backgroundColor(val: ColorDef); /** The color used to draw geometry in monochrome mode. * @see [ViewFlags.monochrome]($common) for enabling monochrome mode. */ get monochromeColor(): ColorDef; set monochromeColor(val: ColorDef); private _backgroundMapGeometry?; /** @internal */ anyMapLayersVisible(overlay: boolean): boolean; /** @internal */ getIsBackgroundMapVisible(): boolean; /** @internal */ get backgroundMapElevationBias(): number | undefined; /** @internal */ getBackgroundMapGeometry(): BackgroundMapGeometry | undefined; /** [[ContextRealityModelState]]s attached to this display style. * @see [DisplayStyleSettings.contextRealityModels]($common). */ get contextRealityModelStates(): ReadonlyArray<ContextRealityModelState>; /** @internal */ getGlobalGeometryAndHeightRange(): { geometry: BackgroundMapGeometry; heightRange: Range1d; } | undefined; /** Returns true if this is a 3d display style. */ is3d(): this is DisplayStyle3dState; /** Customize the way geometry belonging to a [[SubCategory]] is drawn by this display style. * @param id The ID of the SubCategory whose appearance is to be overridden. * @param ovr The overrides to apply to the [[SubCategoryAppearance]]. * @see [[dropSubCategoryOverride]] */ overrideSubCategory(id: Id64String, ovr: SubCategoryOverride): void; /** Remove any [[SubCategoryOverride]] applied to a [[SubCategoryAppearance]] by this style. * @param id The ID of the [[SubCategory]]. * @see [[overrideSubCategory]] */ dropSubCategoryOverride(id: Id64String): void; /** Returns true if an [[SubCategoryOverride]]s are defined by this style. */ get hasSubCategoryOverride(): boolean; /** Obtain the overrides applied to a [[SubCategoryAppearance]] by this style. * @param id The ID of the [[SubCategory]]. * @returns The corresponding SubCategoryOverride, or undefined if the SubCategory's appearance is not overridden. * @see [[overrideSubCategory]] */ getSubCategoryOverride(id: Id64String): SubCategoryOverride | undefined; /** For each subcategory belonging to any of the specified categories, make it visible by turning off the "invisible" flag in its subcategory appearance. * This requires that the categories and subcategories have been previously loaded by, e.g., a call to IModelConnection.querySubCategories. * @returns true if the visibility of any subcategory was modified. * @see Viewport.changeCategoryDisplay * @see ViewCreator3dOptions.allSubCategoriesVisible * @internal */ enableAllLoadedSubCategories(categoryIds: Id64Arg): boolean; /** Change the "invisible" flag for the given subcategory's appearance. * This requires that the subcategory appearance has been previously loaded by, e.g., a call to IModelConnection.Categories.getSubCategoryInfo. * @returns true if the visibility of any subcategory was modified. * @see [[enableAllLoadedSubCategories]] * @internal */ setSubCategoryVisible(subCategoryId: Id64String, visible: boolean): boolean; /** Returns true if solar shadow display is enabled by this display style. */ get wantShadows(): boolean; /** @internal */ protected registerSettingsEventListeners(): void; /** @internal */ protected createRealityModel(props: ContextRealityModelProps): ContextRealityModelState; /** @internal */ getPlanarClipMaskState(modelId: Id64String): PlanarClipMaskState | undefined; } /** A display style that can be applied to 2d views. * @public * @extensions */ export declare class DisplayStyle2dState extends DisplayStyleState { static get className(): string; private readonly _settings; get settings(): DisplayStyleSettings; /** @internal */ overrideTerrainDisplay(): TerrainDisplayOverrides | undefined; constructor(props: DisplayStyleProps, iModel: IModelConnection); } /** A [[DisplayStyleState]] that can be applied to spatial views. * @public * @extensions */ export declare class DisplayStyle3dState extends DisplayStyleState { static get className(): string; private _settings; get settings(): DisplayStyle3dSettings; constructor(props: DisplayStyleProps, iModel: IModelConnection, source?: DisplayStyle3dState); get environment(): Environment; set environment(env: Environment); get lights(): LightSettings; set lights(lights: LightSettings); /** The direction of the solar light. */ get sunDirection(): Readonly<Vector3d>; /** Set the solar light direction based on time value * @param time The time in unix time milliseconds. * @see [DisplayStyle3dSettings.sunTime]($common) to obtain the current sun time. * @see [DisplayStyle3dSettings.setSunTime]($common). */ setSunTime(time: number): void; /** Settings controlling shadow display. */ get solarShadows(): SolarShadowSettings; set solarShadows(settings: SolarShadowSettings); /** @internal */ protected registerSettingsEventListeners(): void; /** @internal */ overrideTerrainDisplay(): TerrainDisplayOverrides | undefined; } //# sourceMappingURL=DisplayStyleState.d.ts.map