Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYOrientationEditor.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 
32 #include "TYOrientationEditor.h"
33 
34 #define TR(id) OLocalizator::getString("TYOrientationEditor", (id))
35 
37 {
38  _active = false;
39 
42  OColor oLineColor;
43  oLineColor.r = 1.0;
44  oLineColor.g = 0.0;
45  oLineColor.b = 0.0;
46  _pOGLLineElement->setColor(oLineColor);
47 
49 
51 }
52 
54 {
56  delete _pOGLLineElement;
57 }
58 
60 {
61  // Init seg a 0
62  _pOGLLineElement->setPoint1(OPoint3D(0.0, 0.0, 0.0));
63  _pOGLLineElement->setPoint2(OPoint3D(0.0, 0.0, 0.0));
64 }
65 
67 {
69  //_pOrientationActor->VisibilityOff();
71 }
72 
74 {
75  if (view == TYModelerFrame::TopView)
76  {
77  _active = true;
78  }
79  else
80  {
81  _active = false;
82  }
83 }
84 
85 void TYOrientationEditor::slotMousePressed(int x, int y, Qt::MouseButton button, Qt::KeyboardModifiers state)
86 {
87  if ((button == Qt::LeftButton) && _active)
88  {
89  _pOGLLineElement->setPoint1(OPoint3D(x, _pInteractor->height() - y, 0.0));
90  _pOGLLineElement->setPoint2(OPoint3D(x, _pInteractor->height() - y, 0.0));
91  }
92 }
93 
94 void TYOrientationEditor::slotMouseMoved(int x, int y, Qt::MouseButtons button, Qt::KeyboardModifiers state)
95 {
96  if ((button == Qt::LeftButton) && _active)
97  {
98  _pOGLLineElement->setPoint2(OPoint3D(x, _pInteractor->height() - y, 0.0));
100 
102  }
103 }
104 
105 void TYOrientationEditor::slotMouseReleased(int x, int y, Qt::MouseButton button, Qt::KeyboardModifiers state)
106 {
107  if ((button == Qt::LeftButton) && _active)
108  {
109  double point[4];
110  TYSegment segOrientation;
111  LPTYSiteNode pSite = ((TYSiteModelerFrame*)_pModeler)->getSite();
112 
113  // Pt 1
115  _pOGLLineElement->getPoint1()[2], point);
116  segOrientation._ptA.setFromOGL(point);
117 
118  // Pt 2
120  _pOGLLineElement->getPoint2()[2], point);
121  segOrientation._ptB.setFromOGL(point);
122 
123  TYAction* pAction = new TYSetOrientationSiteAction(pSite, pSite->getOrientation(), segOrientation,
124  _pModeler, TR("id_action_setorientation"));
125  _pModeler->getActionManager()->addAction(pAction);
126 
127  pSite->setOrientation(segOrientation);
128  pSite->updateGraphic();
129 
131 
133 
135 
136  // La scene a ete modifiee
138  }
139 }
fichier contenant differents types d'actions (fichier header)
Classe generique pour une fenetre de modeleur (fichier header)
#define TR(id)
edition de l'orientation (fichier header)
Le role de cette classe est limite a emettre des signaux pouvant etre utilise pour interagir sur le r...
Classe Modeler specialisee pour l'edition des sites (fichier header)
Definition: color.h:31
float b
Definition: color.h:33
float r
Definition: color.h:33
float g
Definition: color.h:33
void setVisibility(bool bVisible)
Definition: OGLElement.h:51
double * getPoint2()
void setPoint1(const OPoint3D &point1)
void setColor(const OColor &oColor)
double * getPoint1()
void setPoint2(const OPoint3D &point2)
The 3D point class.
Definition: 3d.h:487
virtual void setFromOGL(double x, double y, double z)
Definition: 3d.cpp:340
OPoint3D _ptA
Point A of the segment.
Definition: 3d.h:1201
OPoint3D _ptB
Point B of the segment.
Definition: 3d.h:1203
Classe abstraite pour la gestion de l'interaction entre la vue graphique (2D ou 3D) et le clavier et ...
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.
TYRenderWindowInteractor * _pInteractor
La vue graphique associee a cet editor.
void addAction(TYAction *pAction)
Ajoute une nouvelle action a l'historique.
Definit une action, necessaire pour la gestion de l'undo.
Definition: TYAction.h:37
static void setIsSavedOk(const bool &toSave)
Definition: TYElement.h:915
TYRenderWindowInteractor * getView()
TYActionManager * getActionManager()
virtual void updateView(bool clipping=true, bool axesAndGrid=true)
void updateDisplayList(void)
void addOGLElement(OGLElement *pOGLElement)
void removeOGLElement(OGLElement *pOGLElement)
virtual void slotMouseReleased(int x, int y, Qt::MouseButton button, Qt::KeyboardModifiers state)
bool _active
Indique si cet editor est actif.
virtual void slotMouseMoved(int x, int y, Qt::MouseButtons button, Qt::KeyboardModifiers state)
OGLLineElement * _pOGLLineElement
L'objet graphique representant l'orientation.
virtual void slotViewTypeChanged(int view)
virtual void slotMousePressed(int x, int y, Qt::MouseButton button, Qt::KeyboardModifiers state)
TYOrientationEditor(TYSiteModelerFrame *pModeler)
virtual void updateGL()
TYOpenGLRenderer * getRenderer()
Action d'orientation du site.
Definition: TYActions.h:794
Classe Modeler specialisee pour l'edition des sites.
void setOrientation(TYSegment seg)
Definition: TYSiteNode.h:294
TYSegment getOrientation() const
Definition: TYSiteNode.h:287