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
This commit is contained in:
xavier
2009-12-13 16:43:35 +00:00
parent b66f42e2ef
commit dbf3cda58f
3 changed files with 14 additions and 3 deletions

View File

@@ -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);
}

View File

@@ -121,5 +121,6 @@ namespace QET {
QString diagramAreaToString(const QET::DiagramArea &);
QET::DiagramArea diagramAreaFromString(const QString &);
QString pointerString(void *);
qreal correctAngle(const qreal &);
}
#endif

View File

@@ -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);