Subversion Repositories Scribus

Rev

Rev 20691 | Rev 21563 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4430 cbradney 1
/*
2
For general Scribus (>=1.3.2) copyright and licensing information please refer
3
to the COPYING file provided with the program. Following this notice may exist
4
a copyright and/or license notice that predates the release of Scribus 1.3.2
5
for which a new license (GPL+exception) is in place.
6
*/
68 Franz 7
 
8
#ifndef __SCPAINTER_H__
9
#define __SCPAINTER_H__
10
 
9319 fschmid 11
#include <QPainterPath>
12
#include <QPainter>
12055 jghali 13
#include <QVector>
9319 fschmid 14
#include <QStack>
15
#include <QColor>
13951 fschmid 16
#include <QTransform>
9319 fschmid 17
#include <QFont>
18
#include <QImage>
16856 craig 19
#include <QPointF>
2969 craig 20
#include "scribusapi.h"
3113 fschmid 21
#include "scconfig.h"
21107 craig 22
#include "sctextstruct.h"
68 Franz 23
#include "fpoint.h"
24
#include "fpointarray.h"
25
#include "vgradient.h"
15024 fschmid 26
#include "mesh.h"
68 Franz 27
 
19034 craig 28
class ScPattern;
29
 
3113 fschmid 30
typedef struct _cairo cairo_t;
5604 fschmid 31
typedef struct _cairo_surface cairo_surface_t;
6368 fschmid 32
typedef struct _cairo_pattern cairo_pattern_t;
68 Franz 33
 
2969 craig 34
class SCRIBUS_API ScPainter
68 Franz 35
{
36
public:
9319 fschmid 37
        ScPainter( QImage *target, unsigned int w, unsigned int h, double transparency = 1.0, int blendmode = 0 );
68 Franz 38
        virtual ~ScPainter();
18935 fschmid 39
        enum FillMode { None, Solid, Gradient, Pattern, Hatch };
7049 fschmid 40
        virtual void beginLayer(double transparency, int blendmode, FPointArray *clipArray = 0);
41
        virtual void endLayer();
6809 fschmid 42
        virtual void setAntialiasing(bool enable);
68 Franz 43
        virtual void begin();
44
        virtual void end();
45
        void clear();
46
        virtual void clear( const QColor & );
21107 craig 47
        virtual cairo_t* context();
68 Franz 48
 
49
        // matrix manipulation
13951 fschmid 50
        virtual void setWorldMatrix( const QTransform & );
51
        virtual const QTransform worldMatrix();
68 Franz 52
        virtual void setZoomFactor( double );
53
        virtual double zoomFactor() { return m_zoomFactor; }
54
        virtual void translate( double, double );
16856 craig 55
        virtual void translate( const QPointF& offset );
68 Franz 56
        virtual void rotate( double );
57
        virtual void scale( double, double );
58
 
59
        // drawing
60
        virtual void moveTo( const double &, const double & );
61
        virtual void lineTo( const double &, const double & );
62
        virtual void curveTo( FPoint p1, FPoint p2, FPoint p3 );
63
        virtual void newPath();
5233 fschmid 64
        virtual void closePath();
68 Franz 65
        virtual void fillPath();
1998 fschmid 66
        virtual void strokePath();
68 Franz 67
        virtual void setFillRule( bool fillRule );
1888 fschmid 68
        virtual bool fillRule() { return m_fillRule; }
68 Franz 69
        virtual void setFillMode( int fill );
20640 jghali 70
        virtual int  fillMode() { return m_fillMode; }
21107 craig 71
        virtual int  maskMode() { return m_maskMode; }
14168 fschmid 72
        virtual void setStrokeMode( int stroke );
20640 jghali 73
        virtual int  strokeMode() { return m_strokeMode; }
14284 fschmid 74
        virtual void setGradient( VGradient::VGradientType mode, FPoint orig, FPoint vec, FPoint foc, double scale, double skew);
14276 fschmid 75
        virtual void setPattern(ScPattern *pattern, double scaleX, double scaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, bool mirrorX, bool mirrorY);
14297 fschmid 76
 
77
        virtual void setMaskMode( int mask );
78
        virtual void setGradientMask( VGradient::VGradientType mode, FPoint orig, FPoint vec, FPoint foc, double scale, double skew);
79
        virtual void setPatternMask(ScPattern *pattern, double scaleX, double scaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, bool mirrorX, bool mirrorY);
14952 fschmid 80
 
81
        virtual void set4ColorGeometry(FPoint p1, FPoint p2, FPoint p3, FPoint p4, FPoint c1, FPoint c2, FPoint c3, FPoint c4);
82
        virtual void set4ColorColors(QColor col1, QColor col2, QColor col3, QColor col4);
14981 fschmid 83
        virtual void setDiamondGeometry(FPoint p1, FPoint p2, FPoint p3, FPoint p4, FPoint c1, FPoint c2, FPoint c3, FPoint c4, FPoint c5);
15024 fschmid 84
        virtual void setMeshGradient(FPoint p1, FPoint p2, FPoint p3, FPoint p4, QList<QList<meshPoint> > meshArray);
16729 fschmid 85
        virtual void setMeshGradient(FPoint p1, FPoint p2, FPoint p3, FPoint p4, QList<meshGradientPatch> meshPatches);
14952 fschmid 86
 
18935 fschmid 87
        virtual void setHatchParameters(int mode, double distance, double angle, bool useBackground, QColor background, QColor foreground, double width, double height);
88
 
267 Franz 89
        virtual void setClipPath();
68 Franz 90
 
14825 fschmid 91
        virtual void drawImage( QImage *image);
264 Franz 92
        virtual void setupPolygon(FPointArray *points, bool closed = true);
17790 fschmid 93
        virtual void setupSharpPolygon(FPointArray *points, bool closed = true);
94
        virtual void sharpLineHelper(FPoint &pp);
95
        virtual void sharpLineHelper(QPointF &pp);
68 Franz 96
        virtual void drawPolygon();
97
        virtual void drawPolyLine();
98
        virtual void drawLine(FPoint start, FPoint end);
16856 craig 99
        virtual void drawLine(const QPointF& start, const QPointF& end);
17790 fschmid 100
        virtual void drawSharpLine(FPoint start, FPoint end);
101
        virtual void drawSharpLine(QPointF start, QPointF end);
68 Franz 102
        virtual void drawRect(double, double, double, double);
17790 fschmid 103
        virtual void drawSharpRect(double x, double y, double w, double h);
17788 fschmid 104
        virtual void drawText(QRectF area, QString text, bool filled = true, int align = 0);
17963 fschmid 105
        virtual void drawShadeCircle(const QRectF &re, const QColor color, bool sunken, int lineWidth);
106
        virtual void drawShadePanel(const QRectF &r, const QColor color, bool sunken, int lineWidth);
20111 fschmid 107
        virtual void colorizeAlpha(QColor color);
108
        virtual void colorize(QColor color);
18772 fschmid 109
        virtual void blurAlpha(int radius);
110
        virtual void blur(int radius);
68 Franz 111
 
112
        // pen + brush
113
        virtual QColor pen();
114
        virtual QColor brush();
21107 craig 115
        virtual double brushOpacity();
68 Franz 116
        virtual void setPen( const QColor & );
80 Franz 117
        virtual void setPen( const QColor &c, double w, Qt::PenStyle st, Qt::PenCapStyle ca, Qt::PenJoinStyle jo );
118
        virtual void setPenOpacity( double op );
119
        virtual void setLineWidth( double w);
20691 craig 120
        virtual void setDash(const QVector<double>& m_array, double ofs);
68 Franz 121
        virtual void setBrush( const QColor & );
80 Franz 122
        virtual void setBrushOpacity( double op );
123
        virtual void setOpacity( double op );
68 Franz 124
        virtual void setFont( const QFont &f );
80 Franz 125
        virtual QFont font();
68 Franz 126
 
127
        // stack management
128
        virtual void save();
129
        virtual void restore();
21107 craig 130
        virtual int blendModeFill();
68 Franz 131
 
9319 fschmid 132
 
14306 fschmid 133
        virtual void setRasterOp( int blendMode );
134
        virtual void setBlendModeFill( int blendMode );
135
        virtual void setBlendModeStroke( int blendMode );
68 Franz 136
 
137
        VGradient fill_gradient;
138
        VGradient stroke_gradient;
14297 fschmid 139
        VGradient mask_gradient;
140
        ScPattern *m_maskPattern;
6369 fschmid 141
        ScPattern *m_pattern;
68 Franz 142
 
143
private:
17288 jghali 144
        void fillPathHelper();
145
        void strokePathHelper();
16281 jghali 146
 
9319 fschmid 147
        cairo_t *m_cr;
148
        struct layerProp
149
        {
150
                cairo_surface_t *data;
151
                int blendmode;
152
                double tranparency;
14854 fschmid 153
                int maskMode;                           // 0 = none, 1 = gradient 2 = pattern
154
                double mask_patternScaleX;
155
                double mask_patternScaleY;
156
                double mask_patternOffsetX;
157
                double mask_patternOffsetY;
158
                double mask_patternRotation;
159
                double mask_patternSkewX;
160
                double mask_patternSkewY;
161
                bool mask_patternMirrorX;
162
                bool mask_patternMirrorY;
163
                double mask_gradientScale;
164
                double mask_gradientSkew;
165
                VGradient mask_gradient;
166
                ScPattern *maskPattern;
9319 fschmid 167
                FPointArray groupClip;
168
                bool pushed;
16744 fschmid 169
                bool fillRule;
9319 fschmid 170
        };
14298 fschmid 171
        cairo_pattern_t *getMaskPattern();
20691 craig 172
        cairo_surface_t *m_imageMask;
173
        QImage m_imageQ;
16281 jghali 174
 
20691 craig 175
        QStack<layerProp> m_Layers;
176
        QStack<double> m_zoomStack;
1815 fschmid 177
        QImage *m_image;
5373 fschmid 178
        double  m_layerTransparency;
179
        int  m_blendMode;
14306 fschmid 180
        int  m_blendModeFill;
181
        int  m_blendModeStroke;
68 Franz 182
        unsigned int m_width;
183
        unsigned int m_height;
13951 fschmid 184
        QTransform m_matrix;
68 Franz 185
        QFont m_font;
186
        bool mf_underline;
187
        bool mf_strikeout;
188
        bool mf_shadow;
189
        bool mf_outlined;
4646 subik 190
        /*! \brief Filling */
68 Franz 191
        QColor m_fill;
20691 craig 192
        double m_fill_trans;
68 Franz 193
        bool m_fillRule;
20640 jghali 194
        int m_fillMode;                         // 0 = none, 1 = solid, 2 = gradient 3 = pattern 4 = hatch
20691 craig 195
        double m_patternScaleX;
196
        double m_patternScaleY;
197
        double m_patternOffsetX;
198
        double m_patternOffsetY;
199
        double m_patternRotation;
200
        double m_patternSkewX;
201
        double m_patternSkewY;
202
        bool m_patternMirrorX;
203
        bool m_patternMirrorY;
204
        double m_gradientScale;
205
        double m_gradientSkew;
14952 fschmid 206
        FPoint gradPatchP1;
207
        FPoint gradPatchP2;
208
        FPoint gradPatchP3;
209
        FPoint gradPatchP4;
210
        FPoint gradControlP1;
211
        FPoint gradControlP2;
212
        FPoint gradControlP3;
213
        FPoint gradControlP4;
14981 fschmid 214
        FPoint gradControlP5;
14952 fschmid 215
        QColor gradPatchColor1;
216
        QColor gradPatchColor2;
217
        QColor gradPatchColor3;
218
        QColor gradPatchColor4;
15024 fschmid 219
        QList<QList<meshPoint> > meshGradientArray;
16729 fschmid 220
        QList<meshGradientPatch> meshGradientPatches;
20691 craig 221
        double m_hatchAngle;
222
        double m_hatchDistance;
223
        int m_hatchType;                                // 0 = single 1 = double 2 = triple
224
        bool m_hatchUseBackground;
225
        QColor m_hatchBackground;
226
        QColor m_hatchForeground;
227
        double m_hatchWidth;
228
        double m_hatchHeight;
4646 subik 229
        /*! \brief Stroking */
68 Franz 230
        QColor m_stroke;
20691 craig 231
        double m_stroke_trans;
232
        double m_LineWidth;
20640 jghali 233
        int m_strokeMode;                               // 0 = none, 1 = solid, 2 = gradient 3 = pattern
20691 craig 234
        int m_maskMode;                         // 0 = none, 1 = gradient 2 = pattern
235
        double m_mask_patternScaleX;
236
        double m_mask_patternScaleY;
237
        double m_mask_patternOffsetX;
238
        double m_mask_patternOffsetY;
239
        double m_mask_patternRotation;
240
        double m_mask_patternSkewX;
241
        double m_mask_patternSkewY;
242
        bool m_mask_patternMirrorX;
243
        bool m_mask_patternMirrorY;
244
        double m_mask_gradientScale;
245
        double m_mask_gradientSkew;
80 Franz 246
 
4646 subik 247
        /*! \brief Line End Style */
9319 fschmid 248
        Qt::PenCapStyle PLineEnd;
4646 subik 249
  /*! \brief Line Join Style */
9319 fschmid 250
        Qt::PenJoinStyle PLineJoin;
4646 subik 251
  /*! \brief The Dash Array */
12055 jghali 252
        QVector<double> m_array;
80 Franz 253
        double m_offset;
4646 subik 254
        /*! \brief Zoom Factor of the Painter */
68 Franz 255
        double m_zoomFactor;
20691 craig 256
        bool m_imageMode;
257
        bool m_layeredMode;
258
        bool m_svgMode;
68 Franz 259
};
260
 
261
#endif