diff --git a/element.cpp b/element.cpp index f1dcedb63..fa3b028e7 100644 --- a/element.cpp +++ b/element.cpp @@ -26,7 +26,24 @@ Element::~Element() { @param options Les options de style a prendre en compte @param widget Le widget sur lequel on dessine */ -void Element::paint(QPainter *painter, const QStyleOptionGraphicsItem *options, QWidget *) { +void Element::paint(QPainter *painter, const QStyleOptionGraphicsItem *options, QWidget *widget) { + +#ifdef Q_WS_X11 + // corrige un bug de rendu ne se produisant que lors du rendu sur QGraphicsScene sous X11 au zoom par defaut + static bool must_correct_rendering_bug = !QString(qVersion()).startsWith("4.4"); + if (must_correct_rendering_bug) { + Diagram *dia = diagram(); + if (dia && options -> levelOfDetail == 1.0 && widget) { + // calcule la rotation qu'a subi l'element + qreal applied_rotation = 90.0 * (ori.current() - ori.defaultOrientation()); + while (applied_rotation < 360.0) applied_rotation += 360.0; + while (applied_rotation > 360.0) applied_rotation -= 360.0; + if (applied_rotation == 90.0) painter -> translate(1.0, -1.0); + else if (applied_rotation == 180.0) painter -> translate(-1.0, -1.0); + else if (applied_rotation == 270.0) painter -> translate(-1.0, 1.0); + } + } +#endif // Dessin de l'element lui-meme paint(painter, options); diff --git a/terminal.cpp b/terminal.cpp index f87fb085d..fabab78e8 100644 --- a/terminal.cpp +++ b/terminal.cpp @@ -163,9 +163,32 @@ void Terminal::removeConductor(Conductor *f) { @param options Les options de dessin @param widget Le widget sur lequel on dessine */ -void Terminal::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) { +void Terminal::paint(QPainter *p, const QStyleOptionGraphicsItem *options, QWidget *widget) { p -> save(); +#ifdef Q_WS_X11 + // corrige un bug de rendu ne se produisant que lors du rendu sur QGraphicsScene sous X11 au zoom par defaut + static bool must_correct_rendering_bug = !QString(qVersion()).startsWith("4.4"); + if (must_correct_rendering_bug) { + Diagram *dia = diagram(); + if (dia && options -> levelOfDetail == 1.0 && widget) { + // calcule la rotation qu'a subi l'element + qreal applied_rotation = 0.0; + if (Element *elt = qgraphicsitem_cast(parentItem())) { + // 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; + } + if (applied_rotation == 90.0) p -> translate(1.0, -1.0); + else if (applied_rotation == 180.0) p -> translate(-1.0, -1.0); + else if (applied_rotation == 270.0) p -> translate(-1.0, 1.0); + } + } +#endif + //annulation des renderhints p -> setRenderHint(QPainter::Antialiasing, false); p -> setRenderHint(QPainter::TextAntialiasing, false);