+ painter->DrawArc(a->p1, a->radius, a->angle1, a->angle2);
+ break;
+ }
+ case OTDimension:
+ {
+ Dimension * d = (Dimension *)obj;
+
+ Vector v(d->p1, d->p2);
+ double angle = v.Angle();
+ Vector unit = v.Unit();
+ Vector linePt1 = d->p1, linePt2 = d->p2;
+ Vector ortho;
+ double x1, y1, length;
+
+ if (d->subtype == DTLinearVert)
+ {
+ if ((angle < 0) || (angle > PI))
+ {
+ x1 = (d->p1.x > d->p2.x ? d->p1.x : d->p2.x);
+ y1 = (d->p1.y > d->p2.y ? d->p1.y : d->p2.y);
+ ortho = Vector(1.0, 0);
+ angle = PI3_OVER_2;
+ }
+ else
+ {
+ x1 = (d->p1.x > d->p2.x ? d->p2.x : d->p1.x);
+ y1 = (d->p1.y > d->p2.y ? d->p2.y : d->p1.y);
+ ortho = Vector(-1.0, 0);
+ angle = PI_OVER_2;
+ }
+
+ linePt1.x = linePt2.x = x1;
+ length = fabs(d->p1.y - d->p2.y);
+ }
+ else if (d->subtype == DTLinearHorz)
+ {
+ if ((angle < PI_OVER_2) || (angle > PI3_OVER_2))
+ {
+ x1 = (d->p1.x > d->p2.x ? d->p1.x : d->p2.x);
+ y1 = (d->p1.y > d->p2.y ? d->p1.y : d->p2.y);
+ ortho = Vector(0, 1.0);
+ angle = 0;
+ }
+ else
+ {
+ x1 = (d->p1.x > d->p2.x ? d->p2.x : d->p1.x);
+ y1 = (d->p1.y > d->p2.y ? d->p2.y : d->p1.y);
+ ortho = Vector(0, -1.0);
+ angle = PI;
+ }
+
+ linePt1.y = linePt2.y = y1;
+ length = fabs(d->p1.x - d->p2.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->p1 + (ortho * 4.0 * scaledThickness);
+ Point p6 = d->p2 + (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);
+
+ if (inches == 0)
+ dimText = QString("%1'").arg(feet);
+ else
+ dimText = QString("%1' %2\"").arg(feet).arg(inches);
+ }
+ #endif
+
+ painter->DrawAngledText(ctr, angle, dimText, scaledThickness);
+
+ break;
+ }
+ case OTText:
+ {
+ Text * t = (Text *)obj;
+
+ for(float angle=0; angle<(PI*3.0/2.0); angle+=PI/8.0)
+ painter->DrawTextObject(t->p1, t->s.c_str(), scaledThickness, angle);
+