Scribus
Open source desktop publishing at your fingertips
scpainterex_ps2.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 /* This file is part of the KDE project
8  Copyright (C) 2001, 2002, 2003 The Karbon Developers
9 
10  This library is free software; you can redistribute it and/or
11  modify it under the terms of the GNU Library General Public
12  License as published by the Free Software Foundation; either
13  version 2 of the License, or (at your option) any later version.
14 
15  This library is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Library General Public License for more details.
19 
20  You should have received a copy of the GNU Library General Public License
21  along with this library; see the file COPYING.LIB. If not, write to
22  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23  Boston, MA 02110-1301, USA.
24 */
25 /* Adapted for Scribus 22.08.2003 by Franz Schmid */
26 /* Adapted for Scribus 15.01.2006 by Jean Ghali */
27 
28 #ifndef __SCPAINTEREX_PS2_H__
29 #define __SCPAINTEREX_PS2_H__
30 
31 // libart wrapper
32 
33 #include <QGlobalStatic>
34 #include <QColor>
35 #include <QFont>
36 #include <QTransform>
37 #include <QList>
38 #include <QPixmap>
39 #include <QStack>
40 #include <QTextStream>
41 
42 #include "scribusapi.h"
43 #include "scconfig.h"
44 #include "colormgmt/sccolormgmtengine.h"
45 #include "fpoint.h"
46 #include "fpointarray.h"
47 #include "vgradient.h"
48 #include "scpainterexbase.h"
49 
50 class ScribusDoc;
51 
53 {
54 public:
55  ScPs2OutputParams(ScribusDoc* doc = NULL);
56  ScPainterExBase::ColorMode colorMode;
57  ScribusDoc* document;
58  bool reloadImages;
59  int resolution;
60  bool useProfiles;
61  bool toGray;
62  bool mirrorH;
63  bool mirrorV;
64  QString outputProfile;
65  ScColorProfile hProfile;
66  ScColorTransform rgbToOutputColorTransform;
67  ScColorTransform rgbToOutputImageTransform;
68  ScColorTransform cmykToOutputColorTransform;
69  ScColorTransform cmykToOutputImageTransform;
70 };
71 
72 class SCRIBUS_API ScPainterEx_Ps2 : public ScPainterExBase
73 {
74 public:
75 
76  ScPainterEx_Ps2( QIODevice* iodev, QRect& rect, ScPs2OutputParams& options );
77  virtual ~ScPainterEx_Ps2();
78 
79  virtual int supportedColorModes() { return (int) (rgbMode|cmykMode); }
80  virtual ColorMode preferredColorMode() { return m_colorMode; }
81  virtual void setPreferredColorMode(ScPainterEx_Ps2::ColorMode colorMode) { m_colorMode = colorMode; }
82  virtual ImageMode imageMode();
83 
84  virtual void begin();
85  virtual void end();
86  virtual void clear();
87  virtual void clear( ScColorShade & );
88 
89  // matrix manipulation
90  virtual void setWorldMatrix( const QTransform & );
91  virtual const QTransform worldMatrix();
92  virtual void translate( double, double );
93  virtual void rotate( double );
94  virtual void scale( double, double );
95 
96  // drawing
97  virtual void moveTo( const double &, const double & );
98  virtual void lineTo( const double &, const double & );
99  virtual void curveTo( FPoint p1, FPoint p2, FPoint p3 );
100  virtual void newPath();
101  virtual void closePath();
102  virtual void fillPath();
103  virtual void strokePath();
104  virtual void setFillRule( bool fillRule );
105  virtual bool fillRule() { return m_fillRule; }
106  virtual void setFillMode( int fill );
107  virtual int fillMode() { return m_fillMode; }
108  virtual void setStrokeMode( int fill );
109  virtual int strokeMode() { return m_strokeMode; }
110  virtual void setGradient( VGradientEx::Type mode, FPoint orig, FPoint vec, FPoint foc, double scale, double skew);
111  virtual void setPattern(ScPattern *pattern, double scaleX, double scaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, bool mirrorX, bool mirrorY);
112 
113  virtual void setMaskMode( int mask ) {};
114  virtual void setGradientMask(VGradientEx::Type mode, FPoint orig, FPoint vec, FPoint foc, double scale, double skew) {};
115  virtual void setPatternMask(ScPattern *pattern, double scaleX, double scaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, bool mirrorX, bool mirrorY) {};
116 
117  virtual void set4ColorGeometry(FPoint p1, FPoint p2, FPoint p3, FPoint p4, FPoint c1, FPoint c2, FPoint c3, FPoint c4) {};
118  virtual void set4ColorColors(const ScColorShade& col1, const ScColorShade& col2, const ScColorShade& col3, const ScColorShade& col4) {};
119  virtual void setDiamondGeometry(FPoint p1, FPoint p2, FPoint p3, FPoint p4, FPoint c1, FPoint c2, FPoint c3, FPoint c4, FPoint c5) {};
120  virtual void setMeshGradient(FPoint p1, FPoint p2, FPoint p3, FPoint p4, QList<QList<meshPoint> > meshArray) {};
121  virtual void setMeshGradient(FPoint p1, FPoint p2, FPoint p3, FPoint p4, QList<meshGradientPatch> meshPatches) {};
122 
123  virtual void setClipPath();
124 
125  virtual void drawImage( ScImage *image, ScPainterExBase::ImageMode mode );
126  virtual void drawRGBImage_ps2( ScImage *image );
127  virtual void drawCMYKImage_ps2( ScImage *image );
128 
129  virtual bool hasAlphaChannel( ScImage* image );
130 
131  virtual void setupPolygon(FPointArray *points, bool closed = true);
132  virtual void drawPolygon();
133  virtual void drawPolyLine();
134  virtual void drawLine(FPoint start, FPoint end);
135  virtual void drawRect(double, double, double, double);
136 
137  // pen + brush
138  virtual ScColorShade pen();
139  virtual ScColorShade brush();
140  virtual void setPen( const ScColorShade & );
141  virtual void setPen( const ScColorShade &c, double w, Qt::PenStyle st, Qt::PenCapStyle ca, Qt::PenJoinStyle jo );
142  virtual void setPenOpacity( double op );
143  virtual void setLineWidth( double w);
144  virtual void setDash(const QVector<double>& array, double ofs);
145  virtual void setBrush( const ScColorShade & );
146  virtual void setBrushOpacity( double op );
147  virtual void setOpacity( double op );
148  virtual void setFont( const QFont &f );
149  virtual QFont font();
150 
151  // stack management
152  virtual void save();
153  virtual void restore();
154 
155  virtual void setRasterOp( int op );
156  virtual void setBlendModeFill( int blendMode ) {};
157  virtual void setBlendModeStroke( int blendMode ) {};
158 
159 protected:
160 
161  virtual void writeRGBImageToStream_Ascii85 ( ScImage* image );
162  virtual void writeRGBImageToStream_AsciiHex ( ScImage* image );
163  virtual void writeCMYKImageToStream_Ascii85( ScImage* image );
164  virtual void writeCMYKImageToStream_AsciiHex( ScImage* image );
165  virtual void writeMaskToStream ( QImage* image );
166 
167 private:
168 
169  typedef enum {
170  Ascii85Encoding,
171  AsciiHexEncoding
172  } AsciiEncoding;
173 
174  /* Output stream */
175  QTextStream m_stream;
176  ColorMode m_colorMode;
177  AsciiEncoding m_encoding;
178 
179  /* Path bounding boxes*/
180  QRect m_pathBBox;
181  QRect m_clipBBox;
182 
183  /* General output options */
184  ScPs2OutputParams m_options;
185 
186  /* Basic drawing functions*/
187  void drawVPath( int mode );
188  void drawGradient( VGradientEx& gradient );
189  void drawLinearGradient( VGradientEx& gradient, const QRect& rect );
190  void drawLinearGradient_RGB( VGradientEx& gradient, const QRect& rect );
191  void drawLinearGradient_CMYK( VGradientEx& gradient, const QRect& rect );
192  void drawCircularGradient( VGradientEx& gradient, const QRect& rect );
193  void drawCircularGradient_RGB( VGradientEx& gradient, const QRect& rect );
194  void drawCircularGradient_CMYK( VGradientEx& gradient, const QRect& rect );
195  void getPathBoundingBox( FPointArray* points, QRect& r );
196  void transformPoint( const FPoint& in, FPoint& out );
197  void transformPoints( const FPoint* in, FPoint* out, uint length );
198 
199  void putColor( ScColorShade& colorShade, bool doFill );
200 
201  unsigned int m_width;
202  unsigned int m_height;
203  unsigned int m_x;
204  unsigned int m_y;
205  QTransform m_pageTrans;
206  QTransform m_matrix;
207  QFont m_font;
208 /* Filling */
209  ScColorShade m_fillColor;
210  double m_fillTrans;
211  bool m_fillRule;
212  int m_fillMode; // 0 = none, 1 = solid, 2 = gradient
213 
214  double m_patternScaleX;
215  double m_patternScaleY;
216  double m_patternOffsetX;
217  double m_patternOffsetY;
218  double m_patternRotation;
219  double m_patternSkewX;
220  double m_patternSkewY;
221  bool m_patternMirrorX;
222  bool m_patternMirrorY;
223 
224 /* Stroking */
225  ScColorShade m_strokeColor;
226  double m_strokeTrans;
227  double m_lineWidth;
228  int m_strokeMode; // 0 = none, 1 = solid, 2 = gradient 3 = pattern
229 /* Line End Style */
230  Qt::PenCapStyle m_lineEnd;
231 /* Line Join Style */
232  Qt::PenJoinStyle m_lineJoin;
233 /* The Dash Array */
234  QVector<double> m_array;
235  double m_offset;
236 /* Transformation Stack */
237  QStack<QTransform> m_stack;
238 
239 /* Some data to describe state of drawing */
240  bool m_pathIsClosed;
241  bool m_drawingClosedPath;
242 /* Drawing surface dimensions */
243  double m_deviceDimX;
244  double m_deviceDimY;
245 /* Device resolutions */
246  double m_deviceResX;
247  double m_deviceResY;
248 
249 /* Color conversion function */
250  void transformImage( QImage* image, uchar* data, int scan);
251 };
252 
253 #endif
Definition: sccolorprofile.h:16
Definition: sccolorshade.h:29
Definition: sccolortransform.h:16
Definition: scpattern.h:36
Definition: scimage.h:36
A point with floating point precision.
Definition: fpoint.h:43
Definition: scpainterex_ps2.h:52
the Document Class
Definition: scribusdoc.h:90
Definition: vgradientex.h:80
Definition: scpainterexbase.h:50
Definition: fpointarray.h:42
Definition: scpainterex_ps2.h:72