NEED URGENT HELP: SetTransparency

Hi!

Can anybody tell me what's wrong with my code (see bellow)?
I can change everything: material, color... unless the transparency of the entities that are on the document...

Thanks in advance, Sofia Gameiro.

TDF_Label L;
TDF_Label myLabel = (pDoc->GetOCAFDoc())->Main();

Handle(AIS_InteractiveContext) myAISContext = pDoc->GetAISContext();

// setting material
Handle(TPrsStd_AISPresentation) prs;
Handle(AIS_InteractiveObject) aObject;
Handle(AIS_Drawer) aDrawer;
Handle(AIS_InteractiveContext) IC;

for (TDF_ChildIterator it2(myLabel); it2.More(); it2.Next())
{
TDF_Label L = it2.Value();
Handle(TNaming_NamedShape) TNS;
if (!L.FindAttribute(TNaming_NamedShape::GetID(), TNS)) continue;

TopoDS_Shape &aShape = TNaming_Tool::GetShape(TNS);
if ((aShape.ShapeType() == TopAbs_COMPOUND) || (aShape.ShapeType() == TopAbs_COMPSOLID)
|| (aShape.ShapeType() == TopAbs_SOLID) || (aShape.ShapeType() == TopAbs_SHELL)
|| (aShape.ShapeType() == TopAbs_FACE))
{

TopAbs_ShapeEnum e = aShape.ShapeType();
prs= TPrsStd_AISPresentation::Set(L, TNaming_NamedShape::GetID());
prs->Display(FALSE);
aObject = prs->GetAIS();
aObject->SetMaterial(pDoc->objectMaterial);
aObject->SetColor(pDoc->objectColor);
aObject->SetTransparency(pDoc->objectTransparency * 0.01);
aDrawer =aObject->Attributes();
aObject->SetAttributes(aDrawer);
IC=aObject->GetContext();
IC->SetLocalAttributes(aObject, aDrawer,Standard_True);
prs->Display(TRUE);
prs->Update();
myAISContext->UpdateCurrentViewer();
}
}
// END

Roman Lygin's picture

Hi Sofia,

Not sure it will help but just in case. Make sure your transparency is within the [0.0, 1.0] range. IIRC, values less than 0.05 are not treated (i.e. the object gets opaque).
Also you need to make your 3D view accept transparency (V3d_View::SetTransparency()).

HTH.
Roman

viviana's picture

Hi Sofia,

Could you post the part of the code where you create pDoc and your application?, I have already checked the OCAF manual and I wrote the code as in the section "4.2 The Application", but it didn't work, maybe I have the wrong includes...I don't know, help please.

...
#include
#include
#include
#include
...
TCollection_ExtendedString DocName("NewDocumentFormat");
Handle(TDocStd_Application) appyOCAF = new MyApplication_Application();
Handle(TDocStd_Document) docOCAF;
appyOCAF->NewDocument(DocName,docOCAF);
...
Thanks in advance.

viviana's picture

Hi Sofia,

Could you post the part of the code where you create pDoc and your application?, I have already checked the OCAF manual and I wrote the code as in the section "4.2 The Application", but it didn't work, maybe I have the wrong includes...I don't know, help please.

...
#include
#include
#include
#include
...
TCollection_ExtendedString DocName("NewDocumentFormat");
Handle(TDocStd_Application) appyOCAF = new MyApplication_Application();
Handle(TDocStd_Document) docOCAF;
appyOCAF->NewDocument(DocName,docOCAF);
...
Thanks in advance.

viviana's picture

Hi Sofia,

Could you post the part of the code where you create pDoc and your application?, I have already checked the OCAF manual and I wrote the code as in the section "4.2 The Application", but it didn't work, maybe I have the wrong includes...I don't know, help please.

...
#include
#include
#include
#include
...
TCollection_ExtendedString DocName("NewDocumentFormat");
Handle(TDocStd_Application) appyOCAF = new MyApplication_Application();
Handle(TDocStd_Document) docOCAF;
appyOCAF->NewDocument(DocName,docOCAF);
...
Thanks in advance.