Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYLinearMaillageWidget.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 #include <QLabel>
24 
30 #include "TYLinearMaillageWidget.h"
31 
32 #define TR(id) OLocalizator::getString("TYLinearMaillageWidget", (id))
33 
35  : TYWidget(pElement, _pParent)
36 {
37 
38  _maillageW = new TYMaillageWidget(pElement, this);
39 
40  resize(300, 200);
41  setWindowTitle(TR("id_caption"));
42  QGridLayout* pLinearMaillageLayout = new QGridLayout();
43  setLayout(pLinearMaillageLayout);
44 
45  pLinearMaillageLayout->addWidget(_maillageW, 0, 0);
46 
47  QGroupBox* pGroupBox = new QGroupBox(this);
48  QGridLayout* pGroupBoxLayout = new QGridLayout();
49  pGroupBox->setLayout(pGroupBoxLayout);
50 
51  QLabel* pLabelDensite = new QLabel(TR("id_densite"), pGroupBox);
52  _lineEditDensite = new TYLineEdit(pGroupBox);
53  QObject::connect(_lineEditDensite, &QLineEdit::textChanged, this,
55  QLabel* pLabelDensiteUnite = new QLabel(TR("id_densite_unit"), pGroupBox);
56  pGroupBoxLayout->addWidget(pLabelDensite, 0, 0);
57  pGroupBoxLayout->addWidget(_lineEditDensite, 0, 1);
58  pGroupBoxLayout->addWidget(pLabelDensiteUnite, 0, 2);
59 
60  pLinearMaillageLayout->addWidget(pGroupBox, 1, 0);
61 
62  QGroupBox* pGroupBoxSegment = new QGroupBox(this);
63  pGroupBoxSegment->setTitle(TR("id_segment"));
64  QGridLayout* pGroupBoxSegmentLayout = new QGridLayout();
65  pGroupBoxSegment->setLayout(pGroupBoxSegmentLayout);
66 
67  _lineEditNomSegment = new QLineEdit(pGroupBoxSegment);
68  _lineEditNomSegment->setEnabled(false);
69  pGroupBoxSegmentLayout->addWidget(_lineEditNomSegment, 0, 0);
70 
71  QLabel* pLongueurLabel = new QLabel(TR("id_longueur"), pGroupBoxSegment);
72  pGroupBoxSegmentLayout->addWidget(pLongueurLabel, 0, 1);
73  _lineEditLongueur = new TYLineEdit(pGroupBoxSegment);
74  _lineEditLongueur->setReadOnly(true);
75  pGroupBoxSegmentLayout->addWidget(_lineEditLongueur, 0, 2);
76 
77  QPushButton* pPushButtonSegment = new QPushButton(TR("id_proprietes_button"), pGroupBoxSegment);
78  pGroupBoxSegmentLayout->addWidget(pPushButtonSegment, 0, 3);
79 
80  pLinearMaillageLayout->addWidget(pGroupBoxSegment, 2, 0);
81 
82  updateContent();
83 
84  connect(pPushButtonSegment, &QPushButton::clicked, this, &TYLinearMaillageWidget::editSegment);
85 }
86 
88 
90 {
92 
93  if (getElement()->getSegment())
94  {
95  _lineEditNomSegment->setText(getElement()->getSegment()->getName());
96  _lineEditLongueur->setText(QString().setNum(getElement()->getSegment()->longueur(), 'f', 2));
97  }
98 
99  _lineEditDensite->setText(QString().setNum(getElement()->getDensite(), 'f', 2));
100 }
101 
103 {
104  double longueur = _lineEditLongueur->text().toDouble();
105  double densite = _lineEditDensite->text().toDouble();
106 
107  _maillageW->updateNbPoints(longueur * densite);
108 }
109 
111 {
112  _maillageW->apply();
113 
114  // Si la densite est differente
115  if ((getElement()->getDensite() != _lineEditDensite->text().toDouble()) && getElement()->getSegment())
116  {
117  getElement()->make(getElement()->getSegment(), _lineEditDensite->text().toDouble());
118  dynamic_cast<TYProjet*>(getElement()->getParent())->updateCalculsWithMaillage(getElement());
119 
120  // La densite a changee, il faut mettre a jour l'altimetrie
121  LPTYProjet pProj = dynamic_cast<TYProjet*>(getElement()->getParent());
122  if (pProj && pProj->getSite()->getAltimetry()->containsData())
123  {
124  pProj->updateAltiRecepteurs();
125  }
126  }
127 
128  emit modified();
129 }
130 
132 {
133  int ret = getElement()->getSegment()->edit(this);
134 
135  if (ret == QDialog::Accepted)
136  {
137  _lineEditNomSegment->setText(getElement()->getSegment()->getName());
138  }
139 }
outil IHM pour une entrée utilisateur (fichier header)
#define TR(id)
Outil IHM pour un maillage lineaire (fichier header)
Outil IHM pour un maillage (fichier header)
bool containsData()
Definition: TYAltimetrie.h:237
TYLinearMaillageWidget(TYLinearMaillage *pElement, QWidget *_pParent=NULL)
TYMaillageWidget * _maillageW
Classe de definition d'un maillage lineaire.
classe de l'objet IHM pour un maillage
virtual void updateContent()
void updateNbPoints(unsigned int nbPts)
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()