Scribus Developer Documentation - API
logo-pen

Scribus Developer Documentation - API

scpainterex_ps2.h

Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 /* This file is part of the KDE project
00008    Copyright (C) 2001, 2002, 2003 The Karbon Developers
00009 
00010    This library is free software; you can redistribute it and/or
00011    modify it under the terms of the GNU Library General Public
00012    License as published by the Free Software Foundation; either
00013    version 2 of the License, or (at your option) any later version.
00014 
00015    This library is distributed in the hope that it will be useful,
00016    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018    Library General Public License for more details.
00019 
00020    You should have received a copy of the GNU Library General Public License
00021    along with this library; see the file COPYING.LIB.  If not, write to
00022    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00023    Boston, MA 02111-1307, USA.
00024 */
00025 /* Adapted for Scribus 22.08.2003 by Franz Schmid */
00026 /* Adapted for Scribus 15.01.2006 by Jean Ghali */
00027 
00028 #ifndef __SCPAINTEREX_PS2_H__
00029 #define __SCPAINTEREX_PS2_H__
00030 
00031 // libart wrapper
00032 
00033 #include <QGlobalStatic>
00034 #include <QColor>
00035 #include <QFont>
00036 #include <QMatrix>
00037 #include <QList>
00038 #include <QPixmap>
00039 #include <QStack>
00040 #include <QTextStream>
00041 
00042 #include "scribusapi.h"
00043 #include "scconfig.h"
00044 #include "fpoint.h"
00045 #include "fpointarray.h"
00046 #include "vgradient.h"
00047 
00048 #include "scpainterexbase.h"
00049 #include CMS_INC
00050 
00051 class ScribusDoc;
00052 
00053 class ScPs2OutputParams
00054 {
00055 public:
00056     ScPs2OutputParams(ScribusDoc* doc = NULL);
00057     ScPainterExBase::ColorMode colorMode;
00058     ScribusDoc* document;
00059     bool reloadImages;
00060     int resolution;
00061     bool useProfiles;
00062     bool toGray;
00063     bool mirrorH;
00064     bool mirrorV;
00065     QString outputProfile;
00066     cmsHPROFILE   hProfile;
00067     cmsHTRANSFORM rgbToOutputColorTransform;
00068     cmsHTRANSFORM rgbToOutputImageTransform;
00069     cmsHTRANSFORM cmykToOutputColorTransform;
00070     cmsHTRANSFORM cmykToOutputImageTransform;
00071 };
00072 
00073 class SCRIBUS_API ScPainterEx_Ps2 : public ScPainterExBase
00074 {
00075 public:
00076 
00077     ScPainterEx_Ps2( QIODevice* iodev, QRect& rect, ScPs2OutputParams& options );
00078     virtual ~ScPainterEx_Ps2();
00079 
00080     virtual int supportedColorModes() { return (int) (rgbMode|cmykMode); }
00081     virtual ColorMode preferredColorMode() { return m_colorMode; }
00082     virtual void setPreferredColorMode(ScPainterEx_Ps2::ColorMode colorMode) { m_colorMode = colorMode; }
00083     virtual ImageMode imageMode();
00084 
00085     virtual void begin();
00086     virtual void end();
00087     virtual void clear();
00088     virtual void clear( ScColorShade & );
00089 
00090     // matrix manipulation
00091     virtual void setWorldMatrix( const QMatrix & );
00092     virtual const QMatrix worldMatrix();
00093     virtual void translate( double, double );
00094     virtual void rotate( double );
00095     virtual void scale( double, double );
00096 
00097     // drawing
00098     virtual void moveTo( const double &, const double & );
00099     virtual void lineTo( const double &, const double & );
00100     virtual void curveTo( FPoint p1, FPoint p2, FPoint p3 );
00101     virtual void newPath();
00102     virtual void closePath();
00103     virtual void fillTextPath();
00104     virtual void strokeTextPath();
00105     virtual void fillPath();
00106     virtual void strokePath();
00107     virtual void setFillRule( bool fillRule );
00108     virtual bool fillRule() { return m_fillRule; }
00109     virtual void setFillMode( int fill );
00110     virtual int  fillMode() { return m_fillMode; }
00111     virtual void setGradient( VGradientEx::Type mode, FPoint orig, FPoint vec, FPoint foc = FPoint(0,0));
00112     virtual void setPattern ( ScPattern* pattern, QMatrix& patternTransform );
00113     virtual void setClipPath();
00114 
00115     virtual void drawImage( ScImage *image, ScPainterExBase::ImageMode mode );
00116     virtual void drawRGBImage_ps2( ScImage *image );
00117     virtual void drawCMYKImage_ps2( ScImage *image );
00118 
00119     virtual bool hasAlphaChannel( ScImage* image );
00120 
00121     virtual void setupPolygon(FPointArray *points, bool closed = true);
00122     virtual void setupTextPolygon(FPointArray *points);
00123     virtual void drawPolygon();
00124     virtual void drawPolyLine();
00125     virtual void drawLine(FPoint start, FPoint end);
00126     virtual void drawRect(double, double, double, double);
00127 
00128     // pen + brush
00129     virtual ScColorShade pen();
00130     virtual ScColorShade brush();
00131     virtual void setPen( const ScColorShade & );
00132     virtual void setPen( const ScColorShade &c, double w, Qt::PenStyle st, Qt::PenCapStyle ca, Qt::PenJoinStyle jo );
00133     virtual void setPenOpacity( double op );
00134     virtual void setLineWidth( double w);
00135     virtual void setDash(const QList<double>& array, double ofs);
00136     virtual void setBrush( const ScColorShade & );
00137     virtual void setBrushOpacity( double op );
00138     virtual void setOpacity( double op );
00139     virtual void setFont( const QFont &f );
00140     virtual QFont font();
00141 
00142     // stack management
00143     virtual void save();
00144     virtual void restore();
00145 
00146     virtual void setRasterOp( int op );
00147 
00148 protected:
00149 
00150     virtual void writeRGBImageToStream_Ascii85 ( ScImage* image );
00151     virtual void writeRGBImageToStream_AsciiHex ( ScImage* image );
00152     virtual void writeCMYKImageToStream_Ascii85( ScImage* image );
00153     virtual void writeCMYKImageToStream_AsciiHex( ScImage* image );
00154     virtual void writeMaskToStream ( QImage* image ); 
00155 
00156 private:
00157 
00158     typedef enum {
00159         Ascii85Encoding,
00160         AsciiHexEncoding
00161     } AsciiEncoding;
00162 
00163     /* Output stream */
00164     QTextStream   m_stream;
00165     ColorMode     m_colorMode;
00166     AsciiEncoding m_encoding; 
00167 
00168     /* Path bounding boxes*/
00169     QRect m_pathBBox;
00170     QRect m_clipBBox;
00171 
00172     /* General output options */
00173     ScPs2OutputParams m_options;
00174 
00175     /* Basic drawing functions*/
00176     void drawVPath( int mode );
00177     void drawGradient( VGradientEx& gradient );
00178     void drawLinearGradient( VGradientEx& gradient, const QRect& rect );
00179     void drawLinearGradient_RGB( VGradientEx& gradient, const QRect& rect );
00180     void drawLinearGradient_CMYK( VGradientEx& gradient, const QRect& rect );
00181     void drawCircularGradient( VGradientEx& gradient, const QRect& rect );
00182     void drawCircularGradient_RGB( VGradientEx& gradient, const QRect& rect );
00183     void drawCircularGradient_CMYK( VGradientEx& gradient, const QRect& rect );
00184     void getPathBoundingBox( FPointArray* points, QRect& r );
00185     void transformPoint( const FPoint& in, FPoint& out );
00186     void transformPoints( const FPoint* in, FPoint* out, uint length );
00187 
00188     void putColor( ScColorShade& colorShade, bool doFill );
00189 
00190     unsigned int m_width;
00191     unsigned int m_height;
00192     unsigned int m_x;
00193     unsigned int m_y;
00194     QMatrix m_pageTrans;
00195     QMatrix m_matrix;
00196     QFont m_font;
00197 /* Filling */
00198     ScColorShade m_fillColor;
00199     double m_fillTrans;
00200     bool   m_fillRule;
00201     int    m_fillMode;          // 0 = none, 1 = solid, 2 = gradient
00202     int    m_gradientMode;      // 1 = linear, 2 = radial
00203 /* Stroking */
00204     ScColorShade m_strokeColor;
00205     double m_strokeTrans;
00206     double m_lineWidth;
00207 
00208 /* Line End Style */
00209     Qt::PenCapStyle m_lineEnd;
00210 /* Line Join Style */
00211     Qt::PenJoinStyle m_lineJoin;
00212 /* The Dash Array */
00213     QList<double> m_array;
00214     double m_offset;
00215 /* Transformation Stack */
00216     QStack<QMatrix> m_stack;
00217 /* Zoom Factor of the Painter */
00218     double m_zoomFactor;
00219 
00220 /* Some data to describe state of drawing */    
00221     bool m_pathIsClosed;
00222     bool m_drawingClosedPath;
00223 /* Drawing surface dimensions */
00224     double m_deviceDimX;
00225     double m_deviceDimY;
00226 /* Device resolutions */
00227     double m_deviceResX;
00228     double m_deviceResY;
00229 
00230 /* Color conversion function */
00231     void   transformImage( QImage* image, uchar* data, int scan);
00232 };
00233 
00234 #endif
Created with personalized Doxygen. This is documentation for GPL software Scribus - Open Source Desktop Publishing.