HOOPS Visualize Documentation

< Table of Contents

PROGRAMMING GUIDE

6.4 Highlighting

6.4 Highlighting

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. Note that 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 levelDescription
SelectionResultsThe complete contents of a SelectionResults object can be highlighted.
SelectionItemA single item withing a SelectionResults object can be highlighted.
SearchResultsThe complete results of a search
KeyPathA common selection case is to highlight a model sub-assembly. This is accomplished using a KeyPath.
KeyThe 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 KeyPath is required to provide resolution. The KeyPath object is discussed in section 1.2.1.

The HighlightControl is the object that controls this mechanic. It is only available from a 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.

[snippet 6.4.a]
NamedStyleDefinition orange_style = myPortfolio.DefineNamedStyle("myHighlightStyle", mySegmentKey);
mySegmentKey.GetMaterialMappingControl().SetFaceColor(RGBAColor(0.89f, 0.62f, 0.11f));
hok.SetStyleName(UTF8("myHighlightStyle"));
myWindowKey.GetPortfolioControl().Push(myPortfolio);
myWindowKey.GetHighlightControl().Highlight(keyPath, hok);
NamedStyleDefinition orange_style = myPortfolio.DefineNamedStyle("myHighlightStyle", mySegmentKey);
mySegmentKey.GetMaterialMappingControl().SetFaceColor(new RGBAColor(0.89f, 0.62f, 0.11f));
hok.SetStyleName("myHighlightStyle");
myWindowKey.GetPortfolioControl().Push(myPortfolio);
myWindowKey.GetHighlightControl().Highlight(keyPath, hok);

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.

The following screenshots show examples of highlight styles:

[figure 6.4.a] An unhighlighted model
[figure 6.4.b] The model's bottom tube has been highlighted with an opaque red highlight style.
[figure 6.4.b] The model's bottom tube has been highlighted with a textured highlight style.

Overlays

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.

6.4.1 Using a highlight operator

The HighlightOperator and 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 HighlightOptionsKit to the operator before the selection occurs.

[snippet 6.4.1.a]
HighlightOperator* highlightOperator
myView.GetOperatorControl().Push(highlightOperator); // makes 'highlightOperator' active
// set the highlight style, which must be predefined
HighlightOptionsKit hok("myHighlightStyle");
highlightOperator->SetHighlightOptions(hok);
// ... <perform selection>
// ... <style is applied automatically to the selection set>
HPS.HighlightOperator highlightOperator
= new HPS.HighlightOperator(HPS.MouseButtons.ButtonLeft());
myView.GetOperatorControl().Push(highlightOperator); // makes 'highlightOperator' active
// set the highlight style, which must be predefined
HPS.HighlightOptionsKit hok = new HPS.HighlightOptionsKit("myHighlightStyle");
highlightOperator.SetHighlightOptions(hok);
// ... <perform selection>
// ... <style is applied automatically to the selection set>

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.