Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYModelerFrame.h
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 
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"
48 
49 class QGridLayout;
50 class QBoxLayout;
51 class QComboBox;
52 class QStatusBar;
53 class QToolButton;
54 class OGLTextElement;
56 class OGLLineElement;
57 class OGLGridElement;
58 class OGLLightElement;
59 class OGLCamera;
60 
65 class TYModelerFrame : public QWidget
66 {
67  Q_OBJECT
68 
69 public:
79  {
88  NbOfViews
89  };
90 
95  {
96  NoMode = -1,
104  };
105 
109  TYModelerFrame(QWidget* parent = 0, const char* name = 0, Qt::WindowFlags f = Qt::SubWindow);
113  virtual ~TYModelerFrame();
114 
119  {
120  return _pView;
121  }
122 
127  {
128  return _pView->getRenderer();
129  }
130 
135  {
136  return _curViewType;
137  }
138 
143  {
144  return getRenderer()->getRenderMode();
145  }
146 
153  {
154  return _pPicker;
155  }
160  {
161  return _pPickEditor;
162  }
163 
168  {
169  return _pCurrentEditor;
170  }
171 
176  {
177  return _pCameraEditor;
178  }
179 
183  QStatusBar* statusBar()
184  {
185  return _pStatusBar;
186  }
187 
192  {
193  return _snapGridActive;
194  }
195 
200  {
201  return &_actionManager;
202  }
203 
208  {
209  return _showSources;
210  }
211 
215  bool getShowGrid()
216  {
217  return _showGrid;
218  }
219 
226  {
228  }
229 
233  void setElement(LPTYElement pElement)
234  {
235  _pElement = pElement;
236  }
241  {
242  return _pElement;
243  }
244 
259  bool askForResetResultat();
260 
266  virtual bool computeCurPos(int x, int y, float* pos);
267 
275  virtual float getDefaultZCoord();
276 
282  void setDefaultZCoord(float fDefaultZCoord)
283  {
284  _defaultZCoord = fDefaultZCoord;
285  }
286 
287 public slots:
291  virtual void setViewType(int view);
292 
296  virtual void setRenderModeSlot(int mode);
297 
301  virtual void setRenderMode(TYOpenGLRenderer::RenderMode mode, bool bUpdateGL);
302 
306  virtual void setEditorMode(int mode);
311  {
313  }
314 
318  void showGrid(bool show);
319 
324  void showNormals(bool show);
325 
330  void showPlafond(bool show);
331 
335  void showSources();
336 
340  void showRays(bool show);
341 
345  void setKeepRays(bool keepRays);
346 
350  void setSnapGridActive(bool state);
351 
355  void setCameraCoordinates();
356 
361  void screenShot();
362 
370  virtual void updateView(bool clipping = true, bool axesAndGrid = true);
371 
376  void updateAxes();
377 
381  void updateCurPosInfo(int x, int y);
382 
386  void updateGrid();
387 
394  void updateElementGraphic(bool force = false);
395 
399  void print();
400 
405  void copy();
406 
410  void editElement();
411 
416  void fit();
417 
421  virtual void updatePreferences();
422 
426  void resizeGrid();
427 
432  virtual bool close();
433 
439  void setWireframeOnMovingCamera(bool state)
440  {
441  _wireframeOnMovingCamera = state;
442  }
443 
449  void startMovingRenderMode();
455  void stopMovingRenderMode();
456 
460  void updateScale();
461 
465  void showScale(bool show);
466 
470  static double getDouble(const QString& title, const QString& txt, double min, double max, double val,
471  bool& ok, int dec = 2);
472 
473 signals:
477  void aboutToClose();
478 
482  void viewTypeChanged(int);
483 
487  void editorModeChanged(int mode);
488 
493 
497  void mouseEnter();
498 
502  void mouseLeave();
503 
508  void frameResized();
509 
510 protected:
511  virtual void keyPressEvent(QKeyEvent* pEvent);
512  virtual void keyReleaseEvent(QKeyEvent* pEvent);
513  virtual void mouseMoveEvent(QMouseEvent* pEvent);
514  virtual void wheelEvent(QWheelEvent* pEvent);
515  virtual void resizeEvent(QResizeEvent* pEvent);
516  virtual void focusInEvent(QFocusEvent* pEvent);
517  virtual void showEvent(QShowEvent* pEvent);
518  virtual void closeEvent(QCloseEvent* pEvent);
519  virtual void enterEvent(QEvent* pEvent);
520  virtual void leaveEvent(QEvent* pEvent);
521 
525  void setGridLinesActorsVisibility(bool showGridXY, bool showGridXZ, bool showGridZY);
526 
528 
529  void addScreenShotBtn();
530 
533 
534 private:
536  QGridLayout* _pLayout;
537 
539  QComboBox* _pRenderModeBox;
540 
542  QToolButton* _pSnapGridBtn;
543 
546 
548  QToolButton* _pShowSourcesBtn;
549 
552 
554  QToolButton* _pShowNormalsBtn;
555 
558 
560  QToolButton* _pShowPlafondBtn;
561 
564 
566  QToolButton* _pShowRaysBtn;
567 
569  bool _showRays;
570 
572  QStatusBar* _pStatusBar;
573 
576 
579 
582 
585 
588 
591 
594 
597 
605 
607  QToolButton* _pGridBtn;
608 
612 
614  bool _showGrid;
615 
618 
621 
622  // Collections of lines for the grid.
624 
627 
629  QToolButton* _pShowScale;
630 
633 
635 
636 protected:
638  QBoxLayout* _pCtrlLayout;
639 
641  QComboBox* _pViewTypeBox;
642 
645 
648 
651 
654 
657 
660 
662  float _gridStep;
666  float _gridDimX;
668  float _gridDimY;
669 
672 
674  QToolButton* _pScreenShotBtn;
675 
677  QToolButton* _pCopyBtn;
678 
681 
684 };
685 
686 #endif //__TY_MODELER_FRAME__
Gere les undos (fichier header)
#define min(a, b)
Realise le rendu VTK et le rendu OpenGL (fichier header)
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:1346
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
Generic class for a modeler window.
virtual void wheelEvent(QWheelEvent *pEvent)
QToolButton * _pSnapGridBtn
Button to activate the magnetic grid.
void setSnapGridActive(bool state)
virtual void closeEvent(QCloseEvent *pEvent)
void updateElementGraphic(bool force=false)
virtual void leaveEvent(QEvent *pEvent)
int _curViewType
The type of the current view.
QStatusBar * _pStatusBar
Status bar.
LPTYElement getElement()
virtual bool computeCurPos(int x, int y, float *pos)
bool getWireframeOnMovingCamera()
TYCameraEditor * _pCameraEditor
Manages the camera.
void showScale(bool show)
bool _editorModeAccepted
Indicates if the editing mode has been processed.
OGLScalarBarElement * _pOGLScalarBarElement
Graphic object for representing the scale.
QToolButton * _pShowRaysBtn
Button for displaying rays calculated by ray tracing.
virtual void setRenderModeSlot(int mode)
LPTYElement _pElement
A pointer to the element to edit.
void showPlafond(bool show)
TYRenderWindowInteractor * getView()
QToolButton * _pShowScale
Button for displaying the scale.
virtual void enterEvent(QEvent *pEvent)
TYPositionEditor * _pPositionEditor
Editor for moving elements.
void setEditorModeToCamera()
TYCameraZoneEditor * _pCameraZoneEditor
Editor to define a zoom area for the camera.
OGLTextElement * _pOGLTextElement
2D label to display the type of view.
virtual void resizeEvent(QResizeEvent *pEvent)
TYAbstractSceneEditor * _pCurrentEditor
The current editor.
void setKeepRays(bool keepRays)
virtual ~TYModelerFrame()
void editorModeChanged(int mode)
OGLLineElement * _pOGLLineElementAxeX
Geometry of the Axes.
void setGridLinesActorsVisibility(bool showGridXY, bool showGridXZ, bool showGridZY)
QToolButton * _pShowPlafondBtn
Button for displaying the ceiling of buildings.
void showRays(bool show)
void viewTypeChanged(int)
bool _wireframeOnMovingCamera
Indicates whether to switch to wireframe rendering during camera movement.
QToolButton * _pShowNormalsBtn
Button for displaying normals.
TYElementPicker * getElementPicker()
virtual void focusInEvent(QFocusEvent *pEvent)
bool _snapGridActive
Indicates whether or not to activate the magnetic grid.
void setWireframeOnMovingCamera(bool state)
TYActionManager _actionManager
For managing the history.
void aboutToClose()
OGLLightElement * _pLightElement
The default light.
bool getSnapGridActive()
QBoxLayout * _pCtrlLayout
The layout where buttons, etc., are located.
virtual void mouseMoveEvent(QMouseEvent *pEvent)
QGridLayout * _pLayout
The layout of this frame.
void setElement(LPTYElement pElement)
QToolButton * _pShowSourcesBtn
Button for displaying point sources.
OGLTextElement * _pOGLTextElementLabelY
virtual void setViewType(int view)
TYActionManager * getActionManager()
OGLLineElement * _pOGLLineElementX
X and Y axes of the grid.
QStatusBar * statusBar()
QToolButton * _pGridBtn
Button to activate the grid.
bool isElementInCurrentProjet()
void setDefaultZCoord(float fDefaultZCoord)
sets default Z coordinate for editors
OGLGridElement * _pOGLGridElement
TYRenderWindowInteractor * _pView
The graphics window.
void frameResized()
QToolButton * _pCopyBtn
Button for taking a screenshot.
virtual bool close()
virtual float getDefaultZCoord()
Returns default Z coordinate for editors This value will depend on the type of modeler and of the fix...
bool _showPlafond
Indicates whether or not to display or hide the ceiling of buildings.
void showNormals(bool show)
OGLLineElement * _pOGLLineElementAxeZ
QComboBox * _pRenderModeBox
Combo box for rendering mode.
OGLTextElement * _pOGLTextElementLabelX
TYOpenGLRenderer::RenderMode getRenderMode()
bool _showGrid
Indicates whether to display the grid or not.
TYModelerFrame(QWidget *parent=0, const char *name=0, Qt::WindowFlags f=Qt::SubWindow)
bool _showNormals
Indicates whether or not to display or hide normals.
void setCameraCoordinates()
OGLTextElement * _pOGLTextElementLabelZ
bool isElementInCurrentCalcul()
bool askForResetResultat()
bool _showScale
Indicates whether to display the scale or not.
void eltModified(LPTYElement pElt)
int _lastEditorMode
To keep track of the last editing mode.
TYCameraEditor * getCameraEditor()
QToolButton * _pSetCameraCoordinatesBtn
Button to specify camera coordinates.
TYOpenGLRenderer::RenderMode _lastRenderMode
The last current rendering mode.
OGLLineElement * _pOGLLineElementAxeY
void updateCurPosInfo(int x, int y)
float _gridDimX
Grid dimension in X.
float _gridDimY
Grid dimension in Y.
void startMovingRenderMode()
TYElementPicker * _pPicker
For picking.
virtual void setRenderMode(TYOpenGLRenderer::RenderMode mode, bool bUpdateGL)
OGLCamera * _pOGLCameras[NbOfViews]
Cameras for each type of view.
float _gridStep
Grid step.
virtual void updatePreferences()
bool _showRays
Indicates whether or not to display rays.
TYPickEditor * _pPickEditor
Manages the context menu.
OGLLineElement * _pOGLLineElementY
float _gridMagnStep
Magnetic grid step.
QToolButton * _pScreenShotBtn
Button for saving a screenshot.
TYPickEditor * getPickEditor()
virtual void keyPressEvent(QKeyEvent *pEvent)
TYAbstractSceneEditor * getCurrentEditor()
TYDistanceEditor * _pDistanceEditor
Tools for measuring.
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)
float _defaultZCoord
Default Z coordinate for editors.
TYOpenGLRenderer * getRenderer()
bool _showSources
Indicates whether or not to display point sources.
QComboBox * _pViewTypeBox
Combo box for selecting the current camera.
Realise le rendu VTK et le rendu OpenGL.
RenderMode getRenderMode()
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()