Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYSolWidget.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 
21 // Added by qt3to4:
22 #include <QGridLayout>
23 #include <QLabel>
24 #include <QtWidgets>
25 
28 #include "TYSolWidget.h"
31 #include "TYElementWidget.h"
32 
33 #define TR(id) OLocalizator::getString("TYSolWidget", (id))
34 
35 TYSolWidget::TYSolWidget(TYSol* pElement, QWidget* _pParent /*=NULL*/) : TYWidget(pElement, _pParent)
36 {
37  _elmW = new TYElementWidget(pElement, this);
38 
39  resize(300, 300);
40  setWindowTitle(TR("id_caption"));
41  _solLayout = new QGridLayout();
42  setLayout(_solLayout);
43 
44  _solLayout->addWidget(_elmW, 0, 0);
45 
46  _groupBoxDefaultSolver = new QGroupBox(this);
47  _groupBoxDefaultSolver->setTitle("DefaultSolver");
48  _groupBoxDefaultSolverLayout = new QGridLayout();
50  _groupBoxDefaultSolverLayout->setColumnStretch(2, 1);
51 
52  _lineEditEpaisseur = new TYLineEdit(QString(), false, false, _groupBoxDefaultSolver);
54  QLabel* pUnitEpais = new QLabel(_groupBoxDefaultSolver);
55  pUnitEpais->setText(TR("id_unite_epaisseur"));
56  _groupBoxDefaultSolverLayout->addWidget(pUnitEpais, 1, 2);
57 
58  _lineEditResistivite = new TYLineEdit(QString(), false, false, _groupBoxDefaultSolver);
60  QLabel* pUnitResis = new QLabel(_groupBoxDefaultSolver);
61  pUnitResis->setText(TR("id_unite_resistivite"));
62  _groupBoxDefaultSolverLayout->addWidget(pUnitResis, 0, 2);
63 
66  QLabel* pUnitEcart = new QLabel(_groupBoxDefaultSolver);
67  pUnitEcart->setText(TR("id_unite_ecarttype"));
68  _lineEditEcartType->setEnabled(false);
69  _groupBoxDefaultSolverLayout->addWidget(pUnitEcart, 2, 2);
70 
71  _lineEditLongueur = new TYLineEdit(QString(), false, false, _groupBoxDefaultSolver);
73  QLabel* pUnitLong = new QLabel(_groupBoxDefaultSolver);
74  pUnitLong->setText(TR("id_unite_longueur"));
75  _lineEditLongueur->setEnabled(false);
76  _groupBoxDefaultSolverLayout->addWidget(pUnitLong, 3, 2);
77 
79  _pushButtonResistivite->setText(TR("id_edit_resistivite"));
81 
83  _labelEpaisseur->setText(TR("id_epaisseur_label"));
85 
87  _labelResistivite->setText(TR("id_resistivite_label"));
89 
91  _labelEcartType->setText(TR("id_ecarttype_label"));
93 
95  _labelLongueur->setText(TR("id_longueur_label"));
97 
98  _solLayout->addWidget(_groupBoxDefaultSolver, 1, 0);
99 
100  _groupBox9613Solver = new QGroupBox(this);
101  _groupBox9613Solver->setTitle("ISO 9613");
102  _groupBox9613SolverLayout = new QGridLayout();
104  _groupBox9613SolverLayout->setColumnStretch(2, 1);
105 
108  QLabel* pUnitG = new QLabel(_groupBox9613Solver);
109  pUnitG->setText("-");
110  _groupBox9613SolverLayout->addWidget(pUnitG, 0, 2);
111 
112  _labelFacteurG = new QLabel(_groupBox9613Solver);
113  _labelFacteurG->setText(TR("id_facteur_g_label"));
114  _labelFacteurG->setToolTip(TR("id_facteur_g_tooltip"));
115  _groupBox9613SolverLayout->addWidget(_labelFacteurG, 0, 0);
116 
117  _solLayout->addWidget(_groupBox9613Solver, 2, 0);
118 
119  connect(_pushButtonResistivite, &QPushButton::clicked, this, &TYSolWidget::editResistivite);
120 
121  updateContent();
122 }
123 
125 
127 {
128  QString num;
129 
130  _elmW->updateContent();
131 
132  _lineEditResistivite->setText(num.setNum(getElement()->getResistivite(), 'f', 2));
133  _lineEditEpaisseur->setText(num.setNum(getElement()->getEpaisseur(), 'f', 2));
134  _lineEditEcartType->setText(num.setNum(getElement()->getEcartType(), 'f', 2));
135  _lineEditLongueur->setText(num.setNum(getElement()->getLongueur(), 'f', 3));
136 
137  _lineEditFacteurG->setText(num.setNum(getElement()->getG(), 'f', 2));
138 }
139 
141 {
142  _elmW->apply();
143 
144  // On ne peut pas rentrer une resistivite <= 0 (mini 1 kRayl)
145  double resistivite = _lineEditResistivite->text().toDouble();
146  resistivite = resistivite <= 1.0 ? 1.0 : resistivite;
147  getElement()->setResistivite(resistivite);
148 
149  // On ne peut avoir une epaisseur <= 0 (mini 1 cm)
150  double epaisseur = _lineEditEpaisseur->text().toDouble();
151  epaisseur = epaisseur <= 0.01 ? 0.01 : epaisseur;
152  getElement()->setEpaisseur(epaisseur);
153 
154  double ecarttype = _lineEditEcartType->text().toDouble();
155  ecarttype = ecarttype < 0 ? 0 : ecarttype;
156  getElement()->setEcartType(ecarttype);
157 
158  double longueur = _lineEditLongueur->text().toDouble();
159  longueur = longueur <= 0 ? 0.0001 : longueur;
160  getElement()->setLongueur(longueur);
161 
162  // G factor must be between 0 and 1
163  double G = _lineEditFacteurG->text().toDouble();
164  G = G < 0.00 ? 0.00 : (G > 1.00 ? 1.00 : G);
165  getElement()->setG(G);
166 
167  emit modified();
168 }
169 
171 {
172  TYSolResistanceDialog* pDialog = new TYSolResistanceDialog(this, getElement()->getResistivite());
173 
174  int ret = pDialog->exec();
175 
176  if (ret == QDialog::Accepted)
177  {
178  // Mise a jour du widget associe a la resistivite
179  _lineEditResistivite->setText(QString().setNum(pDialog->getResistivite(), 'f', 2));
180  }
181 }
outil IHM pour un element (fichier header)
outil IHM pour une entrée utilisateur (fichier header)
Outil IHM pour la saisie de la resisitivite du sol (fichier header)
#define TR(id)
Definition: TYSolWidget.cpp:33
outil IHM pour un sol (fichier header)
classe de l'objet IHM pour un element
virtual void apply()
virtual void updateContent()
Objet IHM pour la saisie de la resisitivite du sol.
QGridLayout * _groupBoxDefaultSolverLayout
Definition: TYSolWidget.h:83
QLabel * _labelLongueur
Definition: TYSolWidget.h:76
QGridLayout * _solLayout
Definition: TYSolWidget.h:82
TYLineEdit * _lineEditResistivite
Definition: TYSolWidget.h:69
TYLineEdit * _lineEditLongueur
Definition: TYSolWidget.h:71
virtual void apply()
TYElementWidget * _elmW
Definition: TYSolWidget.h:86
void editResistivite()
TYLineEdit * _lineEditEcartType
Definition: TYSolWidget.h:70
virtual void updateContent()
QLabel * _labelResistivite
Definition: TYSolWidget.h:74
QGroupBox * _groupBoxDefaultSolver
Definition: TYSolWidget.h:66
QLabel * _labelEcartType
Definition: TYSolWidget.h:75
QGridLayout * _groupBox9613SolverLayout
Definition: TYSolWidget.h:84
QGroupBox * _groupBox9613Solver
Definition: TYSolWidget.h:67
QLabel * _labelEpaisseur
Definition: TYSolWidget.h:73
TYLineEdit * _lineEditEpaisseur
Definition: TYSolWidget.h:68
virtual ~TYSolWidget()
QLabel * _labelFacteurG
Definition: TYSolWidget.h:77
TYLineEdit * _lineEditFacteurG
Definition: TYSolWidget.h:72
TYSolWidget(TYSol *pElement, QWidget *_pParent=NULL)
Definition: TYSolWidget.cpp:35
QPushButton * _pushButtonResistivite
Definition: TYSolWidget.h:79
Definition: TYSol.h:25
classe de l'objet IHM pour un objet metier de type TYElement
Definition: TYWidget.h:43
void modified()