#
# Architektonas Qt project file
#
-# by James L. Hammons
+# by James Hammons
# Copyright (C) 2011 Underground Software
#
# See the README and GPLv3 files for licensing and warranty information
src/container.h \
src/dimension.h \
src/drawingview.h \
+ src/drawcircleaction.h \
src/drawlineaction.h \
src/generaltab.h \
src/line.h \
src/container.cpp \
src/dimension.cpp \
src/drawingview.cpp \
+ src/drawcircleaction.cpp \
src/drawlineaction.cpp \
src/generaltab.cpp \
src/line.cpp \
//
// about.cpp - Credits
//
-// by James L. Hammons
+// by James Hammons
// (C) 2011 Underground Software
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// Who When What
// --- ---------- -------------------------------------------------------------
"<tr><td align='right' width='100'><b>Architektonas: </b></td><td>Free, <i>Industrial Strength</i> 2D Computer Aided Design</td></tr>"
"<tr><td align='right'><b>Version: </b></td><td>1.0.0</td></tr>"
"<tr><td align='right'><b>License: </b></td><td>GPL v3 or later</td></tr>"
- "<tr><td align='right'><b>Chief Architect: </b></td><td>James L. Hammons (shamus)</td></tr>"
- "<tr><td align='right'><b>Coders: </b></td><td>James L. Hammons (shamus)</td></tr>"
+ "<tr><td align='right'><b>Chief Architect: </b></td><td>James Hammons (shamus)</td></tr>"
+ "<tr><td align='right'><b>Coders: </b></td><td>James Hammons (shamus)</td></tr>"
// "<tr><td align='right'><b>Testers: </b></td><td>shamus</td></tr>"
"<tr><td align='right'><b>Homepage: </b></td><td>http://shamusworld.gotdns.org/architektonas/</td></tr>"
"</table>"
// (C) 2011 Underground Software
// See the README and GPLv3 files for licensing and warranty information
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// WHO WHEN WHAT
// --- ---------- ------------------------------------------------------------
// (C) 2011 Underground Software
// See the README and GPLv3 files for licensing and warranty information
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// Who When What
// --- ---------- -------------------------------------------------------------
drawing->SetAddLineToolActive(addLineAct->isChecked());
}
+void ApplicationWindow::AddCircleTool(void)
+{
+ addLineAct->setChecked(false);
+ addArcAct->setChecked(false);
+ rotateAct->setChecked(false);
+ RotateTool();
+ drawing->SetAddCircleToolActive(addCircleAct->isChecked());
+}
+
void ApplicationWindow::ZoomInTool(void)
{
double zoomFactor = 2.0;
connect(addLineAct, SIGNAL(triggered()), this, SLOT(AddLineTool()));
addCircleAct = CreateAction(tr("Add &Circle"), tr("Add Circle"), tr("Adds circles to the drawing."), QIcon(":/res/generic-tool.png"), QKeySequence("A,C"), true);
+ connect(addCircleAct, SIGNAL(triggered()), this, SLOT(AddCircleTool()));
addArcAct = CreateAction(tr("Add &Arc"), tr("Add Arc"), tr("Adds arcs to the drawing."), QIcon(":/res/generic-tool.png"), QKeySequence("A,A"), true);
void DimensionTool(void);
void RotateTool(void);
void AddLineTool(void);
+ void AddCircleTool(void);
void ZoomInTool(void);
void ZoomOutTool(void);
void HelpAbout(void);
// (C) 2011 Underground Software
// See the README and GPLv3 files for licensing and warranty information
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// WHO WHEN WHAT
// --- ---------- ------------------------------------------------------------
// (C) 2011 Underground Software
// See the README and GPLv3 files for licensing and warranty information
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// WHO WHEN WHAT
// --- ---------- ------------------------------------------------------------
// (C) 2011 Underground Software
// See the README and GPLv3 files for licensing and warranty information
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// WHO WHEN WHAT
// --- ---------- ------------------------------------------------------------
// (C) 2011 Underground Software
// See the README and GPLv3 files for licensing and warranty information
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// WHO WHEN WHAT
// --- ---------- ------------------------------------------------------------
--- /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"
+
+
+#define FIRST_POINT 0
+#define NEXT_POINT 1
+
+
+DrawCircleAction::DrawCircleAction(): state(0), circle(NULL)
+{
+}
+
+DrawCircleAction::~DrawCircleAction()
+{
+}
+
+
+/*virtual*/ void DrawCircleAction::Draw(Painter * painter)
+{
+ // Need to fix pen colors, etc...
+ // I think stuff like crosshairs should be done in the DrawingView, tho
+ if (state == FIRST_POINT)
+ {
+ painter->DrawPoint(p1.x, p1.y);
+ }
+ else
+ {
+ 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;
+ }
+}
--- /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);
+
+ private:
+ int state;
+ Circle * circle;
+ Vector p1, p2;
+};
+
+#endif // __DRAWCIRCLEACTION_H__
// (C) 2011 Underground Software
// See the README and GPLv3 files for licensing and warranty information
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// Who When What
// --- ---------- -------------------------------------------------------------
#include "arc.h"
#include "circle.h"
#include "dimension.h"
+#include "drawcircleaction.h"
#include "drawlineaction.h"
#include "line.h"
#include "painter.h"
//printf("DrawingView::SetAddLineToolActive(). toolAction=%08X\n", toolAction);
}
+void DrawingView::SetAddCircleToolActive(bool state/*= true*/)
+{
+ if (state && toolAction == NULL)
+ {
+ toolAction = new DrawCircleAction();
+ connect(toolAction, SIGNAL(ObjectReady(Object *)), this,
+ SLOT(AddNewObjectToDocument(Object *)));
+ }
+ else if (!state && toolAction)
+ {
+ delete toolAction;
+ toolAction = NULL;
+ }
+
+ addCircleTool = state;
+ update();
+//printf("DrawingView::SetAddLineToolActive(). toolAction=%08X\n", toolAction);
+}
+
void DrawingView::AddNewObjectToDocument(Object * object)
{
if (object)
public:
void SetRotateToolActive(bool state = true);
void SetAddLineToolActive(bool state = true);
+ void SetAddCircleToolActive(bool state = true);
public slots:
void AddNewObjectToDocument(Object *);
bool scrollDrag;
Vector oldPoint;
bool addLineTool;
+ bool addCircleTool;
Action * toolAction;
/* QSize minimumSizeHint() const;
QSize sizeHint() const;
// (C) 2011 Underground Software
// See the README and GPLv3 files for licensing and warranty information
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// WHO WHEN WHAT
// --- ---------- ------------------------------------------------------------
// (C) 2011 Underground Software
// See the README and GPLv3 files for licensing and warranty information
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// WHO WHEN WHAT
// --- ---------- ------------------------------------------------------------
// (C) 2011 Underground Software
// See the README and GPLv3 files for licensing and warranty information
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// WHO WHEN WHAT
// --- ---------- ------------------------------------------------------------
// (C) 2011 Underground Software
// See the README and GPLv3 files for licensing and warranty information
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// Who When What
// --- ---------- -------------------------------------------------------------
// NOTE: Since this has no code associated with it, there is no corresponding
// .cpp file.
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// WHO WHEN WHAT
// --- ---------- ------------------------------------------------------------
// (C) 2011 Underground Software
// See the README and GPLv3 files for licensing and warranty information
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// WHO WHEN WHAT
// --- ---------- ------------------------------------------------------------
// (C) 2011 Underground Software
// See the README and GPLv3 files for licensing and warranty information
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// WHO WHEN WHAT
// --- ---------- ------------------------------------------------------------
void Painter::DrawAngledText(Vector center, double angle, QString text)
{
+ if (!painter)
+ return;
+
// Strategy: Since Qt doesn't have any rotated text drawing functions,
// we instead translate the origin to the center of the text to be drawn and
// then rotate the frame to the desired angle.
// Need to figure out if dimensions are always rendered at one size regardless of zoom,
// or if they have a definite size, and are thus zoomable.
// If zoomable, this is incorrect:
- int yOffset = -12;
+ // (Added zoom, so this is correct now :-)
+ int yOffset = -12 * zoom;
// Fix text so it isn't upside down...
if ((angle > PI * 0.5) && (angle < PI * 1.5))
{
angle += PI;
- yOffset = 12;
+ yOffset = 12 * zoom;
}
+#if 0
+ Vector offset = CartesianToQtCoords(Vector(0, yOffset));
+ textBox.translate(offset.x, offset.y);
+#else
textBox.translate(0, yOffset);
+#endif
painter->save();
painter->translate(center.x, center.y);
// Angles are backwards in the Qt coord system, so we flip ours...
painter->rotate(-angle * RADIANS_TO_DEGREES);
+//Need to fix this so the text scales as well...
painter->drawText(textBox, Qt::AlignCenter, text);
painter->restore();
}
// (C) 2011 Underground Software
// See the README and GPLv3 files for licensing and warranty information
//
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
//
// WHO WHEN WHAT
// --- ---------- ------------------------------------------------------------
//\r
// vector.cpp: Various structures used for 3 dimensional imaging\r
//\r
-// by James L. Hammons\r
+// by James Hammons\r
// (C) 2006 Underground Software\r
//\r
// JLH = James L. Hammons <jlhamm@acm.org>\r