Salome HOME
Fix for the bug #45: check and warning when the same image is used in 2 arguments.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_CalculationOp.cxx
index 6fb6cfb4ab9b2ee538421a3440dbcfdf7886ad5f..ad69b40c86fe7ae1690bb09178491878e8bc245a 100644 (file)
@@ -186,8 +186,8 @@ HYDROGUI_InputPanel* HYDROGUI_CalculationOp::createInputPanel() const
   // Connect signals and slots
   connect( aPanel, SIGNAL( addObjects() ), SLOT( onAddObjects() ) );
   connect( aPanel, SIGNAL( removeObjects() ), SLOT( onRemoveObjects() ) );
-  connect( aPanel, SIGNAL( splitZones() ), SLOT( onSplitZones() ) );
-  connect( aPanel, SIGNAL( hideZones() ), SLOT( onHideZones() ) );
+  connect( aPanel, SIGNAL( Next( const int ) ), SLOT( onSplitZones() ) );
+  connect( aPanel, SIGNAL( Back( const int ) ), SLOT( onHideZones() ) );
   connect( aPanel, SIGNAL( clicked( SUIT_DataObject* ) ), SLOT( onSelected( SUIT_DataObject* ) ) );
   connect( aPanel, SIGNAL( setMergeType( int, QString& ) ), SLOT( onSetMergeType( int, QString& ) ) );
   connect( aPanel, SIGNAL( moveZones( SUIT_DataObject*, const QList<SUIT_DataObject*>& ) ),
@@ -206,43 +206,39 @@ HYDROGUI_InputPanel* HYDROGUI_CalculationOp::createInputPanel() const
 
 void HYDROGUI_CalculationOp::onBoundarySelected ( const QString & theObjName )
 {
-  // Set the selected boundary polyline to the calculation case
-  Handle(HYDROData_PolylineXY) anObject;
-  Handle(AIS_InteractiveContext) aCtx;
-  if ( myPreviewViewManager ) 
-  {
-    if ( OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer() )
-    {
-      aCtx = aViewer->getAISContext();
-    }
-  }
+  bool anIsToUpdateViewer = false;
+
   // Remove the old boundary from the operation viewer
-  anObject = myEditedObject->GetBoundaryPolyline();
-  if ( !anObject.IsNull() )
+  Handle(HYDROData_PolylineXY) aPrevPolyline = 
+    myEditedObject->GetBoundaryPolyline();
+  if ( !aPrevPolyline.IsNull() )
   {
-    module()->removeObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, anObject );
+    module()->removeObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, aPrevPolyline );
+    anIsToUpdateViewer = true;
   }
 
-  if ( theObjName.trimmed().isEmpty() )
-  {
-    // No polyline is selected
-    myEditedObject->RemoveBoundaryPolyline();
-  }
-  else
+  // Set the selected boundary polyline to the calculation case
+  Handle(HYDROData_PolylineXY) aNewPolyline = Handle(HYDROData_PolylineXY)::DownCast(
+    HYDROGUI_Tool::FindObjectByName( module(), theObjName, KIND_POLYLINEXY ) );
+  myEditedObject->SetBoundaryPolyline( aNewPolyline );
+
+  if ( myPreviewViewManager )
   {
-    Handle(HYDROData_Entity) anEntity = 
-      HYDROGUI_Tool::FindObjectByName( module(), theObjName, KIND_POLYLINEXY );
-    if ( !anEntity.IsNull() )
+    OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer();
+    if ( aViewer )
     {
-      anObject = Handle(HYDROData_PolylineXY)::DownCast( anEntity );
-      if ( !anObject.IsNull() )
+      if ( !aNewPolyline.IsNull() )
       {
-        myEditedObject->SetBoundaryPolyline( anObject );
+        Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
         if ( !aCtx.IsNull() )
         {
-          showObject( anEntity, aCtx );
+          showObject( aNewPolyline, aCtx );
+          anIsToUpdateViewer = true;
         }
       }
+
+      if ( anIsToUpdateViewer )
+        aViewer->update();
     }
   }
 }
@@ -560,7 +556,7 @@ void HYDROGUI_CalculationOp::onSplitZones()
   if ( myEditedObject->IsMustBeUpdated() )
   {
     myShowZones = true;
-    myEditedObject->SplitGeometryObjects();
+    myEditedObject->Update();
 
     aPanel->setEditedObject( myEditedObject );
 
@@ -617,6 +613,8 @@ void HYDROGUI_CalculationOp::setZonesVisible( bool theIsVisible )
           }
         }
       }
+
+      aViewer->update();
     }
   }
 }
@@ -695,6 +693,8 @@ void HYDROGUI_CalculationOp::createPreview()
       if ( OCCViewer_ViewWindow* vw = (OCCViewer_ViewWindow*)myPreviewViewManager->getActiveView() )
         vw->onTopView();
     }
+
+    aViewer->update();
   }
 }
 
@@ -708,7 +708,7 @@ void HYDROGUI_CalculationOp::showObject( Handle(HYDROData_Entity) theEntity, Han
       aShape = new HYDROGUI_Shape( theCtx, theEntity );
       module()->setObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, theEntity, aShape );
     }
-    aShape->update();
+    aShape->update( false );
   }
 }