23 #include <qstatusbar.h>
24 #include <qvector3d.h>
46 #define TR(id) OLocalizator::getString("TYPositionEditor", (id))
48 static bool bTYPositionEditorFirstMove =
true;
126 if (QString(
_pModeler->metaObject()->className()).compare(
"TYMachineModelerFrame") == 0)
136 else if (QString(
_pModeler->metaObject()->className()).compare(
"TYBatimentModelerFrame") == 0)
151 else if (QString(
_pModeler->metaObject()->className()).compare(
"TYSiteModelerFrame") == 0)
187 static const char dirName[] =
"UserPreferences";
189 if (TYPreferenceManager::getInstance().exists(dirName,
"ViewOnlyHighlight"))
191 _viewOnlyBoundingBox = TYPreferenceManager::getInstance().getBool(dirName,
"ViewOnlyHighlight");
282 if (button == Qt::LeftButton)
316 TYApplication::setOverrideCursor(Qt::SizeAllCursor);
320 TYApplication::setOverrideCursor(Qt::BlankCursor);
327 bTYPositionEditorFirstMove =
true;
342 _pEditGeoNode->getGraphicObject()->setOnlyBoundingBox(
false);
373 TYApplication::restoreOverrideCursor();
408 while (pParent && (pParent != pModelerTarget))
429 if (!pSiteNodeParent)
532 if (pParent->
isA(
"TYEtage"))
536 else if (pParent->
isA(
"TYInfrastructure"))
895 assert(pSite !=
nullptr &&
"The parent of a TYTopographie element must be a TYSiteNode");
954 assert(pSite !=
nullptr &&
"The parent of a TYTopographie element must be a TYSiteNode");
1013 assert(pSite !=
nullptr &&
"The parent of a TYTopographie element must be a TYSiteNode");
1081 TR(
"id_action_movesrcponct"));
1128 TR(
"id_action_movepointcontrol"));
1196 TYPoint centralPoint(centralPointGN);
1209 TYListPtrGeoNode::iterator ite = GeoNodeParents.end();
1210 int i = 0, rootIndex = 0;
1211 if (pRootGeometryNode)
1213 for (i = 0; i < (int)GeoNodeParents.size(); i++)
1216 if ((*ite) == pRootGeometryNode)
1223 for (i = rootIndex; i < ((int)GeoNodeParents.size() - rootIndex); i++)
1227 currentMatrix = pCurrentTYGeometryNode->
getMatrix();
1228 if (!bPointOfGeoNodeInCurrentSiteCoordinates)
1230 currentMatrix = currentMatrix.
getInvert();
1232 totalMatrix = totalMatrix * currentMatrix;
1234 centralPoint = totalMatrix * centralPoint;
1236 centralPointGN = centralPoint;
1241 bool modified =
false;
1244 bool enableX =
true;
1245 bool enableY =
true;
1246 bool enableZ =
true;
1262 modified =
move(&repere.
_origin, enableX, enableY, enableZ);
1283 modified =
rotate(&repere, enableX, enableY, enableZ);
1288 if (modified && bTYPositionEditorFirstMove)
1291 bTYPositionEditorFirstMove =
false;
1298 _pEditGeoNode->getGraphicObject()->setOnlyBoundingBox(
true);
1362 bool modified =
false;
1429 bool modified =
false;
1482 double displaySrcePos[4];
1486 displaySrcePos[2], ptCur);
1487 OPoint3D optCur(ptCur[0], -ptCur[2], ptCur[1]);
1492 if (pRootGeometryNode)
1534 if (!enableX && !enableY && !enableZ)
1546 if (QString(
_pModeler->metaObject()->className()).compare(
"TYSiteModelerFrame") == 0)
1562 OVector3D delta(pt1[0] - pt2[0], -(pt1[2] - pt2[2]), pt1[1] - pt2[1]);
1606 .arg(pPt->
_x, 0,
'f', 2)
1607 .arg(pPt->
_y, 0,
'f', 2)
1608 .arg(pPt->
_z, 0,
'f', 2),
1615 .arg(pPt->
_x, 0,
'f', 2)
1616 .arg(pPt->
_y, 0,
'f', 2)
1617 .arg(pPt->
_z, 0,
'f', 2),
1618 (
int)org[0], (
int)org[1]);
1630 if (QString(
_pModeler->metaObject()->className()).compare(
"TYSiteModelerFrame") == 0)
1641 Q_CHECK_PTR(pRepere);
1644 if (!enableX && !enableY && !enableZ)
1656 if (QString(
_pModeler->metaObject()->className()).compare(
"TYSiteModelerFrame") == 0)
1669 double a1 = atan2(
double(diffY1),
double(diffX1));
1670 double a2 = atan2(
double(diffY2),
double(diffX2));
1671 float angle = (a2 - a1) / (2.0 * 3.1415926535) * 360.0 / 10.0 *
_trackballFactor;
1719 tyMat = pRepere->
asMatrix() * tyMatTmpZ * tyMatTmpY * tyMatTmpX;
1722 pRepere->
set(tyMat);
1738 if (QString(
_pModeler->metaObject()->className()).compare(
"TYSiteModelerFrame") == 0)
1750 for (
size_t i = 0; i < pInPoints->size(); i++)
1752 TYPoint curPt = pInPoints->at(i);
1760 ptId =
static_cast<int>(i);
1773 TYPoint centralPoint = pPoints->at(centralPointId);
1779 if (centralPointId - 1 >= 0)
1781 TYPoint prevPoint = pPoints->at(centralPointId - 1);
1792 if (centralPointId + 1 < (
int)pPoints->size())
1794 TYPoint nextPoint = pPoints->at(centralPointId + 1);
1825 while (pParent && (
dynamic_cast<TYSiteNode*
>(pParent) ==
nullptr))
1842 if (pModelerTarget && (pParent != pModelerTarget))
1860 TR(
"id_action_insertptpolyline"));
1864 size_t nbPts = pts.size();
1865 if (nbPts < 3 || (closed && nbPts < 4))
1872 TR(
"id_action_delptpolyline"));
1896 newPoint =
TYPoint(ptProj[0], -ptProj[2], pts[idInsert]._z);
1905 if (pAlti && !pAlti->
altitude(newPoint))
1907 newPoint.
_z = std::numeric_limits<double>::quiet_NaN();
1909 pts.insert(pts.begin() + idInsert, newPoint);
1915 deletedPoint = pts[idDelete];
1916 pts.erase(pts.begin() + idDelete);
1922 size_t nbPts = pts.size();
1923 double ptOnDisplay[3];
1927 std::vector<OVector3D> ptsDisplay;
1929 for (
size_t i = 0; i < nbPts; ++i)
1932 pt = matrixNode * pts[i];
1934 ptsDisplay.push_back(
OVector3D(ptOnDisplay[0], ptOnDisplay[1], 0.0));
1937 double distSqrMin = (std::numeric_limits<double>::max)();
1944 for (
size_t i = 0; i < nbPts; ++i)
1946 j = i < (nbPts - 1) ? i + 1 : 0;
1951 if (distSqr < distSqrMin)
1953 distSqrMin = distSqr;
1954 idPt =
static_cast<int>(i);
1963 size_t nbPts = pts.size();
1964 double distSqrMin = (std::numeric_limits<double>::max)();
1965 double ptOnDisplay[3];
1966 double diffx = 0, diffy = 0, distSqr = 0;
1970 for (
size_t i = 0; i < nbPts; ++i)
1973 pt = matrixNode * pts[i];
1977 distSqr = diffx * diffx + diffy * diffy;
1978 if (distSqr < distSqrMin)
1980 distSqrMin = distSqr;
1981 ptId =
static_cast<int>(i);
1990 double l2 = (vx - wx) * (vx - wx) + (vy - wy) * (vy - wy);
1993 double t = ((mx - vx) * (wx - vx) + (my - vy) * (wy - vy)) / l2;
1996 return (mx - vx) * (mx - vx) + (my - vy) * (my - vy);
2000 return (mx - wx) * (mx - wx) + (my - wy) * (my - wy);
2004 return (mx - (vx + t * (wx - vx))) * (mx - (vx + t * (wx - vx))) +
2005 (my - (vy + t * (wy - vy))) * (my - (vy + t * (wy - vy)));
2010 return (mx - vx) * (mx - vx) + (my - vy) * (my - vy);
All base classes related to 3D manipulation.
int ROUND(double a)
Compute the rounded value of a number.
fichier contenant differents types d'actions (fichier header)
pour l'application Tympan (fichier header)
gestion de l'edition de la camera (fichier header)
std::vector< TYPoint > TYTabPoint
Collection de TYPoint.
gestion des elements selectionnes par picking (fichier header)
std::list< TYGeometryNode * > TYListPtrGeoNode
Liste ordonnee de pointeurs de TYElement.
Classe generique pour une fenetre de modeleur (fichier header)
gestion de la position selon les modes 'moving', 'rotation', 'edition' (fichier header)
Contexte de rendu utilisé par les fonctions d'affichage.
@ Display
The current render is intended to be displayed on screen.
@ Overlay
The current render pass is for overlay elements.
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 _y
y coordinate of OCoord3D
double _z
z coordinate of OCoord3D
double _x
x coordinate of OCoord3D
const QVector3D & front() const
void setVisibility(bool bVisible)
void setPoint2(const QVector3D &point2)
void setColor(const OColor &oColor)
void setPoint1(const QVector3D &point1)
int setRotationOz(double a)
Update a rotation matrix (Oz axis).
int setRotationOy(double a)
Update a rotation matrix (Oy axis).
OMatrix getInvert(int *ok=0) const
Return the inverse matrix of this matrix.
int setRotationOx(double a)
Update a rotation matrix (Ox axis).
static OPrototype * safeDownCast(OPrototype *pObject)
bool isA(const char *className) const
3D frame with a point and 3 vectors.
void set(const OPoint3D &origin, const OVector3D &vecI, const OVector3D &vecJ, const OVector3D &vecK)
Sets with a point and 3 vectors.
OPoint3D _origin
The origin point.
OMatrix asMatrix() const
return the transformation matrix from unity to this pose such as this = transform * unity
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.
void worldToDisplay(double x, double y, double z, double *displayPoint)
Methode utilitaire pour convertir un point en coordonnees globale en coordonnees ecran.
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...
virtual void disconnect()
Deconnecte cet editor a l'interactor associe.
void updateText(QString msg="", int posX=0, int posY=0, bool show=true)
Mets a jour le texte informatif sur la vue 3D.
TYModelerFrame * _pModeler
Le modeler associe a cet editor.
TYCameraEditor * _pCameraEditor
Le caméra editor associé à cet éditor.
void displayToWorld(double x, double y, double z, double *worldPoint)
Methode utilitaire pour convertir un point en coordonnees ecran en coordonnees globale.
virtual void connect()
Connecte cet editor a l'interactor associe.
void showText(bool show=true)
Affiche ou pas le texte informatif sur la vue 3D.
TYRenderWindowInteractor * _pInteractor
La vue graphique associee a cet editor.
TYTabPoint & getTabPoint()
LPTYAcousticVolumeGeoNode findAcousticVol(const LPTYAcousticVolume pAccVol)
void addAction(TYAction *pAction)
Ajoute une nouvelle action a l'historique.
double altitude(const OPoint3D &pt)
Gestion de l'edition en mode camera.
void setLeftButtonFunction2D(void(TYCameraEditor::*function)())
void setMiddleButtonFunction2D(void(TYCameraEditor::*function)())
void setRightButtonFunction2D(void(TYCameraEditor::*function)())
void setShiftRightButtonFunction2D(void(TYCameraEditor::*function)())
void setShiftLeftButtonFunction2D(void(TYCameraEditor::*function)())
virtual void slotViewTypeChanged(int view)
TYTabPoint & getListPoints()
void courbeNiveauPicked(TYElement *pElt)
void etagePicked(TYElement *pElt)
void linearMaillagePicked(TYElement *pElt)
void sourcePonctuellePicked(TYElement *pElt)
void ecranPicked(TYElement *pElt)
void reset()
Retourne dans son etat initial.
void acousticSemiCylinderPicked(TYElement *pElt)
void pointControlPicked(TYElement *pElt)
void highlightElement(TYElement *pElt)
Dessine la boite englobante de l'element passe.
void machinePicked(TYElement *pElt)
void routePicked(TYElement *pElt)
void acousticBoxPicked(TYElement *pElt)
void acousticCylinderPicked(TYElement *pElt)
void coursEauPicked(TYElement *pElt)
bool pick(int x, int y)
Effectue un picking en (x, y).
void reseauTransportPicked(TYElement *pElt)
void planEauPicked(TYElement *pElt)
void batimentPicked(TYElement *pElt)
void terrainPicked(TYElement *pElt)
void rectangularMaillagePicked(TYElement *pElt)
TYElement * getParent() const
static void setIsSavedOk(const bool &toSave)
virtual void setIsGeometryModified(bool isModified)
double getHauteur() const
bool setMurs(const TYTabPoint &tabPts, double hauteur=2.0, bool close=true)
const ORepere3D & getORepere3D() const
OMatrix localToGlobal() const
OMatrix globalToLocal() const
void GetGeoNodeParentList(TYListPtrGeoNode &GetGeoNodeParents)
TYElement * getElement() const
OMatrix getMatrix() const
static TYGeometryNode * GetGeoNode(TYElement *pElement)
void setRepere(const ORepere3D &repere)
LPTYBatimentGeoNode findBatiment(const LPTYBatiment pBatiment)
LPTYUserSourcePonctuelleGeoNode findSrc(const LPTYUserSourcePonctuelle pSrc)
LPTYReseauTransportGeoNode findResTrans(const LPTYReseauTransport pResTrans)
Action editing for a polyline (when inserting point)
Classe de definition d'un maillage.
Generic class for a modeler window.
TYElementPicker * getElementPicker()
TYActionManager * getActionManager()
bool askForResetResultat()
virtual void updateView(bool clipping=true, bool axesAndGrid=true)
Actions de deplacement d'un GeometryNode.
Action de deplacement d'un point de controle.
Action de deplacement d'un point d'un etage.
Action editing for a polyline (when moving point)
Action de deplacement d'un source ponctuelle.
void addOGLElement(OGLElement *pOGLElement)
void invalidateScene(void)
void removeOGLElement(OGLElement *pOGLElement)
void updateDisplayListOverlay(TYRenderContext &renderContext, TYGeometryNode *pElement, TYGeometryNode *pDansCeRepere)
Action d'orientation d'une source ponctuelle.
virtual TYTabPoint & getListPoints()
Classe de definition d'un point de controle.Le point de controle est un point de calcul avec une haut...
void initEditPlanEau(TYElement *pElt)
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 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 initEditTerrain(TYElement *pElt)
void initEditMaillage(TYElement *pElt)
virtual void disconnect()
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.
virtual ~TYPositionEditor()
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 ¢ralPointGN, 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.
TYTabPoint _editContour
Le contour de l'etage a editer.
void PointOfCurrentSiteInGeoNodeCoordinates(TYGeometryNode *pGeoNode, OPoint3D ¢ralPointGN)
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)
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 ¢ralPointGN)
virtual void slotKeyPressed(int key)
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)
classe de definition d'un projet.
LPTYMaillageGeoNode findMaillage(const LPTYMaillage pMaillage)
Retrouve le GeoNode associe a un maillage.
const TYRenderViewport & getViewport() const
TYOpenGLRenderer * getRenderer()
OGLCamera * getActiveCamera()
Actions de rotation d'un GeometryNode.
Classe Modeler specialisee pour l'edition des sites.
LPTYAltimetrie getAltimetry() const
LPTYSiteNodeGeoNode findSiteNode(const LPTYSiteNode pSiteNode)
OVector3D & getOrientation()
virtual TYTabPoint & getListPoints()
LPTYCourbeNiveauGeoNode findCrbNiv(const LPTYCourbeNiveau pCrbNiv)
LPTYTerrainGeoNode findTerrain(const LPTYTerrain pTerrain)
LPTYPlanEauGeoNode findPlanEau(const LPTYPlanEau pPlanEau)
LPTYCoursEauGeoNode findCrsEau(const LPTYCoursEau pCrsEau)