svgtopt/gfx2d/inc/GfxFlatteningPathIterator.h
changeset 0 d46562c3d99d
equal deleted inserted replaced
-1:000000000000 0:d46562c3d99d
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Graphics Extension Library header file
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef GFXFLATTENINGPATHITERATOR_H
       
    20 #define GFXFLATTENINGPATHITERATOR_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <e32std.h>
       
    24 
       
    25 #include "GfxFloatFixPt.h"
       
    26 #include "GfxPathIterator.h"
       
    27 
       
    28 
       
    29 
       
    30 class TGfxAffineTransform;
       
    31 class MGfxShape;
       
    32 
       
    33 /**
       
    34  * This class provides the methods to smooth a path.
       
    35  *
       
    36  *  @lib Gfx2D.lib
       
    37  *  @since 1.0
       
    38  */
       
    39 class CGfxFlatteningPathIterator : public CGfxPathIterator
       
    40     {
       
    41     public:
       
    42 
       
    43         /**
       
    44          * Two-phase constructor.
       
    45          *
       
    46          * @since 1.0
       
    47          * @param aSrc : source of path of flatten
       
    48          * @param aAt : transform to apply.
       
    49          * @param aFlatness : degree of flattening to apply.
       
    50          * @param aLimit : maximum number of points used for flattening.
       
    51          * @return
       
    52          */
       
    53          static CGfxFlatteningPathIterator*     NewL( MGfxShape* aSrc,
       
    54                                                               TGfxAffineTransform* aAt,
       
    55                                                               TInt32 aLimit );
       
    56 
       
    57 
       
    58         /**
       
    59          * Destructor
       
    60          *
       
    61          * @since 1.0
       
    62          * @return
       
    63          */
       
    64          virtual                                ~CGfxFlatteningPathIterator();
       
    65 
       
    66 
       
    67         /**
       
    68          * Set the degree of flattening to apply.
       
    69          *
       
    70          * @since 1.0
       
    71          * @param aFlatness : degree of flattening.
       
    72          * @return
       
    73          */
       
    74 
       
    75          void                                   SetFlatness( TFloatFixPt& aFlatness );
       
    76 
       
    77         /**
       
    78          * Set the recursion level.
       
    79          *
       
    80          * @since 1.0
       
    81          * @param aLimit : recursion level.
       
    82          * @return
       
    83          */
       
    84          void                                   SetRecursionLimit( TInt32 aLimit );
       
    85 
       
    86         /**
       
    87          * Get the flattening level..
       
    88          *
       
    89          * @since 1.0
       
    90          * @param aLimit : recursion level.
       
    91          * @return flattening value.
       
    92          */
       
    93 
       
    94          TFloatFixPt                                 Flatness();
       
    95 
       
    96         /**
       
    97          * Get the recursion level.
       
    98          *
       
    99          * @since 1.0
       
   100          * @return the recursion level.
       
   101          */
       
   102          TInt32                                 RecursionLimit();
       
   103 
       
   104 
       
   105         /**
       
   106          * Get the points defining the current segment of iteration.
       
   107          *
       
   108          * @since 1.0
       
   109          * @param aCoords : array to store segment points.
       
   110          * @return segment type.
       
   111          */
       
   112          TGfxSegType                            CurrentSegment( TFloatFixPt* aCoords );
       
   113 
       
   114         /**
       
   115          * Determine wether the end has been reached.
       
   116          *
       
   117          * @since 1.0
       
   118          * @return true, if end of iterator reached.
       
   119          */
       
   120          TBool                                  IsDone();
       
   121 
       
   122         /**
       
   123          * Cycle to the next segment of this iterator.
       
   124          *
       
   125          * @since 1.0
       
   126          * @return
       
   127          */
       
   128          void                                   NextL();
       
   129 
       
   130 
       
   131         /**
       
   132          * Create a polygon from iterator.  This method is does nothing.
       
   133          *
       
   134          * @since 1.0
       
   135          * @return
       
   136          */
       
   137          void PolygonizeL( CGfxEdgeListP* aRenderer, TInt aFlatness );
       
   138 
       
   139     private:
       
   140 
       
   141         /**
       
   142          * Constructor
       
   143          *
       
   144          * @since 1.0
       
   145          * @param aFlatness : degree of flattening to apply.
       
   146          * @param aLimit : maximum number of points used for flattening.
       
   147          * @return
       
   148          */
       
   149                             CGfxFlatteningPathIterator( TInt32 aLimit );
       
   150 
       
   151         /**
       
   152          * Second phase of constrction.
       
   153          *
       
   154          * @since 1.0
       
   155          * @param aSrc : source of path of flatten
       
   156          * @param aAt : transform to apply.
       
   157          * @return
       
   158          */
       
   159         void                ConstructL( MGfxShape* aSrc,
       
   160                                         TGfxAffineTransform* aAt );
       
   161 
       
   162 
       
   163         /**
       
   164          * Create a quadratic sub-curve.
       
   165          *
       
   166          * @since 1.0
       
   167          * @param aCtrlPoints : quadratic control points.
       
   168          * @return
       
   169          */
       
   170         void                CreateSubcurveQuadL( RArray<TFloatFixPt>* aCtrlPoints );
       
   171 
       
   172         /**
       
   173          * Create a cubic sub-curve.
       
   174          *
       
   175          * @since 1.0
       
   176          * @param aCtrlPoints : cubic control points.
       
   177          * @return
       
   178          */
       
   179         void                CreateSubcurveCubicL( RArray<TFloatFixPt>* aCtrlPoints );
       
   180 
       
   181     private:
       
   182         RArray<TFloatFixPt>*     iCoords;
       
   183         TInt32              iIdx;
       
   184         CGfxPathIterator*   iSrc;
       
   185         TFloatFixPt              iLastX;
       
   186         TFloatFixPt              iLastY;
       
   187         TGfxSegType         iSegType;
       
   188         TBool               iIsDone;
       
   189 
       
   190         TInt32              iLimit;
       
   191 
       
   192         TFloatFixPt              iFlatness;
       
   193 
       
   194 
       
   195 
       
   196     };
       
   197 
       
   198 #endif      // GFXFLATTENINGPATHITERATOR_H