
Sat, 03/08/2025 - 20:00
Forums:
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!
Mon, 03/10/2025 - 08:45
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, whileAIS_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).These two lines do (almost) the same thing, hence only one should be left (
::UpdateCurrentViewer()
for example). If you are usingAIS_ViewController
(preferred), then you better callAIS_ViewController::FlushViewEvents()
instead.Note that the last boolean flag in
AIS_InteractiveContext::Remove()
/::Erase()
/::Display()
methods is to update the viewer.\ You should passFALSE
there if you callAIS_InteractiveContext::UpdateCurrentViewer()
afterwards, otherwise you are redrawing viewer redundantly multiple times.Mon, 03/10/2025 - 08:44
If you experience some bug - it would be better providing a complete reproducer to see why it might happen.