- Add Arc
- Add Polygon
+ - Add Ellipse
+ - Add Spline
+ - Add Text
- Manipulate Dimension
- Object connections
- Group selection (kind done, needs more work though)
- Take movement code out of Objects and put it into top level Container
- - Fix snap to grid to honor both states (right now, it's a weird mix of states)
- Add OSD routines so they don't have to be implemented in Objects
- Add OSD to Object creation
- Add layers
- Add fill/hatch to Objects
- Fix zooming to be more intuitive
- Add other Dimension types, like radial, diametric, leader
- - Add Ellipse
- - Add Spline
- - Add Text
+ - Mirror tool
+ - Restrict movement horizontal/vertical tool
+ - Trim tool
+
+Stuff That's Done
+-----------------
+
+ - Fix snap to grid to honor both states (right now, it's a weird mix of states)
src/container.h \
src/dimension.h \
src/drawingview.h \
+ src/drawarcaction.h \
src/drawcircleaction.h \
src/drawdimensionaction.h \
src/drawlineaction.h \
src/container.cpp \
src/dimension.cpp \
src/drawingview.cpp \
+ src/drawarcaction.cpp \
src/drawcircleaction.cpp \
src/drawdimensionaction.cpp \
src/drawlineaction.cpp \
drawing->SetAddLineToolActive(addLineAct->isChecked());
drawing->SetAddCircleToolActive(addCircleAct->isChecked());
+ drawing->SetAddArcToolActive(addArcAct->isChecked());
drawing->SetAddDimensionToolActive(addDimensionAct->isChecked());
}
dragging(false), draggingHandle1(false), draggingHandle2(false)//, needUpdate(false)
{
type = OTContainer;
+ state = OSInactive;
}
// Use overloaded assignment operator
*this = copy;
type = OTContainer;
+ state = OSInactive;
}
painter->SetPen(QPen(Qt::blue, 2.0, Qt::DashLine));
painter->SetBrush(QBrush(Qt::NoBrush));
- painter->DrawRect(boundary);
+ painter->DrawPaddedRect(boundary);
}
}
--- /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 "painter.h"
+#include "arc.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)
+{
+}
+
+
+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
+ if (state == FIRST_POINT)
+ {
+ painter->DrawHandle(p1);
+ }
+ else
+ {
+// painter->DrawLine(p1, p2);
+// painter->DrawHandle(p2);
+ }
+}
+
+
+/*virtual*/ void DrawArcAction::MouseDown(Vector point)
+{
+ if (state == FIRST_POINT)
+ p1 = point;
+// else
+// p2 = point;
+}
+
+
+/*virtual*/ void DrawArcAction::MouseMoved(Vector point)
+{
+ if (state == FIRST_POINT)
+ p1 = point;
+// else
+// p2 = point;
+}
+
+
+/*virtual*/ void DrawArcAction::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.
+// text = new Text(p1, p2);
+// arc = new Arc(...);
+ // We don't need no stinkin' sentinels, when we have signals & slots!
+ emit ObjectReady(arc);
+ }
+}
+
--- /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);
+
+ private:
+ int state;
+ Arc * arc;
+ Vector p1, p2;
+};
+
+#endif // __DRAWARCACTION_H__
#include "arc.h"
#include "circle.h"
#include "dimension.h"
+#include "drawarcaction.h"
#include "drawcircleaction.h"
#include "drawdimensionaction.h"
#include "drawlineaction.h"
scaled the same way as the arrowheads.
Need a way to scale line widths as well. :-/ Shouldn't be too difficult, just
-need a thickness parameter similar to the "size" param for dimensions.
+need a thickness parameter similar to the "size" param for dimensions. (And now
+we do! :-)
*/
#if 0
}
+void DrawingView::SetAddArcToolActive(bool state/*= true*/)
+{
+ if (state)
+ {
+ toolAction = new DrawArcAction();
+ connect(toolAction, SIGNAL(ObjectReady(Object *)), this,
+ SLOT(AddNewObjectToDocument(Object *)));
+ }
+
+ update();
+}
+
+
void DrawingView::SetAddDimensionToolActive(bool state/*= true*/)
{
if (state)
}
+//
+// This looks strange, but it's really quite simple: We want a point that's
+// more than half-way to the next grid point to snap there while conversely we
+// want a point that's less than half-way to to the next grid point then snap
+// to the one before it. So we add half of the grid spacing to the point, then
+// divide by it so that we can remove the fractional part, then multiply it
+// back to get back to the correct answer.
+//
+Vector DrawingView::SnapPointToGrid(Vector point)
+{
+ point += gridSpacing / 2.0; // *This* adds to Z!!!
+ point /= gridSpacing;
+ point.x = floor(point.x);//need to fix this for negative numbers...
+ point.y = floor(point.y);
+ point.z = 0; // Make *sure* Z doesn't go anywhere!!!
+ point *= gridSpacing;
+ return point;
+}
+
+
void DrawingView::paintEvent(QPaintEvent * /*event*/)
{
QPainter qtPainter(this);
if (event->button() == Qt::LeftButton)
{
Vector point = Painter::QtToCartesianCoords(Vector(event->x(), event->y()));
+
+ if (Object::snapToGrid)
+ point = SnapPointToGrid(point);
+
collided = document.Collided(point);
if (collided)
// Grid processing...
#if 1
- // This looks strange, but it's really quite simple: We want a point that's
- // more than half-way to the next grid point to snap there while conversely
- // we want a point that's less than half-way to to the next grid point then
- // snap to the one before it. So we add half of the grid spacing to the
- // point, then divide by it so that we can remove the fractional part, then
- // multiply it back to get back to the correct answer.
- if (event->buttons() & Qt::LeftButton)
+ if ((event->buttons() & Qt::LeftButton) && Object::snapToGrid)
{
+#if 0
point += gridSpacing / 2.0; // *This* adds to Z!!!
point /= gridSpacing;
//200% is ok, gridSpacing = 6 in this case...
point.y = floor(point.y);
point.z = 0; // Make *sure* Z doesn't go anywhere!!!
point *= gridSpacing;
+#else
+ point = SnapPointToGrid(point);
+#endif
}
#endif
//we should keep track of the last point here and only pass this down *if* the point
void SetRotateToolActive(bool state = true);
void SetAddLineToolActive(bool state = true);
void SetAddCircleToolActive(bool state = true);
+ void SetAddArcToolActive(bool state = true);
void SetAddDimensionToolActive(bool state = true);
void SetGridSize(uint32_t);
void UpdateGridBackground(void);
private:
QPoint GetAdjustedMousePosition(QMouseEvent * event);
QPoint GetAdjustedClientPosition(int x, int y);
+ Vector SnapPointToGrid(Vector);
public:
bool useAntialiasing;
#endif
-/*virtual*/ void Object::Translate(Vector)
+/*virtual*/ void Object::Translate(Vector amount)
{
+ position += amount;
}
static int viewportHeight;
static bool deleteActive;
static bool dimensionActive;
+ public:
static bool snapToGrid;
static bool ignoreClicks;
static bool dontMove;
}
+// This is drawn in Qt coordinates...
void Painter::DrawRoundedRect(QRectF rect, double radiusX, double radiusY)
{
if (!painter)
}
+// This is drawn partially in Cartesian coordinates, and partially in Qt
+// coordinates. The rect itself is in Cartesian but we want to pad it by a set
+// number of pixels.
+void Painter::DrawPaddedRect(QRectF rect)
+{
+ if (!painter)
+ return;
+
+ Vector v1 = CartesianToQtCoords(Vector(rect.x(), rect.y()));
+ Vector v2 = CartesianToQtCoords(Vector(rect.right(), rect.bottom()));
+ QRectF screenRect(QPointF(v1.x, v1.y), QPointF(v2.x, v2.y));
+ screenRect.adjust(-8, 8, 8, -8); // Left/top, right/bottom
+ painter->drawRect(screenRect);
+}
+
+
void Painter::DrawRect(QRectF rect)
{
if (!painter)
void DrawLine(Vector, Vector);
void DrawPoint(int, int);
void DrawRoundedRect(QRectF, double, double);
+ void DrawPaddedRect(QRectF);
void DrawRect(QRectF);
void DrawText(QRectF, int, QString);
void DrawArrowhead(Vector, Vector, double);