X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fpainter.cpp;h=2314a8559b4de310848a8af737096b0e829b3712;hb=refs%2Fheads%2Fmaster;hp=322e1508ebe7f5bd55172b93ecae6c591fc4a74f;hpb=eb39f1bb5e6518c5dc4f4dbd3c88912a97192e95;p=architektonas diff --git a/src/painter.cpp b/src/painter.cpp index 322e150..2314a85 100644 --- a/src/painter.cpp +++ b/src/painter.cpp @@ -44,12 +44,12 @@ origin is -10, -10 and zoom level is 2 (200%) 1st, invert the Y: 10, 10 -> 10, 90 2nd, add origin: 10, 90 -> 0, 80 (no, not right--err, yes, it is) -3rd, aply zoom: 0, 80 -> 0, 40 +3rd, apply zoom: 0, 80 -> 0, 40 or, is it: 1st, invert the Y: 10, 10 -> 10, 90 -2nd, aply zoom: 10, 90 -> 5, 45 +2nd, apply zoom: 10, 90 -> 5, 45 3rd, add origin: 5, 45 -> -5, 35 it depends on whether or not origin is in Qt coords or cartesian. If Qt, then the 1st @@ -372,6 +372,16 @@ void Painter::DrawPoint(int x, int y) painter->drawPoint(v.x, v.y); } +// The rect passed in is in Qt coordinates... (?) +void Painter::DrawRoundedRect(Rect rect, double radiusX, double radiusY) +{ + if (!painter) + return; + + QRectF r(QPointF(rect.l, rect.t), QPointF(rect.r, rect.b)); + painter->drawRoundedRect(r, radiusX, radiusY); +} + // The rect passed in is in Qt coordinates... void Painter::DrawRoundedRect(QRectF rect, double radiusX, double radiusY) { @@ -383,35 +393,36 @@ void Painter::DrawRoundedRect(QRectF rect, double radiusX, double radiusY) // The rect passed in is in Cartesian but we want to pad it by a set number of // pixels (currently set at 8), so the pad looks the same regardless of zoom. -void Painter::DrawPaddedRect(QRectF rect) +void Painter::DrawPaddedRect(Rect rect) { if (!painter) return; - Vector v1 = CartesianToQtCoords(Vector(rect.x(), rect.y())); - Vector v2 = CartesianToQtCoords(Vector(rect.right(), rect.bottom())); + Vector v1 = CartesianToQtCoords(rect.TopLeft()); + Vector v2 = CartesianToQtCoords(rect.BottomRight()); QRectF screenRect(QPointF(v1.x, v1.y), QPointF(v2.x, v2.y)); screenRect.adjust(-8, 8, 8, -8); // Left/top, right/bottom painter->drawRect(screenRect); } -void Painter::DrawRect(QRectF rect) +void Painter::DrawRect(Rect rect) { if (!painter) return; - Vector v1 = CartesianToQtCoords(Vector(rect.x(), rect.y())); - Vector v2 = CartesianToQtCoords(Vector(rect.right(), rect.bottom())); + Vector v1 = CartesianToQtCoords(rect.TopLeft()); + Vector v2 = CartesianToQtCoords(rect.BottomRight()); QRectF screenRect(QPointF(v1.x, v1.y), QPointF(v2.x, v2.y)); painter->drawRect(screenRect); } -void Painter::DrawText(QRectF rect, int type, QString text) +void Painter::DrawText(Rect rect, int type, QString text) { if (!painter) return; - painter->drawText(rect, (Qt::AlignmentFlag)type, text); + QRectF r(QPointF(rect.l, rect.t), QPointF(rect.r, rect.b)); + painter->drawText(r, (Qt::AlignmentFlag)type, text); } void Painter::DrawArrowhead(Vector head, Vector tail, double size)