QGIS API Documentation 3.99.0-Master (c22de0620c0)
Loading...
Searching...
No Matches
qgsdxfpaintengine.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsdxpaintengine.h
3 ------------------
4 begin : November 2013
5 copyright : (C) 2013 by Marco Hugentobler
6 email : marco at sourcepole dot ch
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSDXFPAINTENGINE_H
19#define QGSDXFPAINTENGINE_H
20
21
22#include "qgis_core.h"
23#include "qgsabstractgeometry.h"
24
25#include <QPaintEngine>
26#include <QPainterPath>
27
28#define SIP_NO_FILE
29
30class QgsPoint;
31class QgsDxfExport;
33
34
41
42class CORE_EXPORT QgsDxfPaintEngine: public QPaintEngine
43{
44 public:
45 QgsDxfPaintEngine( const QgsDxfPaintDevice *dxfDevice, QgsDxfExport *dxf );
46
47 bool begin( QPaintDevice *pdev ) override;
48 bool end() override;
49 QPaintEngine::Type type() const override;
50 void updateState( const QPaintEngineState &state ) override;
51
52 void drawPixmap( const QRectF &r, const QPixmap &pm, const QRectF &sr ) override;
53
54 void drawPolygon( const QPointF *points, int pointCount, PolygonDrawMode mode ) override;
55 void drawPath( const QPainterPath &path ) override;
56 void drawLines( const QLineF *lines, int lineCount ) override;
57
58 void setLayer( const QString &layer ) { mLayer = layer; }
59 QString layer() const { return mLayer; }
60
61 void setShift( QPointF shift ) { mShift = shift; }
62
63 private:
64 const QgsDxfPaintDevice *mPaintDevice = nullptr;
65 QgsDxfExport *mDxf = nullptr;
66
67 //painter state information
68 QTransform mTransform;
69 QPen mPen;
70 QBrush mBrush;
72 double mOpacity = 1.0;
73 QString mLayer;
74 QPointF mShift;
75 QgsRingSequence mPolygon;
76 QPolygonF mCurrentPolygon;
77 QList<QPointF> mCurrentCurve;
78
79 QgsPoint toDxfCoordinates( QPointF pt ) const;
80 double currentWidth() const;
81
82 void moveTo( double dx, double dy );
83 void lineTo( double dx, double dy );
84 void curveTo( double dx, double dy );
85 void endPolygon();
86 void endCurve();
87
88 void setRing( QgsPointSequence &polyline, const QPointF *points, int pointCount );
89
90 //utils for bezier curve calculation
91 static QPointF bezierPoint( const QList<QPointF> &controlPolygon, double t );
92 static double bernsteinPoly( int n, int i, double t );
93 static int lower( int n, int i );
94 static double power( double a, int b );
95 static int faculty( int n );
96
98 QColor penColor() const;
100 QColor brushColor() const;
101};
102
103#endif // QGSDXFPAINTENGINE_H
Exports QGIS layers to the DXF format.
A paint device for drawing into dxf files.
void setShift(QPointF shift)
void drawPath(const QPainterPath &path) override
bool begin(QPaintDevice *pdev) override
QgsDxfPaintEngine(const QgsDxfPaintDevice *dxfDevice, QgsDxfExport *dxf)
void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) override
void updateState(const QPaintEngineState &state) override
void setLayer(const QString &layer)
void drawLines(const QLineF *lines, int lineCount) override
QPaintEngine::Type type() const override
QString layer() const
void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) override
Point geometry type, with support for z-dimension and m-values.
Definition qgspoint.h:53
QVector< QgsPointSequence > QgsRingSequence
QVector< QgsPoint > QgsPointSequence