Salome HOME
Schémas YACS - suite
[modules/homard.git] / src / HOMARDGUI / MonCreateYACS.cxx
index 6612fba40e8ae121ae653c92e59920896522a7fd..74538e816588d7d207e9c80616e6eb6795dfd5fa 100644 (file)
@@ -30,26 +30,28 @@ using namespace std;
 #include <utilities.h>
 
 
-// -----------------------------------------------------------------------------------------
+// ----------------------------------------------------------------------
 /* Constructs a MonCreateYACS
  * Sets attributes to default values
  */
-// -----------------------------------------------------------------------------------------
-MonCreateYACS::MonCreateYACS (QWidget* parent, bool modal, HOMARD::HOMARD_Gen_var myHomardGen, QString CaseName )
+// ----------------------------------------------------------------------
+MonCreateYACS::MonCreateYACS (QWidget* parent, bool modal, HOMARD::HOMARD_Gen_var myHomardGen0, QString CaseName )
     :
     Ui_CreateYACS(),
     _aCaseName(CaseName),
-    _aFileNameScript(""),
+    _aScriptFile(""),
     _aDirName(""),
-    _aFileNameMesh("")
+    _aMeshFile("")
 {
   MESSAGE("Debut du constructeur de MonCreateYACS");
-  _myHomardGen=HOMARD::HOMARD_Gen::_duplicate(myHomardGen);
+  myHomardGen=HOMARD::HOMARD_Gen::_duplicate(myHomardGen0);
   setupUi(this);
   setModal(modal);
 
   InitConnect();
 
+  SetNewName() ;
+
   if (_aCaseName != QString(""))
     { SetCaseName(); }
   else
@@ -59,6 +61,24 @@ MonCreateYACS::MonCreateYACS (QWidget* parent, bool modal, HOMARD::HOMARD_Gen_va
   MESSAGE("Fin du constructeur de MonCreateYACS");
 }
 
+// ----------------------------------------------------------------------
+MonCreateYACS::MonCreateYACS(QWidget* parent,
+                             HOMARD::HOMARD_Gen_var myHomardGen0,
+                             QString caseName):
+// ----------------------------------------------------------------------
+// Constructeur appele par MonEditYACS
+//
+    myHomardGen(myHomardGen0),
+    _Name (""),
+    Chgt (false)
+    {
+  //  MESSAGE("Debut de  MonCreateYACS")
+      setupUi(this) ;
+
+      setModal(true) ;
+      InitConnect() ;
+    }
+
 // ------------------------------------------------------------------------
 MonCreateYACS::~MonCreateYACS()
 // ------------------------------------------------------------------------
@@ -71,11 +91,11 @@ void MonCreateYACS::InitConnect()
 {
     connect( PBCaseName,     SIGNAL(pressed()), this, SLOT(SetCaseName()));
     connect( PushDir,        SIGNAL(pressed()), this, SLOT(SetDirName()));
-    connect( PushFile,       SIGNAL(pressed()), this, SLOT(SetFileNameScript()));
-    connect( PushFile_2,     SIGNAL(pressed()), this, SLOT(SetFileNameMesh()));
+    connect( PushFile,       SIGNAL(pressed()), this, SLOT(SetScriptFile()));
+    connect( PushFile_2,     SIGNAL(pressed()), this, SLOT(SetMeshFile()));
 
-    connect( RBStatic,       SIGNAL(clicked()), this, SLOT(FromIteration()));
-    connect( RBTransient,    SIGNAL(clicked()), this, SLOT(FromCase()));
+    connect( RBStatic,       SIGNAL(clicked()), this, SLOT(SetType(1)));
+    connect( RBTransient,    SIGNAL(clicked()), this, SLOT(SetType(2)));
 
     connect( buttonOk,       SIGNAL(pressed()), this, SLOT(PushOnOK()));
     connect( buttonApply,    SIGNAL(pressed()), this, SLOT(PushOnApply()));
@@ -95,7 +115,7 @@ bool MonCreateYACS::PushOnApply()
     return false;
   }
 // Le fichier du script
-  QString aFileName=LEFileNameScript->text().trimmed();
+  QString aFileName=LEScriptFile->text().trimmed();
   if (aFileName ==QString(""))
   {
     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
@@ -111,7 +131,7 @@ bool MonCreateYACS::PushOnApply()
                               QObject::tr("HOM_CASE_DIRECTORY_4") );
     return false;
   }
-  if ((aDirName != _aDirName) and (_myHomardGen->VerifieDir( aDirName.toStdString().c_str()) == false))
+  if ((aDirName != _aDirName) and (myHomardGen->VerifieDir( aDirName.toStdString().c_str()) == false))
   {
     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
                               QObject::tr("HOM_CASE_DIRECTORY_2") );
@@ -125,7 +145,7 @@ bool MonCreateYACS::PushOnApply()
   }
 
 // Le fichier du tout premier maillage
-  aFileName=LEFileNameMesh->text().trimmed();
+  aFileName=LEMeshFile->text().trimmed();
   if (aFileName ==QString(""))
   {
     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
@@ -143,7 +163,21 @@ bool MonCreateYACS::PushOnApply()
   HOMARD_UTILS::updateObjBrowser();
   MESSAGE ("_aCaseName.toStdString " << _aCaseName.toStdString() );
 
-  return true;
+// Creation de l'objet CORBA
+  try
+  {
+    _Name=LEName->text().trimmed();
+    aYACS=myHomardGen->CreateYACSSchema(CORBA::string_dup(_Name.toStdString().c_str()), _aCaseName.toStdString().c_str(), _aScriptFile.toStdString().c_str(), _aDirName.toStdString().c_str(), _aMeshFile.toStdString().c_str());
+//     _parent->AddYACS(_Name);
+  }
+  catch( SALOME::SALOME_Exception& S_ex )
+  {
+    QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
+                              QObject::tr(CORBA::string_dup(S_ex.details.text)) );
+    return false;
+  }
+
+return true;
 }
 // ---------------------------
 void MonCreateYACS::PushOnOK()
@@ -158,6 +192,29 @@ void MonCreateYACS::PushOnHelp()
 {
   HOMARD_UTILS::PushOnHelp(QString("gui_create_case.html"), QString(""));
 }
+// -------------------------------------------------
+void MonCreateYACS::SetNewName()
+// --------------------------------------------------
+{
+
+  HOMARD::listeYACSs_var MyObjects = myHomardGen->GetAllYACSsName();
+  int num = 0; QString aName="";
+  while (aName == QString("") )
+  {
+    aName.setNum(num+1) ;
+    aName.insert(0, QString("YACS_")) ;
+    for ( int i=0; i<MyObjects->length(); i++)
+    {
+      if ( aName ==  QString(MyObjects[i]))
+      {
+          num=num+1;
+          aName="";
+          break;
+      }
+   }
+  }
+  LEName->setText(aName);
+}
 // ------------------------------------------------------------------------
 void MonCreateYACS::SetCaseName()
 // ------------------------------------------------------------------------
@@ -169,7 +226,7 @@ void MonCreateYACS::SetCaseName()
     if (_aCaseName == QString("")) { raise();return;};
   }
 /*  MESSAGE ("appel de GetCase avec _aCaseName = " << _aCaseName.toStdString() );*/
-  aCase = _myHomardGen->GetCase(_aCaseName.toStdString().c_str());
+  aCase = myHomardGen->GetCase(_aCaseName.toStdString().c_str());
   LECaseName->setText(_aCaseName);
 }
 // ------------------------------------------------------------------------
@@ -180,20 +237,26 @@ void MonCreateYACS::SetDirName()
   if (!(aDirName.isEmpty()))LEDirName->setText(aDirName);
 }
 // ------------------------------------------------------------------------
-void MonCreateYACS::SetFileNameScript()
+void MonCreateYACS::SetScriptFile()
 // ------------------------------------------------------------------------
 {
-  QString fileName0 = LEFileNameScript->text().trimmed();
+  QString fileName0 = LEScriptFile->text().trimmed();
   QString fileName = HOMARD_QT_COMMUN::PushNomFichier(false);
   if (fileName.isEmpty()) fileName = fileName0 ;
-  LEFileNameScript->setText(fileName);
+  LEScriptFile->setText(fileName);
 }
 // ------------------------------------------------------------------------
-void MonCreateYACS::SetFileNameMesh()
+void MonCreateYACS::SetMeshFile()
 // ------------------------------------------------------------------------
 {
-  QString fileName0 = LEFileNameMesh->text().trimmed();
+  QString fileName0 = LEMeshFile->text().trimmed();
   QString fileName = HOMARD_QT_COMMUN::PushNomFichier(false);
   if (fileName.isEmpty()) fileName = fileName0 ;
-  LEFileNameMesh->setText(fileName);
+  LEMeshFile->setText(fileName);
+}
+// ------------------------------------------------------------------------
+void MonCreateYACS::SetType(int Type)
+// ------------------------------------------------------------------------
+{
+  _Type=Type;
 }