Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYPointCalculEditor.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 
21 #include <qmessagebox.h>
22 #include <qinputdialog.h>
23 
32 #include "TYPointCalculEditor.h"
33 
34 #define TR(id) OLocalizator::getString("TYPointCalculEditor", (id))
35 
37 {
38  _active = false;
39 
41 }
42 
44 
46 
47 void TYPointCalculEditor::slotMouseReleased(int x, int y, Qt::MouseButton button, Qt::KeyboardModifiers state)
48 {
49  if ((button == Qt::LeftButton) && _active)
50  {
51  LPTYProjet pProjet = NULL;
52 
53  if (getTYApp()->getCurProjet())
54  {
55  pProjet = getTYApp()->getCurProjet();
56  }
57 
58  if (pProjet)
59  {
61  {
62  // Hauteur pour ce point de controle
63  bool ok = false;
64  double hauteur =
65  TYModelerFrame::getDouble("", TR("id_msg_gethauteur"), -1000.0, 1000.0, 2.0, ok);
66 
67  if (ok)
68  {
69  double point[4];
70  LPTYPointControl pPointControl = new TYPointControl();
71 
72  // Pos
73  displayToWorld(x, _pInteractor->height() - y, 0.0, point);
74 
75  // Si la grille magnetique est activee
77  {
78  snapToGrid(point[0], point[1], point[2], _gridMagnStep);
79  }
80 
81  // Init point
82  pPointControl->setHauteur(hauteur);
83  pPointControl->setFromOGL(point);
84  pPointControl->_z = 0.0;
85 
86  // Action
87  TYAction* pAction = new TYAddPointControlAction(pProjet, pPointControl, _pModeler,
88  TR("id_action_addptcalcul"));
90 
91  // Ajout
92  pProjet->addPointControl(pPointControl);
93  pProjet->updateGraphicTree();
98  }
99  }
100  }
101  else
102  {
103  // Msg "Pas de projet..."
104  QString msg(TR("id_warning_no_curcalcul"));
105  writeOutputMsg(msg);
106  QMessageBox::warning(_pModeler, "Tympan", msg, QMessageBox::Ok, QMessageBox::NoButton);
107  }
108  }
109 }
110 
112 {
113  if (view == TYModelerFrame::TopView)
114  {
115  _active = true;
116  }
117  else
118  {
119  _active = false;
120  }
121 }
fichier contenant differents types d'actions (fichier header)
void writeOutputMsg(QString msg)
Affiche un message dans la fenetre de sortie.
TYApplication * getTYApp()
Retourne le pointeur sur l'application.
pour l'application Tympan (fichier header)
Classe generique pour une fenetre de modeleur (fichier header)
#define TR(id)
gestion de l'edition d'un point de calcul (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)
double _z
z coordinate of OCoord3D
Definition: 3d.h:284
virtual void setFromOGL(double x, double y, double z)
Definition: 3d.cpp:340
Classe abstraite pour la gestion de l'interaction entre la vue graphique (2D ou 3D) et le clavier et ...
double _gridMagnStep
Pas de la grille magnétique de positionnement.
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...
void refreshProjectFrame()
Rafraichit l'arborescence du TYProjectFrame.
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
Action d'ajout d'un point de controle.
Definition: TYActions.h:875
LPTYProjet getCurProjet()
Set/Get du projet courant.
static void setIsSavedOk(const bool &toSave)
Definition: TYElement.h:915
TYRenderWindowInteractor * getView()
bool getSnapGridActive()
TYActionManager * getActionManager()
bool askForResetResultat()
virtual void updateView(bool clipping=true, bool axesAndGrid=true)
static double getDouble(const QString &title, const QString &txt, double min, double max, double val, bool &ok, int dec=2)
void updateDisplayList(void)
virtual void slotMouseReleased(int x, int y, Qt::MouseButton button, Qt::KeyboardModifiers state)
virtual void slotViewTypeChanged(int view)
bool _active
Indique si cet editor est actif.
TYPointCalculEditor(TYSiteModelerFrame *pModeler)
Classe de definition d'un point de controle.Le point de controle est un point de calcul avec une haut...
void setHauteur(double hauteur)
Set de la hauteur de ce point par rapport au sol (a l'altimetrie en fait).
bool addPointControl(LPTYPointControl pPointControl)
Definition: TYProjet.cpp:394
TYOpenGLRenderer * getRenderer()
Classe Modeler specialisee pour l'edition des sites.