ai_epsrr.h

Go to the documentation of this file.
00001 // $Id: ai_epsrr.h 1336 2006-06-17 16:18:41Z alex $
00002 // Declaration of Adobe Illustrator EPS render region.
00003 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00004 ================================XARAHEADERSTART===========================
00005  
00006                Xara LX, a vector drawing and manipulation program.
00007                     Copyright (C) 1993-2006 Xara Group Ltd.
00008        Copyright on certain contributions may be held in joint with their
00009               respective authors. See AUTHORS file for details.
00010 
00011 LICENSE TO USE AND MODIFY SOFTWARE
00012 ----------------------------------
00013 
00014 This file is part of Xara LX.
00015 
00016 Xara LX is free software; you can redistribute it and/or modify it
00017 under the terms of the GNU General Public License version 2 as published
00018 by the Free Software Foundation.
00019 
00020 Xara LX and its component source files are distributed in the hope
00021 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00022 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00023 See the GNU General Public License for more details.
00024 
00025 You should have received a copy of the GNU General Public License along
00026 with Xara LX (see the file GPL in the root directory of the
00027 distribution); if not, write to the Free Software Foundation, Inc., 51
00028 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00029 
00030 
00031 ADDITIONAL RIGHTS
00032 -----------------
00033 
00034 Conditional upon your continuing compliance with the GNU General Public
00035 License described above, Xara Group Ltd grants to you certain additional
00036 rights. 
00037 
00038 The additional rights are to use, modify, and distribute the software
00039 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00040 library and any other such library that any version of Xara LX relased
00041 by Xara Group Ltd requires in order to compile and execute, including
00042 the static linking of that library to XaraLX. In the case of the
00043 "CDraw" library, you may satisfy obligation under the GNU General Public
00044 License to provide source code by providing a binary copy of the library
00045 concerned and a copy of the license accompanying it.
00046 
00047 Nothing in this section restricts any of the rights you have under
00048 the GNU General Public License.
00049 
00050 
00051 SCOPE OF LICENSE
00052 ----------------
00053 
00054 This license applies to this program (XaraLX) and its constituent source
00055 files only, and does not necessarily apply to other Xara products which may
00056 in part share the same code base, and are subject to their own licensing
00057 terms.
00058 
00059 This license does not apply to files in the wxXtra directory, which
00060 are built into a separate library, and are subject to the wxWindows
00061 license contained within that directory in the file "WXXTRA-LICENSE".
00062 
00063 This license does not apply to the binary libraries (if any) within
00064 the "libs" directory, which are subject to a separate license contained
00065 within that directory in the file "LIBS-LICENSE".
00066 
00067 
00068 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00069 ----------------------------------------------
00070 
00071 Subject to the terms of the GNU Public License (see above), you are
00072 free to do whatever you like with your modifications. However, you may
00073 (at your option) wish contribute them to Xara's source tree. You can
00074 find details of how to do this at:
00075   http://www.xaraxtreme.org/developers/
00076 
00077 Prior to contributing your modifications, you will need to complete our
00078 contributor agreement. This can be found at:
00079   http://www.xaraxtreme.org/developers/contribute/
00080 
00081 Please note that Xara will not accept modifications which modify any of
00082 the text between the start and end of this header (marked
00083 XARAHEADERSTART and XARAHEADEREND).
00084 
00085 
00086 MARKS
00087 -----
00088 
00089 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00090 designs are registered or unregistered trademarks, design-marks, and/or
00091 service marks of Xara Group Ltd. All rights in these marks are reserved.
00092 
00093 
00094       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00095                         http://www.xara.com/
00096 
00097 =================================XARAHEADEREND============================
00098  */
00099 
00100 #ifndef INC_AI_EPS_RENDER_REGION
00101 #define INC_AI_EPS_RENDER_REGION
00102 
00103 #include "saveeps.h"
00104 
00105 class NodeBevel;
00106 
00107 // Constants.
00108 const TCHAR LinearGradient []   = _T("Linear Gradient");
00109 const TCHAR RadialGradient []   = _T("Radial Gradient");
00110 const INT32 LinearFill          = 0;
00111 const INT32 RadialFill          = 1;
00112 
00113 // number of intermediate steps to use when emulating short or long hsv fills (HSV fills
00114 //  are done by creating an ordinary RGB fill, but with intermediate colour stops to simulate
00115 //  the hue change).
00116 const INT32 NumFillEmulationSteps = 5;
00117 
00118 /********************************************************************************************
00119 
00120 >   class AIEPSGradientScanRenderRegion : public VectorFileRenderRegion
00121 
00122     Author:     Chris_Gallimore (Xara Group Ltd) <camelotdev@xara.com>
00123     Created:    5/2/2001
00124     Purpose:    RenderRegion used to scan through the tree, looking for gradient fills to be
00125                 cached for Illustrator export.
00126     SeeAlso:    AIEPSRenderRegion, 
00127 
00128 ********************************************************************************************/
00129 class AIEPSGradientScanRenderRegion : public VectorFileRenderRegion
00130 {
00131     CC_DECLARE_DYNAMIC (AIEPSGradientScanRenderRegion)
00132 
00133 protected:
00134 
00135     RenderRegion * m_pController;
00136 
00137 public:
00138 
00139     AIEPSGradientScanRenderRegion (RenderRegion * pControllingRegion);
00140 
00141     RenderRegion * GetControllingRegion () {return m_pController;}
00142     void SetControllingRegion (RenderRegion * pControllingRegion);
00143 
00144     virtual void DrawPathToOutputDevice(Path *PathToRender, PathShape shapePath=PATHSHAPE_PATH);
00145 
00146     virtual BOOL StopRender() {return FALSE;};
00147     virtual void DrawRect(DocRect *RectToRender) {};
00148     virtual void DrawDragRect(DocRect *RectToRender) {};
00149     virtual void DrawLine(const DocCoord &StartPoint, const DocCoord &EndPoint) {};
00150     virtual void DrawPixel(const DocCoord &Point) {};
00151     virtual void DrawBlob(DocCoord p, BlobType type) {};
00152     virtual void DrawCross(const DocCoord &Point, const UINT32 Size) {};
00153 
00154     virtual void DrawBitmap(const DocCoord &Point, KernelBitmap* pBitmap) {};
00155     virtual void DrawBitmap(const DocCoord &Point, UINT32 BitmapID, UINT32 ToolID = NULL) {};
00156     virtual void DrawBitmapBlob(const DocCoord &Point, KernelBitmap* BlobShape) {};
00157     virtual void DrawBitmapBlob(const DocCoord &Point, ResourceID resID ) {};
00158 
00159     virtual void InitClipping() {};
00160     virtual void InitAttributes() {};
00161 
00162     virtual void SetOSDrawingMode() {};
00163     virtual MILLIPOINT CalcPixelWidth() {return MILLIPOINT (1);};
00164     virtual MILLIPOINT CalcScaledPixelWidth() {return MILLIPOINT (1);};
00165 };
00166 
00167 
00168 
00169 /********************************************************************************************
00170 
00171 >   class ListFill : public CCObject
00172 
00173     Author:     Chris_Gallimore (Xara Group Ltd) <camelotdev@xara.com>
00174     Created:    30/3/2001
00175     Purpose:    Relatively generic Gradient Fill holder class, so that gradient fills can 
00176                 be stored in a linked list (mainly used while scanning for grad fills)
00177     SeeAlso:    AIEPSRenderRegion, AIEPSGradientScanRenderRegion
00178 
00179 ********************************************************************************************/
00180 class ListFill : public CCObject
00181 {
00182     CC_DECLARE_DYNAMIC (ListFill);
00183 
00184 public:
00185 
00186     ListFill ();
00187     ListFill (FillGeometryAttribute * pNewFill);
00188     ListFill (FillGeometryAttribute * pNewFill, EFFECTTYPE eff, ListFill * pNewNext);
00189     ~ListFill ();
00190 
00191     FillGeometryAttribute * pFill;
00192     EFFECTTYPE effect;
00193     ListFill * pNext;
00194     INT32 id;
00195 };
00196 
00197 /********************************************************************************************
00198 
00199 >   class AIEPSRenderRegion : public EPSRenderRegion
00200 
00201     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>, extended by Graeme
00202     Created:    08/03/94
00203     Purpose:    A render region for exporting EPS files in Adobe Illustrator 7.0 EPS format.
00204     SeeAlso:    EPSRenderRegion
00205 
00206 ********************************************************************************************/
00207 class AIEPSRenderRegion : public EPSRenderRegion
00208 {
00209 friend class AIEPSGradientScanRenderRegion;
00210 
00211     CC_DECLARE_DYNAMIC (AIEPSRenderRegion)
00212     
00213 public:
00214     AIEPSRenderRegion (DocRect ClipRect, Matrix ConvertMatrix, FIXED16 ViewScale);
00215     ~AIEPSRenderRegion ();
00216 
00217     // Export methods for dealing with out of the ordinary classes.
00218     BOOL ExportBitmap ( NodeBitmap  *pNodeBMP );        // Write a bitmap definition.
00219     BOOL ExportBevel  ( NodeBevel   *pBevel );          // Write a bevel definition.
00220     BOOL ExportShadow ( OILBitmap   *pBitmap,           // Write a shadow to the file.
00221                         UINT32      Darkness,
00222                         DocRect     &Bounds );
00223     BOOL ExportLayer  ( Layer       *pLayer );          // Write a layer to the file.
00224     BOOL StartLayer   ( Layer       *pLayer );          // Start writing a layer definition.
00225 
00226     virtual BOOL RenderChar   (WCHAR ch, Matrix* pMatrix);      // Write out a single character.
00227 
00228     BOOL ExportingOnPath ();                        // Whether we're exporting text on a path
00229 
00230     virtual void OverflowTextStart ();              // Start a block of overflow text
00231     virtual void OverflowTextFinish ();             // Finish a block of overflow text
00232 
00233     // Mask control functions.
00234     BOOL WriteMask ( Path *MaskPath, BOOL OutputGroupToken = FALSE );
00235 
00237     //  ChrisG 8/11/2000
00238     //  Implementation of clipping within an EPSRenderRegion.
00239     virtual void SetClipRegion      (ClipRegionAttribute * pClipAttr, BOOL Temp);
00240     virtual void RestoreClipRegion  (ClipRegionAttribute * pClipAttr, BOOL Temp);
00242 
00243     // ChrisG 8/11/00 used make all text printed out as shapes (TRUE), or characters (FALSE)
00244     virtual void SetTextAsShapes (BOOL shapes);
00245     virtual BOOL GetTextAsShapes ();
00246 
00247     virtual BOOL IsGradientFillValidForExport (FillGeometryAttribute * pFill);
00248     virtual void IncludeGradientFill (FillGeometryAttribute * pFill, EFFECTTYPE effect);
00249 
00250 protected:
00251     // Class-specific initialisation code.
00252     virtual void Initialise ();
00253     
00254     // Virtual functions to export document information for AI files.
00255     virtual BOOL WriteEPSVersion ();
00256     virtual BOOL WriteEPSProcessColours ();
00257     virtual BOOL WriteEPSResources ( EPSFilter  *pFilter,
00258                                      Document   *pDocument );
00259     virtual BOOL WriteEPSProlog ( EPSFilter *pFilter,
00260                                   Document  *pDocument );
00261 
00262     virtual void OutputFillColour ( void );
00263                                       
00264     // Extract the gradient fills from the tree, and save them to file.
00265     virtual BOOL WriteGradientFills ( Document *pDocument );
00266 
00267     // Determine whether or not to write the font definitions to file.
00268     virtual BOOL WriteDocumentSetup ( Document  *pDocument,
00269                                       EPSFilter *pFilter );
00270 
00271     virtual BOOL EndLayer ( void );
00272 
00273     // These Output functions output any additional information that the 
00274     //  Illustrator EPS export needs before calling the base EPS output.
00275     virtual void OutputWindingRule ();
00276 
00277     virtual void OutputStrokeColour ();
00278     virtual void OutputLineWidth ();
00279     virtual void OutputJoinType ();
00280     virtual void OutputDashPattern ();
00281     virtual void OutputStartCap ();
00282     virtual void OutputMitreLimit ();
00283     
00284     virtual void OutputFontName ();
00285 
00286     virtual void OutputTextRenderMode ();
00287     virtual void OutputTextAspectRatio ();
00288     virtual void OutputTextTracking ();
00289     virtual void OutputTextJustification ();
00290     virtual void OutputTextLineSpacing ();
00291     virtual void OutputTextBaselineShift ();
00292     virtual void OutputTextSubSuperScript ();
00293 
00294     virtual void OutputFillRGBColour ();
00295     virtual void OutputFillCMYKColour ();
00296     virtual void OutputStrokeRGBColour ();
00297     virtual void OutputStrokeCMYKColour ();
00298 
00299     // These OverflowText functions are used to control the output of overflow text 
00300     //  (TX) to the EPS file.
00301 
00302     virtual void OverflowTextStartGap ();
00303     virtual void OverflowTextFinishGap ();
00304     virtual void OverflowTextWrite (TCHAR * text);
00305     virtual void OverflowTextWriteSingleColour (UINT32 n);
00306     virtual void OverflowTextWriteColour (PColourCMYK*);
00307     virtual void OverflowTextWriteNamedColour (DocColour*, ColourContext* pContext=NULL);
00308     virtual void OverflowTextWriteColourName (DocColour* pCol);
00309 
00310     // (Chris G 8/11/00) - added so that gradient-filled text can be exported as shapes.
00311     virtual BOOL RenderCharAsShape (WCHAR ch, Matrix* pMatrix);
00312 
00313     // (Chris G 9/11/00) - added to stop new line characters from being exported when text
00314     //  is exported as shapes.
00315     virtual BOOL WriteNewLine ( void );
00316 
00317 private:
00318     // Functions for writing gradients out.
00319     virtual void BuildGradientCache (Node * pStartNode);
00320     virtual void BuildGradientCacheUsingScanner (Node * pNode, AIEPSGradientScanRenderRegion * pScan);
00321     virtual void WriteGradientCount ();
00322     virtual void WriteGradientDefinitions ();
00323     virtual void ClearGradientCache ();
00324     virtual INT32 FindGradientInCache (FillGeometryAttribute * pFill, EFFECTTYPE effect);
00325 
00326     BOOL WriteLinearFill ( FillGeometryAttribute * pFill, EFFECTTYPE effect, INT32 id);
00327     BOOL WriteRadialFill ( FillGeometryAttribute * pFill, EFFECTTYPE effect, INT32 id);
00328     virtual void WriteGradientFillInstance ();
00329     BOOL WriteGradientEntry ( DocColour *pColour,
00330                               INT32     Position,
00331                               INT32     Midpoint );
00332     BOOL WriteFillEffectSteps ( DocColour *pColour1,
00333                                 INT32 pos1, 
00334                                 DocColour *pColour2, 
00335                                 INT32 pos2, 
00336                                 INT32 bias, 
00337                                 EFFECTTYPE effect);
00338     
00339     // Matrix write and store functions.
00340     BOOL LoadBitmapMatrix ( NodeBitmap  *pNodeBMP );
00341     BOOL LoadTranslationMatrix ( DocCoord &Translation );
00342     BOOL WriteLoadedMatrix ( void );
00343 
00344     BOOL WriteMaskTags ( void );
00345 
00346     // Bitmap handling functions.
00347     BOOL WriteBitmapRecord  ( OILBitmap *pBitmap );
00348     BOOL WriteBitmapHeader  ( INT32 Width,
00349                               INT32 Height );
00350     BOOL WriteBitmapBody    ( OILBitmap *pBitmap,
00351                               INT32     Width,
00352                               INT32     Height );
00353     BOOL WriteContoneBody   ( OILBitmap *pBitmap );
00354     BOOL WriteBitmapTail    ( void );
00355 
00356     // Member variables.
00357     ListFill *  m_pLinearGradList;  // The linear gradient fill cache
00358     ListFill *  m_pRadialGradList;  // The radial gradient fill cache
00359 
00360     double      m_a;                // Transformation matrix component.
00361     double      m_b;                // Transformation matrix component.
00362     double      m_c;                // Transformation matrix component.
00363     double      m_d;                // Transformation matrix component.
00364     DocCoord    m_T;                // Transformation matrix component.
00365 
00366     BOOL        m_ActiveLayer;      // Is there a layer being exported right now?
00367     UINT32      m_LayerColour;      // Colour code used to ID a layer.
00368 
00369     FILE *      m_fpOverflowText;   // File to write the extra info to  ( for the overflow (TX) )
00370     BOOL        m_bInTextGap;       // If we're setting attributes      ( part of a text block  )
00371     BOOL        m_bTextAsShapes;    // we're going to draw text as shapes (i.e. it's gradient filled.
00372 
00373 };
00374 
00375 #endif

Generated on Sat Nov 10 03:44:08 2007 for Camelot by  doxygen 1.4.4