1 // Copyright (C) 2011-2021 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, bool modal,
42 SMESHHOMARD::HOMARD_Gen_var myHomardGen0,
44 QStringList listeGroupesHypo)
45 : QDialog(0), SMESH_Ui_CreateListGroup(),
46 _aCaseName (aCaseName),
47 _listeGroupesHypo (listeGroupesHypo),
48 _parentBound(parentBound)
50 MESSAGE("Debut de SMESH_CreateListGroupCAO");
51 myHomardGen = SMESHHOMARD::HOMARD_Gen::_duplicate(myHomardGen0);
57 // --------------------------------------------------------------------------------------------------------------
58 SMESH_CreateListGroupCAO::SMESH_CreateListGroupCAO(SMESH_CreateBoundaryCAO* parentBound,
59 SMESHHOMARD::HOMARD_Gen_var myHomardGen,
61 QStringList listeGroupesHypo)
62 : QDialog(0), SMESH_Ui_CreateListGroup(),
63 _aCaseName (aCaseName),
64 _listeGroupesHypo (listeGroupesHypo),
65 _parentBound(parentBound)
67 myHomardGen = SMESHHOMARD::HOMARD_Gen::_duplicate(myHomardGen);
72 // ------------------------------------------------------------------------
73 SMESH_CreateListGroupCAO::~SMESH_CreateListGroupCAO()
74 // ------------------------------------------------------------------------
76 // no need to delete child widgets, Qt does it all for us
78 // ------------------------------------------------------------------------
79 void SMESH_CreateListGroupCAO::InitConnect()
80 // ------------------------------------------------------------------------
82 connect( buttonOk, SIGNAL( pressed() ), this, SLOT( PushOnOK() ) );
83 connect( buttonApply, SIGNAL( pressed() ), this, SLOT( PushOnApply() ) );
84 connect( buttonCancel, SIGNAL( pressed() ), this, SLOT( close() ) );
85 connect( buttonHelp, SIGNAL( pressed() ), this, SLOT( PushOnHelp() ) );
87 // ------------------------------------------------------------------------
88 bool SMESH_CreateListGroupCAO::PushOnApply()
89 // ------------------------------------------------------------------------
90 // Appele lorsque l'un des boutons Ok ou Apply est presse
93 QStringList ListeGroup ;
94 for ( int row=0; row< TWGroupe->rowCount(); row++)
96 if ( TWGroupe->item( row, 0 )->checkState() == Qt::Checked )
97 ListeGroup.insert(0, QString(TWGroupe->item(row, 1)->text()) );
99 if ( _parentBound ) { _parentBound->setGroups(ListeGroup);};
104 // ------------------------------------------------------------------------
105 void SMESH_CreateListGroupCAO::PushOnOK()
106 // ------------------------------------------------------------------------
108 if (PushOnApply()) this->close();
109 if ( _parentBound ) { _parentBound->raise(); _parentBound->activateWindow(); };
111 // ------------------------------------------------------------------------
112 void SMESH_CreateListGroupCAO::PushOnHelp()
113 // ------------------------------------------------------------------------
115 SMESH::ShowHelpFile(QString("gui_create_hypothese.html"));
117 // ------------------------------------------------------------------------
118 void SMESH_CreateListGroupCAO::InitGroupes()
119 // ------------------------------------------------------------------------
121 MESSAGE("Debut de SMESH_CreateListGroupCAO::InitGroupes ");
122 for ( int row=0; row< TWGroupe->rowCount(); row++)
123 TWGroupe->removeRow(row);
124 TWGroupe->setRowCount(0);
125 if (_aCaseName == QString("")) { return; };
126 SMESHHOMARD::HOMARD_Cas_var monCas = myHomardGen->GetCase();
127 SMESHHOMARD::ListGroupType_var _listeGroupesCas = monCas->GetGroups();
128 for ( int i = 0; i < _listeGroupesCas->length(); i++ ) {
129 TWGroupe->insertRow(i);
130 TWGroupe->setItem( i, 0, new QTableWidgetItem( QString ("") ) );
131 TWGroupe->item( i, 0 )->setFlags( 0 );
132 TWGroupe->item( i, 0 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled );
133 if (_listeGroupesHypo.contains (QString((_listeGroupesCas)[i])))
134 {TWGroupe->item( i, 0 )->setCheckState( Qt::Checked );}
136 {TWGroupe->item( i, 0 )->setCheckState( Qt::Unchecked );}
137 TWGroupe->setItem( i, 1, new QTableWidgetItem(QString((_listeGroupesCas)[i]).trimmed()));
138 TWGroupe->item( i, 1 )->setFlags(Qt::ItemIsEnabled |Qt::ItemIsSelectable );
140 TWGroupe->resizeColumnsToContents();
141 TWGroupe->resizeRowsToContents();
142 TWGroupe->clearSelection();
143 // MESSAGE("Fin de SMESH_CreateListGroupCAO::InitGroupes ");
147 // ------------------------------------------------------------------------
148 SMESH_CreateListGroup::SMESH_CreateListGroup(SMESH_CreateBoundaryDi* parentBound, bool modal,
149 SMESHHOMARD::HOMARD_Gen_var myHomardGen0,
150 QString aCaseName, QStringList listeGroupesHypo)
151 : QDialog(0), SMESH_Ui_CreateListGroup(),
152 _aCaseName (aCaseName),
153 _listeGroupesHypo (listeGroupesHypo),
154 _parentBound(parentBound)
156 MESSAGE("Debut de SMESH_CreateListGroup");
157 myHomardGen = SMESHHOMARD::HOMARD_Gen::_duplicate(myHomardGen0);
164 // ------------------------------------------------------------------------
165 SMESH_CreateListGroup::SMESH_CreateListGroup(SMESH_CreateBoundaryDi* parentBound,
166 SMESHHOMARD::HOMARD_Gen_var myHomardGen,
167 QString aCaseName, QStringList listeGroupesHypo)
168 : QDialog(0), SMESH_Ui_CreateListGroup(),
169 _aCaseName (aCaseName),
170 _listeGroupesHypo (listeGroupesHypo),
171 _parentBound(parentBound)
173 myHomardGen = SMESHHOMARD::HOMARD_Gen::_duplicate(myHomardGen);
178 // ------------------------------------------------------------------------
179 SMESH_CreateListGroup::~SMESH_CreateListGroup()
181 // no need to delete child widgets, Qt does it all for us
183 // ------------------------------------------------------------------------
184 void SMESH_CreateListGroup::InitConnect()
185 // ------------------------------------------------------------------------
187 connect( buttonOk, SIGNAL( pressed() ), this, SLOT( PushOnOK() ) );
188 connect( buttonApply, SIGNAL( pressed() ), this, SLOT( PushOnApply() ) );
189 connect( buttonCancel, SIGNAL( pressed() ), this, SLOT( close() ) );
190 connect( buttonHelp, SIGNAL( pressed() ), this, SLOT( PushOnHelp() ) );
192 // ------------------------------------------------------------------------
193 bool SMESH_CreateListGroup::PushOnApply()
194 // ------------------------------------------------------------------------
195 // Appele lorsque l'un des boutons Ok ou Apply est presse
198 QStringList ListeGroup ;
199 for ( int row=0; row< TWGroupe->rowCount(); row++)
201 if ( TWGroupe->item( row, 0 )->checkState() == Qt::Checked )
202 ListeGroup.insert(0, QString(TWGroupe->item(row, 1)->text()) );
204 if ( _parentBound ) { _parentBound->setGroups(ListeGroup);};
209 // ------------------------------------------------------------------------
210 void SMESH_CreateListGroup::PushOnOK()
211 // ------------------------------------------------------------------------
216 if ( _parentBound ) { _parentBound->raise(); _parentBound->activateWindow(); };
219 // ------------------------------------------------------------------------
220 void SMESH_CreateListGroup::PushOnHelp()
221 // ------------------------------------------------------------------------
223 SMESH::ShowHelpFile(QString("gui_create_hypothese.html"));
225 // ------------------------------------------------------------------------
226 void SMESH_CreateListGroup::InitGroupes()
227 // ------------------------------------------------------------------------
229 MESSAGE("Debut de SMESH_CreateListGroup::InitGroupes ");
230 for ( int row=0; row< TWGroupe->rowCount(); row++)
231 TWGroupe->removeRow(row);
232 TWGroupe->setRowCount(0);
233 if (_aCaseName == QString("")) { return; };
234 SMESHHOMARD::HOMARD_Cas_var monCas = myHomardGen->GetCase();
235 SMESHHOMARD::ListGroupType_var _listeGroupesCas = monCas->GetGroups();
236 for ( int i = 0; i < _listeGroupesCas->length(); i++ )
238 TWGroupe->insertRow(i);
239 TWGroupe->setItem( i, 0, new QTableWidgetItem( QString ("") ) );
240 TWGroupe->item( i, 0 )->setFlags( 0 );
241 TWGroupe->item( i, 0 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled );
242 if (_listeGroupesHypo.contains (QString((_listeGroupesCas)[i])))
243 {TWGroupe->item( i, 0 )->setCheckState( Qt::Checked );}
245 {TWGroupe->item( i, 0 )->setCheckState( Qt::Unchecked );}
246 TWGroupe->setItem( i, 1, new QTableWidgetItem(QString((_listeGroupesCas)[i]).trimmed()));
247 TWGroupe->item( i, 1 )->setFlags(Qt::ItemIsEnabled |Qt::ItemIsSelectable );
249 TWGroupe->resizeColumnsToContents();
250 TWGroupe->resizeRowsToContents();
251 TWGroupe->clearSelection();
252 // MESSAGE("Fin de SMESH_CreateListGroup::InitGroupes ");
255 //---------------------------------------------------------------------
256 SMESH_EditListGroupCAO::SMESH_EditListGroupCAO( SMESH_CreateBoundaryCAO* parentBound,
258 SMESHHOMARD::HOMARD_Gen_var myHomardGen,
260 QStringList listeGroupesHypo):
261 //---------------------------------------------------------------------
262 SMESH_CreateListGroupCAO(parentBound,myHomardGen,aCaseName,listeGroupesHypo)
264 MESSAGE("Debut de SMESH_EditListGroupCAO");
265 setWindowTitle(QObject::tr("HOM_GROU_EDIT_WINDOW_TITLE"));
270 //------------------------------------
271 SMESH_EditListGroupCAO:: ~SMESH_EditListGroupCAO()
272 //------------------------------------
275 // -------------------------------------
276 void SMESH_EditListGroupCAO:: InitGroupes()
277 // -------------------------------------
279 for (int i = 0; i < _listeGroupesHypo.size(); i++ )
281 std::cerr << _listeGroupesHypo[i].toStdString().c_str() << std::endl;
282 TWGroupe->insertRow(i);
283 TWGroupe->setItem( i, 0, new QTableWidgetItem( QString ("") ) );
284 TWGroupe->item( i, 0 )->setFlags( 0 );
285 TWGroupe->item( i, 0 )->setCheckState( Qt::Checked );
286 TWGroupe->setItem( i, 1, new QTableWidgetItem(_listeGroupesHypo[i]));
288 TWGroupe->resizeRowsToContents();
291 //---------------------------------------------------------------------
292 SMESH_EditListGroup::SMESH_EditListGroup( SMESH_CreateBoundaryDi* parentBound,
294 SMESHHOMARD::HOMARD_Gen_var myHomardGen,
296 QStringList listeGroupesHypo):
297 //---------------------------------------------------------------------
298 SMESH_CreateListGroup(parentBound,myHomardGen,aCaseName,listeGroupesHypo)
300 MESSAGE("Debut de SMESH_EditListGroup");
301 setWindowTitle(QObject::tr("HOM_GROU_EDIT_WINDOW_TITLE"));
306 //------------------------------------
307 SMESH_EditListGroup::~SMESH_EditListGroup()
308 //------------------------------------
311 // -------------------------------------
312 void SMESH_EditListGroup::InitGroupes()
313 // -------------------------------------
315 for (int i = 0; i < _listeGroupesHypo.size(); i++ )
317 std::cerr << _listeGroupesHypo[i].toStdString().c_str() << std::endl;
318 TWGroupe->insertRow(i);
319 TWGroupe->setItem( i, 0, new QTableWidgetItem( QString ("") ) );
320 TWGroupe->item( i, 0 )->setFlags( 0 );
321 TWGroupe->item( i, 0 )->setCheckState( Qt::Checked );
322 TWGroupe->setItem( i, 1, new QTableWidgetItem(_listeGroupesHypo[i]));
324 TWGroupe->resizeRowsToContents();