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 #include "gui/gl/TYRenderContext.h"
49 
50 class QGridLayout;
51 class QBoxLayout;
52 class QComboBox;
53 class QStatusBar;
54 class QToolButton;
55 class OGLTextElement;
57 class OGLLineElement;
58 class OGLGridElement;
59 class OGLLightElement;
60 class OGLCamera;
61 
66 class TYModelerFrame : public QWidget
67 {
68  Q_OBJECT
69 
70 public:
80  {
89  NbOfViews
90  };
91 
96  {
97  NoMode = -1,
105  };
106 
110  TYModelerFrame(QWidget* parent = 0, const char* name = 0, Qt::WindowFlags f = Qt::SubWindow);
114  virtual ~TYModelerFrame();
115 
120  {
121  return _pView;
122  }
123 
128  {
129  return _pView->getRenderer();
130  }
131 
136  {
137  return _curViewType;
138  }
139 
144  {
145  return getRenderer()->getRenderMode();
146  }
147 
154  {
155  return _pPicker;
156  }
161  {
162  return _pPickEditor;
163  }
164 
169  {
170  return _pCurrentEditor;
171  }
172 
177  {
178  return _pCameraEditor;
179  }
180 
184  QStatusBar* statusBar()
185  {
186  return _pStatusBar;
187  }
188 
193  {
194  return _snapGridActive;
195  }
196 
201  {
202  return &_actionManager;
203  }
204 
209  {
210  return _showSources;
211  }
212 
216  bool getShowGrid()
217  {
218  return _showGrid;
219  }
220 
227  {
229  }
230 
234  void setElement(LPTYElement pElement)
235  {
236  _pElement = pElement;
237  }
242  {
243  return _pElement;
244  }
245 
260  bool askForResetResultat();
261 
267  virtual bool computeCurPos(int x, int y, float* pos);
268 
276  virtual float getDefaultZCoord();
277 
283  void setDefaultZCoord(float fDefaultZCoord)
284  {
285  _defaultZCoord = fDefaultZCoord;
286  }
287 
288 public slots:
292  virtual void setViewType(int view);
293 
297  virtual void setRenderModeSlot(int mode);
298 
302  virtual void setRenderMode(TYOpenGLRenderer::RenderMode mode, bool bUpdateGL);
303 
307  virtual void setEditorMode(int mode);
312  {
314  }
315 
319  void showGrid(bool show);
320 
325  void showNormals(bool show);
326 
331  void showPlafond(bool show);
332 
336  void showSources();
337 
341  void showRays(bool show);
342 
346  void setKeepRays(bool keepRays);
347 
351  void setSnapGridActive(bool state);
352 
356  void setCameraCoordinates();
357 
362  void screenShot();
363 
371  virtual void updateView(bool clipping = true, bool axesAndGrid = true);
372 
377  void updateAxes();
378 
382  void updateCurPosInfo(int x, int y);
383 
387  void updateGrid();
388 
395  void updateElementGraphic(bool force = false);
396 
400  void print();
401 
406  void copy();
407 
411  void editElement();
412 
417  void fit();
418 
422  virtual void updatePreferences();
423 
427  void resizeGrid();
428 
433  virtual bool close();
434 
440  void setWireframeOnMovingCamera(bool state)
441  {
442  _wireframeOnMovingCamera = state;
443  }
444 
450  void startMovingRenderMode();
456  void stopMovingRenderMode();
457 
461  void updateScale();
462 
466  void showScale(bool show);
467 
471  static double getDouble(const QString& title, const QString& txt, double min, double max, double val,
472  bool& ok, int dec = 2);
473 
475 
476 signals:
480  void aboutToClose();
481 
485  void viewTypeChanged(int);
486 
490  void editorModeChanged(int mode);
491 
496 
500  void mouseEnter();
501 
505  void mouseLeave();
506 
511  void frameResized();
512 
513 protected:
514  virtual void keyPressEvent(QKeyEvent* pEvent);
515  virtual void keyReleaseEvent(QKeyEvent* pEvent);
516  virtual void mouseMoveEvent(QMouseEvent* pEvent);
517  virtual void wheelEvent(QWheelEvent* pEvent);
518  virtual void resizeEvent(QResizeEvent* pEvent);
519  virtual void focusInEvent(QFocusEvent* pEvent);
520  virtual void showEvent(QShowEvent* pEvent);
521  virtual void closeEvent(QCloseEvent* pEvent);
522  virtual void enterEvent(QEvent* pEvent);
523  virtual void leaveEvent(QEvent* pEvent);
524 
528  void setGridLinesActorsVisibility(bool showGridXY, bool showGridXZ, bool showGridZY);
529 
531 
532  void addScreenShotBtn();
533 
536 
537 private:
539  QGridLayout* _pLayout;
540 
542  QComboBox* _pRenderModeBox;
543 
545  QToolButton* _pSnapGridBtn;
546 
549 
551  QToolButton* _pShowSourcesBtn;
552 
555 
557  QToolButton* _pShowNormalsBtn;
558 
561 
563  QToolButton* _pShowPlafondBtn;
564 
567 
569  QToolButton* _pShowRaysBtn;
570 
572  bool _showRays;
573 
575  QStatusBar* _pStatusBar;
576 
579 
582 
585 
588 
591 
594 
597 
600 
608 
610  QToolButton* _pGridBtn;
611 
615 
617  bool _showGrid;
618 
621 
624 
625  // Collections of lines for the grid.
627 
630 
632  QToolButton* _pShowScale;
633 
636 
638 
639 protected:
641  QBoxLayout* _pCtrlLayout;
642 
644  QComboBox* _pViewTypeBox;
645 
648 
651 
654 
657 
660 
663 
665  float _gridStep;
669  float _gridDimX;
671  float _gridDimY;
672 
675 
677  QToolButton* _pScreenShotBtn;
678 
680  QToolButton* _pCopyBtn;
681 
684 
687 };
688 
689 #endif //__TY_MODELER_FRAME__
Gere les undos (fichier header)
#define min(a, b)
Realise le rendu VTK et le rendu OpenGL (fichier header)
Contexte de rendu utilisé par les fonctions d'affichage.
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
virtual TYRenderContext createRenderContext()
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()