Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYAcousticVolumeWidget.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 // Added by qt3to4:
22 #include <QGridLayout>
23 #include <QtWidgets>
24 
30 #include "TYAcousticVolumeWidget.h"
31 #include "TYElementWidget.h"
32 
33 #define TR(id) OLocalizator::getString("TYAcousticVolumeWidget", (id))
34 
36  : TYWidget(pElement, _pParent), _isColorModified(false)
37 {
38 
39  resize(300, 425);
40  setWindowTitle(TR("id_caption"));
41  _acousticVolumeLayout = new QGridLayout();
42  setLayout(_acousticVolumeLayout);
43 
44  _elmW = new TYElementWidget(pElement, this);
45  _colorW = new TYColorInterfaceWidget(dynamic_cast<TYColorInterface*>(pElement), this);
46  _interW = new TYAcousticInterfaceWidget(dynamic_cast<TYAcousticInterface*>(pElement), this);
47 
48  unsigned int iln = 0;
49 
50  _acousticVolumeLayout->addWidget(_elmW, iln, 0);
51  _acousticVolumeLayout->addWidget(_colorW, ++iln, 0);
52  _acousticVolumeLayout->addWidget(_interW, ++iln, 0);
53 
54  _groupBoxMat = new QGroupBox(this);
55 
56  if (_pElement->getParent() != NULL)
57  {
58  if (_pElement->getParent()->isA("TYMachine"))
59  {
60  _groupBoxMat->setTitle(TR("id_mat"));
61  }
62  else // _pParent->isA("TYBatiment");
63  {
64  _groupBoxMat->setTitle(TR("id_paroi"));
65  }
66  }
67  else // _pParent != NULL
68  {
69  _groupBoxMat->setTitle(TR("id_paroi"));
70  }
71 
72  _groupBoxMatLayout = new QGridLayout();
73  _groupBoxMat->setLayout(_groupBoxMatLayout);
74 
75  _lineEditNomMat = new QLineEdit(_groupBoxMat);
76  _lineEditNomMat->setEnabled(false);
77  _groupBoxMatLayout->addWidget(_lineEditNomMat, 0, 0);
78 
79  _pushButtonMat = new QPushButton(_groupBoxMat);
80  _pushButtonMat->setText(TR("id_proprietes_button"));
81  _groupBoxMatLayout->addWidget(_pushButtonMat, 0, 1);
82 
83  if (getElement()->getMateriau() != NULL)
84  {
85  _lineEditNomMat->setText(getElement()->getMateriau()->getName());
86  }
87  else
88  {
89  _groupBoxMat->setEnabled(false);
90  }
91 
92  _acousticVolumeLayout->addWidget(_groupBoxMat, ++iln, 0);
93 
95  connect(_pushButtonMat, &QPushButton::clicked, this, &TYAcousticVolumeWidget::editMat);
96 }
97 
99 
101 {
102  _elmW->updateContent();
105 }
106 
108 {
109  _elmW->apply();
110  _colorW->apply();
111 
112  if (_isColorModified)
113  {
114  TYTabAcousticSurfaceGeoNode tab = getElement()->acousticFaces();
115  for (unsigned int i = 0; i < tab.size(); ++i)
116  {
117  LPTYAcousticSurface pAccSurf = TYAcousticSurface::safeDownCast(tab[i]->getElement());
118  if (!pAccSurf->getIsSub())
119  {
120  pAccSurf->setColor(getElement()->getColor());
121  }
122  }
123 
124  _isColorModified = false;
125  }
126 
127  _interW->apply();
128 
130 
131  emit modified();
132 }
133 
135 {
136  _isColorModified = false;
137 
138  // Si l'utilisateur annule, on restitue l'etat du regime courant
139  // getElement()->setCurRegime(getElement()->getCurRegime());
140 }
141 
143 {
144  if ((_pElement->getParent()->isA("TYMachine")) ||
145  (dynamic_cast<TYAcousticCylinder*>(_pElement) != nullptr))
146  {
147  int ret = getElement()->getMateriau()->edit(this);
148 
149  if ((ret == QDialog::Accepted) && (getElement()->getMateriau() != NULL))
150  {
151  _lineEditNomMat->setText(getElement()->getMateriau()->getName());
152  }
153  }
154  else // _pElement->getParent()->isA("TYBatiment")
155  {
156  int ret = TYEtage::safeDownCast(_pElement)->getParoi()->edit(this);
157 
158  if ((ret == QDialog::Accepted) && (TYEtage::safeDownCast(_pElement)->getParoi() != NULL))
159  {
160  _lineEditNomMat->setText(TYEtage::safeDownCast(_pElement)->getParoi()->getName());
161 
162  TYEtage::safeDownCast(_pElement)->updateParoi();
163  } //*/
164  }
165 }
166 
168 {
169  _isColorModified = true;
170 
171  emit colorModified();
172 }
QColor getColor
Outil IHM pour une interface acoustique (fichier header)
std::vector< LPTYAcousticSurfaceGeoNode > TYTabAcousticSurfaceGeoNode
Collection de noeuds geometriques de type TYAcousticSurface.
#define TR(id)
outil IHM pour un volume acoustique (fichier header)
outil IHM pour l'objet ColorInterface (fichier header)
outil IHM pour un element (fichier header)
static OPrototype * safeDownCast(OPrototype *pObject)
Definition: TYElement.cpp:71
bool isA(const char *className) const
Definition: TYElement.cpp:65
classe de l'objet IHM pour une interface acoustique
TYColorInterfaceWidget * _colorW
TYAcousticVolumeWidget(TYAcousticVolume *pElement, QWidget *_pParent=NULL)
TYAcousticInterfaceWidget * _interW
classe de l'objet IHM pour l'objet ColorInterface
virtual void setColor(const OColor &color)
classe de l'objet IHM pour un element
virtual void apply()
virtual void updateContent()
TYElement * getParent() const
Definition: TYElement.h:706
virtual void setIsAcousticModified(bool isModified)
Definition: TYElement.cpp:248
classe de l'objet IHM pour un objet metier de type TYElement
Definition: TYWidget.h:43
TYElement * _pElement
Definition: TYWidget.h:114
void modified()