Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYPositionDialog.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 
23 // Added by qt3to4:
24 #include <QGridLayout>
25 #include <QBoxLayout>
26 #include <QHBoxLayout>
27 #include <QLabel>
28 
39 
40 #include "TYPositionDialog.h"
41 
42 #define TR(id) OLocalizator::getString("TYPositionDialog", (id))
43 
44 TYPositionDialog::TYPositionDialog(TYGeometryNode* pElement, QWidget* _pParent /*=NULL*/)
45  : TYFormDialog(_pParent)
46 {
47  Q_ASSERT(pElement);
48  _pElement = pElement;
49 
50  resize(300, 174);
51  setWindowTitle(TR("id_caption"));
52  _pointLayout = new QGridLayout();
53  setLayout(_pointLayout);
54 
55  _groupBox = new QGroupBox(this);
56  _groupBox->setTitle(TR(""));
57  _groupBoxLayout = new QGridLayout();
58  _groupBox->setLayout(_groupBoxLayout);
59 
60  _labelX = new QLabel(_groupBox);
61  _labelX->setText(TR("id_x_label"));
62  _groupBoxLayout->addWidget(_labelX, 0, 0);
63 
65  _groupBoxLayout->addWidget(_lineEditX, 0, 1);
66 
67  _labelY = new QLabel(_groupBox);
68  _labelY->setText(TR("id_y_label"));
69  _groupBoxLayout->addWidget(_labelY, 1, 0);
70 
72  _groupBoxLayout->addWidget(_lineEditY, 1, 1);
73 
74  _labelZ = new QLabel(_groupBox);
75  _labelZ->setText(TR("id_z_label"));
76  _groupBoxLayout->addWidget(_labelZ, 2, 0);
77 
79  _groupBoxLayout->addWidget(_lineEditZ, 2, 1);
80 
81  _labelHauteur = new QLabel(_groupBox);
82  _labelHauteur->setText(TR("id_h_label"));
83  _groupBoxLayout->addWidget(_labelHauteur, 4, 0);
84 
86  _groupBoxLayout->addWidget(_lineEditH, 4, 1);
87 
88  _pointLayout->addWidget(_groupBox, 0, 0);
89 
90  QBoxLayout* pBtnLayout = new QHBoxLayout();
91 
92  pBtnLayout->addStretch(1);
93 
94  QPushButton* pButtonOK = new QPushButton(TR("id_ok_btn"), this);
95  pButtonOK->setDefault(true);
96  QObject::connect(pButtonOK, &QPushButton::clicked, this, &TYPositionDialog::apply);
97  pBtnLayout->addWidget(pButtonOK);
98 
99  QPushButton* pButtonCancel = new QPushButton(TR("id_cancel_btn"), this);
100  pButtonCancel->setShortcut(Qt::Key_Escape);
101  QObject::connect(pButtonCancel, &QPushButton::clicked, this, &TYPositionDialog::reject);
102  pBtnLayout->addWidget(pButtonCancel);
103 
104  _pointLayout->addLayout(pBtnLayout, 1, 0);
105 
106  _bHauteurEnable = true;
107 
108  updateContent();
109 }
110 
112 
114 {
115  _lineEditX->setText(QString().setNum(_pElement->getORepere3D()._origin._x, 'f', 2));
116  _lineEditY->setText(QString().setNum(_pElement->getORepere3D()._origin._y, 'f', 2));
117  _lineEditZ->setText(QString().setNum(_pElement->getORepere3D()._origin._z, 'f', 2));
118  _lineEditH->setText(QString().setNum(_pElement->getHauteur(), 'f', 2));
119 
120  // Quand on doit saisir la hauteur, le Z est desactive et incersement
121  _lineEditH->setEnabled(_bHauteurEnable);
122  _lineEditZ->setEnabled(!_bHauteurEnable);
123 
124  // Cas particulier d'un siteNode
125 
126  if (dynamic_cast<TYSiteNode*>(_pElement->getElement()) != nullptr)
127  {
128  _lineEditZ->setEnabled(false);
129  }
130 
131  // Cas particulier d'un maillage
132  if ((dynamic_cast<TYMaillage*>(_pElement->getElement()) != nullptr) ||
133  (dynamic_cast<TYAcousticSurface*>(_pElement->getElement()) != nullptr))
134  {
135  _bHauteurEnable = false;
136  _lineEditZ->setEnabled(false);
137  _lineEditH->setEnabled(false);
138  }
139 }
140 
142 {
143  _pElement->getORepere3D()._origin._x = _lineEditX->text().toDouble();
144  _pElement->getORepere3D()._origin._y = _lineEditY->text().toDouble();
145  _pElement->getORepere3D()._origin._z = _lineEditZ->text().toDouble();
146 
147  _pElement->setHauteur(_lineEditH->text().toDouble());
148 
150  accept();
151 }
All base classes related to 3D manipulation.
outil IHM pour un element (fichier header)
Parent class of Tympan Qt dialogs of type form (geader file)
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:1279
static void setIsSavedOk(const bool &toSave)
Definition: TYElement.h:915
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
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