From d90a581cefcc55423f12edd390bd91118a4a6b0c Mon Sep 17 00:00:00 2001 From: GERALD NICOLAS Date: Mon, 8 Feb 2021 15:52:38 +0100 Subject: [PATCH] =?utf8?q?Gestion=20des=20erreurs=20de=20donn=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- doc/salome/gui/SMESH/input/adaptation.rst | 2 +- src/SMESHGUI/MG_ADAPTGUI.cxx | 238 ++++++++++++---------- src/SMESHGUI/MG_ADAPTGUI.hxx | 7 +- src/SMESHGUI/SMESHGUI_MG_ADAPTDRIVER.cxx | 57 +++--- src/SMESHGUI/SMESHGUI_MG_ADAPTDRIVER.h | 8 +- src/SMESHGUI/SMESH_msg_en.ts | 12 +- src/SMESHGUI/SMESH_msg_fr.ts | 8 + 7 files changed, 184 insertions(+), 148 deletions(-) diff --git a/doc/salome/gui/SMESH/input/adaptation.rst b/doc/salome/gui/SMESH/input/adaptation.rst index bb048aefb..624851d75 100644 --- a/doc/salome/gui/SMESH/input/adaptation.rst +++ b/doc/salome/gui/SMESH/input/adaptation.rst @@ -33,6 +33,6 @@ To start **Remeshing** operation, select **MG Adapt** tab in **Adaptation** dial :align: center .. note:: - The exhaustive description of MG-Adapt can be read into its documentation. It can be reached bu the general help button. + The exhaustive description of MG-Adapt can be read into its documentation. It can be reached by the general help button. **See Also** a sample TUI Script of :ref:`tui_adaptation_page`. diff --git a/src/SMESHGUI/MG_ADAPTGUI.cxx b/src/SMESHGUI/MG_ADAPTGUI.cxx index b2ab3b7d6..8a31faa72 100644 --- a/src/SMESHGUI/MG_ADAPTGUI.cxx +++ b/src/SMESHGUI/MG_ADAPTGUI.cxx @@ -84,7 +84,6 @@ #include - const int SPACING = 6; // layout spacing const int MARGIN = 9; // layout margin @@ -135,32 +134,25 @@ void SMESHGUI_MgAdaptDlg::buildDlg() myAdvOpt->logGroupBox ->setTitle(tr( "LOG_GROUP_TITLE" )); // buttons - QPushButton* okBtn = new QPushButton( tr( "SMESH_BUT_OK" ), this ); - okBtn->setAutoDefault( true ); - okBtn->setDefault( true ); - okBtn->setFocus(); + QPushButton* buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), this); + buttonOk->setAutoDefault(false); QPushButton* buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), this); - buttonApply->setAutoDefault(true); - QPushButton* buttonApplyAndClose = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), this); - buttonApplyAndClose->setAutoDefault(true); - QPushButton* cancelBtn = new QPushButton( tr( "SMESH_BUT_CANCEL" ), this ); - cancelBtn->setAutoDefault( true ); - QPushButton* helpBtn = new QPushButton( tr( "SMESH_BUT_HELP" ), this ); - helpBtn->setAutoDefault( true ); + buttonApply->setAutoDefault(false); + QPushButton* buttonCancel = new QPushButton( tr( "SMESH_BUT_CANCEL" ), this ); + buttonCancel->setAutoDefault( false ); + QPushButton* buttonHelp = new QPushButton( tr( "SMESH_BUT_HELP" ), this ); + buttonHelp->setAutoDefault( false ); QHBoxLayout* btnLayout = new QHBoxLayout; btnLayout->setSpacing( SPACING ); btnLayout->setMargin( 0 ); - btnLayout->addWidget( buttonApplyAndClose ); + btnLayout->addWidget( buttonOk ); btnLayout->addStretch( 10 ); btnLayout->addWidget( buttonApply ); btnLayout->addStretch( 10 ); - btnLayout->addWidget( okBtn ); - btnLayout->addStretch( 10 ); - btnLayout->addWidget( cancelBtn ); + btnLayout->addWidget( buttonCancel ); btnLayout->addStretch( 10 ); - btnLayout->addWidget( helpBtn ); - okBtn->hide(); // tab 1 + btnLayout->addWidget( buttonHelp ); QVBoxLayout* l = new QVBoxLayout ( this ); l->setMargin( MARGIN ); @@ -169,13 +161,12 @@ void SMESHGUI_MgAdaptDlg::buildDlg() l->addStretch(); l->addLayout( btnLayout ); + connect( buttonOk, SIGNAL(pressed()), this, SLOT(PushOnOK())); + connect( buttonApply, SIGNAL(pressed()), this, SLOT(PushOnApply())); + connect( buttonCancel, SIGNAL(pressed()), this, SLOT(close())); + connect( buttonHelp, SIGNAL(pressed()), this, SLOT(PushOnHelp())); - connect( okBtn, SIGNAL(clicked()), this, SLOT( clickOnOk() ) ); - connect( helpBtn, SIGNAL(clicked()), this, SLOT( clickOnHelp() ) ); - connect(cancelBtn, SIGNAL(clicked()), this, SLOT(reject())); - connect(buttonApply, SIGNAL(clicked()), this,SLOT(clickOnApply())); - connect(buttonApplyAndClose, SIGNAL(clicked()), this,SLOT(clickOnOk())); - connect(myArgs, SIGNAL(meshDimSignal(ADAPTATION_MODE)), myAdvOpt, SLOT( onMeshDimChanged(ADAPTATION_MODE)) ); + connect( myArgs, SIGNAL(meshDimSignal(ADAPTATION_MODE)), myAdvOpt, SLOT( onMeshDimChanged(ADAPTATION_MODE)) ); } @@ -199,15 +190,15 @@ SMESH::MG_ADAPT_ptr SMESHGUI_MgAdaptDlg::getModel() const /*! \brief Perform clean-up actions on the dialog box closing. */ -bool SMESHGUI_MgAdaptDlg::clickOnApply() +bool SMESHGUI_MgAdaptDlg::PushOnApply() { - readParamsFromWidgets(); - return true; + bool ret = readParamsFromWidgets(); + return ret; } -void SMESHGUI_MgAdaptDlg::clickOnOk() +void SMESHGUI_MgAdaptDlg::PushOnOK() { - clickOnApply(); - reject(); + bool ret = PushOnApply(); + if ( ret ) reject(); } void SMESHGUI_MgAdaptDlg::reject() { @@ -292,103 +283,127 @@ bool SMESHGUI_MgAdaptDlg::readParamsFromHypo( ) const } - bool SMESHGUI_MgAdaptDlg::readParamsFromWidgets() { - bool ret = true; + MESSAGE ("readParamsFromWidgets") ; + bool ret = true ; SMESH::MgAdaptHypothesisData* aData = new SMESH::MgAdaptHypothesisData(); - aData->fromMedFile = myArgs->aMedfile->isChecked(); - if (aData->fromMedFile) - { - - aData->myFileInDir = CORBA::string_dup(myArgs->myFileInDir->toStdString().c_str()); - aData->myMeshFileIn = CORBA::string_dup(myArgs->selectMedFileLineEdit->text().toStdString().c_str()); - // aData->myInMeshName = // TODO - } - else // TODO browser + while ( ret ) { - aData->myInMeshName = CORBA::string_dup(myArgs->aBrowserObject->text().toStdString().c_str()); - aData->myFileInDir = CORBA::string_dup(myAdvOpt->workingDirectoryLineEdit->text().toStdString().c_str()); - - TCollection_AsciiString aGenericName = (char*)aData->myFileInDir; - TCollection_AsciiString aGenericName2 = "MgAdapt_"; - aGenericName2 += getpid(); - aGenericName2 += "_"; - aGenericName2 += Abs((Standard_Integer)(long) aGenericName.ToCString()); - aGenericName2 += ".med"; - aGenericName+=aGenericName2; - emit myArgs->toExportMED(aGenericName.ToCString()); - aData->myMeshFileIn = aGenericName2.ToCString(); - } - aData->myOutMeshName = CORBA::string_dup(myArgs->meshNameLineEdit->text().toStdString().c_str()); - aData->myMeshOutMed = myArgs->medFileCheckBox->isChecked(); - if(aData->myMeshOutMed) - { - aData->myFileOutDir = CORBA::string_dup(myArgs->myFileOutDir->toStdString().c_str()); - aData->myMeshFileOut = CORBA::string_dup(myArgs->selectOutMedFileLineEdit->text().toStdString().c_str()); - - } - else - { - aData->myMeshFileOut = ""; - } - - aData->myPublish = myArgs->publishOut->isChecked(); - + // 1. Fichier du maillage de départ + aData->fromMedFile = myArgs->aMedfile->isChecked(); + if (aData->fromMedFile) + { + aData->myFileInDir = CORBA::string_dup(myArgs->myFileInDir->toStdString().c_str()); + aData->myMeshFileIn = CORBA::string_dup(myArgs->selectMedFileLineEdit->text().toStdString().c_str()); + // aData->myInMeshName = // TODO + } + else // TODO browser + { + QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"), + QObject::tr("MG_ADAPT_MED_FILE_4") ); + ret = false ; + break ; + // aData->myInMeshName = CORBA::string_dup(myArgs->aBrowserObject->text().toStdString().c_str()); + // aData->myFileInDir = CORBA::string_dup(myAdvOpt->workingDirectoryLineEdit->text().toStdString().c_str()); + // + // TCollection_AsciiString aGenericName = (char*)aData->myFileInDir; + // TCollection_AsciiString aGenericName2 = "MgAdapt_"; + // aGenericName2 += getpid(); + // aGenericName2 += "_"; + // aGenericName2 += Abs((Standard_Integer)(long) aGenericName.ToCString()); + // aGenericName2 += ".med"; + // aGenericName+=aGenericName2; + // emit myArgs->toExportMED(aGenericName.ToCString()); + // aData->myMeshFileIn = aGenericName2.ToCString(); + } + // 2. Fichier du maillage de sortie + aData->myOutMeshName = CORBA::string_dup(myArgs->meshNameLineEdit->text().toStdString().c_str()); + aData->myMeshOutMed = myArgs->medFileCheckBox->isChecked(); + if(aData->myMeshOutMed) + { + aData->myFileOutDir = CORBA::string_dup(myArgs->myFileOutDir->toStdString().c_str()); + aData->myMeshFileOut = CORBA::string_dup(myArgs->selectOutMedFileLineEdit->text().toStdString().c_str()); + } + else + { + aData->myMeshFileOut = ""; + } + aData->myPublish = myArgs->publishOut->isChecked(); + + // 3. Type de carte de tailles + aData->myUseLocalMap = myArgs->localButton->isChecked(); + aData->myUseBackgroundMap = myArgs->backgroundButton->isChecked(); + aData->myUseConstantValue = myArgs->constantButton->isChecked(); + // 3.1. Constante + if (aData->myUseConstantValue) + { + aData->myConstantValue = myArgs->dvalue->value(); + } + else + { + aData->myConstantValue = 0.0; + } + // 3.2. Arrière-plan + if (aData->myUseBackgroundMap) + { + aData->myFileSizeMapDir = CORBA::string_dup(myArgs->myFileSizeMapDir->toStdString().c_str()); + aData->myMeshFileBackground = CORBA::string_dup(myArgs->selectMedFileBackgroundLineEdit->text().toStdString().c_str()); + } + else + { + aData->myMeshFileBackground = ""; + } - aData->myUseLocalMap = myArgs->localButton->isChecked(); - aData->myUseBackgroundMap = myArgs->backgroundButton->isChecked(); - aData->myUseConstantValue = myArgs->constantButton->isChecked(); - if (aData->myUseConstantValue) - { - aData->myConstantValue = myArgs->dvalue->value(); - } - else - { - aData->myConstantValue = 0.0; - } - if (aData->myUseBackgroundMap) - { - aData->myFileSizeMapDir = CORBA::string_dup(myArgs->myFileSizeMapDir->toStdString().c_str()); - aData->myMeshFileBackground = CORBA::string_dup(myArgs->selectMedFileBackgroundLineEdit->text().toStdString().c_str()); - } - else - { - aData->myMeshFileBackground = ""; - } + // 4. Le champ + if ( ! aData->myUseConstantValue ) + { + if ( strlen(myArgs->fieldNameCmb->currentText().toStdString().c_str()) == 0 ) + { + QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"), + QObject::tr("MG_ADAPT_MED_FILE_5") ); + ret = false ; + break ; + } + { + aData->myFieldName = CORBA::string_dup(myArgs->fieldNameCmb->currentText().toStdString().c_str()); + aData->myUseNoTimeStep = myArgs->noTimeStep->isChecked(); + aData->myUseLastTimeStep = myArgs->lastTimeStep->isChecked(); + aData->myUseChosenTimeStep = myArgs->chosenTimeStep->isChecked(); + if (aData->myUseChosenTimeStep) + { + aData->myRank = myArgs->rankSpinBox->value(); + aData->myTimeStep = myArgs->timeStep->value(); + } + } + } - aData->myFieldName = CORBA::string_dup(myArgs->fieldNameCmb->currentText().toStdString().c_str()); - aData->myUseNoTimeStep = myArgs->noTimeStep->isChecked(); - aData->myUseLastTimeStep = myArgs->lastTimeStep->isChecked(); - aData->myUseChosenTimeStep = myArgs->chosenTimeStep->isChecked(); - if (aData->myUseChosenTimeStep) - { - aData->myRank = myArgs->rankSpinBox->value(); - aData->myTimeStep = myArgs->timeStep->value(); + // 5. Options avancées + aData->myWorkingDir = CORBA::string_dup(myAdvOpt->workingDirectoryLineEdit->text().toStdString().c_str()); + aData->myPrintLogInFile = myAdvOpt->logInFileCheck->isChecked(); + aData->myVerboseLevel = myAdvOpt->verboseLevelSpin->value(); + aData->myRemoveLogOnSuccess = myAdvOpt->removeLogOnSuccessCheck->isChecked(); + aData->myKeepFiles = myAdvOpt->keepWorkingFilesCheck->isChecked(); + model->setData(*aData); + QString msg; + checkParams(msg); + break ; } - aData->myWorkingDir = CORBA::string_dup(myAdvOpt->workingDirectoryLineEdit->text().toStdString().c_str()); - aData->myPrintLogInFile = myAdvOpt->logInFileCheck->isChecked(); - aData->myVerboseLevel = myAdvOpt->verboseLevelSpin->value(); - aData->myRemoveLogOnSuccess = myAdvOpt->removeLogOnSuccessCheck->isChecked(); - aData->myKeepFiles = myAdvOpt->keepWorkingFilesCheck->isChecked(); - model->setData(*aData); - QString msg; - checkParams(msg); delete aData; + return ret; } bool SMESHGUI_MgAdaptDlg::storeParamsToHypo( const SMESH::MgAdaptHypothesisData& ) const { - } /*! \brief Show help page */ -void SMESHGUI_MgAdaptDlg::clickOnHelp() +void SMESHGUI_MgAdaptDlg::PushOnHelp() { - // QString aHelpFile; +// QString aHelpFile; // if ( myTabWidget->currentIndex() == MinDistance ) { // aHelpFile = "measurements.html#min-distance-anchor"; // } else if ( myTabWidget->currentIndex() == BoundingBox ) { @@ -399,7 +414,7 @@ void SMESHGUI_MgAdaptDlg::clickOnHelp() // aHelpFile = "measurements.html#basic-properties-anchor"; // } - // SMESH::ShowHelpFile( aHelpFile ); +// SMESH::ShowHelpFile( aHelpFile ); } bool SMESHGUI_MgAdaptDlg::checkParams(QString& msg) { @@ -407,7 +422,7 @@ bool SMESHGUI_MgAdaptDlg::checkParams(QString& msg) { SUIT_MessageBox::warning( this, tr( "SMESH_WRN_WARNING" ), - tr( "GHS3D_PERMISSION_DENIED" ) ); + tr( "NO_PERMISSION" ) ); return false; } @@ -473,7 +488,7 @@ SMESHGUI_MgAdaptArguments::SMESHGUI_MgAdaptArguments( QWidget* parent ) aMeshIn = new QGroupBox( tr( "MeshIn" ), this ); aMedfile = new QRadioButton( tr( "MEDFile" ), aMeshIn ); aBrowser = new QRadioButton( tr( "Browser" ), aMeshIn ); - aBrowserObject = new QLineEdit( aMeshIn ); + aBrowserObject = new QLineEdit( aMeshIn ); selectMedFilebutton = new QPushButton("", aMeshIn); selectMedFileLineEdit = new QLineEdit( aMeshIn ); @@ -1416,4 +1431,3 @@ std::string remove_extension(const std::string& filename) if (lastdot == std::string::npos) return filename; return filename.substr(0, lastdot); } - diff --git a/src/SMESHGUI/MG_ADAPTGUI.hxx b/src/SMESHGUI/MG_ADAPTGUI.hxx index 853b2683e..823a5afa9 100644 --- a/src/SMESHGUI/MG_ADAPTGUI.hxx +++ b/src/SMESHGUI/MG_ADAPTGUI.hxx @@ -131,11 +131,12 @@ public: public slots: protected slots: + virtual bool PushOnApply(); -virtual bool clickOnApply(); private slots: -virtual void clickOnHelp(); -virtual void clickOnOk(); + virtual void PushOnHelp(); + virtual void PushOnOK(); + protected : SMESHGUI_MgAdaptArguments* myArgs; diff --git a/src/SMESHGUI/SMESHGUI_MG_ADAPTDRIVER.cxx b/src/SMESHGUI/SMESHGUI_MG_ADAPTDRIVER.cxx index 77ccb41d2..fc1496380 100644 --- a/src/SMESHGUI/SMESHGUI_MG_ADAPTDRIVER.cxx +++ b/src/SMESHGUI/SMESHGUI_MG_ADAPTDRIVER.cxx @@ -341,27 +341,44 @@ SMESH::SMESH_Mesh_var SMESHGUI_MG_ADAPTDRIVER::getMyMesh() } //================================================================================= -// function : ClickOnOk() +// function : PushOnOk() // purpose : //================================================================================= -void SMESHGUI_MG_ADAPTDRIVER::clickOnOk() +void SMESHGUI_MG_ADAPTDRIVER::PushOnOK() { setIsApplyAndClose( true ); - clickOnApply(); - reject(); + bool ret = PushOnApply(); +// std::cout << "SMESHGUI_MG_ADAPTDRIVER::PushOnOK ret : " <getPublish()) this->createMeshInObjectBrowser(); + if ( ok ) + { + ok = execute(); + if (getModel()->getPublish()) this->createMeshInObjectBrowser(); +// std::cout << "SMESHGUI_MG_ADAPTDRIVER::PushOnApply ok 2 : " <key() == Qt::Key_F1 ) { e->accept(); - clickOnHelp(); + PushOnHelp(); } } //================================================================================= -// function : clickOnHelp() +// function : PushOnHelp() // purpose : //================================================================================= -void SMESHGUI_MG_ADAPTDRIVER::clickOnHelp() +void SMESHGUI_MG_ADAPTDRIVER::PushOnHelp() { - LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication()); - if (app) - app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName); - else { - QString platform; -#ifdef WIN32 - platform = "winapplication"; -#else - platform = "application"; -#endif - SUIT_MessageBox::warning(this, tr("WRN_WARNING"), - tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). - arg(app->resourceMgr()->stringValue("ExternalBrowser",platform)). - arg(myHelpFileName)); - } + QString aHelpFile = "adaptation.html#_mg_adapt_anchor"; + + SMESH::ShowHelpFile( aHelpFile ); } diff --git a/src/SMESHGUI/SMESHGUI_MG_ADAPTDRIVER.h b/src/SMESHGUI/SMESHGUI_MG_ADAPTDRIVER.h index e73a77795..f68398525 100644 --- a/src/SMESHGUI/SMESHGUI_MG_ADAPTDRIVER.h +++ b/src/SMESHGUI/SMESHGUI_MG_ADAPTDRIVER.h @@ -190,10 +190,10 @@ private slots: void exportMED(const char* ); - virtual bool clickOnApply(); - virtual void clickOnOk(); - virtual void clickOnHelp(); - //~void SelectionIntoArgument(); + virtual bool PushOnApply(); + virtual void PushOnOK(); + virtual void PushOnHelp(); + void deactivateActiveDialog(); void activateThisDialog(); void onConstructor( int ); diff --git a/src/SMESHGUI/SMESH_msg_en.ts b/src/SMESHGUI/SMESH_msg_en.ts index 23c92f86b..fcac5cfe7 100644 --- a/src/SMESHGUI/SMESH_msg_en.ts +++ b/src/SMESHGUI/SMESH_msg_en.ts @@ -430,7 +430,7 @@ LOCAL_MG_ADAPT - local + Local BACKGRND_MG_ADAPT @@ -450,12 +450,20 @@ SIZE_MAP_DEF - size map definition + Size map definition ADVOP Advanced Options + + MG_ADAPT_DIAG_1 + Adaptation succeeded. + + + MG_ADAPT_DIAG_2 + Adaptation failed. + MEN_CONV_TO_QUAD Convert to/from quadratic diff --git a/src/SMESHGUI/SMESH_msg_fr.ts b/src/SMESHGUI/SMESH_msg_fr.ts index 95306a7ec..9cdbdd649 100644 --- a/src/SMESHGUI/SMESH_msg_fr.ts +++ b/src/SMESHGUI/SMESH_msg_fr.ts @@ -456,6 +456,14 @@ ADVOP Options avancées + + MG_ADAPT_DIAG_1 + Adaptation réussie. + + + MG_ADAPT_DIAG_2 + Echec de l'adaptation. + MEN_CONV_TO_QUAD Convertir vers/depuis quadratique -- 2.39.2