X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fpainter.cpp;h=a649306c74ecd96be81cbba047c8cba253be5d99;hb=e8987f4028a1f9c0eeb33a45bd11b2e409b9c2c5;hp=6cfd91f8ef62641d6584158631c6a3834866532a;hpb=11802354d1ddc5bc571d83d8fc9b600618cb4372;p=architektonas diff --git a/src/painter.cpp b/src/painter.cpp index 6cfd91f..a649306 100644 --- a/src/painter.cpp +++ b/src/painter.cpp @@ -208,6 +208,7 @@ void Painter::DrawPoint(int x, int y) } +// The rect passed in is in Qt coordinates... void Painter::DrawRoundedRect(QRectF rect, double radiusX, double radiusY) { if (!painter) @@ -217,6 +218,21 @@ 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) +{ + if (!painter) + return; + + Vector v1 = CartesianToQtCoords(Vector(rect.x(), rect.y())); + Vector v2 = CartesianToQtCoords(Vector(rect.right(), rect.bottom())); + 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) { if (!painter) @@ -240,6 +256,9 @@ void Painter::DrawText(QRectF rect, int type, QString text) void Painter::DrawArrowhead(Vector head, Vector tail, double size) { + if (!painter) + return; + QPolygonF arrow; // We draw the arrowhead aligned along the line from tail to head @@ -261,3 +280,15 @@ void Painter::DrawArrowhead(Vector head, Vector tail, double size) painter->drawPolygon(arrow); } + +// Point is given in Cartesian coordinates +void Painter::DrawCrosshair(Vector point) +{ + if (!painter) + return; + + Vector screenPoint = CartesianToQtCoords(point); + painter->drawLine(0, screenPoint.y, screenSize.x, screenPoint.y); + painter->drawLine(screenPoint.x, 0, screenPoint.x, screenSize.y); +} +