UNPKG

@itwin/core-frontend

Version:
273 lines • 11.8 kB
/** @packageDocumentation * @module LocatingElements */ import { BeDuration, Id64Arg, Id64Set } from "@itwin/core-bentley"; import { Point3d, XAndY } from "@itwin/core-geometry"; import { HitListHolder, LocateResponse, SnapStatus } from "./ElementLocateManager"; import { HitDetail, HitList, IntersectDetail, SnapDetail, SnapMode } from "./HitDetail"; import { CanvasDecoration } from "./render/CanvasDecoration"; import { SpriteLocation } from "./Sprites"; import { BeButtonEvent, BeTouchEvent } from "./tools/Tool"; import { DecorateContext } from "./ViewContext"; import { Decorator } from "./ViewManager"; import { ScreenViewport, Viewport } from "./Viewport"; /** Virtual cursor for using AccuSnap with touch input. * @internal */ export declare class TouchCursor implements CanvasDecoration { position: Point3d; viewport: Viewport; protected _offsetPosition: Point3d; protected _size: number; protected _yOffset: number; protected _isSelected: boolean; protected _isDragging: boolean; protected _inTouchTap: boolean; protected constructor(vp: ScreenViewport); protected setPosition(vp: Viewport, worldLocation: Point3d): boolean; protected drawHandle(ctx: CanvasRenderingContext2D, filled: boolean): void; drawDecoration(ctx: CanvasRenderingContext2D): void; protected isSelected(pt: XAndY): boolean; isButtonHandled(ev: BeButtonEvent): boolean; doTouchMove(ev: BeTouchEvent): boolean; doTouchMoveStart(ev: BeTouchEvent, startEv: BeTouchEvent): boolean; doTouchStart(ev: BeTouchEvent): void; doTouchEnd(ev: BeTouchEvent): void; doTouchTap(ev: BeTouchEvent): Promise<boolean>; static createFromTouchTap(ev: BeTouchEvent): TouchCursor | undefined; } /** AccuSnap is an aide for snapping to interesting points on elements or decorations as the cursor moves over them. * @see [Using AccuSnap]($docs/learning/frontend/primitivetools.md#AccuSnap) * @public * @extensions */ export declare class AccuSnap implements Decorator { /** Currently active hit */ currHit?: HitDetail; /** Current list of hits. */ aSnapHits?: HitList<HitDetail>; /** Views that need to be flashed */ readonly needFlash: Set<Viewport>; /** Views that are already flashed */ readonly areFlashed: Set<Viewport>; /** The "+" that indicates where the snap point is */ readonly cross: SpriteLocation; /** The icon that indicates what type of snap is active */ readonly icon: SpriteLocation; /** The icon that indicates an error */ readonly errorIcon: SpriteLocation; /** Reason key for last error */ errorKey?: string; /** localized message explaining why last error was generated. */ explanation?: string; /** Number of times "suppress" has been called -- unlike suspend this is not automatically cleared by tools */ private _suppressed; /** Location of cursor when we last checked for motion */ private readonly _lastCursorPos; /** @internal */ readonly toolState: AccuSnap.ToolState; /** @internal */ protected _settings: AccuSnap.Settings; /** @internal */ touchCursor?: TouchCursor; /** Current request for tooltip message. */ private _toolTipPromise?; /** @internal */ onInitialized(): void; private get _searchDistance(); private get _hotDistanceInches(); /** Whether locate of elements under the cursor is enabled by the current InteractiveTool. */ get isLocateEnabled(): boolean; /** Whether snapping to elements under the cursor is enabled by the current InteractiveTool. */ get isSnapEnabled(): boolean; /** Whether the user setting for snapping is enabled. Snapping is done only when both the user and current InteractiveTool have enabled it. */ get isSnapEnabledByUser(): boolean; /** AccuSnap user settings */ get userSettings(): AccuSnap.Settings; private isFlashed; private needsFlash; private setNeedsFlash; private setIsFlashed; private clearIsFlashed; private static toSnapDetail; /** Currently active snap */ getCurrSnapDetail(): SnapDetail | undefined; /** Determine whether there is a current hit that is *hot*. */ get isHot(): boolean; /** Optional ids to never flash. Useful for tools like "trim curve" that won't want a flashed segment to obscure a result preview. * @note Cleared when a primitive or view tool is started and saved/restored when a primitive tool is suspended/unsuspended. * @public */ neverFlash(ids?: Id64Arg): void; /** @internal */ destroy(): void; private get _doSnapping(); private get _isSnapSuspended(); /** Get the current snap divisor to use to use for SnapMode.NearestKeypoint. * @public */ get keypointDivisor(): number; /** Get the current active SnapModes. SnapMode position determines priority, with the first entry being the highest. The SnapDetail will be returned for the first SnapMode that produces a hot snap. * @public */ getActiveSnapModes(): SnapMode[]; /** Can be implemented by a subclass of AccuSnap to implement a SnapMode override that applies only to the next point. * This method will be called whenever a new tool is installed and on button events. * @internal */ synchSnapMode(): void; /** Check whether current tentative snap has valid curve geometry for finding extended intersections. */ private get _searchForExtendedIntersections(); /** * Check to see whether its appropriate to generate an AccuSnap point, given the current user * and command settings, and whether a tentative point is currently active. */ get isActive(): boolean; private initializeForCheckMotion; /** Clear the current AccuSnap info. */ clear(): void; /** @internal */ setCurrHit(newHit?: HitDetail): void; /** flash a hit in a single view. */ private flashHitInView; private setNeedsFlashView; /** flash a hit in its view. */ private setFlashHit; /** @internal */ erase(): void; private showElemInfo; private showLocateMessage; /** @internal */ displayToolTip(viewPt: XAndY, vp: ScreenViewport, uorPt?: Point3d): void; /** @internal */ clearToolTip(ev?: BeButtonEvent): void; /** Display the sprites for the current snap to indicate its position on the screen and what snap mode it represents. */ private showSnapSprite; private static adjustIconLocation; /** try to indicate what's wrong with the current point (why we're not snapping). */ private showSnapError; private clearSprites; /** determine whether a hit should be hilited or not. */ private hitShouldBeHilited; private unFlashViews; /** @internal */ adjustPointIfHot(pt: Point3d, view: Viewport): void; /** Implemented by sub-classes to update ui to show current enabled state. * @internal */ onEnabledStateChange(_isEnabled: boolean, _wasEnabled: boolean): void; /** @internal */ getHitAndList(holder: HitListHolder): HitDetail | undefined; private initCmdState; /** @internal */ suspend(doSuspend: boolean): void; /** @internal */ suppress(doSuppress: boolean): number; /** Turn AccuSnap on or off */ enableSnap(yesNo: boolean): void; /** @internal */ intersectXY(tpSnap: SnapDetail, second: SnapDetail): IntersectDetail | undefined; private static doPostProcessSnapMode; /** @internal */ static requestSnap(thisHit: HitDetail, snapModes: SnapMode[], hotDistanceInches: number, keypointDivisor: number, hitList?: HitList<HitDetail>, out?: LocateResponse): Promise<SnapDetail | undefined>; private getAccuSnapDetail; /** Request a snap from the backend for the supplied HitDetail. * @param hit The HitDetail to snap to. * @param snapMode Optional SnapMode, uses active snap modes if not specified. * @return A Promise for the SnapDetail or undefined if no snap could be created. */ doSnapRequest(hit: HitDetail, snapMode?: SnapMode): Promise<SnapDetail | undefined>; private findHits; private findLocatableHit; /** When in auto-locate mode, advance to the next hit without searching again. * @internal */ resetButton(): Promise<SnapStatus>; /** Find the best snap point according to the current cursor location * @internal */ onMotion(ev: BeButtonEvent): Promise<void>; /** @internal */ onPreButtonEvent(ev: BeButtonEvent): boolean; /** @internal */ onTouchStart(ev: BeTouchEvent): void; /** @internal */ onTouchEnd(ev: BeTouchEvent): void; /** @internal */ onTouchCancel(ev: BeTouchEvent): void; /** @internal */ onTouchMove(ev: BeTouchEvent): boolean; /** @internal */ onTouchMoveStart(ev: BeTouchEvent, startEv: BeTouchEvent): boolean; /** @internal */ get wantVirtualCursor(): boolean; /** @internal */ onTouchTap(ev: BeTouchEvent): Promise<boolean>; private flashElements; /** @internal */ decorate(context: DecorateContext): void; private clearElemFromHitList; /** @internal */ clearIfElement(sourceId: string): void; /** Enable locating elements. * @public */ enableLocate(yesNo: boolean): void; /** Called whenever a new [[Tool]] is started. * @internal */ onStartTool(): void; /** * Force AccuSnap to reevaluate the snap at the current cursor location. * This is useful of an application changes the snap mode and wants AccuSnap to choose it immediately, without * requiring the user to move the mouse. * @internal */ reEvaluate(): Promise<void>; } /** TentativeOrAccuSnap returns information about an active snap generated by either [[AccuSnap]] or [[TentativePoint]]. * @public */ export declare class TentativeOrAccuSnap { /** @return true if AccuSnap is *hot* or TentativePoint is active and snapped to pickable geometry. */ static get isHot(): boolean; /** Get the current snap from either AccuSnap or TentativePoint. * @param checkIsHot true to only return the snap from AccuSnap when it is *hot*. * @return The current snap from AccuSnap, TentativePoint, or undefined. */ static getCurrentSnap(checkIsHot?: boolean): SnapDetail | undefined; /** @return The current snap location from AccuSnap or TentativePoint */ static getCurrentPoint(): Point3d; /** @return The current snap Viewport from AccuSnap or TentativePoint */ static getCurrentView(): ScreenViewport | undefined; } /** @public */ export declare namespace AccuSnap { class ToolState { enabled: boolean; locate: boolean; suspended: number; neverFlash?: Id64Set; setFrom(other: ToolState): void; clone(): ToolState; } class Settings { /** How far cursor can be from snap location (relative to snap aperture) and be considered a hot snap */ hotDistanceFactor: number; /** When moving along an element, affects the affinity for snapping to the same curve as the previous snap */ stickyFactor: number; /** Factor applied to locate aperture when snapping is enabled and used to pick snap candidates */ searchDistance: number; /** Whether the snapped element is also hilited when the snap is not hot */ hiliteColdHits: boolean; /** Enables snap on cursor motion when true, only snap using Tentative snap when false */ enableFlag: boolean; /** Whether to show a tooltip for snap and element locate */ toolTip: boolean; /** Delay before tooltip appears */ toolTipDelay: BeDuration; /** Curve segment divisor used by SnapMode.NearestKeypoint */ keypointDivisor: number; } } //# sourceMappingURL=AccuSnap.d.ts.map