From: Shamus Hammons Date: Wed, 13 May 2015 20:13:54 +0000 (-0500) Subject: Removing cruft. :-) X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=architektonas;a=commitdiff_plain;h=833a64e86dbed3bb953ff945c1e8b130e1e78a58 Removing cruft. :-) --- diff --git a/src/drawarcaction.cpp b/src/drawarcaction.cpp deleted file mode 100644 index 290f8dd..0000000 --- a/src/drawarcaction.cpp +++ /dev/null @@ -1,135 +0,0 @@ -// 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 -// -// 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*/) -{ -} - diff --git a/src/drawarcaction.h b/src/drawarcaction.h deleted file mode 100644 index f11b2fa..0000000 --- a/src/drawarcaction.h +++ /dev/null @@ -1,29 +0,0 @@ -#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__ - diff --git a/src/drawcircleaction.cpp b/src/drawcircleaction.cpp deleted file mode 100644 index 0a2ac79..0000000 --- a/src/drawcircleaction.cpp +++ /dev/null @@ -1,94 +0,0 @@ -// 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 -// -// 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*/) -{ -} - diff --git a/src/drawcircleaction.h b/src/drawcircleaction.h deleted file mode 100644 index ab43259..0000000 --- a/src/drawcircleaction.h +++ /dev/null @@ -1,28 +0,0 @@ -#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__ - diff --git a/src/drawlineaction.cpp b/src/drawlineaction.cpp deleted file mode 100644 index 3dc9f7d..0000000 --- a/src/drawlineaction.cpp +++ /dev/null @@ -1,136 +0,0 @@ -// 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 -// -// 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()); - } -} - diff --git a/src/drawlineaction.h b/src/drawlineaction.h deleted file mode 100644 index 7caa814..0000000 --- a/src/drawlineaction.h +++ /dev/null @@ -1,29 +0,0 @@ -#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__ - diff --git a/src/rotateaction.cpp b/src/rotateaction.cpp deleted file mode 100644 index 071b31d..0000000 --- a/src/rotateaction.cpp +++ /dev/null @@ -1,168 +0,0 @@ -// 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 -// -// 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()); - } -} - diff --git a/src/rotateaction.h b/src/rotateaction.h deleted file mode 100644 index 3d8cdc3..0000000 --- a/src/rotateaction.h +++ /dev/null @@ -1,33 +0,0 @@ -#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__ -