Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYPositionEditor.h
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 
26 #ifndef __TY_POSITION_EDITOR__
27 #define __TY_POSITION_EDITOR__
28 
29 #include <limits>
30 
31 #include "TYAbstractSceneEditor.h"
33 #include "TYAction.h"
34 
35 class TYElement;
36 class QTimer;
37 class OGLLineElement;
38 
44 {
45  Q_OBJECT
46 
47 public:
54  TYPositionEditor(TYModelerFrame* pModeler, int mode = Moving);
58  virtual ~TYPositionEditor();
59 
63  void setInteractionTime(int time)
64  {
65  _interactionTime = time;
66  }
71  {
72  return _interactionTime;
73  }
74 
78  void setSensitivity(float t)
79  {
80  _trackballFactor = t;
81  }
86  {
87  return _trackballFactor;
88  }
89 
93  void setMode(int mode)
94  {
95  _mode = mode;
96  }
100  int getMode()
101  {
102  return _mode;
103  }
104 
108  void setAngleStep(float step)
109  {
110  _angleStep = step;
111  }
115  float getAngleStep()
116  {
117  return _angleStep;
118  }
119 
123  void setPickPointPrecision(float precision)
124  {
125  _pickPointPrecision = precision;
126  }
131  {
132  return _pickPointPrecision;
133  }
134 
139  {
140  return _viewOnlyHighlight;
141  }
142 
146  bool selectElement(TYElement* pElt);
147 
149  enum
150  {
153  Edition
154  };
155 
156 public slots:
157  virtual void connect();
158  virtual void disconnect();
159  virtual void init();
160  virtual void cancel();
161  virtual void close();
162  virtual void slotMousePressed(int x, int y, Qt::MouseButton button, Qt::KeyboardModifiers state);
163  virtual void slotMouseReleased(int x, int y, Qt::MouseButton button, Qt::KeyboardModifiers state);
164  virtual void slotMouseMoved(int x, int y, Qt::MouseButtons button, Qt::KeyboardModifiers state);
165  virtual void slotKeyPressed(int key);
166  virtual void slotKeyReleased(int key);
167  virtual void slotViewTypeChanged(int view);
168 
172  void viewOnlyHighlight(bool state)
173  {
174  _viewOnlyHighlight = state;
175  }
176 
177 protected slots:
178  void initEditSiteNode(TYElement* pElt);
179  void initEditVolume(TYElement* pElt);
180  void initEditMachine(TYElement* pElt);
181  // void initEditEtage(TYElement* pElt);
182  void initEditBatiment(TYElement* pElt);
183  void initEditRoute(TYElement* pElt);
184  void initEditResTrans(TYElement* pElt);
185  void initEditCrbNiv(TYElement* pElt);
186  void initEditCrsEau(TYElement* pElt);
187  void initEditPlanEau(TYElement* pElt);
188  void initEditTerrain(TYElement* pElt);
189  void initEditSrcPonct(TYElement* pElt);
190  void initEditPointControl(TYElement* pElt);
191  void initEditMaillage(TYElement* pElt);
192  void initEditEcran(TYElement* pElt);
193 
199  void editGeoNode();
200 
204  void editPoint();
205 
210  void editPointEtage();
211 
215  void orienteSrcPonct();
216 
217 protected:
230  bool move(OPoint3D* pPt, bool enableX = true, bool enableY = true, bool enableZ = true);
231 
245  bool rotate(ORepere3D* pRepere, bool enableX = true, bool enableY = true, bool enableZ = true);
246 
257  int findPoint(float* ptToFind, TYTabPoint* pInPoints);
258 
262  void updateMovingLines(TYTabPoint* pPoints, int centralPointId);
266  void updateMovingPoint(const TYPoint& point);
267 
271  void PointOfGeoNodeInCurrentSiteCoordinates(TYGeometryNode* pGeoNode, OPoint3D& centralPointGN);
275  void PointOfCurrentSiteInGeoNodeCoordinates(TYGeometryNode* pGeoNode, OPoint3D& centralPointGN);
280  TYGeometryNode* pGeoNode, OPoint3D& centralPointGN, bool bPointOfGeoNodeInCurrentSiteCoordinates);
288  void editPolyLine(LPTYElement pElt, TYTabPoint& pts, bool close, LPTYAltimetrie pAlti = NULL);
289 
297  void insertNewPoint(TYTabPoint& pts, TYPoint& newPoint, int& idInsert, LPTYAltimetrie pAlti = NULL);
298 
305  void deletePoint(TYTabPoint& pts, TYPoint& deletedPoint, int& idDelete);
306 
312  int findClosestSegmentToMouse(const TYTabPoint& pts);
313 
319  int findClosestPointToMouse(const TYTabPoint& pts);
320 
331  double distSegmentSqr(double mx, double my, double vx, double vy, double wx, double wy) const;
332 
333 protected:
335  int _mode;
336 
338  bool _active;
339 
342 
344  bool _inUse;
345 
348 
351 
354 
356  bool _shiftOn;
357 
359  bool _keyAOn;
360 
362  bool _keyDOn;
363 
366 
369 
372 
375 
377  QTimer* _pStepTimer;
380 
383 
388 
391 
395 
396 private:
399 
401  float _angleInfo;
402 
405 
407  float _angleStep;
408 
411 };
412 
413 #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:1211
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 de l'edition en mode camera.
gestion des elements selectionnes par picking
Classe generique pour une fenetre de modeleur.
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 _viewOnlyHighlight
Indique si on affiche que la bounding box lors de l'edition.
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.
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.
TYCameraEditor * _pCamEditor
Un CameraEditor associe a cet editor.
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)