#include "painter.h"
-Arc::Arc(Vector p1, double r, double a1, double a2, Object * p/*= NULL*/): Object(p1, p),
- radius(r), startAngle(a1), angleSpan(a2)
+Arc::Arc(Vector p1, double r, double a1, double a2, Object * p/*= NULL*/):
+ Object(p1, p), /*type(OTArc),*/ radius(r), startAngle(a1), angleSpan(a2)
{
+ // This is in the base class, why can't we use the contructor to fill it???
+ type = OTArc;
}
pen = QPen(QColor(0x00, 0xFF, 0x00), 1.0, Qt::SolidLine);
painter->SetPen(pen);
painter->SetBrush(QBrush(QColor(0x40, 0xFF, 0x40, 0x9F)));
- QRectF textRect(10.0, 10.0, 260.0, 60.0); // x, y, w, h
+ QRectF textRect(10.0, 10.0, 270.0, 70.0); // x, y, w, h
painter->DrawRoundedRect(textRect, 7.0, 7.0);
textRect.setLeft(textRect.left() + 14);
painter->SetFont(*Object::font);
- pen = QPen(QColor(0xDF, 0x5F, 0x00), 1.0, Qt::SolidLine);
+// pen = QPen(QColor(0xDF, 0x5F, 0x00), 1.0, Qt::SolidLine);
+ pen = QPen(QColor(0x00, 0x5F, 0xDF));
painter->SetPen(pen);
painter->DrawText(textRect, Qt::AlignVCenter, text);
+ painter->SetPen(QPen(QColor(0xDF, 0x5F, 0x00)));
}
}
else
}
painter->DrawArc(position, radius, startAngle, angleSpan);
+// painter->DrawRect(Extents());
}
/*virtual*/ void Arc::PointerMoved(Vector point)
{
+ if (selectionInProgress)
+ {
+ // Check for whether or not the rect contains this circle
+ if (selection.normalized().contains(Extents()))
+ state = OSSelected;
+ else
+ state = OSInactive;
+
+ return;
+ }
+
// The TLC will send these messages if the object is selected but not clicked on.
// So we have to be careful with our assumptions here.
// This is actually untrue in that case, we need to come up with something better
// Here we check for just a click: If object was clicked and dragged, then
// revert to the old state (OSInactive). Otherwise, keep the new state that
// we set.
-/*Maybe it would be better to just check for "object was dragged" state and not have to worry
-about keeping track of old states...
-Well, we can't know if it was dragged from Inactive or not, that's the problem. We could make
-a variable called "needToRevertToInactive" instead
+/*
+Maybe it would be better to just check for "object was dragged" state and not
+have to worry about keeping track of old states...
+Well, we can't know if it was dragged from Inactive or not, that's the problem.
+We could make a variable called "needToRevertToInactive" instead
I mean, we could write like:
if (objectWasDragged && oldState == OSInactive)
state = oldState;
}
+
+/*virtual*/ QRectF Arc::Extents(void)
+{
+ double start = startAngle;
+ double end = start + angleSpan;
+ QPointF p1(cos(start), sin(start));
+ QPointF p2(cos(end), sin(end));
+ QRectF bounds(p1, p2);
+
+ // Swap X/Y coordinates if they're backwards...
+ if (bounds.left() > bounds.right())
+ {
+ double temp = bounds.left();
+ bounds.setLeft(bounds.right());
+ bounds.setRight(temp);
+ }
+
+ if (bounds.bottom() > bounds.top())
+ {
+ double temp = bounds.bottom();
+ bounds.setBottom(bounds.top());
+ bounds.setTop(temp);
+ }
+
+ // If the end of the arc is before the beginning, add 360 degrees to it
+ if (end < start)
+ end += 2.0 * PI;
+
+ // Adjust the bounds depending on which axes are crossed
+ if ((start < PI_OVER_2) && (end > PI_OVER_2))
+ bounds.setTop(1.0);
+
+ if ((start < PI) && (end > PI))
+ bounds.setLeft(-1.0);
+
+ if ((start < (PI + PI_OVER_2)) && (end > (PI + PI_OVER_2)))
+ bounds.setBottom(-1.0);
+
+ if ((start < (2.0 * PI)) && (end > (2.0 * PI)))
+ bounds.setRight(1.0);
+
+ if ((start < ((2.0 * PI) + PI_OVER_2)) && (end > ((2.0 * PI) + PI_OVER_2)))
+ bounds.setTop(1.0);
+
+ if ((start < (3.0 * PI)) && (end > (3.0 * PI)))
+ bounds.setLeft(-1.0);
+
+ if ((start < ((3.0 * PI) + PI_OVER_2)) && (end > ((3.0 * PI) + PI_OVER_2)))
+ bounds.setBottom(-1.0);
+
+ bounds.setTopLeft(QPointF(bounds.left() * radius, bounds.top() * radius));
+ bounds.setBottomRight(QPointF(bounds.right() * radius, bounds.bottom() * radius));
+ bounds.translate(position.x, position.y);
+ return bounds;
+}
+
+
#if 0
/*virtual*/ bool Arc::NeedsUpdate(void)
{