Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYAcousticVolumeWidget.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 // Added by qt3to4:
22 #include <QGridLayout>
23 
29 #include "TYAcousticVolumeWidget.h"
30 
31 #define TR(id) OLocalizator::getString("TYAcousticVolumeWidget", (id))
32 
34  : TYWidget(pElement, _pParent), _isColorModified(false)
35 {
36 
37  resize(300, 425);
38  setWindowTitle(TR("id_caption"));
39  _acousticVolumeLayout = new QGridLayout();
40  setLayout(_acousticVolumeLayout);
41 
42  _elmW = new TYElementWidget(pElement, this);
43  _colorW = new TYColorInterfaceWidget(dynamic_cast<TYColorInterface*>(pElement), this);
44  _interW = new TYAcousticInterfaceWidget(dynamic_cast<TYAcousticInterface*>(pElement), this);
45 
46  unsigned int iln = 0;
47 
48  _acousticVolumeLayout->addWidget(_elmW, iln, 0);
49  _acousticVolumeLayout->addWidget(_colorW, ++iln, 0);
50  _acousticVolumeLayout->addWidget(_interW, ++iln, 0);
51 
52  _groupBoxMat = new QGroupBox(this);
53 
54  if (_pElement->getParent() != NULL)
55  {
56  if (_pElement->getParent()->isA("TYMachine"))
57  {
58  _groupBoxMat->setTitle(TR("id_mat"));
59  }
60  else // _pParent->isA("TYBatiment");
61  {
62  _groupBoxMat->setTitle(TR("id_paroi"));
63  }
64  }
65  else // _pParent != NULL
66  {
67  _groupBoxMat->setTitle(TR("id_paroi"));
68  }
69 
70  _groupBoxMatLayout = new QGridLayout();
71  _groupBoxMat->setLayout(_groupBoxMatLayout);
72 
73  _lineEditNomMat = new QLineEdit(_groupBoxMat);
74  _lineEditNomMat->setEnabled(false);
75  _groupBoxMatLayout->addWidget(_lineEditNomMat, 0, 0);
76 
77  _pushButtonMat = new QPushButton(_groupBoxMat);
78  _pushButtonMat->setText(TR("id_proprietes_button"));
79  _groupBoxMatLayout->addWidget(_pushButtonMat, 0, 1);
80 
81  if (getElement()->getMateriau() != NULL)
82  {
83  _lineEditNomMat->setText(getElement()->getMateriau()->getName());
84  }
85  else
86  {
87  _groupBoxMat->setEnabled(false);
88  }
89 
90  _acousticVolumeLayout->addWidget(_groupBoxMat, ++iln, 0);
91 
93  connect(_pushButtonMat, &QPushButton::clicked, this, &TYAcousticVolumeWidget::editMat);
94 }
95 
97 
99 {
100  _elmW->updateContent();
103 }
104 
106 {
107  _elmW->apply();
108  _colorW->apply();
109 
110  if (_isColorModified)
111  {
112  TYTabAcousticSurfaceGeoNode tab = getElement()->acousticFaces();
113  for (unsigned int i = 0; i < tab.size(); ++i)
114  {
115  LPTYAcousticSurface pAccSurf = TYAcousticSurface::safeDownCast(tab[i]->getElement());
116  if (!pAccSurf->getIsSub())
117  {
118  pAccSurf->setColor(getElement()->getColor());
119  }
120  }
121 
122  _isColorModified = false;
123  }
124 
125  _interW->apply();
126 
128 
129  emit modified();
130 }
131 
133 {
134  _isColorModified = false;
135 
136  // Si l'utilisateur annule, on restitue l'etat du regime courant
137  // getElement()->setCurRegime(getElement()->getCurRegime());
138 }
139 
141 {
142  if ((_pElement->getParent()->isA("TYMachine")) ||
143  (dynamic_cast<TYAcousticCylinder*>(_pElement) != nullptr))
144  {
145  int ret = getElement()->getMateriau()->edit(this);
146 
147  if ((ret == QDialog::Accepted) && (getElement()->getMateriau() != NULL))
148  {
149  _lineEditNomMat->setText(getElement()->getMateriau()->getName());
150  }
151  }
152  else // _pElement->getParent()->isA("TYBatiment")
153  {
154  int ret = TYEtage::safeDownCast(_pElement)->getParoi()->edit(this);
155 
156  if ((ret == QDialog::Accepted) && (TYEtage::safeDownCast(_pElement)->getParoi() != NULL))
157  {
158  _lineEditNomMat->setText(TYEtage::safeDownCast(_pElement)->getParoi()->getName());
159 
160  TYEtage::safeDownCast(_pElement)->updateParoi();
161  } //*/
162  }
163 }
164 
166 {
167  _isColorModified = true;
168 
169  emit colorModified();
170 }
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)
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:699
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()