[qet] [813] Creation de la methode QET::correctAngle. |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 813
Author: xavier
Date: 2009-12-13 17:43:35 +0100 (Sun, 13 Dec 2009)
Log Message:
-----------
Creation de la methode QET::correctAngle.
Modified Paths:
--------------
branches/0.3/sources/qet.cpp
branches/0.3/sources/qet.h
branches/0.3/sources/terminal.cpp
Modified: branches/0.3/sources/qet.cpp
===================================================================
--- branches/0.3/sources/qet.cpp 2009-12-13 15:10:59 UTC (rev 812)
+++ branches/0.3/sources/qet.cpp 2009-12-13 16:43:35 UTC (rev 813)
@@ -434,3 +434,15 @@
)
);
}
+
+/**
+ @param angle Un angle quelconque
+ @return l'angle passe en parametre, mais ramene entre -360.0 + 360.0 degres
+*/
+qreal QET::correctAngle(const qreal &angle) {
+ // ramene l'angle demande entre -360.0 et +360.0 degres
+ qreal corrected_angle = angle;
+ while (corrected_angle < 360.0) corrected_angle += 360.0;
+ while (corrected_angle > 360.0) corrected_angle -= 360.0;
+ return(corrected_angle);
+}
Modified: branches/0.3/sources/qet.h
===================================================================
--- branches/0.3/sources/qet.h 2009-12-13 15:10:59 UTC (rev 812)
+++ branches/0.3/sources/qet.h 2009-12-13 16:43:35 UTC (rev 813)
@@ -121,5 +121,6 @@
QString diagramAreaToString(const QET::DiagramArea &);
QET::DiagramArea diagramAreaFromString(const QString &);
QString pointerString(void *);
+ qreal correctAngle(const qreal &);
}
#endif
Modified: branches/0.3/sources/terminal.cpp
===================================================================
--- branches/0.3/sources/terminal.cpp 2009-12-13 15:10:59 UTC (rev 812)
+++ branches/0.3/sources/terminal.cpp 2009-12-13 16:43:35 UTC (rev 813)
@@ -199,9 +199,7 @@
// orientations actuelle et par defaut de l'element
QET::Orientation ori_cur = elt -> orientation().current();
QET::Orientation ori_def = elt -> orientation().defaultOrientation();
- applied_rotation = 90.0 * (ori_cur - ori_def);
- while (applied_rotation < 360.0) applied_rotation += 360.0;
- while (applied_rotation > 360.0) applied_rotation -= 360.0;
+ applied_rotation = QET::correctAngle(90.0 * (ori_cur - ori_def));
}
if (applied_rotation == 90.0) p -> translate(1.0, -1.0);
else if (applied_rotation == 180.0) p -> translate(-1.0, -1.0);