// (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
// --- ---------- ------------------------------------------------------------
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.
// 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();
}