]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Add warning on empty regions.
authormzn <mzn@opencascade.com>
Thu, 23 Oct 2014 11:56:04 +0000 (11:56 +0000)
committermzn <mzn@opencascade.com>
Thu, 23 Oct 2014 11:56:04 +0000 (11:56 +0000)
src/HYDROGUI/HYDROGUI_CalculationOp.cxx
src/HYDROGUI/HYDROGUI_CalculationOp.h
src/HYDROGUI/HYDROGUI_Wizard.cxx
src/HYDROGUI/HYDROGUI_Wizard.h
src/HYDROGUI/resources/HYDROGUI_msg_en.ts

index 79a9611092b81d4b3a1fe2d5c9ebce17470ffc74..f43261a3465ae8571b594e530a3129d0d5d12264 100644 (file)
@@ -543,6 +543,35 @@ bool HYDROGUI_CalculationOp::confirmModeChange() const
   return isConfirmed;
 }
 
+bool HYDROGUI_CalculationOp::confirmContinueWithWarning( const HYDROData_Warning& theWarning ) const
+{
+  HYDROData_WarningType aType = theWarning.Type;
+  if ( aType == WARN_OK ) {
+    return true;
+  }
+
+  QString aTitle;
+  QString aMsg;
+  switch ( aType )
+  {
+    case WARN_EMPTY_REGIONS:
+      aTitle = tr( "EMPTY_REGIONS" );
+      aMsg = tr( "CONFIRM_CONTINUE_WITH_OBJECTS_NOT_INCLUDED_TO_REGION" ).arg( theWarning.Data );
+      break;
+    default:
+      aTitle = tr( "WARNING" );
+      aMsg = theWarning.Data;
+  }
+
+
+  int anAnswer = SUIT_MessageBox::warning( module()->getApp()->desktop(),
+                                           aTitle, aMsg,
+                                           QMessageBox::Yes | QMessageBox::No,
+                                           QMessageBox::No );
+
+  return ( anAnswer == QMessageBox::Yes );
+}
+
 bool HYDROGUI_CalculationOp::processApply( int&     theUpdateFlags,
                                            QString& theErrorMsg,
                                            QStringList& theBrowseObjectsEntries )
@@ -565,6 +594,20 @@ bool HYDROGUI_CalculationOp::processApply( int&     theUpdateFlags,
 
 void HYDROGUI_CalculationOp::onApply()
 {
+  // Check warnings
+  HYDROData_Warning aWarning = myEditedObject->GetLastWarning();
+  if ( aWarning.Type != WARN_OK ) {
+    if ( !confirmContinueWithWarning( aWarning ) ) {
+      // Go back to the first page
+      HYDROGUI_CalculationDlg* aPanel = 
+        ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
+      if ( aPanel ) {
+        aPanel->onFirstPage();
+      }
+      return;
+    }
+  }
+
   QApplication::setOverrideCursor( Qt::WaitCursor );
 
   int anUpdateFlags = 0;
@@ -632,6 +675,9 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex )
     // automatic names generation for regions and zones
     myEditedObject->SetName( aNewCaseName );
 
+    // Clear rules
+    myEditedObject->ClearRules();
+
     // Set parameters for automatic mode
     int aMode = aPanel->getMode();
     if ( aMode == HYDROData_CalculationCase::AUTOMATIC ) {
@@ -648,7 +694,6 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex )
       }
 
       // Set priority rules
-      myEditedObject->ClearRules();
       foreach ( const HYDROData_CustomRule& aRule, aPanel->getRules() ) {
         myEditedObject->AddRule( aRule.Object1, aRule.Priority,
                                  aRule.Object2, aRule.MergeType );
index d64b483e7a729d03946baaced9833715f7a0bc1c..271bb52d6613d30822d346f3adc439c03dc1ca96 100644 (file)
@@ -138,6 +138,13 @@ private:
    */
   bool                            confirmModeChange() const;
 
+  /**
+   * Ask user to confirm the operation continuation with warning.
+   * @param theWarning the warning
+   * \return true if confirmed
+   */
+  bool                            confirmContinueWithWarning( const HYDROData_Warning& theWarning ) const;
+
 private:
   bool                            myIsEdit;
   bool                            myShowZones;
index 35707867c75380e4f0d562cda2427f3f40e26a4d..d9f4a37dde1dcf0e67328149ffc9ec589255e967 100644 (file)
@@ -130,6 +130,17 @@ void HYDROGUI_Wizard::onBack()
   emit Back( aCurIdx );
 }
 
+void HYDROGUI_Wizard::onFirstPage()
+{
+  if ( myWizard->count() > 1 ) {
+    myNext->setVisible( true );
+    myFinish->setVisible( false );
+    myWizard->setCurrentIndex( 0 );
+    myBack->setEnabled( false );
+    emit Back( myWizard->currentIndex() );
+  }
+}
+
 bool HYDROGUI_Wizard::acceptCurrent() const
 {
   return true;
index 2d31434ab1225f63887e4c1134c337ae3d2b64d4..6699e8de64739bf3c925569bee3df1df4b93ace0 100644 (file)
@@ -47,6 +47,8 @@ public:
 public slots:
   void             onNext();
   void             onBack();
+  
+  void             onFirstPage();
 
 signals:
   void             Next( const int );
index 27a76640d97db8f80477e96c5dae79531ac9e3ca..c99b8fe1d7a5ad88a9286ca859f68b0a28ce22ed 100644 (file)
@@ -329,6 +329,16 @@ All supported formats (*.brep *.iges *.igs *.step *.stp)</translation>
       <source>CONFIRM_SPLITTING_ZONES_RECALCULATION_MODE</source>
       <translation>Case splitting zones already exist and will be recalculated after mode change. Do you confirm the recalculation?</translation>
     </message>
+    <message>
+      <source>EMPTY_REGIONS</source>
+      <translation>Empty regions</translation>
+    </message>
+    <message>
+      <source>CONFIRM_CONTINUE_WITH_OBJECTS_NOT_INCLUDED_TO_REGION</source>
+      <translation>Some objects are not included to any region: 
+%1. 
+Do you want to continue?</translation>
+    </message>
   </context>
 
   <context>