Salome HOME
updated copyright message
[modules/homard.git] / src / HOMARDGUI / MonCreateBoundaryDi.cxx
index db1edcd2dbfc344c66b2bf2b9aedc3a7f220fabe..4b78f602983878bfea98e612aa687b2b535670b3 100644 (file)
@@ -1,4 +1,21 @@
-using namespace std;
+// Copyright (C) 2011-2023  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 
 #include "MonCreateBoundaryDi.h"
 #include "MonCreateListGroup.h"
@@ -12,16 +29,18 @@ using namespace std;
 #include "HomardQtCommun.h"
 #include <utilities.h>
 
+using namespace std;
+
 // -------------------------------------------------------------------------------
 MonCreateBoundaryDi::MonCreateBoundaryDi(MonCreateCase* parent, bool modal,
-                                         HOMARD::HOMARD_Gen_var myHomardGen,
-                                         QString caseName, QString aBoundaryName)
+                                         HOMARD::HOMARD_Gen_var myHomardGen0,
+                                         QString caseName, QString aName)
 // ---------------------------------------------------------------------------------
 /* Constructs a MonCreateBoundaryDi */
     :
     QDialog(0), Ui_CreateBoundaryDi(),
-    _parent(parent), _aBoundaryName(aBoundaryName),
-    _myHomardGen(HOMARD::HOMARD_Gen::_duplicate(myHomardGen)),
+    _parent(parent), _aName(aName),
+    myHomardGen(HOMARD::HOMARD_Gen::_duplicate(myHomardGen0)),
     _aCaseName(caseName)
     {
       MESSAGE("Constructeur") ;
@@ -29,7 +48,7 @@ MonCreateBoundaryDi::MonCreateBoundaryDi(MonCreateCase* parent, bool modal,
       setModal(modal);
       InitConnect();
 
-     if ( _aBoundaryName == QString("") ) {SetNewBoundaryName();};
+     if ( _aName == QString("") ) {SetNewName();};
     }
 
 // ------------------------------------------------------------------------
@@ -58,11 +77,10 @@ bool MonCreateBoundaryDi::PushOnApply()
 {
 // Verifications
 
-  QString aBoundaryName=LEBoundaryName->text().trimmed();
-  if (aBoundaryName=="") {
-    QMessageBox::information( 0, "Error",
-                              "The boundary must be named.",
-                              QMessageBox::Ok + QMessageBox::Default );
+  QString aName=LEName->text().trimmed();
+  if (aName=="") {
+    QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
+                              QObject::tr("HOM_BOUN_NAME") );
     return false;
   }
 
@@ -70,9 +88,8 @@ bool MonCreateBoundaryDi::PushOnApply()
   QString aMeshFile=LEFileName->text().trimmed();
   if (aMeshFile ==QString(""))
   {
-    QMessageBox::information( 0, "Error",
-              QString("The mesh of the boundary must be selected."),
-              QMessageBox::Ok + QMessageBox::Default );
+    QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
+                              QObject::tr("HOM_BOUN_MESH") );
     return false;
   }
 
@@ -80,34 +97,30 @@ bool MonCreateBoundaryDi::PushOnApply()
   QString aMeshName = HOMARD_QT_COMMUN::LireNomMaillage(aMeshFile);
   if (aMeshName == "" )
   {
-    QMessageBox::information( 0, "Error",
-              QString("no mesh in mesh file"),
-              QMessageBox::Ok + QMessageBox::Default );
+    QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
+                              QObject::tr("HOM_MED_FILE_2") );
     return false;
   }
 
 // Creation de l'objet CORBA si ce n'est pas deja fait sous le meme nom
-  if ( _aBoundaryName != aBoundaryName )
+  if ( _aName != aName )
   {
-   try 
+   try
    {
-     _aBoundaryName=aBoundaryName;
-     _aBoundary=_myHomardGen->CreateBoundary(CORBA::string_dup(_aBoundaryName.toStdString().c_str()),0);
-     _parent->addBoundaryDi(_aBoundaryName);
-     _aBoundary->SetCaseCreation(_aCaseName.toStdString().c_str());
+     _aName=aName;
+     aBoundary=myHomardGen->CreateBoundaryDi(CORBA::string_dup(_aName.toStdString().c_str()), aMeshName.toStdString().c_str(), aMeshFile.toStdString().c_str());
+     _parent->AddBoundaryDi(_aName);
+     aBoundary->SetCaseCreation(_aCaseName.toStdString().c_str());
    }
    catch( SALOME::SALOME_Exception& S_ex )
    {
-      QMessageBox::information( 0, "Error",
-                  QString(CORBA::string_dup(S_ex.details.text)),
-                  QMessageBox::Ok + QMessageBox::Default );
+      QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
+                                QObject::tr(CORBA::string_dup(S_ex.details.text)) );
       return false;
    }
   }
 
-// Mise en place des attributs
-  _aBoundary->SetMeshFile(aMeshFile.toStdString().c_str());
-  _aBoundary->SetMeshName(aMeshName.toStdString().c_str());
+// Les groupes
   AssocieLesGroupes();
 
   HOMARD_UTILS::updateObjBrowser();
@@ -126,7 +139,8 @@ void MonCreateBoundaryDi::PushOnOK()
 void MonCreateBoundaryDi::PushOnHelp()
 // ------------------------------------------------------------------------
 {
-  HOMARD_UTILS::PushOnHelp(QString("gui_create_hypothese.html"));
+  std::string LanguageShort = myHomardGen->GetLanguageShort();
+  HOMARD_UTILS::PushOnHelp(QString("gui_create_boundary.html"), QString("frontiere-discrete"), QString(LanguageShort.c_str()));
 }
 // ------------------------------------------------------------------------
 void MonCreateBoundaryDi::AssocieLesGroupes()
@@ -138,38 +152,38 @@ void MonCreateBoundaryDi::AssocieLesGroupes()
   int i=0;
   for (it = _listeGroupesBoundary.constBegin(); it != _listeGroupesBoundary.constEnd(); it++)
      aSeqGroupe[i++]=(*it).toStdString().c_str();
-  _aBoundary->SetGroups(aSeqGroupe);
+  aBoundary->SetGroups(aSeqGroupe);
 
 }
 
 // -------------------------------------------------
-void MonCreateBoundaryDi::SetNewBoundaryName()
+void MonCreateBoundaryDi::SetNewName()
 // --------------------------------------------------
 {
 
-  HOMARD::listeBoundarys_var  MyBoundarys = _myHomardGen->GetAllBoundarys();
-  int num = 0; QString aBoundaryName="";
-  while (aBoundaryName == QString("") )
+  HOMARD::listeBoundarys_var  MyObjects = myHomardGen->GetAllBoundarysName();
+  int num = 0; QString aName="";
+  while (aName == QString("") )
   {
-    aBoundaryName.setNum(num+1) ;
-    aBoundaryName.insert(0, QString("Boun_")) ;
-    for ( int i=0; i<MyBoundarys->length(); i++)
+    aName.setNum(num+1) ;
+    aName.insert(0, QString("Boun_")) ;
+    for ( int i=0; i<MyObjects->length(); i++)
     {
-      if ( aBoundaryName ==  QString(MyBoundarys[i]))
+      if ( aName ==  QString(MyObjects[i]))
       {
-          num=num+1;
-          aBoundaryName="";
-          break;
+        num ++ ;
+        aName = "" ;
+        break ;
       }
    }
   }
-  LEBoundaryName->setText(aBoundaryName);
+  LEName->setText(aName);
 }
 // ------------------------------------------------------------------------
 void MonCreateBoundaryDi::SetMeshFile()
 // ------------------------------------------------------------------------
 {
-  QString aMeshFile = HOMARD_QT_COMMUN::PushNomFichier();
+  QString aMeshFile = HOMARD_QT_COMMUN::PushNomFichier( false, QString("med") );
   if (!(aMeshFile.isEmpty())) LEFileName->setText(aMeshFile);
 }
 
@@ -183,16 +197,15 @@ void MonCreateBoundaryDi::setGroups (QStringList listGroup)
 void MonCreateBoundaryDi::SetFiltrage()
 // // ------------------------------------------------------------------------
 {
-   if (!CBGroupe->isChecked()) return;
-   if (_aCaseName.toStdString().c_str() == QString()) {
-        QMessageBox::information( 0, "Error",
-                              "Case MeshFile unknowned.",
-                              QMessageBox::Ok + QMessageBox::Default );
-        return;
-   }
+  if (!CBGroupe->isChecked()) return;
+  if (_aCaseName.toStdString().c_str() == QString()) {
+    QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
+                              QObject::tr("HOM_BOUN_CASE") );
+    return;
+  }
 
-   MonCreateListGroup *aDlg = new MonCreateListGroup(NULL,this,  TRUE, HOMARD::HOMARD_Gen::_duplicate(_myHomardGen),
-                              _aCaseName, _listeGroupesBoundary) ;
+  MonCreateListGroup *aDlg = new MonCreateListGroup(NULL, this, true, HOMARD::HOMARD_Gen::_duplicate(myHomardGen),
+                            _aCaseName, _listeGroupesBoundary) ;
   aDlg->show();
 }