]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Fix for the bug #49: Message box on objects list change is absent
authorrkv <rkv@opencascade.com>
Tue, 12 Nov 2013 13:12:32 +0000 (13:12 +0000)
committerrkv <rkv@opencascade.com>
Tue, 12 Nov 2013 13:12:32 +0000 (13:12 +0000)
src/HYDROGUI/HYDROGUI_CalculationOp.cxx
src/HYDROGUI/HYDROGUI_CalculationOp.h
src/HYDROGUI/resources/HYDROGUI_msg_en.ts

index 0433f520d77185f25ee47d3340ebd532604254fc..093b78fa412643a56118c17a42d097652b0e5d1c 100644 (file)
@@ -209,7 +209,6 @@ void HYDROGUI_CalculationOp::onBoundarySelected ( const QString & theObjName )
 {
   // Set the selected boundary polyline to the calculation case
   Handle(HYDROData_Polyline) anObject;
-  HYDROGUI_Shape* aShape;
   Handle(AIS_InteractiveContext) aCtx;
   if ( myPreviewViewManager ) 
   {
@@ -410,29 +409,32 @@ void HYDROGUI_CalculationOp::onAddObjects()
   if ( aPanel )
   {
     // Add geometry objects selected in the module browser to the calculation case
-    Handle(HYDROData_Object) anObject;
-    Handle(HYDROData_Entity) anEntity;
-    QStringList aList;
     QStringList aSelectedList = aPanel->getSelectedAvailableGeomObjects();
-    for (int i = 0; i < aSelectedList.length(); i++)
+    if ( ( !aSelectedList.isEmpty() ) && ( confirmRegionsChange() ) )
     {
-      anEntity = HYDROGUI_Tool::FindObjectByName( module(), aSelectedList.at(i) );
-      if ( !anEntity.IsNull() )
+      Handle(HYDROData_Object) anObject;
+      Handle(HYDROData_Entity) anEntity;
+      QStringList aList;
+      for (int i = 0; i < aSelectedList.length(); i++)
       {
-        anObject = Handle(HYDROData_Object)::DownCast( anEntity );
-        if ( !anObject.IsNull() )
+        anEntity = HYDROGUI_Tool::FindObjectByName( module(), aSelectedList.at(i) );
+        if ( !anEntity.IsNull() )
         {
-          if (myEditedObject->AddGeometryObject( anObject ))
+          anObject = Handle(HYDROData_Object)::DownCast( anEntity );
+          if ( !anObject.IsNull() )
           {
-            aList.append( anObject->GetName() );
+            if (myEditedObject->AddGeometryObject( anObject ))
+            {
+              aList.append( anObject->GetName() );
+            }
           }
         }
       }
-    }
-    if ( !aList.isEmpty() )
-    {
-      aPanel->includeGeomObjects( aList );
-      createPreview();
+      if ( !aList.isEmpty() )
+      {
+        aPanel->includeGeomObjects( aList );
+        createPreview();
+      }
     }
   }
 }
@@ -445,26 +447,50 @@ void HYDROGUI_CalculationOp::onRemoveObjects()
   if ( aPanel )
   {
     QStringList aList = aPanel->getSelectedGeomObjects();
-    Handle(HYDROData_Object) anObject;
-    Handle(HYDROData_Entity) anEntity;
-    for (int i = 0; i < aList.length(); i++)
+    if ( ( !aList.isEmpty() ) && ( confirmRegionsChange() ) )
     {
-      anEntity = HYDROGUI_Tool::FindObjectByName( module(), aList.at(i) );
-      if ( !anEntity.IsNull() )
+      Handle(HYDROData_Object) anObject;
+      Handle(HYDROData_Entity) anEntity;
+      for (int i = 0; i < aList.length(); i++)
       {
-        anObject = Handle(HYDROData_Object)::DownCast( anEntity );
-        if ( !anObject.IsNull() )
+        anEntity = HYDROGUI_Tool::FindObjectByName( module(), aList.at(i) );
+        if ( !anEntity.IsNull() )
         {
-          module()->removeObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, anObject );
-          myEditedObject->RemoveGeometryObject( anObject );
+          anObject = Handle(HYDROData_Object)::DownCast( anEntity );
+          if ( !anObject.IsNull() )
+          {
+            module()->removeObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, anObject );
+            myEditedObject->RemoveGeometryObject( anObject );
+          }
         }
       }
+      if ( !aList.isEmpty() )
+      {
+        aPanel->excludeGeomObjects( aList );
+      }
     }
-    if ( !aList.isEmpty() )
+  }
+}
+
+bool HYDROGUI_CalculationOp::confirmRegionsChange() const
+{
+  // Check if the case is already modified or not
+  bool isConfirmed = myEditedObject->IsMustBeUpdated();
+  if ( !isConfirmed )
+  {
+    // If not modified check if the case has already defined regions with zones
+    HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions();
+    if ( aSeq.Length() > 0 )
     {
-      aPanel->excludeGeomObjects( aList );
+      // If there are already defined zones then ask a user to confirm zones recalculation
+      isConfirmed = ( SUIT_MessageBox::question( module()->getApp()->desktop(),
+                               tr( "REGIONS_CHANGED" ),
+                               tr( "CONFIRM_SPLITTING_ZONES_RECALCULATION" ),
+                               QMessageBox::Yes | QMessageBox::No,
+                               QMessageBox::No ) == QMessageBox::Yes );
     }
   }
+  return isConfirmed;
 }
 
 bool HYDROGUI_CalculationOp::processApply( int&     theUpdateFlags,
index 274f144c3e6f3d8b79f519a4ba32065762633726..bf449bde2826ab0514c550fa7f69fe3ccdd41ba2 100644 (file)
@@ -105,6 +105,11 @@ private:
   void                            setZonesVisible( bool theIsVisible );
   void                            getNamesAndEntries( const HYDROData_SequenceOfObjects& theSeq, 
                                                 QStringList& theNames, QStringList& theEntries ) const;
+  /**
+   * Ask user to confirm splitting zones recalculation.
+   * \return true if confirmed
+   */
+  bool                            confirmRegionsChange() const;
 
 private:
   bool                            myIsEdit;
index 8a4450400067c7fedf0a2132c74b47a7216d29e0..56aa68926acf1406b6f6cb2197f473a6a1161980 100644 (file)
@@ -180,6 +180,14 @@ does not exist or you have not enough permissions to open it.</translation>
       <source>PREVIEW_CASE_ZONES</source>
       <translation>Preview case zones</translation>
     </message>
+    <message>
+      <source>REGIONS_CHANGED</source>
+      <translation>Regions list modification</translation>
+    </message>
+    <message>
+      <source>CONFIRM_SPLITTING_ZONES_RECALCULATION</source>
+      <translation>Case splitting zones already exist and will be recalculated after regions list modification. Do you confirm the recalculation?</translation>
+    </message>
   </context>
 
   <context>