Standard operators
Overview
In order for the user to interact with the scene, your application needs to respond to various input events that might be coming from the mouse, the keyboard, or a touch device. While you are free to handle user input yourself and make calls into the Web Viewer API in response to them, HOOPS Communicator provides the concept of “operators” for this purpose. An operator is a hook into the user input event loop with a predefined structure to respond to user input in a sensible way.
For example, one operator might handle a mouse click which selects geometry. Another might handle keystrokes. Communicator can have any number of operators active at the same time.
The Web Viewer offers a set of standard operators for the most common user interactions such as camera manipulation, selection, and inserting markup, but you can also write your own operators with completely custom functionality.
Built-in operators
The Web Viewer supports several predefined, standard operators in various categories. All those operators are available with fully readable source-code. We encourage you to browse through the source code to understand the design patterns when writing operator code.
The OperatorManager maintains a stack of operators that are all active at the same time and receive events based on their position in the stack with the operator pushed on the stack last getting to “see” the events first. When starting the Web Viewer this is what the operator stack looks like:
Navigate
Select
CuttingPlane
Handles
NavCube
AxisTriad
Activating a predefined operator
The Communicator.OperatorId enum stores a list of all predefined operator IDs. To activate one of them, simply use one of the operator IDs with the push or set functions of the OperatorManager:
hwv.operatorManager.set(Communicator.OperatorId.KeyboardWalk, 0);
As with the custom operators, you need to be mindful of how an activated operator interacts with other operators already on the stack. For example, if you want to use one of the walk operators you should not just push it to the top of the stack but instead, replace the existing camera-related operator (Navigate in the default configuration) with it. If in doubt it is best to experiment to see how the predefined operators interact with each other and define your operator stack accordingly.
Operator categories
The built-in operators fall into a few major categories:
Camera
Navigate
Orbit
Pan
Zoom
Turntable
WalkMode
Walk
KeyboardWalk
Selection
Select
AreaSelect
RayDrillSelect
Markup
Note
RedlineCircle
RedlinePolyline
RedlineRectangle
RedlineText
Measurement
MeasureEdgeLength
MeasureFaceFaceAngle
MeasureLineLineAngle
MeasureFaceFaceDistance
MeasureBodyBodyDistance
MeasurePointPointDistance
MeasurePolylineDistanceOperator
Misc.
AxisTriad
Handle
NavCube
Please see the reference manual for more information on each operator category. Some of them will also be discussed throughout this Programming Guide.