From 6d592627e88a395398a02d7b884796e85331c1c1 Mon Sep 17 00:00:00 2001 From: mzn Date: Thu, 23 Oct 2014 11:56:04 +0000 Subject: [PATCH] Add warning on empty regions. --- src/HYDROGUI/HYDROGUI_CalculationOp.cxx | 47 ++++++++++++++++++++++- src/HYDROGUI/HYDROGUI_CalculationOp.h | 7 ++++ src/HYDROGUI/HYDROGUI_Wizard.cxx | 11 ++++++ src/HYDROGUI/HYDROGUI_Wizard.h | 2 + src/HYDROGUI/resources/HYDROGUI_msg_en.ts | 10 +++++ 5 files changed, 76 insertions(+), 1 deletion(-) diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx index 79a96110..f43261a3 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx @@ -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( 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 ); diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.h b/src/HYDROGUI/HYDROGUI_CalculationOp.h index d64b483e..271bb52d 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.h +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.h @@ -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; diff --git a/src/HYDROGUI/HYDROGUI_Wizard.cxx b/src/HYDROGUI/HYDROGUI_Wizard.cxx index 35707867..d9f4a37d 100644 --- a/src/HYDROGUI/HYDROGUI_Wizard.cxx +++ b/src/HYDROGUI/HYDROGUI_Wizard.cxx @@ -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; diff --git a/src/HYDROGUI/HYDROGUI_Wizard.h b/src/HYDROGUI/HYDROGUI_Wizard.h index 2d31434a..6699e8de 100644 --- a/src/HYDROGUI/HYDROGUI_Wizard.h +++ b/src/HYDROGUI/HYDROGUI_Wizard.h @@ -47,6 +47,8 @@ public: public slots: void onNext(); void onBack(); + + void onFirstPage(); signals: void Next( const int ); diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 27a76640..c99b8fe1 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -329,6 +329,16 @@ All supported formats (*.brep *.iges *.igs *.step *.stp) CONFIRM_SPLITTING_ZONES_RECALCULATION_MODE Case splitting zones already exist and will be recalculated after mode change. Do you confirm the recalculation? + + EMPTY_REGIONS + Empty regions + + + CONFIRM_CONTINUE_WITH_OBJECTS_NOT_INCLUDED_TO_REGION + Some objects are not included to any region: +%1. +Do you want to continue? + -- 2.39.2