Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYEcranWidget.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 #include <math.h>
22 #include <qradiobutton.h>
23 #include <qbuttongroup.h>
24 // Added by qt3to4:
25 #include <QGridLayout>
26 #include <QtWidgets>
27 
32 #include "TYEcranWidget.h"
33 
34 #define TR(id) OLocalizator::getString("TYEcranWidget", (id))
35 
36 TYEcranWidget::TYEcranWidget(TYEcran* pElement, QWidget* _pParent /*=NULL*/) : TYWidget(pElement, _pParent)
37 {
38 
39  _elmW = new TYAcousticFaceSetWidget(pElement, this);
40 
41  resize(300, 810);
42  setWindowTitle(TR("id_caption"));
43  _ecranLayout = new QGridLayout();
44  setLayout(_ecranLayout);
45 
46  _ecranLayout->addWidget(_elmW, 0, 0);
47 
48  // Parametre hauteur et epaisseur...
49  _widgetProp = new QWidget(this);
50  QGridLayout* _groupBoxPropLayout = new QGridLayout();
51  _widgetProp->setLayout(_groupBoxPropLayout);
52 
53  _groupBoxHauteur = new QGroupBox(_widgetProp);
54  _groupBoxHauteur->setTitle(TR("id_hauteur_label"));
55  _groupBoxHauteurLayout = new QGridLayout();
57 
58  _groupBoxEpaisseur = new QGroupBox(_widgetProp);
59  _groupBoxEpaisseur->setTitle(TR("id_epaisseur_label"));
60  _groupBoxEpaisseurLayout = new QGridLayout();
62 
63  // Presentation du volume
64  _lineEditHauteur = new TYLineEdit(QString(), false, false, _groupBoxHauteur);
65  _lineEditHauteur->setEnabled(true);
66  _groupBoxHauteurLayout->addWidget(_lineEditHauteur, 0, 0);
67 
68  // Presentation de la surface
69  _lineEditEpaisseur = new TYLineEdit(QString(), false, false, _groupBoxEpaisseur);
70  _lineEditEpaisseur->setEnabled(true);
72 
73  // Insertion dans la boite de dialogue
74  _groupBoxPropLayout->addWidget(_groupBoxHauteur, 0, 0);
75  _groupBoxPropLayout->addWidget(_groupBoxEpaisseur, 0, 1);
76 
77  _ecranLayout->addWidget(_widgetProp, 1, 0);
78 
79  updateContent();
80 }
81 
83 
85 {
87 
88  _lineEditHauteur->setText(QString().setNum(((TYEcran*)getElement())->getHauteur()));
89  _lineEditEpaisseur->setText(QString().setNum(((TYEcran*)getElement())->getEpaisseur()));
90 }
91 
93 {
94  _elmW->apply();
95 
96  float hauteur = NAN, epaisseur = NAN;
97  float new_hauteur = NAN, new_epaisseur = NAN;
98 
99  hauteur = ((TYEcran*)getElement())->getHauteur();
100  epaisseur = ((TYEcran*)getElement())->getEpaisseur();
101 
102  QString strHauteur = _lineEditHauteur->text();
103  QString strEpaisseur = _lineEditEpaisseur->text();
104  bool bOk = false;
105 
106  new_hauteur = strHauteur.toFloat(&bOk);
107  if (bOk && (new_hauteur != hauteur))
108  {
109  ((TYEcran*)getElement())->setHauteur(new_hauteur);
110  }
111 
112  new_epaisseur = strEpaisseur.toFloat(&bOk);
113  if (bOk && (new_epaisseur != epaisseur))
114  {
115  ((TYEcran*)getElement())->setEpaisseur(new_epaisseur);
116  }
117 
118  ((TYEcran*)getElement())
119  ->updateGeometry(); // update geometry to take in account changes in height or width...
120 
121  emit modified();
122 }
#define TR(id)
Outil IHM pour un ecran (fichier header)
outil IHM pour une entrée utilisateur (fichier header)
classe d'un objet IHM pour un ensemble de faces acoustiques
virtual void apply()
TYEcranWidget(TYEcran *pElement, QWidget *_pParent=NULL)
QGridLayout * _groupBoxEpaisseurLayout
Definition: TYEcranWidget.h:77
TYAcousticFaceSetWidget * _elmW
Definition: TYEcranWidget.h:70
QGroupBox * _groupBoxEpaisseur
Definition: TYEcranWidget.h:74
QWidget * _widgetProp
Definition: TYEcranWidget.h:72
QGridLayout * _groupBoxHauteurLayout
Definition: TYEcranWidget.h:76
QGroupBox * _groupBoxHauteur
Definition: TYEcranWidget.h:73
virtual ~TYEcranWidget()
TYLineEdit * _lineEditEpaisseur
Definition: TYEcranWidget.h:80
QGridLayout * _ecranLayout
Definition: TYEcranWidget.h:68
QGridLayout * _groupBoxPropLayout
Definition: TYEcranWidget.h:75
TYLineEdit * _lineEditHauteur
Definition: TYEcranWidget.h:79
virtual void updateContent()
classe de l'objet IHM pour un objet metier de type TYElement
Definition: TYWidget.h:43
void modified()