]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
Gestion des erreurs de données
authorGERALD NICOLAS <D68518@dsp0864451.atlas.edf.fr>
Mon, 8 Feb 2021 14:52:38 +0000 (15:52 +0100)
committerGERALD NICOLAS <D68518@dsp0864451.atlas.edf.fr>
Mon, 8 Feb 2021 14:52:38 +0000 (15:52 +0100)
doc/salome/gui/SMESH/input/adaptation.rst
src/SMESHGUI/MG_ADAPTGUI.cxx
src/SMESHGUI/MG_ADAPTGUI.hxx
src/SMESHGUI/SMESHGUI_MG_ADAPTDRIVER.cxx
src/SMESHGUI/SMESHGUI_MG_ADAPTDRIVER.h
src/SMESHGUI/SMESH_msg_en.ts
src/SMESHGUI/SMESH_msg_fr.ts

index bb048aefb981db4962db81ac6597e8a0c9914483..624851d7542cb3a7e4853bfbb28fae10953dd958 100644 (file)
@@ -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`.
index b2ab3b7d6a75e7c55d9fc4be84d25033bd3098ef..8a31faa728ca1c1b5889a0e1772fc41b9de32e1e 100644 (file)
@@ -84,7 +84,6 @@
 
 #include <TCollection_AsciiString.hxx>
 
-
 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);
 }
-
index 853b2683e0b981508af983481c8abc864d54f06c..823a5afa9195524ec3342f020aa2e5b98d7bdc76 100644 (file)
@@ -131,11 +131,12 @@ public:
 public slots:\r
 \r
 protected slots:\r
+  virtual bool PushOnApply();\r
 \r
-virtual bool clickOnApply();\r
 private slots:\r
-virtual void clickOnHelp();\r
-virtual void clickOnOk();\r
+  virtual void PushOnHelp();\r
+  virtual void PushOnOK();\r
+\r
 protected :\r
 \r
   SMESHGUI_MgAdaptArguments* myArgs;\r
index 77ccb41d2010ab7ed225663ba020e98aa1bba044..fc1496380c1b6462edd792630a65e42ce29ac4e4 100644 (file)
@@ -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 : " <<ret<<std::endl;
+  if ( ret ) reject();
 }
-bool SMESHGUI_MG_ADAPTDRIVER::clickOnApply()
+bool SMESHGUI_MG_ADAPTDRIVER::PushOnApply()
 {
+  MESSAGE("PushOnApply");
 
   if ( SMESHGUI::isStudyLocked() )
     return false;
   if( !isValid() )
     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 (getModel()->getPublish()) this->createMeshInObjectBrowser();
+  if ( ok )
+  {
+    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;
 }
@@ -464,33 +481,21 @@ void SMESHGUI_MG_ADAPTDRIVER::keyPressEvent( QKeyEvent* e )
   if ( e->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 );
 
 }
 
index e73a7779586fb61a1b19aa896d3eae15b6771829..f68398525e382d9cc8938d9504093591abf70f19 100644 (file)
@@ -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 );
index 23c92f86b2d464e068810b3bd45057d9b543a777..fcac5cfe766687640b336103ca6921f80671cc10 100644 (file)
     </message>
     <message>
         <source>LOCAL_MG_ADAPT</source>
-        <translation>local</translation>
+        <translation>Local</translation>
     </message>
     <message>
         <source>BACKGRND_MG_ADAPT</source>
     </message>
     <message>
         <source>SIZE_MAP_DEF</source>
-        <translation>size map definition</translation>
+        <translation>Size map definition</translation>
     </message>
     <message>
         <source>ADVOP</source>
         <translation>Advanced Options</translation>
     </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>
         <source>MEN_CONV_TO_QUAD</source>
         <translation>Convert to/from quadratic</translation>
index 95306a7ec106fc69b10a61dd3d52d16aaf0e8313..9cdbdd649e7fb90ac6f9ac0874bc1527e322ec3b 100644 (file)
         <source>ADVOP</source>
         <translation>Options avancées</translation>
     </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>
         <source>MEN_CONV_TO_QUAD</source>
         <translation>Convertir vers/depuis quadratique</translation>