1 // Copyright (C) 2011-2020 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "MonCreateBoundaryCAO.h"
21 #include "MonCreateListGroupCAO.h"
22 #include "MonCreateCase.h"
24 #include <QFileDialog>
25 #include <QMessageBox>
27 #include "SalomeApp_Tools.h"
28 #include "HOMARDGUI_Utils.h"
29 #include "HomardQtCommun.h"
30 #include <utilities.h>
34 // -------------------------------------------------------------------------------
35 MonCreateBoundaryCAO::MonCreateBoundaryCAO(MonCreateCase* parent, bool modal,
36 ADAPT::ADAPT_Gen_var myHomardGen0,
37 QString caseName, QString aName)
38 // ---------------------------------------------------------------------------------
39 /* Constructs a MonCreateBoundaryCAO */
41 QDialog(0), Ui_CreateBoundaryCAO(),
42 _parent(parent), _aName(aName),
43 myHomardGen(ADAPT::ADAPT_Gen::_duplicate(myHomardGen0)),
46 MESSAGE("Constructeur") ;
51 if ( _aName == QString("") ) {SetNewName();};
54 // ------------------------------------------------------------------------
55 MonCreateBoundaryCAO::~MonCreateBoundaryCAO()
56 // ------------------------------------------------------------------------
58 // no need to delete child widgets, Qt does it all for us
60 // ------------------------------------------------------------------------
61 void MonCreateBoundaryCAO::InitConnect()
62 // ------------------------------------------------------------------------
64 connect( PushFichier, SIGNAL(pressed()), this, SLOT(SetCAOFile()));
65 connect( buttonOk, SIGNAL(pressed()), this, SLOT( PushOnOK()));
66 connect( buttonApply, SIGNAL(pressed()), this, SLOT( PushOnApply()));
67 connect( buttonCancel, SIGNAL(pressed()), this, SLOT(close()));
68 connect( buttonHelp, SIGNAL(pressed()), this, SLOT( PushOnHelp()));
69 connect( CBGroupe, SIGNAL(stateChanged(int)), this, SLOT( SetFiltrage()));
72 // ------------------------------------------------------------------------
73 bool MonCreateBoundaryCAO::PushOnApply()
74 // ------------------------------------------------------------------------
75 // Appele lorsque l'un des boutons Ok ou Apply est presse
80 QString aName=LEName->text().trimmed();
82 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
83 QObject::tr("HOM_BOUN_NAME") );
88 QString aCAOFile=LEFileName->text().trimmed();
89 if (aCAOFile ==QString(""))
91 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
92 QObject::tr("HOM_BOUN_CAO") );
96 // Creation de l'objet CORBA si ce n'est pas deja fait sous le meme nom
97 if ( _aName != aName )
102 aBoundary=myHomardGen->CreateBoundaryCAO(CORBA::string_dup(_aName.toStdString().c_str()), aCAOFile.toStdString().c_str());
103 _parent->AddBoundaryCAO(_aName);
104 aBoundary->SetCaseCreation(_aCaseName.toStdString().c_str());
106 catch( SALOME::SALOME_Exception& S_ex )
108 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
109 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
117 HOMARD_UTILS::updateObjBrowser();
122 // ------------------------------------------------------------------------
123 void MonCreateBoundaryCAO::PushOnOK()
124 // ------------------------------------------------------------------------
126 if (PushOnApply()) this->close();
127 if ( _parent ) { _parent->raise(); _parent->activateWindow(); };
129 // ------------------------------------------------------------------------
130 void MonCreateBoundaryCAO::PushOnHelp()
131 // ------------------------------------------------------------------------
133 std::string LanguageShort = myHomardGen->GetLanguageShort();
134 HOMARD_UTILS::PushOnHelp(QString("gui_create_boundary.html"), QString("CAO"), QString(LanguageShort.c_str()));
136 // ------------------------------------------------------------------------
137 void MonCreateBoundaryCAO::AssocieLesGroupes()
138 // ------------------------------------------------------------------------
140 ADAPT::ListGroupType_var aSeqGroupe = new ADAPT::ListGroupType;
141 aSeqGroupe->length(_listeGroupesBoundary.size());
142 QStringList::const_iterator it;
144 for (it = _listeGroupesBoundary.constBegin(); it != _listeGroupesBoundary.constEnd(); it++)
145 aSeqGroupe[i++]=(*it).toStdString().c_str();
146 aBoundary->SetGroups(aSeqGroupe);
150 // -------------------------------------------------
151 void MonCreateBoundaryCAO::SetNewName()
152 // --------------------------------------------------
155 ADAPT::listeBoundarys_var MyObjects = myHomardGen->GetAllBoundarysName();
156 int num = 0; QString aName="";
157 while (aName == QString("") )
159 aName.setNum(num+1) ;
160 aName.insert(0, QString("Boun_")) ;
161 for ( int i=0; i<MyObjects->length(); i++)
163 if ( aName == QString(MyObjects[i]))
171 LEName->setText(aName);
173 // ------------------------------------------------------------------------
174 void MonCreateBoundaryCAO::SetCAOFile()
175 // ------------------------------------------------------------------------
177 QString aCAOFile = HOMARD_QT_COMMUN::PushNomFichier( false, QString("xao") );
178 if (!(aCAOFile.isEmpty())) LEFileName->setText(aCAOFile);
181 // ------------------------------------------------------------------------
182 void MonCreateBoundaryCAO::setGroups (QStringList listGroup)
183 // ------------------------------------------------------------------------
185 _listeGroupesBoundary = listGroup;
187 // ------------------------------------------------------------------------
188 void MonCreateBoundaryCAO::SetFiltrage()
189 // // ------------------------------------------------------------------------
191 if (!CBGroupe->isChecked()) return;
192 if (_aCaseName.toStdString().c_str() == QString()) {
193 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
194 QObject::tr("HOM_BOUN_CASE") );
198 MonCreateListGroupCAO *aDlg = new MonCreateListGroupCAO(NULL, this, true, ADAPT::ADAPT_Gen::_duplicate(myHomardGen),
199 _aCaseName, _listeGroupesBoundary) ;