Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYPositionDialog.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 
23 // Added by qt3to4:
24 #include <QGridLayout>
25 #include <QBoxLayout>
26 #include <QHBoxLayout>
27 #include <QLabel>
28 
38 
39 #include "TYPositionDialog.h"
40 
41 #define TR(id) OLocalizator::getString("TYPositionDialog", (id))
42 
43 TYPositionDialog::TYPositionDialog(TYGeometryNode* pElement, QWidget* _pParent /*=NULL*/)
44  : TYFormDialog(_pParent)
45 {
46  Q_ASSERT(pElement);
47  _pElement = pElement;
48 
49  resize(300, 174);
50  setWindowTitle(TR("id_caption"));
51  _pointLayout = new QGridLayout();
52  setLayout(_pointLayout);
53 
54  _groupBox = new QGroupBox(this);
55  _groupBox->setTitle(TR(""));
56  _groupBoxLayout = new QGridLayout();
57  _groupBox->setLayout(_groupBoxLayout);
58 
59  _labelX = new QLabel(_groupBox);
60  _labelX->setText(TR("id_x_label"));
61  _groupBoxLayout->addWidget(_labelX, 0, 0);
62 
64  _groupBoxLayout->addWidget(_lineEditX, 0, 1);
65 
66  _labelY = new QLabel(_groupBox);
67  _labelY->setText(TR("id_y_label"));
68  _groupBoxLayout->addWidget(_labelY, 1, 0);
69 
71  _groupBoxLayout->addWidget(_lineEditY, 1, 1);
72 
73  _labelZ = new QLabel(_groupBox);
74  _labelZ->setText(TR("id_z_label"));
75  _groupBoxLayout->addWidget(_labelZ, 2, 0);
76 
78  _groupBoxLayout->addWidget(_lineEditZ, 2, 1);
79 
80  _labelHauteur = new QLabel(_groupBox);
81  _labelHauteur->setText(TR("id_h_label"));
82  _groupBoxLayout->addWidget(_labelHauteur, 4, 0);
83 
85  _groupBoxLayout->addWidget(_lineEditH, 4, 1);
86 
87  _pointLayout->addWidget(_groupBox, 0, 0);
88 
89  QBoxLayout* pBtnLayout = new QHBoxLayout();
90 
91  pBtnLayout->addStretch(1);
92 
93  QPushButton* pButtonOK = new QPushButton(TR("id_ok_btn"), this);
94  pButtonOK->setDefault(true);
95  QObject::connect(pButtonOK, &QPushButton::clicked, this, &TYPositionDialog::apply);
96  pBtnLayout->addWidget(pButtonOK);
97 
98  QPushButton* pButtonCancel = new QPushButton(TR("id_cancel_btn"), this);
99  pButtonCancel->setShortcut(Qt::Key_Escape);
100  QObject::connect(pButtonCancel, &QPushButton::clicked, this, &TYPositionDialog::reject);
101  pBtnLayout->addWidget(pButtonCancel);
102 
103  _pointLayout->addLayout(pBtnLayout, 1, 0);
104 
105  _bHauteurEnable = true;
106 
107  updateContent();
108 }
109 
111 
113 {
114  _lineEditX->setText(QString().setNum(_pElement->getORepere3D()._origin._x, 'f', 2));
115  _lineEditY->setText(QString().setNum(_pElement->getORepere3D()._origin._y, 'f', 2));
116  _lineEditZ->setText(QString().setNum(_pElement->getORepere3D()._origin._z, 'f', 2));
117  _lineEditH->setText(QString().setNum(_pElement->getHauteur(), 'f', 2));
118 
119  // Quand on doit saisir la hauteur, le Z est desactive et incersement
120  _lineEditH->setEnabled(_bHauteurEnable);
121  _lineEditZ->setEnabled(!_bHauteurEnable);
122 
123  // Cas particulier d'un siteNode
124 
125  if (dynamic_cast<TYSiteNode*>(_pElement->getElement()) != nullptr)
126  {
127  _lineEditZ->setEnabled(false);
128  }
129 
130  // Cas particulier d'un maillage
131  if ((dynamic_cast<TYMaillage*>(_pElement->getElement()) != nullptr) ||
132  (dynamic_cast<TYAcousticSurface*>(_pElement->getElement()) != nullptr))
133  {
134  _bHauteurEnable = false;
135  _lineEditZ->setEnabled(false);
136  _lineEditH->setEnabled(false);
137  }
138 }
139 
141 {
143  {_lineEditX->text().toDouble(), _lineEditY->text().toDouble(), _lineEditZ->text().toDouble()});
144  _pElement->setHauteur(_lineEditH->text().toDouble());
145 
147  accept();
148 }
All base classes related to 3D manipulation.
outil IHM pour un element (fichier header)
outil IHM pour une entrée utilisateur (fichier header)
#define TR(id)
boite de dialogue pour la gestion de la position selon les modes 'moving', 'rotation',...
double _y
y coordinate of OCoord3D
Definition: 3d.h:283
double _z
z coordinate of OCoord3D
Definition: 3d.h:284
double _x
x coordinate of OCoord3D
Definition: 3d.h:282
OPoint3D _origin
The origin point.
Definition: 3d.h:1331
static void setIsSavedOk(const bool &toSave)
Definition: TYElement.h:905
const ORepere3D & getORepere3D() const
void setHauteur(const double &hauteur)
Set the heigth above the ground.
double getHauteur()
Get the height above the ground.
TYElement * getElement() const
void setPosition(const OPoint3D &pos)
Set the position of the element.
Classe de definition d'un maillage.
Definition: TYMaillage.h:51
QGridLayout * _groupBoxLayout
TYLineEdit * _lineEditX
TYPositionDialog(TYGeometryNode *pElement, QWidget *_pParent=NULL)
virtual void updateContent()
TYLineEdit * _lineEditH
QGridLayout * _pointLayout
TYLineEdit * _lineEditY
QGroupBox * _groupBox
virtual void apply()
TYGeometryNode * _pElement
TYLineEdit * _lineEditZ