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