Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYFaceModelerFrame.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 <qcombobox.h>
22 #include <qlayout.h>
23 #include <qtoolbutton.h>
24 #include <qpushbutton.h>
25 // Added by qt3to4:
26 #include <QFocusEvent>
27 
38 #include "TYFaceModelerFrame.h"
39 
40 #define TR(id) OLocalizator::getString("TYFaceModelerFrame", (id))
41 #define IMG(id) OLocalizator::getPicture("TYFaceModelerFrame", (id))
42 
44 
46  Qt::WindowFlags f)
47  : TYModelerFrame(parent, name, f)
48 {
49  _nbInstance++;
50  setWindowTitle(TR("id_caption") + " " + QString("%1").arg(_nbInstance));
51 
53  _pCtrlLayout->addStretch(1);
54 
55  // QPushButton * pButtonOK = new QPushButton(TR("id_ok_btn"), this);
56  // QObject::connect(pButtonOK, &QPushButton::clicked, this, &TYFaceModelerFrame:: accept);
57  //_pCtrlLayout->addWidget(pButtonOK);
58 
59  //_pViewTypeBox->setEnabled(false);
60 
61  // Vue de dessus
63 
64  // Rectangle Editor
66 
67  // Le pick editor
68  delete _pPickEditor;
71 
72  // Cadrage
77 
78  // Attribution de la face a editer
79  if (pFace)
80  {
81  setFace(pFace);
82  }
83  else
84  {
86  }
87 
89 
90  showMaximized();
91 }
92 
94 {
95  _nbInstance--;
96 
97  delete _pRectangleEditor;
98  getView()->update();
99 }
100 
102 {
103  return TYModelerFrame::close();
104 }
105 
107 {
108  if (_pFace)
109  {
110  _pFace->drawGraphic(false);
111  }
112 
113  _pFace = pFace;
114 
115  if (_pFace)
116  {
117  // On affiche la face
118  _pFace->drawGraphic();
119 
120  // On recadre
121  fit();
122  }
123 
124  _pElement = _pFace;
125 
127 
129 }
130 
132 {
133  if (!_editorModeAccepted)
134  {
135  getPickEditor()->usePopup(true);
136  getPickEditor()->useHighlight(false);
137 
138  if (_pCurrentEditor)
139  {
142  }
143 
144  _editorModeAccepted = true;
145 
146  switch (mode)
147  {
148  case BoucheMode:
151  break;
152  case ChemineeMode:
155  break;
156  case FenetreMode:
159  break;
160  default:
161  _editorModeAccepted = false;
162  }
163  }
164 
166 }
167 
169 {
170  if (ok)
171  {
172  }
173  else
174  {
175  }
176 
177  close();
179  false,
180  false); // az++ : permet de rafraichir le modeler machine & de site apres avoir ajoute une/des faces
181 }
182 
184 {
185  done(true);
186 }
187 
189 {
190  done(false);
191 }
192 
194 {
195  // Grille
196  _gridDimX = 20.0f;
197  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "GridDimXFace"))
198  {
199  _gridDimX = TYPreferenceManager::getFloat(TYDIRPREFERENCEMANAGER, "GridDimXFace");
200  }
201  else
202  {
203  TYPreferenceManager::setFloat(TYDIRPREFERENCEMANAGER, "GridDimXFace", _gridDimX);
204  }
205 
206  _gridDimY = 20.0f;
207  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "GridDimYFace"))
208  {
209  _gridDimY = TYPreferenceManager::getFloat(TYDIRPREFERENCEMANAGER, "GridDimYFace");
210  }
211  else
212  {
213  TYPreferenceManager::setFloat(TYDIRPREFERENCEMANAGER, "GridDimYFace", _gridDimY);
214  }
215 
216  _gridStep = 1.0f;
217  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "GridStepFace"))
218  {
219  _gridStep = TYPreferenceManager::getFloat(TYDIRPREFERENCEMANAGER, "GridStepFace");
220  }
221  else
222  {
223  TYPreferenceManager::setFloat(TYDIRPREFERENCEMANAGER, "GridStepFace", _gridStep);
224  }
225 
226  _gridMagnStep = 1.0f;
227  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "GridMagnStepFace"))
228  {
229  _gridMagnStep = TYPreferenceManager::getFloat(TYDIRPREFERENCEMANAGER, "GridMagnStepFace");
230  }
231  else
232  {
233  TYPreferenceManager::setFloat(TYDIRPREFERENCEMANAGER, "GridMagnStepFace", _gridMagnStep);
234  }
236 
237  resizeGrid();
240  (_curViewType == LeftView));
241 
243 }
244 
246 {
247  if (_pFace)
248  {
249  // Activation des outils selon le type de la face
250  if (dynamic_cast<TYMur*>(_pFace._pObj) != nullptr)
251  {
252  // Les sous-faces sont des fenetres
256  }
257  else
258  {
259  // Les sous-faces sont des bouches ou cheminees
263  }
264  }
265  else
266  {
267  // Desactive tous les outils
269  }
270 }
271 
272 void TYFaceModelerFrame::focusInEvent(QFocusEvent* pEvent)
273 {
276 }
gestion de l'interaction entre la vue graphique (2D ou 3D) et le clavier et la souris (fichier header...
Representation graphique d'un ensemble de rectangles acoustiques (fichier header)
TYMainWindow * getTYMainWnd()
Retourne le pointeur sur la fenetre principale.
pour l'application Tympan (fichier header)
#define TYDIRPREFERENCEMANAGER
Definition: TYElement.h:51
#define TR(id)
Classe Modeler specialisee pour l'edition des faces (fichier header)
gestion du picking des faces (fichier header)
Barre d'outils Face (fichier header)
Fenetre principale de l'application Tympan (fichier header)
gestion de l'element actionne par picking (fichier header)
gestion de l'edition d'un rectangle (fichier header)
const char * name
void setDefaultZoomFactor(double defaultZoomFactor)
Definition: OGLCamera.cpp:453
T * _pObj
The real pointer, must derived IRefCount.
Definition: smartptr.h:307
virtual void close()
Appeler apres l'utilisation de l'editor.
virtual void disconnect()
Deconnecte cet editor a l'interactor associe.
virtual void connect()
Connecte cet editor a l'interactor associe.
void setGridMagnStep(float gridMagnStep=1.0)
Met Ã&#160; jour le pas de la grille magnétique.
void focusInEvent(QFocusEvent *pEvent)
virtual void updatePreferences()
TYFaceModelerFrame(LPTYAcousticRectangleNode pFace=0, QWidget *parent=0, const char *name=0, Qt::WindowFlags f=Qt::SubWindow)
virtual void setEditorMode(int mode)
TYRectangleEditor * _pRectangleEditor
Rectangle editor.
static int _nbInstance
Nombre d'instance de type TYFaceModelerFrame.
void setFace(LPTYAcousticRectangleNode pFace)
LPTYAcousticRectangleNode _pFace
Un pointeur sur la face a decouper.
gestion du picking des faces
void activeCheminee(bool active)
void activeFenetre(bool active)
void activeBouche(bool active)
void activeButtons(bool active)
Active/Desactive chaque boutons.
void updateModelers(bool clipping=true, bool axesAndGrid=true, bool displayList=true)
TYFaceToolbar * getFaceToolbar()
Definition: TYMainWindow.h:86
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)
virtual void focusInEvent(QFocusEvent *pEvent)
QBoxLayout * _pCtrlLayout
The layout where buttons, etc., are located.
virtual void setViewType(int view)
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()
TYPickEditor * _pPickEditor
Manages the context menu.
float _gridMagnStep
Magnetic grid step.
TYPickEditor * getPickEditor()
virtual void setEditorMode(int mode)
Definition: TYMur.h:36
void invalidateScene(void)
void usePopup(bool state)
Definition: TYPickEditor.h:104
void useHighlight(bool state)
Definition: TYPickEditor.h:97
gestion de l'edition d'un rectangle
void setMode(int mode)
TYOpenGLRenderer * getRenderer()