Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYBoucheSurfaceWidget.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 <QMessageBox>
23 #include <QGridLayout>
24 
30 #include "TYBoucheSurfaceWidget.h"
31 
32 #include <math.h>
33 
34 #define TR(id) OLocalizator::getString("TYBoucheSurfaceWidget", (id))
35 
36 TYBoucheSurfaceWidget::TYBoucheSurfaceWidget(TYBoucheSurface* pElement, QWidget* _pParent /*=NULL*/)
37  : TYWidget(pElement, _pParent)
38 {
39 
40  resize(300, 640);
41  setWindowTitle(TR("id_caption"));
42  _pBoucheSurfaceLayout = new QGridLayout();
43  setLayout(_pBoucheSurfaceLayout);
44 
45  _elmW = new TYAcousticRectangleWidget(pElement, this);
46  _elmW->setLayoutSpacing(0, 0);
47  // _elmW->getSurfaceWidget()->getGroupBoxSrcSurf()->hide();
48 
49  _pBoucheSurfaceLayout->addWidget(_elmW, 0, 0);
50  /*
51  QGroupBox * pGroupBoxSrc = new QGroupBox( this );
52  pGroupBoxSrc->setTitle( TR( "id_source_bafflee" ) );
53  pGroupBoxSrc->setColumnLayout(0, Qt::Vertical );
54  pGroupBoxSrc->layout()->setSpacing( 6 );
55  pGroupBoxSrc->layout()->setContentsMargins(11, 11, 11, 11);
56  QGridLayout * pGroupBoxSrcLayout = new QGridLayout( pGroupBoxSrc->layout() );
57  pGroupBoxSrcLayout->setAlignment( Qt::AlignTop );
58 
59  _pLineEditSrc = new QLineEdit( pGroupBoxSrc );
60  _pLineEditSrc->setEnabled( false );
61  pGroupBoxSrcLayout->addWidget( _pLineEditSrc, 0, 0 );
62 
63  QPushButton * pPushButtonSrc = new QPushButton( pGroupBoxSrc );
64  pPushButtonSrc->setText( TR( "id_proprietes_button" ) );
65  pGroupBoxSrcLayout->addWidget( pPushButtonSrc, 0, 1 );
66 
67  _pBoucheSurfaceLayout->addWidget(pGroupBoxSrc, 1, 0);
68  */
69 
70  // Dimensions
71  _groupBoxDimensions = new QGroupBox(this);
72  _groupBoxDimensions->setTitle(TR("id_title_dimensions"));
73  _groupBoxDimensionsLayout = new QGridLayout();
75 
76  _dimensionsXLabel = new QLabel("labelName");
77  _dimensionsXLabel->setText("X :");
79 
80  _dimensionsYLabel = new QLabel("labelName");
81  _dimensionsYLabel->setText("Y :");
83 
88 
90 
91  updateContent();
92 
93  // connect(pPushButtonSrc, &QPushButton::clicked, this, &TYBoucheSurfaceWidget::editSource);
94 }
95 
97 
99 {
100  _elmW->updateContent();
101 
102  float sizeX = NAN, sizeY = NAN;
103  ((TYRectangle*)_elmW->getElement()->getShape())->getSize(sizeX, sizeY);
104 
105  _dimensionsXLineEdit->setText(QString().setNum(sizeX, 'f', 2));
106  _dimensionsYLineEdit->setText(QString().setNum(sizeY, 'f', 2));
107 
108  // _pLineEditSrc->setText( getElement()->getSourceBafflee()->getName());
109 }
110 
112 {
113  _elmW->apply();
114 
115  double sizeX = _dimensionsXLineEdit->text().toDouble();
116  double sizeY = _dimensionsYLineEdit->text().toDouble();
117 
118  if (sizeX <= 1E-4 || sizeY <= 1.E-4) // Eviter les surfaces nulles
119  {
120  QMessageBox::warning(this, "Tympan", TR("id_warning_size_not_ok"),
121  QMessageBox::Yes); //, QMessageBox::No);
122  return;
123  }
124 
125  ((TYRectangle*)_elmW->getElement()->getShape())->setSize(sizeX, sizeY);
126 
127  TYAcousticRectangleNode* pRectNode = TYAcousticRectangleNode::safeDownCast(getElement()->getParent());
128  if (pRectNode)
129  {
130  pRectNode->updateGrid();
131  }
132 
134 
135  emit modified();
136 }
137 /*
138 void TYBoucheSurfaceWidget::editSource()
139 {
140  int ret = getElement()->getSourceBafflee()->edit(this);
141 
142  if ((ret == QDialog::Accepted) && ( getElement()->getSourceBafflee() != NULL ) ) {
143  _pLineEditSrc->setText( getElement()->getSourceBafflee()->getName() );
144  }
145 }
146 */
outil IHM pour un rectangle acoustique (fichier header)
#define TR(id)
outil IHM pour une bouche de ventilation (fichier header)
outil IHM pour une entrée utilisateur (fichier header)
static OPrototype * safeDownCast(OPrototype *pObject)
Definition: TYElement.cpp:71
classe d'un objet IHM pour un rectangle acoustique
void setLayoutSpacing(int margin, int spacing)
TYBoucheSurfaceWidget(TYBoucheSurface *pElement, QWidget *_pParent=NULL)
QGridLayout * _groupBoxDimensionsLayout
QGridLayout * _pBoucheSurfaceLayout
TYAcousticRectangleWidget * _elmW
virtual void setIsAcousticModified(bool isModified)
Definition: TYElement.cpp:248
classe de l'objet IHM pour un objet metier de type TYElement
Definition: TYWidget.h:43
TYElement * _pElement
Definition: TYWidget.h:114
void modified()