PrimitiveTool Class

The PrimitiveTool class can be used to implement tools to create or modify geometric elements.

see Writing a PrimitiveTool

Extends

Extended by

Methods

Name Description
constructor(..._args: any[]): PrimitiveTool    
autoLockTarget(): void Called on data button down event to lock the tool to its current target model.  
exitTool(): void    
getPrompt(): string Returns the prompt based on the tool's current state.  
isCompatibleViewport(vp: Viewport | undefined, isSelectedViewChange: boolean): boolean Determine whether the supplied Viewport is compatible with this tool.  
isValidLocation(ev: BeButtonEvent, isButtonEvent: boolean): boolean Checks that the adjusted point from the supplied button event is within the project extents for spatial views.  
onRedoPreviousStep(): Promise<boolean> Called to reinstate to a previous tool state (ex.  
onReinitialize(): void Called to reset tool to initial state.  
onRestartTool(): void Abstract Called when an external event may invalidate the current tool's state.  
onSelectedViewportChanged(_previous: Viewport | undefined, current: Viewport | undefined): void Called when active view changes.  
onUndoPreviousStep(): Promise<boolean> Called to reverse to a previous tool state (ex.  
requireWriteableTarget(): boolean Called from isCompatibleViewport to check for a read only iModel, which is not a valid target for tools that create or modify elements.  
run(..._args: any[]): boolean Establish this tool as the active PrimitiveTool.  
saveChanges(): Promise<void> Tools need to call SaveChanges to commit any elements they have added/changes they have made.  

Inherited methods

Name Inherited from Description
applyToolSettingPropertyChange(_updatedValue: ToolSettingsPropertySyncItem): boolean InteractiveTool Used to receive property changes from UI.
beginDynamics(): void InteractiveTool Call to initialize dynamics mode.
changeLocateState(enableLocate: boolean, enableSnap?: false | true, cursor?: string, coordLockOvr?: CoordinateLockOverrides): void InteractiveTool Helper method to keep the view cursor, display of locate circle, and coordinate lock overrides consistent with AccuSnap.isLocateEnabled and AccuSnap.isSnapEnabled.
decorate(_context: DecorateContext): void InteractiveTool Called to allow an active tool to display non-element decorations in overlay mode.
decorateSuspended(_context: DecorateContext): void InteractiveTool Called to allow a suspended tool to display non-element decorations in overlay mode.
endDynamics(): void InteractiveTool Call to terminate dynamics mode.
filterHit(_hit: HitDetail, _out?: LocateResponse): Promise<LocateFilterStatus> InteractiveTool Invoked to allow tools to filter which elements can be located.
getCurrentButtonEvent(ev: BeButtonEvent): void InteractiveTool Fill the supplied button event from the current cursor location.
getDecorationGeometry(_hit: HitDetail): GeometryStreamProps | undefined InteractiveTool Called to allow snapping to pickable decoration geometry.
getToolTip(_hit: HitDetail): Promise<HTMLElement | string> InteractiveTool Invoked before the locate tooltip is displayed to retrieve the information about the located element.
initLocateElements(enableLocate: boolean = true, enableSnap?: false | true, cursor?: string, coordLockOvr?: CoordinateLockOverrides): void InteractiveTool Helper method for tools that need to locate existing elements.
onCleanup(): void InteractiveTool Invoked when the tool becomes no longer active, to perform additional cleanup logic
onDataButtonDown(_ev: BeButtonEvent): Promise<EventHandled> InteractiveTool Invoked when the data button is pressed.
onDataButtonUp(_ev: BeButtonEvent): Promise<EventHandled> InteractiveTool Invoked when the data button is released.
onDynamicFrame(_ev: BeButtonEvent, _context: DynamicsContext): void InteractiveTool Called to allow Tool to display dynamic elements.
onInstall(): boolean InteractiveTool Override to execute additional logic when tool is installed.
onKeyTransition(_wentDown: boolean, _keyEvent: KeyboardEvent): Promise<EventHandled> InteractiveTool Called when any key is pressed or released.
onMiddleButtonDown(_ev: BeButtonEvent): Promise<EventHandled> InteractiveTool Invoked when the middle mouse button is pressed.
onMiddleButtonUp(_ev: BeButtonEvent): Promise<EventHandled> InteractiveTool Invoked when the middle mouse button is released.
onModifierKeyTransition(_wentDown: boolean, _modifier: BeModifierKeys, _event: KeyboardEvent): Promise<EventHandled> InteractiveTool Called when Control, Shift, or Alt modifier keys are pressed or released.
onMouseEndDrag(ev: BeButtonEvent): Promise<EventHandled> InteractiveTool Invoked when the button is released after onMouseStartDrag.
onMouseMotion(_ev: BeButtonEvent): Promise<void> InteractiveTool Invoked when the cursor is moving
onMouseStartDrag(_ev: BeButtonEvent): Promise<EventHandled> InteractiveTool Invoked when the cursor begins moving while a button is depressed.
onMouseWheel(_ev: BeWheelEvent): Promise<EventHandled> InteractiveTool Invoked when the mouse wheel moves.
onPostInstall(): void InteractiveTool Override to execute additional logic after tool becomes active
onResetButtonDown(_ev: BeButtonEvent): Promise<EventHandled> InteractiveTool Invoked when the reset button is pressed.
onResetButtonUp(_ev: BeButtonEvent): Promise<EventHandled> InteractiveTool Invoked when the reset button is released.
onSuspend(): void InteractiveTool Notification of a ViewTool or InputCollector starting and this tool is being suspended.
onTouchCancel(_ev: BeTouchEvent): Promise<void> InteractiveTool Called when a touch point is interrupted in some way and needs to be dropped from the list of target touches.
onTouchComplete(_ev: BeTouchEvent): Promise<void> InteractiveTool Called when the last touch point is removed from the surface completing the current gesture.
onTouchEnd(_ev: BeTouchEvent): Promise<void> InteractiveTool Called when user removes a touch point by lifting a finger or stylus from the surface.
onTouchMove(_ev: BeTouchEvent): Promise<void> InteractiveTool Called when a touch point moves along the surface.
onTouchMoveStart(_ev: BeTouchEvent, _startEv: BeTouchEvent): Promise<EventHandled> InteractiveTool Called after at least one touch point has moved for an appreciable time and distance along the surface to not be considered a tap.
onTouchStart(_ev: BeTouchEvent): Promise<void> InteractiveTool Called when user adds a touch point by placing a finger or stylus on the surface.
onTouchTap(_ev: BeTouchEvent): Promise<EventHandled> InteractiveTool Called when touch point(s) are added and removed from a surface within a small time window without any touch point moving.
onUnsuspend(): void InteractiveTool Notification of a ViewTool or InputCollector exiting and this tool is being unsuspended.
parseAndRun(..._args: string[]): boolean Tool Run this instance of a tool using a series of string arguments.
supplyToolSettingsProperties(): ToolSettingsPropertyRecord[] | undefined InteractiveTool Used to supply list of properties that can be used to generate ToolSettings.
syncToolSettingsProperties(syncData: ToolSettingsPropertySyncItem[]): void InteractiveTool Called by tool to synchronize the UI with property changes made by tool.
testDecorationHit(_id: string): boolean InteractiveTool Called to support operations on pickable decorations, like snapping.
register(namespace?: I18NNamespace, i18n?: I18N): void Static Tool Register this Tool class with the ToolRegistry.

Properties

Name Type Description
iModel Accessor ReadOnly IModelConnection Get the iModel the tool is operating against.  
targetIsLocked boolean    
targetModelId undefined | string    
targetView undefined | Viewport    

Inherited properties

Name Type Inherited from Description
description Accessor ReadOnly string Tool Get the localized description string from this Tool's class
description Accessor StaticReadOnly string Tool Get the localized description for this Tool class. This returns the value of "tools." + this.toolId + ".description" from
its registered Namespace (e.g. "en/MyApp.json"). If that key is not in the localization namespace,
Tool.flyover is returned.
englishKeyin Accessor StaticReadOnly string Tool Get the English keyin string for this Tool class. This returns the value of "tools." + this.toolId + ".keyin" from
its registered Namespace (e.g. "en/MyApp.json").
flyover Accessor ReadOnly string Tool Get the localized flyover string from this Tool's class
flyover Accessor StaticReadOnly string Tool Get the localized flyover for this Tool class. This returns the value of "tools." + this.toolId + ".flyover" from
its registered Namespace (e.g. "en/MyApp.json"). If that key is not in the localization namespace,
Tool.keyin is returned.
hidden Static boolean Tool If true, this Tool will not appear in the list from ToolRegistry.getToolList.
i18n Static I18N Tool The internationalization services instance used to translate strings from the namespace.
iconSpec Accessor ReadOnly string Tool Get the iconSpec from this Tool's class.
iconSpec Static string Tool The icon for this Tool.
isDynamicsStarted Accessor ReadOnly boolean InteractiveTool Call to find out if dynamics are currently active.
keyin Accessor ReadOnly string Tool Get the localized keyin string from this Tool's class
keyin Accessor StaticReadOnly string Tool Get the localized keyin string for this Tool class. This returns the value of "tools." + this.toolId + ".keyin" from
its registered Namespace (e.g. "en/MyApp.json").
maxArgs Accessor StaticReadOnly number | undefined Tool The maximum number of arguments allowed by Tool.parseAndRun, or undefined if there is no maximum.
If subclasses override Tool.parseAndRun, they should also override this method to indicate the maximum
number of arguments their implementation expects.
minArgs Accessor StaticReadOnly number Tool The minimum number of arguments allowed by Tool.parseAndRun. If subclasses override Tool.parseAndRun, they should also
override this method to indicate the minimum number of arguments their implementation expects. UI controls can use
this information to ensure the tool has enough information to execute.
namespace Static I18NNamespace Tool The I18NNamespace that provides localized strings for this Tool.
receivedDownEvent boolean InteractiveTool Used to avoid sending tools up events for which they did not receive the down event.
toolId Accessor ReadOnly string Tool Get the toolId string for this Tool class. This string is used to identify the Tool in the ToolRegistry and is used to localize
the keyin, description, etc. from the current locale.
toolId Static string Tool The unique string that identifies this tool.

Defined in

Last Updated: 05 June, 2020