+++ /dev/null
-// drawarcaction.cpp: Draw arc object
-//
-// 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 08/13/2013 Created this file
-//
-
-#include "drawarcaction.h"
-#include "arc.h"
-#include "mathconstants.h"
-#include "painter.h"
-
-
-enum { FIRST_POINT, SECOND_POINT, THIRD_POINT };
-
-
-DrawArcAction::DrawArcAction(): state(FIRST_POINT), arc(NULL)
-{
-}
-
-
-DrawArcAction::~DrawArcAction()
-{
-}
-
-
-/*virtual*/ void DrawArcAction::Draw(Painter * painter)
-{
- 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 if (state == SECOND_POINT)
- {
- painter->DrawLine(p1, p2);
- painter->DrawHandle(p2);
- }
- else if (state == THIRD_POINT)
- {
- painter->DrawLine(p1, p2);
- painter->DrawArc(p1, radius, startAngle, span);
- painter->DrawHandle(p3);
- }
-}
-
-
-/*virtual*/ void DrawArcAction::MouseDown(Vector point)
-{
- if (state == FIRST_POINT)
- // How to check for hitting an object here?
- p1 = 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;
- }
-}
-
-
-/*virtual*/ void DrawArcAction::MouseMoved(Vector point)
-{
- if (state == FIRST_POINT)
- p1 = 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;
- }
-}
-
-
-/*virtual*/ void DrawArcAction::MouseReleased(void)
-{
- if (state == FIRST_POINT)
- {
- state = SECOND_POINT;
- }
- else if (state == SECOND_POINT)
- {
- state = THIRD_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.
- 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*/ void DrawArcAction::KeyDown(int /*key*/)
-{
-}
-
-
-/*virtual*/ void DrawArcAction::KeyReleased(int /*key*/)
-{
-}
-
+++ /dev/null
-#ifndef __DRAWARCACTION_H__
-#define __DRAWARCACTION_H__
-
-#include "action.h"
-
-class Arc;
-
-class DrawArcAction: public Action
-{
- public:
- DrawArcAction();
- ~DrawArcAction();
-
- virtual void Draw(Painter *);
- virtual void MouseDown(Vector);
- virtual void MouseMoved(Vector);
- virtual void MouseReleased(void);
- virtual void KeyDown(int);
- virtual void KeyReleased(int);
-
- private:
- int state;
- Arc * arc;
- Vector p1, p2, p3;
- double radius, startAngle, span;
-};
-
-#endif // __DRAWARCACTION_H__
-
+++ /dev/null
-// drawcircleaction.cpp: Action class for drawing circles
-//
-// Part of the Architektonas Project
-// (C) 2012 Underground Software
-// See the README and GPLv3 files for licensing and warranty information
-//
-// JLH = James Hammons <jlhamm@acm.org>
-//
-// WHO WHEN WHAT
-// --- ---------- ------------------------------------------------------------
-// JLH 02/01/2012 Created this file
-//
-
-#include "drawcircleaction.h"
-#include "circle.h"
-#include "painter.h"
-#include "vector.h"
-
-
-enum { FIRST_POINT, NEXT_POINT };
-
-
-DrawCircleAction::DrawCircleAction(): state(0), circle(NULL)
-{
-}
-
-DrawCircleAction::~DrawCircleAction()
-{
-}
-
-
-/*virtual*/ void DrawCircleAction::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->DrawHandle(p1);
- double radius = Vector::Magnitude(p1, p2);
- painter->DrawEllipse(p1, radius, radius);
- }
-}
-
-/*virtual*/ void DrawCircleAction::MouseDown(Vector point)
-{
- if (state == FIRST_POINT)
- p1 = point;
- else
- p2 = point;
-}
-
-/*virtual*/ void DrawCircleAction::MouseMoved(Vector point)
-{
- if (state == FIRST_POINT)
- p1 = point;
- else
- p2 = point;
-}
-
-/*virtual*/ void DrawCircleAction::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.
- circle = new Circle(p1, Vector::Magnitude(p1, p2));
- // We don't need no stinkin' sentinels, when we have signals & slots!
- emit ObjectReady(circle);
-
- state = FIRST_POINT;
- p1 = p2;
- }
-}
-
-
-/*virtual*/ void DrawCircleAction::KeyDown(int /*key*/)
-{
-}
-
-
-/*virtual*/ void DrawCircleAction::KeyReleased(int /*key*/)
-{
-}
-
+++ /dev/null
-#ifndef __DRAWCIRCLEACTION_H__
-#define __DRAWCIRCLEACTION_H__
-
-#include "action.h"
-
-class Circle;
-
-class DrawCircleAction: public Action
-{
- public:
- DrawCircleAction();
- ~DrawCircleAction();
-
- virtual void Draw(Painter *);
- virtual void MouseDown(Vector);
- virtual void MouseMoved(Vector);
- virtual void MouseReleased(void);
- virtual void KeyDown(int);
- virtual void KeyReleased(int);
-
- private:
- int state;
- Circle * circle;
- Vector p1, p2;
-};
-
-#endif // __DRAWCIRCLEACTION_H__
-
+++ /dev/null
-// drawlineaction.cpp: Action class for drawing lines
-//
-// 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 10/04/2011 Created this file
-// JLH 11/07/2011 Made it so this class actually does something ;-)
-//
-
-#include "drawlineaction.h"
-#include "line.h"
-#include "mathconstants.h"
-#include "painter.h"
-
-
-enum { FIRST_POINT, NEXT_POINT };
-
-
-DrawLineAction::DrawLineAction(): state(FIRST_POINT), line(NULL),
- shiftWasPressedOnNextPoint(false)
-{
-}
-
-
-DrawLineAction::~DrawLineAction()
-{
-}
-
-
-/*virtual*/ void DrawLineAction::Draw(Painter * painter)
-{
- painter->SetPen(QPen(Qt::red, 2.0, Qt::DotLine));
-
- // I think stuff like crosshairs should be done in the DrawingView, tho
- // (and it's done there now...)
- if (state == FIRST_POINT)
- {
- painter->DrawHandle(p1);
- }
- else
- {
- painter->DrawLine(p1, p2);
- painter->DrawHandle(p2);
-
- Vector v(p1, p2);
- double absAngle = v.Angle() * RADIANS_TO_DEGREES;
- double absLength = v.Magnitude();
- QString text = tr("Length: %1 in.\n") + QChar(0x2221) + tr(": %2");
- text = text.arg(absLength).arg(absAngle);
- painter->DrawInformativeText(text);
- }
-}
-
-
-/*virtual*/ void DrawLineAction::MouseDown(Vector point)
-{
- // Clear our override...
- shiftWasPressedOnNextPoint = false;
-
- if (state == FIRST_POINT)
- p1 = point;
- else
- p2 = point;
-}
-
-
-/*virtual*/ void DrawLineAction::MouseMoved(Vector point)
-{
- if (state == FIRST_POINT)
- p1 = point;
- else
- p2 = point;
-}
-
-
-/*virtual*/ void DrawLineAction::MouseReleased(void)
-{
- if (state == FIRST_POINT)
- {
- p2 = p1;
- state = NEXT_POINT;
- line = NULL;
- }
- else if (state == NEXT_POINT)
- {
- Line * oldLine = line;
- // 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);
-
- // Connect Lines by default
- if (oldLine)
- {
- oldLine->Connect(line, 0);
- line->Connect(oldLine, 1.0);
- }
-
- // We don't need no stinkin' sentinels, when we have signals & slots!
- emit ObjectReady(line);
-
- p1 = p2;
- state = NEXT_POINT;
- }
-}
-
-
-/*virtual*/ void DrawLineAction::KeyDown(int key)
-{
- if ((key == Qt::Key_Shift) && (state == NEXT_POINT))
- {
- shiftWasPressedOnNextPoint = true;
- p1Save = p1;
- p1 = p2;
- state = FIRST_POINT;
- emit NeedRefresh();
- }
-}
-
-
-/*virtual*/ void DrawLineAction::KeyReleased(int key)
-{
- if ((key == Qt::Key_Shift) && shiftWasPressedOnNextPoint)
- {
- shiftWasPressedOnNextPoint = false;
- p2 = p1;
- p1 = p1Save;
- state = NEXT_POINT;
- emit(NeedRefresh());
- }
-}
-
+++ /dev/null
-#ifndef __DRAWLINEACTION_H__
-#define __DRAWLINEACTION_H__
-
-#include "action.h"
-
-class Line;
-
-class DrawLineAction: public Action
-{
- public:
- DrawLineAction();
- ~DrawLineAction();
-
- virtual void Draw(Painter *);
- virtual void MouseDown(Vector);
- virtual void MouseMoved(Vector);
- virtual void MouseReleased(void);
- virtual void KeyDown(int);
- virtual void KeyReleased(int);
-
- private:
- int state;
- Line * line;
- Vector p1, p2, p1Save;
- bool shiftWasPressedOnNextPoint;
-};
-
-#endif // __DRAWLINEACTION_H__
-
+++ /dev/null
-// rotateaction.cpp: Action class for rotating selected objects
-//
-// 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 09/03/2011 Created this file
-//
-
-#include "rotateaction.h"
-#include "applicationwindow.h"
-#include "container.h"
-#include "drawingview.h"
-#include "line.h"
-#include "mathconstants.h"
-#include "painter.h"
-
-
-enum { FIRST_POINT, NEXT_POINT };
-
-
-RotateAction::RotateAction(): state(FIRST_POINT), line(NULL),
- shiftWasPressedOnNextPoint(false), ctrlWasPressed(false),
- spin(new Container(Vector()))
-{
- ApplicationWindow::drawing->document.CopySelectedContentsTo(spin);
- spin->Save();
-}
-
-
-RotateAction::~RotateAction()
-{
-}
-
-
-/*virtual*/ void RotateAction::Draw(Painter * painter)
-{
- painter->SetPen(QPen(Qt::red, 2.0, Qt::DotLine));
-
- // I think stuff like crosshairs should be done in the DrawingView, tho
- // (and it's done there now...)
- if (state == FIRST_POINT)
- {
- painter->DrawHandle(p1);
- }
- else
- {
- painter->DrawHandle(p1);
-
- // Draw the rotated objects only if there's been a line to spin around
- if (p1 == p2)
- return;
-
- painter->DrawLine(p1, p2);
-
- double absAngle = (Vector(p2 - p1).Angle()) * RADIANS_TO_DEGREES;
-
- QString text = QChar(0x2221) + QObject::tr(": %1");
- text = text.arg(absAngle);
-
- if (ctrlWasPressed)
- text += " (Copy)";
-
- painter->DrawInformativeText(text);
-
-// this does nothing, because the objects override any color set here with
-// their own pens... :-/
-// Which means we have to have a flag in the object to tell it not to color itself.
-// if (ctrlWasPressed)
-// painter->SetPen(QPen(Qt::green, 3.0, Qt::SolidLine));
-
- spin->Draw(painter);
- }
-}
-
-
-/*virtual*/ void RotateAction::MouseDown(Vector point)
-{
- // Clear our override...
- shiftWasPressedOnNextPoint = false;
-
- if (state == FIRST_POINT)
- p1 = point;
- else
- p2 = point;
-}
-
-
-/*virtual*/ void RotateAction::MouseMoved(Vector point)
-{
- if (state == FIRST_POINT)
- p1 = point;
- else
- {
- p2 = point;
- double angle = Vector(p2, p1).Angle();
- spin->Restore();
- spin->Rotate(p1, angle);
- }
-}
-
-
-/*virtual*/ void RotateAction::MouseReleased(void)
-{
- if (state == FIRST_POINT)
- {
- p2 = p1;
- state = NEXT_POINT;
- }
- else if (state == NEXT_POINT)
- {
- if (!ctrlWasPressed)
- {
- state = FIRST_POINT;
- double angle = Vector(p2, p1).Angle();
- ApplicationWindow::drawing->document.RotateSelected(p1, angle);
-
- spin->Clear();
- ApplicationWindow::drawing->document.CopySelectedContentsTo(spin);
- spin->Save();
- }
- else
- {
- spin->CopyContentsTo(&(ApplicationWindow::drawing->document));
- }
- }
-}
-
-
-/*virtual*/ void RotateAction::KeyDown(int key)
-{
- if ((key == Qt::Key_Shift) && (state == NEXT_POINT))
- {
- shiftWasPressedOnNextPoint = true;
- p1Save = p1;
- p1 = p2;
- state = FIRST_POINT;
- emit(NeedRefresh());
- }
- else if (key == Qt::Key_Control)
- {
- ctrlWasPressed = true;
- emit(NeedRefresh());
- }
-}
-
-
-/*virtual*/ void RotateAction::KeyReleased(int key)
-{
- if ((key == Qt::Key_Shift) && shiftWasPressedOnNextPoint)
- {
- shiftWasPressedOnNextPoint = false;
- p2 = p1;
- p1 = p1Save;
- state = NEXT_POINT;
- emit(NeedRefresh());
- }
- else if (key == Qt::Key_Control)
- {
- ctrlWasPressed = false;
- emit(NeedRefresh());
- }
-}
-
+++ /dev/null
-#ifndef __ROTATEACTION_H__
-#define __ROTATEACTION_H__
-
-#include "action.h"
-
-class Container;
-class Line;
-
-class RotateAction: public Action
-{
- public:
- RotateAction();
- ~RotateAction();
-
- virtual void Draw(Painter *);
- virtual void MouseDown(Vector);
- virtual void MouseMoved(Vector);
- virtual void MouseReleased(void);
- virtual void KeyDown(int);
- virtual void KeyReleased(int);
-
- private:
- int state;
- Line * line;
- Point p1, p2, p1Save;
- bool shiftWasPressedOnNextPoint;
- bool ctrlWasPressed;
-// Container * selected;
- Container * spin;
-};
-
-#endif // __ROTATEACTION_H__
-