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 "MonCreateListGroup.h"
21 #include "MonCreateHypothesis.h"
22 #include "MonCreateBoundaryDi.h"
24 #include <QFileDialog>
26 #include "SalomeApp_Tools.h"
27 #include "HOMARDGUI_Utils.h"
28 #include "HomardQtCommun.h"
29 #include <utilities.h>
31 #include <SUIT_Desktop.h>
32 #include <SUIT_MessageBox.h>
33 #include <SUIT_ResourceMgr.h>
34 #include <SUIT_Session.h>
35 #include <SUIT_ViewManager.h>
39 // --------------------------------------------------------------------------------------------------------------
40 MonCreateListGroup::MonCreateListGroup(MonCreateHypothesis* parentHyp, MonCreateBoundaryDi* parentBound, bool modal,
41 HOMARD::HOMARD_Gen_var myHomardGen0, 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(myHomardGen0);
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 // ------------------------------------------------------------------------
113 if ( _parentHyp ) { _parentHyp->raise(); _parentHyp->activateWindow(); };
114 if ( _parentBound ) { _parentBound->raise(); _parentBound->activateWindow(); };
117 // ------------------------------------------------------------------------
118 void MonCreateListGroup::PushOnHelp()
119 // ------------------------------------------------------------------------
121 std::string LanguageShort = myHomardGen->GetLanguageShort();
122 HOMARD_UTILS::PushOnHelp(QString("gui_create_hypothese.html"), QString(""), QString(LanguageShort.c_str()));
124 // ------------------------------------------------------------------------
125 void MonCreateListGroup::InitGroupes()
126 // ------------------------------------------------------------------------
128 MESSAGE("Debut de MonCreateListGroup::InitGroupes ");
129 for ( int row=0; row< TWGroupe->rowCount(); row++)
130 TWGroupe->removeRow(row);
131 TWGroupe->setRowCount(0);
132 if (_aCaseName == QString("")) { return; };
133 HOMARD::HOMARD_Cas_var monCas= myHomardGen->GetCase(_aCaseName.toStdString().c_str());
134 HOMARD::ListGroupType_var _listeGroupesCas = monCas->GetGroups();
135 for ( int i = 0; i < _listeGroupesCas->length(); i++ )
137 TWGroupe->insertRow(i);
138 TWGroupe->setItem( i, 0, new QTableWidgetItem( QString ("") ) );
139 TWGroupe->item( i, 0 )->setFlags( 0 );
140 TWGroupe->item( i, 0 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled );
141 if (_listeGroupesHypo.contains (QString((_listeGroupesCas)[i])))
142 {TWGroupe->item( i, 0 )->setCheckState( Qt::Checked );}
144 {TWGroupe->item( i, 0 )->setCheckState( Qt::Unchecked );}
145 TWGroupe->setItem( i, 1, new QTableWidgetItem(QString((_listeGroupesCas)[i]).trimmed()));
146 TWGroupe->item( i, 1 )->setFlags(Qt::ItemIsEnabled |Qt::ItemIsSelectable );
148 TWGroupe->resizeColumnsToContents();
149 TWGroupe->resizeRowsToContents();
150 TWGroupe->clearSelection();
151 // MESSAGE("Fin de MonCreateListGroup::InitGroupes ");