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 <qpushbutton.h>
24 #include <qmessagebox.h>
25 
34 #include "TYBatimentModelerFrame.h"
35 
36 #define TR(id) OLocalizator::getString("TYBatimentModelerFrame", (id))
37 #define IMG(id) OLocalizator::getPicture("TYSiteModelerFrame", (id))
38 
40 
41 TYBatimentModelerFrame::TYBatimentModelerFrame(LPTYBatiment pBatiment, QWidget* parent, const char* name,
42  Qt::WindowFlags f)
43  : TYModelerFrame(parent, name, f)
44 {
45  _nbInstance++;
46  setWindowTitle(TR("id_caption") + " " + QString("%1").arg(_nbInstance));
47 
48  _pCtrlLayout->addSpacing(10);
49 
50  // Btn Calculer
51  QPushButton* pCalculBtn =
52  new QPushButton(QPixmap(IMG("id_icon_calculalti_btn")), "", /*TR("id_calcul_btn"),*/ this);
53  pCalculBtn->setFixedSize(24, 24);
54  _pCtrlLayout->addWidget(pCalculBtn, 0);
55  connect(pCalculBtn, &QPushButton::clicked, this, &TYBatimentModelerFrame::calculDistribution);
56 
58  _pCtrlLayout->addStretch(1);
59  // Editors
60  _pEtageEditor = new TYEtageEditor(this);
61  _pSilosEditor = new TYSilosEditor(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  getView()->update();
107  return ret;
108 }
109 
111 {
112  QString caption(TR("id_caption") + " " + QString("%1").arg(_nbInstance));
113 
114  if (_pBatiment)
115  {
116  // On recherche si ce batiment fait parti d'un site
117  if (_pBatiment->getParent())
118  {
120  if (pSite)
121  {
122  // Dans ce cas on supprime le plan de masse du site
123 #ifdef _DEBUG
124  // getRenderer()->RemoveActor(pSite->getGraphicObject()->getProp());//az-- : revoir (ne devait
125  // pas marcher en OpenGL)
126 #endif
127  }
128  }
129 
130  _pBatiment->drawGraphic(false);
131  }
132 
133  _pBatiment = pBatiment;
134 
135  if (_pBatiment)
136  {
137  if (!_pBatiment->getName().isEmpty())
138  {
139  caption += QString(" : %1").arg(_pBatiment->getName());
140  }
141 
142  // On affiche le batiment
143  _pBatiment->drawGraphic();
144 
145  // On recherche si ce batiment fait parti d'un site
146  if (_pBatiment->getParent())
147  {
149  if (pSite)
150  {
151  // Dans ce cas on affiche le plan de masse du site
152  // getRenderer()->AddActor(pSite->getGraphicObject()->getActor()); // Mise en
153  // Commentaire DT le 08/07/03
154  }
155  }
156  }
157 
159  setWindowTitle(caption);
160 
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: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.
TYCameraEditor * _pCameraEditor
Manages the camera.
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