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);
375 TYApplication::restoreOverrideCursor();
410 while (pParent && (pParent != pModelerTarget))
431 if (!pSiteNodeParent)
534 if (pParent->
isA(
"TYEtage"))
538 else if (pParent->
isA(
"TYInfrastructure"))
897 assert(pSite !=
nullptr &&
"The parent of a TYTopographie element must be a TYSiteNode");
956 assert(pSite !=
nullptr &&
"The parent of a TYTopographie element must be a TYSiteNode");
1015 assert(pSite !=
nullptr &&
"The parent of a TYTopographie element must be a TYSiteNode");
1083 TR(
"id_action_movesrcponct"));
1130 TR(
"id_action_movepointcontrol"));
1198 TYPoint centralPoint(centralPointGN);
1211 TYListPtrGeoNode::iterator ite = GeoNodeParents.end();
1212 int i = 0, rootIndex = 0;
1213 if (pRootGeometryNode)
1215 for (i = 0; i < (int)GeoNodeParents.size(); i++)
1218 if ((*ite) == pRootGeometryNode)
1225 for (i = rootIndex; i < ((int)GeoNodeParents.size() - rootIndex); i++)
1229 currentMatrix = pCurrentTYGeometryNode->
getMatrix();
1230 if (!bPointOfGeoNodeInCurrentSiteCoordinates)
1232 currentMatrix = currentMatrix.
getInvert();
1234 totalMatrix = totalMatrix * currentMatrix;
1236 centralPoint = totalMatrix * centralPoint;
1238 centralPointGN = centralPoint;
1243 bool modified =
false;
1246 bool enableX =
true;
1247 bool enableY =
true;
1248 bool enableZ =
true;
1264 modified =
move(&repere.
_origin, enableX, enableY, enableZ);
1285 modified =
rotate(&repere, enableX, enableY, enableZ);
1290 if (modified && bTYPositionEditorFirstMove)
1293 bTYPositionEditorFirstMove =
false;
1365 bool modified =
false;
1432 bool modified =
false;
1485 double displaySrcePos[4];
1489 displaySrcePos[2], ptCur);
1490 OPoint3D optCur(ptCur[0], -ptCur[2], ptCur[1]);
1495 if (pRootGeometryNode)
1537 if (!enableX && !enableY && !enableZ)
1549 if (QString(
_pModeler->metaObject()->className()).compare(
"TYSiteModelerFrame") == 0)
1565 OVector3D delta(pt1[0] - pt2[0], -(pt1[2] - pt2[2]), pt1[1] - pt2[1]);
1609 .arg(pPt->
_x, 0,
'f', 2)
1610 .arg(pPt->
_y, 0,
'f', 2)
1611 .arg(pPt->
_z, 0,
'f', 2),
1618 .arg(pPt->
_x, 0,
'f', 2)
1619 .arg(pPt->
_y, 0,
'f', 2)
1620 .arg(pPt->
_z, 0,
'f', 2),
1621 (
int)org[0], (
int)org[1]);
1633 if (QString(
_pModeler->metaObject()->className()).compare(
"TYSiteModelerFrame") == 0)
1644 Q_CHECK_PTR(pRepere);
1647 if (!enableX && !enableY && !enableZ)
1659 if (QString(
_pModeler->metaObject()->className()).compare(
"TYSiteModelerFrame") == 0)
1672 double a1 = atan2(
double(diffY1),
double(diffX1));
1673 double a2 = atan2(
double(diffY2),
double(diffX2));
1674 float angle = (a2 - a1) / (2.0 * 3.1415926535) * 360.0 / 10.0 *
_trackballFactor;
1722 tyMat = pRepere->
asMatrix() * tyMatTmpZ * tyMatTmpY * tyMatTmpX;
1725 pRepere->
set(tyMat);
1741 if (QString(
_pModeler->metaObject()->className()).compare(
"TYSiteModelerFrame") == 0)
1753 for (
size_t i = 0; i < pInPoints->size(); i++)
1755 TYPoint curPt = pInPoints->at(i);
1763 ptId =
static_cast<int>(i);
1776 TYPoint centralPoint = pPoints->at(centralPointId);
1782 if (centralPointId - 1 >= 0)
1784 TYPoint prevPoint = pPoints->at(centralPointId - 1);
1795 if (centralPointId + 1 < (
int)pPoints->size())
1797 TYPoint nextPoint = pPoints->at(centralPointId + 1);
1828 while (pParent && (
dynamic_cast<TYSiteNode*
>(pParent) ==
nullptr))
1845 if (pModelerTarget && (pParent != pModelerTarget))
1863 TR(
"id_action_insertptpolyline"));
1867 size_t nbPts = pts.size();
1868 if (nbPts < 3 || (closed && nbPts < 4))
1875 TR(
"id_action_delptpolyline"));
1899 newPoint =
TYPoint(ptProj[0], -ptProj[2], pts[idInsert]._z);
1908 if (pAlti && !pAlti->
altitude(newPoint))
1910 newPoint.
_z = std::numeric_limits<double>::quiet_NaN();
1912 pts.insert(pts.begin() + idInsert, newPoint);
1918 deletedPoint = pts[idDelete];
1919 pts.erase(pts.begin() + idDelete);
1925 size_t nbPts = pts.size();
1926 double ptOnDisplay[3];
1930 std::vector<OVector3D> ptsDisplay;
1932 for (
size_t i = 0; i < nbPts; ++i)
1935 pt = matrixNode * pts[i];
1937 ptsDisplay.push_back(
OVector3D(ptOnDisplay[0], ptOnDisplay[1], 0.0));
1940 double distSqrMin = (std::numeric_limits<double>::max)();
1947 for (
size_t i = 0; i < nbPts; ++i)
1949 j = i < (nbPts - 1) ? i + 1 : 0;
1954 if (distSqr < distSqrMin)
1956 distSqrMin = distSqr;
1957 idPt =
static_cast<int>(i);
1966 size_t nbPts = pts.size();
1967 double distSqrMin = (std::numeric_limits<double>::max)();
1968 double ptOnDisplay[3];
1969 double diffx = 0, diffy = 0, distSqr = 0;
1973 for (
size_t i = 0; i < nbPts; ++i)
1976 pt = matrixNode * pts[i];
1980 distSqr = diffx * diffx + diffy * diffy;
1981 if (distSqr < distSqrMin)
1983 distSqrMin = distSqr;
1984 ptId =
static_cast<int>(i);
1993 double l2 = (vx - wx) * (vx - wx) + (vy - wy) * (vy - wy);
1996 double t = ((mx - vx) * (wx - vx) + (my - vy) * (wy - vy)) / l2;
1999 return (mx - vx) * (mx - vx) + (my - vy) * (my - vy);
2003 return (mx - wx) * (mx - wx) + (my - wy) * (my - wy);
2007 return (mx - (vx + t * (wx - vx))) * (mx - (vx + t * (wx - vx))) +
2008 (my - (vy + t * (wy - vy))) * (my - (vy + t * (wy - vy)));
2013 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.
@ 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()
virtual TYRenderContext createRenderContext()
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)