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  if (_pFace)
98  {
99  _pFace->drawGraphic(false);
100  }
101 
102  delete _pRectangleEditor;
103  getView()->update();
104 }
105 
107 {
108  return TYModelerFrame::close();
109 }
110 
112 {
113  if (_pFace)
114  {
115  _pFace->drawGraphic(false);
116  }
117 
118  _pFace = pFace;
119 
120  if (_pFace)
121  {
122  // On affiche la face
123  _pFace->drawGraphic();
124 
125  // On recadre
126  fit();
127  }
128 
129  _pElement = _pFace;
130 
132 
134 }
135 
137 {
138  if (!_editorModeAccepted)
139  {
140  getPickEditor()->usePopup(true);
141  getPickEditor()->useHighlight(false);
142 
143  if (_pCurrentEditor)
144  {
147  }
148 
149  _editorModeAccepted = true;
150 
151  switch (mode)
152  {
153  case BoucheMode:
156  break;
157  case ChemineeMode:
160  break;
161  case FenetreMode:
164  break;
165  default:
166  _editorModeAccepted = false;
167  }
168  }
169 
171 }
172 
174 {
175  if (ok)
176  {
177  }
178  else
179  {
180  }
181 
182  close();
184  false,
185  false); // az++ : permet de rafraichir le modeler machine & de site apres avoir ajoute une/des faces
186 }
187 
189 {
190  done(true);
191 }
192 
194 {
195  done(false);
196 }
197 
199 {
200  // Grille
201  _gridDimX = 20.0f;
202  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "GridDimXFace"))
203  {
204  _gridDimX = TYPreferenceManager::getFloat(TYDIRPREFERENCEMANAGER, "GridDimXFace");
205  }
206  else
207  {
208  TYPreferenceManager::setFloat(TYDIRPREFERENCEMANAGER, "GridDimXFace", _gridDimX);
209  }
210 
211  _gridDimY = 20.0f;
212  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "GridDimYFace"))
213  {
214  _gridDimY = TYPreferenceManager::getFloat(TYDIRPREFERENCEMANAGER, "GridDimYFace");
215  }
216  else
217  {
218  TYPreferenceManager::setFloat(TYDIRPREFERENCEMANAGER, "GridDimYFace", _gridDimY);
219  }
220 
221  _gridStep = 1.0f;
222  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "GridStepFace"))
223  {
224  _gridStep = TYPreferenceManager::getFloat(TYDIRPREFERENCEMANAGER, "GridStepFace");
225  }
226  else
227  {
228  TYPreferenceManager::setFloat(TYDIRPREFERENCEMANAGER, "GridStepFace", _gridStep);
229  }
230 
231  _gridMagnStep = 1.0f;
232  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "GridMagnStepFace"))
233  {
234  _gridMagnStep = TYPreferenceManager::getFloat(TYDIRPREFERENCEMANAGER, "GridMagnStepFace");
235  }
236  else
237  {
238  TYPreferenceManager::setFloat(TYDIRPREFERENCEMANAGER, "GridMagnStepFace", _gridMagnStep);
239  }
241 
242  resizeGrid();
245  (_curViewType == LeftView));
246 
248 }
249 
251 {
252  if (_pFace)
253  {
254  // Activation des outils selon le type de la face
255  if (dynamic_cast<TYMur*>(_pFace._pObj) != nullptr)
256  {
257  // Les sous-faces sont des fenetres
261  }
262  else
263  {
264  // Les sous-faces sont des bouches ou cheminees
268  }
269  }
270  else
271  {
272  // Desactive tous les outils
274  }
275 }
276 
277 void TYFaceModelerFrame::focusInEvent(QFocusEvent* pEvent)
278 {
281 }
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()