Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYVegetationWidget.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 
26 #include <QGridLayout>
27 #include <QLabel>
28 #include <qcheckbox.h>
29 #include <qcombobox.h>
30 
31 #include "TYVegetationWidget.h"
32 
33 #define TR(id) OLocalizator::getString("TYVegetationWidget", (id))
34 
35 TYVegetationWidget::TYVegetationWidget(TYVegetation* pElement, QWidget* _pParent /*=NULL*/)
36  : TYWidget(pElement, _pParent)
37 {
38  QString num;
39 
40  resize(300, 200);
41  setWindowTitle(TR("id_caption"));
42  _vegetationLayout = new QGridLayout();
43  setLayout(_vegetationLayout);
44 
45  // _elmW = new TYElementWidget(pElement, this);
46 
47  _comboBoxSelectVegeName = new QComboBox(this);
48  _comboBoxSelectVegeName->setEditable(true);
49 
51 
52  _groupBox = new QGroupBox(this);
53  _groupBox->setTitle(TR(""));
54  _groupBoxLayout = new QGridLayout();
55  _groupBox->setLayout(_groupBoxLayout);
56 
57  // Gestion du feuillage
58  _labelFoliageActive = new QLabel(_groupBox);
59  _labelFoliageActive->setText(TR("id_foliageactivelabel_label"));
60  _groupBoxLayout->addWidget(_labelFoliageActive, 0, 0);
61  _checkBoxFoliageActive = new QCheckBox(_groupBox);
62  _groupBoxLayout->addWidget(_checkBoxFoliageActive, 0, 1);
63 
64  // Hauteur de la hauteur de la végétation
65  _labelHauteur = new QLabel(_groupBox);
66  _labelHauteur->setText(TR("id_hauteur_label"));
67  _groupBoxLayout->addWidget(_labelHauteur, 1, 0);
68 
70  _groupBoxLayout->addWidget(_lineEditHauteur, 1, 1);
71  QLabel* pUnitHauteur = new QLabel(_groupBox);
72  pUnitHauteur->setText(TR("id_unite_hauteur"));
73  _groupBoxLayout->addWidget(pUnitHauteur, 1, 2);
74 
75  _vegetationLayout->addWidget(_groupBox, 1, 0);
76 
77  _groupBoxSpectreAtt = new QGroupBox(this);
78  _groupBoxSpectreAtt->setTitle(TR("id_spectreatt"));
79  _groupBoxSpectreAttLayout = new QGridLayout();
81 
84 
85  _pushButtonSpectreAtt = new QPushButton(_groupBoxSpectreAtt);
86  _pushButtonSpectreAtt->setText(TR("id_proprietes_button"));
88 
89  _vegetationLayout->addWidget(_groupBoxSpectreAtt, 2, 0);
90 
91  connect(_pushButtonSpectreAtt, &QPushButton::clicked, this, &TYVegetationWidget::editSpectre);
92 }
93 
95 
97 {
98  if (getElement())
99  {
100  // _elmW->updateContent();
101 
102  updateComboVegetation(); // Remplit le combobox
103 
104  _checkBoxFoliageActive->setChecked(getElement()->getFoliageStatus());
105  _lineEditHauteur->setText(QString().setNum(getElement()->getHauteur(), 'f', 2));
106  _lineEditNomSpectreAtt->setText(getElement()->getSpectreAtt()->getName());
107  }
108 }
109 
111 {
112  if (getElement())
113  {
114  // _elmW->apply();
115 
116  getElement()->setName(_comboBoxSelectVegeName->itemText(_comboBoxSelectVegeName->currentIndex()));
117  getElement()->setFoliageStatus(_checkBoxFoliageActive->isChecked());
118  getElement()->setHauteur(_lineEditHauteur->text().toDouble());
119 
120  emit modified();
121  }
122 }
123 
125 {
126  int ret = getElement()->getSpectreAtt()->edit(this);
127 
128  if (ret == QDialog::Accepted)
129  {
130  _lineEditNomSpectreAtt->setText(getElement()->getSpectreAtt()->getName());
131  }
132 }
133 
135 {
136  _comboBoxSelectVegeName->clear();
137  for (unsigned int i = 0; i < 5; i++)
138  {
140  }
141 
142  _comboBoxSelectVegeName->setCurrentIndex(TYVegetation::getIndexVegetation(getElement()->getName()));
143 }
outil IHM pour une entrée utilisateur (fichier header)
#define TR(id)
outil IHM pour une vegetation (fichier header)
QCheckBox * _checkBoxFoliageActive
QGridLayout * _groupBoxLayout
QComboBox * _comboBoxSelectVegeName
TYVegetationWidget(TYVegetation *pElement, QWidget *_pParent=NULL)
virtual void updateContent()
TYLineEdit * _lineEditHauteur
QGroupBox * _groupBoxSpectreAtt
QLineEdit * _lineEditNomSpectreAtt
QPushButton * _pushButtonSpectreAtt
QGridLayout * _groupBoxSpectreAttLayout
QGridLayout * _vegetationLayout
static QString _vegeName[]
Definition: TYVegetation.h:119
static unsigned int getIndexVegetation(const QString &vegeName)
classe de l'objet IHM pour un objet metier de type TYElement
Definition: TYWidget.h:43
void modified()