Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYSourceEditor.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 <qinputdialog.h>
22 
32 #include "TYSourceEditor.h"
33 #include "TYCameraEditor.h"
34 
35 #define TR(id) OLocalizator::getString("TYSourceEditor", (id))
36 
38 {
39  _active = false;
40 
42 }
43 
45 
47 
49 
51 {
52  if (view == TYModelerFrame::TopView)
53  {
54  _active = true;
55  }
56  else
57  {
58  _active = false;
59  }
60 }
61 
62 void TYSourceEditor::slotMousePressed(int x, int y, Qt::MouseButton button, Qt::KeyboardModifiers state)
63 {
64  if ((button == Qt::LeftButton) && _active)
65  {
66  }
67 }
68 
69 void TYSourceEditor::slotMouseMoved(int x, int y, Qt::MouseButtons button, Qt::KeyboardModifiers state)
70 {
71  if ((button == Qt::LeftButton) && _active)
72  {
73  }
74 }
75 
76 void TYSourceEditor::slotMouseReleased(int x, int y, Qt::MouseButton button, Qt::KeyboardModifiers state)
77 {
78  if ((button == Qt::LeftButton) && _active)
79  {
81  {
82  return;
83  }
84 
85  // Hauteur pour ce point de controle
86  bool ok = false;
87  double hauteur = TYModelerFrame::getDouble("", TR("id_msg_gethauteur"), -1000.0, 1000.0, 2.0, ok);
88 
89  if (ok)
90  {
91  double point[4];
93 
94  // Pos
95  displayToWorld(x, _pInteractor->getViewport().height() - y, 0.0, point);
96 
97  // Si la grille magnetique est activee
99  {
100  snapToGrid(point[0], point[1], point[2], _gridMagnStep);
101  }
102 
103  // Init source
104  pSrcPonct->setHauteur(hauteur);
105  pSrcPonct->getPos()->setFromOGL(point);
106  pSrcPonct->getPos()->_z = 0.0 + _pModeler->getDefaultZCoord();
107  pSrcPonct->getOrientation()._x = 1.0;
108 
109  if (QString(_pModeler->metaObject()->className()).compare("TYSiteModelerFrame") == 0)
110  {
111  TYSiteNode* pSite = ((TYSiteModelerFrame*)_pModeler)->getSite();
112 
113  // Ajout
114  if (pSite->getInfrastructure()->addSrc(pSrcPonct))
115  {
116  // On ajoute cette source a la selection du calcul courant
117  if (getTYApp()->getCurProjet() && (getTYApp()->getCurProjet()->getSite() == pSite))
118  {
120 
121  if (pCalcul)
122  {
123  pCalcul->addToSelection(pSrcPonct);
124  }
125  }
126 
127  // Action
128  TYAction* pAction =
129  new TYAddElementToInfraAction((LPTYElement&)pSrcPonct, pSite->getInfrastructure(),
130  _pModeler, TR("id_action_addsource"));
131  _pModeler->getActionManager()->addAction(pAction);
132 
134 
135  // Update
136  pSite->getInfrastructure()->updateGraphicTree();
138  updateSiteFrame(); // Mise a jour de l'arborescence de site
139  }
140  }
141  else if (QString(_pModeler->metaObject()->className()).compare("TYBatimentModelerFrame") == 0)
142  {
143  pSrcPonct->getPos()->_z = hauteur + _pModeler->getDefaultZCoord();
144 
145  TYBatiment* pBat = ((TYBatimentModelerFrame*)_pModeler)->getBatiment();
146  LPTYEtage pEtage = (TYEtage*)pBat->getAcousticVol(0).getRealPointer();
147 
148  if (pEtage)
149  {
150  bool addOk = pEtage->addSource(pSrcPonct);
151 
152  if (addOk) // Si l'action d'ajouter a ete effectuee sans probleme
153  {
154  // Action
155  TYAction* pAction = new TYAddElementToEtageAction(
156  (LPTYElement&)pSrcPonct, pEtage, _pModeler, TR("id_action_addsource"));
157  _pModeler->getActionManager()->addAction(pAction);
158  }
159 
160  // Update
161  pEtage->updateGraphicTree();
162  updateSiteFrame();
165  }
166  }
167 
169  }
170  }
171 }
fichier contenant differents types d'actions (fichier header)
TYApplication * getTYApp()
Retourne le pointeur sur l'application.
pour l'application Tympan (fichier header)
Modeler specialisee pour l'edition des batiments (fichier header)
gestion de l'edition de la camera (fichier header)
Classe generique pour une fenetre de modeleur (fichier header)
Classe Modeler specialisee pour l'edition des sites (fichier header)
#define TR(id)
gestion de l'edition d'une source (fichier header)
double _z
z coordinate of OCoord3D
Definition: 3d.h:284
double _x
x coordinate of OCoord3D
Definition: 3d.h:282
virtual void setFromOGL(double x, double y, double z)
Definition: 3d.cpp:340
T * getRealPointer()
Definition: smartptr.h:291
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 updateSiteFrame()
Reconstruit l'arborescence du TYSiteFrame.
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.
LPTYAcousticVolume getAcousticVol(int index)
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
ajout d'un element a un etage
Definition: TYActions.h:271
Ajout d'un element a une infrastructure.
Definition: TYActions.h:399
LPTYProjet getCurProjet()
Set/Get du projet courant.
Classe Modeler specialisee pour l'edition des batiments.
bool addToSelection(TYUUID id)
Adds the item to the selection of this Calculation.
Definition: TYCalcul.cpp:873
static void setIsSavedOk(const bool &toSave)
Definition: TYElement.h:914
bool addSource(LPTYUserSourcePonctuelleGeoNode pSourceGeoNode)
Definition: TYEtage.cpp:1239
bool addSrc(LPTYUserSourcePonctuelle pSrc)
Generic class for a modeler window.
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)
LPTYSiteNode getSite()
Get du site.
Definition: TYProjet.h:169
LPTYCalcul getCurrentCalcul()
Set/Get du pointeur du Calcul courant.
Definition: TYProjet.h:426
const TYRenderViewport & getViewport() const
TYOpenGLRenderer * getRenderer()
Classe Modeler specialisee pour l'edition des sites.
LPTYInfrastructure getInfrastructure()
Definition: TYSiteNode.h:174
virtual void slotMouseMoved(int x, int y, Qt::MouseButtons button, Qt::KeyboardModifiers state)
TYSourceEditor(TYModelerFrame *pModeler)
virtual void slotViewTypeChanged(int view)
virtual void init()
virtual void slotMouseReleased(int x, int y, Qt::MouseButton button, Qt::KeyboardModifiers state)
bool _active
Indique si cet editor est actif.
virtual void close()
virtual void slotMousePressed(int x, int y, Qt::MouseButton button, Qt::KeyboardModifiers state)
OVector3D & getOrientation()
void setHauteur(double hauteur)