]> Shamusworld >> Repos - architektonas/blobdiff - src/painter.cpp
Added action for adding circles to the drawing.
[architektonas] / src / painter.cpp
index 8fe59ab9ad64720bd06d901b662d602ccf052c2c..0dfdf3c76471920a33ae7e679524f80bc8ebd73a 100644 (file)
@@ -5,7 +5,7 @@
 // (C) 2011 Underground Software
 // See the README and GPLv3 files for licensing and warranty information
 //
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
 //
 // WHO  WHEN        WHAT
 // ---  ----------  ------------------------------------------------------------
@@ -100,6 +100,9 @@ void Painter::SetPen(QPen pen)
 
 void Painter::DrawAngledText(Vector center, double angle, QString text)
 {
+       if (!painter)
+               return;
+
        // Strategy: Since Qt doesn't have any rotated text drawing functions,
        // we instead translate the origin to the center of the text to be drawn and
        // then rotate the frame to the desired angle.
@@ -114,20 +117,27 @@ void Painter::DrawAngledText(Vector center, double angle, QString text)
        // Need to figure out if dimensions are always rendered at one size regardless of zoom,
        // or if they have a definite size, and are thus zoomable.
        // If zoomable, this is incorrect:
-       int yOffset = -12;
+       // (Added zoom, so this is correct now :-)
+       int yOffset = -12 * zoom;
 
        // Fix text so it isn't upside down...
        if ((angle > PI * 0.5) && (angle < PI * 1.5))
        {
                angle += PI;
-               yOffset = 12;
+               yOffset = 12 * zoom;
        }
 
+#if 0
+       Vector offset = CartesianToQtCoords(Vector(0, yOffset));
+       textBox.translate(offset.x, offset.y);
+#else
        textBox.translate(0, yOffset);
+#endif
        painter->save();
        painter->translate(center.x, center.y);
        // Angles are backwards in the Qt coord system, so we flip ours...
        painter->rotate(-angle * RADIANS_TO_DEGREES);
+//Need to fix this so the text scales as well...
        painter->drawText(textBox, Qt::AlignCenter, text);
        painter->restore();
 }