Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYAbstractSceneEditor.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 
30 #include "TYAbstractSceneEditor.h"
31 
32 #define IMG(id) OLocalizator::getPicture("TYAbstractSceneEditor", (id))
33 
35 {
36  Q_CHECK_PTR(pModeler);
37  _pModeler = pModeler;
38  _gridMagnStep = 1.0;
40 
41  // Text
45  _pOGLTextElement->setFont(IMG("id_font"));
48 }
49 
51 {
53  delete _pOGLTextElement;
54 }
55 
57 {
59 }
60 
62 {
64 }
65 
67 {
69 }
71 {
72  // Connections...
79  QObject::connect(_pInteractor, &TYRenderWindowInteractor::mouseMoved, this,
81  QObject::connect(_pInteractor, &TYRenderWindowInteractor::wheeled, this,
83  QObject::connect(_pInteractor, &TYRenderWindowInteractor::keyPressed, this,
85  QObject::connect(_pInteractor, &TYRenderWindowInteractor::keyReleased, this,
87  QObject::connect(_pModeler, &TYModelerFrame::viewTypeChanged, this,
91 
92  float r = 94.0f, g = 110.0f, b = 255.0f;
93 
94  // Couleur de la police
95  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "FontColorR"))
96  {
97  TYPreferenceManager::getColor(TYDIRPREFERENCEMANAGER, "FontColor", r, g, b);
98  }
99  else
100  {
101  TYPreferenceManager::setColor(TYDIRPREFERENCEMANAGER, "FontColor", r, g, b);
102  }
103 
104  OColor oColor;
105  oColor.r = r / 255.0f;
106  oColor.g = g / 255.0f;
107  oColor.b = b / 255.0f;
108  _pOGLTextElement->setColor(oColor);
109 
110  // Update du type de vue actif
112 }
113 
115 {
116  // Deconnections...
117  QObject::disconnect(_pInteractor, &TYRenderWindowInteractor::mousePressed, this,
119  QObject::disconnect(_pInteractor, &TYRenderWindowInteractor::mouseReleased, this,
123  QObject::disconnect(_pInteractor, &TYRenderWindowInteractor::mouseMoved, this,
125  QObject::disconnect(_pInteractor, &TYRenderWindowInteractor::wheeled, this,
127  QObject::disconnect(_pInteractor, &TYRenderWindowInteractor::keyPressed, this,
129  QObject::disconnect(_pInteractor, &TYRenderWindowInteractor::keyReleased, this,
131  QObject::disconnect(_pModeler, &TYModelerFrame::viewTypeChanged, this,
135 }
136 
137 void TYAbstractSceneEditor::updateText(QString msg, int posX, int posY, bool show)
138 {
141 
142  if (show)
143  {
145  }
146 }
147 
149 {
151 }
152 
153 void TYAbstractSceneEditor::displayToWorld(double x, double y, double z, double* worldPoint)
154 {
155  NxVec3 ret = OGLCamera::displayToWorld(NxVec3(x, y, z));
156  worldPoint[0] = ret.x;
157  worldPoint[1] = ret.y;
158  worldPoint[2] = ret.z;
159 }
160 
161 void TYAbstractSceneEditor::worldToDisplay(double x, double y, double z, double* displayPoint)
162 {
163  NxVec3 ret = OGLCamera::worldToDisplay(NxVec3(x, y, z));
164  displayPoint[0] = ret.x;
165  displayPoint[1] = ret.y;
166  displayPoint[2] = ret.z;
167 }
168 
169 void TYAbstractSceneEditor::snapToGrid(float& x, float& y, float& z, float& gridMagnStep)
170 {
171  x = ROUND(x / gridMagnStep) * gridMagnStep;
172  y = ROUND(y / gridMagnStep) * gridMagnStep;
173  z = ROUND(z / gridMagnStep) * gridMagnStep;
174 }
175 
176 void TYAbstractSceneEditor::snapToGrid(double& x, double& y, double& z, double& gridMagnStep)
177 {
178  x = ROUND(x / gridMagnStep) * gridMagnStep;
179  y = ROUND(y / gridMagnStep) * gridMagnStep;
180  z = ROUND(z / gridMagnStep) * gridMagnStep;
181 }
182 
184 {
185  _gridMagnStep = gridMagnStep;
186 }
int ROUND(double a)
Compute the rounded value of a number.
Definition: 3d.h:192
#define IMG(id)
gestion de l'interaction entre la vue graphique (2D ou 3D) et le clavier et la souris (fichier header...
TYMainWindow * getTYMainWnd()
Retourne le pointeur sur la fenetre principale.
pour l'application Tympan (fichier header)
#define TYDIRPREFERENCEMANAGER
Definition: TYElement.h:52
Fenetre principale de l'application Tympan (fichier header)
Classe generique pour une fenetre de modeleur (fichier header)
Frame pour la gestion de projet (fichier header)
Le role de cette classe est limite a emettre des signaux pouvant etre utilise pour interagir sur le r...
Frame pour la gestion de site (fichier header)
Definition: NxVec3.h:23
NxReal z
Definition: NxVec3.h:80
NxReal y
Definition: NxVec3.h:80
NxReal x
Definition: NxVec3.h:80
Definition: color.h:31
float b
Definition: color.h:33
float r
Definition: color.h:33
float g
Definition: color.h:33
static NxVec3 displayToWorld(NxVec3 display)
Definition: OGLCamera.cpp:699
static NxVec3 worldToDisplay(NxVec3 world)
Definition: OGLCamera.cpp:722
void setVisibility(bool bVisible)
Definition: OGLElement.h:51
void setDisplayPosition(double displayPositionX, double displayPositionY)
Definition: OGLElement.h:46
void setColor(const OColor &oColor)
void setTextToDisplay(const QString &qsText)
void setFont(const QString &qsFontPath)
double _gridMagnStep
Pas de la grille magnétique de positionnement.
void refreshSiteFrame()
Rafraichit l'arborescence du TYSiteFrame.
virtual void slotViewTypeChanged(int view)
La vue courante du modeler a change.
void worldToDisplay(double x, double y, double z, double *displayPoint)
Methode utilitaire pour convertir un point en coordonnees globale en coordonnees ecran.
static void snapToGrid(float &x, float &y, float &z, float &gridMagnStep)
Methode utilitaire qui adapte les coordonnees d'un point pour que celui-ci soit aligne avec la grille...
virtual void disconnect()
Deconnecte cet editor a l'interactor associe.
void refreshProjectFrame()
Rafraichit l'arborescence du TYProjectFrame.
void updateText(QString msg="", int posX=0, int posY=0, bool show=true)
Mets a jour le texte informatif sur la vue 3D.
OGLTextElement * _pOGLTextElement
Affichage du texte 2D sur la vue 3D.
void updateSiteFrame()
Reconstruit l'arborescence du TYSiteFrame.
virtual void slotMouseLeave()
Le curseur de souris est sortie dans la widget.
virtual void slotMousePressed(int x, int y, Qt::MouseButton button, Qt::KeyboardModifiers state)
Une touche de la souris a ete enfoncee.
virtual void slotWheeled(int x, int y, int delta, Qt::KeyboardModifiers state)
La molette de la souris a ete utilisee.
virtual void slotMouseDoubleClicked(int x, int y, Qt::MouseButton button, Qt::KeyboardModifiers state)
Une touche de la souris a ete double clickee.
TYAbstractSceneEditor(TYModelerFrame *pModeler)
Constructeur par defaut.
TYModelerFrame * _pModeler
Le modeler associe a cet editor.
void displayToWorld(double x, double y, double z, double *worldPoint)
Methode utilitaire pour convertir un point en coordonnees ecran en coordonnees globale.
virtual void slotMouseReleased(int x, int y, Qt::MouseButton button, Qt::KeyboardModifiers state)
Une touche de la souris a ete relachee.
virtual void connect()
Connecte cet editor a l'interactor associe.
virtual void slotMouseEnter()
Le curseur de souris est entree dans la widget.
virtual void slotKeyPressed(int key)
Une touche a ete relachee.
virtual ~TYAbstractSceneEditor()
Destructeur.
void setGridMagnStep(float gridMagnStep=1.0)
Met Ã&#160; jour le pas de la grille magnétique.
void showText(bool show=true)
Affiche ou pas le texte informatif sur la vue 3D.
virtual void slotMouseMoved(int x, int y, Qt::MouseButtons button, Qt::KeyboardModifiers state)
La souris a ete deplacee.
virtual void slotKeyReleased(int key)
Une touche a ete relachee.
TYRenderWindowInteractor * _pInteractor
La vue graphique associee a cet editor.
TYProjetFrame * getProjetFrame()
Definition: TYMainWindow.h:76
TYSiteFrame * getSiteFrame()
Definition: TYMainWindow.h:80
Classe generique pour une fenetre de modeleur.
TYRenderWindowInteractor * getView()
void viewTypeChanged(int)
void addOGLElement(OGLElement *pOGLElement)
void removeOGLElement(OGLElement *pOGLElement)
void mouseMoved(int x, int y, Qt::MouseButtons button, Qt::KeyboardModifiers state)
void mouseDoubleClicked(int x, int y, Qt::MouseButton button, Qt::KeyboardModifiers state)
void keyPressed(int key)
void wheeled(int x, int y, int delta, Qt::KeyboardModifiers state)
void mousePressed(int x, int y, Qt::MouseButton button, Qt::KeyboardModifiers state)
void mouseReleased(int x, int y, Qt::MouseButton button, Qt::KeyboardModifiers state)
void keyReleased(int key)
TYOpenGLRenderer * getRenderer()
void updateList()