Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYTerrainWidget.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 <qlayout.h>
22 #include <QLabel>
23 #include <qcheckbox.h>
24 #include <QTreeWidget>
25 #include <QTreeWidgetItem>
26 #include <QtWidgets>
27 
33 #include "TabPointsWidget.h"
34 #include "TYVegetationWidget.h"
35 #include "TYTerrainWidget.h"
36 #include "TYElementWidget.h"
37 
38 #define TR(id) OLocalizator::getString("TYTerrainWidget", (id))
39 
40 TYTerrainWidget::TYTerrainWidget(TYTerrain* pElement, QWidget* _pParent /*=NULL*/)
41  : TYWidget(pElement, _pParent), _pVegetation(nullptr)
42 {
43  unsigned short lnW = 0;
44 
45  _elmW = new TYElementWidget(pElement, this);
46  _colorW = new TYColorInterfaceWidget(pElement, this);
47 
48  resize(300, 330);
49  setWindowTitle(TR("id_caption"));
50  _terrainLayout = new QGridLayout();
51  setLayout(_terrainLayout);
52 
53  _terrainLayout->addWidget(_elmW, lnW++, 0);
54  _terrainLayout->addWidget(_colorW, lnW++, 0);
55 
56  _groupBox = new QGroupBox(this);
57  _groupBox->setTitle(TR(""));
58  _groupBoxLayout = new QGridLayout();
59  _groupBox->setLayout(_groupBoxLayout);
60  _labelVegetActive = new QLabel(_groupBox);
61  _labelVegetActive->setText(TR("id_vegetactive_label"));
62  _groupBoxLayout->addWidget(_labelVegetActive, 0, 0);
63  _checkBoxVegetActive = new QCheckBox(_groupBox);
64  _groupBoxLayout->addWidget(_checkBoxVegetActive, 0, 1);
65 
66  _terrainLayout->addWidget(_groupBox, lnW++, 0);
67 
68  _tabWidget = new QTabWidget(this);
69 
70  _solW = new TYSolWidget(getElement()->getSol(), _tabWidget);
71  _tabWidget->insertTab(1, _solW, TR("id_sol"));
72 
73  _pVegetation = getElement()->getVegetation();
75 
76  _tabWidget->insertTab(2, _vegetationWidget, TR("id_vegetation"));
77 
78  _groupBox = new QGroupBox(_tabWidget);
79  _groupBox->setTitle(TR("id_pts"));
80  _groupBoxLayout = new QGridLayout();
81  _groupBox->setLayout(_groupBoxLayout);
82 
84  _tabPoints->setEnabled(true);
85 
86  _groupBoxLayout->addWidget(_tabPoints, 0, 0);
87 
88  _tabWidget->insertTab(3, _groupBox, TR("id_geometrie"));
89 
90  _terrainLayout->addWidget(_tabWidget, lnW++, 0);
91 
92  connect(_checkBoxVegetActive, &QPushButton::clicked, this, &TYTerrainWidget::useVegetation);
93 
94  updateContent();
95 }
96 
98 
100 {
101  QString num;
102 
103  _elmW->updateContent();
105  _solW->updateContent();
106 
107  bool bVegActive = getElement()->isUsingVegetation();
108  _checkBoxVegetActive->setChecked(bVegActive);
109  _vegetationWidget->setEnabled(bVegActive);
111 
112  _tabPoints->update();
113 }
114 
116 {
117  _elmW->apply();
118  _colorW->apply();
119  _solW->apply();
121 
122  getElement()->setVegetation(_pVegetation);
123 
124  _tabPoints->apply();
125 
126  emit modified();
127 }
128 
130 {
131  _tabWidget->removeTab(0);
132 }
133 
135 {
136  // Efface le widget d'activation de la vegatation
137  _checkBoxVegetActive->setEnabled(false);
138  _tabWidget->removeTab(0);
139 }
140 
142 {
143  if (_checkBoxVegetActive->isChecked())
144  {
145  _pVegetation = getElement()->getVegetation();
146 
147  // If no vegetation create it
148  if (_pVegetation == nullptr)
149  {
150  _pVegetation = new TYVegetation();
151  }
152  }
153  else
154  {
155  _pVegetation = nullptr;
156  }
157 
160  _vegetationWidget->setEnabled(_checkBoxVegetActive->isChecked());
161 }
outil IHM pour l'objet ColorInterface (fichier header)
outil IHM pour un element (fichier header)
outil IHM pour un sol (fichier header)
#define TR(id)
outil IHM pour un terrain (fichier header)
outil IHM pour une vegetation (fichier header)
classe de l'objet IHM pour l'objet ColorInterface
classe de l'objet IHM pour un element
virtual void apply()
virtual void updateContent()
classe de l'objet IHM pour un sol
Definition: TYSolWidget.h:43
virtual void apply()
virtual void updateContent()
TYSolWidget * _solW
QGridLayout * _terrainLayout
TabPointsWidget * _tabPoints
TYVegetationWidget * _vegetationWidget
QCheckBox * _checkBoxVegetActive
QGridLayout * _groupBoxLayout
QTabWidget * _tabWidget
TYElementWidget * _elmW
TYColorInterfaceWidget * _colorW
virtual void apply()
QGroupBox * _groupBox
virtual ~TYTerrainWidget()
TYTerrainWidget(TYTerrain *pElement, QWidget *_pParent=NULL)
virtual void updateContent()
LPTYVegetation _pVegetation
void disableVegetationWidget()
QLabel * _labelVegetActive
virtual TYTabPoint & getListPoints()
Definition: TYTerrain.h:131
classe de l'objet IHM pour une vegetation
virtual void updateContent()
classe de l'objet IHM pour un objet metier de type TYElement
Definition: TYWidget.h:43
void setElement(TYElement *pElement)
Definition: TYWidget.h:82
void modified()
virtual void apply()
virtual void update()