Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYBoundaryNoiseMapWidget.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 <limits>
22 
23 // Added by qt3to4:
24 #include <QGridLayout>
25 #include <QLabel>
26 
32 
33 #define TR(id) OLocalizator::getString("TYBoundaryNoiseMapWidget", (id))
34 
35 #undef min
36 #undef max
37 
39  : TYWidget(pElement, _pParent)
40 {
41 
42  _maillageW = new TYMaillageWidget(pElement, this);
43 
44  resize(300, 200);
45  setWindowTitle(TR("id_caption"));
46  QGridLayout* pBoundaryNoiseMapLayout = new QGridLayout();
47  setLayout(pBoundaryNoiseMapLayout);
48 
49  pBoundaryNoiseMapLayout->addWidget(_maillageW, 0, 0);
50 
51  QGroupBox* pGroupBox = new QGroupBox(this);
52  QGridLayout* pGroupBoxLayout = new QGridLayout();
53  pGroupBox->setLayout(pGroupBoxLayout);
54 
55  // Thickness
56  _pThicknessSpinBox = new QDoubleSpinBox(pGroupBox);
57  _pThicknessSpinBox->setRange(0.1, std::numeric_limits<double>::max());
58  _pThicknessSpinBox->setCorrectionMode(QAbstractSpinBox::CorrectToNearestValue);
59  pGroupBoxLayout->addWidget(new QLabel(TR("id_thickness"), pGroupBox), 0, 0);
60  pGroupBoxLayout->addWidget(_pThicknessSpinBox, 0, 1);
61 
62  // Closed or open polyline
63  _pClosedCheckBox = new QCheckBox(pGroupBox);
64  if (!pElement->getCanBeClosed())
65  {
66  _pClosedCheckBox->setDisabled(true);
67  }
68  pGroupBoxLayout->addWidget(new QLabel(TR("id_closed"), pGroupBox), 1, 0);
69  pGroupBoxLayout->addWidget(_pClosedCheckBox, 1, 1);
70 
71  // Density
72  _pDensitySpinBox = new QDoubleSpinBox(pGroupBox);
73  _pDensitySpinBox->setSingleStep(0.1);
74  _pDensitySpinBox->setCorrectionMode(QAbstractSpinBox::CorrectToNearestValue);
75  pGroupBoxLayout->addWidget(new QLabel(TR("id_density"), pGroupBox), 2, 0);
76  pGroupBoxLayout->addWidget(_pDensitySpinBox, 2, 1);
77  pGroupBoxLayout->addWidget(new QLabel(TR("id_density_unit"), pGroupBox), 2, 2);
78 
79  // The minimum value of thickness and density will be set automatically, because
80  // the signal valueChanged() will be triggered by the setValue() functions in updateContent()
81  // (that's why we don't use valueEdited() that only works with user input)
82  void (QDoubleSpinBox::*qDoubleSpinBox_valueChanged)(double) = &QDoubleSpinBox::valueChanged;
83  QObject::connect(_pThicknessSpinBox, qDoubleSpinBox_valueChanged, this,
85 
86  pBoundaryNoiseMapLayout->addWidget(pGroupBox, 1, 0);
87 
88  updateContent();
89 }
90 
92 
94 {
96 
97  _pThicknessSpinBox->setValue(getElement()->getThickness());
98  _pClosedCheckBox->setChecked(getElement()->isClosed());
99  _pDensitySpinBox->setValue(getElement()->getDensity());
100 }
101 
103 {
104  _maillageW->apply();
105 
106  double thickness = _pThicknessSpinBox->value();
107  bool closed = _pClosedCheckBox->isChecked();
108  double density = _pDensitySpinBox->value();
109 
110  // If something changed
111  if (getElement()->getThickness() != thickness || getElement()->isClosed() != closed ||
112  getElement()->getDensity() != density)
113  {
114  getElement()->make(getElement()->getTabPoint(), thickness, closed, density);
115  dynamic_cast<TYProjet*>(getElement()->getParent())->updateCalculsWithMaillage(getElement());
116 
117  // La densite a changee, il faut mettre a jour l'altimetrie
118  LPTYProjet pProj = dynamic_cast<TYProjet*>(getElement()->getParent());
119  if (pProj && pProj->getSite()->getAltimetry()->containsData())
120  {
121  pProj->updateAltiRecepteurs();
122  }
123  }
124 
125  emit modified();
126 }
127 
129 {
131  std::numeric_limits<double>::max());
132 }
#define TR(id)
BoundaryNoiseMap widget (header file)
Outil IHM pour un maillage (fichier header)
bool containsData()
Definition: TYAltimetrie.h:237
void updateMinimumDensity(double thickness)
Update the minimum value of the density thanks to the new thickness value.
QDoubleSpinBox * _pDensitySpinBox
Density spin box.
TYBoundaryNoiseMapWidget(TYBoundaryNoiseMap *pElement, QWidget *_pParent=NULL)
virtual void apply()
When the user validate the dialog window (press ok).
TYMaillageWidget * _maillageW
The maillage widget.
virtual void updateContent()
Update the content of the widgets by reading the stuffs in pElement.
QDoubleSpinBox * _pThicknessSpinBox
Density spin box.
QCheckBox * _pClosedCheckBox
Closed check box (if the polyline is closed or pen).
This class represents a polyline with a thickness. Acoustic receptors are sampled inside this region.
static double computeMinimumDensity(double thickness)
Return the minimum density to get a correct sampling.
bool getCanBeClosed() const
Getter of _canBeClosed.
classe de l'objet IHM pour un maillage
virtual void updateContent()
virtual void apply()
classe de definition d'un projet.
Definition: TYProjet.h:45
bool updateAltiRecepteurs()
Definition: TYProjet.cpp:599
LPTYSiteNode getSite()
Get du site.
Definition: TYProjet.h:169
LPTYAltimetrie getAltimetry() const
classe de l'objet IHM pour un objet metier de type TYElement
Definition: TYWidget.h:43
void modified()