X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Farc.cpp;fp=src%2Farc.cpp;h=925676d3f2bb148b22970dc1b9b0fd57795cb6f9;hb=bd9b40058a376c946318a444dd6c77737ec6ac98;hp=adccd21507f23c816110b031c45aa3450a0d9c2c;hpb=7ac2021bfe0d3032e161520e3fa790ef621e39b3;p=architektonas diff --git a/src/arc.cpp b/src/arc.cpp index adccd21..925676d 100644 --- a/src/arc.cpp +++ b/src/arc.cpp @@ -16,6 +16,7 @@ #include #include "mathconstants.h" +#include "painter.h" Arc::Arc(Vector p1, double r, double a1, double a2, Object * p/*= NULL*/): Object(p1, p), @@ -27,8 +28,10 @@ Arc::~Arc() { } -/*virtual*/ void Arc::Draw(QPainter * painter) +/*virtual*/ void Arc::Draw(Painter * painter) { + QPen pen; + if (state == OSSelected) { Point p1(cos(startAngle), sin(startAngle)); @@ -44,23 +47,25 @@ Arc::~Arc() // moving it from. Point p3(cos(oldAngle), sin(oldAngle)); Vector oldLine = (p3 * (radius * 1.25)) + position; - painter->setPen(QPen(QColor(0x80, 0x80, 0x80), 1.0, Qt::DashLine)); - painter->drawLine((int)position.x, (int)position.y, (int)oldLine.x, (int)oldLine.y); + pen = QPen(QColor(0x80, 0x80, 0x80), 1.0, Qt::DashLine); + painter->SetPen(pen); + painter->DrawLine((int)position.x, (int)position.y, (int)oldLine.x, (int)oldLine.y); } // In rotating and setting the span, we draw a line showing where // we angle/span is that we're setting. - painter->setPen(QPen(QColor(0x00, 0xC0, 0x80), 1.0, Qt::DashLine)); - painter->drawLine((int)position.x, (int)position.y, (int)oldPoint.x, (int)oldPoint.y); + pen = QPen(QColor(0x00, 0xC0, 0x80), 1.0, Qt::DashLine); + painter->SetPen(pen); + painter->DrawLine((int)position.x, (int)position.y, (int)oldPoint.x, (int)oldPoint.y); } // Draw the center point of the arc - painter->setPen(QPen(Qt::red, 2.0, Qt::DotLine)); - painter->drawEllipse(QPointF(position.x, position.y), 4.0, 4.0); + painter->SetPen(QPen(Qt::red, 2.0, Qt::DotLine)); + painter->DrawEllipse(position, 4.0, 4.0); // Draw the rotation & span setting handles - painter->drawEllipse(QPointF(handle2.x, handle2.y), 4.0, 4.0); - painter->drawEllipse(QPointF(handle3.x, handle3.y), 4.0, 4.0); + painter->DrawEllipse(handle2, 4.0, 4.0); + painter->DrawEllipse(handle3, 4.0, 4.0); // If we're rotating or setting the span, draw an information panel // showing both absolute and relative angles being set. @@ -70,13 +75,13 @@ Arc::~Arc() double relAngle = (startAngle >= oldAngle ? startAngle - oldAngle : startAngle - oldAngle + (2.0 * PI)) * RADIANS_TO_DEGREES; - painter->save(); +// 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(); +// painter->resetTransform(); QString text; if (hitHandle2) @@ -97,28 +102,37 @@ Arc::~Arc() text = text.arg(radius, 0, 'd', 4).arg(radius / oldRadius * 100.0, 0, 'd', 0); } - painter->setPen(QPen(QColor(0x00, 0xFF, 0x00), 1.0, Qt::SolidLine)); - painter->setBrush(QBrush(QColor(0x40, 0xFF, 0x40, 0x9F))); + 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 - painter->drawRoundedRect(textRect, 7.0, 7.0); + painter->DrawRoundedRect(textRect, 7.0, 7.0); textRect.setLeft(textRect.left() + 14); - painter->setFont(*Object::font); - painter->setPen(QPen(QColor(0xDF, 0x5F, 0x00), 1.0, Qt::SolidLine)); - painter->drawText(textRect, Qt::AlignVCenter, text); - painter->restore(); + painter->SetFont(*Object::font); + pen = QPen(QColor(0xDF, 0x5F, 0x00), 1.0, Qt::SolidLine); + painter->SetPen(pen); + painter->DrawText(textRect, Qt::AlignVCenter, text); +// painter->Restore(); } // painter->setPen(QPen(Qt::red, 2.0, Qt::DotLine)); } else - painter->setPen(QPen(Qt::black, 1.0, Qt::SolidLine)); + { + pen = QPen(Qt::black, 1.0, Qt::SolidLine); + 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); + painter->DrawArc(rectangle, -angle1, -angle2); +#else + painter->DrawArc(position, radius, startAngle, angleSpan); +#endif } /*virtual*/ Vector Arc::Center(void)