ViewCube stops working when altering the selection method


The AIS_ViewCube works correctly, but when I change the selection method to for example edge selection, I clear all other selection methods, before setting the desired selection method

Handle(AIS_InteractiveContext) hAISContext = GetAISContext();
if (hAISContext)

Looking at AIS_ViewCube::ComputeSelection, it will only accept selection mode 0, so this explains probably why it stops working.

I would expect the viewcube to continue working no matter what selection method.
Any work around?

gkv311 n's picture

Don't use global activate/deactivate methods - always specify interactive objects you would like to modify.

If your intention is to alter all shapes - you may write something like this:

Handle(AIS_InteractiveContext) theCtx = ...;
int aSelMode = AIS_Shape::SelectionMode(TopAbs_FACE);

AIS_ListOfInteractive aDispList;
for (const Handle(AIS_InteractiveObject)& aPrsIter : aDispList)
  Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(aPrsIter);
  if (aShape.IsNull()) { continue; }

  theCtx->Activate(aShape, aSelMode);

Luc Wens's picture

Hmm, yes, this makes sense.
Also, since I may have both objects originating from IGES/STEP at one side, and STL meshes where I can pick vertices/edges/surfaces, but which have different selection modes, I could fine-tune the setting of the selection mode.