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())

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.

Sathiya nathan's picture

I faced same performance issue while hiding/showing sub shapes. I tried the following trick. Hopefully it can solve the performance issue.

if(!m_layer->isVisible ())
SetCustomTransparency (m_shape, 1);
SetCustomTransparency (m_shape, 0);

UpdatePresentations ();