Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYMateriauConstructionWidget.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012-2024> <EDF-DTG> <FRANCE>
3  * This file is part of Code_TYMPAN (R).
4  * Code_TYMPAN (R) is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  * Code_TYMPAN (R) 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.
11  * See the GNU General Public License for more details.
12  * You should have received a copy of the GNU General Public License along
13  * with Code_TYMPAN (R). If not, see <https://www.gnu.org/licenses/>.
14  */
15 
23 #include <qfiledialog.h>
28 // Added by qt3to4:
29 #include <QGridLayout>
30 #include <QLabel>
31 #include <QtWidgets>
32 
34 #include "TYElementWidget.h"
35 
36 #define TR(id) OLocalizator::getString("TYMateriauConstructionWidget", (id))
37 
39  QWidget* _pParent /*=NULL*/)
40  : TYWidget(pElement, _pParent)
41 {
42  QString num;
43 
44  _elmW = new TYElementWidget(pElement, this);
45 
46  resize(300, 200);
47  setWindowTitle(TR("id_caption"));
48  _matConstrLayout = new QGridLayout();
49  setLayout(_matConstrLayout);
50  _matConstrLayout->addWidget(_elmW, 0, 0);
51 
52  _groupBox = new QGroupBox(this);
53  _groupBox->setTitle(TR(""));
54  _groupBoxLayout = new QGridLayout();
55  _groupBox->setLayout(_groupBoxLayout);
56 
58  _lineEditMasseVol->setText(num.setNum(getElement()->getMasseVol(), 'f', 2));
59  _groupBoxLayout->addWidget(_lineEditMasseVol, 0, 1);
60  QLabel* pUnitMassVol = new QLabel(_groupBox);
61  pUnitMassVol->setText(TR("id_unite_massvol"));
62  _groupBoxLayout->addWidget(pUnitMassVol, 0, 2);
63 
64  _labelMasseVol = new QLabel(_groupBox);
65  _labelMasseVol->setText(TR("id_massevol_label"));
66  _groupBoxLayout->addWidget(_labelMasseVol, 0, 0);
67 
68  _matConstrLayout->addWidget(_groupBox, 1, 0);
69 
70  _groupBoxSpectreAbs = new QGroupBox(this);
71  _groupBoxSpectreAbs->setTitle(TR("id_spectreabs"));
72  _groupBoxSpectreAbsLayout = new QGridLayout();
74 
75  _pushButtonSpectreAbs = new QPushButton(_groupBoxSpectreAbs);
76  _pushButtonSpectreAbs->setText(TR("id_proprietes_button"));
78 
80  _lineEditNomSpectreAbs->setText(getElement()->getSpectreAbso().getName());
81  _lineEditNomSpectreAbs->setEnabled(false);
82 
84 
85  _matConstrLayout->addWidget(_groupBoxSpectreAbs, 2, 0);
86 
87  _groupBoxSpectreTransm = new QGroupBox(this);
88  _groupBoxSpectreTransm->setTitle(TR("id_spectretransm"));
89  _groupBoxSpectreTransmLayout = new QGridLayout();
91 
93  _pushButtonSpectreTransm->setText(TR("id_proprietes_button"));
94 
96 
98  _lineEditNomSpectreTransm->setText(getElement()->getSpectreTransm().getName());
99  _lineEditNomSpectreTransm->setEnabled(false);
101 
102  _matConstrLayout->addWidget(_groupBoxSpectreTransm, 3, 0);
103 
104  QGroupBox* buttonGroupBox = new QGroupBox(this);
105  buttonGroupBox->setTitle(TR(""));
106  QGridLayout* buttonGroupBoxLayout = new QGridLayout();
107  buttonGroupBox->setLayout(buttonGroupBoxLayout);
108 
109  _pushButtonGetFromXML = new QPushButton(buttonGroupBox);
110  _pushButtonGetFromXML->setText(TR("id_get_from_xml"));
111  buttonGroupBoxLayout->addWidget(_pushButtonGetFromXML, 0, 1);
112 
113  _matConstrLayout->addWidget(buttonGroupBox, 4, 0);
114 
115  connect(_pushButtonGetFromXML, &QPushButton::clicked, this, &TYMateriauConstructionWidget::getFromXML);
116  connect(_pushButtonSpectreTransm, &QPushButton::clicked, this,
118  connect(_pushButtonSpectreAbs, &QPushButton::clicked, this, &TYMateriauConstructionWidget::editSpectreA);
119 
120  updateContent();
121 }
122 
124 
126 {
127  QString num;
128 
129  _elmW->updateContent();
130 
131  _lineEditMasseVol->setText(num.setNum(getElement()->getMasseVol(), 'f', 2));
132  _lineEditNomSpectreAbs->setText(getElement()->getSpectreAbso().getName());
133  _lineEditNomSpectreTransm->setText(getElement()->getSpectreTransm().getName());
134 }
135 
137 {
138  _elmW->apply();
139 
140  getElement()->setMasseVol(_lineEditMasseVol->text().toDouble());
141 
142  emit modified();
143 }
144 
146 {
147  int ret = getElement()->getSpectreTransm().edit(this);
148 
149  if (ret == QDialog::Accepted)
150  {
151  _lineEditNomSpectreTransm->setText(getElement()->getSpectreTransm().getName());
152  }
153 }
154 
156 {
157  int ret = getElement()->getSpectreAbso().edit(this);
158 
159  if (ret == QDialog::Accepted)
160  {
161  _lineEditNomSpectreAbs->setText(getElement()->getSpectreAbso().getName());
162  }
163 }
164 
166 {
167  QString fileName = QFileDialog::getOpenFileName(this, "", "", "XML (*.xml)");
168 
169  if (!fileName.isEmpty())
170  {
171  TYXMLManager xmlManager;
172  TYElement* pElt = NULL;
173  LPTYElementArray eltList;
174 
175  LPTYMateriauConstruction pMat = NULL;
176 
177  xmlManager.load(fileName, eltList);
178 
179  size_t count = eltList.size();
180  for (size_t i = 0; i < count; i++)
181  {
182  pElt = eltList.at(i);
183 
184  if ((pElt != NULL) && (pElt->isA("TYMateriauConstruction")))
185  {
186  pMat = (TYMateriauConstruction*)pElt;
187 
188  if (pMat != NULL)
189  {
190  (*getElement()) = (*pMat);
191  updateContent();
192  }
193  }
194  }
195 
196  pElt = NULL;
197  }
198 }
outil IHM pour un element (fichier header)
std::vector< LPTYElement > LPTYElementArray
Definition: TYElement.h:344
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)