6.4.1 Using a highlight operator
After a selection is performed, it is usually desirable to provide visual feedback to the user regarding what was selected. In HOOPS Visualize, this concept is called highlighting. The details of how to represent highlighting are up to the developer. You could choose to modify an object's color, line weight, vertex/edge/face visibility, material, shading mode, or any combination of these and other attributes. Selection and highlighting and two distinct operations. Thus, it is not required to perform a selection before highlighting an object, nor must you highlight something that was selected.
Highlighting can be applied at several different levels:
Selection level | Description |
---|---|
HPS::SelectionResults | The complete contents of a HPS::SelectionResults object can be highlighted. |
HPS::SelectionItem | A single item withing a HPS::SelectionResults object can be highlighted. |
HPS::SearchResults | The complete results of a search |
HPS::KeyPath | A common selection case is to highlight a model sub-assembly. This is accomplished using a HPS::KeyPath. |
HPS::Key | The contents of a segment can be highlighted. |
Note that a single geometric entity cannot be highlighted by simply providing its key. Visualize does not allow this because commonly, geometry is duplicated across the scene through the use of include segments. To avoid the ambiguous possibility of the same geometry being rendered multiple times, a HPS::KeyPath is required to provide resolution. The HPS::KeyPath object is discussed in section 1.2.1.
The HPS::HighlightControl is the object that controls this mechanic. It is only available from a HPS::WindowKey and uses the attributes of defined styles to achieve the highlight effect. The code below defines a simple style and highlights an object based on its key path.
Why would you complicate matters by using the highlight control when you could just apply a style manually? You certainly could apply it manually, but the highlighting mechanic keeps track of what is highlighted so that it can easily be unhighlighted at a future time. It also enables you to easily select from highlight styles you've previously defined. For information on how to build a highlight style, see section 4.3.
The following screenshots show examples of highlight styles:
All highlighting is performed using the concept of overlays. An overlay will allow an entity to be highlighted without redrawing the entire scene. When using overlays with a highlight style, you should set the overlay with the highlight options kit, not in the style itself. If both the highlight options kit and highlight style define different overlay settings, the result is undefined.
For detailed information on overlays, see section 6.5.
The HPS::HighlightOperator and HPS::HighlightAreaOperator provide visual feedback by applying a style to a selected object. The highlighting operators derive from the selection operators, and thus, can be used to perform selection as well. The style, or "highlight", is set by passing a HPS::HighlightOptionsKit to the operator before the selection occurs.
For information on how to define the highlight style itself, see section 4.3 of the Programming Guide. If you need more control over how highlights are applied, refer to the custom operators section for details on how to create your own custom operator.