UNPKG

@itwin/core-frontend

Version:
90 lines 4.63 kB
/** @packageDocumentation * @module Tools */ import { BriefcaseConnection } from "../BriefcaseConnection"; import { IModelConnection } from "../IModelConnection"; import { Viewport } from "../Viewport"; import { BeButtonEvent, InteractiveTool } from "./Tool"; /** The PrimitiveTool class can be used to implement tools to create or modify geometric elements. * @see [Writing a PrimitiveTool]($docs/learning/frontend/primitivetools.md) * @public * @extensions */ export declare abstract class PrimitiveTool extends InteractiveTool { /** The viewport within which the tool operates. * @note This property is only initialized if [[run]] returns `true`, causing the tool to be installed. */ targetView?: Viewport; private _targetModelId?; get targetModelId(): string | undefined; set targetModelId(v: string | undefined); targetIsLocked: boolean; /** Get the iModel on which this tool operates. * @note The iModel is obtained from [[targetView]], so should only be invoked if the tool installed successfully. */ get iModel(): IModelConnection; /** Get the briefcase on which this tool operates, if the tool has successfully installed and the target [[iModel]] is a briefcase. */ get briefcase(): BriefcaseConnection | undefined; /** * Establish this tool as the active PrimitiveTool. * @return true if this tool was installed (though it may have exited too) * @note If you override this method you **must** call `super.run` and return false if it returns false. */ run(..._args: any[]): Promise<boolean>; /** Determine whether the supplied Viewport is compatible with this tool. * @param vp the Viewport to check */ isCompatibleViewport(vp: Viewport | undefined, isSelectedViewChange: boolean): boolean; /** * Checks that the adjusted point from the supplied button event is within the project extents for spatial views. The range of physical geometry * should always be fully inside the project extents. Only checking the adjusted point won't absolutely guarantee that a tool doesn't create/move geometry * outside the project extents, but it will be sufficient to handle most cases and provide good feedback to the user. * @return true if ev is acceptable. */ isValidLocation(ev: BeButtonEvent, isButtonEvent: boolean): boolean; /** Called on data button down event to lock the tool to its current target model. */ autoLockTarget(): void; /** Returns the prompt based on the tool's current state. */ getPrompt(): string; /** Called from isCompatibleViewport to check for a read only iModel, which is not a valid target for tools that create or modify elements. */ requireWriteableTarget(): boolean; /** * Called when active view changes. Tool may choose to restart or exit based on current view type. * @param _previous The previously active view. * @param current The new active view. */ onSelectedViewportChanged(_previous: Viewport | undefined, current: Viewport | undefined): Promise<void>; /** * Called when an external event may invalidate the current tool's state. * Examples are undo, which may invalidate any references to elements, or an incompatible active view change. * The active tool is expected to call installTool with a new instance, or exitTool to start the default tool. * ```ts * const tool = new MyPrimitiveTool(); * if (!await tool.run()) * return this.exitTool(); // Don't leave current instance active if new instance rejects install... * ``` */ abstract onRestartTool(): Promise<void>; /** * Called to reset tool to initial state. PrimitiveTool implements this method to call onRestartTool. */ onReinitialize(): Promise<void>; exitTool(): Promise<void>; /** * Called to reverse to a previous tool state (ex. undo last data button). * @return false to instead reverse the most recent transaction. */ onUndoPreviousStep(): Promise<boolean>; /** @internal */ undoPreviousStep(): Promise<boolean>; /** * Called to reinstate to a previous tool state (ex. redo last data button). * @return false to instead reinstate the most recent transaction. */ onRedoPreviousStep(): Promise<boolean>; /** @internal */ redoPreviousStep(): Promise<boolean>; /** If this tool is editing a briefcase, commits any elements that the tool has changed, supplying the tool flyover for the undo description. */ saveChanges(): Promise<void>; } //# sourceMappingURL=PrimitiveTool.d.ts.map