ViewState Class

The front-end state of a ViewDefinition element. A ViewState is typically associated with a Viewport to display the contents of the view on the screen. A ViewState being displayed by a Viewport is considered to be "attached" to that viewport; a "detached" viewport is not being displayed by any viewport. Because the Viewport modifies the state of its attached ViewState, a ViewState can only be attached to one Viewport at a time. Technically, two Viewports can display two different ViewStates that both use the same DisplayStyleState, but this is discouraged - changes made to the style by one Viewport will affect the contents of the other Viewport.

extensions

Extends

Extended by

Methods

Name Description
_updateMaxGlobalScopeFactor(): void Protected    
adjustAspectRatio(aspect: number): void Adjust the aspect ratio of this ViewState so it matches the supplied value.  
allow3dManipulations(): boolean Abstract Returns true if ViewTools are allowed to operate in three dimensions on this view.  
applyPose(props: ViewPose): ViewState Abstract Apply a pose to this view to change the viewed volume.  
calculateFocusCorners(): Point3d[]    
calculateFrustum(result?: Frustum): undefined | Frustum Calculate the world coordinate Frustum from the parameters of this ViewState.  
computeDisplayTransform(args: ComputeDisplayTransformArgs): undefined | Transform Compute the transform applied to a model or element at display time, if any. Beta  
computeFitRange(): Range3d Abstract Compute a range in CoordSystem.World coordinates that tightly encloses the contents of this view.  
equals(other: ViewState): boolean Determine whether this ViewState exactly matches another.  
forEachModel(func: (model: GeometricModelState) => void): void Abstract Execute a function on each viewed model  
getAspectRatio(): number Get the aspect ratio (width/height) of this view  
getAspectRatioSkew(): number Get the aspect ratio skew (x/y, usually 1.0) that is used to exaggerate the y axis of the view.  
getAuxiliaryCoordinateSystemId(): string Get the Id of the auxiliary coordinate system for this ViewState  
getCenter(result?: Point3d): Point3d Get the point at the geometric center of the view.  
getExtents(): Vector3d Abstract Get the extents of this view in CoordSystem.World coordinates.  
getGlobeRotation(): undefined | Matrix3d If the view is not of the project as determined by ViewState.getIsViewingProject then return  
getGridOrientation(): GridOrientationType Get the grid settings for this view  
getGridSettings(vp: Viewport, origin: Point3d, rMatrix: Matrix3d, orientation: GridOrientationType): void Populate the given origin and rotation with information from the grid settings from the grid orientation.  
getGridSpacing(): Readonly<WritableXAndY>    
getGridsPerRef(): number    
getIsViewingProject(): boolean Return true if the view is looking at the current iModel project extents or  
getModelAppearanceOverride(id: string): undefined | FeatureAppearance Query the symbology overrides applied to a model when rendered using this ViewState.  
getOrigin(): Point3d Abstract Get the origin of this view in CoordSystem.World coordinates.  
getRotation(): Matrix3d Abstract Get the 3x3 ortho-normal Matrix3d for this view.  
getSubCategoryOverride(id: string): undefined | SubCategoryOverride Query the symbology overrides applied to geometry belonging to a specific subcategory when rendered using this ViewState.  
getTargetPoint(result?: Point3d): Point3d Get the target point of the view.  
getUpVector(point: Point3d): Vector3d    
getViewClip(): undefined | ClipVector Get the clipping volume for this view, if defined  
getViewedExtents(): Range3d Abstract Get the extents of this view in CoordSystem.World coordinates.  
getXVector(result?: Vector3d): Vector3d Get the unit vector that points in the view X (left-to-right) direction.  
getYVector(result?: Vector3d): Vector3d Get the unit vector that points in the view Y (bottom-to-top) direction.  
getZVector(result?: Vector3d): Vector3d Get the unit vector that points in the view Z (front-to-back) direction.  
hasSameCoordinates(other: ViewState): boolean Determine whether this ViewState has the same coordinate system as another one.  
is2d(): this is ViewState2d Returns true if this ViewState is-a ViewState2d  
is3d(): this is ViewState3d Abstract Returns true if this ViewState is-a ViewState3d  
isDrawingView(): this is DrawingViewState Abstract Returns true if this ViewState is-a DrawingViewState  
isSheetView(): this is SheetViewState Returns true if this ViewState is-a SheetViewState  
isSpatialView(): this is SpatialViewState Abstract Returns true if this ViewState is-a SpatialViewState  
load(): Promise<void> Asynchronously load any required data for this ViewState from the backend.  
lookAtViewAlignedVolume(volume: Range3d, aspect?: number, options?: MarginOptions & OnViewExtentsError): void Look at a volume of space defined by a range in view local coordinates, keeping its current rotation.  
lookAtVolume(volume: Readonly<WritableLowAndHighXYZ> | Readonly<WritableLowAndHighXY>, aspect?: number, options?: MarginOptions & OnViewExtentsError): void Change the volume that this view displays, keeping its current rotation.  
postload(hydrateResponse: HydrateViewStateResponseProps): Promise<void> Protected    
preload(hydrateRequest: HydrateViewStateRequestProps): void Protected Populates the hydrateRequest object stored on the ViewState with:  
resetExtentLimits(): void Resets the largest and smallest values allowed for the extents of this ViewState to their default values.  
savePose(): ViewPose Abstract Capture a copy of this view's viewed volume.  
setAspectRatioSkew(val: number): void Set the aspect ratio skew (x/y) for this view.  
setAuxiliaryCoordinateSystem(acs?: AuxCoordSystemState): void Set or clear the AuxiliaryCoordinateSystem for this view.  
setCategorySelector(categories: CategorySelectorState): void Set the CategorySelector for this view.  
setCenter(center: Point3d): void set the center of this view to a new position.  
setDisplayStyle(style: DisplayStyleState): void    
setExtents(viewDelta: Vector3d): void Abstract Set the extents of this view in CoordSystem.World coordinates.  
setGridSettings(orientation: GridOrientationType, spacing: Point2d, gridsPerRef: number): void Set the grid settings for this view  
setOrigin(viewOrg: Readonly<WritableXYAndZ>): void Abstract Set the origin of this view in CoordSystem.World coordinates.  
setRotation(viewRot: Matrix3d): void Abstract Change the rotation of the view.  
setRotationAboutPoint(rotation: Matrix3d, point?: Point3d): void Set the rotation of this ViewState to the supplied rotation, by rotating it about a point.  
setStandardGlobalRotation(id: StandardViewId): void Orient this view to one of the StandardView rotations, if the the view is not viewing the project then the  
setStandardRotation(id: StandardViewId): void Orient this view to one of the StandardView rotations.  
setViewClip(clip?: ClipVector): void Set or clear the clipping volume for this view.  
setupFromFrustum(inFrustum: Frustum, opts?: OnViewExtentsError): ViewStatus Initialize the origin, extents, and rotation from an existing Frustum  
toJSON(): ViewDefinitionProps Convert to JSON representation.  
toProps(): ViewStateProps Serialize this ViewState as a set of properties that can be used to recreate it via ViewState.createFromProps.  
viewsCategory(id: string): boolean Determine whether the specified Category is displayed in this view  
viewsModel(modelId: string): boolean Abstract Returns true if this view displays the contents of a ViewState.Model specified by Id.  
createFromProps(_props: ViewStateProps, _iModel: IModelConnection): undefined | ViewState Static Create a new ViewState object from a set of properties.  

Inherited methods

Name Inherited from Description
clone(iModel?: IModelConnection): ViewState ElementState Make an independent copy of this EntityState

Properties

Name Type Description
analysisStyle Accessor ReadOnly undefined | AnalysisStyle See DisplayStyleSettings.analysisStyle.  
areAllTileTreesLoaded Accessor ReadOnly boolean Returns true if all TileTrees required by this view have been loaded.  
auxiliaryCoordinateSystem Accessor ReadOnly AuxCoordSystemState get the auxiliary coordinate system state object for this ViewState.  
backgroundColor Accessor ReadOnly ColorDef Get this view's background color.  
categorySelector Accessor CategorySelectorState Selects the categories that are display by this ViewState.  
defaultExtentLimits Accessor AbstractReadOnly ExtentLimits Returns the default extent limits for this ViewState.  
description undefined | string    
details Accessor AbstractReadOnly ViewDetails Provides access to optional detail settings for this view.  
displayStyle Accessor DisplayStyleState The style that controls how the contents of the view are displayed.  
extentLimits Accessor ExtentLimits Get or set the largest and smallest values allowed for the extents for this ViewState  
globalScopeFactor Accessor ReadOnly number A value that represents the global scope of the view -- a value greater than one indicates that the scope of this view is global (viewing most of Earth).  
isAttachedToViewport Accessor ReadOnly boolean Returns whether this view is currently being displayed by a Viewport.  
isPrivate undefined | boolean    
modelDisplayTransformProvider Accessor undefined | ModelDisplayTransformProvider An object that can provide per-model transforms to be applied at display time.  
name Accessor ReadOnly string Get the name of the ViewDefinition from which this ViewState originated.  
onDisplayStyleChanged Readonly BeEvent<(newStyle: DisplayStyleState) => void> An event raised just before assignment to the ViewState.displayStyle property, only if the view is attached to a Viewport.  
onModelDisplayTransformProviderChanged Readonly BeEvent<(newProvider: undefined | ModelDisplayTransformProvider) => void> Event raised just before assignment to the ViewState.modelDisplayTransformProvider property, only if the view is attached to a Viewport. Beta  
onViewedCategoriesChanged Readonly BeEvent<() => void> An event raised when the set of categories viewed by this view changes, only if the view is attached to a Viewport.  
scheduleScript Accessor ReadOnly undefined | Script The RenderSchedule.Script that animates the contents of the view, if any.  
viewFlags Accessor ViewFlags Flags controlling various aspects of this view's DisplayStyleState.  

Inherited properties

Name Type Inherited from Description
classFullName Accessor StaticReadOnly string ElementState Get full BIS class name of this Entity in the form "SchemaName:ClassName".
classFullName Readonly string ElementState The full class name in the form "schema:class".
className Accessor ReadOnly string ElementState The name of the BIS class associated with this class.
code Readonly Code ElementState The Code for this element
federationGuid Readonly undefined | string ElementState A FederationGuid assigned to this element by some other federated database
id Readonly string ElementState The Id of this Entity.
iModel Readonly IModelConnection ElementState The iModel from which this Entity was loaded
jsonProperties Readonly { T } ElementState Optional json properties of this Entity.
model Readonly string ElementState The ModelId of the Model containing this element
parent Readonly undefined | RelatedElement ElementState The parent Element of this, or undefined if no parent.
schemaName Accessor StaticReadOnly string ElementState The name of the BIS schema for this class.
userLabel Readonly undefined | string ElementState A user-assigned label for this element.

Defined in

Last Updated: 20 June, 2023