problem with managing TPrsStd_AISPresentation

Hello,

I am trying the following code without success.

If someone has an idea ...

//Creation of a new label in an OCAF document (MDTV-Standard format of 0CC62)
TDF_Label AnnotLabel= TDF_TagSource::NewChild(FifthLabel);

//Adding TDataStd_Shape
Handle(TDataStd_Shape) ShapeAnnot= new TDataStd_Shape();
ShapeAnnot->Set(AnnotLabel, aShape);

//Adding TDataStd_Name
Handle(TDataStd_Name) NomPlnAnnot= new TDataStd_Name();
NomPlnAnnot->Set(thename.ToCString());
AnnotLabel.AddAttribute(NomPlnAnnot);

//Adding TPrsStd_AISPresentation
Handle(TPrsStd_AISPresentation) aTPrsStdAISPresentation= new TPrsStd_AISPresentation();
aTPrsStdAISPresentation->SetColor(aColor);
aTPrsStdAISPresentation->SetWidth(2.0);
aTPrsStdAISPresentation->Set(AnnotLabel, TNaming_NamedShape::GetID());

if(aTPrsStdAISPresentation->HasOwnColor()) {cout if(aTPrsStdAISPresentation->HasOwnWidth()) {cout

//Trying to read TPrsStd_AISPresentation
Handle_TPrsStd_AISPresentation aTPrsStdAISPresentation2= new TPrsStd_AISPresentation(); aTPrsStdAISPresentation2->Set(AnnotLabel, TNaming_NamedShape::GetID());

if(aTPrsStdAISPresentation2->HasOwnColor()) {cout if(aTPrsStdAISPresentation2->HasOwnWidth()) {cout

The messages
Color OK.
Width OK.

are displayed.

The messages
Color is read.
Width is read.

are NEVER displayed.

In the browser document, the attributes seem to be correct.

WHY ?

Tkanks for any help,

Denis

Fotis Sioutis's picture

Try to retrieve your attribute like :

Handle(TPrsStd_AISPresentation) aPresentation;
AnnotLabel.FindAttribute(TPrsStd_AISPresentation::GetID(),aPresentation);

and then try to read your attribute's values

(btw TPrsStd_AISPresentation::Set is static public method)

Fotis

Denis Teissandier's picture

Thank's for your answer.

AnnotLabel.FindAttribute(TPrsStd_AISPresentation::GetID(),aPresentation);

seems to work and return a True value.

I try to read again the attribute's values and the methods HasOwnColor() and HasOwnWidth() are returning again False values ...

Regards,

Denis

Fotis Sioutis's picture

It should work ...

Only thing that can come in mind is that you have opened a transaction somewhere higher in the code without commiting it (xxxCommand methods of TDocStd_Document).Otherwise i am out of ideas.

Regards,

Fotis

Benjamin Bihler's picture

Hi Denis,

this is a very late reply. I have used your code for my own purposes and doing that I have found the bug. The line

aTPrsStdAISPresentation->Set(AnnotLabel, TNaming_NamedShape::GetID());

is wrong, since the Set(...) method returns a new attribute. Therefore this should actually be your instance construction line:

Handle(TPrsStd_AISPresentation) aTPrsStdAISPresentation = TPrsStd_AISPresentation::Set(AnnotLabel, TNaming_NamedShape::GetID());

Even though this reply may be of no use for you anymore, I hope that it saves debugging time of others who try to use your code as I have done... :-)

Bye,
Benjamin