Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYPointControlWidget.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 #include <qradiobutton.h>
22 #include <qbuttongroup.h>
23 // Added by qt3to4:
24 #include <QGridLayout>
25 #include <QLabel>
26 #include <QLineEdit>
27 #include <QtWidgets>
28 
35 #include "TYPointControlWidget.h"
36 
37 #define TR(id) OLocalizator::getString("TYPointControlWidget", (id))
38 
39 TYPointControlWidget::TYPointControlWidget(TYPointControl* pElement, QWidget* _pParent /*=NULL*/)
40  : TYWidget(pElement, _pParent)
41 {
42  unsigned short pos = 0;
43 
45  _pPointBack->deepCopy(pElement, true);
46 
47  resize(300, 200);
48  setWindowTitle(TR("id_caption"));
49  QGridLayout* pPointCalculLayout = new QGridLayout();
50  setLayout(pPointCalculLayout);
51 
52  _ptCalculW = new TYPointCalculWidget(pElement, this);
54  pPointCalculLayout->addWidget(_ptCalculW, pos++, 0);
55 
56  QGroupBox* pGroupBoxHauteur = new QGroupBox(this);
57  pGroupBoxHauteur->setTitle(TR("id_maillage"));
58  QGridLayout* groupBoxHauteurLayout = new QGridLayout();
59  pGroupBoxHauteur->setLayout(groupBoxHauteurLayout);
60 
61  QLabel* pLabelHauteur = new QLabel(TR("id_hauteur"), pGroupBoxHauteur);
62  groupBoxHauteurLayout->addWidget(pLabelHauteur, 0, 0);
63  _lineEditHauteur = new TYLineEdit(pGroupBoxHauteur);
64  groupBoxHauteurLayout->addWidget(_lineEditHauteur, 0, 1);
65 
66  pPointCalculLayout->addWidget(pGroupBoxHauteur, pos++, 0);
67 
68  // Choix du systeme de coordonnees
69  QGroupBox* pGroupBoxSIG = new QGroupBox(this);
70  pGroupBoxSIG->setTitle(TR("id_SIG"));
71  QGridLayout* groupBoxSIGLayout = new QGridLayout();
72  pGroupBoxSIG->setLayout(groupBoxSIGLayout);
73 
74  _labelRepere = new QLabel(TR("id_choixSIG"), pGroupBoxSIG);
75  groupBoxSIGLayout->addWidget(_labelRepere, 0, 0);
76 
77  _lineEditRepere = new QLineEdit(pGroupBoxSIG);
78  groupBoxSIGLayout->addWidget(_lineEditRepere, 0, 1);
79 
80  _buttonGroupSysCoord = new QButtonGroup();
81  _buttonGroupSysCoord->setExclusive(true);
82  QRadioButton* pRadioButtonTympan = new QRadioButton(TR("id_tympan"));
83  _buttonGroupSysCoord->addButton(pRadioButtonTympan, 0);
84  QRadioButton* pRadioButtonSIG = new QRadioButton(TR("id_sigle_SIG"));
85  _buttonGroupSysCoord->addButton(pRadioButtonSIG, 1);
86 
87  QGridLayout* groupBoxSysCoordLayout = new QGridLayout();
88  groupBoxSysCoordLayout->addWidget(pRadioButtonTympan, 0, 0);
89  groupBoxSysCoordLayout->addWidget(pRadioButtonSIG, 0, 1);
90 
91  QGroupBox* groupBoxSysCoord = new QGroupBox();
92  groupBoxSysCoord->setTitle(TR("id_repere"));
93  groupBoxSysCoord->setLayout(groupBoxSysCoordLayout);
94 
95  groupBoxSIGLayout->addWidget(groupBoxSysCoord, 0, 2);
96 
97  pPointCalculLayout->addWidget(pGroupBoxSIG, pos++, 0);
98 
99  // Choix de l'object geometrique et couleur
100  QGroupBox* groupBoxAspect = new QGroupBox(this);
101  groupBoxAspect->setTitle(TR(""));
102  QGridLayout* groupBoxLayoutAspect = new QGridLayout();
103  groupBoxAspect->setLayout(groupBoxLayoutAspect);
104 
105  // Choix de l'object geometrique
106  QGroupBox* groupBoxObject = new QGroupBox(groupBoxAspect);
107  groupBoxObject->setTitle(TR(""));
108  QGridLayout* groupBoxLayoutObject = new QGridLayout();
109  groupBoxObject->setLayout(groupBoxLayoutObject);
110 
111  _labelSelectObject = new QLabel(groupBoxObject);
112  _labelSelectObject->setText(TR("id_objet_label"));
113  groupBoxLayoutObject->addWidget(_labelSelectObject, 0, 0);
114 
115  _comboBoxSelectObject = new QComboBox(groupBoxObject);
116  groupBoxLayoutObject->addWidget(_comboBoxSelectObject, 0, 1);
117 
118  groupBoxLayoutAspect->addWidget(groupBoxObject, 0, 0);
119 
120  // Choix de la couleur
121  _colorW = new TYColorInterfaceWidget(pElement, groupBoxAspect);
122  groupBoxLayoutAspect->addWidget(_colorW, 0, 1);
123 
124  pPointCalculLayout->addWidget(groupBoxAspect, pos++, 0);
125 
126  updateContent();
127 
128  // Disambiguate the overloaded signals
129  void (QComboBox::*_qComboBox_activated)(int) = &QComboBox::activated;
130  void (QButtonGroup::*_qButtonGroup_clicked)(int) = &QButtonGroup::idClicked;
131 
132  QObject::connect(_comboBoxSelectObject, _qComboBox_activated, this, &TYPointControlWidget::changeObject);
133  QObject::connect(_buttonGroupSysCoord, _qButtonGroup_clicked, this, &TYPointControlWidget::updateCoord);
134 }
135 
137 
139 {
141  QString strSIG;
142  int SIGType = getElement()->getSIGType();
143 
144  switch (SIGType)
145  {
146  case 1:
147  strSIG = "LAMBERT IIe";
148  break;
149  case 2:
150  strSIG = "GPS";
151  break;
152 
153  case 0:
154  default:
155  strSIG = "TYMPAN";
156  break;
157  }
158 
159  _buttonGroupSysCoord->button(0)->setChecked(true);
160 
161  _lineEditRepere->setText(strSIG);
162  _lineEditRepere->setEnabled(false); // On ne peut pas choisir ici son systeme de coordonnees
163 
165 
166  _lineEditHauteur->setText(QString().setNum(getElement()->getHauteur()));
167 
169 }
170 
172 {
173  _ptCalculW->apply();
174  _colorW->apply();
175 
176  getElement()->fromSIG(); // Pas de danger car le point controle son etat
177 
178  getElement()->setHauteur(_lineEditHauteur->text().toDouble());
179 
180  delete _pPointBack;
181  _pPointBack = NULL;
182 
183  emit modified();
184 }
185 
187 {
189  getElement()->fromSIG(); // Pas de danger car le point controle son etat
190  delete _pPointBack;
191  _pPointBack = NULL;
192 }
193 
195 {
196  _comboBoxSelectObject->clear();
197 
198  // Remplissage du comboBox des objects
199  _comboBoxSelectObject->insertItem(0, TR("id_objet_cube"));
200  _comboBoxSelectObject->insertItem(1, TR("id_objet_pyramide"));
201  _comboBoxSelectObject->insertItem(2, TR("id_objet_sphere"));
202  _comboBoxSelectObject->insertItem(3, TR("id_objet_etoile"));
203 
204  // On affiche la forme d'objet courante
205  _comboBoxSelectObject->setCurrentIndex(getElement()->getObject());
206 }
207 
209 {
210  getElement()->setObject(object);
211 }
212 
214 {
215  _ptCalculW->apply();
216 
217  if (selected == 0)
218  {
219  getElement()->fromSIG();
220  }
221  else
222  {
223  getElement()->toSIG();
224  }
225 
227 }
outil IHM pour l'objet ColorInterface (fichier header)
outil IHM pour une entrée utilisateur (fichier header)
outil IHM pour un point de calcul (fichier header)
#define TR(id)
outil IHM pour un point de controle (fichier header)
classe de l'objet IHM pour l'objet ColorInterface
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
Definition: TYElement.cpp:305
classe de l'objet IHM pour un point de calcul
void setLayoutSpacing(int margin, int spacing)
TYPointControl * _pPointBack
Copie du point de controle.
void updateCoord(int selected)
QButtonGroup * _buttonGroupSysCoord
Choix du systeme de coordonnee.
TYPointCalculWidget * _ptCalculW
TYColorInterfaceWidget * _colorW
Interface pour la gestion de la couleur.
TYPointControlWidget(TYPointControl *pElement, QWidget *_pParent=NULL)
QLabel * _labelSelectObject
Choix de la forme de l'objet.
Classe de definition d'un point de controle.Le point de controle est un point de calcul avec une haut...
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
classe de l'objet IHM pour un objet metier de type TYElement
Definition: TYWidget.h:43
TYElement * _pElement
Definition: TYWidget.h:114
void modified()