Salome HOME
[bos #32517][EDF] Dynamic log messages switched on and off by SALOME_VERBOSE environm...
[modules/homard.git] / src / HOMARDGUI / MonCreateBoundaryAn.cxx
index ab9604d90adfe6ad8dd18c20c73cbbf1d5d2573c..0e0fe382a2d170a80d882c47b0ba8b997c4e70b7 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2011-2014  CEA/DEN, EDF R&D
+// Copyright (C) 2011-2022  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
@@ -38,6 +38,7 @@
 #define PI 3.141592653589793
 
 using namespace std;
+
 // ------------------------------------------------------------------------------------------------------------------------
 MonCreateBoundaryAn::MonCreateBoundaryAn(MonCreateCase* parent, bool modal,
                              HOMARD::HOMARD_Gen_var myHomardGen0,
@@ -49,7 +50,7 @@ MonCreateBoundaryAn::MonCreateBoundaryAn(MonCreateCase* parent, bool modal,
 */
     QDialog(0), Ui_CreateBoundaryAn(),
     _parent(parent),
-    _aName (""),
+    _Name (""),
     _aCaseName(caseName),
     _Xmin(0), _Xmax(0), _Xincr(0), _Ymin(0), _Ymax(0), _Yincr(0), _Zmin(0), _Zmax(0), _Zincr(0), _DMax(0),
     _Type(1),
@@ -105,12 +106,11 @@ MonCreateBoundaryAn::MonCreateBoundaryAn(MonCreateCase* parent,
                              HOMARD::HOMARD_Gen_var myHomardGen0,
                              QString caseName):
 // --------------------------------------------------------------------------------------------------------------
-// Constructeur appele par MonEditBoundaryAn
 //
     QDialog(0), Ui_CreateBoundaryAn(),
      myHomardGen(myHomardGen0),
     _parent(parent),
-    _aName (""),
+    _Name (""),
     _aCaseName(caseName),
     _Type(1),
     _BoundaryAnXcentre(0), _BoundaryAnYcentre(0), _BoundaryAnZcentre(0), _BoundaryAnRayon(0),
@@ -418,6 +418,22 @@ bool MonCreateBoundaryAn::PushOnApply()
 
  }
 
+// Controles
+// L'axe pour un cylindre
+  if ( _Type == 5 )
+  {
+    double daux = _BoundaryAnXaxis*_BoundaryAnXaxis + _BoundaryAnYaxis*_BoundaryAnYaxis + _BoundaryAnZaxis*_BoundaryAnZaxis ;
+    if ( daux < 0.0000001 )
+    {
+      QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
+                                QObject::tr("HOM_AXE") );
+      return false;
+    }
+  }
+
+//
+// Création ou mise à jour de la frontière
+//
   bool bOK = CreateOrUpdateBoundaryAn();
 
   if ( bOK ) { HOMARD_UTILS::updateObjBrowser() ; }
@@ -426,94 +442,64 @@ bool MonCreateBoundaryAn::PushOnApply()
 
 }
 // ---------------------------------------------------
-bool MonCreateBoundaryAn:: CreateOrUpdateBoundaryAn()
+bool MonCreateBoundaryAn::CreateOrUpdateBoundaryAn()
 //----------------------------------------------------
 //  Creation de l'objet boundary
 {
-  _aName = LEName->text().trimmed();
-  switch (_Type)
+  MESSAGE("Debut de CreateOrUpdateBoundaryAn avec _Type ="<<_Type<<", _Name ="<<_Name.toStdString().c_str()<<" et LEName ="<<LEName->text().trimmed().toStdString().c_str());
+//
+  if (_Name != LEName->text().trimmed())
   {
-    case 1 : // il s agit d un cylindre
-    {
-      try
-      {
-        aBoundaryAn = myHomardGen->CreateBoundaryCylinder(CORBA::string_dup(_aName.toStdString().c_str()), \
-        _BoundaryAnXcentre, _BoundaryAnYcentre, _BoundaryAnZcentre, _BoundaryAnXaxis, _BoundaryAnYaxis, _BoundaryAnZaxis, _BoundaryAnRayon );
-      }
-      catch( SALOME::SALOME_Exception& S_ex )
-      {
-        QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
-                                  QObject::tr(CORBA::string_dup(S_ex.details.text)) );
-        return false ;
-      }
-      break;
-    }
-    case 2 : // il s agit d une sphere
-    {
-      try
-      {
-        aBoundaryAn = myHomardGen->CreateBoundarySphere(CORBA::string_dup(_aName.toStdString().c_str()), \
-        _BoundaryAnXcentre, _BoundaryAnYcentre, _BoundaryAnZcentre, _BoundaryAnRayon);
-      }
-      catch( SALOME::SALOME_Exception& S_ex )
-      {
-        QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
-                                  QObject::tr(CORBA::string_dup(S_ex.details.text)) );
-        return false ;
-      }
-      break;
-    }
-    case 3 : // il s agit d un cone defini par un axe et un angle
-    {
-      try
-      {
-        aBoundaryAn = myHomardGen->CreateBoundaryConeA(CORBA::string_dup(_aName.toStdString().c_str()), \
-        _BoundaryAnXaxisCone, _BoundaryAnYaxisCone, _BoundaryAnZaxisCone, _BoundaryAngle, \
-        _BoundaryAnXorigCone, _BoundaryAnYorigCone, _BoundaryAnYorigCone);
-      }
-      catch( SALOME::SALOME_Exception& S_ex )
-      {
-        QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
-                                  QObject::tr(CORBA::string_dup(S_ex.details.text)) );
-        return false ;
-      }
-      break;
-    }
-    case 4 : // il s agit d un cone defini par les 2 rayons
+    _Name = LEName->text().trimmed() ;
+    try
     {
-      try
-      {
-        aBoundaryAn = myHomardGen->CreateBoundaryConeR(CORBA::string_dup(_aName.toStdString().c_str()), \
-        _BoundaryAnXcone1, _BoundaryAnYcone1, _BoundaryAnZcone1, _BoundaryAnRayon1, \
-        _BoundaryAnXcone2, _BoundaryAnYcone2, _BoundaryAnZcone2, _BoundaryAnRayon2);
-      }
-      catch( SALOME::SALOME_Exception& S_ex )
+      switch (_Type)
       {
-        QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
-                                  QObject::tr(CORBA::string_dup(S_ex.details.text)) );
-        return false ;
+        case 1 : // il s agit d un cylindre
+        { aBoundaryAn = myHomardGen->CreateBoundaryCylinder(CORBA::string_dup(_Name.toStdString().c_str()), \
+            _BoundaryAnXcentre, _BoundaryAnYcentre, _BoundaryAnZcentre, _BoundaryAnXaxis, _BoundaryAnYaxis, _BoundaryAnZaxis, _BoundaryAnRayon );
+          break;
+        }
+        case 2 : // il s agit d une sphere
+        { aBoundaryAn = myHomardGen->CreateBoundarySphere(CORBA::string_dup(_Name.toStdString().c_str()), \
+            _BoundaryAnXcentre, _BoundaryAnYcentre, _BoundaryAnZcentre, _BoundaryAnRayon);
+          break;
+       }
+        case 3 : // il s agit d un cone defini par un axe et un angle
+        { aBoundaryAn = myHomardGen->CreateBoundaryConeA(CORBA::string_dup(_Name.toStdString().c_str()), \
+            _BoundaryAnXaxisCone, _BoundaryAnYaxisCone, _BoundaryAnZaxisCone, _BoundaryAngle, \
+            _BoundaryAnXorigCone, _BoundaryAnYorigCone, _BoundaryAnYorigCone);
+          break;
+        }
+        case 4 : // il s agit d un cone defini par les 2 rayons
+        { aBoundaryAn = myHomardGen->CreateBoundaryConeR(CORBA::string_dup(_Name.toStdString().c_str()), \
+            _BoundaryAnXcone1, _BoundaryAnYcone1, _BoundaryAnZcone1, _BoundaryAnRayon1, \
+            _BoundaryAnXcone2, _BoundaryAnYcone2, _BoundaryAnZcone2, _BoundaryAnRayon2);
+          break;
+        }
+        case 5 : // il s agit d un tore
+        { aBoundaryAn = myHomardGen->CreateBoundaryTorus(CORBA::string_dup(_Name.toStdString().c_str()), \
+            _BoundaryAnToreXcentre, _BoundaryAnToreYcentre, _BoundaryAnToreZcentre, _BoundaryAnToreXaxe, _BoundaryAnToreYaxe, _BoundaryAnToreZaxe, _BoundaryAnToreRRev, _BoundaryAnToreRPri );
+          break;
+        }
       }
-      break;
     }
-   case 5 : // il s agit d un tore
+    catch( SALOME::SALOME_Exception& S_ex )
     {
-      try
-      {
-        aBoundaryAn = myHomardGen->CreateBoundaryTorus(CORBA::string_dup(_aName.toStdString().c_str()), \
-        _BoundaryAnToreXcentre, _BoundaryAnToreYcentre, _BoundaryAnToreZcentre, _BoundaryAnToreXaxe, _BoundaryAnToreYaxe, _BoundaryAnToreZaxe, _BoundaryAnToreRRev, _BoundaryAnToreRPri );
-      }
-      catch( SALOME::SALOME_Exception& S_ex )
-      {
-        QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
-                                  QObject::tr(CORBA::string_dup(S_ex.details.text)) );
-        return false ;
-     }
-      break;
+      QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
+                                QObject::tr(CORBA::string_dup(S_ex.details.text)) );
+      return false ;
     }
-  }
-  _parent->AddBoundaryAn(_aName);
+    _parent->AddBoundaryAn(_Name);
 
-  return true;
+    return true;
+  }
+  else {
+    QMessageBox::warning( 0, QObject::tr("HOM_WARNING"),
+                             QObject::tr("HOM_SELECT_OBJECT_4") );
+    return false ;
+  }
+  MESSAGE("Fin de CreateOrUpdateBoundaryAn");
 }
 // ------------------------------------------------------------------------
 void MonCreateBoundaryAn::PushOnOK()
@@ -557,7 +543,7 @@ void MonCreateBoundaryAn::SetNewName()
 void MonCreateBoundaryAn::SetCylinder()
 // ------------------------------------------------------------------------
 {
-  MESSAGE("Debut de SetCylinder")
+  MESSAGE("Debut de SetCylinder");
   gBCylindre->setVisible(1);
   gBSphere->setVisible(0);
   gBCone->setVisible(0);
@@ -572,7 +558,7 @@ void MonCreateBoundaryAn::SetCylinder()
 void MonCreateBoundaryAn::SetSphere()
 // ------------------------------------------------------------------------
 {
-  MESSAGE("Debut de SetSphere")
+  MESSAGE("Debut de SetSphere");
   gBCylindre->setVisible(0);
   gBSphere->setVisible(1);
   gBCone->setVisible(0);
@@ -587,7 +573,7 @@ void MonCreateBoundaryAn::SetSphere()
 void MonCreateBoundaryAn::SetConeR()
 // ------------------------------------------------------------------------
 {
-  MESSAGE("Debut de SetConeR")
+  MESSAGE("Debut de SetConeR");
 //
 // Stockage et conversion des valeurs si elles ont change
   if ((_BoundaryAnXaxisCone != SpinBox_Cone_X1->value())  ||
@@ -598,7 +584,7 @@ void MonCreateBoundaryAn::SetConeR()
       (_BoundaryAnZorigCone != SpinBox_Cone_Z2->value())  ||
       (_BoundaryAngle       != SpinBox_Cone_V1->value()) )
   {
-    MESSAGE("Stockage et conversion")
+    MESSAGE("Stockage et conversion");
     _BoundaryAnXaxisCone = SpinBox_Cone_X1->value() ;
     _BoundaryAnYaxisCone = SpinBox_Cone_Y1->value() ;
     _BoundaryAnZaxisCone = SpinBox_Cone_Z1->value() ;
@@ -611,28 +597,28 @@ void MonCreateBoundaryAn::SetConeR()
 //
   _Type=4;
 //
-  TLCone_X1->setText(QApplication::translate("CreateBoundaryAn", "X centre 1", 0, QApplication::UnicodeUTF8));
+  TLCone_X1->setText(QApplication::translate("CreateBoundaryAn", "X centre 1", 0));
   SpinBox_Cone_X1->setValue(_BoundaryAnXcone1);
-  TLCone_Y1->setText(QApplication::translate("CreateBoundaryAn", "Y centre 1", 0, QApplication::UnicodeUTF8));
+  TLCone_Y1->setText(QApplication::translate("CreateBoundaryAn", "Y centre 1", 0));
   SpinBox_Cone_Y1->setValue(_BoundaryAnYcone1);
-  TLCone_Z1->setText(QApplication::translate("CreateBoundaryAn", "Z centre 1", 0, QApplication::UnicodeUTF8));
+  TLCone_Z1->setText(QApplication::translate("CreateBoundaryAn", "Z centre 1", 0));
   SpinBox_Cone_Z1->setValue(_BoundaryAnZcone1);
 //
-  TLCone_V1->setText(QApplication::translate("CreateBoundaryAn", "Radius 1", 0, QApplication::UnicodeUTF8));
+  TLCone_V1->setText(QApplication::translate("CreateBoundaryAn", "Radius 1", 0));
   SpinBox_Cone_V1->setSingleStep(_Rayon/10.);
   SpinBox_Cone_V1->setMaximum(100000.*_DMax);
   SpinBox_Cone_V1->setValue(_BoundaryAnRayon1);
 //
-  TLCone_X2->setText(QApplication::translate("CreateBoundaryAn", "X centre 2", 0, QApplication::UnicodeUTF8));
+  TLCone_X2->setText(QApplication::translate("CreateBoundaryAn", "X centre 2", 0));
   SpinBox_Cone_X2->setValue(_BoundaryAnXcone2);
-  TLCone_Y2->setText(QApplication::translate("CreateBoundaryAn", "Y centre 2", 0, QApplication::UnicodeUTF8));
+  TLCone_Y2->setText(QApplication::translate("CreateBoundaryAn", "Y centre 2", 0));
   SpinBox_Cone_Y2->setValue(_BoundaryAnYcone2);
-  TLCone_Z2->setText(QApplication::translate("CreateBoundaryAn", "Z centre 2", 0, QApplication::UnicodeUTF8));
+  TLCone_Z2->setText(QApplication::translate("CreateBoundaryAn", "Z centre 2", 0));
   SpinBox_Cone_Z2->setValue(_BoundaryAnZcone2);
 //
   TLCone_V2->setVisible(1);
   SpinBox_Cone_V2->setVisible(1);
-  TLCone_V2->setText(QApplication::translate("CreateBoundaryAn", "Radius 2", 0, QApplication::UnicodeUTF8));
+  TLCone_V2->setText(QApplication::translate("CreateBoundaryAn", "Radius 2", 0));
   SpinBox_Cone_V2->setValue(_BoundaryAnRayon2);
 //
 //   MESSAGE("Fin de SetConeR")
@@ -641,7 +627,7 @@ void MonCreateBoundaryAn::SetConeR()
 void MonCreateBoundaryAn::SetConeA()
 // ------------------------------------------------------------------------
 {
-  MESSAGE("Debut de SetConeA")
+  MESSAGE("Debut de SetConeA");
 // Stockage et conversion des valeurs si elles ont change
   if ((_BoundaryAnXcone1 != SpinBox_Cone_X1->value())  ||
       (_BoundaryAnYcone1 != SpinBox_Cone_Y1->value())  ||
@@ -652,7 +638,7 @@ void MonCreateBoundaryAn::SetConeA()
       (_BoundaryAnZcone2 != SpinBox_Cone_Z2->value())  ||
       (_BoundaryAnRayon2 != SpinBox_Cone_V2->value()) )
   {
-    MESSAGE("Stockage et conversion")
+    MESSAGE("Stockage et conversion");
     _BoundaryAnXcone1 = SpinBox_Cone_X1->value() ;
     _BoundaryAnYcone1 = SpinBox_Cone_Y1->value() ;
     _BoundaryAnZcone1 = SpinBox_Cone_Z1->value() ;
@@ -666,21 +652,21 @@ void MonCreateBoundaryAn::SetConeA()
 //
   _Type=3;
 //
-  TLCone_X1->setText(QApplication::translate("CreateBoundaryAn", "X axis", 0, QApplication::UnicodeUTF8));
+  TLCone_X1->setText(QApplication::translate("CreateBoundaryAn", "X axis", 0));
   SpinBox_Cone_X1->setValue(_BoundaryAnXaxisCone);
-  TLCone_Y1->setText(QApplication::translate("CreateBoundaryAn", "Y axis", 0, QApplication::UnicodeUTF8));
+  TLCone_Y1->setText(QApplication::translate("CreateBoundaryAn", "Y axis", 0));
   SpinBox_Cone_Y1->setValue(_BoundaryAnYaxisCone);
-  TLCone_Z1->setText(QApplication::translate("CreateBoundaryAn", "Z axis", 0, QApplication::UnicodeUTF8));
+  TLCone_Z1->setText(QApplication::translate("CreateBoundaryAn", "Z axis", 0));
   SpinBox_Cone_Z1->setValue(_BoundaryAnZaxisCone);
 //
-  TLCone_X2->setText(QApplication::translate("CreateBoundaryAn", "X centre", 0, QApplication::UnicodeUTF8));
+  TLCone_X2->setText(QApplication::translate("CreateBoundaryAn", "X centre", 0));
   SpinBox_Cone_X2->setValue(_BoundaryAnXorigCone);
-  TLCone_Y2->setText(QApplication::translate("CreateBoundaryAn", "Y centre", 0, QApplication::UnicodeUTF8));
+  TLCone_Y2->setText(QApplication::translate("CreateBoundaryAn", "Y centre", 0));
   SpinBox_Cone_Y2->setValue(_BoundaryAnYorigCone);
-  TLCone_Z2->setText(QApplication::translate("CreateBoundaryAn", "Z centre", 0, QApplication::UnicodeUTF8));
+  TLCone_Z2->setText(QApplication::translate("CreateBoundaryAn", "Z centre", 0));
   SpinBox_Cone_Z2->setValue(_BoundaryAnZorigCone);
 //
-  TLCone_V1->setText(QApplication::translate("CreateBoundaryAn", "Angle", 0, QApplication::UnicodeUTF8));
+  TLCone_V1->setText(QApplication::translate("CreateBoundaryAn", "Angle", 0));
   SpinBox_Cone_V1->setValue(_BoundaryAngle);
   SpinBox_Cone_V1->setSingleStep(1.);
   SpinBox_Cone_V1->setMaximum(90.);
@@ -695,7 +681,7 @@ void MonCreateBoundaryAn::SetConeA()
 void MonCreateBoundaryAn::SetCone()
 // ------------------------------------------------------------------------
 {
-  MESSAGE("Debut de SetCone")
+  MESSAGE("Debut de SetCone");
   gBCylindre->setVisible(0);
   gBSphere->setVisible(0);
   gBCone->setVisible(1);
@@ -717,7 +703,7 @@ void MonCreateBoundaryAn::SetCone()
 void MonCreateBoundaryAn::SetTore()
 // ------------------------------------------------------------------------
 {
-  MESSAGE("Debut de SetTore")
+  MESSAGE("Debut de SetTore");
   gBCylindre->setVisible(0);
   gBSphere->setVisible(0);
   gBCone->setVisible(0);
@@ -735,7 +721,7 @@ void MonCreateBoundaryAn::convertRayonAngle(int option)
 // par deux rayons ou avec un axe et un angle.
 // Voir sfcoi1 de HOMARD
 {
-  MESSAGE("Debut de convertRayonAngle, option = "<<option)
+  MESSAGE("Debut de convertRayonAngle, option = "<<option);
 //
 //         o
 //         !    .