Activate selection type not working

I am trying to activate a single selection type (TopAbs_FACE) on a group of AIS_ColoredShape's and disable all selection on other AIS_ColoredShape's. I am currently able to get the desired behavior by in the code below.

Handle(AIS_InteractiveContext) ic;
Handle(AIS_ColoredShape) shapeToActivate;
Handle(AIS_ColoredShape) shapeToLeaveDeactivated;
ic->Deactivate();
ic->Activate(AIS_ColoredShape::SelectionMode(TolAbs_FACE));
ic->Deactivate(shapeToLeaveDeactivated);
ic->UpdateCurrentViewer() // is this needed?

My issue is I do not always have access to shapeToLeaveDeactivated. Is there a way to only activate a selection mode on a specific AIS_ColoredShape? I have tried the below code but the result is no active selection on shapeToActivate.

Handle(AIS_InteractiveContext) ic;
Handle(AIS_ColoredShape) shapeToActivate;
//Handle(AIS_ColoredShape) shapeToLeaveDeactivated;
ic->Deactivate();
ic->Activate(shapeToActivate, AIS_ColoredShape::SelectionMode(TolAbs_FACE));
ic->UpdateCurrentViewer() // is this needed?

Thanks in advance!

Kirill Gavrilov's picture

I have tried the below code but the result is no active selection on shapeToActivate.

That shouldn't be like that. AIS_InteractiveContext::Activate() called without objects in the first sample calls the same ::Activate() method from the second sample for each displayed object. The only difference is that it also calls AIS_InteractiveContext::Load() for each object - which might be necessary if you have displayed object with disabled selection with extended syntax of AIS_InteractiveContext::Display() instead of default selection mode.