X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Farc.cpp;h=8fc66319bbe540ef96a153ed193c6ec4635993e9;hb=59e5af9d8606aa091fa979e19f78e9325a1c0825;hp=77c1ce942075772ece9e951e7dda9f261f0890dd;hpb=043ecf4d074909ba2f7f53237962f9eaa72f19c2;p=architektonas diff --git a/src/arc.cpp b/src/arc.cpp index 77c1ce9..8fc6631 100644 --- a/src/arc.cpp +++ b/src/arc.cpp @@ -19,15 +19,19 @@ #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; } + Arc::~Arc() { } + /*virtual*/ void Arc::Draw(Painter * painter) { QPen pen; @@ -61,11 +65,11 @@ Arc::~Arc() // Draw the center point of the arc painter->SetPen(QPen(Qt::red, 2.0, Qt::DotLine)); - painter->DrawEllipse(position, 4.0, 4.0); + painter->DrawHandle(position); // Draw the rotation & span setting handles - painter->DrawEllipse(handle2, 4.0, 4.0); - painter->DrawEllipse(handle3, 4.0, 4.0); + painter->DrawHandle(handle2); + painter->DrawHandle(handle3); // If we're rotating or setting the span, draw an information panel // showing both absolute and relative angles being set. @@ -75,13 +79,6 @@ Arc::~Arc() double relAngle = (startAngle >= oldAngle ? startAngle - oldAngle : startAngle - oldAngle + (2.0 * PI)) * RADIANS_TO_DEGREES; -// painter->save(); -//close, but no cigar. we need to "invert" our transformation to make this work properly -// return QPoint(-offsetX + x, (size().height() - (-offsetY + y)) * +1.0); -// painter->translate(0, viewportHeight); -// painter->scale(1.0, -1.0); -// Give up for now; just paint the info panel in the upper left corner of the screen -// painter->resetTransform(); QString text; if (hitHandle2) @@ -105,18 +102,17 @@ Arc::~Arc() 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, 220.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->Restore(); + painter->SetPen(QPen(QColor(0xDF, 0x5F, 0x00))); } - -// painter->setPen(QPen(Qt::red, 2.0, Qt::DotLine)); } else { @@ -124,22 +120,16 @@ Arc::~Arc() painter->SetPen(pen); } -#if 0 - QRectF rectangle(QPointF(position.x - radius, position.y - radius), - QPointF(position.x + radius, position.y + radius)); - int angle1 = (int)(startAngle * RADIANS_TO_DEGREES * 16.0); - int angle2 = (int)(angleSpan * RADIANS_TO_DEGREES * 16.0); - painter->DrawArc(rectangle, -angle1, -angle2); -#else painter->DrawArc(position, radius, startAngle, angleSpan); -#endif } + /*virtual*/ Vector Arc::Center(void) { return position; } + /* We need at least *four* handles for this object: - one for moving @@ -243,6 +233,7 @@ so let's do like this: return false; } + /*virtual*/ void Arc::PointerMoved(Vector point) { // The TLC will send these messages if the object is selected but not clicked on. @@ -283,6 +274,7 @@ so let's do like this: needUpdate = true; } + /*virtual*/ void Arc::PointerReleased(void) { hitHandle1 = hitHandle2 = hitHandle3 = hitHandle4 = false; @@ -304,6 +296,14 @@ but this is actually more compact and cleaner. state = oldState; } + +/*virtual*/ QRectF Arc::Extents(void) +{ +#warning "!!! Arc extents not calculated !!!" + return QRectF(); +} + + #if 0 /*virtual*/ bool Arc::NeedsUpdate(void) { @@ -311,6 +311,15 @@ but this is actually more compact and cleaner. } #endif + +#if 0 +/*virtual*/ ObjectType Arc::Type(void) +{ + return OTArc; +} +#endif + + /* start = 350, span = 20, end = 10, angle = 5 angle < start, so angle = 365 @@ -330,3 +339,10 @@ bool Arc::AngleInArcSpan(double angle) return (passedInSpan <= angleSpan ? true : false); } + + +/*virtual*/ void Arc::Enumerate(FILE * file) +{ + fprintf(file, "ARC (%lf,%lf) %lf, %lf, %lf\n", position.x, position.y, radius, startAngle, angleSpan); +} +