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