UNPKG

@itwin/core-frontend

Version:
559 lines • 24.1 kB
/** @packageDocumentation * @module Tools */ import { Angle, Plane3dByOriginAndUnitNormal, Point3d, Range3d } from "@itwin/core-geometry"; import { DialogItem, DialogProperty, DialogPropertySyncItem } from "@itwin/appui-abstract"; import { StandardViewId } from "../StandardView"; import { Animator, MarginOptions, ViewChangeOptions } from "../ViewAnimation"; import { DecorateContext } from "../ViewContext"; import { DepthPointSource, ScreenViewport, Viewport } from "../Viewport"; import { ViewPose } from "../ViewPose"; import { ViewStatus } from "../ViewStatus"; import { PrimitiveTool } from "./PrimitiveTool"; import { BeButtonEvent, BeModifierKeys, BeTouchEvent, BeWheelEvent, EventHandled, InteractiveTool } from "./Tool"; import { ToolAssistanceInstruction } from "./ToolAssistance"; /** @internal */ export declare enum ViewHandleType { None = 0, Rotate = 1, TargetCenter = 2, Pan = 4, Scroll = 8, Zoom = 16, Walk = 32, Fly = 64, Look = 128, LookAndMove = 256 } /** @internal */ declare const enum ViewManipPriority { Low = 1, Normal = 10, Medium = 100, High = 1000 } /** An InteractiveTool that manipulates a view. * @public * @extensions */ export declare abstract class ViewTool extends InteractiveTool { viewport?: ScreenViewport | undefined; static translate(val: string): string; inDynamicUpdate: boolean; beginDynamicUpdate(): void; endDynamicUpdate(): void; run(..._args: any[]): Promise<boolean>; constructor(viewport?: ScreenViewport | undefined); onResetButtonUp(_ev: BeButtonEvent): Promise<EventHandled>; /** Do not override. */ exitTool(): Promise<void>; static showPrompt(prompt: string): void; } /** @internal */ export declare abstract class ViewingToolHandle { viewTool: ViewManip; protected readonly _lastPtNpc: Point3d; protected _depthPoint?: Point3d; constructor(viewTool: ViewManip); onReinitialize(): void; onCleanup(): void; focusOut(): void; motion(_ev: BeButtonEvent): boolean; checkOneShot(): boolean; getHandleCursor(): string; abstract doManipulation(ev: BeButtonEvent, inDynamics: boolean): boolean; abstract firstPoint(ev: BeButtonEvent): boolean; abstract testHandleForHit(ptScreen: Point3d, out: { distance: number; priority: ViewManipPriority; }): boolean; abstract get handleType(): ViewHandleType; focusIn(): void; drawHandle(_context: DecorateContext, _hasFocus: boolean): void; onWheel(_ev: BeWheelEvent): boolean; onTouchStart(_ev: BeTouchEvent): boolean; onTouchEnd(_ev: BeTouchEvent): boolean; onTouchComplete(_ev: BeTouchEvent): Promise<boolean>; onTouchCancel(_ev: BeTouchEvent): Promise<boolean>; onTouchMove(_ev: BeTouchEvent): boolean; onTouchMoveStart(_ev: BeTouchEvent, _startEv: BeTouchEvent): boolean; onTouchTap(_ev: BeTouchEvent): boolean; onKeyTransition(_wentDown: boolean, _keyEvent: KeyboardEvent): boolean; onModifierKeyTransition(_wentDown: boolean, _modifier: BeModifierKeys, _event: KeyboardEvent): boolean; needDepthPoint(_ev: BeButtonEvent, _isPreview: boolean): boolean; adjustDepthPoint(isValid: boolean, _vp: Viewport, _plane: Plane3dByOriginAndUnitNormal, source: DepthPointSource): boolean; protected pickDepthPoint(ev: BeButtonEvent): void; protected changeFocusFromDepthPoint(): void; } /** @internal */ export declare class ViewHandleArray { viewTool: ViewManip; handles: ViewingToolHandle[]; focus: number; focusDrag: boolean; hitHandleIndex: number; constructor(viewTool: ViewManip); empty(): void; get count(): number; get hitHandle(): ViewingToolHandle | undefined; get focusHandle(): ViewingToolHandle | undefined; add(handle: ViewingToolHandle): void; getByIndex(index: number): ViewingToolHandle | undefined; focusHitHandle(): void; testHit(ptScreen: Point3d, forced?: ViewHandleType): boolean; drawHandles(context: DecorateContext): void; setFocus(index: number): void; onReinitialize(): void; onCleanup(): void; motion(ev: BeButtonEvent): void; onWheel(ev: BeWheelEvent): boolean; /** determine whether a handle of a specific type exists */ hasHandle(handleType: ViewHandleType): boolean; } /** Base class for tools that manipulate the frustum of a Viewport. * @public * @extensions */ export declare abstract class ViewManip extends ViewTool { handleMask: number; oneShot: boolean; isDraggingRequired: boolean; /** @internal */ viewHandles: ViewHandleArray; frustumValid: boolean; readonly targetCenterWorld: Point3d; inHandleModify: boolean; isDragging: boolean; targetCenterValid: boolean; targetCenterLocked: boolean; nPts: number; /** @internal */ forcedHandle: ViewHandleType; /** @internal */ protected _depthPreview?: { testPoint: Point3d; pickRadius: number; plane: Plane3dByOriginAndUnitNormal; source: DepthPointSource; isDefaultDepth: boolean; sourceId?: string; }; /** @internal */ protected _startPose?: ViewPose; constructor(viewport: ScreenViewport | undefined, handleMask: number, oneShot: boolean, isDraggingRequired?: boolean); decorate(context: DecorateContext): void; /** @internal */ previewDepthPoint(context: DecorateContext): void; /** @internal */ getDepthPointGeometryId(): string | undefined; /** @internal */ clearDepthPoint(): boolean; /** @internal */ pickDepthPoint(ev: BeButtonEvent, isPreview?: boolean): Point3d | undefined; /** In addition to the onReinitialize calls after a tool installs or restarts, it is also * called from the mouseover event to cancel a drag operation if the up event occurred outside the view. * When operating in one shot mode and also requiring dragging, the tool should exit and not restart in ths situation. * A tool must opt in to allowing [[ViewTool.exitTool]] to be called from [[ViewManip.onReinitialize]] by * overriding this method to return true. */ protected get isExitAllowedOnReinitialize(): boolean; onReinitialize(): Promise<void>; onDataButtonDown(ev: BeButtonEvent): Promise<EventHandled>; onDataButtonUp(_ev: BeButtonEvent): Promise<EventHandled>; onMouseWheel(inputEv: BeWheelEvent): Promise<EventHandled>; /** @internal */ startHandleDrag(ev: BeButtonEvent, forcedHandle?: ViewHandleType): Promise<EventHandled>; onMouseStartDrag(ev: BeButtonEvent): Promise<EventHandled>; onMouseEndDrag(ev: BeButtonEvent): Promise<EventHandled>; onMouseMotion(ev: BeButtonEvent): Promise<void>; onTouchStart(ev: BeTouchEvent): Promise<void>; onTouchEnd(ev: BeTouchEvent): Promise<void>; onTouchComplete(ev: BeTouchEvent): Promise<void>; onTouchCancel(ev: BeTouchEvent): Promise<void>; onTouchMove(ev: BeTouchEvent): Promise<void>; onTouchMoveStart(ev: BeTouchEvent, startEv: BeTouchEvent): Promise<EventHandled>; onTouchTap(ev: BeTouchEvent): Promise<EventHandled>; onKeyTransition(wentDown: boolean, keyEvent: KeyboardEvent): Promise<EventHandled>; onModifierKeyTransition(wentDown: boolean, modifier: BeModifierKeys, event: KeyboardEvent): Promise<EventHandled>; onPostInstall(): Promise<void>; provideToolAssistance(mainInstrKey: string, additionalInstr?: ToolAssistanceInstruction[]): void; /** Called from [[ViewManip.onReinitialize]] to allow tools to establish the tool assistance for the first point. */ protected provideInitialToolAssistance(): void; onCleanup(): Promise<void>; /** * Set the center of rotation for rotate handle. * @param pt the new target point in world coordinates * @param lockTarget consider the target point locked for this tool instance * @param saveTarget save this target point for use between tool instances */ setTargetCenterWorld(pt: Point3d, lockTarget: boolean, saveTarget: boolean): void; updateTargetCenter(): void; processFirstPoint(ev: BeButtonEvent): boolean; processPoint(ev: BeButtonEvent, inDynamics: boolean): boolean; lensAngleMatches(angle: Angle, tolerance: number): boolean; get isZUp(): boolean; static getFocusPlaneNpc(vp: Viewport): number; static getDefaultTargetPointWorld(vp: Viewport): Point3d; /** Determine whether the supplied point is visible in this Viewport. */ isPointVisible(testPt: Point3d): boolean; /** @internal */ static computeFitRange(viewport: ScreenViewport): Range3d; static fitView(viewport: ScreenViewport, animateFrustumChange: boolean, options?: ViewChangeOptions & MarginOptions): void; /** @internal */ static fitViewWithGlobeAnimation(viewport: ScreenViewport, animateFrustumChange: boolean, options?: ViewChangeOptions & MarginOptions): void; static zoomToAlwaysDrawnExclusive(viewport: ScreenViewport, options?: ViewChangeOptions & MarginOptions): Promise<boolean>; setCameraLensAngle(lensAngle: Angle, retainEyePoint: boolean): ViewStatus; enforceZUp(pivotPoint: Point3d): boolean; changeViewport(vp?: ScreenViewport): void; } /** The tool that performs a Pan view operation * @public */ export declare class PanViewTool extends ViewManip { static toolId: string; static iconSpec: string; constructor(vp: ScreenViewport | undefined, oneShot?: boolean, isDraggingRequired?: boolean); protected get isExitAllowedOnReinitialize(): boolean; protected provideInitialToolAssistance(): void; } /** A tool that performs a Rotate view operation * @public */ export declare class RotateViewTool extends ViewManip { static toolId: string; static iconSpec: string; constructor(vp: ScreenViewport, oneShot?: boolean, isDraggingRequired?: boolean); protected get isExitAllowedOnReinitialize(): boolean; protected provideInitialToolAssistance(): void; } /** A tool that performs the look operation * @public */ export declare class LookViewTool extends ViewManip { static toolId: string; static iconSpec: string; constructor(vp: ScreenViewport, oneShot?: boolean, isDraggingRequired?: boolean); protected get isExitAllowedOnReinitialize(): boolean; protected provideInitialToolAssistance(): void; } /** A tool that performs the scroll operation * @public */ export declare class ScrollViewTool extends ViewManip { static toolId: string; static iconSpec: string; constructor(vp: ScreenViewport, oneShot?: boolean, isDraggingRequired?: boolean); protected get isExitAllowedOnReinitialize(): boolean; protected provideInitialToolAssistance(): void; } /** A tool that performs the zoom operation * @public */ export declare class ZoomViewTool extends ViewManip { static toolId: string; static iconSpec: string; constructor(vp: ScreenViewport, oneShot?: boolean, isDraggingRequired?: boolean); protected get isExitAllowedOnReinitialize(): boolean; protected provideInitialToolAssistance(): void; } /** A tool that performs the walk operation using mouse+keyboard or touch controls. * Keyboard and mouse controls are similar to those used by many video games: * - Mouse motion: look around. * - W, A, S, D (or arrow keys): move forward, left, right, or backward respectively. * - E, Q (or PgUp, PgDn): move up and down respectively. * - +, - (or scroll wheel): increase or decrease velocity. * @public */ export declare class LookAndMoveTool extends ViewManip { static toolId: string; static iconSpec: string; constructor(vp: ScreenViewport, oneShot?: boolean, isDraggingRequired?: boolean); protected get isExitAllowedOnReinitialize(): boolean; protected provideInitialToolAssistance(): void; provideToolAssistance(mainInstrKey: string): void; } /** A tool that performs the walk operation * @public */ export declare class WalkViewTool extends ViewManip { static toolId: string; static iconSpec: string; constructor(vp: ScreenViewport, oneShot?: boolean, isDraggingRequired?: boolean); protected get isExitAllowedOnReinitialize(): boolean; protected provideInitialToolAssistance(): void; provideToolAssistance(mainInstrKey: string): void; } /** A tool that performs the fly operation * @public */ export declare class FlyViewTool extends ViewManip { static toolId: string; static iconSpec: string; constructor(vp: ScreenViewport, oneShot?: boolean, isDraggingRequired?: boolean); protected get isExitAllowedOnReinitialize(): boolean; protected provideInitialToolAssistance(): void; provideToolAssistance(mainInstrKey: string): void; } /** A tool that performs a fit view * @public */ export declare class FitViewTool extends ViewTool { static toolId: string; static iconSpec: string; oneShot: boolean; doAnimate: boolean; isolatedOnly: boolean; constructor(viewport: ScreenViewport, oneShot: boolean, doAnimate?: boolean, isolatedOnly?: boolean); provideToolAssistance(): void; onDataButtonDown(ev: BeButtonEvent): Promise<EventHandled>; onPostInstall(): Promise<void>; doFit(viewport: ScreenViewport, oneShot: boolean, doAnimate?: boolean, isolatedOnly?: boolean): Promise<boolean>; } /** A tool that views a location on the background map from a satellite's perspective; the viewed location is derived from the position of the current camera's eye above the background map. Operates on the selected view. * @public */ export declare class ViewGlobeSatelliteTool extends ViewTool { static toolId: string; oneShot: boolean; doAnimate: boolean; constructor(viewport: ScreenViewport, oneShot?: boolean, doAnimate?: boolean); /** @internal */ onDataButtonDown(ev: BeButtonEvent): Promise<EventHandled>; /** @internal */ onPostInstall(): Promise<void>; private _beginSatelliteView; private _doSatelliteView; } /** A tool that views a location on the background map from a bird's eye perspective; the viewed location is derived from the position of the current camera's eye above the background map. Operates on the selected view. * @public */ export declare class ViewGlobeBirdTool extends ViewTool { static toolId: string; oneShot: boolean; doAnimate: boolean; constructor(viewport: ScreenViewport, oneShot?: boolean, doAnimate?: boolean); /** @internal */ onDataButtonDown(ev: BeButtonEvent): Promise<EventHandled>; /** @internal */ onPostInstall(): Promise<void>; private _beginDoBirdView; private _doBirdView; } /** A tool that views a location on the background map corresponding to a specified string. * This will either look down at the location using a bird's eye height, or, if a range is available, the entire range corresponding to the location will be viewed. * Operates on the selected view. * @public */ export declare class ViewGlobeLocationTool extends ViewTool { private _globalLocation?; static toolId: string; oneShot: boolean; doAnimate: boolean; constructor(viewport: ScreenViewport, oneShot?: boolean, doAnimate?: boolean); static get minArgs(): number; static get maxArgs(): undefined; /** This runs the tool based on the provided location arguments. * arguments: latitude longitude | string * If specified, the latitude and longitude arguments are numbers specified in degrees. * If specified, the string argument contains a location name. Examples of location name include named geographic areas like "Seattle, WA" or "Alaska", a specific address like "1600 Pennsylvania Avenue NW, Washington, DC 20500", or a place name like "Philadelphia Museum of Art". **/ parseAndRun(...args: string[]): Promise<boolean>; /** @internal */ onPostInstall(): Promise<void>; private _doLocationView; } /** A tool that views the current iModel on the background map so that the extent of the project is visible. Operates on the selected view. * @public */ export declare class ViewGlobeIModelTool extends ViewTool { static toolId: string; oneShot: boolean; doAnimate: boolean; constructor(viewport: ScreenViewport, oneShot?: boolean, doAnimate?: boolean); /** @internal */ onDataButtonDown(ev: BeButtonEvent): Promise<EventHandled>; /** @internal */ onPostInstall(): Promise<void>; private _doIModelView; } /** A tool that rotates the view to one of the standard views. * @public */ export declare class StandardViewTool extends ViewTool { private _standardViewId; static toolId: string; static iconSpec: string; constructor(viewport: ScreenViewport, _standardViewId: StandardViewId); onPostInstall(): Promise<void>; } /** A tool that performs a Window-area view operation * @public */ export declare class WindowAreaTool extends ViewTool { static toolId: string; static iconSpec: string; private _haveFirstPoint; private _firstPtWorld; private _secondPtWorld; private _lastPtView?; private _corners; private _shapePts; private _fillColor; onPostInstall(): Promise<void>; onReinitialize(): Promise<void>; onResetButtonUp(ev: BeButtonEvent): Promise<EventHandled>; provideToolAssistance(): void; onDataButtonDown(ev: BeButtonEvent): Promise<EventHandled>; onMouseMotion(ev: BeButtonEvent): Promise<void>; onTouchTap(ev: BeTouchEvent): Promise<EventHandled>; onTouchMoveStart(ev: BeTouchEvent, startEv: BeTouchEvent): Promise<EventHandled>; onTouchMove(ev: BeTouchEvent): Promise<void>; onTouchComplete(ev: BeTouchEvent): Promise<void>; onTouchCancel(ev: BeTouchEvent): Promise<void>; private computeWindowCorners; decorate(context: DecorateContext): void; private doManipulation; } /** @internal */ export declare class DefaultViewTouchTool extends ViewManip implements Animator { static toolId: string; private readonly _lastPtView; private readonly _startPtWorld; private readonly _startPtView; private readonly _frustum; private _startDirection; private _startDistance; private _startTouchCount; private _inertiaVec?; private _singleTouch; private _duration; private _end; private _rotate2dDisabled; private _rotate2dThreshold?; private _only2dManipulations; /** Move this handle during the inertia duration */ animate(): boolean; interrupt(): void; constructor(startEv: BeTouchEvent, ev: BeTouchEvent, only2dManipulations?: boolean); onStart(ev: BeTouchEvent): void; private computeZoomRatio; private computeRotation; private handle2dPan; private handle2dRotateZoom; private handle3dRotate; private handle3dPanZoom; private handleEvent; private perform; onDataButtonDown(_ev: BeButtonEvent): Promise<EventHandled>; onDataButtonUp(_ev: BeButtonEvent): Promise<EventHandled>; onTouchStart(ev: BeTouchEvent): Promise<void>; onTouchMove(ev: BeTouchEvent): Promise<void>; onTouchCancel(_ev: BeTouchEvent): Promise<void>; onTouchComplete(_ev: BeTouchEvent): Promise<void>; } /** A tool that performs view undo operation. An application could also just call Viewport.doUndo directly, creating a ViewTool isn't required. * @public */ export declare class ViewUndoTool extends ViewTool { static toolId: string; static iconSpec: string; onPostInstall(): Promise<void>; } /** A tool that performs view redo operation. An application could also just call Viewport.doRedo directly, creating a ViewTool isn't required. * @public */ export declare class ViewRedoTool extends ViewTool { static toolId: string; static iconSpec: string; onPostInstall(): Promise<void>; } /** A tool that toggles the camera on/off in a spatial view * @public */ export declare class ViewToggleCameraTool extends ViewTool { static toolId: string; static iconSpec: string; onInstall(): Promise<boolean>; onPostInstall(): Promise<void>; } /** A tool that sets the view camera by two points. This is a PrimitiveTool and not a ViewTool to allow the view to be panned, zoomed, and rotated while defining the points. * To show tool settings for specifying camera and target heights above the snap point, make sure formatting and parsing data are cached before the tool starts * by calling QuantityFormatter.onInitialized at app startup. * @public */ export declare class SetupCameraTool extends PrimitiveTool { static toolId: string; static iconSpec: string; viewport?: ScreenViewport; protected _haveEyePt: boolean; protected _eyePtWorld: Point3d; protected _targetPtWorld: Point3d; isCompatibleViewport(vp: Viewport | undefined, isSelectedViewChange: boolean): boolean; isValidLocation(_ev: BeButtonEvent, _isButtonEvent: boolean): boolean; requireWriteableTarget(): boolean; onPostInstall(): Promise<void>; onUnsuspend(): Promise<void>; protected setupAndPromptForNextAction(): void; onResetButtonUp(_ev: BeButtonEvent): Promise<EventHandled>; protected provideToolAssistance(): void; onRestartTool(): Promise<void>; protected getAdjustedEyePoint(): Point3d; protected getAdjustedTargetPoint(): Point3d; onDataButtonDown(ev: BeButtonEvent): Promise<EventHandled>; onMouseMotion(ev: BeButtonEvent): Promise<void>; static drawCameraFrustum(context: DecorateContext, vp: ScreenViewport, eyePtWorld: Point3d, targetPtWorld: Point3d, eyeSnapPtWorld?: Point3d, targetSnapPtWorld?: Point3d): void; decorate(context: DecorateContext): void; decorateSuspended(context: DecorateContext): void; private doManipulation; private _useCameraHeightProperty; get useCameraHeightProperty(): DialogProperty<boolean>; get useCameraHeight(): boolean; set useCameraHeight(option: boolean); private _cameraHeightProperty; get cameraHeightProperty(): DialogProperty<number>; get cameraHeight(): number; set cameraHeight(value: number); private _useTargetHeightProperty; get useTargetHeightProperty(): DialogProperty<boolean>; get useTargetHeight(): boolean; set useTargetHeight(value: boolean); private _targetHeightProperty; get targetHeightProperty(): DialogProperty<number>; get targetHeight(): number; set targetHeight(value: number); protected getToolSettingLockProperty(property: DialogProperty<any>): DialogProperty<boolean> | undefined; applyToolSettingPropertyChange(updatedValue: DialogPropertySyncItem): Promise<boolean>; supplyToolSettingsProperties(): DialogItem[] | undefined; } /** A tool that sets a walk tool starting position by a floor point and look direction. This is a PrimitiveTool and not a ViewTool to allow the view to be panned, zoomed, and rotated while defining the points. * @public */ export declare class SetupWalkCameraTool extends PrimitiveTool { static toolId: string; static iconSpec: string; viewport?: ScreenViewport; protected _haveEyePt: boolean; protected _eyePtWorld: Point3d; protected _targetPtWorld: Point3d; isCompatibleViewport(vp: Viewport | undefined, isSelectedViewChange: boolean): boolean; isValidLocation(_ev: BeButtonEvent, _isButtonEvent: boolean): boolean; requireWriteableTarget(): boolean; onPostInstall(): Promise<void>; onUnsuspend(): Promise<void>; protected setupAndPromptForNextAction(): void; onResetButtonUp(_ev: BeButtonEvent): Promise<EventHandled>; protected provideToolAssistance(): void; onRestartTool(): Promise<void>; protected getAdjustedEyePoint(): Point3d; protected getAdjustedTargetPoint(): Point3d; onDataButtonDown(ev: BeButtonEvent): Promise<EventHandled>; onMouseMotion(ev: BeButtonEvent): Promise<void>; private static getFigurePoints; private static getFigureTransform; static drawFigure(context: DecorateContext, vp: Viewport, groundPt: Point3d, eyeHeight: number): void; decorate(context: DecorateContext): void; decorateSuspended(context: DecorateContext): void; private doManipulation; } export {}; //# sourceMappingURL=ViewTool.d.ts.map