OperatorStack

class cee.OperatorStack()

The OperatorStack manages registered Operator instances for a view. Any active operators on the stack will be called in a “Last In, First Called” order. An operator event listener method (i.e. onMouseDown, onWheel, onKeyDown, etc.) will return an OperatorEventStatus to indicate whether the particular event should be propagated to the next operator in the stack, or if it should be stopped.

Since multiple operators can be added to the stack and respond to the same single event, the order of operators matters and it is important to understand an operator propagates different events. It is recommend that more global operators, such as the NavigationOperator, are added first, and more specific and local operators are added last. This way, local operations can be captured and handled before they are propagated to the more global operations, if so desired.

When a new operator is pushed to the stack, the operator stack will track the reference to that operator object. You can then use the OperatorStack.get method to retrieve a reference to the operator object by name (regardless of whether that operator object is active and on the stack or not). The prevents the need to instantiate and set up the same operator again, and preserves the state of any setup operators. If you push a new instance of an operator with a previously used name, the old operator reference will be replaced with the new one.

By default, the OperatorStack is empty when a View is created. It is the developers responsibility to add any desired default operators in your application. You can remove operators with the OperatorStack.pop, OperatorStack.remove, or OperatorStack.clear methods.

Accessors

cee.OperatorStack.activeOperators()
get activeOperators(): Operator[]

Returns the array of active Operator objects

Returns: Operator[]

cee.OperatorStack.hotKeyOperator()
get hotKeyOperator(): Operator

Sets the hot key operator for this operator stack. The hot key (Alt/Opt) can be held to temporarily use this operator without reordering the stack. The operator must already be in the stack to be used with the hot key. Other stack operators will not be called while the hot key is held. To remove the hot key operator designation, but keep the operator on the stack, set the hot key operator to null.

Returns: Operator

set hotKeyOperator(operator: Operator): void

Parameters

operator: Operator

Returns: void

Methods

cee.OperatorStack.clear()
clear(): void

Removes all operators from the stack

Returns: void

cee.OperatorStack.get()
get(operatorName: S): GetOperatorType

Returns a reference to the operator object with the given name and type. The desired operator does not need to be active on the stack. If the operator was pushed to the stack during the lifetime of the view, it is registered and the reference to the operator can be returned.

If the operator is not found, null will be returned. You can always check if the operator is registered by using the OperatorStack.has method

Exmaple usage:

// Standard Operator
const standardOperator = view.operators.get(cee.StandardOperator.OPERATOR_ENUM);

// Custom User-Provided Operator
const myCustomOperator = view.operators.get(MyCustomOperatorName) as MyCustomOperator;
const myCustomOperator = view.operators.get<MyCustomOperator>(MyCustomOperatorName);

// Generic Operator
const generic = view.operators.get("MyOperatorName");  // Returns Operator type w/o cast

Parameters

operatorName: S

Returns: GetOperatorType

cee.OperatorStack.has()
has(operator: string): boolean

Returns true if the operator has been registered with the operator stack.

Parameters

operator: string

Returns: boolean

cee.OperatorStack.indexOf()
indexOf(operator: Operator): number

Returns the index of an operator on the stack If the operator is not found on the stack, -1 is returned.

Parameters

operator: Operator

Returns: number

cee.OperatorStack.peek()
peek(): Operator

Returns the operator at the top of the stack

Returns: Operator

cee.OperatorStack.pop()
pop(): Operator

Removes an operator from the top of the stack

Returns: Operator

cee.OperatorStack.push()
push(operator: Operator, setAsHotKeyOperator: boolean): boolean

Adds an operator on the stack if it’s not already on the stack

Parameters

operator: Operator

setAsHotKeyOperator: boolean

Returns: boolean

cee.OperatorStack.remove()
remove(operatorInput: (string | Operator)): void

Removes an operator from the stack

Parameters

operatorInput: (string | Operator)

Returns: void

cee.OperatorStack.set()
set(operator: Operator, position: number): boolean

Sets an operator to the 0 based index position on the stack. If there is already an operator in that position, it is replaced. If the operator is already on the stack, it is moved to the requested position.

Parameters

operator: Operator

position: number

Returns: boolean

cee.OperatorStack.size()
size(): number

Returns the operator stack size

Returns: number