QGIS API Documentation  2.18.3-Las Palmas (77b8c3d)
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;
64  QString mLayer;
65  QPointF mShift;
66  QgsRingSequenceV2 mPolygon;
67  QPolygonF mCurrentPolygon;
68  QList<QPointF> mCurrentCurve;
69 
70  QgsPointV2 toDxfCoordinates( QPointF pt ) const;
71  double currentWidth() const;
72 
73  void moveTo( double dx, double dy );
74  void lineTo( double dx, double dy );
75  void curveTo( double dx, double dy );
76  void endPolygon();
77  void endCurve();
78 
79  void setRing( QgsPointSequenceV2 &polyline, const QPointF * points, int pointCount );
80 
81  //utils for bezier curve calculation
82  static QPointF bezierPoint( const QList<QPointF>& controlPolygon, double t );
83  static double bernsteinPoly( int n, int i, double t );
84  static int lower( int n, int i );
85  static double power( double a, int b );
86  static int faculty( int n );
87 };
88 
89 #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)