QGIS API Documentation 3.41.0-Master (af5edcb665c)
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 <QPaintEngine>
25#include <QPainterPath>
26#include "qgsabstractgeometry.h"
27
28class QgsPoint;
29class QgsDxfExport;
31
32
40class CORE_EXPORT QgsDxfPaintEngine: public QPaintEngine
41{
42 public:
43 QgsDxfPaintEngine( const QgsDxfPaintDevice *dxfDevice, QgsDxfExport *dxf );
44
45 bool begin( QPaintDevice *pdev ) override;
46 bool end() override;
47 QPaintEngine::Type type() const override;
48 void updateState( const QPaintEngineState &state ) override;
49
50 void drawPixmap( const QRectF &r, const QPixmap &pm, const QRectF &sr ) override;
51
52 void drawPolygon( const QPointF *points, int pointCount, PolygonDrawMode mode ) override;
53 void drawPath( const QPainterPath &path ) override;
54 void drawLines( const QLineF *lines, int lineCount ) override;
55
56 void setLayer( const QString &layer ) { mLayer = layer; }
57 QString layer() const { return mLayer; }
58
59 void setShift( QPointF shift ) { mShift = shift; }
60
61 private:
62 const QgsDxfPaintDevice *mPaintDevice = nullptr;
63 QgsDxfExport *mDxf = nullptr;
64
65 //painter state information
66 QTransform mTransform;
67 QPen mPen;
68 QBrush mBrush;
70 double mOpacity = 1.0;
71 QString mLayer;
72 QPointF mShift;
73 QgsRingSequence mPolygon;
74 QPolygonF mCurrentPolygon;
75 QList<QPointF> mCurrentCurve;
76
77 QgsPoint toDxfCoordinates( QPointF pt ) const;
78 double currentWidth() const;
79
80 void moveTo( double dx, double dy );
81 void lineTo( double dx, double dy );
82 void curveTo( double dx, double dy );
83 void endPolygon();
84 void endCurve();
85
86 void setRing( QgsPointSequence &polyline, const QPointF *points, int pointCount );
87
88 //utils for bezier curve calculation
89 static QPointF bezierPoint( const QList<QPointF> &controlPolygon, double t );
90 static double bernsteinPoly( int n, int i, double t );
91 static int lower( int n, int i );
92 static double power( double a, int b );
93 static int faculty( int n );
94
96 QColor penColor() const;
98 QColor brushColor() const;
99};
100
101#endif // QGSDXFPAINTENGINE_H
Exports QGIS layers to the DXF format.
A paint device for drawing into dxf files.
Custom paint engine for rendering to DXF drawings.
void setShift(QPointF shift)
void setLayer(const QString &layer)
QString layer() const
Point geometry type, with support for z-dimension and m-values.
Definition qgspoint.h:49
QVector< QgsPointSequence > QgsRingSequence
QVector< QgsPoint > QgsPointSequence