packageDocumentation module import { Matrix3d , Point3d , Vector3d } from "@itwin/core-geometry" ; import { IModelApp , SelectedViewportChangedArgs , StandardViewId , Viewport } from "@itwin/core-frontend" ; import { UiEvent } from "@itwin/appui-abstract" ; import { Face } from "../navigationaids/Cube" ; public export interface DrawingViewportChangeEventArgs { rotation : Matrix3d ; origin : Point3d ; complete : boolean ; } public export class DrawingViewportChangeEvent extends UiEvent < DrawingViewportChangeEventArgs > { } public export interface CubeRotationChangeEventArgs { rotMatrix : Matrix3d ; face : Face ; complete ? : boolean ; } public export class CubeRotationChangeEvent extends UiEvent < CubeRotationChangeEventArgs > { } public export interface StandardRotationChangeEventArgs { standardRotation : StandardViewId ; } public export class StandardRotationChangeEvent extends UiEvent < StandardRotationChangeEventArgs > { } public export interface ViewRotationChangeEventArgs { viewport : Viewport ; animationTime ? : number ; } public export class ViewRotationChangeEvent extends UiEvent < ViewRotationChangeEventArgs > { } public export interface ViewClassFullNameChangedEventArgs { viewport : Viewport ; oldName : string ; newName : string ; } public export class ViewClassFullNameChangedEvent extends UiEvent < ViewClassFullNameChangedEventArgs > { } public export interface ViewIdChangedEventArgs { viewport : Viewport ; oldId : string ; newId : string ; } public export class ViewIdChangedEvent extends UiEvent < ViewIdChangedEventArgs > { } public export class ViewportComponentEvents { private static _removeListener ? : ( ) => void ; public static initialize ( ) { if ( undefined !== this . _removeListener ) return ; this . _removeListener = IModelApp . viewManager . onSelectedViewportChanged . addListener ( ViewportComponentEvents . handleSelectedViewportChanged ) ; } internal public static terminate ( ) { if ( this . _removeListener ) { this . _removeListener ( ) ; this . _removeListener = undefined ; } } public static face = Face . None ; public static readonly origin = Point3d . createZero ( ) ; public static readonly extents = Vector3d . createZero ( ) ; public static readonly rotationMatrix = Matrix3d . createIdentity ( ) ; public static readonly onDrawingViewportChangeEvent = new DrawingViewportChangeEvent ( ) ; public static readonly onCubeRotationChangeEvent = new CubeRotationChangeEvent ( ) ; public static readonly onStandardRotationChangeEvent = new StandardRotationChangeEvent ( ) ; public static readonly onViewRotationChangeEvent = new ViewRotationChangeEvent ( ) ; public static readonly onViewClassFullNameChangedEvent = new ViewClassFullNameChangedEvent ( ) ; public static readonly onViewIdChangedEvent = new ViewIdChangedEvent ( ) ; private static handleSelectedViewportChanged ( args ) { if ( args . current ) ViewportComponentEvents . setViewMatrix ( args . current ) ; } public static setCubeMatrix ( rotMatrix , face = Face . None , complete = false ) { this . rotationMatrix . setFrom ( rotMatrix ) ; this . face = face ; this . onCubeRotationChangeEvent . emit ( { rotMatrix , complete , face } ) ; } public static setDrawingViewportState ( origin , rotation , complete = false ) { this . onDrawingViewportChangeEvent . emit ( { origin , rotation , complete } ) ; } public static setStandardRotation ( standardRotation ) { this . onStandardRotationChangeEvent . emit ( { standardRotation } ) ; } public static setViewMatrix ( viewport , animationTime ? ) { setTimeout ( ( ) => { if ( viewport . view ) { this . origin . setFrom ( viewport . view . getOrigin ( ) ) ; this . extents . setFrom ( viewport . view . getExtents ( ) ) ; } this . rotationMatrix . setFrom ( viewport . rotation ) ; this . onViewRotationChangeEvent . emit ( { viewport , animationTime } ) ; } ) ; } }