23 #include <qstatusbar.h>
43 #define TR(id) OLocalizator::getString("TYPositionEditor", (id))
45 static bool bTYPositionEditorFirstMove =
true;
123 if (QString(
_pModeler->metaObject()->className()).compare(
"TYMachineModelerFrame") == 0)
133 else if (QString(
_pModeler->metaObject()->className()).compare(
"TYBatimentModelerFrame") == 0)
148 else if (QString(
_pModeler->metaObject()->className()).compare(
"TYSiteModelerFrame") == 0)
184 static const char dirName[] =
"UserPreferences";
186 if (TYPreferenceManager::getInstance().exists(dirName,
"ViewOnlyHighlight"))
188 _viewOnlyHighlight = TYPreferenceManager::getInstance().getBool(dirName,
"ViewOnlyHighlight");
192 TYPreferenceManager::getInstance().setBool(dirName,
"ViewOnlyHighlight",
_viewOnlyHighlight);
279 if (button == Qt::LeftButton)
313 TYApplication::setOverrideCursor(Qt::SizeAllCursor);
317 TYApplication::setOverrideCursor(Qt::BlankCursor);
324 bTYPositionEditorFirstMove =
true;
367 TYApplication::restoreOverrideCursor();
402 while (pParent && (pParent != pModelerTarget))
423 if (!pSiteNodeParent)
526 if (pParent->
isA(
"TYEtage"))
530 else if (pParent->
isA(
"TYInfrastructure"))
889 assert(pSite !=
nullptr &&
"The parent of a TYTopographie element must be a TYSiteNode");
948 assert(pSite !=
nullptr &&
"The parent of a TYTopographie element must be a TYSiteNode");
1007 assert(pSite !=
nullptr &&
"The parent of a TYTopographie element must be a TYSiteNode");
1075 TR(
"id_action_movesrcponct"));
1122 TR(
"id_action_movepointcontrol"));
1190 TYPoint centralPoint(centralPointGN);
1203 TYListPtrGeoNode::iterator ite = GeoNodeParents.end();
1204 int i = 0, rootIndex = 0;
1205 if (pRootGeometryNode)
1207 for (i = 0; i < (int)GeoNodeParents.size(); i++)
1210 if ((*ite) == pRootGeometryNode)
1217 for (i = rootIndex; i < ((int)GeoNodeParents.size() - rootIndex); i++)
1221 currentMatrix = pCurrentTYGeometryNode->
getMatrix();
1222 if (!bPointOfGeoNodeInCurrentSiteCoordinates)
1224 currentMatrix = currentMatrix.
getInvert();
1226 totalMatrix = totalMatrix * currentMatrix;
1228 centralPoint = totalMatrix * centralPoint;
1230 centralPointGN = centralPoint;
1235 bool modified =
false;
1238 bool enableX =
true;
1239 bool enableY =
true;
1240 bool enableZ =
true;
1256 modified =
move(&repere.
_origin, enableX, enableY, enableZ);
1277 modified =
rotate(&repere, enableX, enableY, enableZ);
1282 if (modified && bTYPositionEditorFirstMove)
1285 bTYPositionEditorFirstMove =
false;
1352 bool modified =
false;
1419 bool modified =
false;
1472 double displaySrcePos[4];
1477 OPoint3D optCur(ptCur[0], -ptCur[2], ptCur[1]);
1482 if (pRootGeometryNode)
1524 if (!enableX && !enableY && !enableZ)
1536 if (QString(
_pModeler->metaObject()->className()).compare(
"TYSiteModelerFrame") == 0)
1551 OVector3D delta(pt1[0] - pt2[0], -(pt1[2] - pt2[2]), pt1[1] - pt2[1]);
1595 .arg(pPt->
_x, 0,
'f', 2)
1596 .arg(pPt->
_y, 0,
'f', 2)
1597 .arg(pPt->
_z, 0,
'f', 2),
1604 .arg(pPt->
_x, 0,
'f', 2)
1605 .arg(pPt->
_y, 0,
'f', 2)
1606 .arg(pPt->
_z, 0,
'f', 2),
1607 (
int)org[0], (
int)org[1]);
1619 if (QString(
_pModeler->metaObject()->className()).compare(
"TYSiteModelerFrame") == 0)
1630 Q_CHECK_PTR(pRepere);
1633 if (!enableX && !enableY && !enableZ)
1645 if (QString(
_pModeler->metaObject()->className()).compare(
"TYSiteModelerFrame") == 0)
1658 double a1 = atan2(
double(diffY1),
double(diffX1));
1659 double a2 = atan2(
double(diffY2),
double(diffX2));
1660 float angle = (a2 - a1) / (2.0 * 3.1415926535) * 360.0 / 10.0 *
_trackballFactor;
1695 if (vpNormal[0] != 0)
1699 if (vpNormal[2] != 0)
1703 if (vpNormal[1] != 0)
1708 tyMat = pRepere->
asMatrix() * tyMatTmpZ * tyMatTmpY * tyMatTmpX;
1711 pRepere->
set(tyMat);
1727 if (QString(
_pModeler->metaObject()->className()).compare(
"TYSiteModelerFrame") == 0)
1739 for (
size_t i = 0; i < pInPoints->size(); i++)
1741 TYPoint curPt = pInPoints->at(i);
1749 ptId =
static_cast<int>(i);
1762 TYPoint centralPoint = pPoints->at(centralPointId);
1768 if (centralPointId - 1 >= 0)
1770 TYPoint prevPoint = pPoints->at(centralPointId - 1);
1781 if (centralPointId + 1 < (
int)pPoints->size())
1783 TYPoint nextPoint = pPoints->at(centralPointId + 1);
1814 while (pParent && (
dynamic_cast<TYSiteNode*
>(pParent) ==
nullptr))
1831 if (pModelerTarget && (pParent != pModelerTarget))
1849 TR(
"id_action_insertptpolyline"));
1853 size_t nbPts = pts.size();
1854 if (nbPts < 3 || (closed && nbPts < 4))
1861 TR(
"id_action_delptpolyline"));
1884 newPoint =
TYPoint(ptProj[0], -ptProj[2], pts[idInsert]._z);
1893 if (pAlti && !pAlti->
altitude(newPoint))
1895 newPoint.
_z = std::numeric_limits<double>::quiet_NaN();
1897 pts.insert(pts.begin() + idInsert, newPoint);
1903 deletedPoint = pts[idDelete];
1904 pts.erase(pts.begin() + idDelete);
1910 size_t nbPts = pts.size();
1911 double ptOnDisplay[3];
1915 std::vector<OVector3D> ptsDisplay;
1917 for (
size_t i = 0; i < nbPts; ++i)
1920 pt = matrixNode * pts[i];
1922 ptsDisplay.push_back(
OVector3D(ptOnDisplay[0], ptOnDisplay[1], 0.0));
1925 double distSqrMin = (std::numeric_limits<double>::max)();
1932 for (
size_t i = 0; i < nbPts; ++i)
1934 j = i < (nbPts - 1) ? i + 1 : 0;
1939 if (distSqr < distSqrMin)
1941 distSqrMin = distSqr;
1942 idPt =
static_cast<int>(i);
1951 size_t nbPts = pts.size();
1952 double distSqrMin = (std::numeric_limits<double>::max)();
1953 double ptOnDisplay[3];
1954 double diffx = 0, diffy = 0, distSqr = 0;
1958 for (
size_t i = 0; i < nbPts; ++i)
1961 pt = matrixNode * pts[i];
1965 distSqr = diffx * diffx + diffy * diffy;
1966 if (distSqr < distSqrMin)
1968 distSqrMin = distSqr;
1969 ptId =
static_cast<int>(i);
1978 double l2 = (vx - wx) * (vx - wx) + (vy - wy) * (vy - wy);
1981 double t = ((mx - vx) * (wx - vx) + (my - vy) * (wy - vy)) / l2;
1984 return (mx - vx) * (mx - vx) + (my - vy) * (my - vy);
1988 return (mx - wx) * (mx - wx) + (my - wy) * (my - wy);
1992 return (mx - (vx + t * (wx - vx))) * (mx - (vx + t * (wx - vx))) +
1993 (my - (vy + t * (wy - vy))) * (my - (vy + t * (wy - vy)));
1998 return (mx - vx) * (mx - vx) + (my - vy) * (my - vy);
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)
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
void setVisibility(bool bVisible)
void setPoint1(const OPoint3D &point1)
void setColor(const OColor &oColor)
void setPoint2(const OPoint3D &point2)
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.
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.
Classe generique pour une fenetre de modeleur.
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 updateDisplayList(void)
void updateDisplayListOverlay(TYGeometryNode *pElement, TYGeometryNode *pDansCeRepere)
void addOGLElement(OGLElement *pOGLElement)
void removeOGLElement(OGLElement *pOGLElement)
OGLCamera * getActiveCamera()
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 _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 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.
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.
TYCameraEditor * _pCamEditor
Un CameraEditor associe a cet editor.
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.
TYOpenGLRenderer * getRenderer()
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)