UnsetColor may not work as expected


I loaded colored sample cubes as XCAFPrs_AISObject's into a scene. When loaded it automatically extracts the colors specified on the shape. When I do SetColor, color changes and after using it I like to UnsetColor. I was thinking that unsetting will revert to original color specified by shape and put it in original state. This it true for the wires/lines around the cube but not the faces. I thought it would work exactly as with transparency.

Extracting the color from the label/shape and setting back after usage isn't a solution as I'm not dealing with subshapes.


Did I miss something? Thanks in advance!


Kirill Gavrilov's picture

XCAFPrs_AISObject / AIS_ColoredShape do not implement UnsetColor() method, so that it cannot revert modifications properly - you will have to implement this method, if really needed.

Apart from this, calling XCAFPrs_AISObject::SetColor() doesn't look really useful as XCAFPrs_AISObject is expected to preserve colors and materials stored within an XCAF document. Trying to overriding properties on presentation level would cause diversion and uncertainty on how exactly application would like to mix styles - for such scenarios subclassing presentation and overriding DispatchStyles() would make more sense. Note that class also defines a virtual method XCAFPrs_AISObject::DefaultStyle(), which can be overridden to define a desirable default style for shapes having no style in a document.

Michael Maenz's picture

Ah I see.

The purpose is to highlight a part from a document in a tree for better visibility and in another use case I want to overlay two of the same objects from different revisions to make a visual compare. Therefore I need to change to distinct colors to have a violet (old) and a green (new) compare view.

So my new approach will be to copy the needed object, hide the original, recolor the copy and after usage throw away. That would be easier then implementing color unset. I never wanted to reflect the changes back to the XCAF document.

Thanks for your quick reply, you are always helpful to me!