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  : TYAbstractSceneEditor(pModeler, pCameraEditor)
39 {
40  _active = false;
41 
43 }
44 
46 
48 
49 void TYPointCalculEditor::slotMouseReleased(int x, int y, Qt::MouseButton button, Qt::KeyboardModifiers state)
50 {
51  if ((button == Qt::LeftButton) && _active)
52  {
53  LPTYProjet pProjet = NULL;
54 
55  if (getTYApp()->getCurProjet())
56  {
57  pProjet = getTYApp()->getCurProjet();
58  }
59 
60  if (pProjet)
61  {
63  {
64  // Hauteur pour ce point de controle
65  bool ok = false;
66  double hauteur =
67  TYModelerFrame::getDouble("", TR("id_msg_gethauteur"), -1000.0, 1000.0, 2.0, ok);
68 
69  if (ok)
70  {
71  double point[4];
72  LPTYPointControl pPointControl = new TYPointControl();
73 
74  // Pos
75  displayToWorld(x, _pInteractor->getViewport().height() - y, 0.0, point);
76 
77  // Si la grille magnetique est activee
79  {
80  snapToGrid(point[0], point[1], point[2], _gridMagnStep);
81  }
82 
83  // Init point
84  pPointControl->setHauteur(hauteur);
85  pPointControl->setFromOGL(point);
86  pPointControl->_z = 0.0 + _pModeler->getDefaultZCoord();
87 
88  // Action
89  TYAction* pAction = new TYAddPointControlAction(pProjet, pPointControl, _pModeler,
90  TR("id_action_addptcalcul"));
92 
93  // Ajout
94  pProjet->addPointControl(pPointControl);
95  pProjet->updateGraphicTree();
100  }
101  }
102  }
103  else
104  {
105  // Msg "Pas de projet..."
106  QString msg(TR("id_warning_no_curcalcul"));
107  writeOutputMsg(msg);
108  QMessageBox::warning(_pModeler, "Tympan", msg, QMessageBox::Ok, QMessageBox::NoButton);
109  }
110  }
111 }
112 
114 {
115  if (view == TYModelerFrame::TopView)
116  {
117  _active = true;
118  }
119  else
120  {
121  _active = false;
122  }
123 }
124 
125 void TYPointCalculEditor::slotWheeled(int x, int y, int delta, Qt::KeyboardModifiers state)
126 {
127  _pCameraEditor->slotWheeled(x, y, delta, state);
128 }
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
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.
TYCameraEditor * _pCameraEditor
Le caméra editor associé Ã&#160; cet éditor.
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.
Gestion de l'edition en mode camera.
virtual void slotWheeled(int x, int y, int delta, Qt::KeyboardModifiers state)
static void setIsSavedOk(const bool &toSave)
Definition: TYElement.h:905
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)
void invalidateScene(void)
virtual void slotWheeled(int x, int y, int delta, Qt::KeyboardModifiers state)
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, TYCameraEditor *pCameraEditor)
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:427
const TYRenderViewport & getViewport() const
TYOpenGLRenderer * getRenderer()
Classe Modeler specialisee pour l'edition des sites.