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