Frontend to the famous GRBL.

qpainter2gcode.h 2.7KB

    /* Part of x2grbl * * Copyright Johann Wilhelm <johann.wilhelm@9mal6.de> 2015 * * see Readme.md for detailed license and usage information! */ #ifndef QPAINTER2GCODE_H #define QPAINTER2GCODE_H #include <QPainter> #include <QPaintDevice> #include <QPaintEngine> #include <QSvgGenerator> #include "gcodeoutputdevice.h" #include "gcodeparser.h" class GCodePainterEngine; class QPainter2GCode : public QPaintDevice { public: QPainter2GCode(); virtual ~QPainter2GCode(); virtual QPaintEngine *paintEngine() const; void InitParser(GCodeParser &Parser); protected: GCodePainterEngine *Engine; virtual int metric(PaintDeviceMetric metric) const; }; class GCodePainterEngine : public QPaintEngine { public: explicit GCodePainterEngine(PaintEngineFeatures features=QPaintEngine::AllFeatures); virtual ~GCodePainterEngine(); virtual bool begin(QPaintDevice *pdev); virtual bool end(); virtual void updateState(const QPaintEngineState &state); virtual void drawRects(const QRect *rects, int rectCount); virtual void drawRects(const QRectF *rects, int rectCount); virtual void drawLines(const QLine *lines, int lineCount); virtual void drawLines(const QLineF *lines, int lineCount); virtual void drawEllipse(const QRectF &r); virtual void drawEllipse(const QRect &r); virtual void drawPath(const QPainterPath &path); virtual void drawPoints(const QPointF *points, int pointCount); virtual void drawPoints(const QPoint *points, int pointCount); virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode); virtual void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode); virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr); virtual void drawTextItem(const QPointF &p, const QTextItem &textItem); virtual void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s); virtual void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, Qt::ImageConversionFlags flags = Qt::AutoColor); virtual Type type() const; int SetMillingTool(int width, bool ForcePerfect=true); int SetDrillingTool(int width); protected: virtual void drawPathInternal(const QPainterPath &path); void SimplyfyInternal(QPainterPath &path); static const double ps2mm; double minLength; QList<GCode> GCodeListing; friend QPainter2GCode; double highZ; double lowZ; QMap<int, int> Mills; QMap<int, int> Drills; private: }; #endif // QPAINTER2GCODE_H