For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings


Need to speed up your development?
Have a look at our:

Samples & Tools


Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

Highlight without Select the object

Amine M's picture


I want to make a dynamic selection, where the user see the shapes highlighted when hovering them with the cursor, and after clicking on them they will be selected and shown highlighted (as in 3d CAD software).

Currently to highlight an object or parts of it, I open a localContext and set the selectionMode for it, and I use moveto() and Select() in the mouseMove event in Qt.

The problem with this approach is that it selects the object (and prevents me from selecting others), I want it just to highlight it. So I can use select() in the click() event.

Any idea?

Mimosa Olive's picture

I'd like to do the same as well. I believe with OC 7.2 there is no more need for localContext

Benjamin Bihler's picture

I do it like this:

Handle(TPrsStd_AISPresentation)& presentation = ...

Handle(AIS_InteractiveObject)& interactiveObject = presentation->GetAIS();

                interactiveContext->HighlightStyle(), Standard_False);



Mimosa Olive's picture

Don't you have to test if presentation->GetAIS() returns a valid object? Otherwise HilightWithColor with null object would crash..

Mimosa Olive's picture

also how do you get the handle for the object your mouse is hovering over? Can you complete that line of code of yours:

"Handle(TPrsStd_AISPresentation)& presentation = ..."

Mimosa Olive's picture

I got it to hilight on mouse hover:

First when you create the myContext, you have to specify which type of geometry would be detected (you can activate more than one):

mContext->Activate(TopAbs_FACE, Standard_False );

Then inside the mousemove event:

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

if (mContext->HasDetected() == Standard_True){

//do something with the detected shape if you want, but it will hilight anyway


mView->Redraw(); //to make sure it hilight right away