Salome HOME
patch for correct bathymetry visualization in HYDRO
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_VTKPrsDisplayer.cxx
index a75f52a9966f60e4309a4e5df1f50506ff69fd02..b096a067269bf316943b42c05495e80ab8ce7197 100644 (file)
@@ -200,6 +200,12 @@ void HYDROGUI_VTKPrsDisplayer::Display( const HYDROData_SequenceOfObjects& theOb
         bool anIsInserted = ( aPrs != 0 );
         if( anIsVisible && ( !aPrs || aPrs->getIsToUpdate() || theIsForced ) )
         {
+          // Erase the presentation in the view because of the problem with GEOM_Actor upadting on second SetShape.
+          if ( aPrs )
+          {
+            aViewer->Erase( aPrs, true );
+          }
+          // Update the presentation
           if( HYDROGUI_VTKPrsDriver* aDriver = getDriver( (size_t)aViewer, anObj ) )
           {
             if( aDriver->Update( anObj, aPrs ) && aPrs && !anIsInserted )
@@ -265,7 +271,7 @@ void HYDROGUI_VTKPrsDisplayer::Display( const HYDROData_SequenceOfObjects& theOb
       } 
       else if ( isChanged )
       {
-        aView->Repaint();
+        aView->Repaint( true );
       }
     }
   }
@@ -273,12 +279,14 @@ void HYDROGUI_VTKPrsDisplayer::Display( const HYDROData_SequenceOfObjects& theOb
 
 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() )
@@ -288,17 +296,47 @@ void HYDROGUI_VTKPrsDisplayer::purgeObjects( const int theViewerId )
       {
         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 );
+    }
   }
 }