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