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