QGIS API Documentation  2.10.1-Pisa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
24 class QgsDxfExport;
25 class QgsDxfPaintDevice;
26 class QgsPoint;
27 
28 class CORE_EXPORT QgsDxfPaintEngine: public QPaintEngine
29 {
30  public:
31  QgsDxfPaintEngine( const QgsDxfPaintDevice* dxfDevice, QgsDxfExport* dxf );
33 
34  bool begin( QPaintDevice* pdev ) override;
35  bool end() override;
36  QPaintEngine::Type type() const override;
37  void updateState( const QPaintEngineState& state ) override;
38 
39  void drawPixmap( const QRectF& r, const QPixmap& pm, const QRectF& sr ) override;
40 
41  void drawPolygon( const QPointF * points, int pointCount, PolygonDrawMode mode ) override;
42  void drawPath( const QPainterPath& path ) override;
43  void drawLines( const QLineF* lines, int lineCount ) override;
44 
45  void setLayer( const QString& layer ) { mLayer = layer; }
46  QString layer() const { return mLayer; }
47 
48  void setShift( const QPointF& shift ) { mShift = shift; }
49 
50  private:
51  const QgsDxfPaintDevice* mPaintDevice;
52  QgsDxfExport* mDxf;
53 
54  //painter state information
55  QTransform mTransform;
56  QPen mPen;
57  QBrush mBrush;
58  QString mLayer;
59  QPointF mShift;
60  QgsPolygon mPolygon;
61  QPolygonF mCurrentPolygon;
62  QList<QPointF> mCurrentCurve;
63 
64  QgsPoint toDxfCoordinates( const QPointF& pt ) const;
65  double currentWidth() const;
66 
67  void moveTo( double dx, double dy );
68  void lineTo( double dx, double dy );
69  void curveTo( double dx, double dy );
70  void endPolygon();
71  void endCurve();
72 
73  void setRing( QgsPolyline &polyline, const QPointF * points, int pointCount );
74 
75  //utils for bezier curve calculation
76  static QPointF bezierPoint( const QList<QPointF>& controlPolygon, double t );
77  static double bernsteinPoly( int n, int i, double t );
78  static int lower( int n, int i );
79  static double power( double a, int b );
80  static int faculty( int n );
81 };
82 
83 #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
virtual void drawLines(const QLine *lines, int lineCount)
virtual Type type() const =0
A class to represent a point.
Definition: qgspoint.h:63
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 setShift(const QPointF &shift)
void setLayer(const QString &layer)