Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYMateriauConstructionWidget.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012> <EDF-R&D> <FRANCE>
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10  * See the GNU General Public License for more details.
11  * You should have received a copy of the GNU General Public License along
12  * with this program; if not, write to the Free Software Foundation, Inc.,
13  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
14  */
15 
23 #include <qfiledialog.h>
28 // Added by qt3to4:
29 #include <QGridLayout>
30 #include <QLabel>
31 
33 
34 #define TR(id) OLocalizator::getString("TYMateriauConstructionWidget", (id))
35 
37  QWidget* _pParent /*=NULL*/)
38  : TYWidget(pElement, _pParent)
39 {
40  QString num;
41 
42  _elmW = new TYElementWidget(pElement, this);
43 
44  resize(300, 200);
45  setWindowTitle(TR("id_caption"));
46  _matConstrLayout = new QGridLayout();
47  setLayout(_matConstrLayout);
48  _matConstrLayout->addWidget(_elmW, 0, 0);
49 
50  _groupBox = new QGroupBox(this);
51  _groupBox->setTitle(TR(""));
52  _groupBoxLayout = new QGridLayout();
53  _groupBox->setLayout(_groupBoxLayout);
54 
56  _lineEditMasseVol->setText(num.setNum(getElement()->getMasseVol(), 'f', 2));
57  _groupBoxLayout->addWidget(_lineEditMasseVol, 0, 1);
58  QLabel* pUnitMassVol = new QLabel(_groupBox);
59  pUnitMassVol->setText(TR("id_unite_massvol"));
60  _groupBoxLayout->addWidget(pUnitMassVol, 0, 2);
61 
62  _labelMasseVol = new QLabel(_groupBox);
63  _labelMasseVol->setText(TR("id_massevol_label"));
64  _groupBoxLayout->addWidget(_labelMasseVol, 0, 0);
65 
66  _matConstrLayout->addWidget(_groupBox, 1, 0);
67 
68  _groupBoxSpectreAbs = new QGroupBox(this);
69  _groupBoxSpectreAbs->setTitle(TR("id_spectreabs"));
70  _groupBoxSpectreAbsLayout = new QGridLayout();
72 
73  _pushButtonSpectreAbs = new QPushButton(_groupBoxSpectreAbs);
74  _pushButtonSpectreAbs->setText(TR("id_proprietes_button"));
76 
78  _lineEditNomSpectreAbs->setText(getElement()->getSpectreAbso().getName());
79  _lineEditNomSpectreAbs->setEnabled(false);
80 
82 
83  _matConstrLayout->addWidget(_groupBoxSpectreAbs, 2, 0);
84 
85  _groupBoxSpectreTransm = new QGroupBox(this);
86  _groupBoxSpectreTransm->setTitle(TR("id_spectretransm"));
87  _groupBoxSpectreTransmLayout = new QGridLayout();
89 
91  _pushButtonSpectreTransm->setText(TR("id_proprietes_button"));
92 
94 
96  _lineEditNomSpectreTransm->setText(getElement()->getSpectreTransm().getName());
97  _lineEditNomSpectreTransm->setEnabled(false);
99 
100  _matConstrLayout->addWidget(_groupBoxSpectreTransm, 3, 0);
101 
102  QGroupBox* buttonGroupBox = new QGroupBox(this);
103  buttonGroupBox->setTitle(TR(""));
104  QGridLayout* buttonGroupBoxLayout = new QGridLayout();
105  buttonGroupBox->setLayout(buttonGroupBoxLayout);
106 
107  _pushButtonGetFromXML = new QPushButton(buttonGroupBox);
108  _pushButtonGetFromXML->setText(TR("id_get_from_xml"));
109  buttonGroupBoxLayout->addWidget(_pushButtonGetFromXML, 0, 1);
110 
111  _matConstrLayout->addWidget(buttonGroupBox, 4, 0);
112 
113  connect(_pushButtonGetFromXML, &QPushButton::clicked, this, &TYMateriauConstructionWidget::getFromXML);
114  connect(_pushButtonSpectreTransm, &QPushButton::clicked, this,
116  connect(_pushButtonSpectreAbs, &QPushButton::clicked, this, &TYMateriauConstructionWidget::editSpectreA);
117 
118  updateContent();
119 }
120 
122 
124 {
125  QString num;
126 
127  _elmW->updateContent();
128 
129  _lineEditMasseVol->setText(num.setNum(getElement()->getMasseVol(), 'f', 2));
130  _lineEditNomSpectreAbs->setText(getElement()->getSpectreAbso().getName());
131  _lineEditNomSpectreTransm->setText(getElement()->getSpectreTransm().getName());
132 }
133 
135 {
136  _elmW->apply();
137 
138  getElement()->setMasseVol(_lineEditMasseVol->text().toDouble());
139 
140  emit modified();
141 }
142 
144 {
145  int ret = getElement()->getSpectreTransm().edit(this);
146 
147  if (ret == QDialog::Accepted)
148  {
149  _lineEditNomSpectreTransm->setText(getElement()->getSpectreTransm().getName());
150  }
151 }
152 
154 {
155  int ret = getElement()->getSpectreAbso().edit(this);
156 
157  if (ret == QDialog::Accepted)
158  {
159  _lineEditNomSpectreAbs->setText(getElement()->getSpectreAbso().getName());
160  }
161 }
162 
164 {
165  QString fileName = QFileDialog::getOpenFileName(this, "", "", "XML (*.xml)");
166 
167  if (!fileName.isEmpty())
168  {
169  TYXMLManager xmlManager;
170  TYElement* pElt = NULL;
171  LPTYElementArray eltList;
172 
173  LPTYMateriauConstruction pMat = NULL;
174 
175  xmlManager.load(fileName, eltList);
176 
177  size_t count = eltList.size();
178  for (size_t i = 0; i < count; i++)
179  {
180  pElt = eltList.at(i);
181 
182  if ((pElt != NULL) && (pElt->isA("TYMateriauConstruction")))
183  {
184  pMat = (TYMateriauConstruction*)pElt;
185 
186  if (pMat != NULL)
187  {
188  (*getElement()) = (*pMat);
189  updateContent();
190  }
191  }
192  }
193 
194  pElt = NULL;
195  }
196 }
std::vector< LPTYElement > LPTYElementArray
Definition: TYElement.h:345
outil IHM pour une entrée utilisateur (fichier header)
#define TR(id)
Outil IHM pour des materiaux de construction (fichier header)
bool isA(const char *className) const
Definition: TYElement.cpp:65
classe de l'objet IHM pour un element
virtual void apply()
virtual void updateContent()
TYMateriauConstructionWidget(TYMateriauConstruction *pElement, QWidget *_pParent=NULL)
classe de l'objet IHM pour un objet metier de type TYElement
Definition: TYWidget.h:43
void modified()
int load(const QString &fileName, LPTYElementArray &eltCollection)