[qet] [2057] Added QET::round() and QET::roundPoint().

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 2057
Author:   xavier
Date:     2013-03-06 19:50:46 +0100 (Wed, 06 Mar 2013)
Log Message:
-----------
Added QET::round() and QET::roundPoint().

Modified Paths:
--------------
    trunk/sources/qet.cpp
    trunk/sources/qet.h

Modified: trunk/sources/qet.cpp
===================================================================
--- trunk/sources/qet.cpp	2013-03-04 06:30:44 UTC (rev 2056)
+++ trunk/sources/qet.cpp	2013-03-06 18:50:46 UTC (rev 2057)
@@ -498,6 +498,21 @@
 }
 
 /**
+	Round \a x to the nearest multiple of the invert of \a epsilon.
+	For instance, epsilon = 10 will round to 1/10 = 0.1
+*/
+qreal QET::round(qreal x, qreal epsilon) {
+	return(int(x * epsilon) / epsilon);
+}
+
+/**
+	Round the coordinates of \a p to the nearest multiple of \a epsilon.
+*/
+QPointF QET::roundPoint(const QPointF &p, qreal epsilon) {
+	return(QPointF(QET::round(p.x(), epsilon), QET::round(p.y(), epsilon)));
+}
+
+/**
 	@param angle Un angle quelconque
 	@return l'angle passe en parametre, mais ramene entre -360.0 + 360.0 degres
 */

Modified: trunk/sources/qet.h
===================================================================
--- trunk/sources/qet.h	2013-03-04 06:30:44 UTC (rev 2056)
+++ trunk/sources/qet.h	2013-03-06 18:50:46 UTC (rev 2057)
@@ -161,6 +161,8 @@
 	QString diagramAreaToString(const QET::DiagramArea &);
 	QET::DiagramArea diagramAreaFromString(const QString &);
 	QString pointerString(void *);
+	qreal round(qreal, qreal);
+	QPointF roundPoint(const QPointF &, qreal);
 	qreal correctAngle(const qreal &);
 	bool compareCanonicalFilePaths(const QString &, const QString &);
 	QString titleBlockColumnLengthToString(const TitleBlockColumnLength  &);


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/