-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
/
qgsdxfpaintengine.h
82 lines (66 loc) · 2.86 KB
/
qgsdxfpaintengine.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/***************************************************************************
qgsdxpaintengine.h
------------------
begin : November 2013
copyright : (C) 2013 by Marco Hugentobler
email : marco at sourcepole dot ch
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSDXFPAINTENGINE_H
#define QGSDXFPAINTENGINE_H
#include <QPaintEngine>
class QgsDxfExport;
class QgsDxfPaintDevice;
class QgsPoint;
class CORE_EXPORT QgsDxfPaintEngine: public QPaintEngine
{
public:
QgsDxfPaintEngine( const QgsDxfPaintDevice* dxfDevice, QgsDxfExport* dxf );
~QgsDxfPaintEngine();
bool begin( QPaintDevice* pdev );
bool end();
QPaintEngine::Type type() const;
void updateState( const QPaintEngineState& state );
void drawPixmap( const QRectF& r, const QPixmap& pm, const QRectF& sr );
void drawPolygon( const QPointF * points, int pointCount, PolygonDrawMode mode );
void drawRects( const QRectF * rects, int rectCount );
void drawEllipse( const QRectF& rect );
void drawPath( const QPainterPath& path );
void drawLines( const QLineF* lines, int lineCount );
void setLayer( const QString& layer ) { mLayer = layer; }
QString layer() const { return mLayer; }
void setShift( const QPointF& shift ) { mShift = shift; }
private:
const QgsDxfPaintDevice* mPaintDevice;
QgsDxfExport* mDxf;
//painter state information
QTransform mTransform;
QPen mPen;
QBrush mBrush;
QString mLayer;
QPointF mShift;
QPolygonF mCurrentPolygon;
QList<QPointF> mCurrentCurve;
QgsPoint toDxfCoordinates( const QPointF& pt ) const;
int currentColor() const;
double currentWidth() const;
void moveTo( double dx, double dy );
void lineTo( double dx, double dy );
void curveTo( double dx, double dy );
void endPolygon();
void endCurve();
//utils for bezier curve calculation
static QPointF bezierPoint( const QList<QPointF>& controlPolygon, double t );
static double bernsteinPoly( int n, int i, double t );
static int lower( int n, int i );
static double power( double a, int b );
static int faculty( int n );
};
#endif // QGSDXFPAINTENGINE_H