Gestion des erreurs de données

This commit is contained in:
GERALD NICOLAS 2021-02-08 15:52:38 +01:00
parent 5560a9e80a
commit d90a581cef
7 changed files with 184 additions and 148 deletions

View File

@ -33,6 +33,6 @@ To start **Remeshing** operation, select **MG Adapt** tab in **Adaptation** dial
:align: center :align: center
.. note:: .. 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`. **See Also** a sample TUI Script of :ref:`tui_adaptation_page`.

View File

@ -84,7 +84,6 @@
#include <TCollection_AsciiString.hxx> #include <TCollection_AsciiString.hxx>
const int SPACING = 6; // layout spacing const int SPACING = 6; // layout spacing
const int MARGIN = 9; // layout margin const int MARGIN = 9; // layout margin
@ -135,32 +134,25 @@ void SMESHGUI_MgAdaptDlg::buildDlg()
myAdvOpt->logGroupBox ->setTitle(tr( "LOG_GROUP_TITLE" )); myAdvOpt->logGroupBox ->setTitle(tr( "LOG_GROUP_TITLE" ));
// buttons // buttons
QPushButton* okBtn = new QPushButton( tr( "SMESH_BUT_OK" ), this ); QPushButton* buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), this);
okBtn->setAutoDefault( true ); buttonOk->setAutoDefault(false);
okBtn->setDefault( true );
okBtn->setFocus();
QPushButton* buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), this); QPushButton* buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), this);
buttonApply->setAutoDefault(true); buttonApply->setAutoDefault(false);
QPushButton* buttonApplyAndClose = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), this); QPushButton* buttonCancel = new QPushButton( tr( "SMESH_BUT_CANCEL" ), this );
buttonApplyAndClose->setAutoDefault(true); buttonCancel->setAutoDefault( false );
QPushButton* cancelBtn = new QPushButton( tr( "SMESH_BUT_CANCEL" ), this ); QPushButton* buttonHelp = new QPushButton( tr( "SMESH_BUT_HELP" ), this );
cancelBtn->setAutoDefault( true ); buttonHelp->setAutoDefault( false );
QPushButton* helpBtn = new QPushButton( tr( "SMESH_BUT_HELP" ), this );
helpBtn->setAutoDefault( true );
QHBoxLayout* btnLayout = new QHBoxLayout; QHBoxLayout* btnLayout = new QHBoxLayout;
btnLayout->setSpacing( SPACING ); btnLayout->setSpacing( SPACING );
btnLayout->setMargin( 0 ); btnLayout->setMargin( 0 );
btnLayout->addWidget( buttonApplyAndClose ); btnLayout->addWidget( buttonOk );
btnLayout->addStretch( 10 ); btnLayout->addStretch( 10 );
btnLayout->addWidget( buttonApply ); btnLayout->addWidget( buttonApply );
btnLayout->addStretch( 10 ); btnLayout->addStretch( 10 );
btnLayout->addWidget( okBtn ); btnLayout->addWidget( buttonCancel );
btnLayout->addStretch( 10 ); btnLayout->addStretch( 10 );
btnLayout->addWidget( cancelBtn ); btnLayout->addWidget( buttonHelp );
btnLayout->addStretch( 10 );
btnLayout->addWidget( helpBtn );
okBtn->hide(); // tab 1
QVBoxLayout* l = new QVBoxLayout ( this ); QVBoxLayout* l = new QVBoxLayout ( this );
l->setMargin( MARGIN ); l->setMargin( MARGIN );
@ -169,13 +161,12 @@ void SMESHGUI_MgAdaptDlg::buildDlg()
l->addStretch(); l->addStretch();
l->addLayout( btnLayout ); 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( myArgs, SIGNAL(meshDimSignal(ADAPTATION_MODE)), myAdvOpt, SLOT( onMeshDimChanged(ADAPTATION_MODE)) );
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)) );
} }
@ -199,15 +190,15 @@ SMESH::MG_ADAPT_ptr SMESHGUI_MgAdaptDlg::getModel() const
/*! /*!
\brief Perform clean-up actions on the dialog box closing. \brief Perform clean-up actions on the dialog box closing.
*/ */
bool SMESHGUI_MgAdaptDlg::clickOnApply() bool SMESHGUI_MgAdaptDlg::PushOnApply()
{ {
readParamsFromWidgets(); bool ret = readParamsFromWidgets();
return true; return ret;
} }
void SMESHGUI_MgAdaptDlg::clickOnOk() void SMESHGUI_MgAdaptDlg::PushOnOK()
{ {
clickOnApply(); bool ret = PushOnApply();
reject(); if ( ret ) reject();
} }
void SMESHGUI_MgAdaptDlg::reject() void SMESHGUI_MgAdaptDlg::reject()
{ {
@ -292,103 +283,127 @@ bool SMESHGUI_MgAdaptDlg::readParamsFromHypo( ) const
} }
bool SMESHGUI_MgAdaptDlg::readParamsFromWidgets() bool SMESHGUI_MgAdaptDlg::readParamsFromWidgets()
{ {
bool ret = true; MESSAGE ("readParamsFromWidgets") ;
bool ret = true ;
SMESH::MgAdaptHypothesisData* aData = new SMESH::MgAdaptHypothesisData(); SMESH::MgAdaptHypothesisData* aData = new SMESH::MgAdaptHypothesisData();
aData->fromMedFile = myArgs->aMedfile->isChecked(); while ( ret )
if (aData->fromMedFile)
{ {
// 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();
aData->myFileInDir = CORBA::string_dup(myArgs->myFileInDir->toStdString().c_str()); // 3. Type de carte de tailles
aData->myMeshFileIn = CORBA::string_dup(myArgs->selectMedFileLineEdit->text().toStdString().c_str()); aData->myUseLocalMap = myArgs->localButton->isChecked();
// aData->myInMeshName = // TODO aData->myUseBackgroundMap = myArgs->backgroundButton->isChecked();
} aData->myUseConstantValue = myArgs->constantButton->isChecked();
else // TODO browser // 3.1. Constante
{ if (aData->myUseConstantValue)
aData->myInMeshName = CORBA::string_dup(myArgs->aBrowserObject->text().toStdString().c_str()); {
aData->myFileInDir = CORBA::string_dup(myAdvOpt->workingDirectoryLineEdit->text().toStdString().c_str()); 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 = "";
}
TCollection_AsciiString aGenericName = (char*)aData->myFileInDir; // 4. Le champ
TCollection_AsciiString aGenericName2 = "MgAdapt_"; if ( ! aData->myUseConstantValue )
aGenericName2 += getpid(); {
aGenericName2 += "_"; if ( strlen(myArgs->fieldNameCmb->currentText().toStdString().c_str()) == 0 )
aGenericName2 += Abs((Standard_Integer)(long) aGenericName.ToCString()); {
aGenericName2 += ".med"; QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"),
aGenericName+=aGenericName2; QObject::tr("MG_ADAPT_MED_FILE_5") );
emit myArgs->toExportMED(aGenericName.ToCString()); ret = false ;
aData->myMeshFileIn = aGenericName2.ToCString(); break ;
} }
aData->myOutMeshName = CORBA::string_dup(myArgs->meshNameLineEdit->text().toStdString().c_str()); {
aData->myMeshOutMed = myArgs->medFileCheckBox->isChecked(); aData->myFieldName = CORBA::string_dup(myArgs->fieldNameCmb->currentText().toStdString().c_str());
if(aData->myMeshOutMed) aData->myUseNoTimeStep = myArgs->noTimeStep->isChecked();
{ aData->myUseLastTimeStep = myArgs->lastTimeStep->isChecked();
aData->myFileOutDir = CORBA::string_dup(myArgs->myFileOutDir->toStdString().c_str()); aData->myUseChosenTimeStep = myArgs->chosenTimeStep->isChecked();
aData->myMeshFileOut = CORBA::string_dup(myArgs->selectOutMedFileLineEdit->text().toStdString().c_str()); if (aData->myUseChosenTimeStep)
{
aData->myRank = myArgs->rankSpinBox->value();
aData->myTimeStep = myArgs->timeStep->value();
}
}
}
} // 5. Options avancées
else aData->myWorkingDir = CORBA::string_dup(myAdvOpt->workingDirectoryLineEdit->text().toStdString().c_str());
{ aData->myPrintLogInFile = myAdvOpt->logInFileCheck->isChecked();
aData->myMeshFileOut = ""; aData->myVerboseLevel = myAdvOpt->verboseLevelSpin->value();
aData->myRemoveLogOnSuccess = myAdvOpt->removeLogOnSuccessCheck->isChecked();
aData->myKeepFiles = myAdvOpt->keepWorkingFilesCheck->isChecked();
model->setData(*aData);
QString msg;
checkParams(msg);
break ;
} }
aData->myPublish = myArgs->publishOut->isChecked();
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 = "";
}
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->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; delete aData;
return ret; return ret;
} }
bool SMESHGUI_MgAdaptDlg::storeParamsToHypo( const SMESH::MgAdaptHypothesisData& ) const bool SMESHGUI_MgAdaptDlg::storeParamsToHypo( const SMESH::MgAdaptHypothesisData& ) const
{ {
} }
/*! /*!
\brief Show help page \brief Show help page
*/ */
void SMESHGUI_MgAdaptDlg::clickOnHelp() void SMESHGUI_MgAdaptDlg::PushOnHelp()
{ {
// QString aHelpFile; // QString aHelpFile;
// if ( myTabWidget->currentIndex() == MinDistance ) { // if ( myTabWidget->currentIndex() == MinDistance ) {
// aHelpFile = "measurements.html#min-distance-anchor"; // aHelpFile = "measurements.html#min-distance-anchor";
// } else if ( myTabWidget->currentIndex() == BoundingBox ) { // } else if ( myTabWidget->currentIndex() == BoundingBox ) {
@ -399,7 +414,7 @@ void SMESHGUI_MgAdaptDlg::clickOnHelp()
// aHelpFile = "measurements.html#basic-properties-anchor"; // aHelpFile = "measurements.html#basic-properties-anchor";
// } // }
// SMESH::ShowHelpFile( aHelpFile ); // SMESH::ShowHelpFile( aHelpFile );
} }
bool SMESHGUI_MgAdaptDlg::checkParams(QString& msg) bool SMESHGUI_MgAdaptDlg::checkParams(QString& msg)
{ {
@ -407,7 +422,7 @@ bool SMESHGUI_MgAdaptDlg::checkParams(QString& msg)
{ {
SUIT_MessageBox::warning( this, SUIT_MessageBox::warning( this,
tr( "SMESH_WRN_WARNING" ), tr( "SMESH_WRN_WARNING" ),
tr( "GHS3D_PERMISSION_DENIED" ) ); tr( "NO_PERMISSION" ) );
return false; return false;
} }
@ -473,7 +488,7 @@ SMESHGUI_MgAdaptArguments::SMESHGUI_MgAdaptArguments( QWidget* parent )
aMeshIn = new QGroupBox( tr( "MeshIn" ), this ); aMeshIn = new QGroupBox( tr( "MeshIn" ), this );
aMedfile = new QRadioButton( tr( "MEDFile" ), aMeshIn ); aMedfile = new QRadioButton( tr( "MEDFile" ), aMeshIn );
aBrowser = new QRadioButton( tr( "Browser" ), aMeshIn ); aBrowser = new QRadioButton( tr( "Browser" ), aMeshIn );
aBrowserObject = new QLineEdit( aMeshIn ); aBrowserObject = new QLineEdit( aMeshIn );
selectMedFilebutton = new QPushButton("", aMeshIn); selectMedFilebutton = new QPushButton("", aMeshIn);
selectMedFileLineEdit = new QLineEdit( aMeshIn ); selectMedFileLineEdit = new QLineEdit( aMeshIn );
@ -1416,4 +1431,3 @@ std::string remove_extension(const std::string& filename)
if (lastdot == std::string::npos) return filename; if (lastdot == std::string::npos) return filename;
return filename.substr(0, lastdot); return filename.substr(0, lastdot);
} }

View File

@ -131,11 +131,12 @@ public:
public slots: public slots:
protected slots: protected slots:
virtual bool PushOnApply();
virtual bool clickOnApply();
private slots: private slots:
virtual void clickOnHelp(); virtual void PushOnHelp();
virtual void clickOnOk(); virtual void PushOnOK();
protected : protected :
SMESHGUI_MgAdaptArguments* myArgs; SMESHGUI_MgAdaptArguments* myArgs;

View File

@ -341,27 +341,44 @@ SMESH::SMESH_Mesh_var SMESHGUI_MG_ADAPTDRIVER::getMyMesh()
} }
//================================================================================= //=================================================================================
// function : ClickOnOk() // function : PushOnOk()
// purpose : // purpose :
//================================================================================= //=================================================================================
void SMESHGUI_MG_ADAPTDRIVER::clickOnOk() void SMESHGUI_MG_ADAPTDRIVER::PushOnOK()
{ {
setIsApplyAndClose( true ); setIsApplyAndClose( true );
clickOnApply(); bool ret = PushOnApply();
reject(); // std::cout << "SMESHGUI_MG_ADAPTDRIVER::PushOnOK ret : " <<ret<<std::endl;
if ( ret ) reject();
} }
bool SMESHGUI_MG_ADAPTDRIVER::clickOnApply() bool SMESHGUI_MG_ADAPTDRIVER::PushOnApply()
{ {
MESSAGE("PushOnApply");
if ( SMESHGUI::isStudyLocked() ) if ( SMESHGUI::isStudyLocked() )
return false; return false;
if( !isValid() ) if( !isValid() )
return false; return false;
SMESHGUI_MgAdaptDlg::clickOnApply(); bool ok = SMESHGUI_MgAdaptDlg::PushOnApply();
// std::cout << "SMESHGUI_MG_ADAPTDRIVER::PushOnApply ok 1 : " <<ok<<std::endl;
bool ok = execute(); if ( ok )
if (getModel()->getPublish()) this->createMeshInObjectBrowser(); {
ok = execute();
if (getModel()->getPublish()) this->createMeshInObjectBrowser();
// std::cout << "SMESHGUI_MG_ADAPTDRIVER::PushOnApply ok 2 : " <<ok<<std::endl;
if ( ok )
{
QMessageBox::information( 0, QObject::tr(""),
QObject::tr("MG_ADAPT_DIAG_1") );
}
else
{
QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"),
QObject::tr("MG_ADAPT_DIAG_2") );
}
}
return ok; return ok;
} }
@ -464,33 +481,21 @@ void SMESHGUI_MG_ADAPTDRIVER::keyPressEvent( QKeyEvent* e )
if ( e->key() == Qt::Key_F1 ) if ( e->key() == Qt::Key_F1 )
{ {
e->accept(); e->accept();
clickOnHelp(); PushOnHelp();
} }
} }
//================================================================================= //=================================================================================
// function : clickOnHelp() // function : PushOnHelp()
// purpose : // purpose :
//================================================================================= //=================================================================================
void SMESHGUI_MG_ADAPTDRIVER::clickOnHelp() void SMESHGUI_MG_ADAPTDRIVER::PushOnHelp()
{ {
LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication()); QString aHelpFile = "adaptation.html#_mg_adapt_anchor";
if (app)
app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName); SMESH::ShowHelpFile( aHelpFile );
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));
}
} }

View File

@ -190,10 +190,10 @@ private slots:
void exportMED(const char* ); void exportMED(const char* );
virtual bool clickOnApply(); virtual bool PushOnApply();
virtual void clickOnOk(); virtual void PushOnOK();
virtual void clickOnHelp(); virtual void PushOnHelp();
//~void SelectionIntoArgument();
void deactivateActiveDialog(); void deactivateActiveDialog();
void activateThisDialog(); void activateThisDialog();
void onConstructor( int ); void onConstructor( int );

View File

@ -430,7 +430,7 @@
</message> </message>
<message> <message>
<source>LOCAL_MG_ADAPT</source> <source>LOCAL_MG_ADAPT</source>
<translation>local</translation> <translation>Local</translation>
</message> </message>
<message> <message>
<source>BACKGRND_MG_ADAPT</source> <source>BACKGRND_MG_ADAPT</source>
@ -450,12 +450,20 @@
</message> </message>
<message> <message>
<source>SIZE_MAP_DEF</source> <source>SIZE_MAP_DEF</source>
<translation>size map definition</translation> <translation>Size map definition</translation>
</message> </message>
<message> <message>
<source>ADVOP</source> <source>ADVOP</source>
<translation>Advanced Options</translation> <translation>Advanced Options</translation>
</message> </message>
<message>
<source>MG_ADAPT_DIAG_1</source>
<translation>Adaptation succeeded.</translation>
</message>
<message>
<source>MG_ADAPT_DIAG_2</source>
<translation>Adaptation failed.</translation>
</message>
<message> <message>
<source>MEN_CONV_TO_QUAD</source> <source>MEN_CONV_TO_QUAD</source>
<translation>Convert to/from quadratic</translation> <translation>Convert to/from quadratic</translation>

View File

@ -456,6 +456,14 @@
<source>ADVOP</source> <source>ADVOP</source>
<translation>Options avancées</translation> <translation>Options avancées</translation>
</message> </message>
<message>
<source>MG_ADAPT_DIAG_1</source>
<translation>Adaptation réussie.</translation>
</message>
<message>
<source>MG_ADAPT_DIAG_2</source>
<translation>Echec de l'adaptation.</translation>
</message>
<message> <message>
<source>MEN_CONV_TO_QUAD</source> <source>MEN_CONV_TO_QUAD</source>
<translation>Convertir vers/depuis quadratique</translation> <translation>Convertir vers/depuis quadratique</translation>