QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 #include <QPaintEngine>
22 #include "qgsgeometryfactory.h"
23 #include "qgsabstractgeometryv2.h"
24 
25 class QgsDxfExport;
26 class QgsDxfPaintDevice;
27 
28 
34 class CORE_EXPORT QgsDxfPaintEngine: public QPaintEngine
35 {
36  public:
37  QgsDxfPaintEngine( const QgsDxfPaintDevice* dxfDevice, QgsDxfExport* dxf );
39 
40  bool begin( QPaintDevice* pdev ) override;
41  bool end() override;
42  QPaintEngine::Type type() const override;
43  void updateState( const QPaintEngineState& state ) override;
44 
45  void drawPixmap( const QRectF& r, const QPixmap& pm, const QRectF& sr ) override;
46 
47  void drawPolygon( const QPointF * points, int pointCount, PolygonDrawMode mode ) override;
48  void drawPath( const QPainterPath& path ) override;
49  void drawLines( const QLineF* lines, int lineCount ) override;
50 
51  void setLayer( const QString& layer ) { mLayer = layer; }
52  QString layer() const { return mLayer; }
53 
54  void setShift( QPointF shift ) { mShift = shift; }
55 
56  private:
57  const QgsDxfPaintDevice* mPaintDevice;
58  QgsDxfExport* mDxf;
59 
60  //painter state information
61  QTransform mTransform;
62  QPen mPen;
63  QBrush mBrush;
65  double mOpacity;
66  QString mLayer;
67  QPointF mShift;
68  QgsRingSequenceV2 mPolygon;
69  QPolygonF mCurrentPolygon;
70  QList<QPointF> mCurrentCurve;
71 
72  QgsPointV2 toDxfCoordinates( QPointF pt ) const;
73  double currentWidth() const;
74 
75  void moveTo( double dx, double dy );
76  void lineTo( double dx, double dy );
77  void curveTo( double dx, double dy );
78  void endPolygon();
79  void endCurve();
80 
81  void setRing( QgsPointSequenceV2 &polyline, const QPointF * points, int pointCount );
82 
83  //utils for bezier curve calculation
84  static QPointF bezierPoint( const QList<QPointF>& controlPolygon, double t );
85  static double bernsteinPoly( int n, int i, double t );
86  static int lower( int n, int i );
87  static double power( double a, int b );
88  static int faculty( int n );
89 
91  QColor penColor() const;
93  QColor brushColor() const;
94 };
95 
96 #endif // QGSDXFPAINTENGINE_H
virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr)=0
virtual void drawPath(const QPainterPath &path)
A paint device for drawing into dxf files.
virtual bool begin(QPaintDevice *pdev)=0
QString layer() const
int ANALYSIS_EXPORT faculty(int n)
Faculty function.
virtual bool end()=0
Point geometry type, with support for z-dimension and m-values.
Definition: qgspointv2.h:34
virtual void drawLines(const QLine *lines, int lineCount)
virtual Type type() const=0
void setShift(QPointF shift)
double ANALYSIS_EXPORT power(double a, int b)
Power function for integer coefficients.
int ANALYSIS_EXPORT lower(int n, int i)
Lower function.
virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode)
virtual void updateState(const QPaintEngineState &state)=0
void setLayer(const QString &layer)