aViewShapes.append( theShape );
}
+void HYDROGUI_Module::removeObjectVTKPrs( const int theViewId,
+ const QString& theEntry )
+{
+ if ( !myVTKPrsMap.contains( theViewId ) )
+ return;
+
+ ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
+ Handle(HYDROData_Entity) anObject;
+ QString anEntryRef;
+ for ( int i = 0; i < aViewShapes.length(); )
+ {
+ HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
+ anObject = aShape->getObject();
+ anEntryRef = HYDROGUI_DataObject::dataObjectEntry( anObject );
+ if ( aShape && (!anObject.IsNull()) && ( anEntryRef == theEntry ) )
+ {
+ delete aShape;
+ aViewShapes.removeAt( i );
+ continue;
+ }
+
+ ++i;
+ }
+
+ // Invalidate global Z range
+ double anInvalidRange[2] = { HYDROGUI_VTKPrs::InvalidZValue(), HYDROGUI_VTKPrs::InvalidZValue() };
+ getVTKDisplayer()->SetZRange( theViewId, anInvalidRange );
+}
+
void HYDROGUI_Module::removeObjectVTKPrs( const int theViewId,
const Handle(HYDROData_Entity)& theObject )
{
void removeObjectVTKPrs( const int theViewId,
const Handle(HYDROData_Entity)& theObject );
+ void removeObjectVTKPrs( const int theViewId,
+ const QString& theEntry );
+
/**
* Update global imposed range of Z values for the given VTK viewer id
*/
void HYDROGUI_VTKPrsDisplayer::purgeObjects( const int theViewerId )
{
+ bool doEraseScalarBar = false;
+
SVTK_Viewer* aViewer = module()->getVTKViewer( theViewerId );
if( aViewer )
{
SALOME_ListIO aListIO;
aViewer->GetVisible( aListIO );
-
+
HYDROGUI_VTKPrs* aPrs;
SALOME_ListIteratorOfListIO anIter( aListIO );
for( ; anIter.More(); anIter.Next() )
{
Handle(HYDROData_Entity) anOwnerObj =
module()->getDataModel()->objectByEntry( aPrsObj->getEntry() );
- if ( !anOwnerObj.IsNull() && anOwnerObj->IsRemoved() )
+ if ( anOwnerObj.IsNull() )
+ {
+ // We found an unknown IO presented in the viewer.
+ // Remove such an orphan presentation from all the views of the viewer.
+ SUIT_ViewManager* aViewMgr = dynamic_cast<SUIT_ViewManager*>( aViewer->getViewManager() );
+ if ( aViewMgr && aViewMgr->getViewsCount() > 0 )
+ {
+ QVector<SUIT_ViewWindow*> aViews = aViewMgr->getViews();
+ foreach ( SUIT_ViewWindow* aView, aViews )
+ {
+ SVTK_ViewWindow* aVTKView = dynamic_cast<SVTK_ViewWindow*>( aView );
+ if ( aVTKView )
+ {
+ aVTKView->Erase( aPrsObj, false );
+ }
+ }
+ }
+ // Remove the object presentation from the module's cache
+ module()->removeObjectVTKPrs( (size_t)aViewer, aPrsObj->getEntry() );
+ doEraseScalarBar = true;
+ }
+ else if ( anOwnerObj->IsRemoved() )
{
aPrs = module()->getObjectVTKPrs( (size_t)aViewer, anOwnerObj );
if ( aPrs )
{
aViewer->Erase( aPrs );
}
+ else
+ {
+ }
module()->removeObjectVTKPrs( (size_t)aViewer, anOwnerObj );
+ doEraseScalarBar = true;
}
}
}
+
+ if ( doEraseScalarBar )
+ {
+ EraseScalarBar( theViewerId );
+ }
}
}