Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYModelerFrame.h
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 
27 #ifndef __TY_MODELER_FRAME__
28 #define __TY_MODELER_FRAME__
29 
30 #include <qwidget.h>
31 // Added by qt3to4:
32 #include <QCloseEvent>
33 #include <QBoxLayout>
34 #include <QShowEvent>
35 #include <QWheelEvent>
36 #include <QResizeEvent>
37 #include <QGridLayout>
38 #include <QFocusEvent>
39 #include <QMouseEvent>
40 #include <QKeyEvent>
41 #include <QEvent>
42 
43 #include "TYAppDefines.h"
45 #include "TYActionManager.h"
47 
48 class QGridLayout;
49 class QBoxLayout;
50 class QComboBox;
51 class QStatusBar;
52 class QToolButton;
53 class OGLTextElement;
55 class OGLLineElement;
56 class OGLGridElement;
57 class OGLLightElement;
58 class OGLCamera;
59 
64 class TYModelerFrame : public QWidget
65 {
66  Q_OBJECT
67 
68 public:
78  {
84  NbOfViews
85  };
86 
91  {
99  };
100 
105  {
106  NoMode = -1,
114  };
115 
119  TYModelerFrame(QWidget* parent = 0, const char* name = 0, Qt::WindowFlags f = Qt::SubWindow);
123  virtual ~TYModelerFrame();
124 
129  {
130  return _pView;
131  }
132 
137  {
138  return _pView->getRenderer();
139  }
140 
145  {
146  return _curViewType;
147  }
148 
153  {
154  return _curRenderMode;
155  }
156 
163  {
164  return _pPicker;
165  }
170  {
171  return _pPickEditor;
172  }
173 
178  {
179  return _pCurrentEditor;
180  }
181 
186  {
187  return _pCameraEditor;
188  }
189 
193  QStatusBar* statusBar()
194  {
195  return _pStatusBar;
196  }
197 
202  {
203  return _snapGridActive;
204  }
205 
210  {
211  return &_actionManager;
212  }
213 
218  {
219  return _showSources;
220  }
221 
225  bool getShowGrid()
226  {
227  return _showGrid;
228  }
229 
237  {
239  }
240 
244  void setElement(LPTYElement pElement)
245  {
246  _pElement = pElement;
247  }
252  {
253  return _pElement;
254  }
255 
270  bool askForResetResultat();
271 
278  virtual bool computeCurPos(int x, int y, float* pos);
279 
280 public slots:
284  virtual void setViewType(int view);
285 
289  virtual void setRenderModeSlot(int mode);
290 
294  virtual void setRenderMode(int mode, bool bUpdateGL);
295 
299  virtual void setEditorMode(int mode);
304  {
306  }
307 
311  void showGrid(bool show);
312 
317  void showNormals(bool show);
318 
323  void showPlafond(bool show);
324 
328  void showSources();
329 
333  void showRays(bool show);
337  void setSnapGridActive(bool state);
338 
342  void setCameraCoordinates();
343 
348  void screenShot();
349 
357  virtual void updateView(bool clipping = true, bool axesAndGrid = true);
358 
363  void updateAxes();
364 
368  void updateCurPosInfo();
369 
373  void updateGrid();
374 
381  void updateElementGraphic(bool force = false);
382 
386  void print();
387 
392  void copy();
393 
397  void editElement();
398 
403  void fit();
404 
408  virtual void updatePreferences();
409 
413  void resizeGrid();
414 
419  virtual bool close();
420 
427  void setWireframeOnMovingCamera(bool state)
428  {
429  _wireframeOnMovingCamera = state;
430  }
431 
438  void startMovingRenderMode();
445  void stopMovingRenderMode();
446 
450  void updateScale();
451 
455  void showScale(bool show);
456 
460  static double getDouble(const QString& title, const QString& txt, double min, double max, double val,
461  bool& ok, int dec = 2);
462 
463 signals:
467  void aboutToClose();
468 
472  void viewTypeChanged(int);
473 
477  void editorModeChanged(int mode);
478 
483 
487  void mouseEnter();
488 
492  void mouseLeave();
493 
498  void frameResized();
499 
500 protected:
501  virtual void keyPressEvent(QKeyEvent* pEvent);
502  virtual void keyReleaseEvent(QKeyEvent* pEvent);
503  virtual void mouseMoveEvent(QMouseEvent* pEvent);
504  virtual void wheelEvent(QWheelEvent* pEvent);
505  virtual void resizeEvent(QResizeEvent* pEvent);
506  virtual void focusInEvent(QFocusEvent* pEvent);
507  virtual void showEvent(QShowEvent* pEvent);
508  virtual void closeEvent(QCloseEvent* pEvent);
509  virtual void enterEvent(QEvent* pEvent);
510  virtual void leaveEvent(QEvent* pEvent);
511 
515  void setGridLinesActorsVisibility(bool showGridXY, bool showGridXZ, bool showGridZY);
516 
518 
519 private:
521  QGridLayout* _pLayout;
522 
524  QComboBox* _pRenderModeBox;
525 
527  QToolButton* _pSnapGridBtn;
528 
531 
533  QToolButton* _pScreenShotBtn;
534 
536  QToolButton* _pShowSourcesBtn;
537 
540 
542  QToolButton* _pShowNormalsBtn;
543 
546 
548  QToolButton* _pShowPlafondBtn;
549 
552 
554  QToolButton* _pShowRaysBtn;
555 
557  bool _showRays;
558 
560  QStatusBar* _pStatusBar;
561 
564 
567 
570 
573 
576 
579 
582 
585 
588 
591 
599 
601  QToolButton* _pGridBtn;
602 
606 
608  bool _showGrid;
609 
612 
615 
616  // Les collections de lignes pour la grille.
618 
621 
623  QToolButton* _pShowScale;
624 
627 
629 
630 protected:
632  QBoxLayout* _pCtrlLayout;
633 
635  QComboBox* _pViewTypeBox;
636 
639 
642 
645 
648 
651 
654 
656  float _gridStep;
660  float _gridDimX;
662  float _gridDimY;
663 
666 
669 };
670 
671 #endif //__TY_MODELER_FRAME__
Gere les undos (fichier header)
#define min(a, b)
Le role de cette classe est limite a emettre des signaux pouvant etre utilise pour interagir sur le r...
const char * name
The box class.
Definition: 3d.h:1294
Classe abstraite pour la gestion de l'interaction entre la vue graphique (2D ou 3D) et le clavier et ...
Gere les undos.
Gestion de l'edition en mode camera.
gestion de zoom par zone selectionnee (obsolete)
outil de mesure des distances
gestion des elements selectionnes par picking
Classe generique pour une fenetre de modeleur.
virtual void wheelEvent(QWheelEvent *pEvent)
QToolButton * _pSnapGridBtn
Bouton d'activation de la grille magnetique.
void setSnapGridActive(bool state)
virtual void closeEvent(QCloseEvent *pEvent)
void updateElementGraphic(bool force=false)
virtual void leaveEvent(QEvent *pEvent)
int _curViewType
Le type de la vue courante.
QStatusBar * _pStatusBar
Barre d'etat.
LPTYElement getElement()
virtual bool computeCurPos(int x, int y, float *pos)
bool getWireframeOnMovingCamera()
TYCameraEditor * _pCameraEditor
Gere la camera.
void showScale(bool show)
bool _editorModeAccepted
Indique si le mode d'edition a ete traite.
OGLScalarBarElement * _pOGLScalarBarElement
Objet graphique pour la representation de l'echelle.
QToolButton * _pShowRaysBtn
Bouton pour l'affichage des rayons calcules par le lance de rayons.
virtual void setRenderModeSlot(int mode)
LPTYElement _pElement
Un pointeur sur l'element a editer.
void showPlafond(bool show)
TYRenderWindowInteractor * getView()
QToolButton * _pShowScale
Bouton pour l'affichage de l'echelle.
virtual void enterEvent(QEvent *pEvent)
TYPositionEditor * _pPositionEditor
Editor pour deplacer les elements.
void setEditorModeToCamera()
TYCameraZoneEditor * _pCameraZoneEditor
Editor pour definir une zone de zoom pour la camera.
OGLTextElement * _pOGLTextElement
Label 2D pour afficher le type de la vue.
virtual void resizeEvent(QResizeEvent *pEvent)
TYAbstractSceneEditor * _pCurrentEditor
L'editor courant.
virtual ~TYModelerFrame()
void editorModeChanged(int mode)
OGLLineElement * _pOGLLineElementAxeX
La geometrie des Axes.
void setGridLinesActorsVisibility(bool showGridXY, bool showGridXZ, bool showGridZY)
QToolButton * _pShowPlafondBtn
Bouton pour l'affichage des normals.
void showRays(bool show)
void viewTypeChanged(int)
virtual void setRenderMode(int mode, bool bUpdateGL)
bool _wireframeOnMovingCamera
Indique si on passe en rendu wireframe lors de deplacement de camera.
QToolButton * _pShowNormalsBtn
Bouton pour l'affichage des normals.
TYElementPicker * getElementPicker()
virtual void focusInEvent(QFocusEvent *pEvent)
bool _snapGridActive
Indique si on active ou non la grille magnetique.
void setWireframeOnMovingCamera(bool state)
int _lastRenderMode
Le dernier mode de rendu courant.
TYActionManager _actionManager
Pour la gestion de l'historique.
void aboutToClose()
OGLLightElement * _pLightElement
La lumiere par default.
bool getSnapGridActive()
QBoxLayout * _pCtrlLayout
Le layout ou se trouvent les boutons, etc.
virtual void mouseMoveEvent(QMouseEvent *pEvent)
QGridLayout * _pLayout
Le layout de cette frame.
void setElement(LPTYElement pElement)
QToolButton * _pShowSourcesBtn
Bouton pour l'affichage des sources ponctuelles.
OGLTextElement * _pOGLTextElementLabelY
virtual void setViewType(int view)
TYActionManager * getActionManager()
OGLLineElement * _pOGLLineElementX
Axes X et Y de la grille.
QStatusBar * statusBar()
QToolButton * _pGridBtn
Bouton d'activation de la grille.
bool isElementInCurrentProjet()
OGLGridElement * _pOGLGridElement
TYRenderWindowInteractor * _pView
La fenetre graphique.
void frameResized()
virtual bool close()
bool _showPlafond
Indique si on affiche ou masque les normals.
void showNormals(bool show)
OGLLineElement * _pOGLLineElementAxeZ
QComboBox * _pRenderModeBox
Combo box pour le mode de rendu.
OGLTextElement * _pOGLTextElementLabelX
bool _showGrid
Indique si on affiche ou non la grille.
TYModelerFrame(QWidget *parent=0, const char *name=0, Qt::WindowFlags f=Qt::SubWindow)
bool _showNormals
Indique si on affiche ou masque les normals.
void setCameraCoordinates()
OGLTextElement * _pOGLTextElementLabelZ
bool isElementInCurrentCalcul()
bool askForResetResultat()
bool _showScale
Indique si on affiche ou pas l'echelle.
void eltModified(LPTYElement pElt)
int _lastEditorMode
Pour conserver le dernier mode d'edition.
TYCameraEditor * getCameraEditor()
QToolButton * _pSetCameraCoordinatesBtn
Bouton de specification des coordonnees de la camera.
int _curRenderMode
Le mode de rendu courant.
OGLLineElement * _pOGLLineElementAxeY
float _gridDimX
Dimension de la grille en X.
float _gridDimY
Dimension de la grille en Y.
void startMovingRenderMode()
TYElementPicker * _pPicker
Pour le picking.
OGLCamera * _pOGLCameras[NbOfViews]
Les cameras pour chaque type de vue.
float _gridStep
Pas de la grille.
virtual void updatePreferences()
bool _showRays
Indique si on affiche ou pas les rayons.
TYPickEditor * _pPickEditor
Gere le menu contextuel.
OGLLineElement * _pOGLLineElementY
float _gridMagnStep
Pas de la grille magnetique.
QToolButton * _pScreenShotBtn
Bouton pour effectuer une capture d'ecran.
TYPickEditor * getPickEditor()
virtual void keyPressEvent(QKeyEvent *pEvent)
TYAbstractSceneEditor * getCurrentEditor()
TYDistanceEditor * _pDistanceEditor
Outils pour mesurer.
virtual void setEditorMode(int mode)
void showGrid(bool show)
virtual void updateView(bool clipping=true, bool axesAndGrid=true)
virtual void showEvent(QShowEvent *pEvent)
virtual void keyReleaseEvent(QKeyEvent *pEvent)
static double getDouble(const QString &title, const QString &txt, double min, double max, double val, bool &ok, int dec=2)
TYOpenGLRenderer * getRenderer()
bool _showSources
Indique si on affiche ou pas les sources ponctuelles.
QComboBox * _pViewTypeBox
Combo box pour la selection de la camera courante.
Realise le rendu VTK et le rendu OpenGL.
gestion de l'element actionne par picking
Definition: TYPickEditor.h:40
gestion de la position selon les modes 'moving', 'rotation', 'edition'
Le role de cette classe est limite a emettre des signaux pouvant etre utilise pour interagir sur le r...
TYOpenGLRenderer * getRenderer()