For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

Can't apply transparency for XCAFPrs_AISObject

Hugues Delorme's picture
Forums: 

Hello, I'm trying to make a XCAFPrs_AISObject item half-transparent with :

Handle_AIS_InteractiveContext context = ...;
Handle_XCAFPrs_AISObject obj = ...;
context->SetTransparency(obj, 0.5, false);
context->UpdateCurrentViewer();

but this just doesn't work, the displayed shaded shape stays opaque.

I even tried to call "context->Redisplay(obj, true);" but without any success.

Any idea ?

Kirill Gavrilov's picture

XCAFPrs_AISObject is not a usual AIS object - it is a presentation for XCAF Label.
XCAF document defines presentation properties of shapes and sub-shapes (colors, including transparency),
and XCAFPrs_AISObject is designed to apply these properties while computing presentation.

Therefore, expected workflow of working with XCAFPrs is modifying the document (XCAFDoc_ColorTool) and then redisplaying presentable object.

It is possible, though, modifying presentation properties without changing the document,
but this requires understanding of XCAFPrs_AISObject / AIS_ColoredShape implementation details - like playing with DispatchStyles()/DefaultStyle() methods.
Or, if document properties are not actually needed - just use AIS_Shape instead.