Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYLinearMaillageWidget.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 <QLabel>
24 #include <QtWidgets>
25 
31 #include "TYLinearMaillageWidget.h"
32 
33 #define TR(id) OLocalizator::getString("TYLinearMaillageWidget", (id))
34 
36  : TYWidget(pElement, _pParent)
37 {
38 
39  _maillageW = new TYMaillageWidget(pElement, this);
40 
41  resize(300, 200);
42  setWindowTitle(TR("id_caption"));
43  QGridLayout* pLinearMaillageLayout = new QGridLayout();
44  setLayout(pLinearMaillageLayout);
45 
46  pLinearMaillageLayout->addWidget(_maillageW, 0, 0);
47 
48  QGroupBox* pGroupBox = new QGroupBox(this);
49  QGridLayout* pGroupBoxLayout = new QGridLayout();
50  pGroupBox->setLayout(pGroupBoxLayout);
51 
52  QLabel* pLabelDistance = new QLabel(TR("id_distance"), pGroupBox);
53  _lineEditDistance = new TYLineEdit(pGroupBox);
54  QObject::connect(_lineEditDistance, &QLineEdit::textChanged, this,
56  QLabel* pLabelDistanceUnite = new QLabel(TR("id_distance_unit"), pGroupBox);
57  pGroupBoxLayout->addWidget(pLabelDistance, 0, 0);
58  pGroupBoxLayout->addWidget(_lineEditDistance, 0, 1);
59  pGroupBoxLayout->addWidget(pLabelDistanceUnite, 0, 2);
60 
61  pLinearMaillageLayout->addWidget(pGroupBox, 1, 0);
62 
63  QGroupBox* pGroupBoxSegment = new QGroupBox(this);
64  pGroupBoxSegment->setTitle(TR("id_segment"));
65  QGridLayout* pGroupBoxSegmentLayout = new QGridLayout();
66  pGroupBoxSegment->setLayout(pGroupBoxSegmentLayout);
67 
68  _lineEditNomSegment = new QLineEdit(pGroupBoxSegment);
69  _lineEditNomSegment->setEnabled(false);
70  pGroupBoxSegmentLayout->addWidget(_lineEditNomSegment, 0, 0);
71 
72  QLabel* pLongueurLabel = new QLabel(TR("id_longueur"), pGroupBoxSegment);
73  pGroupBoxSegmentLayout->addWidget(pLongueurLabel, 0, 1);
74  _lineEditLongueur = new TYLineEdit(pGroupBoxSegment);
75  _lineEditLongueur->setReadOnly(true);
76  pGroupBoxSegmentLayout->addWidget(_lineEditLongueur, 0, 2);
77 
78  QPushButton* pPushButtonSegment = new QPushButton(TR("id_proprietes_button"), pGroupBoxSegment);
79  pGroupBoxSegmentLayout->addWidget(pPushButtonSegment, 0, 3);
80 
81  pLinearMaillageLayout->addWidget(pGroupBoxSegment, 2, 0);
82 
83  updateContent();
84 
85  connect(pPushButtonSegment, &QPushButton::clicked, this, &TYLinearMaillageWidget::editSegment);
86 }
87 
89 
91 {
93 
94  if (getElement()->getSegment())
95  {
96  _lineEditNomSegment->setText(getElement()->getSegment()->getName());
97  _lineEditLongueur->setText(QString().setNum(getElement()->getSegment()->longueur(), 'f', 2));
98  }
99 
100  _lineEditDistance->setText(QString().setNum(1.0f / (getElement()->getDensite()), 'f', 2));
101 }
102 
104 {
105  double longueur = _lineEditLongueur->text().toDouble();
106  double densite = 1.0f / (_lineEditDistance->text().toDouble());
107 
108  _maillageW->updateNbPoints(longueur * densite);
109 }
110 
112 {
113  _maillageW->apply();
114  LPTYProjet pProj = dynamic_cast<TYProjet*>(getElement()->getParent());
115 
116  // Si la densite est differente
117  if ((getElement()->getDistance() != _lineEditDistance->text().toDouble()) && getElement()->getSegment())
118  {
119  getElement()->make(getElement()->getSegment(), 1.0f / (_lineEditDistance->text().toDouble()));
120  dynamic_cast<TYProjet*>(getElement()->getParent())->updateCalculsWithMaillage(getElement());
121 
122  // La densite a changee, il faut mettre a jour l'altimetrie
123  if (pProj && pProj->getSite()->getAltimetry()->containsData())
124  {
125  pProj->updateAltiRecepteurs();
126  }
127  }
128  if (pProj)
129  {
130  pProj->updateGraphic();
131  }
132 
133  emit modified();
134 }
135 
137 {
138  int ret = getElement()->getSegment()->edit(this);
139 
140  if (ret == QDialog::Accepted)
141  {
142  _lineEditNomSegment->setText(getElement()->getSegment()->getName());
143  }
144 }
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:251
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:632
LPTYSiteNode getSite()
Get du site.
Definition: TYProjet.h:169
virtual void updateGraphic()
Definition: TYProjet.cpp:1153
LPTYAltimetrie getAltimetry() const
classe de l'objet IHM pour un objet metier de type TYElement
Definition: TYWidget.h:43
void modified()