]> Shamusworld >> Repos - architektonas/blobdiff - src/dimension.cpp
Added Architektonas drawing file loading/saving infrastructure.
[architektonas] / src / dimension.cpp
index b433cac32fa47ad7a6486cca1ac0f3d3c6651392..3060ff1b930c8682409f10993b73622562fbb098 100644 (file)
 #include "painter.h"
 
 
-Dimension::Dimension(Vector p1, Vector p2, Object * p/*= NULL*/): Object(p1, p), endpoint(p2),
+Dimension::Dimension(Vector p1, Vector p2, DimensionType dt/*= DTLinear*/ ,Object * p/*= NULL*/):
+       Object(p1, p), endpoint(p2),
        dragging(false), draggingHandle1(false), draggingHandle2(false),
-       length(p2.Magnitude()), point1(NULL), point2(NULL)
+       length(p2.Magnitude()), type(dt), point1(NULL), point2(NULL)
 {
 }
 
 // This is bad, p1 & p2 could be NULL, causing much consternation...
-Dimension::Dimension(Vector * p1, Vector * p2, Object * p/*= NULL*/): Object(*p1, p), endpoint(*p2),
+Dimension::Dimension(Vector * p1, Vector * p2, DimensionType dt/*= DTLinear*/ , Object * p/*= NULL*/):
+       Object(*p1, p), endpoint(*p2),
        dragging(false), draggingHandle1(false), draggingHandle2(false),
-       length(p2->Magnitude()), point1(p1), point2(p2)
+       length(p2->Magnitude()), type(dt), point1(p1), point2(p2)
 {
 }
 
@@ -56,17 +58,19 @@ Dimension::~Dimension()
        Vector orthogonal = Vector(cos(orthoAngle), sin(orthoAngle));
        Vector unit = Vector(endpoint - position).Unit();
 
+//NOTE: SCREEN_ZOOM is our kludge factor... We need to figure out a better
+//      way of doing this...
        // Get our line parallel to our points
-       Point p1 = position + (orthogonal * 10.0);
-       Point p2 = endpoint + (orthogonal * 10.0);
+       Point p1 = position + (orthogonal * 10.0 * SCREEN_ZOOM);
+       Point p2 = endpoint + (orthogonal * 10.0 * SCREEN_ZOOM);
 
        // Draw main dimension line
        painter->DrawLine(p1, p2);
 
-       Point p3 = position + (orthogonal * 16.0);
-       Point p4 = endpoint + (orthogonal * 16.0);
-       Point p5 = position + (orthogonal * 4.0);
-       Point p6 = endpoint + (orthogonal * 4.0);
+       Point p3 = position + (orthogonal * 16.0 * SCREEN_ZOOM);
+       Point p4 = endpoint + (orthogonal * 16.0 * SCREEN_ZOOM);
+       Point p5 = position + (orthogonal * 4.0 * SCREEN_ZOOM);
+       Point p6 = endpoint + (orthogonal * 4.0 * SCREEN_ZOOM);
 
        // Draw extension lines
        painter->DrawLine(p3, p5);
@@ -75,28 +79,9 @@ Dimension::~Dimension()
        painter->SetBrush(QBrush(QColor(Qt::blue)));
        painter->DrawArrowhead(p1, p2);
        painter->DrawArrowhead(p2, p1);
-#if 0
-       // Draw arrowheads, dots, etc :-P
-       // NOTE: These need some kind of enum in the header so that they can
-       //       be created with some kind of user control...
-
-       Point p7 = position + (unit * 9.0);
-       Point p8 = endpoint - (unit * 9.0);
-       Point p9 = p7 + (orthogonal * 7.0);
-       Point p10 = p7 + (orthogonal * 13.0);
-       Point p11 = p8 + (orthogonal * 7.0);
-       Point p12 = p8 + (orthogonal * 13.0);
-
-       painter->DrawLine(p1, p9);
-       painter->DrawLine(p9, p10);
-       painter->DrawLine(p10, p1);
-       painter->DrawLine(p2, p11);
-       painter->DrawLine(p11, p12);
-       painter->DrawLine(p12, p2);
-#endif
 
        // Draw length of dimension line...
-       painter->SetFont(QFont("Arial", 10 * Painter::zoom));
+       painter->SetFont(QFont("Arial", 10.0 * Painter::zoom * SCREEN_ZOOM));
        Vector v1((p1.x - p2.x) / 2.0, (p1.y - p2.y) / 2.0);
        Point ctr = p2 + v1;
        // This is in pixels, which isn't even remotely correct... !!! FIX !!!
@@ -346,6 +331,16 @@ void Dimension::SetPoint2(Vector * v)
        needUpdate = true;
 }
 
+Vector Dimension::GetPoint1(void)
+{
+       return position;
+}
+
+Vector Dimension::GetPoint2(void)
+{
+       return endpoint;
+}
+
 void Dimension::FlipSides(void)
 {
 #if 0
@@ -359,3 +354,4 @@ void Dimension::FlipSides(void)
 #endif
        needUpdate = true;
 }
+