pythonocc-core icon indicating copy to clipboard operation
pythonocc-core copied to clipboard

Issues with AIS_InteractiveContext SetSelectionMode()

Open e3dEF opened this issue 6 years ago • 4 comments

Hello, I'm using the OCCViewer.Viewer3d to display shapes and get feedback from the user by clicking them. For example, I can successfully change the color of a shape after it was selected in the viewer.

clr = Quantity_Color.Name(1.0, 0, 0)
display.Context.SetColor(ais, clr)

Now I wanted to allow to select e.g. only edges of a shape. So I tried display.Context.SetSelectionMode(ais, TopAbs_EDGE) But it has no effect. I don't want to use, display.SetSelectionModeShape() which works, but is applied on all shapes and additionally closes the context, so that I lose all links the shapes. How can I change only selection mode of a single shape?

e3dEF avatar Dec 06 '19 13:12 e3dEF

@e3dEF I don't know.

tpaviot avatar Dec 07 '19 06:12 tpaviot

The local context is not supported anymore. Please refer to the occt documentation for more information.

rainman110 avatar Dec 07 '19 20:12 rainman110

I had the same problem, and that's how I solved it: simply add "self.Context.Deactivate()" before activate the context, refer to: https://dev.opencascade.org/content/local-context-removal ` def SetSelectionMode(self, mode=None): self.Context.Deactivate() topo_level = next(modes) if mode is None: self.Context.Activate(AIS_Shape_SelectionMode(topo_level), True) else: self.Context.Activate(AIS_Shape_SelectionMode(mode), True) self.Context.UpdateSelected(True)

`

VASIMRLJJ avatar Jul 13 '21 02:07 VASIMRLJJ

Thanks @VASIMRLJJ I was looking for this fix for some time Created a pull request https://github.com/tpaviot/pythonocc-core/pull/1134

EmJay276 avatar Aug 19 '22 14:08 EmJay276