1 // Copyright (C) 2011-2022 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 "SMESHGUI_HomardListGroup.h"
22 #include "SMESHGUI_HomardBoundaryDlg.h"
23 #include "SMESHGUI_HomardUtils.h"
24 #include "SMESHGUI_Utils.h"
26 #include "SalomeApp_Tools.h"
28 #include <SUIT_Desktop.h>
29 #include <SUIT_MessageBox.h>
30 #include <SUIT_ResourceMgr.h>
31 #include <SUIT_Session.h>
32 #include <SUIT_ViewManager.h>
34 #include <utilities.h>
36 #include <QFileDialog>
40 // ------------------------------------------------------------------------------------
41 SMESH_CreateListGroupCAO::SMESH_CreateListGroupCAO(SMESH_CreateBoundaryCAO* parentBound,
43 SMESHHOMARD::HOMARD_Gen_var myHomardGen0,
45 QStringList listeGroupesHypo)
46 : QDialog(0), SMESH_Ui_CreateListGroup(),
47 _aCaseName (aCaseName),
48 _listeGroupesHypo (listeGroupesHypo),
49 _parentBound(parentBound)
51 MESSAGE("Debut de SMESH_CreateListGroupCAO");
52 myHomardGen = SMESHHOMARD::HOMARD_Gen::_duplicate(myHomardGen0);
58 // ------------------------------------------------------------------------------------
59 SMESH_CreateListGroupCAO::SMESH_CreateListGroupCAO(SMESH_CreateBoundaryCAO* parentBound,
60 SMESHHOMARD::HOMARD_Gen_var myHomardGen0,
62 QStringList listeGroupesHypo)
63 : QDialog(0), SMESH_Ui_CreateListGroup(),
64 _aCaseName (aCaseName),
65 _listeGroupesHypo (listeGroupesHypo),
66 _parentBound(parentBound)
68 myHomardGen = SMESHHOMARD::HOMARD_Gen::_duplicate(myHomardGen0);
73 // ------------------------------------------------------------------------
74 SMESH_CreateListGroupCAO::~SMESH_CreateListGroupCAO()
75 // ------------------------------------------------------------------------
77 // no need to delete child widgets, Qt does it all for us
79 // ------------------------------------------------------------------------
80 void SMESH_CreateListGroupCAO::InitConnect()
81 // ------------------------------------------------------------------------
83 connect( buttonOk, SIGNAL( pressed() ), this, SLOT( PushOnOK() ) );
84 connect( buttonApply, SIGNAL( pressed() ), this, SLOT( PushOnApply() ) );
85 connect( buttonCancel, SIGNAL( pressed() ), this, SLOT( close() ) );
86 connect( buttonHelp, SIGNAL( pressed() ), this, SLOT( PushOnHelp() ) );
88 // ------------------------------------------------------------------------
89 bool SMESH_CreateListGroupCAO::PushOnApply()
90 // ------------------------------------------------------------------------
91 // Appele lorsque l'un des boutons Ok ou Apply est presse
94 QStringList ListeGroup ;
95 for ( int row=0; row< TWGroupe->rowCount(); row++)
97 if ( TWGroupe->item( row, 0 )->checkState() == Qt::Checked )
98 ListeGroup.insert(0, QString(TWGroupe->item(row, 1)->text()) );
100 if ( _parentBound ) { _parentBound->setGroups(ListeGroup);};
105 // ------------------------------------------------------------------------
106 void SMESH_CreateListGroupCAO::PushOnOK()
107 // ------------------------------------------------------------------------
109 if (PushOnApply()) this->close();
110 if ( _parentBound ) { _parentBound->raise(); _parentBound->activateWindow(); };
112 // ------------------------------------------------------------------------
113 void SMESH_CreateListGroupCAO::PushOnHelp()
114 // ------------------------------------------------------------------------
116 SMESH::ShowHelpFile(QString("homard_create_boundary.html#filtering-by-the-groups"));
118 // ------------------------------------------------------------------------
119 void SMESH_CreateListGroupCAO::InitGroupes()
120 // ------------------------------------------------------------------------
122 MESSAGE("Debut de SMESH_CreateListGroupCAO::InitGroupes ");
123 for ( int row=0; row< TWGroupe->rowCount(); row++)
124 TWGroupe->removeRow(row);
125 TWGroupe->setRowCount(0);
126 if (_aCaseName == QString("")) { return; };
127 SMESHHOMARD::HOMARD_Cas_var monCas = myHomardGen->GetCase();
128 SMESHHOMARD::ListGroupType_var _listeGroupesCas = monCas->GetGroups();
129 for ( int i = 0; i < _listeGroupesCas->length(); i++ ) {
130 TWGroupe->insertRow(i);
131 TWGroupe->setItem( i, 0, new QTableWidgetItem( QString ("") ) );
132 TWGroupe->item( i, 0 )->setFlags( 0 );
133 TWGroupe->item( i, 0 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled );
134 if (_listeGroupesHypo.contains (QString((_listeGroupesCas)[i])))
135 {TWGroupe->item( i, 0 )->setCheckState( Qt::Checked );}
137 {TWGroupe->item( i, 0 )->setCheckState( Qt::Unchecked );}
138 TWGroupe->setItem( i, 1, new QTableWidgetItem(QString((_listeGroupesCas)[i]).trimmed()));
139 TWGroupe->item( i, 1 )->setFlags(Qt::ItemIsEnabled |Qt::ItemIsSelectable );
141 TWGroupe->resizeColumnsToContents();
142 TWGroupe->resizeRowsToContents();
143 TWGroupe->clearSelection();
144 // MESSAGE("Fin de SMESH_CreateListGroupCAO::InitGroupes ");
148 // ------------------------------------------------------------------------
149 SMESH_CreateListGroup::SMESH_CreateListGroup(SMESH_CreateBoundaryDi* parentBound, bool modal,
150 SMESHHOMARD::HOMARD_Gen_var myHomardGen0,
151 QString aCaseName, QStringList listeGroupesHypo)
152 : QDialog(0), SMESH_Ui_CreateListGroup(),
153 _aCaseName (aCaseName),
154 _listeGroupesHypo (listeGroupesHypo),
155 _parentBound(parentBound)
157 MESSAGE("Debut de SMESH_CreateListGroup");
158 myHomardGen = SMESHHOMARD::HOMARD_Gen::_duplicate(myHomardGen0);
165 // ------------------------------------------------------------------------
166 SMESH_CreateListGroup::SMESH_CreateListGroup(SMESH_CreateBoundaryDi* parentBound,
167 SMESHHOMARD::HOMARD_Gen_var myHomardGen0,
168 QString aCaseName, QStringList listeGroupesHypo)
169 : QDialog(0), SMESH_Ui_CreateListGroup(),
170 _aCaseName (aCaseName),
171 _listeGroupesHypo (listeGroupesHypo),
172 _parentBound(parentBound)
174 myHomardGen = SMESHHOMARD::HOMARD_Gen::_duplicate(myHomardGen0);
179 // ------------------------------------------------------------------------
180 SMESH_CreateListGroup::~SMESH_CreateListGroup()
182 // no need to delete child widgets, Qt does it all for us
184 // ------------------------------------------------------------------------
185 void SMESH_CreateListGroup::InitConnect()
186 // ------------------------------------------------------------------------
188 connect( buttonOk, SIGNAL( pressed() ), this, SLOT( PushOnOK() ) );
189 connect( buttonApply, SIGNAL( pressed() ), this, SLOT( PushOnApply() ) );
190 connect( buttonCancel, SIGNAL( pressed() ), this, SLOT( close() ) );
191 connect( buttonHelp, SIGNAL( pressed() ), this, SLOT( PushOnHelp() ) );
193 // ------------------------------------------------------------------------
194 bool SMESH_CreateListGroup::PushOnApply()
195 // ------------------------------------------------------------------------
196 // Appele lorsque l'un des boutons Ok ou Apply est presse
199 QStringList ListeGroup ;
200 for ( int row=0; row< TWGroupe->rowCount(); row++)
202 if ( TWGroupe->item( row, 0 )->checkState() == Qt::Checked )
203 ListeGroup.insert(0, QString(TWGroupe->item(row, 1)->text()) );
205 if ( _parentBound ) { _parentBound->setGroups(ListeGroup);};
210 // ------------------------------------------------------------------------
211 void SMESH_CreateListGroup::PushOnOK()
212 // ------------------------------------------------------------------------
217 if ( _parentBound ) { _parentBound->raise(); _parentBound->activateWindow(); };
220 // ------------------------------------------------------------------------
221 void SMESH_CreateListGroup::PushOnHelp()
222 // ------------------------------------------------------------------------
224 SMESH::ShowHelpFile(QString("homard_create_boundary.html#filtering-by-the-groups"));
226 // ------------------------------------------------------------------------
227 void SMESH_CreateListGroup::InitGroupes()
228 // ------------------------------------------------------------------------
230 MESSAGE("Debut de SMESH_CreateListGroup::InitGroupes ");
231 for ( int row=0; row< TWGroupe->rowCount(); row++)
232 TWGroupe->removeRow(row);
233 TWGroupe->setRowCount(0);
234 if (_aCaseName == QString("")) { return; };
235 SMESHHOMARD::HOMARD_Cas_var monCas = myHomardGen->GetCase();
236 SMESHHOMARD::ListGroupType_var _listeGroupesCas = monCas->GetGroups();
237 for ( int i = 0; i < _listeGroupesCas->length(); i++ )
239 TWGroupe->insertRow(i);
240 TWGroupe->setItem( i, 0, new QTableWidgetItem( QString ("") ) );
241 TWGroupe->item( i, 0 )->setFlags( 0 );
242 TWGroupe->item( i, 0 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled );
243 if (_listeGroupesHypo.contains (QString((_listeGroupesCas)[i])))
244 {TWGroupe->item( i, 0 )->setCheckState( Qt::Checked );}
246 {TWGroupe->item( i, 0 )->setCheckState( Qt::Unchecked );}
247 TWGroupe->setItem( i, 1, new QTableWidgetItem(QString((_listeGroupesCas)[i]).trimmed()));
248 TWGroupe->item( i, 1 )->setFlags(Qt::ItemIsEnabled |Qt::ItemIsSelectable );
250 TWGroupe->resizeColumnsToContents();
251 TWGroupe->resizeRowsToContents();
252 TWGroupe->clearSelection();
253 // MESSAGE("Fin de SMESH_CreateListGroup::InitGroupes ");
256 //---------------------------------------------------------------------
257 SMESH_EditListGroupCAO::SMESH_EditListGroupCAO( SMESH_CreateBoundaryCAO* parentBound,
259 SMESHHOMARD::HOMARD_Gen_var myHomardGen0,
261 QStringList listeGroupesHypo):
262 //---------------------------------------------------------------------
263 SMESH_CreateListGroupCAO(parentBound,myHomardGen0,aCaseName,listeGroupesHypo)
265 MESSAGE("Debut de SMESH_EditListGroupCAO");
266 setWindowTitle(QObject::tr("HOM_GROU_EDIT_WINDOW_TITLE"));
271 //------------------------------------
272 SMESH_EditListGroupCAO:: ~SMESH_EditListGroupCAO()
273 //------------------------------------
276 // -------------------------------------
277 void SMESH_EditListGroupCAO:: InitGroupes()
278 // -------------------------------------
280 for (int i = 0; i < _listeGroupesHypo.size(); i++ )
282 std::cerr << _listeGroupesHypo[i].toStdString().c_str() << std::endl;
283 TWGroupe->insertRow(i);
284 TWGroupe->setItem( i, 0, new QTableWidgetItem( QString ("") ) );
285 TWGroupe->item( i, 0 )->setFlags( 0 );
286 TWGroupe->item( i, 0 )->setCheckState( Qt::Checked );
287 TWGroupe->setItem( i, 1, new QTableWidgetItem(_listeGroupesHypo[i]));
289 TWGroupe->resizeRowsToContents();
292 //---------------------------------------------------------------------
293 SMESH_EditListGroup::SMESH_EditListGroup( SMESH_CreateBoundaryDi* parentBound,
295 SMESHHOMARD::HOMARD_Gen_var myHomardGen0,
297 QStringList listeGroupesHypo):
298 //---------------------------------------------------------------------
299 SMESH_CreateListGroup(parentBound,myHomardGen0,aCaseName,listeGroupesHypo)
301 MESSAGE("Debut de SMESH_EditListGroup");
302 setWindowTitle(QObject::tr("HOM_GROU_EDIT_WINDOW_TITLE"));
307 //------------------------------------
308 SMESH_EditListGroup::~SMESH_EditListGroup()
309 //------------------------------------
312 // -------------------------------------
313 void SMESH_EditListGroup::InitGroupes()
314 // -------------------------------------
316 for (int i = 0; i < _listeGroupesHypo.size(); i++ )
318 std::cerr << _listeGroupesHypo[i].toStdString().c_str() << std::endl;
319 TWGroupe->insertRow(i);
320 TWGroupe->setItem( i, 0, new QTableWidgetItem( QString ("") ) );
321 TWGroupe->item( i, 0 )->setFlags( 0 );
322 TWGroupe->item( i, 0 )->setCheckState( Qt::Checked );
323 TWGroupe->setItem( i, 1, new QTableWidgetItem(_listeGroupesHypo[i]));
325 TWGroupe->resizeRowsToContents();