Also, minor bugfix in Geometry: the rotation vector was backwards.
Initial thoughts on naming centered around FooCAD or CADFoo (with Foo being
whatever), but a long search on the internet brought forth the conclusion that
such paths have been well trodden by just about anyone who has even given a
-thought towards creating computer aided design software. And so it was
+passing thought towards creating computer aided design software. And so it was
manifestly clear that a different naming scheme would be required. After much
reflection and several false starts, the name Architektonas was chosen as a
rough English transliteration of the Greek word for architect. We feel it's a
{
Circle * ci = (Circle *)obj;
painter->SetBrush(QBrush(Qt::NoBrush));
- painter->DrawEllipse(ci->p[0], ci->radius, ci->radius);
+ painter->DrawEllipse(ci->p[0], ci->radius[0], ci->radius[0]);
break;
}
case OTArc:
{
Arc * a = (Arc *)obj;
- painter->DrawArc(a->p[0], a->radius, a->angle1, a->angle2);
+ painter->DrawArc(a->p[0], a->radius[0], a->angle[0], a->angle[1]);
break;
}
case OTDimension:
if (shiftDown)
return;
- double angle = Vector(toolPoint[1], toolPoint[0]).Angle();
+ double angle = Vector(toolPoint[0], toolPoint[1]).Angle();
std::vector<void *>::iterator j = select.begin();
std::vector<Object>::iterator i = toolScratch.begin();
Object * obj2 = (Object *)(*j);
obj2->p[0] = p1;
obj2->p[1] = p2;
+
+ if (obj.type == OTArc)
+ {
+//printf("Obj2->angle[0] = %f, obj.angle[0] = %f, angle = %f\n", obj2->angle[0], obj.angle[0], angle);
+ obj2->angle[0] = obj.angle[0] + angle;
+
+ if (obj2->angle[0] > PI_TIMES_2)
+ obj2->angle[0] -= PI_TIMES_2;
+ }
}
}
}
if (Global::selectionInProgress)
- {
- // Select all the stuff inside of selection
Global::selectionInProgress = false;
- // Clear our vectors
- select.clear();
- hover.clear();
+// Should be we do this automagically? Hmm...
+ // Clear our vectors
+ select.clear();
+ hover.clear();
- // Scoop 'em up
- std::vector<void *>::iterator i;
+ // Scoop 'em up
+ std::vector<void *>::iterator i;
- for(i=document.objects.begin(); i!=document.objects.end(); i++)
- {
- if (((Object *)(*i))->selected)
- select.push_back(*i);
+ for(i=document.objects.begin(); i!=document.objects.end(); i++)
+ {
+ if (((Object *)(*i))->selected)
+ select.push_back(*i);
//hmm, this is no good, too late to do any good :-P
// if ((*i)->hovered)
// hover.push_back(*i);
- }
+// }
}
}
else if (event->button() == Qt::MiddleButton)
{
Circle * c = (Circle *)obj;
- if (Global::selection.contains(c->p[0].x - c->radius, c->p[0].y - c->radius) && Global::selection.contains(c->p[0].x + c->radius, c->p[0].y + c->radius))
+ if (Global::selection.contains(c->p[0].x - c->radius[0], c->p[0].y - c->radius[0]) && Global::selection.contains(c->p[0].x + c->radius[0], c->p[0].y + c->radius[0]))
c->selected = true;
break;
{
Arc * a = (Arc *)obj;
- double start = a->angle1;
- double end = start + a->angle2;
+ double start = a->angle[0];
+ double end = start + a->angle[1];
QPointF p1(cos(start), sin(start));
QPointF p2(cos(end), sin(end));
QRectF bounds(p1, p2);
if ((start < ((3.0 * PI) + PI_OVER_2)) && (end > ((3.0 * PI) + PI_OVER_2)))
bounds.setBottom(-1.0);
- bounds.setTopLeft(QPointF(bounds.left() * a->radius, bounds.top() * a->radius));
- bounds.setBottomRight(QPointF(bounds.right() * a->radius, bounds.bottom() * a->radius));
+ bounds.setTopLeft(QPointF(bounds.left() * a->radius[0], bounds.top() * a->radius[0]));
+ bounds.setBottomRight(QPointF(bounds.right() * a->radius[0], bounds.bottom() * a->radius[0]));
bounds.translate(a->p[0].x, a->p[0].y);
if (Global::selection.contains(bounds))
*/
-enum ObjectTypeFile { OTFContainer, OTFContainerEnd, OTFLine, OTFCircle, OTFArc, OTFDimension,
- OTFPolygon, OTFText, OTFImage, OTFBlock, OTFEndOfFile };
+enum ObjectTypeFile { OTFContainer, OTFContainerEnd, OTFLine, OTFCircle, OTFArc,
+ OTFDimension, OTFPolygon, OTFText, OTFImage, OTFBlock, OTFEndOfFile };
/*static*/ bool FileIO::SaveAtnsFile(FILE * file, Container * object)
}
+//
+// point: The point we're rotating
+// rotationPoint: The point we're rotating around
+//
Point Geometry::RotatePointAroundPoint(Point point, Point rotationPoint, double angle)
{
- Vector v = Vector(point, rotationPoint);
-// Vector v = Vector(rotationPoint, point);
+// Vector v = Vector(point, rotationPoint);
+ Vector v = Vector(rotationPoint, point);
double px = (v.x * cos(angle)) - (v.y * sin(angle));
double py = (v.x * sin(angle)) + (v.y * cos(angle));
#define PI 3.14159265358979323846264338327
#define PI_OVER_2 (PI / 2.0)
#define PI3_OVER_2 ((3.0 * PI) / 2.0)
+#define PI_TIMES_2 (PI * 2.0)
#define RADIANS_TO_DEGREES (180.0 / PI)
#define DEGREES_TO_RADIANS (PI / 180.0)
+
#include "global.h"
#include "vector.h"
-enum ObjectType { OTNone, OTLine, OTCircle, OTEllipse, OTArc, OTDimension, OTSpline, OTText, OTContainer };
+enum ObjectType { OTNone, OTLine, OTCircle, OTEllipse, OTArc, OTPolygon, OTDimension, OTSpline, OTText, OTContainer };
enum DimensionType { DTLinear, DTLinearVert, DTLinearHorz, DTRadial, DTDiametric, DTCircumferential, DTAngular, DTLeader };
bool hovered; \
bool hitPoint[4]; \
bool hitObject; \
- Point p[4];
+ Point p[4]; \
+ double angle[2]; \
+ double radius[2];
struct Line {
OBJECT_COMMON;
struct Circle {
OBJECT_COMMON;
- double radius;
Circle(): type(OTCircle), id(Global::objectID++) {}
Circle(Vector pt1, double r, float th = 1.0, uint32_t c = 0, int l = LSSolid):
type(OTCircle), id(Global::objectID++), layer(0), color(c), thickness(th),
- style(l), selected(false), hovered(false), hitObject(false), radius(r) { p[0] = pt1; }
+ style(l), selected(false), hovered(false), hitObject(false)
+ { p[0] = pt1; radius[0] = r; }
};
struct Ellipse {
OBJECT_COMMON;
- double radius1;
- double radius2;
Ellipse(): type(OTEllipse), id(Global::objectID++) {}
Ellipse(Vector pt1, Vector pt2, double r1, double r2, float th = 1.0, uint32_t c = 0, int l = LSSolid):
type(OTEllipse), id(Global::objectID++), layer(0), color(c), thickness(th),
- style(l), selected(false), hovered(false), hitObject(false), radius1(r1), radius2(r2) { p[0] = pt1; p[1] = pt2; }
+ style(l), selected(false), hovered(false), hitObject(false)
+ { p[0] = pt1; p[1] = pt2; radius[0] = r1; radius[1] = r2; }
};
struct Arc {
OBJECT_COMMON;
- double radius;
- double angle1;
- double angle2;
Arc(): type(OTArc), id(Global::objectID++) {}
Arc(Vector pt1, double r, double a1, double a2, float th = 1.0, uint32_t c = 0, int l = LSSolid):
type(OTArc), id(Global::objectID++), layer(0), color(c), thickness(th),
- style(l), selected(false), hovered(false), hitObject(false), radius(r), angle1(a1), angle2(a2) { p[0] = pt1; }
+ style(l), selected(false), hovered(false), hitObject(false)
+ { p[0] = pt1; radius[0] = r; angle[0] = a1, angle[1] = a2; }
};
struct Dimension {
style(LSSolid), selected(false), hovered(false), hitObject(false), s(str) { p[0] = pt1; }
};
+struct Polygon {
+ OBJECT_COMMON;
+
+ Polygon(): type(OTPolygon), id(Global::objectID++) {}
+};
+
+struct Spline {
+ OBJECT_COMMON;
+
+ Spline(): type(OTSpline), id(Global::objectID++) {}
+};
+
struct Container {
OBJECT_COMMON;
std::vector<void *> objects;
- double angle;
double scale;
Container(): type(OTContainer), id(Global::objectID++), selected(false), hovered(false), hitObject(false) {}
Object * obj2 = (Object *)(*j);
obj2->p[0] = (*i).p[0];
obj2->p[1] = (*i).p[1];
+ obj2->angle[0] = (*i).angle[0];
+ obj2->angle[1] = (*i).angle[1];
+//we don't do this because we want to keep selected & friends from changing
+// memcpy(obj2, *j, sizeof(Object));
}
}