// JLH = James Hammons <jlhamm@acm.org>
//
// Who When What
-// --- ---------- -------------------------------------------------------------
+// --- ---------- ------------------------------------------------------------
// JLH 03/22/2011 Created this file
// JLH 09/29/2011 Added middle mouse button panning
//
document.objects.push_back(new Line(Vector(10, 83), Vector(17, 2)));
document.objects.push_back(new Circle(Vector(100, 100), 36));
document.objects.push_back(new Circle(Vector(50, 150), 49));
- document.objects.push_back(new Arc(Vector(300, 300), 32, PI / 4.0, PI * 1.3)),
- document.objects.push_back(new Arc(Vector(200, 200), 60, PI / 2.0, PI * 1.5));
+ document.objects.push_back(new Arc(Vector(300, 300), 32, TAU / 8.0, TAU * 0.65)),
+ document.objects.push_back(new Arc(Vector(200, 200), 60, TAU / 4.0, TAU * 0.75));
document.objects.push_back(new Dimension(Vector(50, 40), Vector(5, 5)));
document.objects.push_back(new Text(Vector(10, 83), "Here is some awesome text!"));
#endif
}
-#if 0
-void DrawingView::SetToolActive(Action * action)
-{
- if (action != NULL)
- {
- toolAction = action;
- connect(toolAction, SIGNAL(ObjectReady(Object *)), this,
- SLOT(AddNewObjectToDocument(Object *)));
- connect(toolAction, SIGNAL(NeedRefresh()), this, SLOT(HandleActionUpdate()));
- }
-}
-#endif
-
-
void DrawingView::SetGridSize(uint32_t size)
{
// Sanity check
pmp.end();
// Set up new BG brush & zoom level (pixels per base unit)
-// Painter::zoom = gridPixels / gridSpacing;
Global::zoom = gridPixels / Global::gridSpacing;
UpdateGridBackground();
}
}
-void DrawingView::SetCurrentLayer(int /*layer*/)
-{
-//Not needed anymore...
-// Global::currentLayer = layer;
-//printf("DrawingView::CurrentLayer = %i\n", layer);
-}
-
-
//
// Basically, we just make a single pass through the Container. If the layer #
// is less than the layer # being deleted, then do nothing. If the layer # is
QPoint DrawingView::GetAdjustedMousePosition(QMouseEvent * event)
{
- // This is undoing the transform, e.g. going from client coords to local coords.
- // In essence, the height - y is height + (y * -1), the (y * -1) term doing the
- // conversion of the y-axis from increasing bottom to top.
+ // This is undoing the transform, e.g. going from client coords to local
+ // coords. In essence, the height - y is height + (y * -1), the (y * -1)
+ // term doing the conversion of the y-axis from increasing bottom to top.
return QPoint(offsetX + event->x(), offsetY + (size().height() - event->y()));
}
{
// VOODOO ALERT (ON Y COMPONENT!!!!) (eh?)
// No voodoo here, it's just grouped wrong to see it. It should be:
- // -offsetY + (size.height() + (y * -1.0)) <-- this is wrong, offsetY should be positive
+ // -offsetY + (size.height() + (y * -1.0)) <-- this is wrong, offsetY should be positive [why? we use -offsetX after all]
return QPoint(-offsetX + x, (size().height() - (-offsetY + y)) * +1.0);
}
if (d->subtype == DTLinearVert)
{
- if ((angle < 0) || (angle > PI))
+ if ((angle < 0) || (angle > HALF_TAU))
{
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;
+ angle = THREE_QTR_TAU;
}
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;
+ angle = QTR_TAU;
}
linePt1.x = linePt2.x = x1;
}
else if (d->subtype == DTLinearHorz)
{
- if ((angle < PI_OVER_2) || (angle > PI3_OVER_2))
+ if ((angle < QTR_TAU) || (angle > THREE_QTR_TAU))
{
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);
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;
+ angle = HALF_TAU;
}
linePt1.y = linePt2.y = y1;
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.
+ // 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%
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)
else
dimText = QString("%1' %2\"").arg(feet).arg(inches);
}
- #endif
painter->DrawAngledText(ctr, angle, dimText, scaledThickness);
double span = angle - toolPoint[2].x;
if (span < 0)
- span += PI_TIMES_2;
+ span += TAU;
painter->DrawLine(toolPoint[0], toolPoint[3]);
painter->SetBrush(QBrush(Qt::NoBrush));
double span = endAngle - toolPoint[2].x;
if (span < 0)
- span += PI_TIMES_2;
+ span += TAU;
Arc * arc = new Arc(toolPoint[0], toolPoint[1].x, toolPoint[2].x, span);
arc->layer = Global::activeLayer;
{
obj2->angle[0] = obj.angle[0] + angle;
- if (obj2->angle[0] > PI_TIMES_2)
- obj2->angle[0] -= PI_TIMES_2;
+ if (obj2->angle[0] > TAU)
+ obj2->angle[0] -= TAU;
}
}
}
// This is 2*mirror angle - obj angle - obj span
obj2->angle[0] = (2.0 * angle) - obj.angle[0] - obj.angle[1];
- if (obj2->angle[0] > PI_TIMES_2)
- obj2->angle[0] -= PI_TIMES_2;
+ if (obj2->angle[0] > TAU)
+ obj2->angle[0] -= TAU;
}
}
}
if (numIntersecting > 0)
{
Vector v1 = Global::intersectPoint[0];
+
+ if (numIntersecting == 2)
+ {
+ Vector v2 = Global::intersectPoint[1];
+
+ if (Vector::Magnitude(v2, point) < Vector::Magnitude(v1, point))
+ v1 = v2;
+ }
+
QString text = tr("Intersection <%1, %2>");
informativeText = text.arg(v1.x).arg(v1.y);
-
hoveringIntersection = true;
intersectionPoint = v1;
}
// If the end of the arc is before the beginning, add 360 degrees to it
if (end < start)
- end += 2.0 * PI;
+ end += TAU;
// Adjust the bounds depending on which axes are crossed
- if ((start < PI_OVER_2) && (end > PI_OVER_2))
+ if ((start < QTR_TAU) && (end > QTR_TAU))
bounds.setTop(1.0);
- if ((start < PI) && (end > PI))
+ if ((start < HALF_TAU) && (end > HALF_TAU))
bounds.setLeft(-1.0);
- if ((start < (PI + PI_OVER_2)) && (end > (PI + PI_OVER_2)))
+ if ((start < THREE_QTR_TAU) && (end > THREE_QTR_TAU))
bounds.setBottom(-1.0);
- if ((start < (2.0 * PI)) && (end > (2.0 * PI)))
+ if ((start < TAU) && (end > TAU))
bounds.setRight(1.0);
- if ((start < ((2.0 * PI) + PI_OVER_2)) && (end > ((2.0 * PI) + PI_OVER_2)))
+ if ((start < (TAU + QTR_TAU)) && (end > (TAU + QTR_TAU)))
bounds.setTop(1.0);
- if ((start < (3.0 * PI)) && (end > (3.0 * PI)))
+ if ((start < (TAU + HALF_TAU)) && (end > (TAU + HALF_TAU)))
bounds.setLeft(-1.0);
- if ((start < ((3.0 * PI) + PI_OVER_2)) && (end > ((3.0 * PI) + PI_OVER_2)))
+ if ((start < (TAU + THREE_QTR_TAU)) && (end > (TAU + THREE_QTR_TAU)))
bounds.setBottom(-1.0);
bounds.setTopLeft(QPointF(bounds.left() * a->radius[0], bounds.top() * a->radius[0]));
// Make sure we get the angle in the correct spot
if (angle < obj->angle[0])
- angle += PI_TIMES_2;
+ angle += TAU;
// Get the span that we're pointing at...
double span = angle - obj->angle[0];
double delta = angle - obj->angle[0];
if (delta < 0)
- delta += PI_TIMES_2;
+ delta += TAU;
obj->angle[1] -= delta;
obj->angle[0] = angle;
if (obj->angle[1] < 0)
- obj->angle[1] += PI_TIMES_2;
+ obj->angle[1] += TAU;
QString text = QObject::tr("Span: %1") + QChar(0x00B0) + QObject::tr("\n%2") + QChar(0x00B0) + QObject::tr(" - %3") + QChar(0x00B0);
informativeText = text.arg(obj->angle[1] * RADIANS_TO_DEGREES, 0, 'd', 4).arg(obj->angle[0] * RADIANS_TO_DEGREES, 0, 'd', 2).arg((obj->angle[0] + obj->angle[1]) * RADIANS_TO_DEGREES, 0, 'd', 2);
obj->angle[1] = angle - obj->angle[0];
if (obj->angle[1] < 0)
- obj->angle[1] += PI_TIMES_2;
+ obj->angle[1] += TAU;
QString text = QObject::tr("Span: %1") + QChar(0x00B0) + QObject::tr("\n%2") + QChar(0x00B0) + QObject::tr(" - %3") + QChar(0x00B0);
informativeText = text.arg(obj->angle[1] * RADIANS_TO_DEGREES, 0, 'd', 4).arg(obj->angle[0] * RADIANS_TO_DEGREES, 0, 'd', 2).arg((obj->angle[0] + obj->angle[1]) * RADIANS_TO_DEGREES, 0, 'd', 2);
obj->angle[0] = angle - obj->angle[1];
if (obj->angle[0] < 0)
- obj->angle[0] += PI_TIMES_2;
+ obj->angle[0] += TAU;
QString text = QObject::tr("End angle: %1") + QChar(0x00B0);
informativeText = text.arg((obj->angle[0] + obj->angle[1]) * RADIANS_TO_DEGREES, 0, 'd', 4);