Thu, 10/23/2025 - 19:20
Forums:
I am using this code in the initviewer function to try to load the model and set the highlight style.
// Create AIS context
myContext = new AIS_InteractiveContext (myViewer);
myContext->SetDisplayMode ((int )AIS_DisplayMode::AIS_Shaded, false);
myContext->DefaultDrawer ()->SetFaceBoundaryDraw(true);
myContext->DefaultDrawer ()->FaceBoundaryAspect()->SetColor(Quantity_NameOfColor::Quantity_NOC_BLACK);
myContext->DefaultDrawer ()->FaceBoundaryAspect()->SetWidth(1.2);
Handle(Prs3d_Drawer) highlightStyle = new Prs3d_Drawer();
highlightStyle->SetColor(Quantity_NOC_CYAN);
myContext->SetHighlightStyle(Prs3d_TypeOfHighlight_LocalDynamic, highlightStyle);
myContext->SetHighlightStyle(Prs3d_TypeOfHighlight_LocalSelected, highlightStyle);
myContext->SetHighlightStyle(Prs3d_TypeOfHighlight_Dynamic, highlightStyle);
myContext->SetHighlightStyle(Prs3d_TypeOfHighlight_Selected, highlightStyle);
myView = myViewer->CreateView();
myView->TriedronDisplay (Aspect_TOTP_LEFT_LOWER, Quantity_NOC_WHITE, 0.20, V3d_ZBUFFER);
Any advice on how to set the highlight style for when a part is selected? Thanks
Thu, 10/23/2025 - 21:19
What you expect/want to see and what you actually see? Any screenshots?
Fri, 10/24/2025 - 07:33
It doesn't appear to be setting the color of the highlight. With that code I would expect the highlight color to be a cyan color. What is see is a dark gray highlight color. See the attached photo with the bolt in the the red circle is the selected part of the model and it is just a slightly darker gray than the rest of the model. So I was trying to get the selection to stand out with this code.
Fri, 10/24/2025 - 08:19
On your screenshot it looks like your objects have highlight mode
AIS_Shadedinstead of defaultAIS_Wireframe, but this is not specified in the code snippet. How do you set it? If you doing something likeAIS_Shape::SetHilightMode()then beware that this method creates a customPrs3d_Drawerfor highlighting of specific object, and fills it with default values - e.g.Quantity_NOC_GRAY80:If you want to change default highlight mode for all objects in
AIS_InteractiveContextyou might want to changePrs3d_Drawer::SetDisplayMode()of related style in it.-1means to use active display mode of main presentation.Extra notes:
using fractional line width is probably not a good idea - it will be either ignored or will produce extra aliasing/smashing effect on lines in most cases.
Default highlight style sets more properties than just a color, so that these lines will have more side effects on Viewer behavior than you might expect:
Default style would also link to main presentation
Prs3d_Drawerinstance (so that there is no need to duplicate exactly same customizations) and configure different Z-Layers.I would suggest to change existing drawers in context like:
instead of assigning a new
Prs3d_Drawerinstance.Tue, 10/28/2025 - 07:37
This is the sample code from the IOS project found here https://github.com/Open-Cascade-SAS/OCCT/blob/master/samples/ios/UIKitSample/UIKitSample/OcctViewer.mm#L84
I had added a the extra indented code around the highlighting trying to get it to work. Removing that code and adding the suggested two lines didn't solve the problem entirely. From some of your comments I think the sample project is setting the highlight mode as AIS_Shaded instead of the AIS_Wireframe like you mentioned.
https://github.com/Open-Cascade-SAS/OCCT/blob/master/samples/ios/UIKitSample/UIKitSample/OcctViewer.mm#L336
Commenting out
//aConnected->SetHilightMode(1);got the highlighting showing as I was expecting with the cyan color.