1 // Copyright (C) 2011-2019 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 "MonCreateListGroupCAO.h"
21 #include "MonCreateHypothesis.h"
22 #include "MonCreateBoundaryCAO.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 MonCreateListGroupCAO::MonCreateListGroupCAO(MonCreateHypothesis* parentHyp, MonCreateBoundaryCAO* 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 MonCreateListGroupCAO")
51 myHomardGen=HOMARD::HOMARD_Gen::_duplicate(myHomardGen0);
57 // --------------------------------------------------------------------------------------------------------------
58 MonCreateListGroupCAO::MonCreateListGroupCAO(MonCreateHypothesis* parentHyp, MonCreateBoundaryCAO* 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 MonCreateListGroupCAO::~MonCreateListGroupCAO()
75 // ------------------------------------------------------------------------
77 // no need to delete child widgets, Qt does it all for us
79 // ------------------------------------------------------------------------
80 void MonCreateListGroupCAO::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 MonCreateListGroupCAO::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 MonCreateListGroupCAO::PushOnOK()
108 // ------------------------------------------------------------------------
110 if (PushOnApply()) this->close();
111 if ( _parentHyp ) { _parentHyp->raise(); _parentHyp->activateWindow(); };
112 if ( _parentBound ) { _parentBound->raise(); _parentBound->activateWindow(); };
114 // ------------------------------------------------------------------------
115 void MonCreateListGroupCAO::PushOnHelp()
116 // ------------------------------------------------------------------------
118 std::string LanguageShort = myHomardGen->GetLanguageShort();
119 HOMARD_UTILS::PushOnHelp(QString("gui_create_hypothese.html"), QString(""), QString(LanguageShort.c_str()));
121 // ------------------------------------------------------------------------
122 void MonCreateListGroupCAO::InitGroupes()
123 // ------------------------------------------------------------------------
125 MESSAGE("Debut de MonCreateListGroupCAO::InitGroupes ");
126 for ( int row=0; row< TWGroupe->rowCount(); row++)
127 TWGroupe->removeRow(row);
128 TWGroupe->setRowCount(0);
129 if (_aCaseName == QString("")) { return; };
130 HOMARD::HOMARD_Cas_var monCas= myHomardGen->GetCase(_aCaseName.toStdString().c_str());
131 HOMARD::ListGroupType_var _listeGroupesCas = monCas->GetGroups();
132 for ( int i = 0; i < _listeGroupesCas->length(); i++ )
134 TWGroupe->insertRow(i);
135 TWGroupe->setItem( i, 0, new QTableWidgetItem( QString ("") ) );
136 TWGroupe->item( i, 0 )->setFlags( 0 );
137 TWGroupe->item( i, 0 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled );
138 if (_listeGroupesHypo.contains (QString((_listeGroupesCas)[i])))
139 {TWGroupe->item( i, 0 )->setCheckState( Qt::Checked );}
141 {TWGroupe->item( i, 0 )->setCheckState( Qt::Unchecked );}
142 TWGroupe->setItem( i, 1, new QTableWidgetItem(QString((_listeGroupesCas)[i]).trimmed()));
143 TWGroupe->item( i, 1 )->setFlags(Qt::ItemIsEnabled |Qt::ItemIsSelectable );
145 TWGroupe->resizeColumnsToContents();
146 TWGroupe->resizeRowsToContents();
147 TWGroupe->clearSelection();
148 // MESSAGE("Fin de MonCreateListGroupCAO::InitGroupes ");