Salome HOME
Updated copyright comment
[modules/homard.git] / src / HOMARDGUI / MonCreateYACS.cxx
index 032f04f684471ccd0becd4db372e73dd6b09d017..fc7e15923131827bb0d47e8380ec78044abc55e3 100644 (file)
@@ -1,9 +1,9 @@
-// Copyright (C) 2011-2012  CEA/DEN, EDF R&D
+// Copyright (C) 2011-2024  CEA, EDF
 //
 // 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.
+// 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
@@ -17,9 +17,8 @@
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
-using namespace std;
-
 #include "MonCreateYACS.h"
+#include "HOMARD.hxx"
 
 #include <QFileDialog>
 #include <QMessageBox>
@@ -29,6 +28,10 @@ using namespace std;
 #include "HomardQtCommun.h"
 #include <utilities.h>
 
+#ifdef WIN32
+#include <direct.h>
+#endif
+using namespace std;
 
 // ----------------------------------------------------------------------
 MonCreateYACS::MonCreateYACS (bool modal, HOMARD::HOMARD_Gen_var myHomardGen0, QString CaseName ):
@@ -43,25 +46,32 @@ MonCreateYACS::MonCreateYACS (bool modal, HOMARD::HOMARD_Gen_var myHomardGen0, Q
   _aDirName(""),
   _aMeshFile(""),
   _Type(1)
-  // La valeur de _Type doit etre la meme que celle dans HOMARD_Gen_i::CreateYACSSchema
-  // et doit correspondre aux defauts des boutons
+  // Les valeurs de _Type, _MaxIter, _MaxNode, _MaxElem doivent etre les memes que celles dans HOMARD_Gen_i::CreateYACSSchema
+  // et doivent correspondre aux defauts des boutons
   {
 //     MESSAGE("Debut du constructeur de MonCreateYACS");
     myHomardGen=HOMARD::HOMARD_Gen::_duplicate(myHomardGen0);
     setupUi(this);
-    setModal(modal);
+    if ( modal ) { setWindowModality(Qt::WindowModal); }
+    else         { setWindowModality(Qt::NonModal); }
 
     InitConnect();
 
     SetNewName() ;
 
-    if (_aCaseName != QString(""))
-      { SetCaseName(); }
-    else
-      {setModal(false); /* permet selection du cas dans l arbre d etude */}
-
+    if (_aCaseName != QString("")) { SetCaseName(); }
+    else                           { setWindowModality(Qt::NonModal); /* permet selection du cas dans l arbre d etude */}
+//
+//  Les valeurs definies dans les preferences
+    _MaxIter = myHomardGen->GetYACSMaxIter();
+    _MaxNode = myHomardGen->GetYACSMaxNode();
+    _MaxElem = myHomardGen->GetYACSMaxElem();
+    MESSAGE ("Valeur par defaut de MaxIter = " << _MaxIter<<", MaxNode = "<< _MaxNode<<", MaxElem = "<< _MaxElem);
+    SpinBoxMaxIter->setValue(_MaxIter) ;
+    SpinBoxMaxNode->setValue(_MaxNode) ;
+    SpinBoxMaxElem->setValue(_MaxElem) ;
+//
     adjustSize();
-//     MESSAGE("Fin du constructeur de MonCreateYACS");
   }
 
 // ----------------------------------------------------------------------
@@ -70,17 +80,18 @@ MonCreateYACS::MonCreateYACS(HOMARD::HOMARD_Gen_var myHomardGen0,
 // ----------------------------------------------------------------------
 // Constructeur appele par MonEditYACS
 //
-    myHomardGen(myHomardGen0),
-    _Name (""),
-    Chgt (false)
-    {
+myHomardGen(myHomardGen0),
+_Name (""),
+Chgt (false)
+{
 //       MESSAGE("Debut du constructeur de MonCreateYACS appele par MonEditYACS");
-      setupUi(this) ;
-
-      setModal(true) ;
-      InitConnect() ;
-    }
+  setupUi(this) ;
 
+  setWindowModality(Qt::WindowModal);
+  InitConnect() ;
+//
+  adjustSize();
+}
 // ------------------------------------------------------------------------
 MonCreateYACS::~MonCreateYACS()
 // ------------------------------------------------------------------------
@@ -138,7 +149,7 @@ bool MonCreateYACS::PushOnApply()
       return false;
     }
   }
-  if (chdir(aDirName.toStdString().c_str()) != 0)
+  if (CHDIR(aDirName.toStdString().c_str()) != 0)
   {
     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
                               QObject::tr("HOM_CASE_DIRECTORY_3") );
@@ -175,14 +186,15 @@ bool MonCreateYACS:: CreateOrUpdate()
   MESSAGE("CreateOrUpdate");
   bool bOK = true ;
 
-  // Le cas
+  // 1. Verification des donnees
+  // 1.1. Le cas
   if ( _aCaseName == QString (""))
   {
     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
                               QObject::tr("HOM_CASE_NAME") );
     return false;
   }
-  // Les donnees
+  // 1.2. Les donnees
   QString aScriptFile=LEScriptFile->text().trimmed();
   if ( aScriptFile != _aScriptFile )
   {
@@ -202,7 +214,7 @@ bool MonCreateYACS:: CreateOrUpdate()
     Chgt = true ;
   }
 
-  // Creation de l'objet CORBA
+  // 2. Creation de l'objet CORBA
   try
   {
     _Name=LEName->text().trimmed();
@@ -215,11 +227,25 @@ bool MonCreateYACS:: CreateOrUpdate()
     bOK = false;
   }
 
-  // Options
+  // 3. Options
   if ( bOK )
-  { aYACS->SetType(_Type) ; }
+  {
+  // 3.1. Le type du schema
+    aYACS->SetType(_Type) ;
+
+  // 3.2. Les maximums
+    _MaxIter = SpinBoxMaxIter->value() ;
+    aYACS->SetMaxIter(_MaxIter) ;
+
+    _MaxNode = SpinBoxMaxNode->value() ;
+    aYACS->SetMaxNode(_MaxNode) ;
+
+    _MaxElem = SpinBoxMaxElem->value() ;
+    aYACS->SetMaxElem(_MaxElem) ;
+
+  }
 
-  // Ecriture du fichier
+  // 4. Ecriture du fichier
   if ( bOK )
   {
     int codret = aYACS->Write() ;
@@ -239,8 +265,8 @@ void MonCreateYACS::PushOnOK()
 void MonCreateYACS::PushOnHelp()
 //-------------------------------
 {
-  char* LanguageShort = myHomardGen->GetLanguageShort();
-  HOMARD_UTILS::PushOnHelp(QString("yacs.html"), QString(""), QString(LanguageShort));
+  std::string LanguageShort = myHomardGen->GetLanguageShort();
+  HOMARD_UTILS::PushOnHelp(QString("yacs.html"), QString(""), QString(LanguageShort.c_str()));
 }
 // -------------------------------------------------
 void MonCreateYACS::SetNewName()
@@ -257,9 +283,9 @@ void MonCreateYACS::SetNewName()
     {
       if ( aName ==  QString(MyObjects[i]))
       {
-          num=num+1;
-          aName="";
-          break;
+        num ++ ;
+        aName = "" ;
+        break ;
       }
    }
   }
@@ -289,7 +315,7 @@ void MonCreateYACS::SetScriptFile()
 // ------------------------------------------------------------------------
 {
   QString fileName0 = LEScriptFile->text().trimmed();
-  QString fileName = HOMARD_QT_COMMUN::PushNomFichier(false);
+  QString fileName = HOMARD_QT_COMMUN::PushNomFichier( false, QString("py") ) ;
   if (fileName.isEmpty()) fileName = fileName0 ;
   LEScriptFile->setText(fileName);
 }
@@ -298,7 +324,7 @@ void MonCreateYACS::SetMeshFile()
 // ------------------------------------------------------------------------
 {
   QString fileName0 = LEMeshFile->text().trimmed();
-  QString fileName = HOMARD_QT_COMMUN::PushNomFichier(false);
+  QString fileName = HOMARD_QT_COMMUN::PushNomFichier( false, QString("med") ) ;
   if (fileName.isEmpty()) fileName = fileName0 ;
   LEMeshFile->setText(fileName);
 }