From dbf3cda58f48125fafd1e4ac5b78fcd32055eb72 Mon Sep 17 00:00:00 2001 From: xavier Date: Sun, 13 Dec 2009 16:43:35 +0000 Subject: [PATCH] Creation de la methode QET::correctAngle. git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/branches/0.3@813 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- sources/qet.cpp | 12 ++++++++++++ sources/qet.h | 1 + sources/terminal.cpp | 4 +--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/sources/qet.cpp b/sources/qet.cpp index c35bddb46..45b1d7af3 100644 --- a/sources/qet.cpp +++ b/sources/qet.cpp @@ -434,3 +434,15 @@ QString QET::pointerString(void *ptr) { ) ); } + +/** + @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); +} diff --git a/sources/qet.h b/sources/qet.h index 283655f73..ce32b4dd2 100644 --- a/sources/qet.h +++ b/sources/qet.h @@ -121,5 +121,6 @@ namespace QET { QString diagramAreaToString(const QET::DiagramArea &); QET::DiagramArea diagramAreaFromString(const QString &); QString pointerString(void *); + qreal correctAngle(const qreal &); } #endif diff --git a/sources/terminal.cpp b/sources/terminal.cpp index e5207cb65..d33499333 100644 --- a/sources/terminal.cpp +++ b/sources/terminal.cpp @@ -199,9 +199,7 @@ void Terminal::paint(QPainter *p, const QStyleOptionGraphicsItem *options, QWidg // 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);