Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYBatimentModelerFrame.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 <qlayout.h>
22 #include <qcursor.h>
23 #include <qpushbutton.h>
24 #include <qcursor.h>
25 #include <qmessagebox.h>
26 
35 #include "TYBatimentModelerFrame.h"
36 
37 #define TR(id) OLocalizator::getString("TYBatimentModelerFrame", (id))
38 #define IMG(id) OLocalizator::getPicture("TYSiteModelerFrame", (id))
39 
41 
42 TYBatimentModelerFrame::TYBatimentModelerFrame(LPTYBatiment pBatiment, QWidget* parent, const char* name,
43  Qt::WindowFlags f)
44  : TYModelerFrame(parent, name, f)
45 {
46  _nbInstance++;
47  setWindowTitle(TR("id_caption") + " " + QString("%1").arg(_nbInstance));
48 
49  _pCtrlLayout->addSpacing(10);
50 
51  // Btn Calculer
52  QPushButton* pCalculBtn =
53  new QPushButton(QPixmap(IMG("id_icon_calculalti_btn")), "", /*TR("id_calcul_btn"),*/ this);
54  pCalculBtn->setFixedSize(24, 24);
55  _pCtrlLayout->addWidget(pCalculBtn, 0);
56  _pCtrlLayout->addStretch(1);
57  connect(pCalculBtn, &QPushButton::clicked, this, &TYBatimentModelerFrame::calculDistribution);
58 
59  // Editors
60  _pEtageEditor = new TYEtageEditor(this);
61  _pSilosEditor = new TYSilosEditor(this);
62  _pSourceEditor = new TYSourceEditor(this);
63 
64  // Cadrage
69 
70  if (pBatiment)
71  {
72  setBatiment(pBatiment);
73  }
74  else
75  {
76  setBatiment(new TYBatiment());
77  }
78 
79  // Vue de dessus
82 }
83 
85 {
86  _nbInstance--;
87 
88  if (_pBatiment)
89  {
90  _pBatiment->drawGraphic(false);
91  }
92 
93  delete _pEtageEditor;
94  delete _pSilosEditor;
95  delete _pSourceEditor;
96 }
97 
99 {
101  bool ret = true;
102  if (_pBatiment->getNbChild() > 0)
103  {
104  ret = TYModelerFrame::close();
105  }
106  return ret;
107 }
108 
110 {
111  QString caption(TR("id_caption") + " " + QString("%1").arg(_nbInstance));
112 
113  if (_pBatiment)
114  {
115  // On recherche si ce batiment fait parti d'un site
116  if (_pBatiment->getParent())
117  {
119  if (pSite)
120  {
121  // Dans ce cas on supprime le plan de masse du site
122 #ifdef _DEBUG
123  // getRenderer()->RemoveActor(pSite->getGraphicObject()->getProp());//az-- : revoir (ne devait
124  // pas marcher en OpenGL)
125 #endif
126  }
127  }
128 
129  _pBatiment->drawGraphic(false);
130  }
131 
132  _pBatiment = pBatiment;
133 
134  if (_pBatiment)
135  {
136  if (!_pBatiment->getName().isEmpty())
137  {
138  caption += QString(" : %1").arg(_pBatiment->getName());
139  }
140 
141  // On affiche le batiment
142  _pBatiment->drawGraphic();
143 
144  // On recherche si ce batiment fait parti d'un site
145  if (_pBatiment->getParent())
146  {
148  if (pSite)
149  {
150  // Dans ce cas on affiche le plan de masse du site
151  // getRenderer()->AddActor(pSite->getGraphicObject()->getActor()); // Mise en
152  // Commentaire DT le 08/07/03
153  }
154  }
155  }
156 
158  setWindowTitle(caption);
159 
162 }
163 
165 {
166  if (!_editorModeAccepted)
167  {
168  getPickEditor()->usePopup(true);
169  getPickEditor()->useHighlight(false);
170 
171  if (_pCurrentEditor)
172  {
175  }
176 
177  _editorModeAccepted = true;
178 
179  switch (mode)
180  {
181  case EtageMode:
183  break;
184  case SilosMode:
186  break;
187  // case MachineMode:
188  // _pDataBaseEditor->setElementTypeName("TYMachine");
189  // _pCurrentEditor = _pDataBaseEditor;
190  // break;
191  case SourceMode:
193  break;
194  default:
195  _editorModeAccepted = false;
196  }
197  }
198 
200 }
201 
202 void TYBatimentModelerFrame::closeEvent(QCloseEvent* pEvent)
203 {
204  TYPreferenceManager::saveGeometryToPreferences(metaObject()->className(), this);
205  // If there is no volume in the modeler
206  if (_pBatiment->getNbChild() == 0)
207  {
208  // Displaying a warning message
209  QMessageBox::StandardButton msgBox =
210  QMessageBox::warning(this, "", "Le modeleur est vide. Etes-vous sûr de vouloir le fermer ?",
211  QMessageBox::Yes | QMessageBox::No);
212  switch (msgBox)
213  {
214  // The user aborts the closing event
215  case QMessageBox::No:
216  pEvent->ignore();
217  break;
218  // The user ignores the warning
219  case QMessageBox::Yes:
220  emit frameResized();
221  emit aboutToClose();
222  break;
223  default:
224  pEvent->ignore();
225  return;
226  }
227  }
228  // If there are volumes, the signal is emited and the event accepted
229  else
230  {
231  pEvent->accept();
232  emit frameResized();
233  emit aboutToClose();
234  }
235 }
236 
238 {
239  if (_pBatiment)
240  {
242  }
243 }
244 
246 {
247  // Grille
248  _gridDimX = 100.0f;
249  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "GridDimXBatiment"))
250  {
251  _gridDimX = TYPreferenceManager::getFloat(TYDIRPREFERENCEMANAGER, "GridDimXBatiment");
252  }
253  else
254  {
255  TYPreferenceManager::setFloat(TYDIRPREFERENCEMANAGER, "GridDimXBatiment", _gridDimX);
256  }
257 
258  _gridDimY = 100.0f;
259  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "GridDimYBatiment"))
260  {
261  _gridDimY = TYPreferenceManager::getFloat(TYDIRPREFERENCEMANAGER, "GridDimYBatiment");
262  }
263  else
264  {
265  TYPreferenceManager::setFloat(TYDIRPREFERENCEMANAGER, "GridDimYBatiment", _gridDimY);
266  }
267 
268  _gridStep = 5.0f;
269  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "GridStepBatiment"))
270  {
271  _gridStep = TYPreferenceManager::getFloat(TYDIRPREFERENCEMANAGER, "GridStepBatiment");
272  }
273  else
274  {
275  TYPreferenceManager::setFloat(TYDIRPREFERENCEMANAGER, "GridStepBatiment", _gridStep);
276  }
277 
278  _gridMagnStep = 2.0f;
279  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "GridMagnStepBatiment"))
280  {
281  _gridMagnStep = TYPreferenceManager::getFloat(TYDIRPREFERENCEMANAGER, "GridMagnStepBatiment");
282  }
283  else
284  {
285  TYPreferenceManager::setFloat(TYDIRPREFERENCEMANAGER, "GridMagnStepBatiment", _gridMagnStep);
286  }
290 
291  resizeGrid();
294  (_curViewType == LeftView));
295 
297 }
gestion de l'interaction entre la vue graphique (2D ou 3D) et le clavier et la souris (fichier header...
TYApplication * getTYApp()
Retourne le pointeur sur l'application.
pour l'application Tympan (fichier header)
#define IMG(id)
#define TR(id)
Modeler specialisee pour l'edition des batiments (fichier header)
#define TYDIRPREFERENCEMANAGER
Definition: TYElement.h:52
Construit un etage a partir des points saisis (fichier header)
gestion de l'element actionne par picking (fichier header)
const char * name
gestion de l'edition d'un silo (fichier header)
gestion de l'edition d'une source (fichier header)
void setDefaultZoomFactor(double defaultZoomFactor)
Definition: OGLCamera.cpp:835
static OPrototype * safeDownCast(OPrototype *pObject)
Definition: TYElement.cpp:71
virtual void close()
Appeler apres l'utilisation de l'editor.
virtual void disconnect()
Deconnecte cet editor a l'interactor associe.
void setGridMagnStep(float gridMagnStep=1.0)
Met Ã&#160; jour le pas de la grille magnétique.
TYCalculManager * getCalculManager()
Get du gestionnaire de calculs.
Definition: TYApplication.h:99
virtual ~TYBatimentModelerFrame()
Destructeur.
TYEtageEditor * _pEtageEditor
Editor pour la construction d'etage.
TYSourceEditor * _pSourceEditor
Editor pour l'ajout d'une source ponctuelle.
static int _nbInstance
Nombre d'instance de type TYBatimentModelerFrame.
LPTYBatiment _pBatiment
Un pointeur sur le bâtiment a editer.
void setBatiment(LPTYBatiment pBatiment)
Set/Get du bâtiment a editer.
TYBatimentModelerFrame(LPTYBatiment pBatiment=0, QWidget *parent=0, const char *name=0, Qt::WindowFlags f=QFlag(0))
Constructeur par defaut.
virtual void setEditorMode(int mode)
virtual void closeEvent(QCloseEvent *pEvent)
TYSilosEditor * _pSilosEditor
Editor pour la construction de silos.
virtual void distriSrcs()
Definition: TYBatiment.cpp:132
bool updateAcoustic(TYElement *pElement)
Appelle la methode de calcul acoustique du volume node passe.
TYElement * getParent() const
Definition: TYElement.h:699
virtual QString getName() const
Definition: TYElement.h:684
Construit un etage a partir des points saisis.
Definition: TYEtageEditor.h:51
Classe generique pour une fenetre de modeleur.
int _curViewType
Le type de la vue courante.
bool _editorModeAccepted
Indique si le mode d'edition a ete traite.
LPTYElement _pElement
Un pointeur sur l'element a editer.
TYRenderWindowInteractor * getView()
TYAbstractSceneEditor * _pCurrentEditor
L'editor courant.
void setGridLinesActorsVisibility(bool showGridXY, bool showGridXZ, bool showGridZY)
void aboutToClose()
QBoxLayout * _pCtrlLayout
Le layout ou se trouvent les boutons, etc.
virtual void setViewType(int view)
TYRenderWindowInteractor * _pView
La fenetre graphique.
void frameResized()
virtual bool close()
float _gridDimX
Dimension de la grille en X.
float _gridDimY
Dimension de la grille en Y.
OGLCamera * _pOGLCameras[NbOfViews]
Les cameras pour chaque type de vue.
float _gridStep
Pas de la grille.
virtual void updatePreferences()
float _gridMagnStep
Pas de la grille magnetique.
TYPickEditor * getPickEditor()
virtual void setEditorMode(int mode)
void updateDisplayList(void)
void setElement(LPTYElement pElt)
void usePopup(bool state)
Definition: TYPickEditor.h:104
void useHighlight(bool state)
Definition: TYPickEditor.h:97
TYOpenGLRenderer * getRenderer()
gestion de l'edition d'un silo
Definition: TYSilosEditor.h:36
gestion de l'edition d'une source