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