Selection Mode TopAbs_FACE & TopAbs_EDGE Together

Hello OCCT Community,

I've used "Selection Mode" with my AIS_InteractiveContext and when I assign "TopAbs_FACE" to the SelectionMode method (it can be seen below code block and the image of TopAbs_FACE), I am able to acquire the faces of my mesh object:

ais_interactive_context_->Display (XCAF_Prs_AIS_object_, AIS_Shaded, 0, true);
ais_interactive_context_->Activate(ais_shape, ais_shape->SelectionMode( TopAbs_FACE));

Similarly, when I assign "TopAbs_EDGE" to the "SelectionMode" method (it can be also seen below code block and the image of TopAbs_EDGE), I could acquire the edges of my mesh:

object.ais_interactive_context_->Display (XCAF_Prs_AIS_object_, AIS_Shaded, 0, true);
ais_interactive_context_->Activate(ais_shape, ais_shape->SelectionMode( TopAbs_EDGE));

However, I am not able to using them (i.e. TopAbs_EDGE & TopAbs_FACE altogether) into the "SelectionMode" method. How can I handle this issue? My intention is that when navigating with the mouse, the edges are selectable if I'm on the edges, and the surfaces are selectable if I'm on the surface.

Thank you in advance!

Kirill Gavrilov's picture

Selection mode passed to AIS_InteractiveContext::Activate() is a single mode, not a bitmask. To activate multiple modes at once you need calling the method multiple times.
If you would like activating only single mode at a time, you need deactivating previously activated modes or to use AIS_SelectionModesConcurrency_Single for AIS_InteractiveContext::SetSelectionModeActive().

Not every combination of selection modes would work as expected.

Hakan Kaya's picture

You can create a global SELECTION_MODE variable. You can update this global variable with the toolbar or the button you want to add wherever you want. You can activate the selection mode of the objects displayed after each update with the signal-slot relationship.
 

Example:

enum struct OPERATION_MODE {
    TRANSLATE,
    ROTATE,
    SCALE,
    NOTHING,
    MEASURE,
};
enum struct SELECTION_MODE {
    VERTEX,
    EDGE,
    FACE,
    BODY,
};