Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYBatimentModelerFrame.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 <qlayout.h>
22 #include <qcursor.h>
23 #include <qmessagebox.h>
24 
33 #include "TYBatimentModelerFrame.h"
34 
35 #define TR(id) OLocalizator::getString("TYBatimentModelerFrame", (id))
36 #define IMG(id) OLocalizator::getPicture("TYSiteModelerFrame", (id))
37 
39 
40 TYBatimentModelerFrame::TYBatimentModelerFrame(LPTYBatiment pBatiment, QWidget* parent, const char* name,
41  Qt::WindowFlags f)
42  : TYModelerFrame(parent, name, f)
43 {
44  _nbInstance++;
45  setWindowTitle(TR("id_caption") + " " + QString("%1").arg(_nbInstance));
46 
47  _pCtrlLayout->addSpacing(10);
48 
50  _pCtrlLayout->addStretch(1);
51  // Editors
52  _pEtageEditor = new TYEtageEditor(this);
53  _pSilosEditor = new TYSilosEditor(this);
54  _pSourceEditor = new TYSourceEditor(this);
55 
56  // Cadrage
61 
62  if (pBatiment)
63  {
64  setBatiment(pBatiment);
65  }
66  else
67  {
68  setBatiment(new TYBatiment());
69  }
70 
71  // Vue de dessus
74 }
75 
77 {
78  _nbInstance--;
79 
80  if (_pBatiment)
81  {
82  _pBatiment->drawGraphic(false);
83  }
84 
85  delete _pEtageEditor;
86  delete _pSilosEditor;
87  delete _pSourceEditor;
88 }
89 
91 {
93  bool ret = true;
94  if (_pBatiment->getNbChild() > 0)
95  {
96  ret = TYModelerFrame::close();
97  }
98  getView()->update();
99  return ret;
100 }
101 
103 {
104  QString caption(TR("id_caption") + " " + QString("%1").arg(_nbInstance));
105 
106  if (_pBatiment)
107  {
108  // On recherche si ce batiment fait parti d'un site
109  if (_pBatiment->getParent())
110  {
112  if (pSite)
113  {
114  // Dans ce cas on supprime le plan de masse du site
115 #ifdef _DEBUG
116  // getRenderer()->RemoveActor(pSite->getGraphicObject()->getProp());//az-- : revoir (ne devait
117  // pas marcher en OpenGL)
118 #endif
119  }
120  }
121 
122  _pBatiment->drawGraphic(false);
123  }
124 
125  _pBatiment = pBatiment;
126 
127  if (_pBatiment)
128  {
129  if (!_pBatiment->getName().isEmpty())
130  {
131  caption += QString(" : %1").arg(_pBatiment->getName());
132  }
133 
134  // On affiche le batiment
135  _pBatiment->drawGraphic();
136 
137  // On recherche si ce batiment fait parti d'un site
138  if (_pBatiment->getParent())
139  {
141  if (pSite)
142  {
143  // Dans ce cas on affiche le plan de masse du site
144  // getRenderer()->AddActor(pSite->getGraphicObject()->getActor()); // Mise en
145  // Commentaire DT le 08/07/03
146  }
147  }
148  }
149 
151  setWindowTitle(caption);
152 
154 }
155 
157 {
158  if (!_editorModeAccepted)
159  {
160  getPickEditor()->usePopup(true);
161  getPickEditor()->useHighlight(false);
162 
163  if (_pCurrentEditor)
164  {
167  }
168 
169  _editorModeAccepted = true;
170 
171  switch (mode)
172  {
173  case EtageMode:
175  break;
176  case SilosMode:
178  break;
179  // case MachineMode:
180  // _pDataBaseEditor->setElementTypeName("TYMachine");
181  // _pCurrentEditor = _pDataBaseEditor;
182  // break;
183  case SourceMode:
185  break;
186  default:
187  _editorModeAccepted = false;
188  }
189  }
190 
192 }
193 
194 void TYBatimentModelerFrame::closeEvent(QCloseEvent* pEvent)
195 {
196  TYPreferenceManager::saveGeometryToPreferences(metaObject()->className(), this);
197  // If there is no volume in the modeler
198  if (_pBatiment->getNbChild() == 0)
199  {
200  // Displaying a warning message
201  QMessageBox::StandardButton msgBox =
202  QMessageBox::warning(this, "", "Le modeleur est vide. Etes-vous sûr de vouloir le fermer ?",
203  QMessageBox::Yes | QMessageBox::No);
204  switch (msgBox)
205  {
206  // The user aborts the closing event
207  case QMessageBox::No:
208  pEvent->ignore();
209  break;
210  // The user ignores the warning
211  case QMessageBox::Yes:
212  emit frameResized();
213  emit aboutToClose();
214  break;
215  default:
216  pEvent->ignore();
217  return;
218  }
219  }
220  // If there are volumes, the signal is emited and the event accepted
221  else
222  {
223  pEvent->accept();
224  emit frameResized();
225  emit aboutToClose();
226  }
227 }
228 
230 {
231  if (_pBatiment)
232  {
234  }
235 }
236 
238 {
239  // Grille
240  _gridDimX = 100.0f;
241  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "GridDimXBatiment"))
242  {
243  _gridDimX = TYPreferenceManager::getFloat(TYDIRPREFERENCEMANAGER, "GridDimXBatiment");
244  }
245  else
246  {
247  TYPreferenceManager::setFloat(TYDIRPREFERENCEMANAGER, "GridDimXBatiment", _gridDimX);
248  }
249 
250  _gridDimY = 100.0f;
251  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "GridDimYBatiment"))
252  {
253  _gridDimY = TYPreferenceManager::getFloat(TYDIRPREFERENCEMANAGER, "GridDimYBatiment");
254  }
255  else
256  {
257  TYPreferenceManager::setFloat(TYDIRPREFERENCEMANAGER, "GridDimYBatiment", _gridDimY);
258  }
259 
260  _gridStep = 5.0f;
261  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "GridStepBatiment"))
262  {
263  _gridStep = TYPreferenceManager::getFloat(TYDIRPREFERENCEMANAGER, "GridStepBatiment");
264  }
265  else
266  {
267  TYPreferenceManager::setFloat(TYDIRPREFERENCEMANAGER, "GridStepBatiment", _gridStep);
268  }
269 
270  _gridMagnStep = 2.0f;
271  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "GridMagnStepBatiment"))
272  {
273  _gridMagnStep = TYPreferenceManager::getFloat(TYDIRPREFERENCEMANAGER, "GridMagnStepBatiment");
274  }
275  else
276  {
277  TYPreferenceManager::setFloat(TYDIRPREFERENCEMANAGER, "GridMagnStepBatiment", _gridMagnStep);
278  }
282 
283  resizeGrid();
286  (_curViewType == LeftView));
287 
289 }
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 TR(id)
Modeler specialisee pour l'edition des batiments (fichier header)
#define TYDIRPREFERENCEMANAGER
Definition: TYElement.h:51
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:453
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
TYBatimentModelerFrame(LPTYBatiment pBatiment=0, QWidget *parent=0, const char *name=0, Qt::WindowFlags f=Qt::SubWindow)
Constructeur par defaut.
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.
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:706
virtual QString getName() const
Definition: TYElement.h:691
Construit un etage a partir des points saisis.
Definition: TYEtageEditor.h:51
Generic class for a modeler window.
int _curViewType
The type of the current view.
bool _editorModeAccepted
Indicates if the editing mode has been processed.
LPTYElement _pElement
A pointer to the element to edit.
TYRenderWindowInteractor * getView()
TYAbstractSceneEditor * _pCurrentEditor
The current editor.
void setGridLinesActorsVisibility(bool showGridXY, bool showGridXZ, bool showGridZY)
void aboutToClose()
QBoxLayout * _pCtrlLayout
The layout where buttons, etc., are located.
virtual void setViewType(int view)
void frameResized()
virtual bool close()
float _gridDimX
Grid dimension in X.
float _gridDimY
Grid dimension in Y.
OGLCamera * _pOGLCameras[NbOfViews]
Cameras for each type of view.
float _gridStep
Grid step.
virtual void updatePreferences()
float _gridMagnStep
Magnetic grid step.
TYPickEditor * getPickEditor()
virtual void setEditorMode(int mode)
void invalidateScene(void)
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