1 // Copyright (C) 2011-2012 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.
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
22 #include "MonCreateListGroup.h"
23 #include "MonCreateHypothesis.h"
24 #include "MonCreateBoundaryDi.h"
26 #include <QFileDialog>
28 #include "SalomeApp_Tools.h"
29 #include "HOMARDGUI_Utils.h"
30 #include "HomardQtCommun.h"
31 #include <utilities.h>
33 #include <SUIT_Desktop.h>
34 #include <SUIT_MessageBox.h>
35 #include <SUIT_ResourceMgr.h>
36 #include <SUIT_Session.h>
37 #include <SUIT_ViewManager.h>
39 // --------------------------------------------------------------------------------------------------------------
40 MonCreateListGroup::MonCreateListGroup(MonCreateHypothesis* parentHyp, MonCreateBoundaryDi* parentBound, bool modal,
41 HOMARD::HOMARD_Gen_var myHomardGen, QString aCaseName, QStringList listeGroupesHypo) :
42 // --------------------------------------------------------------------------------------------------------------
44 QDialog(0), Ui_CreateListGroup(),
45 _aCaseName (aCaseName),
46 _listeGroupesHypo (listeGroupesHypo),
47 _parentHyp(parentHyp),
48 _parentBound(parentBound)
50 MESSAGE("Debut de MonCreateListGroup")
51 _myHomardGen=HOMARD::HOMARD_Gen::_duplicate(myHomardGen);
57 // --------------------------------------------------------------------------------------------------------------
58 MonCreateListGroup::MonCreateListGroup(MonCreateHypothesis* parentHyp, MonCreateBoundaryDi* parentBound,
59 HOMARD::HOMARD_Gen_var myHomardGen, QString aCaseName, QStringList listeGroupesHypo) :
60 // --------------------------------------------------------------------------------------------------------------
62 QDialog(0), Ui_CreateListGroup(),
63 _aCaseName (aCaseName),
64 _listeGroupesHypo (listeGroupesHypo),
65 _parentHyp(parentHyp),
66 _parentBound(parentBound)
68 _myHomardGen=HOMARD::HOMARD_Gen::_duplicate(myHomardGen);
73 // ------------------------------------------------------------------------
74 MonCreateListGroup::~MonCreateListGroup()
75 // ------------------------------------------------------------------------
77 // no need to delete child widgets, Qt does it all for us
79 // ------------------------------------------------------------------------
80 void MonCreateListGroup::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 MonCreateListGroup::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 ( _parentHyp ) { _parentHyp->setGroups(ListeGroup);};
101 if ( _parentBound ) { _parentBound->setGroups(ListeGroup);};
106 // ------------------------------------------------------------------------
107 void MonCreateListGroup::PushOnOK()
108 // ------------------------------------------------------------------------
110 if (PushOnApply()) this->close();
111 if ( _parentHyp ) { _parentHyp->raise(); _parentHyp->activateWindow(); };
112 if ( _parentBound ) { _parentBound->raise(); _parentBound->activateWindow(); };
114 // ------------------------------------------------------------------------
115 void MonCreateListGroup::PushOnHelp()
116 // ------------------------------------------------------------------------
118 HOMARD_UTILS::PushOnHelp(QString("gui_create_hypothese.html"));
120 // ------------------------------------------------------------------------
121 void MonCreateListGroup::InitGroupes()
122 // ------------------------------------------------------------------------
124 MESSAGE("Debut de MonCreateListGroup::InitGroupes ");
125 for ( int row=0; row< TWGroupe->rowCount(); row++)
126 TWGroupe->removeRow(row);
127 TWGroupe->setRowCount(0);
128 if (_aCaseName == QString("")) { return; };
129 HOMARD::HOMARD_Cas_var monCas= _myHomardGen->GetCase(_aCaseName.toStdString().c_str());
130 HOMARD::ListGroupType_var _listeGroupesCas = monCas->GetGroups();
131 for ( int i = 0; i < _listeGroupesCas->length(); i++ )
133 TWGroupe->insertRow(i);
134 TWGroupe->setItem( i, 0, new QTableWidgetItem( QString ("") ) );
135 TWGroupe->item( i, 0 )->setFlags( 0 );
136 TWGroupe->item( i, 0 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled );
137 if (_listeGroupesHypo.contains (QString((_listeGroupesCas)[i])))
138 {TWGroupe->item( i, 0 )->setCheckState( Qt::Checked );}
140 {TWGroupe->item( i, 0 )->setCheckState( Qt::Unchecked );}
141 TWGroupe->setItem( i, 1, new QTableWidgetItem(QString((_listeGroupesCas)[i]).trimmed()));
142 TWGroupe->item( i, 1 )->setFlags(Qt::ItemIsEnabled |Qt::ItemIsSelectable );
144 TWGroupe->resizeColumnsToContents();
145 TWGroupe->resizeRowsToContents();
146 TWGroupe->clearSelection();
147 // MESSAGE("Fin de MonCreateListGroup::InitGroupes ");