+ switch (obj->type)
+ {
+ case OTLine:
+ painter->DrawLine(obj->p[0], obj->p[1]);
+
+ if (obj->hitPoint[0])
+ painter->DrawHandle(obj->p[0]);
+
+ if (obj->hitPoint[1])
+ painter->DrawHandle(obj->p[1]);
+
+ break;
+ case OTCircle:
+ painter->SetBrush(QBrush(Qt::NoBrush));
+ painter->DrawEllipse(obj->p[0], obj->radius[0], obj->radius[0]);
+
+ if (obj->hitPoint[0])
+ painter->DrawHandle(obj->p[0]);
+
+ break;
+ case OTArc:
+ painter->DrawArc(obj->p[0], obj->radius[0], obj->angle[0], obj->angle[1]);
+ break;
+ case OTDimension:
+ {
+ Dimension * d = (Dimension *)obj;
+
+ Vector v(d->p[0], d->p[1]);
+ double angle = v.Angle();
+ Vector unit = v.Unit();
+ Vector linePt1 = d->p[0], linePt2 = d->p[1];
+ Vector ortho;
+ double x1, y1, length;
+
+ if (d->subtype == DTLinearVert)
+ {
+ if ((angle < 0) || (angle > PI))
+ {
+ x1 = (d->p[0].x > d->p[1].x ? d->p[0].x : d->p[1].x);
+ y1 = (d->p[0].y > d->p[1].y ? d->p[0].y : d->p[1].y);
+ ortho = Vector(1.0, 0);
+ angle = PI3_OVER_2;
+ }
+ else
+ {
+ x1 = (d->p[0].x > d->p[1].x ? d->p[1].x : d->p[0].x);
+ y1 = (d->p[0].y > d->p[1].y ? d->p[1].y : d->p[0].y);
+ ortho = Vector(-1.0, 0);
+ angle = PI_OVER_2;
+ }
+
+ linePt1.x = linePt2.x = x1;
+ length = fabs(d->p[0].y - d->p[1].y);
+ }
+ else if (d->subtype == DTLinearHorz)
+ {
+ if ((angle < PI_OVER_2) || (angle > PI3_OVER_2))
+ {
+ x1 = (d->p[0].x > d->p[1].x ? d->p[0].x : d->p[1].x);
+ y1 = (d->p[0].y > d->p[1].y ? d->p[0].y : d->p[1].y);
+ ortho = Vector(0, 1.0);
+ angle = 0;
+ }
+ else
+ {
+ x1 = (d->p[0].x > d->p[1].x ? d->p[1].x : d->p[0].x);
+ y1 = (d->p[0].y > d->p[1].y ? d->p[1].y : d->p[0].y);
+ ortho = Vector(0, -1.0);
+ angle = PI;
+ }
+
+ linePt1.y = linePt2.y = y1;
+ length = fabs(d->p[0].x - d->p[1].x);
+ }
+ else if (d->subtype == DTLinear)
+ {
+ angle = Vector(linePt1, linePt2).Angle();
+ ortho = Vector::Normal(linePt1, linePt2);
+ length = v.Magnitude();
+ }
+
+ unit = Vector(linePt1, linePt2).Unit();
+
+ Point p1 = linePt1 + (ortho * 10.0 * scaledThickness);
+ Point p2 = linePt2 + (ortho * 10.0 * scaledThickness);
+ Point p3 = linePt1 + (ortho * 16.0 * scaledThickness);
+ Point p4 = linePt2 + (ortho * 16.0 * scaledThickness);
+ Point p5 = d->p[0] + (ortho * 4.0 * scaledThickness);
+ Point p6 = d->p[1] + (ortho * 4.0 * scaledThickness);
+
+ /*
+ The numbers hardcoded into here, what are they?
+ I believe they are pixels.
+ */
+ // Draw extension lines (if certain type)
+ painter->DrawLine(p3, p5);
+ painter->DrawLine(p4, p6);
+
+ // Calculate whether or not the arrowheads are too crowded to put inside
+ // the extension lines. 9.0 is the length of the arrowhead.
+ double t = Geometry::ParameterOfLineAndPoint(linePt1, linePt2, linePt2 - (unit * 9.0 * scaledThickness));
+ //printf("Dimension::Draw(): t = %lf\n", t);
+
+ // On the screen, it's acting like this is actually 58%...
+ // This is correct, we want it to happen at > 50%
+ if (t > 0.58)
+ {
+ // Draw main dimension line + arrowheads
+ painter->DrawLine(p1, p2);
+ painter->DrawArrowhead(p1, p2, scaledThickness);
+ painter->DrawArrowhead(p2, p1, scaledThickness);
+ }
+ else
+ {
+ // Draw outside arrowheads
+ Point p7 = p1 - (unit * 9.0 * scaledThickness);
+ Point p8 = p2 + (unit * 9.0 * scaledThickness);
+ painter->DrawArrowhead(p1, p7, scaledThickness);
+ painter->DrawArrowhead(p2, p8, scaledThickness);
+ painter->DrawLine(p1, p1 - (unit * 14.0 * scaledThickness));
+ painter->DrawLine(p2, p2 + (unit * 14.0 * scaledThickness));
+ }
+
+ // Draw length of dimension line...
+ painter->SetFont(QFont("Arial", 8.0 * Global::zoom * scaledThickness));
+ Point ctr = p2 + (Vector(p2, p1) / 2.0);
+
+ #if 0
+ QString dimText = QString("%1\"").arg(Vector(endpoint - position).Magnitude());
+ #else
+ QString dimText;
+
+ if (length < 12.0)
+ dimText = QString("%1\"").arg(length);
+ else
+ {
+ double feet = (double)((int)length / 12);
+ double inches = length - (feet * 12.0);