Change color for highlighting when detecting a shape or compound


I am updating an application from OCC 6.7.0 to 7.5.0.

Detecting of shapes or compounds in the viewer works well :
- A colored wireframe is shown when moving the mouse over.

Now I want to change the color by user for detecting.

My Code is :


myAISContext->Select(true); // this works well

catch(...) {}

I found that information in the documentation :

// Run the detection mechanism for activated entities in the current mouse coordinates and in the current view.
// Detected owners will be highlighted with context highlight color
theContext->MoveTo (aXMousePos, aYMousePos, myView, false);
// Select the detected owners

But where I have to change the above mentioned context highlight color ?

Thanks for a hint.

Kirill Gavrilov's picture

Take a look onto documentation of method AIS_InteractiveContext::HighlightStyle() taking Prs3d_TypeOfHighlight enumeration value in case if you would like configuring highlight colors globally (as default for all objects):

aCtx->HighlightStyle (Prs3d_TypeOfHighlight_Dynamic) ->SetColor (Quantity_NOC_RED);
aCtx->HighlightStyle (Prs3d_TypeOfHighlight_Selected)->SetColor (Quantity_NOC_BLUE);

Draw Harness command vselprops can be used for testing this functionality:

box b 1 2 3
vinit View1
vdisplay -dispMode 1 b
vselprops dynHighlight -color RED
vselprops selHighlight -color BLUE
vmoveto 200 200
# red dynamic highlighting
vselect 200 200
# blue highlighting of selection
H. Reinhold's picture

Thank you for your answer,

although the script works with Draw Harness fine it works not in my Application ?
Win 10, VS 2017, OCC 7.5.0, x64, Debug-Mode
While detecting the Compound with the mouse only a grey wirframe is shown.
Maybe any default. The color did not change.

This has no effect:


myAISContext->MoveTo(point.x, point.y, myView, Standard_False);//this is needed so the context is aware of where the mouse is

Thanks for another hint

Kirill Gavrilov's picture

What do you mean by "detecting Compound"? Is is a single AIS_Shape, or maybe selection of sub-shapes or some other class?

H. Reinhold's picture

It is a single Shape.

I am using:

H. Reinhold's picture


TopAbs_ShapeEnum myShapeType = myDetectedShape.ShapeType();;

gives me: