]> Shamusworld >> Repos - architektonas/blobdiff - src/painter.cpp
Preliminary support for Polylines.
[architektonas] / src / painter.cpp
index 322e1508ebe7f5bd55172b93ecae6c591fc4a74f..2314a8559b4de310848a8af737096b0e829b3712 100644 (file)
@@ -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)