QGIS API Documentation  3.0.2-Girona (307d082)
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 #include "qgspoint.h"
27 
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;
67  QString mLayer;
68  QPointF mShift;
69  QgsRingSequence mPolygon;
70  QPolygonF mCurrentPolygon;
71  QList<QPointF> mCurrentCurve;
72 
73  QgsPoint toDxfCoordinates( QPointF pt ) const;
74  double currentWidth() const;
75 
76  void moveTo( double dx, double dy );
77  void lineTo( double dx, double dy );
78  void curveTo( double dx, double dy );
79  void endPolygon();
80  void endCurve();
81 
82  void setRing( QgsPointSequence &polyline, const QPointF *points, int pointCount );
83 
84  //utils for bezier curve calculation
85  static QPointF bezierPoint( const QList<QPointF> &controlPolygon, double t );
86  static double bernsteinPoly( int n, int i, double t );
87  static int lower( int n, int i );
88  static double power( double a, int b );
89  static int faculty( int n );
90 };
91 
92 #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