how to delete a PrsDim_LengthDimension

Hello all,

how to delete a PrsDim_LengthDimension?

void OccBase::clearDimensions()
{
    qDebug() << "dimensions before cleaning" << m_dimensions.size();
    Handle(PrsDim_LengthDimension) dim;
    for (int i=0; i<m_dimensions.size(); i++)
    {
        dim = m_dimensions.at(i);

        OccViewManager::instance()->myContext()->Erase(dim, Standard_True);
        OccViewManager::instance()->myContext()->Remove(dim, Standard_True);
        OccViewManager::instance()->myContext()->Update(dim, Standard_True);
        dim->DimensionAspect().Nullify();
        dim.Nullify();
        Standard::Purge();
    }
    m_dimensions.clear();
    qDebug() << "dimensions after cleaning" << m_dimensions.size();
    OccViewManager::instance()->myContext()->UpdateCurrentViewer();
    OccViewManager::instance()->myContext()->CurrentViewer()->Redraw();
}

this only removes the text and the two lines to the points but not the long line between the points

Thanks!

gkv311 n's picture
        OccViewManager::instance()->myContext()->Erase(dim, Standard_True);
        OccViewManager::instance()->myContext()->Remove(dim, Standard_True);
        OccViewManager::instance()->myContext()->Update(dim, Standard_True);
        dim->DimensionAspect().Nullify();
        dim.Nullify();
        Standard::Purge();

Here you need to call only OccViewManager::instance()->myContext()->Remove(dim, false), everything else is redundant and looks suspicious. Calling ::Update() for removed object certainly looks wrong.

AIS_InteractiveContext::Erase() hides presentation but keeps it in Context for fast redisplay, while AIS_InteractiveContext::Remove() completely removes it from Context (visual effect should be the same, the difference is either you want to redisplay object later or want to abandon it completely).

    OccViewManager::instance()->myContext()->UpdateCurrentViewer();
    OccViewManager::instance()->myContext()->CurrentViewer()->Redraw();

These two lines do (almost) the same thing, hence only one should be left (::UpdateCurrentViewer() for example). If you are using AIS_ViewController (preferred), then you better call AIS_ViewController::FlushViewEvents() instead.

Note that the last boolean flag in AIS_InteractiveContext::Remove()/::Erase()/::Display() methods is to update the viewer.\ You should pass FALSE there if you call AIS_InteractiveContext::UpdateCurrentViewer() afterwards, otherwise you are redrawing viewer redundantly multiple times.

gkv311 n's picture

this only removes the text and the two lines to the points but not the long line between the points

If you experience some bug - it would be better providing a complete reproducer to see why it might happen.