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