Set transperency for AIS_Line

Hello Everyone,

I am trying to change transperency of AIS_Line using SetTransperency() , but it does not seem to work.

Handle_AIS_Line line = new AIS_Line(aPnt1, aPnt2);
Handle_Prs3d_Drawer myDrawer = new Prs3d_Drawer();
Handle_Prs3d_LineAspect asp = new Prs3d_LineAspect(Quantity_NOC_BLACK, Aspect_TOL_DOTDASH, 1.0);
myDrawer->SetLineAspect(asp);
line->SetAttributes(myDrawer);

myContext->Display(line, toUpdateViewer);

line->SetTransparency(0.5);
myContext->UpdateCurrentViewer();

Is there any other way to change transperency for AIS_Line ?

gkv311 n's picture

Drawing transparent lines have small practical benefits, so that OCCT renderer doesn't even consider it. Maybe stipple lines is what you are looking for?

Although there is one trick forcing line transparency using MaskBlend alpha mode, but have no idea if it of any use:

Handle(AIS_Line) aLine = ...;
float anAlpha = 0.3f;
Handle(Prs3d_Drawer) aDrawer = aLine->Attributes();
aDrawer->SetLineAspect(new Prs3d_LineAspect(Quantity_NOC_RED, Aspect_TOL_SOLID, 4.0f));
aDrawer->LineAspect()->Aspect()->SetInteriorColor(Quantity_ColorRGBA(Graphic3d_Vec4(1.0f, 0.0f, 0.0f, anAlpha)));
aDrawer->LineAspect()->Aspect()->SetAlphaMode(Graphic3d_AlphaMode_MaskBlend);
... display line
Prajwal Shelar's picture

Thanks for the reply.

This works for me!

Thanks & Regards,
Prajwal