--- /dev/null
+// drawdimensionaction.cpp: Action class for drawing dimensions
+//
+// Part of the Architektonas Project
+// (C) 2011 Underground Software
+// See the README and GPLv3 files for licensing and warranty information
+//
+// JLH = James Hammons <jlhamm@acm.org>
+//
+// WHO WHEN WHAT
+// --- ---------- ------------------------------------------------------------
+// JLH 03/15/2013 Created this file
+//
+
+#include "drawdimensionaction.h"
+#include "dimension.h"
+#include "painter.h"
+//#include "vector.h"
+
+
+#define FIRST_POINT 0
+#define NEXT_POINT 1
+
+
+DrawDimensionAction::DrawDimensionAction(): state(0), dimension(NULL)
+{
+}
+
+
+DrawDimensionAction::~DrawDimensionAction()
+{
+}
+
+
+/*virtual*/ void DrawDimensionAction::Draw(Painter * painter)
+{
+ painter->SetPen(QPen(Qt::red, 2.0, Qt::DotLine));
+
+ // I think stuff like crosshairs should be done in the DrawingView, tho
+ if (state == FIRST_POINT)
+ {
+ painter->DrawHandle(p1);
+ }
+ else
+ {
+ painter->DrawLine(p1, p2);
+ painter->DrawHandle(p2);
+ }
+}
+
+
+/*virtual*/ void DrawDimensionAction::MouseDown(Vector point)
+{
+ if (state == FIRST_POINT)
+ p1 = point;
+ else
+ p2 = point;
+}
+
+
+/*virtual*/ void DrawDimensionAction::MouseMoved(Vector point)
+{
+ if (state == FIRST_POINT)
+ p1 = point;
+ else
+ p2 = point;
+}
+
+
+/*virtual*/ void DrawDimensionAction::MouseReleased(void)
+{
+ if (state == FIRST_POINT)
+ {
+ p2 = p1;
+ state = NEXT_POINT;
+ }
+ else if (state == NEXT_POINT)
+ {
+ // We create the new object here, and then pass it off to the
+ // DrawingView which stuffs it into the document.
+// line = new Line(p1, p2);
+ // We don't need no stinkin' sentinels, when we have signals & slots!
+ emit ObjectReady(dimension);
+
+ p1 = p2;
+ }
+}
+
--- /dev/null
+#ifndef __DRAWDIMENSIONACTION_H__
+#define __DRAWDIMENSIONACTION_H__
+
+#include "action.h"
+
+class Dimension;
+
+class DrawDimensionAction: public Action
+{
+ public:
+ DrawDimensionAction();
+ ~DrawDimensionAction();
+
+ virtual void Draw(Painter *);
+ virtual void MouseDown(Vector);
+ virtual void MouseMoved(Vector);
+ virtual void MouseReleased(void);
+
+ private:
+ int state;
+ Dimension * dimension;
+ Vector p1, p2;
+};
+
+#endif // __DRAWDIMENSIONACTION_H__