Multiple selection modes (different Interactive Object types)

Here is what I am doing: I am displaying a trihedron when the user selects a face of a shape. To select faces, I open a Local Context and set it to "selecting faces" mode. The trihedron is displayed, but I have been unable to find a way to make something of the trihedron selectable. The shape's faces are still selectable, though.

One thing that almost works is to open a new Local Context, display the trihedron and Activate() selection of faces in the shape. The problem is that face selection is completely screwed up. As long as I do not rotate the view, selection of faces and axes of the trihedron work just fine. When I rotate the view and try to select a different face of the shape, it detects another one. Selection of axes still works as expected, though.

I would like to find a way to make the trihedron's axes selectable (without opening a new Local Context if possible), while also keeping the current selection mode (working as it should).

Thanks in advance.

Paul Jimenez's picture

In case anyone else needs a solution for it, the trick is to use a Selection Filter.

What happens is that when you set the selection mode to a specific type of Shape, a default filter is pushed into the Context. When MoveTo is called, the filter will be used. The problem is that the default filter checks for Shapes only (those that have StdSelect_BRepOwner as Entity Owner). In the case of the Trihedron, no StdSelect_BRepOwner is created at all when computing selection, causing the filter to reject its selection or any of its parts.

Creating a new filter that accepts the Trihedron or any of its parts (or just one that accepts everything), or removing all filters is enough to allow selection. It is also recommended to have a selection mechanism of its own in the Trihedron (in other words, methods and attributes that will be used in ComputeSelection no matter what mode it is being told to use).

In short, AIS_InteractiveContext::RemoveFilters and/or AIS_InteractiveContext::AddFilter is what you are looking for.