#include "painter.h"
#include "penwidget.h"
#include "structs.h"
+#include "units.h"
#include "utils.h"
#define BACKGROUND_MAX_SIZE 512
gridBackground(BACKGROUND_MAX_SIZE, BACKGROUND_MAX_SIZE),
scale(1.0), offsetX(-10), offsetY(-10), supressSelected(false),
document(true),
- gridPixels(0), collided(false), scrollDrag(false), hoverPointValid(false),
- hoveringIntersection(false), dragged(NULL), draggingObject(false),
+ gridPixels(0), collided(false), scrollDrag(false),
+ hoverPointValid(false), hoveringIntersection(false),
+ dragged(NULL), draggingObject(false),
angleSnap(false), dirty(false)
{
//wtf? doesn't work except in c++11??? document = { 0 };
painter->SetFont(QFont("Arial", 8.0 * Global::zoom * scaledThickness));
Point ctr = p2 + (Vector(p2, p1) / 2.0);
- 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);
- }
+ QString dimText = GetDimensionText(&document, length);
/*
Where is the text offset? It looks like it's drawing in the center, but obviously it isn't. It isn't here, it's in Painter::DrawAngledText().
void DrawingView::ToolDraw(Painter * painter)
{
- if (Global::tool == TTLine)
+ switch (Global::tool)
{
+ case TTLine:
if (Global::toolState == TSNone)
{
painter->DrawHandle(toolPoint[0]);
QString text = tr("Length: %1 in.\n") + QChar(0x2221) + tr(": %2");
informativeText = text.arg(absLength).arg(absAngle);
}
- }
- else if (Global::tool == TTCircle)
- {
+
+ break;
+
+ case TTCircle:
if (Global::toolState == TSNone)
{
painter->DrawHandle(toolPoint[0]);
QString text = tr("Radius: %1 in.");
informativeText = text.arg(length);
}
- }
- else if (Global::tool == TTArc)
- {
+
+ break;
+
+ case TTArc:
if (Global::toolState == TSNone)
{
painter->DrawHandle(toolPoint[0]);
QString text = tr("Arc span: %1") + QChar(0x00B0);
informativeText = text.arg(RADIANS_TO_DEGREES * span);
}
- }
- else if (Global::tool == TTRotate)
- {
+
+ break;
+
+ case TTRotate:
if ((Global::toolState == TSNone) || (Global::toolState == TSPoint1))
painter->DrawHandle(toolPoint[0]);
else if ((Global::toolState == TSPoint2) && shiftDown)
if (ctrlDown)
informativeText += " (Copy)";
}
- }
- else if (Global::tool == TTMirror)
- {
+
+ break;
+
+ case TTMirror:
if ((Global::toolState == TSNone) || (Global::toolState == TSPoint1))
painter->DrawHandle(toolPoint[0]);
else if ((Global::toolState == TSPoint2) && shiftDown)
if (ctrlDown)
informativeText += " (Copy)";
}
- }
- else if (Global::tool == TTDimension)
- {
+
+ break;
+
+ case TTDimension:
if (Global::toolState == TSNone)
{
painter->DrawHandle(toolPoint[0]);
QString text = tr("Length: %1 in.\n") + QChar(0x2221) + tr(": %2");
informativeText = text.arg(absLength).arg(absAngle);
}
- }
- else if (Global::tool == TTTrim)
- {
+
+ break;
+
+ case TTTrim:
if (toolObj[0] != NULL)
{
// We're assuming ATM it's just a line...
// QString text = tr("Arc span: %1") + QChar(0x00B0);
// informativeText = text.arg(RADIANS_TO_DEGREES * span);
}
- }
- else if (Global::tool == TTParallel)
- {
+
+ break;
+
+ case TTParallel:
if (Global::toolState == TSPoint1)
{
painter->SetPen(0xFF00FF, 2.0, LSSolid);
}
}
}
+
+ break;
+
+ default:
+ break;
}
}
{
bool needUpdate = false;
+ // Make sure we don't hit test stuff on an invisible layer...
+ if (Global::layerHidden[obj->layer] == true)
+ return false;
+
switch (obj->type)
{
case OTLine:
obj->radius[0] = Vector::Magnitude(obj->p[0], point);
QString text = QObject::tr("Radius: %1\nScale: %2%");
- informativeText = text.arg(obj->radius[0], 0, 'd', 4).arg(obj->radius[0] / oldRadius * 100.0, 0, 'd', 0);
+ informativeText = text.arg(obj->radius[0], 0, 'f', 4).arg(obj->radius[0] / oldRadius * 100.0, 0, 'f', 0);
}
break;