AIEPSRenderRegion Class Reference

A render region for exporting EPS files in Adobe Illustrator 7.0 EPS format. More...

#include <ai_epsrr.h>

Inheritance diagram for AIEPSRenderRegion:

EPSRenderRegion VectorFileRenderRegion RenderRegion ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 AIEPSRenderRegion (DocRect ClipRect, Matrix ConvertMatrix, FIXED16 ViewScale)
 Create and initialise a render region for exporting AI EPS. Sets up the string to put in the %Creator comment.
 ~AIEPSRenderRegion ()
BOOL ExportBitmap (NodeBitmap *pNodeBMP)
 Kicks off the NodeBitmap export process..
BOOL ExportBevel (NodeBevel *pBevel)
 Renders a bevel into a DIB, and exports this as a bitmap to the AI file.
BOOL ExportShadow (OILBitmap *pBitmap, UINT32 Darkness, DocRect &Bounds)
 Renders a shadow into a DIB, and exports this as a bitmap to the AI file.
BOOL ExportLayer (Layer *pLayer)
 If there is an existing layer, it writes the end of layer tags, before creating a new layer record.
BOOL StartLayer (Layer *pLayer)
 Writes a layer record to the file.
virtual BOOL RenderChar (WCHAR ch, Matrix *pMatrix)
 Overrides the default behaviour for rendering a single character. Used to store additional information on text blocks needed for AI text. i.e. the overflow text block ((xxxxxxxxx) TX) which occurs after the unjustified ((x) Tx
(x) Tx
) block. Both of these are needed for correct Illustrator export of text.
BOOL ExportingOnPath ()
 To determine whether this text is being exported on a path.
virtual void OverflowTextStart ()
 Start the overflow text block.
virtual void OverflowTextFinish ()
 Finish the overflow text block and write both blocks to the actual EPS file.
BOOL WriteMask (Path *MaskPath, BOOL OutputGroupToken=FALSE)
 Creates a path that defines a masking pattern. All successive paths (until the end of mask operator) will be clipped to this shape.
virtual void SetClipRegion (ClipRegionAttribute *pClipAttr, BOOL Temp)
 The Adobe Illustrator version of Karim's EPSRenderRegion::SetClipRegion, This was needed as Illustrator uses non-standard EPS commands.
virtual void RestoreClipRegion (ClipRegionAttribute *pClipAttr, BOOL Temp)
 Adobe Illustrator version of Karim's EPSRenderRegion::RestoreClipRegion. See SetClipRegion for why this was necessary.
virtual void SetTextAsShapes (BOOL shapes)
 Sets the export TextAsShapes flag.
virtual BOOL GetTextAsShapes ()
 Sets the export TextAsShapes flag.
virtual BOOL IsGradientFillValidForExport (FillGeometryAttribute *pFill)
 Determines whether a particular fill can be used through the AI export See also: AIEPSRenderRegion::WriteGradientFills, AIEPSRenderRegion::WriteGradientUsage.
virtual void IncludeGradientFill (FillGeometryAttribute *pFill, EFFECTTYPE effect)
 Stores information about a fill so that the same fill isn't declared multiple times. See also: AIEPSRenderRegion::WriteGradientFills, AIEPSRenderRegion::WriteGradientUsage, AIEPSRenderRegion::FindGradientInCache.

Protected Member Functions

virtual void Initialise ()
 Sets up render region - it outputs the AIEPS file header comments, and intialises the rendering attributes.
virtual BOOL WriteEPSVersion ()
 Writes the relevant EPS version declaration.
virtual BOOL WriteEPSProcessColours ()
 Writes the colour type used to disk.
virtual BOOL WriteEPSResources (EPSFilter *pFilter, Document *pDocument)
 This function writes out the resource inclusion string required for the AI file.
virtual BOOL WriteEPSProlog (EPSFilter *pFilter, Document *pDocument)
 This method writes out the initialisation code for the included resources.
virtual void OutputFillColour (void)
 If the fill is a gradient fill, this method will invoke the WriteGradientFillInstance method, otherwise it will call the base EPSRenderRegion OutputFillColour method. This allows Camelot to support gradient fills in the AI file format.
virtual BOOL WriteGradientFills (Document *pDocument)
 Parses through the tree, identifies any gradient fills, and writes them to the export DC's file.
virtual BOOL WriteDocumentSetup (Document *pDocument, EPSFilter *pFilter)
 Browse through the tree, and if a text story is found invoke the document setup function. By only exporting the font setup when necessary, the file size produced is smaller (which makes it easier for me to interpret :) ), and it should hopefully make the filter run a bit faster too.
virtual BOOL EndLayer (void)
 If there is an existing layer, it writes the end of layer tags, before creating a new layer record.
virtual void OutputWindingRule ()
 Output the winding rule used to AI EPS.
virtual void OutputStrokeColour ()
 Output the current stroke colour. This function will use one of the following EPS tokens K - if not separating and colour is unnamed X - if not separating and colour is named G - if separating.
virtual void OutputLineWidth ()
 Output the standard line width token and measure for AI EPS.
virtual void OutputJoinType ()
 Output the standard AI EPS join type.
virtual void OutputDashPattern ()
 Outputs EPS dash pattern values. This function currently only exists so that extra handling can be easily achieved for Illustrator EPS export of dash patterns in the future (if need be).
virtual void OutputStartCap ()
 Output the start cap setting using the usual 'J' EPS token.
virtual void OutputMitreLimit ()
 Output the current mitre limit value using the usual 'M' EPS token. Again, this is only here so that the AI export can be easily expanded or modified.
virtual void OutputFontName ()
 Output an Illustrator format fontname and pointsize token. The format is /_fontname[-Bold|-Italic|-BoldItalic] pointsize Tf. EncodeFontName will generate this format from an internal fontname. DocodeFontName will return an internal format fontname and flags where nec.
virtual void OutputTextRenderMode ()
 Output the change in the text's Render Mode (Tr) - this happens when the text's fill or line colour changes to or from blank, see-through colour.
virtual void OutputTextAspectRatio ()
 Output the change in the text's aspect ratio (Tz).
virtual void OutputTextTracking ()
 Output the change in the tracking (Tt).
virtual void OutputTextJustification ()
 Output the change in the text justification (Ta).
virtual void OutputTextLineSpacing ()
 Output the change in the line spacing (Tl).
virtual void OutputTextBaselineShift ()
 Output the change in Baseline shift (Ts).
virtual void OutputTextSubSuperScript ()
 Output the change in the Sub/Super script attribute (Ts).
virtual void OutputFillRGBColour ()
 Writes additional info to the file for RGB fill colours See also: EPSRenderRegion::OutputFillRGBColour.
virtual void OutputFillCMYKColour ()
 Writes additional info to the file for CMYK fill colours See also: EPSRenderRegion::OutputFillCMYKColour.
virtual void OutputStrokeRGBColour ()
 Writes additional info to the file for RGB stroke colours See also: EPSRenderRegion::OutputStrokeRGBColour.
virtual void OutputStrokeCMYKColour ()
 Writes additional info to the file for CMYK fill colours See also: EPSRenderRegion::OutputFillCMYKColour.
virtual void OverflowTextStartGap ()
 Starts a new gap in the Overflow text, so that attributes can be written into the overflow blocks (the TX ones).
virtual void OverflowTextFinishGap ()
 Closes a gap for writing attributes in the overflow text, so that a new line of overflow text can be started.
virtual void OverflowTextWrite (TCHAR *text)
 Write some text to the overflow body file. This will store all the text and modified attributes for the TX text block.
virtual void OverflowTextWriteSingleColour (UINT32 n)
 Output a colour value to the overflow text file. A 'single colour' is a value as used in the Camelot 'Colour' class, i.e. in the range 0 to 255. This range is converted to the range 0.0 to 1.0, and output to the file.
virtual void OverflowTextWriteColour (PColourCMYK *)
 Output a colour, as expressed by the Camelot 'Colour' class. This function takes the CMYK variation, is this is most appropriate to EPS files. Camelot colour values are converted from the 0-255 range to the 0.0-1.0 range before being output.
virtual void OverflowTextWriteNamedColour (DocColour *, ColourContext *pContext=NULL)
 Similar to OutputColour(), except it outputs the colour name and tint of the colour as well. If pCol does not reference an indexed colour, then the name "NoName" is used.
virtual void OverflowTextWriteColourName (DocColour *pCol)
 Outputs a named colour's name as a string. If pCol does not reference an indexed colour, then the name "NoName" is used. This was seperated from OutputNamedColour so that the DeviceContext will not need to worry about which ColourModel to use (CMYK, RGB, etc...), as this will be determined by the RenderRegion.
virtual BOOL RenderCharAsShape (WCHAR ch, Matrix *pMatrix)
 Allows text to be drawn as shapes, not characters, so that AI can cope with gradient filled text.
virtual BOOL WriteNewLine (void)
 Writes a new line to the output of text if text is exported as characters, does nothing if it's exported as shapes.

Private Member Functions

virtual void BuildGradientCache (Node *pStartNode)
 Builds up a 'cache' of gradient fills.
virtual void BuildGradientCacheUsingScanner (Node *pNode, AIEPSGradientScanRenderRegion *pScan)
 Builds up the gradient cache by scanning through each node under pNode for new fills.
virtual void WriteGradientCount ()
 Writes out the count of all the gradient fills in the Cache.
virtual void WriteGradientDefinitions ()
 Writes out the definitions of all the gradient fills in the Cache.
virtual void ClearGradientCache ()
 Deletes the list of stored gradient fills, that was built up using IncludeGradientFill.
virtual INT32 FindGradientInCache (FillGeometryAttribute *pFill, EFFECTTYPE effect)
 Deletes the list of stored gradient fills, that was built up using IncludeGradientFill.
BOOL WriteLinearFill (FillGeometryAttribute *pFill, EFFECTTYPE effect, INT32 id)
 Writes a linear fill to the disk file.
BOOL WriteRadialFill (FillGeometryAttribute *pFill, EFFECTTYPE effect, INT32 id)
 Writes a Radial fill to the disk file.
virtual void WriteGradientFillInstance ()
 This function identifies whether or not the current fill is a gradient fill, and writes in the appropriate values if it is. I've already created the records of the gradients themselves (see above), so this is just a case of matching the gradient with its ID, and Adobe Illustrator can then put the records together.
BOOL WriteGradientEntry (DocColour *pColour, INT32 Position, INT32 Midpoint)
 Writes a line into the definition of a gradient fill.
BOOL WriteFillEffectSteps (DocColour *pColour1, INT32 pos1, DocColour *pColour2, INT32 pos2, INT32 bias, EFFECTTYPE effect)
 Writes the additional entries required for a special fill effect (rainbow or alt-rainbow) to the gradient definition, as a series of steps. See Also: AIEPSRenderRegion::WriteGradientEntry AIEPSRenderRegion::WriteLinearFill AIEPSRenderRegion::WriteRadialFill.
BOOL LoadBitmapMatrix (NodeBitmap *pNodeBMP)
 This code generates a matrix to position and manipulate a bitmap within an AI file. Roughly, it calculates the angle of rotation, followed by the skew angle, and creates a matrix using these values. See Also: FlashExportDC::WriteBitmapFill ().
BOOL LoadTranslationMatrix (DocCoord &Translation)
 Loads the matrix with:.
BOOL WriteLoadedMatrix (void)
 Writes a pre-loaded matrix to the file. I've added a couple of functions to create a matrix first, since it'll be more efficient to store the data, and re-write it as required, than to recalculate it twice.
BOOL WriteMaskTags (void)
 Writes out the tags at the end of each block of a mask's definition.
BOOL WriteBitmapRecord (OILBitmap *pBitmap)
 Creates a kernel bitmap instance within the AI file.
BOOL WriteBitmapHeader (INT32 Width, INT32 Height)
 Writes the AI header for a bitmap record.
BOOL WriteBitmapBody (OILBitmap *pBitmap, INT32 Width, INT32 Height)
 Writes the bitmap's data to the file.
BOOL WriteContoneBody (OILBitmap *pBitmap)
 Writes a contone bitmap to the file as a 32bpp image.
BOOL WriteBitmapTail (void)
 Wraps up the bitmap instance.

Private Attributes

ListFillm_pLinearGradList
ListFillm_pRadialGradList
double m_a
double m_b
double m_c
double m_d
DocCoord m_T
BOOL m_ActiveLayer
UINT32 m_LayerColour
FILE * m_fpOverflowText
BOOL m_bInTextGap
BOOL m_bTextAsShapes

Friends

class AIEPSGradientScanRenderRegion

Detailed Description

A render region for exporting EPS files in Adobe Illustrator 7.0 EPS format.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>, extended by Graeme
Date:
08/03/94
See also:
EPSRenderRegion

Definition at line 207 of file ai_epsrr.h.


Constructor & Destructor Documentation

AIEPSRenderRegion::AIEPSRenderRegion DocRect  ClipRect,
Matrix  ConvertMatrix,
FIXED16  ViewScale
 

Create and initialise a render region for exporting AI EPS. Sets up the string to put in the %Creator comment.

Author:
Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/3/00
See also:
EPSRenderRegion::EPSRenderRegion ()

Definition at line 145 of file ai_epsrr.cpp.

00148     : EPSRenderRegion ( ClipRect, ConvertMatrix, ViewScale )
00149 {
00150     // Set up member variables.
00151     m_a             = 1;
00152     m_b             = 0;
00153     m_c             = 0;
00154     m_d             = 1;
00155     m_T             = DocCoord ( 0, 0 );
00156     m_ActiveLayer   = FALSE;
00157     m_LayerColour   = 0;
00158 
00159     m_fpOverflowText    = NULL;
00160 
00161     m_bInTextGap        = FALSE;
00162     m_bTextAsShapes     = FALSE;
00163     
00164     m_pLinearGradList   = NULL;
00165     m_pRadialGradList   = NULL;
00166 
00167     // Initialise the creator string to show that it's an AI file.
00168     CreatorString = _T("Adobe Illustrator(TM) 7.0 by Xara.");
00169 }

AIEPSRenderRegion::~AIEPSRenderRegion  ) 
 

Definition at line 181 of file ai_epsrr.cpp.

00182 {
00183     ClearGradientCache ();
00184 }


Member Function Documentation

void AIEPSRenderRegion::BuildGradientCache Node pStartNode  )  [private, virtual]
 

Builds up a 'cache' of gradient fills.

Author:
Chris_Gallimore (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/3/2001
Parameters:
pStartNode - the node to start looking from. [INPUTS]
See also: AIEPSRenderRegion::WriteGradientFills, AIEPSRenderRegion::WriteGradientDefinitions

Definition at line 3601 of file ai_epsrr.cpp.

03602 {
03603 //  Node * pChild   = NULL;
03604 
03605     // Set up the gradient searching system
03606     AIEPSGradientScanRenderRegion scanRR (this);
03607     scanRR.AttachDevice (DocView::GetSelected (), RenderDC, RenderView->GetDoc()->FindFirstSpread ());
03608     scanRR.InitDevice ();
03609 
03610     // Although the counting system does return the number of fills found, it can be got from
03611     //  the scanner just as easily.
03612     BuildGradientCacheUsingScanner (pStartNode, &scanRR);
03613 }

void AIEPSRenderRegion::BuildGradientCacheUsingScanner Node pNode,
AIEPSGradientScanRenderRegion pScan
[private, virtual]
 

Builds up the gradient cache by scanning through each node under pNode for new fills.

Author:
Chris_Gallimore (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/3/2001
Parameters:
pNode - the node to start looking from. [INPUTS] pScan - the scanner to use
See also: AIEPSRenderRegion::WriteGradientFills, AIEPSRenderRegion::WriteGradientDefinitions

Definition at line 3631 of file ai_epsrr.cpp.

03632 {
03633     // Children are rendered first, so that attributes will be applied to the right objects.
03634     Node * pChild = pNode->FindFirstChild ();
03635     while (pChild!=NULL)
03636     {
03637         BuildGradientCacheUsingScanner (pChild, pScan);
03638         pChild = pChild->FindNext ();
03639     }
03640 
03641     // "Render" the node into the scanner. Currently, rendering is the only way to access
03642     //  the intermediate steps (and their attributes) in blends, contours and some others, 
03643     //  so we need to use a special Render Region to catch the gradient (fill) information.
03644     //
03645     // NOTE: Since this uses the same system as the main render loop, it shouldn't be possible
03646     //  for the gradient cache and the main file to become out of sync. Also, bevels and 
03647     //  shadows are excluded, as they are rendered as bitmaps in AI export.
03648     if (!pNode->IsABevel () && !pNode->IsAShadow ())
03649         pNode->Render (pScan);
03650 }

void AIEPSRenderRegion::ClearGradientCache  )  [private, virtual]
 

Deletes the list of stored gradient fills, that was built up using IncludeGradientFill.

Author:
Chris_Gallimore (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/3/2001
See also: AIEPSRenderRegion::IncludeGradientFill, AIEPSRenderRegion::FindGradientInCache

Definition at line 3495 of file ai_epsrr.cpp.

03496 {
03497     ListFill * pList = NULL;
03498 
03499     // only clear it if there is a list to clear
03500     if (m_pLinearGradList)
03501     {
03502         // Cycle through the linear list deleting each item in turn.
03503         while (m_pLinearGradList != NULL)
03504         {
03505             pList = m_pLinearGradList->pNext;
03506             delete m_pLinearGradList;
03507             m_pLinearGradList = pList;
03508         }
03509     }
03510 
03511     if (m_pRadialGradList)
03512     {
03513         // Cycle through the radial list deleting each item in turn.
03514         while (m_pRadialGradList != NULL)
03515         {
03516             pList = m_pRadialGradList->pNext;
03517             delete m_pRadialGradList;
03518             m_pRadialGradList = pList;
03519         }
03520     }
03521 }

BOOL AIEPSRenderRegion::EndLayer void   )  [protected, virtual]
 

If there is an existing layer, it writes the end of layer tags, before creating a new layer record.

Author:
Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/4/00
Parameters:
- [INPUTS]
Returns:
TRUE - Success. FALSE - An error occured.
See also:
AIEPSRenderRegion::ExportLayer ()

Reimplemented from EPSRenderRegion.

Definition at line 1219 of file ai_epsrr.cpp.

01220 {
01221     // Only act if there's an active layer.
01222     if ( m_ActiveLayer )
01223     {
01224         // Cast the RenderDC pointer into a useful form.
01225         KernelDC    *pDC    = static_cast<KernelDC *> ( CCDC::ConvertFromNativeDC(RenderDC) );
01226 
01227         // Write out the end of layer tag.
01228         pDC->OutputToken    ( _T("LB") );
01229         pDC->OutputNewLine  ();
01230         pDC->OutputToken    ( _T("%AI5_EndLayer") );
01231         pDC->OutputNewLine  ();
01232 
01233         // Set m_ActiveLayer to be FALSE.
01234         m_ActiveLayer = FALSE;
01235     }
01236 
01237     return TRUE;
01238 }

BOOL AIEPSRenderRegion::ExportBevel NodeBevel pBevel  ) 
 

Renders a bevel into a DIB, and exports this as a bitmap to the AI file.

Author:
Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/4/00
Parameters:
pBevel - A pointer to a bevel node. [INPUTS]
Returns:
TRUE - Success. FALSE - An error occured.
See also:
NodeBevel::ExportRender

Definition at line 228 of file ai_epsrr.cpp.

00229 {
00230     // Set up the local variables.
00231     KernelDC                *pDC            = static_cast<KernelDC *> ( CCDC::ConvertFromNativeDC(RenderDC) );
00232     RangeControl            ControlFlags    ( TRUE, TRUE );
00233     Range                   ToRender        ( pBevel, pBevel, ControlFlags );
00234     KernelBitmap            *pBitmap        = NULL;
00235     Path                    *pSourcePath    = &( pBevel->InkPath );
00236     DocRect                 Bounds          = pBevel->GetBoundingRect ();
00237     DocCoord                Position        ( Bounds.lo.x, Bounds.hi.y );
00238     double                  Width           = static_cast<double> ( Bounds.Width () );
00239     double                  Height          = static_cast<double> ( Bounds.Height () );
00240 
00241     // Create and render the bitmap.
00242     pBitmap = pBevel->CreateBitmapCopy(-1.0,FALSE);
00243 
00244     if(!pBitmap)
00245         return FALSE;
00246 
00247     // Get the width and height of the bitmap.
00248     double                  BMPWidth        = static_cast<double> ( pBitmap->GetWidth () );
00249     double                  BMPHeight       = static_cast<double> ( pBitmap->GetHeight () );
00250 
00251     // Write the path. (ChrisG 16/01/01) If we have one.
00252     if (pSourcePath->GetNumCoords () != 0)
00253     {
00254         WriteMask ( pSourcePath, TRUE );
00255     }
00256 
00257     // Set up the bitmap translation matrix.
00258     LoadTranslationMatrix ( Position );
00259 
00260     // Scale width and height to be valid value for AI co-ordinates.
00261     Width   /= 1000;
00262     Height  /= 1000;
00263     
00264     // And calcuate the scale values for placing the bitmap.
00265     m_a = Width  / BMPWidth;
00266     m_d = Height / BMPHeight;
00267 
00268     // Write the bitmap record.
00269     WriteBitmapRecord ( pBitmap->ActualBitmap );
00270 
00271     // Write the end of mask operator. (ChrisG 16/01/01) If we've written a mask.
00272     if (pSourcePath->GetNumCoords () != 0)
00273     {
00274         pDC->OutputToken    ( _T("Q") );
00275         pDC->OutputNewLine  ();
00276     }
00277 
00278     if(pBitmap)
00279     {
00280         pBitmap->DestroyGreyscaleVersion();
00281         delete pBitmap;
00282     }
00283 
00284     // Success!
00285     return TRUE;
00286 }

BOOL AIEPSRenderRegion::ExportBitmap NodeBitmap pNodeBMP  ) 
 

Kicks off the NodeBitmap export process..

Author:
Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/3/00
Parameters:
pNodeBMP - A pointer to the NodeBitmap being exported. [INPUTS]
Returns:
TRUE - If successful. FALSE - If an error is encountered.
See also:
NodeBitmap::ExportRender ()

Definition at line 200 of file ai_epsrr.cpp.

00201 {
00202     // Set up the local variables.
00203     KernelBitmap    *pBitmap    = pNodeBMP->GetBitmap ();
00204 
00205     // Set up the bitmap's transformation matrix.
00206     LoadBitmapMatrix ( pNodeBMP );
00207 
00208     // Write out the bitmap record.
00209     WriteBitmapRecord ( pBitmap->GetActualBitmap () );
00210 
00211     return TRUE;
00212 }

BOOL AIEPSRenderRegion::ExportingOnPath  ) 
 

To determine whether this text is being exported on a path.

Author:
Chris_Gallimore (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/11/00
Returns:
TRUE - yes, we are exporting on a path FALSE - no, we aren't exporting on a path
See also:

Definition at line 2578 of file ai_epsrr.cpp.

02579 {
02580     if (m_fpOverflowText)
02581         return TRUE;
02582     else
02583         return FALSE;
02584 }

BOOL AIEPSRenderRegion::ExportLayer Layer pLayer  ) 
 

If there is an existing layer, it writes the end of layer tags, before creating a new layer record.

Author:
Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/4/00
Parameters:
pLayer - A pointer to a layer object. [INPUTS]
Returns:
TRUE - Success. FALSE - An error occured.
See also:
AIEPSRenderRegion::EndLayer ()

Definition at line 358 of file ai_epsrr.cpp.

00359 {
00360     // Tidy up the existing layer, if it exists.
00361     EndLayer ();
00362 
00363     // And write out the next layer.
00364     return StartLayer ( static_cast<Layer*> ( pLayer->FindNext
00365                                               ( CC_RUNTIME_CLASS ( Layer ) ) ) );
00366 }

BOOL AIEPSRenderRegion::ExportShadow OILBitmap pBitmap,
UINT32  Darkness,
DocRect Bounds
 

Renders a shadow into a DIB, and exports this as a bitmap to the AI file.

Author:
Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/4/00
Parameters:
pShadow - A pointer to a shadow node. [INPUTS]
Returns:
TRUE - Success. FALSE - An error occured.
See also:
NodeBevel::ExportRender

Definition at line 304 of file ai_epsrr.cpp.

00307 {
00308     // Set up the local variables.
00309 //  KernelDC *pDC = (KernelDC*)CCDC::ConvertFromNativeDC(RenderDC);
00310     DocCoord    Position        ( Bounds.lo.x, Bounds.hi.y );
00311     double      Width           = static_cast<double> ( Bounds.Width () ) / 1000;
00312     double      Height          = static_cast<double> ( Bounds.Height () ) / 1000;
00313     double      BMPWidth        = static_cast<double> ( pBitmap->GetWidth () );
00314     double      BMPHeight       = static_cast<double> ( pBitmap->GetHeight () );
00315     DocColour   ShadowColour    = *( static_cast<FillGeometryAttribute*>
00316                                      ( GetCurrentAttribute ( ATTR_FILLGEOMETRY ) )
00317                                      ->GetStartColour () );
00318     DocColour   BlendedShadow   = AlphaBlend ( ShadowColour, mBackgroundColour, Darkness );
00319 
00320     // And use the shadow colour to build a contone bitmap palette.
00321     pBitmap->BuildContonePalette ( BlendedShadow, mBackgroundColour, EFFECT_RGB,
00322                                    RenderView );
00323 
00324     // Set up the bitmap translation matrix.
00325     LoadTranslationMatrix ( Position );
00326     
00327     // And calcuate the scale values for placing the bitmap.
00328     m_a = Width  / BMPWidth;
00329     m_d = Height / BMPHeight;
00330 
00331     // Write out the bitmap header.
00332     WriteBitmapHeader ( (INT32)BMPWidth, (INT32)BMPHeight );
00333 
00334     // Export the bitmap.
00335     WriteContoneBody ( pBitmap );
00336 
00337     // Finish off the bitmap record.
00338     WriteBitmapTail ();
00339 
00340     return TRUE;
00341 }

INT32 AIEPSRenderRegion::FindGradientInCache FillGeometryAttribute pFill,
EFFECTTYPE  effect
[private, virtual]
 

Deletes the list of stored gradient fills, that was built up using IncludeGradientFill.

Author:
Chris_Gallimore (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/3/2001 Returns the identifier of the found gradient fill, or 0 if it wasn't found
See also: AIEPSRenderRegion::IncludeGradientFill,

Definition at line 3538 of file ai_epsrr.cpp.

03539 {
03540     INT32 id    = 0;
03541     ListFill * pList = NULL;
03542     FillGeometryAttribute * pStoredFill = NULL;
03543 
03544     double fillBias = 0;
03545     CProfileBiasGain fillProfile = pFill->GetProfile ();
03546     fillBias = (double) fillProfile.GetBias ();
03547 
03548     // work out which list we want to search in.
03549     if (pFill->IsARadialFill () || pFill->IsASquareFill ())
03550         pList = m_pRadialGradList;
03551     else
03552         pList = m_pLinearGradList;
03553 
03554     // Cycle through all the fills until we find the one we want, or until we run out of fills
03555     while ((pList != NULL) && (id == 0))
03556     {
03557         pStoredFill = pList->pFill;
03558 
03559         // Because the start and end points for an Illustrator fill are not included in the
03560         //  cache, we don't need to worry about them being the same.
03561         //
03562         // So, we set all the start and end points to be the same (since they would cause two
03563         //  identical fills in different places, or of different lengths to be considered as
03564         //  different otherwise).
03565         pStoredFill->SetStartPoint (pFill->GetStartPoint ());
03566         pStoredFill->SetEndPoint (pFill->GetEndPoint ());
03567         pStoredFill->SetEndPoint2 (pFill->GetEndPoint2 ());
03568         pStoredFill->SetEndPoint3 (pFill->GetEndPoint3 ());
03569 
03570         // Now that the fill coords are the same, test to see whether they're 
03571         //  the same fill, or not.
03572         if (*pStoredFill == *pFill)
03573         {
03574             double storeBias = 0;
03575             CProfileBiasGain storeProfile = pStoredFill->GetProfile ();
03576             storeBias = (double) storeProfile.GetBias ();
03577 
03578             if ((storeBias == fillBias) && (pList->effect == effect))
03579                 id = pList->id;
03580         }
03581 
03582         // Check the next fill
03583         pList = pList->pNext;
03584     }
03585 
03586     return id;
03587 }

BOOL AIEPSRenderRegion::GetTextAsShapes  )  [virtual]
 

Sets the export TextAsShapes flag.

Author:
Chris_Gallimore (Xara Group Ltd) <camelotdev@xara.com>
Date:
8th November 2000
Returns:
BOOL - whether text is exported as shapes (TRUE) or characters (FALSE)
See also: AIEPSRenderRegion::GetTextAsShapes

Definition at line 3036 of file ai_epsrr.cpp.

03037 {
03038     return m_bTextAsShapes;
03039 }

void AIEPSRenderRegion::IncludeGradientFill FillGeometryAttribute pFill,
EFFECTTYPE  effect
[virtual]
 

Stores information about a fill so that the same fill isn't declared multiple times. See also: AIEPSRenderRegion::WriteGradientFills, AIEPSRenderRegion::WriteGradientUsage, AIEPSRenderRegion::FindGradientInCache.

Author:
Chris_Gallimore (Xara Group Ltd) <camelotdev@xara.com>
Date:
5/2/2001

Definition at line 3416 of file ai_epsrr.cpp.

03417 {
03418     ERROR3IF ((pFill == NULL), "AIEPSRenderRegion::IncludeGradientFill - Attempted to include NULL fill");
03419 
03420     ListFill * pNewList = NULL;
03421     FillGeometryAttribute * pNewFill = NULL;
03422 
03423     // don't try and store the fill if it's invalid.
03424     if (pFill != NULL)
03425     {
03426         // Create a new FillGeometryAttribute, of the same type as the one passed in.
03427 
03428         //  NOTE: Four colour fills are derived from three colour fills, so they return
03429         //      TRUE for IsAThreeColFill. This means that we need to process four colour
03430         //      fills before we process three colour fills, otherwise all four colour fills
03431         //      will become represented by three colour ones and the copy won't match the
03432         //      original.
03433 
03434         if (pFill->IsALinearFill ())
03435             pNewFill = new LinearFillAttribute;
03436         else if (pFill->IsARadialFill ())
03437             pNewFill = new RadialFillAttribute;
03438         else if (pFill->IsAConicalFill ())
03439             pNewFill = new ConicalFillAttribute;
03440         else if (pFill->IsASquareFill ())
03441             pNewFill = new SquareFillAttribute;
03442         else if (pFill->IsAFourColFill ())
03443             pNewFill = new FourColFillAttribute;
03444         else if (pFill->IsAThreeColFill ())
03445             pNewFill = new ThreeColFillAttribute;
03446         else if (pFill->IsAFractalFill ())
03447             pNewFill = new FractalFillAttribute;
03448         else if (pFill->IsANoiseFill ())
03449             pNewFill = new NoiseFillAttribute;
03450         else if (pFill->IsABitmapFill ())
03451             pNewFill = new BitmapFillAttribute;
03452         else
03453         {
03454             pNewFill = NULL;
03455             ERROR3 ("AIEPSRenderRegion::IncludeGradientFill - Unrecognised fill included");
03456         }
03457 
03458         // Copy fill data if the the fill is recognised. There's no point in doing this if
03459         //  we didn't recognise the fill, as the copy is bound to be different to the original.
03460         if (pNewFill != NULL)
03461         {
03462             // Copy all the relevant info.
03463             *(pNewFill) = *pFill;
03464             ERROR3IF ( !(*pFill == *pNewFill), "AIEPSRenderRegion::IncludeGradientFill - Copied fill doesn't match original");
03465 
03466             // New Fill is built, so add it into either the radial or linear list.
03467             if (pFill->IsARadialFill () || pFill->IsASquareFill ())
03468             {
03469                 pNewList = new ListFill (pNewFill, effect, m_pRadialGradList);
03470                 m_pRadialGradList = pNewList;
03471             }
03472             else
03473             {
03474                 pNewList = new ListFill (pNewFill, effect, m_pLinearGradList);
03475                 m_pLinearGradList = pNewList;
03476             }
03477         }
03478     }
03479 }

void AIEPSRenderRegion::Initialise  )  [protected, virtual]
 

Sets up render region - it outputs the AIEPS file header comments, and intialises the rendering attributes.

Author:
Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/3/00
See also:
EPSRenderRegion::Initialise, EPSRenderRegion::InitAttributes

Definition at line 531 of file ai_epsrr.cpp.

00532 {
00533     // Set up member variables.
00534     m_a             = 1;
00535     m_b             = 0;
00536     m_c             = 0;
00537     m_d             = 1;
00538     m_T             = DocCoord ( 0, 0 );
00539     m_ActiveLayer   = FALSE;
00540     m_LayerColour   = 0;
00541 
00542     ClearGradientCache ();
00543 
00544     // Call the EPSRenderRegion method to re-enter the export loop.
00545     EPSRenderRegion::InitAttributes ();
00546 }

BOOL AIEPSRenderRegion::IsGradientFillValidForExport FillGeometryAttribute pFill  )  [virtual]
 

Determines whether a particular fill can be used through the AI export See also: AIEPSRenderRegion::WriteGradientFills, AIEPSRenderRegion::WriteGradientUsage.

Author:
Chris_Gallimore (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/01/01

Definition at line 3383 of file ai_epsrr.cpp.

03384 {
03385     BOOL acceptable = FALSE;
03386 
03387     if ( pFill->IsAColourFill () &&         // Is it a colour fill?
03388          pFill->IsAGradFill () &&           // Is it a graduated fill?
03389          ! (pFill->IsAFractalFill ()) &&    // Is it not a fractal (clouds) fill?
03390          ! (pFill->IsANoiseFill ()) &&      // Is it not a fractal (plasma) fill?
03391          ! (pFill->IsABitmapFill ()) )      // Is it not a bitmap fill?
03392     {
03393         acceptable = TRUE;
03394     }
03395     else
03396     {
03397         acceptable = FALSE;
03398     }
03399 
03400     return acceptable;
03401 }

BOOL AIEPSRenderRegion::LoadBitmapMatrix NodeBitmap pNodeBMP  )  [private]
 

This code generates a matrix to position and manipulate a bitmap within an AI file. Roughly, it calculates the angle of rotation, followed by the skew angle, and creates a matrix using these values. See Also: FlashExportDC::WriteBitmapFill ().

Author:
Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/4/00
Parameters:
pNodeBitmap - A pointer to the bitmap node being exported. [INPUTS]
Returns:
TRUE - Successful. FALSE - An error has occured.

Definition at line 1402 of file ai_epsrr.cpp.

01403 {
01404     // Step 1:  Extract the co-ordinates of three corners from the bitmap record, and store
01405     //          them as named co-ordinates within this function. The names are a historical
01406     //          reference to the original names within the FlashExportDC, and refer to the
01407     //          positions of a bitmap fill.
01408     double          Angle       = pNodeBMP->GetRotationAngle ();
01409 
01410     double          SinRotate   = sin ( Angle );
01411     double          CosRotate   = cos ( Angle );
01412 //  double          Skew        = 0;
01413 
01414     DocCoord        LowLeft     = pNodeBMP->Parallel [3];   // Low corner of the bitmap.
01415     DocCoord        TopLeft     = pNodeBMP->Parallel [0];   // Max Y corner.
01416     DocCoord        LowRight    = pNodeBMP->Parallel [2];   // Max X corner.
01417 
01418     // Step 2:  Calculate the normalised dot product of the two vectors, and this forms
01419     //          the cosine of their internal angle.
01420     double          WidthX      = static_cast<double> ( LowLeft.x - LowRight.x ) / 1000;
01421     double          WidthY      = static_cast<double> ( LowLeft.y - LowRight.y ) / 1000;
01422     double          HeightX     = static_cast<double> ( TopLeft.x - LowLeft.x  ) / 1000;
01423     double          HeightY     = static_cast<double> ( TopLeft.y - LowLeft.y  ) / 1000;
01424     
01425     // Get the lengths of these vectors to normalise the dot-product. (Necessary for the
01426     // trignometric function calculations.)
01427     double          Width       = sqrt ( ( WidthX * WidthX ) + ( WidthY * WidthY ) );
01428     double          Height      = sqrt ( ( HeightX * HeightX ) + ( HeightY * HeightY ) );
01429 /*
01430     // The dot product calculation. By normalising the result, the cosine of the angle is
01431     // calculated.
01432     double      CosSkew = ( ( WidthX * HeightX ) + ( HeightY * WidthY ) ) /
01433                               ( Height * Width );
01434     double      SinSkew = sqrt ( 1 - ( CosSkew * CosSkew ) );
01435 
01436     // Multiply the width of the shape by the sine derived from the dot product. This will
01437     // give the actual width, and not the one distorted by skewing.
01438     Width *= SinSkew;
01439 
01440     // If the DotSine value is not 0, calculate the tan value that forms the skew angle.
01441     // Since tan is undefined for 0, I'm ignoring this state.
01442     if ( SinSkew != 0 )
01443     {
01444         Skew = - CosSkew / SinSkew;
01445     }
01446 */
01447     // Grab a reference to the bitmap, and pull it's height and width from it.
01448     KernelBitmap    *pBitmap    = pNodeBMP->GetBitmap ();   // A reference to the bitmap.
01449 
01450     double          BMPWidth    = static_cast<double> ( pBitmap->GetWidth () );
01451     double          BMPHeight   = static_cast<double> ( pBitmap->GetHeight () );
01452 
01453     // Catch BMPWidth or BMPHeight set to zero. This shouldn't happen...
01454     if ( BMPWidth == 0 )
01455         BMPWidth = 1;
01456 
01457     if ( BMPHeight == 0 )
01458         BMPHeight = 1;
01459 
01460     // Step 4:  Use the above values to calculate the values with which to populate the
01461     //          transformation matrix.
01462     double          ScaleX      = Width  / BMPWidth;
01463     double          ScaleY      = Height / BMPHeight;
01464 
01465     // Step 5:  Use these to build the matrix. The variables a, b, c, d refer to the AI
01466     //          matrix entries. The form of the matrix is:
01467     //
01468     //          | SinRotate     CosRotate | | ScaleX        0       |
01469     //          | -CosRotate    SinRotate | | Skew * ScaleY ScaleY  |
01470 
01471     m_a = ( SinRotate * ScaleX );   // + ( CosRotate * Skew * ScaleY );
01472     m_b = ( - CosRotate * ScaleX ); // + ( SinRotate * Skew * ScaleY );
01473     m_c = CosRotate * ScaleY;
01474     m_d = SinRotate * ScaleY;
01475 
01476     // There's a weird bug with the AI export, in that a small (>0.0001) value is misread
01477     // by Adobe Illustrator as a monstrous value. To get around this, I'm going to set all
01478     // near zero values to zero.
01479     if ( Absol ( m_a ) < 1e-4 )
01480     {
01481         m_a = 0;
01482     }
01483 
01484     if ( Absol ( m_b ) < 1e-4 )
01485     {
01486         m_b = 0;
01487     }
01488 
01489     if ( Absol ( m_c ) < 1e-4 )
01490     {
01491         m_c = 0;
01492     }
01493 
01494     if ( Absol ( m_d ) < 1e-4 )
01495     {
01496         m_d = 0;
01497     }
01498 
01499     // Step 6:  Calculate the translation part of the matrix.
01500     m_T = TopLeft;
01501 
01502     return TRUE;
01503 }

BOOL AIEPSRenderRegion::LoadTranslationMatrix DocCoord Translation  )  [private]
 

Loads the matrix with:.

Author:
Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/4/00
Parameters:
- [INPUTS]
Returns:
TRUE - Success. FALSE - An error occured.
| 1 0 Translation.x | | 0 1 Translation.y |

Which can then be written with WriteLoadedMatrix.

See also:
AIESPRenderRegion::LoadBitmapMatrix, AIEPSRenderRegion::WriteLoadedMatrix

Definition at line 1524 of file ai_epsrr.cpp.

01525 {
01526     // Set the transformation part of the matrix to be the identity matrix.
01527     m_a = 1;
01528     m_b = 0;
01529     m_c = 0;
01530     m_d = 1;
01531 
01532     // And load up the translation value.
01533     m_T = Translation;
01534 
01535     return TRUE;
01536 }

void AIEPSRenderRegion::OutputDashPattern  )  [protected, virtual]
 

Outputs EPS dash pattern values. This function currently only exists so that extra handling can be easily achieved for Illustrator EPS export of dash patterns in the future (if need be).

Author:
Chris_Gallimore (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/11/00
See also:
EPSRenderRegion::OutputDashPattern (); EPSRenderRegion::OutputDashPatternInit();

Reimplemented from EPSRenderRegion.

Definition at line 2141 of file ai_epsrr.cpp.

02142 {
02143     EPSRenderRegion::OutputDashPattern ();
02144 }

void AIEPSRenderRegion::OutputFillCMYKColour  )  [protected, virtual]
 

Writes additional info to the file for CMYK fill colours See also: EPSRenderRegion::OutputFillCMYKColour.

Author:
Chris_Gallimore (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/12/00

Reimplemented from EPSRenderRegion.

Definition at line 3167 of file ai_epsrr.cpp.

03168 {
03169     // NOTE: We need to export any changes to the overflow text here, 
03170     // as it's the last place we can catch the colour change.
03171     if (ExportingOnPath ())
03172     {
03173         PColourCMYK CMYK;
03174 
03175         OverflowT