//
#include "drawarcaction.h"
-#include "painter.h"
#include "arc.h"
+#include "mathconstants.h"
+#include "painter.h"
//#include "vector.h"
enum { FIRST_POINT, SECOND_POINT, THIRD_POINT };
-//#define FIRST_POINT 0
-//#define SECOND_POINT 1
-#define NEXT_POINT 2
DrawArcAction::DrawArcAction(): state(FIRST_POINT), arc(NULL)
painter->SetPen(QPen(Qt::red, 2.0, Qt::DotLine));
// I think stuff like crosshairs should be done in the DrawingView, tho
+ // (and it is! :-D)
if (state == FIRST_POINT)
{
painter->DrawHandle(p1);
}
- else
+ else if (state == SECOND_POINT)
+ {
+ painter->DrawLine(p1, p2);
+ painter->DrawHandle(p2);
+ }
+ else if (state == THIRD_POINT)
{
-// painter->DrawLine(p1, p2);
-// painter->DrawHandle(p2);
+ painter->DrawLine(p1, p2);
+ painter->DrawArc(p1, radius, startAngle, span);
+ painter->DrawHandle(p3);
}
}
{
if (state == FIRST_POINT)
p1 = point;
-// else
-// p2 = point;
+ else if (state == SECOND_POINT)
+ {
+ p2 = point;
+ Vector r1(p2, p1);
+ radius = Vector::Magnitude(p1, p2);
+ startAngle = r1.Angle();
+ }
+ else if (state == THIRD_POINT)
+ {
+ p3 = point;
+ Vector r2(p3, p1);
+ span = r2.Angle() - startAngle;
+
+ if (span < 0)
+ span += 2.0 * PI;
+ }
}
{
if (state == FIRST_POINT)
p1 = point;
-// else
-// p2 = point;
+ else if (state == SECOND_POINT)
+ {
+ p2 = point;
+ Vector r1(p2, p1);
+ radius = Vector::Magnitude(p1, p2);
+ startAngle = r1.Angle();
+ }
+ else if (state == THIRD_POINT)
+ {
+ p3 = point;
+ Vector r2(p3, p1);
+ span = r2.Angle() - startAngle;
+
+ if (span < 0)
+ span += 2.0 * PI;
+ }
}
{
if (state == FIRST_POINT)
{
-// p2 = p1;
- state = NEXT_POINT;
+ state = SECOND_POINT;
+ }
+ else if (state == SECOND_POINT)
+ {
+ state = THIRD_POINT;
}
- else if (state == NEXT_POINT)
+ else if (state == THIRD_POINT)
{
// We create the new object here, and then pass it off to the
// DrawingView which stuffs it into the document.
-// text = new Text(p1, p2);
-// arc = new Arc(...);
+ arc = new Arc(p1, radius, startAngle, span);
// We don't need no stinkin' sentinels, when we have signals & slots!
emit ObjectReady(arc);
+
+ state = FIRST_POINT;
}
}
+
+/*virtual*/ bool DrawArcAction::KeyDown(int /*key*/)
+{
+ return false;
+}
+
+
+/*virtual*/ bool DrawArcAction::KeyReleased(int /*key*/)
+{
+ return false;
+}
+