
Wed, 10/06/2021 - 17:04
Forums:
Hi,
I would like to change the attributes of Edge presentation in DynamicHilightAttributes. But it does not work.
Handle(AIS_InteractiveContext) ctx = ...;
TopoDS_Shape shape = MakeBox(20, 20, 20);
Handle(AIS_Shape) prs = new AIS_Shape(shape);
prs->SetDynamicHilightAttributes(new Prs3d_Drawer());
prs->DynamicHilightAttributes()->SetLineAspect(new Prs3d_LineAspect(Quantity_NOC_RED, Aspect_TOL_SOLID, 10.0));
ctx->Display(prs, false);
ctx->SetDisplayMode(prs, AIS_Shaded, false);
ctx->Activate(prs, AIS_Shape::SelectionMode(TopAbs_EDGE));
At this point i can detect the edges of the presentation. But i would like to override the default graphical representation of a detected Edge. Increase the line width and change the color. I thought this was the role of DynamicHilightAttributes()->LineAspect();
I think there is something i am missing.
Thank you for your help, Aurelien
Thu, 10/07/2021 - 10:58
Highlighting of AIS_Shape reuses the same presentation for a normal display, so that DynamicHilightAttributes() affects only color and a couple of other attributes, but not fine-grained attributes like number of isolines to compute or width of wires. See also a comment for method AIS_InteractiveContext::HighlightStyle():
You will need modifying behavior of AIS_Shape if you really need highlighting to have different presentation - like making a dedicated display mode or customizing SelectMgr_EntityOwner::HilightWithColor() within subclasses.
Alternatively, Graphic3d_PresentationAttributes might be extended within OCCT itself to allow overriding line width (as a multiplier, for instance) for highlighting.
Thu, 10/07/2021 - 12:56
So one of the best solutions for specific highlighting behaviour is probably to create a new presentation that better suits the needs.
Now without talking about highlighting, only taking into account the presentation. For an AIS_Shape, in theory we could change the width of the face boundaries with the SetWidth() method.
When we look at the source code of AIS_Shape.cxx, the SetWidth() method modifies the FaceBoundary aspect. Note that SetFaceBoundaryDraw(Standard_True).
Then: AIS_Shape::Compute() - StdPrs_ShadedShape::Add(thePrs, myShape, myDrawer, ...)
We can see that for the display of face boudaries, the aspect taken into account is FaceBoudaryAspect whose Width we modified just before.
The problem is that nothing has changed visually. Face boundaries still have the default width.
Mon, 10/11/2021 - 16:45
Which OpenGL setup are you running on (Core or Compatible profile / direct or virtual environment)? Does it support thick lines at all?