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