Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYPointCalculWidget.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 
30 #include "TYPointCalculWidget.h"
31 
32 #define TR(id) OLocalizator::getString("TYPointCalculWidget", (id))
33 
34 TYPointCalculWidget::TYPointCalculWidget(TYPointCalcul* pElement, QWidget* _pParent /*=NULL*/)
35  : TYWidget(pElement, _pParent)
36 {
37  unsigned short wLn = 0;
38 
39  resize(300, 200);
40 
41  setWindowTitle(TR("id_caption"));
42  _pPointCalculLayout = new QGridLayout();
43  setLayout(_pPointCalculLayout);
44 
45  _elmW = new TYElementWidget(pElement, this);
46  _pPointCalculLayout->addWidget(_elmW, wLn++, 0);
47 
48  // Affichage de l'etat du spectre (actif/inactif)
49  _buttonGroupState = new QButtonGroup();
50  _buttonGroupState->setExclusive(true);
51  _pRadioButtonInactif = new QRadioButton(TR("id_inactif"));
53  _pRadioButtonActif = new QRadioButton(TR("id_actif"));
55 
56  QGridLayout* groupBoxStateLayout = new QGridLayout();
57  groupBoxStateLayout->addWidget(_pRadioButtonInactif, 0, 0);
58  groupBoxStateLayout->addWidget(_pRadioButtonActif, 0, 1);
59 
60  _groupBoxState = new QGroupBox();
61  _groupBoxState->setTitle(TR("id_etat"));
62  _groupBoxState->setLayout(groupBoxStateLayout);
63 
64  _pPointCalculLayout->addWidget(_groupBoxState, wLn++, 0);
65 
66  // Groupbox du spectre
67  QGroupBox* pGroupBoxSpectre = new QGroupBox(this);
68  pGroupBoxSpectre->setTitle(TR("id_spectre"));
69  QGridLayout* pGroupBoxSpectreLayout = new QGridLayout();
70  pGroupBoxSpectre->setLayout(pGroupBoxSpectreLayout);
71 
72  // Choix du calcul associe au spectre
73  _labelSpectreCalcul = new QLabel(pGroupBoxSpectre);
74  _labelSpectreCalcul->setText(TR("id_spectre_calcul"));
75  pGroupBoxSpectreLayout->addWidget(_labelSpectreCalcul, 0, 0);
76 
77  // Spectre
78  _lineEditNomSpectre = new QLineEdit(pGroupBoxSpectre);
79  _lineEditNomSpectre->setEnabled(false);
80  pGroupBoxSpectreLayout->addWidget(_lineEditNomSpectre, 1, 0);
81 
82  QPushButton* pPushButtonSpectre = new QPushButton(TR("id_proprietes_button"), pGroupBoxSpectre);
83  QObject::connect(pPushButtonSpectre, &QPushButton::clicked, this, &TYPointCalculWidget::editSpectre);
84  pGroupBoxSpectreLayout->addWidget(pPushButtonSpectre, 1, 1);
85 
86  _pPointCalculLayout->addWidget(pGroupBoxSpectre, wLn++, 0);
87 
88  // Affichage de la position
89  _ptW = new TYPointWidget(pElement, this);
90  _ptW->setLayoutSpacing(0, 0);
91 
92  _pPointCalculLayout->addWidget(_ptW, wLn++, 0);
93 
94  updateContent();
95 }
96 
98 
100 {
101 
102  _elmW->updateContent();
103  _ptW->updateContent();
104  _ptW->disableZ();
105 
106  _lineEditNomSpectre->setText(getElement()->getSpectre()->getName());
107 
108  int bouton = getElement()->etat() ? 1 : 0;
109  _buttonGroupState->button(bouton)->setChecked(true);
110 }
111 
113 {
114  _elmW->apply();
115  _ptW->apply();
116  getElement()->setEtat(_buttonGroupState->checkedId());
117  emit modified();
118 }
119 
121 {
122  _lineEditNomSpectre->setText(getElement()->getSpectre()->getName());
123 
124  int bouton = getElement()->etat() ? 1 : 0;
125  _buttonGroupState->button(bouton)->setChecked(true);
126 }
127 
129 {
130  LPTYSpectre sp = getElement()->getSpectre();
131  bool bSave = sp->getIsReadOnly();
132 
133  sp->setIsReadOnly(true);
134 
135  sp->edit(this);
136 
137  sp->setIsReadOnly(bSave);
138 }
139 
140 // void TYPointCalculWidget::showResultatTreeDialog()
141 //{
142 // TYResultatTreeDialog * pDlg = new TYResultatTreeDialog(this);
143 // TYResultat * pResultat = NULL;
144 // TYCalcul * pCalcul = NULL;
145 //
146 // if (TYMaillage::safeDownCast(getElement()->getParent())) {
147 // pCalcul = TYCalcul::safeDownCast(getElement()->getParent()->getParent());
148 // } else {
149 // pCalcul = TYCalcul::safeDownCast(getElement()->getParent());
150 // }
151 //
152 // if (pCalcul) {
153 // pResultat = pCalcul->getResultat();
154 // }
155 //
156 // if (pResultat) {
157 // pDlg->set(pResultat, getElement());
158 // pDlg->exec();
159 // }
160 //}
#define TR(id)
outil IHM pour un point de calcul (fichier header)
outil IHM pour un point (fichier header)
classe de l'objet IHM pour un element
virtual void apply()
virtual void updateContent()
QGridLayout * _pPointCalculLayout
void changeCalcul(int calcul)
QLabel * _labelSpectreCalcul
Choix du calcul associe au spectre.
QRadioButton * _pRadioButtonActif
TYElementWidget * _elmW
QRadioButton * _pRadioButtonInactif
virtual void updateContent()
QButtonGroup * _buttonGroupState
TYPointCalculWidget(TYPointCalcul *pElement, QWidget *_pParent=NULL)
Classe de definition d'un point de calcul.C'est une classe derivee a TYPoint avec en plus un spectrep...
Definition: TYPointCalcul.h:33
classe de l'objet IHM pour un point
Definition: TYPointWidget.h:49
void setLayoutSpacing(int margin, int spacing)
Definition: TYPointWidget.h:71
virtual void apply()
virtual void updateContent()
virtual bool getIsReadOnly()
Set/Get du flag de conservation en BDD.
Definition: TYSpectre.h:135
virtual void setIsReadOnly(bool flag)
Set/Get du flag _isReadOnly.
Definition: TYSpectre.h:141
classe de l'objet IHM pour un objet metier de type TYElement
Definition: TYWidget.h:43
void modified()