X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fbase%2Fpaintinterface.cpp;h=fdcbee464204887a8f361419573fdab84eb9cada;hb=2ee84c5948ede7fc2f7b4435c5edef42a030ac05;hp=55da307881a7cb13902759492b98c0755bf45bcf;hpb=d774c2655ba2c3657a565f325411144452392277;p=architektonas diff --git a/src/base/paintinterface.cpp b/src/base/paintinterface.cpp index 55da307..fdcbee4 100644 --- a/src/base/paintinterface.cpp +++ b/src/base/paintinterface.cpp @@ -2,7 +2,9 @@ // // Part of the Architektonas Project // Extensively rewritten and refactored by James L. Hammons -// (C) 2010 Underground Software +// Portions copyright (C) 2001-2003 RibbonSoft +// Copyright (C) 2010 Underground Software +// See the README and GPLv2 files for licensing and warranty information // // JLH = James L. Hammons // @@ -16,8 +18,8 @@ #include "paintinterface.h" -#include "rs_debug.h" -#include "rs_math.h" +#include "debug.h" +#include "mathextra.h" PaintInterface::PaintInterface(QPainter * p): painter(p), drawingMode(RS2::ModeFull), offset(Vector(0.0, 0.0)) @@ -45,7 +47,7 @@ void PaintInterface::createArc(QPolygon & pa, const Vector& cp, double radius, { if (radius < 1.0e-6) { - RS_DEBUG->print(RS_Debug::D_WARNING, "PaintInterface::createArc: invalid radius: %f", radius); + DEBUG->print(Debug::D_WARNING, "PaintInterface::createArc: invalid radius: %f", radius); return; } @@ -118,7 +120,7 @@ void PaintInterface::drawRect(const Vector & p1, const Vector & p2) drawLine(Vector(p1.x, p2.y), Vector(p1.x, p1.y)); } -void PaintInterface::drawHandle(const Vector & p, const RS_Color & c, int size) +void PaintInterface::drawHandle(const Vector & p, const Color & c, int size) { if (size < 0) size = 2; @@ -145,12 +147,12 @@ void PaintInterface::setOffset(const Vector & o) int PaintInterface::toScreenX(double x) { - return RS_Math::round(offset.x + x); + return Math::round(offset.x + x); } int PaintInterface::toScreenY(double y) { - return RS_Math::round(offset.y + y); + return Math::round(offset.y + y); } /** @@ -337,7 +339,7 @@ void PaintInterface::drawArc(const Vector & cp, double radius, double a1, double */ void PaintInterface::drawArcMac(const Vector& cp, double radius, double a1, double a2, bool reversed) { - RS_DEBUG->print("PaintInterface::drawArcMac"); + DEBUG->print("PaintInterface::drawArcMac"); if (radius <= 0.5) drawGridPoint(cp); else @@ -409,7 +411,7 @@ void PaintInterface::drawCircle(const Vector & cp, double radius) if (drawingMode == RS2::ModeXOR && radius < 500) { // This is _very_ slow for large arcs: - painter->drawEllipse(toScreenX(cp.x - radius), toScreenY(cp.y - radius), RS_Math::round(2.0 * radius), RS_Math::round(2.0 * radius)); + painter->drawEllipse(toScreenX(cp.x - radius), toScreenY(cp.y - radius), Math::round(2.0 * radius), Math::round(2.0 * radius)); } else { @@ -420,7 +422,7 @@ void PaintInterface::drawCircle(const Vector & cp, double radius) #endif } #else -// painter->drawEllipse(toScreenX(cp.x - radius), toScreenY(cp.y - radius), RS_Math::round(2.0 * radius), RS_Math::round(2.0 * radius)); +// painter->drawEllipse(toScreenX(cp.x - radius), toScreenY(cp.y - radius), Math::round(2.0 * radius), Math::round(2.0 * radius)); painter->drawEllipse(QPointF(cp.x, cp.y), radius, radius); #endif } @@ -496,7 +498,7 @@ void PaintInterface::drawImg(QImage & img, const Vector & pos, QMatrix wm; wm.translate(pos.x, pos.y); wm.scale(factor.x, factor.y); - wm.rotate(RS_Math::rad2deg(-angle)); + wm.rotate(Math::rad2deg(-angle)); painter->setWorldMatrix(wm); if (fabs(angle) < 1.0e-4) @@ -507,7 +509,7 @@ void PaintInterface::drawImg(QImage & img, const Vector & pos, painter->restore(); } -void PaintInterface::fillRect(int x1, int y1, int w, int h, const RS_Color & col) +void PaintInterface::fillRect(int x1, int y1, int w, int h, const Color & col) { painter->fillRect(x1, y1, w, h, col); } @@ -537,33 +539,33 @@ int PaintInterface::getHeight() void PaintInterface::setPreviewPen() { - setPen(RS_Color(0, 255, 255)); + setPen(Color(0, 255, 255)); } -RS_Pen PaintInterface::getPen() +Pen PaintInterface::getPen() { return lpen; } -void PaintInterface::setPen(const RS_Pen & pen) +void PaintInterface::setPen(const Pen & pen) { lpen = pen; if (drawingMode == RS2::ModeBW) - lpen.setColor(RS_Color(0, 0, 0)); + lpen.setColor(Color(0, 0, 0)); - QPen p(lpen.getColor(), RS_Math::round(lpen.getScreenWidth()), RS2::rsToQtLineType(lpen.getLineType())); + QPen p(lpen.getColor(), Math::round(lpen.getScreenWidth()), RS2::rsToQtLineType(lpen.getLineType())); p.setJoinStyle(Qt::RoundJoin); p.setCapStyle(Qt::RoundCap); painter->setPen(p); } -void PaintInterface::setPen(const RS_Color & color) +void PaintInterface::setPen(const Color & color) { if (drawingMode == RS2::ModeBW) { - lpen.setColor(RS_Color(0, 0, 0)); - painter->setPen(RS_Color(0, 0, 0)); + lpen.setColor(Color(0, 0, 0)); + painter->setPen(Color(0, 0, 0)); } else { @@ -580,13 +582,13 @@ void PaintInterface::setPen(int r, int g, int b) setPen(QColor(r, g, b)); } -void PaintInterface::disablePen() +void PaintInterface::disablePen(void) { - lpen = RS_Pen(RS2::FlagInvalid); + lpen = Pen(RS2::FlagInvalid); painter->setPen(Qt::NoPen); } -void PaintInterface::setBrush(const RS_Color & color) +void PaintInterface::setBrush(const Color & color) { if (drawingMode == RS2::ModeBW) painter->setBrush(QColor(0, 0, 0)); @@ -594,17 +596,23 @@ void PaintInterface::setBrush(const RS_Color & color) painter->setBrush(color); } +void PaintInterface::disableBrush(void) +{ +// lpen = Pen(RS2::FlagInvalid); + painter->setBrush(Qt::NoBrush); +} + void PaintInterface::drawPolygon(const QPolygon & a) { painter->drawPolygon(a); } -void PaintInterface::setXORMode() +void PaintInterface::setXORMode(void) { painter->setCompositionMode(QPainter::CompositionMode_Xor); } -void PaintInterface::setNormalMode() +void PaintInterface::setNormalMode(void) { painter->setCompositionMode(QPainter::CompositionMode_SourceOver); }