]> Shamusworld >> Repos - ttedit/blobdiff - src/painter.cpp
Added preview window to file loading dialog. :-)
[ttedit] / src / painter.cpp
index 16268e70b38535c9ca42090e9f6e17a9a11c4b8d..869843933fd7f9726554dff7ba0c5c280499de2e 100644 (file)
@@ -8,7 +8,7 @@
 // JLH = James Hammons <jlhamm@acm.org>
 //
 // WHO  WHEN        WHAT
-// ---  ----------  ------------------------------------------------------------
+// ---  ----------  -----------------------------------------------------------
 // JLH  09/20/2011  Created this file
 //
 
@@ -148,11 +148,19 @@ void Painter::DrawAngledText(Vector center, double angle, QString text, double s
        float yOffset = -12.0 * Global::zoom * size;
 
        // Fix text so it isn't upside down...
+#if 0
        if ((angle > PI * 0.5) && (angle < PI * 1.5))
        {
                angle += PI;
                yOffset = 12.0 * Global::zoom * size;
        }
+#else
+       if ((angle > QTR_TAU) && (angle < THREE_QTR_TAU))
+       {
+               angle += HALF_TAU;
+               yOffset = 12.0 * Global::zoom * size;
+       }
+#endif
 
        textBox.translate(0, yOffset);
        painter->save();
@@ -230,7 +238,11 @@ void Painter::DrawArrowHandle(Vector center, double angle)
 
        // Since we're drawing directly on the screen, the Y is inverted. So we use
        // the mirror of the angle.
+#if 0
        double orthoAngle = -angle + (PI / 2.0);
+#else
+       double orthoAngle = -angle + QTR_TAU;
+#endif
        Vector orthogonal = Vector(cos(orthoAngle), sin(orthoAngle));
        Vector unit = Vector(cos(-angle), sin(-angle));
 
@@ -256,7 +268,11 @@ void Painter::DrawArrowToLineHandle(Vector center, double angle)
 
        // Since we're drawing directly on the screen, the Y is inverted. So we use
        // the mirror of the angle.
+#if 0
        double orthoAngle = -angle + (PI / 2.0);
+#else
+       double orthoAngle = -angle + QTR_TAU;
+#endif
        Vector orthogonal = Vector(cos(orthoAngle), sin(orthoAngle));
        Vector unit = Vector(cos(-angle), sin(-angle));
 
@@ -279,6 +295,17 @@ void Painter::DrawLine(int x1, int y1, int x2, int y2)
 }
 
 
+void Painter::DrawLine(IPoint p1, IPoint p2)
+{
+       if (!painter)
+               return;
+
+       Vector v1 = CartesianToQtCoords(Vector(p1.x, p1.y));
+       Vector v2 = CartesianToQtCoords(Vector(p2.x, p2.y));
+       painter->drawLine(v1.x, v1.y, v2.x, v2.y);
+}
+
+
 void Painter::DrawLine(Vector v1, Vector v2)
 {
        if (!painter)
@@ -355,7 +382,11 @@ void Painter::DrawArrowhead(Vector head, Vector tail, double size)
 
        // We draw the arrowhead aligned along the line from tail to head
        double angle = Vector(head - tail).Angle();
+#if 0
        double orthoAngle = angle + (PI / 2.0);
+#else
+       double orthoAngle = angle + QTR_TAU;
+#endif
        Vector orthogonal = Vector(cos(orthoAngle), sin(orthoAngle));
        Vector unit = Vector(head - tail).Unit();