#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))
{
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;
}
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;
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);
}
/**
*/
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
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
{
#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
}
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)
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);
}
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
{
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));
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);
}