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 are two distinct operations. Thus, it isn't necessary to perform a selection before highlighting an object, nor must you highlight something that was selected.
Highlighting can be applied at several different levels:
|HPS::SelectionResults||The complete contents of a HPS::SelectionResults object can be highlighted.|
|HPS::SelectionItem||A single item within a HPS::SelectionResults object can be highlighted.|
|HPS::SearchResults||The complete results of a search can be highlighted.|
|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 this section.
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 this section.
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.
More information on overlays can be found here.
Using a highlight operator
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 this section 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.
Searching for highlights
There are two built-in methods for obtaining highlight information from the scene:
To find highlighted elements in your scene, pass a HighlightSearchResults object to the WindowKey::FindHighlights() function. In the following example, we'll set an option in the HighlightSearchOptionsKit to limit our search to items that use the WithZValues overlay type:
The HighlightState object is populated with the ShowHighlightState() function. In this case, we're filtering our results with the HighlightSearchOptionsKit by searching only for highlighted items that use the built-in named style "highlight_style":
After calling ShowHighlightState(), you can call various functions on the HighlightState object to gather details about highlighting on the keypath:
- GetInheritsHighlight() indicates whether the keypath contains a highlight inherited from from a parent segment.
- GetSubentityHighlighted() indicates whether this segment contains a highlighted subentity (e.g., face or vertex). This function is only useful for shells and meshes.
- GetDirectlyHighlighted() indicates if any of the keys on the keypath are directly highlighted (i.e., the highlight is set on this segment and not just inherited from a parent segment).
- GetOnHighlightPath() indicates whether there's a highlight in a child segment on this keypath.