
Mon, 02/17/2025 - 03:01
Forums:
Content:
I am working with OCCT in C# and trying to set different colors for edges and faces when using SetHighlightStyle(LocalDynamic). Below is the Prs3d_Drawer setup I am using:
var drawer = new Prs3d_Drawer();
drawer.SetZLayer(-2);
drawer.SetupOwnDefaults();
drawer.SetDisplayMode(1);
drawer.SetColor(Color.Yellow.To_quantity_color());
var line_aspect = new Prs3d_LineAspect(Color.Red.To_quantity_color(), Aspect_TypeOfLine.SOLID, local_hovered.Edge.Thickness);
drawer.SetWireAspect(line_aspect);
drawer.SetFaceBoundaryAspect(line_aspect);
drawer.SetUnFreeBoundaryAspect(line_aspect);
var shading_aspect = new Prs3d_ShadingAspect();
shading_aspect.SetColor(Color.Green.To_quantity_color());
shading_aspect.SetTransparency(0);
shading_aspect.Aspect().SetPolygonOffsets((int)Aspect_PolygonOffsetMode.Fill, 0.99f, 0.0f);
drawer.SetShadingAspect(shading_aspect);
return drawer;
Observations:
- When setting
var line_aspect = new Prs3d_LineAspect(Color.Red.To_quantity_color(), Aspect_TypeOfLine.SOLID, local_hovered.Edge.Thickness);
- The thickness of the edge is correctly applied.
- However, the edge color does not change to red.
- When setting
var shading_aspect = new Prs3d_ShadingAspect();
shading_aspect.SetColor(Color.Green.To_quantity_color());
- The face color does not change to green as expected.
Question:
Is there a way to display different colors for individual local elements (edges and faces) when using LocalDynamic highlight mode? How can I properly set different colors for edges and faces on hover?
Any insights or alternative methods would be appreciated.
Wed, 02/19/2025 - 00:57
Some image may help understand your question better.
It is possible to show different colors for edges than for faces, for default or hilight or selection drawing (using AIS_InteractiveContext is quite easy):
Hope it helps.
Thu, 02/20/2025 - 03:22
I have modified the drawer settings based on the comment that
viewer.Graphic.Occt
is anAIS_InteractiveContext
.Here is my updated code:
Expected Behavior:
When I run the program:
I expected that when hovering the mouse in Edge or Face selection mode:
Issue:
However, this is not happening as expected. The DisplayMode of
AIS_InteractiveContext
is set to 1.Did I miss something or make a mistake in my implementation? Any guidance would be appreciated!
Additional Screenshots:
Thu, 02/20/2025 - 08:33
AIS
handles highlighting in a special way - by default, it doesn't (re)compute presentation, but modulates/overrides its properties like color. The behavior is managed by classGraphic3d_PresentationAttributes
, which is the base ofPrs3d_Drawer
. Other properties of subclassPrs3d_Drawer
are ignored when highlighting entireAIS_Shape
, but some of them could take effect within local selection of subshapes (but color will be overridden anyway).You would need customizing
AIS_Shape
to achieve highlighting of lines and triangles having different color (and/or probably improving OCCT itself).There is trick, though. You may assign material for highlighting triangles
Prs3d_Drawer::SetBasicFillAreaAspect()
and colorPrs3d_Drawer::SetColor()
which will affect lines:This wouldn't affect line thickness though.
Fri, 02/21/2025 - 02:52
Thank you for the detailed explanation.
Your insights on AIS highlighting behavior and possible customization approaches were really helpful.