Salome HOME
54353: Mesh group is not updated in VTK
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_VTKUtils.cxx
index e0543bc05ad2ea41a1aac3d8e31cd4e2eb1dcc7b..ef9fb3896b5d62ad099ba9ba85fc9cc163ace889 100644 (file)
@@ -362,7 +362,7 @@ namespace SMESH
     }
 
     if ( objModified ) {
-      // PAL16631. Mesurements showed that to show aVisualObj in SHADING(default) mode,
+      // PAL16631. Measurements showed that to show aVisualObj in SHADING(default) mode,
       // ~5 times more memory is used than it occupies.
       // Warn the user if there is less free memory than 30 sizes of a grid
       // TODO: estimate memory usage in other modes and take current mode into account
@@ -396,7 +396,7 @@ namespace SMESH
 
 
   /*! Return active view window, if it instantiates SVTK_ViewWindow class,
-   *  overwise find or create corresponding view window, make it active and return it.
+   *  otherwise find or create corresponding view window, make it active and return it.
    *  \note Active VVTK_ViewWindow can be returned, because it inherits SVTK_ViewWindow.
    */
   SVTK_ViewWindow* GetViewWindow (const SalomeApp_Module* theModule,
@@ -762,6 +762,7 @@ namespace SMESH
                 if ((anActor = CreateActor(aDocument,theEntry,true))) {
                   bool needFitAll = noSmeshActors(theWnd); // fit for the first object only
                   DisplayActor(theWnd,anActor);
+                  anActor->SetVisibility(true);
                   aStudy->setVisibilityState(theEntry, Qtx::ShownState);
                   // FitAll(); - PAL16770(Display of a group performs an automatic fit all)
                   if (needFitAll) FitAll();
@@ -793,12 +794,13 @@ namespace SMESH
     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( selected.Extent() == 0){
+      if ( selected.Extent() == 0 ) {
         vtkRenderer* aRenderer = aWnd->getRenderer();
         VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
         vtkActorCollection *aCollection = aCopy.GetActors();
@@ -810,12 +812,36 @@ namespace SMESH
                 break; // avoid multiple warinings if visu failed
           }
         }
-      }else{
+      }
+      else
+      {
         SALOME_ListIteratorOfListIO anIter( selected );
-        for( ; anIter.More(); anIter.Next()){
+        for( ; anIter.More(); anIter.Next())
+        {
           Handle(SALOME_InteractiveObject) anIO = anIter.Value();
-          if ( !Update(anIO,true) )
+          if ( !Update( anIO, true ))
             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();