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