Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYBoxWidget.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 
29 #include "TYBoxWidget.h"
30 
31 #define TR(id) OLocalizator::getString("TYBoxWidget", (id))
32 
33 TYBoxWidget::TYBoxWidget(TYBox* pElement, QWidget* _pParent /*=NULL*/) : TYWidget(pElement, _pParent)
34 {
35  QString num;
36 
37  _elmW = new TYElementWidget(pElement, this);
38  _colorW = new TYColorInterfaceWidget(pElement, this);
39 
40  resize(300, 240);
41  setWindowTitle(TR("id_caption"));
42  _boxLayout = new QGridLayout();
43  setLayout(_boxLayout);
44 
45  _boxLayout->addWidget(_elmW, 0, 0);
46  _boxLayout->addWidget(_colorW, 1, 0);
47 
48  _groupBox = new QGroupBox(this);
49  _groupBox->setTitle(TR(""));
50  _groupBoxLayout = new QGridLayout();
51  _groupBox->setLayout(_groupBoxLayout);
52 
53  _labelSizeX = new QLabel(_groupBox);
54  _labelSizeX->setText(TR("id_sizeX_label"));
55  _groupBoxLayout->addWidget(_labelSizeX, 0, 0);
56 
57  _labelSizeY = new QLabel(_groupBox);
58  _labelSizeY->setText(TR("id_sizeY_label"));
59  _groupBoxLayout->addWidget(_labelSizeY, 1, 0);
60 
61  _labelSizeZ = new QLabel(_groupBox);
62  _labelSizeZ->setText(TR("id_sizeZ_label"));
63  _groupBoxLayout->addWidget(_labelSizeZ, 2, 0);
64 
66  _lineEditSizeX->setText(num.setNum(getElement()->_sizeX, 'f', 2));
67  _groupBoxLayout->addWidget(_lineEditSizeX, 0, 1);
68  QLabel* pUnitSizeX = new QLabel(_groupBox);
69  pUnitSizeX->setText(TR("id_unite_size"));
70  _groupBoxLayout->addWidget(pUnitSizeX, 0, 2);
71 
73  _lineEditSizeY->setText(num.setNum(getElement()->_sizeY, 'f', 2));
74  _groupBoxLayout->addWidget(_lineEditSizeY, 1, 1);
75  QLabel* pUnitSizeY = new QLabel(_groupBox);
76  pUnitSizeY->setText(TR("id_unite_size"));
77  _groupBoxLayout->addWidget(pUnitSizeY, 1, 2);
78 
80  _lineEditSizeZ->setText(num.setNum(getElement()->_sizeZ, 'f', 2));
81  _groupBoxLayout->addWidget(_lineEditSizeZ, 2, 1);
82  QLabel* pUnitSizeZ = new QLabel(_groupBox);
83  pUnitSizeZ->setText(TR("id_unite_size"));
84  _groupBoxLayout->addWidget(pUnitSizeZ, 2, 2);
85 
86  _boxLayout->addWidget(_groupBox, 2, 0);
87 
88  _groupBoxPosition = new QGroupBox(this);
89  _groupBoxPosition->setTitle(TR("id_position"));
90  _groupBoxPositionLayout = new QGridLayout();
92 
93  _lineEditNomPosition = new QLineEdit(_groupBoxPosition);
94  _lineEditNomPosition->setEnabled(false);
95  _lineEditNomPosition->setText(getElement()->getPosition().getName());
97 
98  _pushButtonPosition = new QPushButton(_groupBoxPosition);
99  _pushButtonPosition->setText(TR("id_proprietes_button"));
101 
102  _boxLayout->addWidget(_groupBoxPosition, 3, 0);
103 
104  connect(_pushButtonPosition, &QPushButton::clicked, this, &TYBoxWidget::editPosition);
105 }
106 
108 
110 {
111  QString num;
112 
113  _elmW->updateContent();
115 
116  _lineEditSizeX->setText(num.setNum(getElement()->_sizeZ, 'f', 2));
117  _lineEditSizeY->setText(num.setNum(getElement()->_sizeZ, 'f', 2));
118  _lineEditSizeZ->setText(num.setNum(getElement()->_sizeZ, 'f', 2));
119  _lineEditNomPosition->setText(getElement()->getPosition().getName());
120 }
121 
123 {
124  _elmW->apply();
125  _colorW->apply();
126 
127  getElement()->_sizeX = _lineEditSizeX->text().toDouble();
128  getElement()->_sizeY = _lineEditSizeY->text().toDouble();
129  getElement()->_sizeZ = _lineEditSizeZ->text().toDouble();
130 
131  emit modified();
132 }
133 
135 {
136  int ret = getElement()->getPosition().edit(this);
137 
138  if (ret == QDialog::Accepted)
139  {
140  _lineEditNomPosition->setText(getElement()->getPosition().getName());
141  }
142 }
#define TR(id)
Definition: TYBoxWidget.cpp:31
outil IHM pour une boite (fichier header)
outil IHM pour l'objet ColorInterface (fichier header)
outil IHM pour une entrée utilisateur (fichier header)
TYColorInterfaceWidget * _colorW
Definition: TYBoxWidget.h:94
TYElementWidget * _elmW
Definition: TYBoxWidget.h:93
QLabel * _labelSizeX
Definition: TYBoxWidget.h:78
QGroupBox * _groupBox
Definition: TYBoxWidget.h:77
QPushButton * _pushButtonPosition
Definition: TYBoxWidget.h:86
QGroupBox * _groupBoxPosition
Definition: TYBoxWidget.h:84
QGridLayout * _groupBoxPositionLayout
Definition: TYBoxWidget.h:91
TYLineEdit * _lineEditSizeZ
Definition: TYBoxWidget.h:83
void editPosition()
QGridLayout * _groupBoxLayout
Definition: TYBoxWidget.h:90
QGridLayout * _boxLayout
Definition: TYBoxWidget.h:89
virtual void updateContent()
QLabel * _labelSizeY
Definition: TYBoxWidget.h:79
TYLineEdit * _lineEditSizeY
Definition: TYBoxWidget.h:82
TYBoxWidget(TYBox *pElement, QWidget *_pParent=NULL)
Definition: TYBoxWidget.cpp:33
TYLineEdit * _lineEditSizeX
Definition: TYBoxWidget.h:81
virtual ~TYBoxWidget()
QLabel * _labelSizeZ
Definition: TYBoxWidget.h:80
QLineEdit * _lineEditNomPosition
Definition: TYBoxWidget.h:85
virtual void apply()
Definition: TYBox.h:34
classe de l'objet IHM pour l'objet ColorInterface
classe de l'objet IHM pour un element
virtual void apply()
virtual void updateContent()
classe de l'objet IHM pour un objet metier de type TYElement
Definition: TYWidget.h:43
void modified()