Problem with color change of AIS_Shapes

Dear fellow occ users,

I have this weird problem in my application which displays many different shapes in a 3d viewer.

Basically we allow the user to toggle the visibillity of these shapes as well as pick individual colors which works fine in most cases. Now I noticed that for some of these shapes, the color change only works if they are currently displayed. In cases where they are not displayed, the color is like one step behind. As an example:

Step 1.: Shape is displayed, color is changed from red to blue: Shape is now blue.
Step 2.: Shape is not displayed, color is changed from blue to yellow, Shape is displayed: Shape is still blue
Step 3.: Shape is not displayed again, color is changed from yellow to green, Shape is displayed: Shape is now yellow.

The shapes which have these problems are TopoDS_Compounds made out of TopoDS_Vertex or / and TopoDS_EDGE. For faces everything works fine.

This is our code for changing the color (our_shape is a derived AIS_Shape):

void our_shape::set_attributes(const Quantity_Color* c)
if(c != 0) { this->SetColor(*c); }
this->Attributes()->SetPointAspect(new Prs3d_PointAspect(Aspect_TOM_PLUS, this->Color(), 1.f));

Finally the weird part: I tried to make it easy for me and just always display the shape before changing the color and probably hiding it again afterwards. But if I call a "ais_context->Display(AIS_Shape)" before the set_attributes, I always get the error described above, no matter if it was displayed befor or not.

Any help is greatly appreciated, I hope everything is correclty explained. Thank you very much in advance.

Billy's picture

I had and still have some problems setting attributes. My advice is don't use SetPointAspect(...), SetShadingAspect(...), etc. passing whole class but change these properties individually something like:


If this doesn't work, it is probably a bug.

Jendrik Seiler's picture

Thank you for the answer, I would prefer your suggestion over our current code but for reasons unknown to me, color chaning does not work at all for vertices with it.