Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYPositionEditor.h
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 
26 #ifndef __TY_POSITION_EDITOR__
27 #define __TY_POSITION_EDITOR__
28 
29 #include <limits>
30 
31 #include "TYAbstractSceneEditor.h"
32 #include "TYAction.h"
33 
34 class TYElement;
35 class QTimer;
36 class OGLLineElement;
37 
43 {
44  Q_OBJECT
45 
46 public:
53  TYPositionEditor(TYModelerFrame* pModeler, int mode = Moving);
57  virtual ~TYPositionEditor();
58 
62  void setInteractionTime(int time)
63  {
64  _interactionTime = time;
65  }
70  {
71  return _interactionTime;
72  }
73 
77  void setSensitivity(float t)
78  {
79  _trackballFactor = t;
80  }
85  {
86  return _trackballFactor;
87  }
88 
92  void setMode(int mode)
93  {
94  _mode = mode;
95  }
99  int getMode()
100  {
101  return _mode;
102  }
103 
107  void setAngleStep(float step)
108  {
109  _angleStep = step;
110  }
114  float getAngleStep()
115  {
116  return _angleStep;
117  }
118 
122  void setPickPointPrecision(float precision)
123  {
124  _pickPointPrecision = precision;
125  }
130  {
131  return _pickPointPrecision;
132  }
133 
138  {
139  return _viewOnlyBoundingBox;
140  }
141 
145  bool selectElement(TYElement* pElt);
146 
148  enum
149  {
152  Edition
153  };
154 
155 public slots:
156  virtual void connect();
157  virtual void disconnect();
158  virtual void init();
159  virtual void cancel();
160  virtual void close();
161  virtual void slotMousePressed(int x, int y, Qt::MouseButton button, Qt::KeyboardModifiers state);
162  virtual void slotMouseReleased(int x, int y, Qt::MouseButton button, Qt::KeyboardModifiers state);
163  virtual void slotMouseMoved(int x, int y, Qt::MouseButtons button, Qt::KeyboardModifiers state);
164  virtual void slotKeyPressed(int key);
165  virtual void slotKeyReleased(int key);
166  virtual void slotViewTypeChanged(int view);
167 
171  void viewOnlyHighlight(bool state)
172  {
173  _viewOnlyBoundingBox = state;
174  }
175 
176 protected slots:
177  void initEditSiteNode(TYElement* pElt);
178  void initEditVolume(TYElement* pElt);
179  void initEditMachine(TYElement* pElt);
180  // void initEditEtage(TYElement* pElt);
181  void initEditBatiment(TYElement* pElt);
182  void initEditRoute(TYElement* pElt);
183  void initEditResTrans(TYElement* pElt);
184  void initEditCrbNiv(TYElement* pElt);
185  void initEditCrsEau(TYElement* pElt);
186  void initEditPlanEau(TYElement* pElt);
187  void initEditTerrain(TYElement* pElt);
188  void initEditSrcPonct(TYElement* pElt);
189  void initEditPointControl(TYElement* pElt);
190  void initEditMaillage(TYElement* pElt);
191  void initEditEcran(TYElement* pElt);
192 
198  void editGeoNode();
199 
203  void editPoint();
204 
209  void editPointEtage();
210 
214  void orienteSrcPonct();
215 
216 protected:
229  bool move(OPoint3D* pPt, bool enableX = true, bool enableY = true, bool enableZ = true);
230 
244  bool rotate(ORepere3D* pRepere, bool enableX = true, bool enableY = true, bool enableZ = true);
245 
256  int findPoint(float* ptToFind, TYTabPoint* pInPoints);
257 
261  void updateMovingLines(TYTabPoint* pPoints, int centralPointId);
265  void updateMovingPoint(const TYPoint& point);
266 
270  void PointOfGeoNodeInCurrentSiteCoordinates(TYGeometryNode* pGeoNode, OPoint3D& centralPointGN);
274  void PointOfCurrentSiteInGeoNodeCoordinates(TYGeometryNode* pGeoNode, OPoint3D& centralPointGN);
279  TYGeometryNode* pGeoNode, OPoint3D& centralPointGN, bool bPointOfGeoNodeInCurrentSiteCoordinates);
287  void editPolyLine(LPTYElement pElt, TYTabPoint& pts, bool close, LPTYAltimetrie pAlti = NULL);
288 
296  void insertNewPoint(TYTabPoint& pts, TYPoint& newPoint, int& idInsert, LPTYAltimetrie pAlti = NULL);
297 
304  void deletePoint(TYTabPoint& pts, TYPoint& deletedPoint, int& idDelete);
305 
311  int findClosestSegmentToMouse(const TYTabPoint& pts);
312 
318  int findClosestPointToMouse(const TYTabPoint& pts);
319 
330  double distSegmentSqr(double mx, double my, double vx, double vy, double wx, double wy) const;
331 
332 protected:
334  int _mode;
335 
337  bool _active;
338 
341 
343  bool _inUse;
344 
347 
350 
352  bool _shiftOn;
353 
355  bool _keyAOn;
356 
358  bool _keyDOn;
359 
362 
365 
368 
371 
373  QTimer* _pStepTimer;
376 
379 
384 
387 
391 
392 private:
395 
397  float _angleInfo;
398 
401 
403  float _angleStep;
404 
407 };
408 
409 #endif // __TY_POSITION_EDITOR__
gestion de l'interaction entre la vue graphique (2D ou 3D) et le clavier et la souris (fichier header...
Definit une action, necessaire pour la gestion de l'undo (fichier header)
std::vector< TYPoint > TYTabPoint
Collection de TYPoint.
Definition: TYDefines.h:340
The 3D point class.
Definition: 3d.h:487
3D frame with a point and 3 vectors.
Definition: 3d.h:1263
Classe abstraite pour la gestion de l'interaction entre la vue graphique (2D ou 3D) et le clavier et ...
Definit une action, necessaire pour la gestion de l'undo.
Definition: TYAction.h:37
gestion des elements selectionnes par picking
Generic class for a modeler window.
gestion de la position selon les modes 'moving', 'rotation', 'edition'
void initEditPlanEau(TYElement *pElt)
virtual void connect()
double distSegmentSqr(double mx, double my, double vx, double vy, double wx, double wy) const
Shortest distance (squared) between a segment and a point.
int _interactionTime
La duree de step pour le timer.
QTimer * _pStepTimer
Timer pour miniser le nombre de refresh.
bool _mouseEventActive
Indique si l'editor est en pleine action.
void updateMovingPoint(const TYPoint &point)
float _pickPointPrecision
Precision pour la detection d'un point clique.
bool rotate(ORepere3D *pRepere, bool enableX=true, bool enableY=true, bool enableZ=true)
void viewOnlyHighlight(bool state)
void setInteractionTime(int time)
void deletePoint(TYTabPoint &pts, TYPoint &deletedPoint, int &idDelete)
Delete the closest point of a polyline to the mouse position.
void editPolyLine(LPTYElement pElt, TYTabPoint &pts, bool close, LPTYAltimetrie pAlti=NULL)
Edit a polyline.
void setMode(int mode)
void initEditTerrain(TYElement *pElt)
void initEditMaillage(TYElement *pElt)
virtual void disconnect()
virtual void close()
int _mode
Le mode pour cet editor.
void initEditSiteNode(TYElement *pElt)
void initEditRoute(TYElement *pElt)
virtual void slotKeyReleased(int key)
bool _keyAOn
If the A key is pressed.
bool _shiftOn
Indique si le bouton Shift est enfonce.
bool _active
Indique si cet editor est actif.
void initEditPointControl(TYElement *pElt)
TYAction * _pLastAction
La derniere action (pour le undo).
OGLLineElement * _pOGLLineElementMoving2
void insertNewPoint(TYTabPoint &pts, TYPoint &newPoint, int &idInsert, LPTYAltimetrie pAlti=NULL)
Add a new point on the closest line to the mouse position.
bool _viewOnlyBoundingBox
Indique si on affiche que la bounding box lors de l'edition.
void updateMovingLines(TYTabPoint *pPoints, int centralPointId)
bool _firstCall
Indiquateur pour l'init de calculs.
TYPoint * _pEditPoint
Le point a deplacer.
bool _inUse
Indique si une action est deja en cours.
void initEditBatiment(TYElement *pElt)
float _angleInfo
Pour l'affichage de l'angle de rotation a appliquer.
void initEditEcran(TYElement *pElt)
void PointOfGeoNodeInCurrentSiteCoordinatesOrPointOfCurrentSiteInGeoNodeCoordinates(TYGeometryNode *pGeoNode, OPoint3D &centralPointGN, bool bPointOfGeoNodeInCurrentSiteCoordinates)
void initEditResTrans(TYElement *pElt)
int findClosestSegmentToMouse(const TYTabPoint &pts)
Find the closest segment of a polyline to the mouse position.
int findClosestPointToMouse(const TYTabPoint &pts)
Return the id of the closest point of a polyline to the mouse position.
virtual void init()
TYTabPoint _editContour
Le contour de l'etage a editer.
void PointOfCurrentSiteInGeoNodeCoordinates(TYGeometryNode *pGeoNode, OPoint3D &centralPointGN)
virtual void slotMousePressed(int x, int y, Qt::MouseButton button, Qt::KeyboardModifiers state)
TYPositionEditor(TYModelerFrame *pModeler, int mode=Moving)
void setPickPointPrecision(float precision)
void initEditCrbNiv(TYElement *pElt)
int _currentMousePos[2]
La position courante du curseur.
TYGeometryNode * _pEditGeoNode
Le GeoNode associe a l'element que l'on edite.
bool move(OPoint3D *pPt, bool enableX=true, bool enableY=true, bool enableZ=true)
virtual void cancel()
int findPoint(float *ptToFind, TYTabPoint *pInPoints)
bool selectElement(TYElement *pElt)
void setAngleStep(float step)
void initEditSrcPonct(TYElement *pElt)
OGLLineElement * _pOGLLineElementMoving1
Pour la representation de l'edition d'un point.
float _trackballFactor
Facteur de rotation.
virtual void slotMouseMoved(int x, int y, Qt::MouseButtons button, Qt::KeyboardModifiers state)
void PointOfGeoNodeInCurrentSiteCoordinates(TYGeometryNode *pGeoNode, OPoint3D &centralPointGN)
virtual void slotKeyPressed(int key)
float getPickPointPrecision()
virtual void slotViewTypeChanged(int view)
int _lastMousePos[2]
La derniere position connue du curseur.
virtual void slotMouseReleased(int x, int y, Qt::MouseButton button, Qt::KeyboardModifiers state)
void initEditVolume(TYElement *pElt)
void setSensitivity(float t)
TYElement * _pEditElement
L'element que l'on edite.
TYElementPicker * _pPicker
Le picker du modeler.
bool _keyDOn
If the D key is pressed.
bool _bSiteModelerFrame
Indicateur d'edition dans un modeler frame.
float _angleStep
Pas d'angle pour la rotation.
void initEditCrsEau(TYElement *pElt)
void initEditMachine(TYElement *pElt)