[qet] [3710] Diagram disable element snap To Grid by Qt::ControlModifier touch |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 3710
Author: scorpio810
Date: 2015-02-12 13:43:13 +0100 (Thu, 12 Feb 2015)
Log Message:
-----------
Diagram disable element snap To Grid by Qt::ControlModifier touch
Modified Paths:
--------------
trunk/sources/diagram.cpp
Modified: trunk/sources/diagram.cpp
===================================================================
--- trunk/sources/diagram.cpp 2015-02-12 10:22:40 UTC (rev 3709)
+++ trunk/sources/diagram.cpp 2015-02-12 12:43:13 UTC (rev 3710)
@@ -1134,12 +1134,24 @@
*/
QPointF Diagram::snapToGrid(const QPointF &p) {
// arrondit l'abscisse a 10 px pres
+ if (QApplication::keyboardModifiers().testFlag(Qt::ControlModifier) == true) {
+ // arrondit l'abscisse a 1 px pres
+ int p_x = qRound(p.x());
+ // arrondit l'ordonnee a 1 px pres
+ int p_y = qRound(p.y());
+ return (QPointF(p_x, p_y));
+ }
+ else if (QApplication::keyboardModifiers().testFlag(Qt::ControlModifier) == false) {
+ // arrondit l'ordonnee a 10 px pres
int p_x = qRound(p.x() / (Diagram::xGrid * 1.0)) * Diagram::xGrid;
// arrondit l'ordonnee a 10 px pres
int p_y = qRound(p.y() / (Diagram::yGrid * 1.0)) * Diagram::yGrid;
return (QPointF(p_x, p_y));
+ }
}
+
+
/**
Definit s'il faut afficher ou non les bornes
@param dt true pour afficher les bornes, false sinon