Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYFaceModelerFrame.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 <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 
52  _pCtrlLayout->addStretch(1);
53 
54  // QPushButton * pButtonOK = new QPushButton(TR("id_ok_btn"), this);
55  // QObject::connect(pButtonOK, &QPushButton::clicked, this, &TYFaceModelerFrame:: accept);
56  //_pCtrlLayout->addWidget(pButtonOK);
57 
58  //_pViewTypeBox->setEnabled(false);
59 
60  // Vue de dessus
62 
63  // Rectangle Editor
65 
66  // Le pick editor
67  delete _pPickEditor;
70 
71  // Cadrage
76 
77  // Attribution de la face a editer
78  if (pFace)
79  {
80  setFace(pFace);
81  }
82  else
83  {
85  }
86 
88 
89  showMaximized();
90 }
91 
93 {
94  _nbInstance--;
95 
96  if (_pFace)
97  {
98  _pFace->drawGraphic(false);
99  }
100 
101  delete _pRectangleEditor;
102  getView()->updateGL();
103 }
104 
106 {
107  return TYModelerFrame::close();
108 }
109 
111 {
112  if (_pFace)
113  {
114  _pFace->drawGraphic(false);
115  }
116 
117  _pFace = pFace;
118 
119  if (_pFace)
120  {
121  // On affiche la face
122  _pFace->drawGraphic();
123 
124  // On recadre
125  fit();
126  }
127 
128  _pElement = _pFace;
129 
131 
133 
135 }
136 
138 {
139  if (!_editorModeAccepted)
140  {
141  getPickEditor()->usePopup(true);
142  getPickEditor()->useHighlight(false);
143 
144  if (_pCurrentEditor)
145  {
148  }
149 
150  _editorModeAccepted = true;
151 
152  switch (mode)
153  {
154  case BoucheMode:
157  break;
158  case ChemineeMode:
161  break;
162  case FenetreMode:
165  break;
166  default:
167  _editorModeAccepted = false;
168  }
169  }
170 
172 }
173 
175 {
176  if (ok)
177  {
178  }
179  else
180  {
181  }
182 
183  close();
185  false,
186  false); // az++ : permet de rafraichir le modeler machine & de site apres avoir ajoute une/des faces
187 }
188 
190 {
191  done(true);
192 }
193 
195 {
196  done(false);
197 }
198 
200 {
201  // Grille
202  _gridDimX = 20.0f;
203  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "GridDimXFace"))
204  {
205  _gridDimX = TYPreferenceManager::getFloat(TYDIRPREFERENCEMANAGER, "GridDimXFace");
206  }
207  else
208  {
209  TYPreferenceManager::setFloat(TYDIRPREFERENCEMANAGER, "GridDimXFace", _gridDimX);
210  }
211 
212  _gridDimY = 20.0f;
213  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "GridDimYFace"))
214  {
215  _gridDimY = TYPreferenceManager::getFloat(TYDIRPREFERENCEMANAGER, "GridDimYFace");
216  }
217  else
218  {
219  TYPreferenceManager::setFloat(TYDIRPREFERENCEMANAGER, "GridDimYFace", _gridDimY);
220  }
221 
222  _gridStep = 1.0f;
223  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "GridStepFace"))
224  {
225  _gridStep = TYPreferenceManager::getFloat(TYDIRPREFERENCEMANAGER, "GridStepFace");
226  }
227  else
228  {
229  TYPreferenceManager::setFloat(TYDIRPREFERENCEMANAGER, "GridStepFace", _gridStep);
230  }
231 
232  _gridMagnStep = 1.0f;
233  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "GridMagnStepFace"))
234  {
235  _gridMagnStep = TYPreferenceManager::getFloat(TYDIRPREFERENCEMANAGER, "GridMagnStepFace");
236  }
237  else
238  {
239  TYPreferenceManager::setFloat(TYDIRPREFERENCEMANAGER, "GridMagnStepFace", _gridMagnStep);
240  }
242 
243  resizeGrid();
246  (_curViewType == LeftView));
247 
249 }
250 
252 {
253  if (_pFace)
254  {
255  // Activation des outils selon le type de la face
256  if (dynamic_cast<TYMur*>(_pFace._pObj) != nullptr)
257  {
258  // Les sous-faces sont des fenetres
262  }
263  else
264  {
265  // Les sous-faces sont des bouches ou cheminees
269  }
270  }
271  else
272  {
273  // Desactive tous les outils
275  }
276 }
277 
278 void TYFaceModelerFrame::focusInEvent(QFocusEvent* pEvent)
279 {
282 }
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:52
#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:835
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()
virtual void setEditorMode(int mode)
TYRectangleEditor * _pRectangleEditor
Rectangle editor.
TYFaceModelerFrame(LPTYAcousticRectangleNode pFace=0, QWidget *parent=0, const char *name=0, Qt::WindowFlags f=QFlag(0))
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:89
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)
virtual void focusInEvent(QFocusEvent *pEvent)
QBoxLayout * _pCtrlLayout
Le layout ou se trouvent les boutons, etc.
virtual void setViewType(int view)
TYRenderWindowInteractor * _pView
La fenetre graphique.
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()
TYPickEditor * _pPickEditor
Gere le menu contextuel.
float _gridMagnStep
Pas de la grille magnetique.
TYPickEditor * getPickEditor()
virtual void setEditorMode(int mode)
Definition: TYMur.h:36
void updateDisplayList(void)
void setElement(LPTYElement pElt)
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)
virtual void updateGL()
TYOpenGLRenderer * getRenderer()