Salome HOME
54353: Mesh group is not updated in VTK
authoreap <eap@opencascade.com>
Mon, 26 Feb 2018 16:57:39 +0000 (19:57 +0300)
committereap <eap@opencascade.com>
Mon, 26 Feb 2018 16:57:39 +0000 (19:57 +0300)
src/SMESHGUI/SMESHGUI_RemoveElementsDlg.cxx
src/SMESHGUI/SMESHGUI_VTKUtils.cxx
src/SMESHGUI/SMESHGUI_VTKUtils.h

index 1e458d8caed1e1101763d1838767d25c7bdcddee..31a46b557fb3799dc46b4ec7c41eeb037f1e6b1e 100644 (file)
@@ -247,15 +247,13 @@ void SMESHGUI_RemoveElementsDlg::ClickOnApply()
 
     } catch (const SALOME::SALOME_Exception& S_ex) {
       SalomeApp_Tools::QtCatchCorbaException(S_ex);
 
     } catch (const SALOME::SALOME_Exception& S_ex) {
       SalomeApp_Tools::QtCatchCorbaException(S_ex);
-      myEditCurrentArgument->clear();
-    } catch (...){
-      myEditCurrentArgument->clear();
+    } catch (...) {
     }
 
     }
 
+    myEditCurrentArgument->clear();
     if (aResult) {
     if (aResult) {
-      myEditCurrentArgument->clear();
       mySelector->ClearIndex();
       mySelector->ClearIndex();
-      SMESH::UpdateView();
+      SMESH::UpdateView( /*withChildrenOfSelected=*/true );
       SMESHGUI::Modified();
     }
   }
       SMESHGUI::Modified();
     }
   }
index 10bc6ba22351523fb3777999d8747c0da72b8bd6..ef9fb3896b5d62ad099ba9ba85fc9cc163ace889 100644 (file)
@@ -794,12 +794,13 @@ namespace SMESH
     return false;
   }
 
     return false;
   }
 
-  void UpdateView(){
+  void UpdateView( bool withChildrenOfSelected )
+  {
     if ( SVTK_ViewWindow* aWnd = SMESH::GetCurrentVtkView()) {
       LightApp_SelectionMgr* mgr = SMESHGUI::selectionMgr();
       SALOME_ListIO selected; mgr->selectedObjects( selected );
 
     if ( SVTK_ViewWindow* aWnd = SMESH::GetCurrentVtkView()) {
       LightApp_SelectionMgr* mgr = SMESHGUI::selectionMgr();
       SALOME_ListIO selected; mgr->selectedObjects( selected );
 
-      if( selected.Extent() == 0){
+      if ( selected.Extent() == 0 ) {
         vtkRenderer* aRenderer = aWnd->getRenderer();
         VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
         vtkActorCollection *aCollection = aCopy.GetActors();
         vtkRenderer* aRenderer = aWnd->getRenderer();
         VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
         vtkActorCollection *aCollection = aCopy.GetActors();
@@ -811,12 +812,36 @@ namespace SMESH
                 break; // avoid multiple warinings if visu failed
           }
         }
                 break; // avoid multiple warinings if visu failed
           }
         }
-      }else{
+      }
+      else
+      {
         SALOME_ListIteratorOfListIO anIter( selected );
         SALOME_ListIteratorOfListIO anIter( selected );
-        for( ; anIter.More(); anIter.Next()){
+        for( ; anIter.More(); anIter.Next())
+        {
           Handle(SALOME_InteractiveObject) anIO = anIter.Value();
           Handle(SALOME_InteractiveObject) anIO = anIter.Value();
-          if ( !Update(anIO,true) )
+          if ( !Update( anIO, true ))
             break; // avoid multiple warinings if visu failed
             break; // avoid multiple warinings if visu failed
+
+          if ( withChildrenOfSelected ) // update all visible children
+          {
+            QString aFatherID = anIO->getEntry();
+            vtkRenderer* aRenderer = aWnd->getRenderer();
+            VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
+            vtkActorCollection *aCollection = aCopy.GetActors();
+            aCollection->InitTraversal();
+            while ( vtkActor *anAct = aCollection->GetNextActor() ) {
+              if ( SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>( anAct )) {
+                if ( anActor->hasIO() && anActor->GetVisibility() )
+                {
+                  QString aChildID = anActor->getIO()->getEntry();
+                  if ( aChildID.size() > aFatherID.size() &&
+                       aChildID.startsWith( aFatherID ))
+                    if ( ! Update( anActor->getIO(), true ))
+                      break;
+                }
+              }
+            }
+          }
         }
       }
       RepaintCurrentView();
         }
       }
       RepaintCurrentView();
index b1159bd139ede160bfcaf7dff4b1451f8a89603b..0f47edb71a08bb88c5c8bf3d255415205083333c 100644 (file)
@@ -120,7 +120,7 @@ SMESHGUI_EXPORT
   bool UpdateView( EDisplaing, const char* = "" );
 
 SMESHGUI_EXPORT
   bool UpdateView( EDisplaing, const char* = "" );
 
 SMESHGUI_EXPORT
-  void UpdateView();
+  void UpdateView( bool withChildrenOfSelected = false );
 
 SMESHGUI_EXPORT
   bool UpdateNulData( const Handle(SALOME_InteractiveObject)& theIO, bool theDisplay);
 
 SMESHGUI_EXPORT
   bool UpdateNulData( const Handle(SALOME_InteractiveObject)& theIO, bool theDisplay);