]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Fix for bug bug #392: change layer order dialog is empty if it is called during calcu...
authormzn <mzn@opencascade.com>
Fri, 4 Apr 2014 10:20:01 +0000 (10:20 +0000)
committermzn <mzn@opencascade.com>
Fri, 4 Apr 2014 10:20:01 +0000 (10:20 +0000)
src/HYDROGUI/HYDROGUI_CalculationOp.cxx
src/HYDROGUI/HYDROGUI_CalculationOp.h

index f6bd84498bef201b439aa22cf2c74f8d8cbe49dd..9165ad2a49598b65654fc59dacfa5a87e6384f2d 100644 (file)
@@ -92,7 +92,6 @@ void HYDROGUI_CalculationOp::startOperation()
     }
   }
 
-
   aPanel->reset();
   QStringList aList;
   QStringList anEntryList;
@@ -235,7 +234,7 @@ void HYDROGUI_CalculationOp::onBoundarySelected ( const QString & theObjName )
     myEditedObject->GetBoundaryPolyline();
   if ( !aPrevPolyline.IsNull() )
   {
-    module()->removeObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, aPrevPolyline );
+    setObjectVisibility( aPrevPolyline, false );
     anIsToUpdateViewer = true;
   }
 
@@ -254,13 +253,13 @@ void HYDROGUI_CalculationOp::onBoundarySelected ( const QString & theObjName )
         Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
         if ( !aCtx.IsNull() )
         {
-          showObject( aNewPolyline, aCtx );
+          setObjectVisibility( aNewPolyline, true );
           anIsToUpdateViewer = true;
         }
       }
 
       if ( anIsToUpdateViewer )
-        aViewer->update();
+        module()->update( UF_OCCViewer );
     }
   }
 }
@@ -465,10 +464,11 @@ void HYDROGUI_CalculationOp::onRemoveObjects()
     if ( anObject.IsNull() )
       continue;
 
-    module()->removeObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, anObject );
+    setObjectVisibility( anObject, false );
     myEditedObject->RemoveGeometryObject( anObject );
   }
 
+  module()->update( UF_OCCViewer );
   aPanel->excludeGeomObjects( aSelectedList );
 }
 
@@ -627,20 +627,13 @@ void HYDROGUI_CalculationOp::setZonesVisible( bool theIsVisible )
             HYDROData_SequenceOfObjects::Iterator aZonesIter( aZones );
             for ( ; aZonesIter.More(); aZonesIter.Next() )
             {
-              if ( theIsVisible )
-              {
-                showObject( aZonesIter.Value(), aCtx );
-              }
-              else
-              {
-                module()->removeObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, aZonesIter.Value() );
-              }
+              setObjectVisibility( aZonesIter.Value(), theIsVisible );
             }
           }
         }
       }
 
-      aViewer->update();
+      module()->update( UF_OCCViewer );
     }
   }
 }
@@ -711,7 +704,7 @@ void HYDROGUI_CalculationOp::createPreview()
       HYDROData_SequenceOfObjects::Iterator anIter( aSeq );
       for ( ; anIter.More(); anIter.Next() )
       {
-        showObject( anIter.Value(), aCtx );
+        setObjectVisibility( anIter.Value(), true );
       }
 
       //Process the draw events for viewer
@@ -720,21 +713,19 @@ void HYDROGUI_CalculationOp::createPreview()
         vw->onTopView();
     }
 
-    aViewer->update();
+    module()->update( UF_OCCViewer );
   }
 }
 
-void HYDROGUI_CalculationOp::showObject( Handle(HYDROData_Entity) theEntity, Handle(AIS_InteractiveContext) theCtx )
+void HYDROGUI_CalculationOp::setObjectVisibility( Handle(HYDROData_Entity) theEntity, const bool theIsVisible )
 {
-  if ( !theEntity.IsNull() )
-  {
-    HYDROGUI_Shape* aShape = module()->getObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, theEntity );
-    if ( !aShape )
-    {
-      aShape = new HYDROGUI_Shape( theCtx, theEntity );
-      module()->setObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, theEntity, aShape );
-    }
-    aShape->update( false );
+  if ( theEntity.IsNull() || !myPreviewViewManager ) {
+    return;
+  }
+
+  OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer();
+  if ( aViewer ) {
+    module()->setObjectVisible( (size_t)aViewer, theEntity, theIsVisible );
   }
 }
 
@@ -761,6 +752,19 @@ void HYDROGUI_CalculationOp::closePreview()
 
   if( myPreviewViewManager )
   {
+    // Hide all the displayed objects in the preview view
+    OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer();
+    if ( aViewer ) {
+      size_t aViewId = (size_t)aViewer;
+      HYDROData_Iterator anIterator( doc() );
+      for( ; anIterator.More(); anIterator.Next() ) {
+        Handle(HYDROData_Entity) anObject = anIterator.Current();
+        if( !anObject.IsNull() ) {
+          module()->setObjectVisible( aViewId, anObject, false );
+        }
+      }
+    }
+
     disconnect( myPreviewViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
                 this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) );
 
index c7c92fdef2637b7c71473da147521a34f0c9b231..829c01bbe3a42f64592f7ec146c1750857c65f0c 100644 (file)
@@ -113,10 +113,10 @@ protected slots:
 private:
   void                            createPreview();
   void                            closePreview();
-  void                            showObject( Handle(HYDROData_Entity) theEntity, Handle(AIS_InteractiveContext) theCtx );
+  void                            setObjectVisibility( Handle(HYDROData_Entity) theEntity, const bool theIsVisible );
   void                            setZonesVisible( bool theIsVisible );
   void                            getNamesAndEntries( const HYDROData_SequenceOfObjects& theSeq, 
-                                                QStringList& theNames, QStringList& theEntries ) const;
+                                                      QStringList& theNames, QStringList& theEntries ) const;
 
   /**
    * Ask user to confirm splitting zones recalculation.