Salome HOME
Porting HOMARD SALOME module on WIN32 platform.
[modules/homard.git] / src / HOMARDGUI / MonCreateCase.cxx
index 40e97c74d15008a98714b3d5c24ebbc5f2b1b5b0..a38e9d8507b2306e5a0418aa3fe54501f61cc6d6 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2011-2012  CEA/DEN, EDF R&D
+// Copyright (C) 2011-2013  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
@@ -17,8 +17,6 @@
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
-using namespace std;
-
 #include "MonCreateCase.h"
 #include "MonCreateBoundaryAn.h"
 #include "MonEditBoundaryAn.h"
@@ -33,34 +31,42 @@ using namespace std;
 #include "HomardQtCommun.h"
 #include <utilities.h>
 
+#ifdef WIN32
+#include <direct.h>
+#endif
+
+using namespace std;
 
-// -----------------------------------------------------------------------------------------
-MonCreateCase::MonCreateCase(QWidget* parent, bool modal, HOMARD::HOMARD_Gen_var myHomardGen)
 // -----------------------------------------------------------------------------------------
 /* Constructs a MonCreateCase
  * Inherits from CasHomard
  * Sets attributes to default values
  */
+// -----------------------------------------------------------------------------------------
+MonCreateCase::MonCreateCase( bool modal, HOMARD::HOMARD_Gen_var myHomardGen0)
     :
     Ui_CreateCase(),
     _aCaseName(""),_aDirName(""),
     _ConfType(1),
     _Pyram(0)
 {
-      _myHomardGen=HOMARD::HOMARD_Gen::_duplicate(myHomardGen);
-      setupUi(this);
-      setModal(modal);
-      InitConnect();
+  MESSAGE("Debut du constructeur de MonCreateCase");
+  myHomardGen=HOMARD::HOMARD_Gen::_duplicate(myHomardGen0);
+  setupUi(this);
+  setModal(modal);
+  InitConnect();
 
-      SetNewCaseName() ;
-      GBBoundaryA->setVisible(0);
-      GBBoundaryD->setVisible(0);
-      GBTypeNoConf->setVisible(0);
-      adjustSize();
-      GBAdvancedOptions->setVisible(0);
-      CBPyramid->setChecked(false);
-}
+  SetNewName() ;
+  GBBoundaryA->setVisible(0);
+  GBBoundaryD->setVisible(0);
+  GBTypeNoConf->setVisible(0);
+  GBAdvancedOptions->setVisible(0);
+  Comment->setVisible(0);
+  CBPyramid->setChecked(false);
 
+  adjustSize();
+  MESSAGE("Fin du constructeur de MonCreateCase");
+}
 // ------------------------------------------------------------------------
 MonCreateCase::~MonCreateCase()
 // ------------------------------------------------------------------------
@@ -71,6 +77,7 @@ MonCreateCase::~MonCreateCase()
 void MonCreateCase::InitConnect()
 // ------------------------------------------------------------------------
 {
+    connect( LEName,     SIGNAL(textChanged(QString)), this, SLOT(CaseNameChanged()));
     connect( PushDir,        SIGNAL(pressed()), this, SLOT(SetDirName()));
     connect( PushFichier,    SIGNAL(pressed()), this, SLOT(SetFileName()));
 
@@ -95,7 +102,6 @@ void MonCreateCase::InitConnect()
     connect( buttonApply,    SIGNAL(pressed()), this, SLOT(PushOnApply()));
     connect( buttonCancel,   SIGNAL(pressed()), this, SLOT(close()));
     connect( buttonHelp,     SIGNAL(pressed()), this, SLOT(PushOnHelp()));
-    connect( LECaseName,     SIGNAL(textChanged(QString)), this, SLOT(CaseNameChanged()));
 }
 // ------------------------------------------------------------------------
 void MonCreateCase::InitBoundarys()
@@ -117,11 +123,11 @@ void MonCreateCase::InitBoundarys()
 // Pour les frontieres discretes : la liste a saisir
 // Pour les frontieres analytiques : les colonnes de chaque frontiere
   HOMARD::HOMARD_Boundary_var myBoundary ;
-  HOMARD::listeBoundarys_var  mesBoundarys = _myHomardGen->GetAllBoundarysName();
+  HOMARD::listeBoundarys_var  mesBoundarys = myHomardGen->GetAllBoundarysName();
 //   MESSAGE("Nombre de frontieres enregistrees : "<<mesBoundarys->length());
   for (int i=0; i<mesBoundarys->length(); i++)
   {
-    myBoundary = _myHomardGen->GetBoundary(mesBoundarys[i]);
+    myBoundary = myHomardGen->GetBoundary(mesBoundarys[i]);
     int type_obj = myBoundary->GetType() ;
     if ( type_obj==0 ) { CBBoundaryDi->addItem(QString(mesBoundarys[i])); }
     else               { AddBoundaryAn(QString(mesBoundarys[i])); }
@@ -136,7 +142,7 @@ bool MonCreateCase::PushOnApply()
 // --------------------------------
 {
   MESSAGE("PushOnApply");
-  QString aCaseName=LECaseName->text().trimmed();
+  QString aCaseName=LEName->text().trimmed();
   if ( aCaseName == "" )
   {
     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
@@ -151,13 +157,23 @@ bool MonCreateCase::PushOnApply()
                               QObject::tr("HOM_CASE_DIRECTORY_1") );
     return 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") );
-    return false;
+
+  if ( aDirName != _aDirName)
+  { QString CaseNameDir = myHomardGen->VerifieDir( aDirName.toStdString().c_str()) ;
+    if ( CaseNameDir != "" )
+    {
+      QString texte ;
+      texte = QObject::tr("HOM_CASE_DIRECTORY_2") + CaseNameDir ;
+      QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
+                                texte );
+      return false;
+    }
   }
+#ifndef WIN32
   if (chdir(aDirName.toStdString().c_str()) != 0)
+#else 
+  if (_chdir(aDirName.toStdString().c_str()) != 0)
+#endif
   {
     QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
                               QObject::tr("HOM_CASE_DIRECTORY_3") );
@@ -216,7 +232,7 @@ bool MonCreateCase::PushOnApply()
     _aCaseName = aCaseName;
     try
     {
-    aCase = _myHomardGen->CreateCase( \
+    aCase = myHomardGen->CreateCase( \
             CORBA::string_dup(_aCaseName.toStdString().c_str()),  \
             CORBA::string_dup(aMeshName.toStdString().c_str()),  \
             CORBA::string_dup(aFileName.toStdString().c_str()) );
@@ -227,9 +243,9 @@ bool MonCreateCase::PushOnApply()
                                 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
       try
       {
-          aCase = _myHomardGen->GetCase(_aCaseName.toStdString().c_str());
+          aCase = myHomardGen->GetCase(_aCaseName.toStdString().c_str());
           string iter0 = aCase->GetIter0Name();
-          HOMARD::HOMARD_Iteration_var aIter =  _myHomardGen->GetIteration(iter0.c_str());
+          HOMARD::HOMARD_Iteration_var aIter =  myHomardGen->GetIteration(iter0.c_str());
           QString aFileName = aIter->GetMeshFile();
           LEFileName->setText(aFileName);
           LEFileName->setReadOnly(true);
@@ -295,20 +311,21 @@ bool MonCreateCase::PushOnApply()
 void MonCreateCase::PushOnOK()
 // ---------------------------
 {
-     bool bOK = PushOnApply();
-     if ( bOK )  this->close();
+  bool bOK = PushOnApply();
+  if ( bOK ) this->close();
 }
 //------------------------------
 void MonCreateCase::PushOnHelp()
 //-------------------------------
 {
-  HOMARD_UTILS::PushOnHelp(QString("gui_create_case.html"));
+  char* LanguageShort = myHomardGen->GetLanguageShort();
+  HOMARD_UTILS::PushOnHelp(QString("gui_create_case.html"), QString(""), QString(LanguageShort));
 }
 // ---------------------------------
-void MonCreateCase::SetNewCaseName()
+void MonCreateCase::SetNewName()
 // ------------------------------
 {
-  HOMARD::listeCases_var  MyCases = _myHomardGen->GetAllCasesName();
+  HOMARD::listeCases_var  MyCases = myHomardGen->GetAllCasesName();
   int num = 0; QString aCaseName="";
   while (aCaseName=="" )
   {
@@ -324,8 +341,8 @@ void MonCreateCase::SetNewCaseName()
       }
    }
   }
-  LECaseName->clear() ;
-  LECaseName->insert(aCaseName);
+  LEName->clear() ;
+  LEName->insert(aCaseName);
 }
 
 // ------------------------------------------------------------------------
@@ -407,7 +424,7 @@ void MonCreateCase::PushBoundaryDiNew()
 // ------------------------------------------------------------------------
 {
    MonCreateBoundaryDi *BoundaryDlg = new MonCreateBoundaryDi(this, true,
-                HOMARD::HOMARD_Gen::_duplicate(_myHomardGen), _aCaseName, "") ;
+                HOMARD::HOMARD_Gen::_duplicate(myHomardGen), _aCaseName, "") ;
    BoundaryDlg->show();
 }
 // ------------------------------------------------------------------------
@@ -416,14 +433,15 @@ void MonCreateCase::PushBoundaryDiEdit()
 {
   if (CBBoundaryDi->currentText() == QString(""))  return;
   MonEditBoundaryDi *BoundaryDlg = new MonEditBoundaryDi(this, true,
-       HOMARD::HOMARD_Gen::_duplicate(_myHomardGen), _aCaseName, CBBoundaryDi->currentText() ) ;
+       HOMARD::HOMARD_Gen::_duplicate(myHomardGen), _aCaseName, CBBoundaryDi->currentText() ) ;
   BoundaryDlg->show();
 }
 // ------------------------------------------------------------------------
 void MonCreateCase::PushBoundaryDiHelp()
 // ------------------------------------------------------------------------
 {
-  HOMARD_UTILS::PushOnHelp(QString("gui_create_boundary.html#frontiere-discrete") ) ;
+  char* LanguageShort = myHomardGen->GetLanguageShort();
+  HOMARD_UTILS::PushOnHelp(QString("gui_create_boundary.html"), QString("frontiere-discrete"), QString(LanguageShort));
 }
 // ------------------------------------------------------------------------
 void MonCreateCase::SetBoundaryA()
@@ -476,7 +494,7 @@ void MonCreateCase::PushBoundaryAnNew()
 // ------------------------------------------------------------------------
 {
    MonCreateBoundaryAn *BoundaryDlg = new MonCreateBoundaryAn(this, true,
-                HOMARD::HOMARD_Gen::_duplicate(_myHomardGen), _aCaseName) ;
+                HOMARD::HOMARD_Gen::_duplicate(myHomardGen), _aCaseName) ;
    BoundaryDlg->show();
 }
 // ------------------------------------------------------------------------
@@ -493,7 +511,7 @@ void MonCreateCase::PushBoundaryAnEdit()
     MESSAGE("nom "<<nom.toStdString().c_str());
     if (nom != QString(""))
     { MonEditBoundaryAn *BoundaryDlg = new MonEditBoundaryAn(this, true,
-        HOMARD::HOMARD_Gen::_duplicate(_myHomardGen), _aCaseName, nom ) ;
+        HOMARD::HOMARD_Gen::_duplicate(myHomardGen), _aCaseName, nom ) ;
       BoundaryDlg->show(); }
   }
 }
@@ -501,13 +519,14 @@ void MonCreateCase::PushBoundaryAnEdit()
 void MonCreateCase::PushBoundaryAnHelp()
 // ------------------------------------------------------------------------
 {
-  HOMARD_UTILS::PushOnHelp(QString("gui_create_boundary.html#frontiere-analytique") ) ;
+  char* LanguageShort = myHomardGen->GetLanguageShort();
+  HOMARD_UTILS::PushOnHelp(QString("gui_create_boundary.html"), QString("frontiere-analytique"), QString(LanguageShort));
 }
 // ------------------------------------------------------------------------
 void MonCreateCase::CaseNameChanged()
 // ------------------------------------------------------------------------
 {
-    if (_aCaseName != LECaseName->text().trimmed())
+    if (_aCaseName != LEName->text().trimmed())
     {
        LEFileName->setReadOnly(false);
        PushFichier->show();