Scribus
Open source desktop publishing at your fingertips
scpainterex_cairo.h
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 */
7 
8 #ifndef SCPAINTEREX_CAIRO_H
9 #define SCPAINTEREX_CAIRO_H
10 
11 #include <cairo.h>
12 #include "scpainterexbase.h"
13 
14 #include "mesh.h"
15 
17 {
18 public:
19  ScPainterEx_Cairo(cairo_t* context, QRect& rect, ScribusDoc* doc, bool gray );
20  virtual ~ScPainterEx_Cairo();
21 
22  virtual Capabilities capabilities() { return transparencies; }
23 
24  virtual int supportedColorModes() { return (int) rgbMode; }
25  virtual ColorMode preferredColorMode() { return rgbMode; }
26  virtual ImageMode imageMode() { return rgbImages; }
27 
28  virtual void begin();
29  virtual void end();
30  virtual void clear();
31  virtual void clear( ScColorShade & );
32 
33  // matrix manipulation
34  virtual void setWorldMatrix( const QTransform & );
35  virtual const QTransform worldMatrix();
36  virtual void translate( double, double );
37  virtual void rotate( double );
38  virtual void scale( double, double );
39 
40  // drawing
41  virtual void moveTo( const double &, const double & );
42  virtual void lineTo( const double &, const double & );
43  virtual void curveTo( FPoint p1, FPoint p2, FPoint p3 );
44  virtual void newPath();
45  virtual void closePath();
46  virtual void fillPath();
47  virtual void strokePath();
48  virtual void setFillRule( bool fillRule );
49  virtual bool fillRule() { return m_fillRule; }
50  virtual void setFillMode( int fill );
51  virtual int fillMode() { return m_fillMode; }
52  virtual void setStrokeMode( int fill );
53  virtual int strokeMode() { return m_strokeMode; }
54  virtual void setGradient( VGradientEx::Type mode, FPoint orig, FPoint vec, FPoint foc, double scale, double skew);
55  virtual void setPattern(ScPattern *pattern, double scaleX, double scaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, bool mirrorX, bool mirrorY);
56 
57  virtual void setMaskMode( int mask );
58  virtual void setGradientMask(VGradientEx::Type mode, FPoint orig, FPoint vec, FPoint foc, double scale, double skew);
59  virtual void setPatternMask(ScPattern *pattern, double scaleX, double scaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, bool mirrorX, bool mirrorY);
60 
61  virtual void set4ColorGeometry(FPoint p1, FPoint p2, FPoint p3, FPoint p4, FPoint c1, FPoint c2, FPoint c3, FPoint c4);
62  virtual void set4ColorColors(const ScColorShade& col1, const ScColorShade& col2, const ScColorShade& col3, const ScColorShade& col4);
63  virtual void setDiamondGeometry(FPoint p1, FPoint p2, FPoint p3, FPoint p4, FPoint c1, FPoint c2, FPoint c3, FPoint c4, FPoint c5);
64  virtual void setMeshGradient(FPoint p1, FPoint p2, FPoint p3, FPoint p4, QList<QList<meshPoint> > meshArray);
65  virtual void setMeshGradient(FPoint p1, FPoint p2, FPoint p3, FPoint p4, QList<meshGradientPatch> meshPatches);
66 
67  virtual void setClipPath();
68 
69  virtual void drawImage( ScImage *image, ScPainterExBase::ImageMode mode );
70  virtual void setupPolygon(FPointArray *points, bool closed = true);
71  virtual void drawPolygon();
72  virtual void drawPolyLine();
73  virtual void drawLine(FPoint start, FPoint end);
74  virtual void drawRect(double, double, double, double);
75 
76  // pen + brush
77  virtual ScColorShade pen();
78  virtual ScColorShade brush();
79  virtual void setPen( const ScColorShade & );
80  virtual void setPen( const ScColorShade &c, double w, Qt::PenStyle st, Qt::PenCapStyle ca, Qt::PenJoinStyle jo );
81  virtual void setPenOpacity( double op );
82  virtual void setLineWidth( double w);
83  virtual void setDash(const QVector<double>& array, double ofs);
84  virtual void setBrush( const ScColorShade & );
85  virtual void setBrushOpacity( double op );
86  virtual void setOpacity( double op );
87  virtual void setFont( const QFont &f );
88  virtual QFont font();
89 
90  // stack management
91  virtual void save();
92  virtual void restore();
93 
94  virtual void setRasterOp( int op );
95  virtual void setBlendModeFill( int blendMode );
96  virtual void setBlendModeStroke( int blendMode );
97 
98 private:
99  void fillPathHelper();
100  void strokePathHelper();
101 
102  void drawGradient( VGradientEx& gradient );
103  void drawLinearGradient( VGradientEx& gradient, const QRect& rect );
104  void drawCircularGradient( VGradientEx& gradient, const QRect& rect );
105  void drawFourColorGradient( const QRect& rect );
106  void drawDiamondGradient( VGradientEx& gradient, const QRect& rect );
107  void drawMeshGradient( const QRect& rect );
108  void drawFreeMeshGradient( const QRect& rect );
109 
110  void strokeGradient( VGradientEx& gradient );
111  void strokeLinearGradient( VGradientEx& gradient );
112  void strokeCircularGradient( VGradientEx& gradient );
113 
114  void getClipPathDimensions( QRect& r );
115 
116  ScribusDoc* m_doc;
117 
118  unsigned int m_width;
119  unsigned int m_height;
120  QTransform m_matrix;
121  QFont m_font;
122 /* Layer blend mode*/
123  int m_blendModeLayer;
124  int m_blendModeFill;
125  int m_blendModeStroke;
126 /* Filling */
127  ScColorShade m_fillColor;
128  double m_fillTrans;
129  bool m_fillRule;
130  int m_fillMode; // 0 = none, 1 = solid, 2 = gradient
131  int m_gradientMode; // 1 = linear, 2 = radial
132 
133  double m_patternScaleX;
134  double m_patternScaleY;
135  double m_patternOffsetX;
136  double m_patternOffsetY;
137  double m_patternRotation;
138  double m_patternSkewX;
139  double m_patternSkewY;
140  bool m_patternMirrorX;
141  bool m_patternMirrorY;
142 
143  FPoint m_gradPatchP1;
144  FPoint m_gradPatchP2;
145  FPoint m_gradPatchP3;
146  FPoint m_gradPatchP4;
147  FPoint m_gradControlP1;
148  FPoint m_gradControlP2;
149  FPoint m_gradControlP3;
150  FPoint m_gradControlP4;
151  FPoint m_gradControlP5;
152  ScColorShade m_gradPatchColor1;
153  ScColorShade m_gradPatchColor2;
154  ScColorShade m_gradPatchColor3;
155  ScColorShade m_gradPatchColor4;
156  QList<QList<meshPoint> > m_meshGradientArray;
157  QList<meshGradientPatch> m_meshGradientPatches;
158 
159  double m_gradientScale;
160  double m_gradientSkew;
161 /* Stroking */
162  ScColorShade m_strokeColor;
163  double m_strokeTrans;
164  double m_lineWidth;
165  int m_strokeMode; // 0 = none, 1 = solid, 2 = gradient 3 = pattern
166 /* Masking */
167  int m_maskMode; // 0 = none, 1 = gradient 2 = pattern
168  double m_maskPatternScaleX;
169  double m_maskPatternScaleY;
170  double m_maskPatternOffsetX;
171  double m_maskPatternOffsetY;
172  double m_maskPatternRotation;
173  double m_maskPatternSkewX;
174  double m_maskPatternSkewY;
175  bool m_maskPatternMirrorX;
176  bool m_maskPatternMirrorY;
177  double m_maskGradientScale;
178  double m_maskGradientSkew;
179 
180 /* Grayscale conversion option */
181  bool m_convertToGray;
182 
183 /* Line End Style */
184  Qt::PenCapStyle m_lineEnd;
185 /* Line Join Style */
186  Qt::PenJoinStyle m_lineJoin;
187 /* The Dash Array */
188  QVector<double> m_array;
189  double m_offset;
190 /* Transformation Stack */
191  QStack<QTransform> m_stack;
192 
193 /* Cairo context */
194  cairo_t* m_cr;
195 
196 /* Color conversion function */
197  QColor transformColor( ScColorShade& colorShade, double trans );
198  void transformImage( QImage& image );
199 
200  QStack<int> m_gStates;
201  double m_positionX;
202  double m_positionY;
203 };
204 
205 #endif
Definition: scpainterex_cairo.h:16
Definition: sccolorshade.h:29
Definition: scpattern.h:36
Definition: scimage.h:36
A point with floating point precision.
Definition: fpoint.h:43
the Document Class
Definition: scribusdoc.h:90
Definition: vgradientex.h:80
Definition: scpainterexbase.h:50
Definition: fpointarray.h:42