else
painter->setPen(QPen(Qt::blue, 1.0, Qt::SolidLine));
-#if 0
-// if (draggingHandle1)
- if (state == OSSelected)
- painter->drawEllipse(QPointF(position.x, position.y), 4.0, 4.0);
-
-// if (draggingHandle2)
- if (state == OSSelected)
- painter->drawEllipse(QPointF(endpoint.x, endpoint.y), 4.0, 4.0);
-
- if (Object::fixedLength && (draggingHandle1 || draggingHandle2))
- {
- Vector point1 = (draggingHandle1 ? endpoint : position);
- Vector point2 = (draggingHandle1 ? position : endpoint);
-
- Vector current(point2 - point1);
- Vector v = current.Unit() * length;
- Vector v2 = point1 + v;
- painter->drawLine((int)point1.x, (int)point1.y, (int)v2.x, (int)v2.y);
-
- if (current.Magnitude() > length)
- {
- painter->setPen(QPen(QColor(128, 0, 0), 1.0, Qt::DashLine));
- painter->drawLine((int)v2.x, (int)v2.y, (int)point2.x, (int)point2.y);
- }
- }
- else
- painter->drawLine((int)position.x, (int)position.y, (int)endpoint.x, (int)endpoint.y);
-#endif
// Draw an aligned dimension line
double angle = Vector(endpoint - position).Angle();
double orthoAngle = angle + (PI / 2.0);
Point ctr = p2 + v1;
QString dimText = QString("%1\"").arg(Vector(endpoint - position).Magnitude());
int textWidth = QFontMetrics(painter->font()).width(dimText);
+ int textHeight = QFontMetrics(painter->font()).height();
//We have to do transformation voodoo to make the text come out readable and in correct orientation...
//Some things to note here: if angle > 90 degrees, then we need to take the negative of the angle
//for our text.
painter->save();
painter->translate(ctr.x, ctr.y);
+int yOffset = -8;
+//16 : printf("textHeight: %d\n", textHeight);
+
+//Fix text so it isn't upside down...
+if ((angle > PI * 0.5) && (angle < PI * 1.5))
+{
+ angle += PI;
+ yOffset = 18;
+}
+
painter->rotate(angle * RADIANS_TO_DEGREES);
painter->scale(1.0, -1.0);
//painter->translate(-textWidth / 2, -24);
// painter->drawText(0, 0, textWidth, 20, Qt::AlignCenter, dimText);
// This version draws the y-coord from the baseline of the font
- painter->drawText(-textWidth / 2, -8, dimText);
+ painter->drawText(-textWidth / 2, yOffset, dimText);
//painter->setPen(QPen(QColor(0xFF, 0x20, 0x20), 1.0, Qt::SolidLine));
//painter->drawLine(20, 0, -20, 0);
//painter->drawLine(0, 20, 0, -20);
if (objectWasDragged)
state = oldState;
}
+
+void Dimension::SetPoint1(Vector v)
+{
+ position = v;
+ needUpdate = true;
+}
+
+void Dimension::SetPoint2(Vector v)
+{
+ endpoint = v;
+ needUpdate = true;
+}