Update display after hide/show subshape in AIS_ColoredShape

I'm using AIS_ColoredShape to display a compound shape containing many wires ("Z-slices" computed out of a shape).

I use AIS_ColoredDrawer::SetHidden(bool) to dynamically show/hide some wires :

const bool hiddenOn = ...;
const TopoDS_Wire& wire = ...;
Handle_AIS_ColoredDrawer aspects = m_aisShape->CustomAspects(wire);
if (!aspects.IsNull())
    aspects->SetHidden(hiddenOn);

I then call AIS_InteractiveContext::RecomputePrsOnly() to update the display, but it's slow.

What would be the fastest way to update display after show/hide subshapes of AIS_ColoredShape ?

 

Kirill Gavrilov's picture

Hiding sub-shapes within existing presentation without special tricks requires its re-computation. If you need switching visibility dynamically and your AIS_ColoredShape holds a big shape, then you better splitting it into smaller pieces (so that re-computation would take less time). Also, AIS_InteractiveContext::Erase() is a cheap operation (no re-computation) - use it for entire AIS_InteractiveObject, when possible.