case OTText:
{
Text * t = (Text *)obj;
- painter->DrawTextObject(t->p[0], t->s.c_str(), scaledThickness);
+
+ if (t->measured == false)
+ {
+ t->extents = painter->MeasureTextObject(t->s.c_str(), scaledThickness);
+ t->measured = true;
+ }
+
+ painter->DrawTextObject(t->p[0], t->s.c_str(), scaledThickness, t->angle[0]);
break;
}
case OTSpline:
rect = Rect(obj->p[0], obj->p[1]);
break;
}
+
case OTCircle:
{
rect = Rect(obj->p[0], obj->p[0]);
rect.Expand(obj->radius[0]);
break;
}
+
case OTArc:
{
Arc * a = (Arc *)obj;
rect *= a->radius[0];
rect.Translate(a->p[0]);
+ break;
+ }
+ case OTText:
+ {
+ Text * t = (Text *)obj;
+ rect = Rect(t->p[0], Point(t->p[0].x + t->extents.Width(), t->p[0].y - t->extents.Height()));
break;
}
+
case OTContainer:
{
Container * c = (Container *)obj;
for(; i!=c->objects.end(); i++)
rect |= GetObjectExtents((Object *)*i);
}
+
default:
break;
}
break;
}
+
case OTCircle:
{
Circle * c = (Circle *)obj;
break;
}
+
case OTArc:
{
Arc * a = (Arc *)obj;
break;
}
+
+ case OTText:
+ {
+ Text * t = (Text *)obj;
+ Rect r(obj->p[0], Point(t->p[0].x + t->extents.Width(), t->p[0].y - t->extents.Height()));
+
+ if (Global::selection.contains(r.l, r.t) && Global::selection.contains(r.r, r.b))
+ t->selected = true;
+
+ break;
+ }
+
default:
break;
}
break;
}
+
case OTCircle:
{
bool oldHP = obj->hitPoint[0], oldHO = obj->hitObject;
double length = Vector::Magnitude(obj->p[0], point);
if ((length * Global::zoom) < 8.0)
+ {
obj->hitPoint[0] = true;
+ hoverPoint = obj->p[0];
+ hoverPointValid = true;
+ }
else if ((fabs(length - obj->radius[0]) * Global::zoom) < 2.0)
obj->hitObject = true;
break;
}
+
case OTArc:
{
bool oldHP0 = obj->hitPoint[0], oldHP1 = obj->hitPoint[1], oldHP2 = obj->hitPoint[2], oldHO = obj->hitObject;
double length3 = Vector::Magnitude(point, handle2);
if ((length * Global::zoom) < 8.0)
+ {
obj->hitPoint[0] = true;
+ hoverPoint = obj->p[0];
+ hoverPointValid = true;
+ }
else if ((length2 * Global::zoom) < 8.0)
{
obj->hitPoint[1] = true;
break;
}
+
case OTDimension:
{
bool oldHP0 = obj->hitPoint[0], oldHP1 = obj->hitPoint[1], oldHP2 = obj->hitPoint[2], oldHP3 = obj->hitPoint[3], oldHP4 = obj->hitPoint[4], oldHO = obj->hitObject;
if ((oldHP0 != obj->hitPoint[0]) || (oldHP1 != obj->hitPoint[1]) || (oldHP2 != obj->hitPoint[2]) || (oldHP3 != obj->hitPoint[3]) || (oldHP4 != obj->hitPoint[4]) || (oldHO != obj->hitObject))
needUpdate = true;
+ break;
+ }
+
+ case OTText:
+ {
+ Text * t = (Text *)obj;
+ bool oldHO = obj->hitObject;
+ obj->hitObject = false;
+
+ Rect r(obj->p[0], Point(obj->p[0].x + t->extents.Width(), obj->p[0].y - t->extents.Height()));
+//printf("Text: p=<%lf, %lf>, w/h=%lf, %lf [lrtb=%lf, %lf, %lf, %lf]\n", obj->p[0].x, obj->p[0].y, t->extents.Width(), t->extents.Height(), t->extents.l, t->extents.r, t->extents.t, t->extents.b);
+
+ if (r.Contains(point))
+ obj->hitObject = true;
+
+ obj->hovered = (obj->hitObject ? true : false);
+
+ if (oldHO != obj->hitObject)
+ needUpdate = true;
break;
}
+
case OTContainer:
{
// Containers must be recursively tested...
break;
}
+
default:
break;
}
break;
+ case OTText:
+ if (obj->hitObject)
+ obj->p[0] += delta;
+
+ break;
+
case OTContainer:
// This is shitty, but works for now until I can code up something
// nicer :-)