Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYPointCalculEditor.cpp
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 
21 #include <qmessagebox.h>
22 #include <qinputdialog.h>
23 
32 #include "TYPointCalculEditor.h"
33 #include "TYCameraEditor.h"
34 
35 #define TR(id) OLocalizator::getString("TYPointCalculEditor", (id))
36 
38 {
39  _active = false;
40 
42 }
43 
45 
47 
48 void TYPointCalculEditor::slotMouseReleased(int x, int y, Qt::MouseButton button, Qt::KeyboardModifiers state)
49 {
50  if ((button == Qt::LeftButton) && _active)
51  {
52  LPTYProjet pProjet = NULL;
53 
54  if (getTYApp()->getCurProjet())
55  {
56  pProjet = getTYApp()->getCurProjet();
57  }
58 
59  if (pProjet)
60  {
62  {
63  // Hauteur pour ce point de controle
64  bool ok = false;
65  double hauteur =
66  TYModelerFrame::getDouble("", TR("id_msg_gethauteur"), -1000.0, 1000.0, 2.0, ok);
67 
68  if (ok)
69  {
70  double point[4];
71  LPTYPointControl pPointControl = new TYPointControl();
72 
73  // Pos
74  displayToWorld(x, _pInteractor->getViewport().height() - y, 0.0, point);
75 
76  // Si la grille magnetique est activee
78  {
79  snapToGrid(point[0], point[1], point[2], _gridMagnStep);
80  }
81 
82  // Init point
83  pPointControl->setHauteur(hauteur);
84  pPointControl->setFromOGL(point);
85  pPointControl->_z = 0.0 + _pModeler->getDefaultZCoord();
86 
87  // Action
88  TYAction* pAction = new TYAddPointControlAction(pProjet, pPointControl, _pModeler,
89  TR("id_action_addptcalcul"));
91 
92  // Ajout
93  pProjet->addPointControl(pPointControl);
94  pProjet->updateGraphicTree();
99  }
100  }
101  }
102  else
103  {
104  // Msg "Pas de projet..."
105  QString msg(TR("id_warning_no_curcalcul"));
106  writeOutputMsg(msg);
107  QMessageBox::warning(_pModeler, "Tympan", msg, QMessageBox::Ok, QMessageBox::NoButton);
108  }
109  }
110 }
111 
113 {
114  if (view == TYModelerFrame::TopView)
115  {
116  _active = true;
117  }
118  else
119  {
120  _active = false;
121  }
122 }
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)
gestion de l'edition de la camera (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
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:876
LPTYProjet getCurProjet()
Set/Get du projet courant.
static void setIsSavedOk(const bool &toSave)
Definition: TYElement.h:914
TYRenderWindowInteractor * getView()
bool getSnapGridActive()
TYActionManager * getActionManager()
virtual float getDefaultZCoord()
Returns default Z coordinate for editors This value will depend on the type of modeler and of the fix...
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)
Super-class for editors performing object construction.
void invalidateScene(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:448
const TYRenderViewport & getViewport() const
TYOpenGLRenderer * getRenderer()
Classe Modeler specialisee pour l'edition des sites.