QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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#define SIP_NO_FILE
22
23#include "qgis_core.h"
24#include "qgsabstractgeometry.h"
25
26#include <QPaintEngine>
27#include <QPainterPath>
28
29class QgsPoint;
30class QgsDxfExport;
32
33
40
41class CORE_EXPORT QgsDxfPaintEngine: public QPaintEngine
42{
43 public:
44 QgsDxfPaintEngine( const QgsDxfPaintDevice *dxfDevice, QgsDxfExport *dxf );
45
46 bool begin( QPaintDevice *pdev ) override;
47 bool end() override;
48 QPaintEngine::Type type() const override;
49 void updateState( const QPaintEngineState &state ) override;
50
51 void drawPixmap( const QRectF &r, const QPixmap &pm, const QRectF &sr ) override;
52
53 void drawPolygon( const QPointF *points, int pointCount, PolygonDrawMode mode ) override;
54 void drawPath( const QPainterPath &path ) override;
55 void drawLines( const QLineF *lines, int lineCount ) override;
56
57 void setLayer( const QString &layer ) { mLayer = layer; }
58 QString layer() const { return mLayer; }
59
60 void setShift( QPointF shift ) { mShift = shift; }
61
62 private:
63 const QgsDxfPaintDevice *mPaintDevice = nullptr;
64 QgsDxfExport *mDxf = nullptr;
65
66 //painter state information
67 QTransform mTransform;
68 QPen mPen;
69 QBrush mBrush;
71 double mOpacity = 1.0;
72 QString mLayer;
73 QPointF mShift;
74 QgsRingSequence mPolygon;
75 QPolygonF mCurrentPolygon;
76 QList<QPointF> mCurrentCurve;
77
78 QgsPoint toDxfCoordinates( QPointF pt ) const;
79 double currentWidth() const;
80
81 void moveTo( double dx, double dy );
82 void lineTo( double dx, double dy );
83 void curveTo( double dx, double dy );
84 void endPolygon();
85 void endCurve();
86
87 void setRing( QgsPointSequence &polyline, const QPointF *points, int pointCount );
88
89 //utils for bezier curve calculation
90 static QPointF bezierPoint( const QList<QPointF> &controlPolygon, double t );
91 static double bernsteinPoly( int n, int i, double t );
92 static int lower( int n, int i );
93 static double power( double a, int b );
94 static int faculty( int n );
95
97 QColor penColor() const;
99 QColor brushColor() const;
100};
101
102#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:49
QVector< QgsPointSequence > QgsRingSequence
QVector< QgsPoint > QgsPointSequence