svgtopt/gfx2d/inc/GfxGeneralPath.h
changeset 46 88edb906c587
child 12 2087eeae8b7f
equal deleted inserted replaced
-1:000000000000 46:88edb906c587
       
     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 GFXGENERALPATH_H
       
    20 #define GFXGENERALPATH_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <e32std.h>
       
    24 
       
    25 #include "GfxFloatFixPt.h"
       
    26 #include "GfxShape.h"
       
    27 #include "GfxAffineTransform.h"
       
    28 #include "GfxRectangle2D.h"
       
    29 #include "GfxPoint2D.h"
       
    30 #include "GfxPathIterator.h"
       
    31 
       
    32 #include <VG/openvg.h>
       
    33 
       
    34 
       
    35 /**
       
    36  * Implementation of a path.
       
    37  *
       
    38  *  @lib Gfx2D.lib
       
    39  *  @since 1.0
       
    40  */
       
    41 
       
    42 class CGfxGeneralPath : public CBase, public MGfxShape
       
    43     {
       
    44     public:
       
    45         /**
       
    46          * Two-phase constructor.
       
    47          *
       
    48          * @since 1.0
       
    49          * @return
       
    50          */
       
    51           static CGfxGeneralPath*    NewL();
       
    52 
       
    53         /**
       
    54          * Two-phase constructor.
       
    55          *
       
    56          * @since 1.0
       
    57          * @return
       
    58          */
       
    59          static CGfxGeneralPath*    NewLC();
       
    60 
       
    61         /**
       
    62          * Destructor.
       
    63          *
       
    64          * @since 1.0
       
    65          * @return
       
    66          */
       
    67          virtual                    ~CGfxGeneralPath();
       
    68 
       
    69         /**
       
    70          * Signal end of path to connect starting point to ending point.
       
    71          *
       
    72          * @since 1.0
       
    73          * @return
       
    74          */
       
    75          void                       ClosePathL();
       
    76 
       
    77 		 void						RemoveLastPathCommand();
       
    78 
       
    79         /**
       
    80          * Add a cubic curve.
       
    81          *
       
    82          * @since 1.0
       
    83          * @param aX1 : x coordinate for control point 1.
       
    84          * @param aY1 : y coordinate for control point 1.
       
    85          * @param aX2 : x coordinate for control point 2.
       
    86          * @param aY2 : y coordinate for control point 2.
       
    87          * @param aX3 : x coordinate for control point 3.
       
    88          * @param aY3 : y coordinate for control point 3.
       
    89          * @param aAbsolute : flag to indicate values are absolute or not.
       
    90          * @return
       
    91          */
       
    92          void                       CubicToL( TFloatFixPt& aX1,
       
    93                                                       TFloatFixPt& aY1,
       
    94                                                       TFloatFixPt& aX2,
       
    95                                                       TFloatFixPt& aY2,
       
    96                                                       TFloatFixPt& aX3,
       
    97                                                       TFloatFixPt& aY3,
       
    98                                                       TBool aAbsolute );
       
    99 
       
   100         /**
       
   101          * Add a line.
       
   102          *
       
   103          * @since 1.0
       
   104          * @param aX1 : x coordinate of line end point.
       
   105          * @param aY1 : y coordinate of line end point.
       
   106          * @param aAbsolute : flag to indicate values are absolute or not.
       
   107          * @return
       
   108          */
       
   109          void                       LineToL( TFloatFixPt& aX,
       
   110                                                      TFloatFixPt& aY,
       
   111                                                      TBool aAbsolute );
       
   112 
       
   113         /**
       
   114          * Start a new sub-path at the given location.
       
   115          *
       
   116          * @since 1.0
       
   117          * @param aX1 : x coordinate of new location.
       
   118          * @param aY1 : y coordinate of new location.
       
   119          * @param aAbsolute : flag to indicate values are absolute or not.
       
   120          * @return
       
   121          */
       
   122          void                       MoveToL( TFloatFixPt& aX,
       
   123                                                      TFloatFixPt& aY,
       
   124                                                      TBool aAbsolute );
       
   125 
       
   126         /**
       
   127          * Add a quadratic curve.
       
   128          *
       
   129          * @since 1.0
       
   130          * @param aX1 : x coordinate for control point 1.
       
   131          * @param aY1 : y coordinate for control point 1.
       
   132          * @param aX2 : x coordinate for control point 2.
       
   133          * @param aY2 : y coordinate for control point 2.
       
   134          * @param aAbsolute : flag to indicate values are absolute or not.
       
   135          * @return
       
   136          */
       
   137          void                       QuadToL( TFloatFixPt& aX1,
       
   138                                                      TFloatFixPt& aY1,
       
   139                                                      TFloatFixPt& aX2,
       
   140                                                      TFloatFixPt& aY2,
       
   141                                                      TBool aAbsolute );
       
   142 
       
   143         /**
       
   144          * Add a horizontal line from the current location.
       
   145          *
       
   146          * @since 1.0
       
   147          * @param aX : x coordinate for ending point.
       
   148          * @param aAbsolute : flag to indicate values are absolute or not.
       
   149          * @return
       
   150          */
       
   151          void                       HorizonToL( TFloatFixPt& aX,
       
   152                                                         TBool aAbsolute );
       
   153 
       
   154         /**
       
   155          * Add a vertical line from the current location.
       
   156          *
       
   157          * @since 1.0
       
   158          * @param aY : y coordinate for ending point.
       
   159          * @param aAbsolute : flag to indicate values are absolute or not.
       
   160          * @return
       
   161          */
       
   162          void                       VertToL( TFloatFixPt& aY,
       
   163                                                      TBool aAbsolute );
       
   164 
       
   165         /**
       
   166          * Add a cubic curve, using the current location as the
       
   167          * first control point.
       
   168          *
       
   169          * @since 1.0
       
   170          * @param aX2 : x coordinate for control point 2.
       
   171          * @param aY2 : y coordinate for control point 2.
       
   172          * @param aX3 : x coordinate for control point 3.
       
   173          * @param aY3 : y coordinate for control point 3.
       
   174          * @param aAbsolute : flag to indicate values are absolute or not.
       
   175          * @return
       
   176          */
       
   177          void                       ShortCubicToL( TFloatFixPt& aX2,
       
   178                                                            TFloatFixPt& aY2,
       
   179                                                            TFloatFixPt& aX3,
       
   180                                                            TFloatFixPt& aY3,
       
   181                                                            TBool aAbsolute );
       
   182         /**
       
   183          * Add a quadratic curve, using the current location as the
       
   184          * first control point.
       
   185          *
       
   186          * @since 1.0
       
   187          * @param aX2 : x coordinate for control point 2.
       
   188          * @param aY2 : y coordinate for control point 2.
       
   189          * @param aAbsolute : flag to indicate values are absolute or not.
       
   190          * @return
       
   191          */
       
   192          void                       ShortQuadToL( TFloatFixPt& aX2,
       
   193                                                           TFloatFixPt& aY2,
       
   194                                                           TBool aAbsolute );
       
   195 
       
   196 
       
   197 
       
   198         /**
       
   199          * Clear all path info.
       
   200          *
       
   201          * @since 1.0
       
   202          * @return
       
   203          */
       
   204          void                       Reset();
       
   205 
       
   206         /**
       
   207          * Append the given points to this path.
       
   208          *
       
   209          * @since 1.0
       
   210          * @param aItr : points to append.
       
   211          * @return
       
   212          */
       
   213          void                       AppendL( CGfxPathIterator* aItr );
       
   214 
       
   215 
       
   216         // Implementation of MGfxShape
       
   217 
       
   218         /**
       
   219          * Get the bounding box for this path.
       
   220          *
       
   221          * @since 1.0
       
   222          * @param aAt : transform to apply.
       
   223          * @param aRect : bounding box info holder.
       
   224          * @return
       
   225          */
       
   226          void                       GetBounds( const TGfxAffineTransform& aAt,
       
   227                                                        TGfxRectangle2D& aRect );
       
   228 
       
   229         /**
       
   230          * Get the iterator for this path.
       
   231          *
       
   232          * @since 1.0
       
   233          * @param aAt : transform to apply.
       
   234          * @param aPitr : iterator info for this path.
       
   235          * @return
       
   236          */
       
   237          void                       GetPathIteratorL( TGfxAffineTransform* aAt,
       
   238                                                               CGfxPathIterator*& aPitr );
       
   239 
       
   240         /**
       
   241          * Get the iterator for this path.
       
   242          *
       
   243          * @since 1.0
       
   244          * @param aAt : transform to apply.
       
   245          * @param aLimit : maximum number of points to define path.
       
   246          * @param aPitr : iterator info for this path.
       
   247          * @return
       
   248          */
       
   249          void                       GetPathIteratorL( TGfxAffineTransform* aAt,
       
   250                                                               TInt aLimit,
       
   251                                                               CGfxPathIterator*& aPitr );
       
   252         /**
       
   253          * Get the area for this path.
       
   254          *
       
   255          * @since 1.0
       
   256          * @return area of path.
       
   257          */
       
   258         TFloatFixPt AreaSize();
       
   259 
       
   260         /**
       
   261          * Get the pointer to the type array.
       
   262          *
       
   263          * @since 1.0
       
   264          * @return type info array pointer
       
   265          */
       
   266          RArray<TUint32>* PointTypeArray();
       
   267          unsigned char* PathSegmentTypeArray();
       
   268          void PathSegmentTypeArray(unsigned char* aSegmentTypeArray);
       
   269          TUint8 CGfxGeneralPath::Count();
       
   270          void CGfxGeneralPath::Count(TUint8 aCount);
       
   271 
       
   272         /**
       
   273          * Get the pointer to the coordinate array.
       
   274          *
       
   275          * @since 1.0
       
   276          * @return coordinate array.
       
   277          */
       
   278          TFloatFixPt* PointCoordsArray();
       
   279 
       
   280         /**
       
   281          * Get the pointer to the type array.
       
   282          *
       
   283          * @since 1.0
       
   284          * @return type info array pointer
       
   285          */
       
   286          RArray<TFloatFixPt>* PointCoordsArrayAll();
       
   287 
       
   288         /**
       
   289          * Set the pointer to the type array.
       
   290          *
       
   291          * @since 1.0
       
   292          * @param aTypesArray : type info array pointer
       
   293          * @return
       
   294          */
       
   295          void       SetPointTypeArrayL( RArray<TUint32>* aTypesArray );
       
   296 
       
   297 		// used in decoding to avoid local copying
       
   298 		 void       SetPointTypeArrayRef( RArray<TUint32>*& aTypesArray );
       
   299 
       
   300         /**
       
   301          * Set the pointer to the coordinate array.
       
   302          *
       
   303          * @since 1.0
       
   304          * @param aPointCoords : coordinate array.
       
   305          * @return
       
   306          */
       
   307          void       SetPointCoordsArrayL( RArray<TFloatFixPt>* aPointCoords );
       
   308 
       
   309 		// used in decoding to avoid local copying
       
   310     	  void       SetPointCoordsArrayRef( RArray<TFloatFixPt>*& aPointCoords );
       
   311 
       
   312 
       
   313         /* Return shape type */
       
   314         inline virtual TInt ShapeType () { return EPath; };
       
   315 
       
   316 		/* gives the total number of segments in the path elementL */
       
   317 		 TInt GetSegmentCount();
       
   318 
       
   319 		/* gives the  segmentType in the path elementL */
       
   320 		 TInt GetSegmentType(TInt aSegmentIndex );
       
   321 
       
   322 		/* gives the  */
       
   323 		 TReal32 GetSegmentParameter(TInt aSegmentIndex ,TInt aParameterIndex);
       
   324 		void IsHorizontalLineOrVertical(TInt aSegmentIndex, TBool& aHorizontal, TBool& aVertical);
       
   325 
       
   326 		 CGfxGeneralPath* CloneL();
       
   327 		 void QuadToLWithNoControlPoint(TFloatFixPt aX, TFloatFixPt aY);
       
   328 
       
   329     protected:
       
   330 
       
   331         /**
       
   332          * Constructor
       
   333          *
       
   334          * @since 1.0
       
   335          * @return
       
   336          */
       
   337                             CGfxGeneralPath();
       
   338 
       
   339         /**
       
   340          * Second phase of construction.
       
   341          *
       
   342          * @since 1.0
       
   343          * @return
       
   344          */
       
   345         void                ConstructL();
       
   346 
       
   347 
       
   348         /**
       
   349          * Get the curve reference point for this last curve.
       
   350          *
       
   351          * @since 1.0
       
   352          * @param aX : storage for x coordinate of reference point.
       
   353          * @param aY : storage for y coordinate of reference point.
       
   354          * @return
       
   355          */
       
   356         void                GetCurveRefPoint( TFloatFixPt& aX, TFloatFixPt& aY );
       
   357 
       
   358     protected:
       
   359         RArray<TUint32>*     iPointTypes;
       
   360         unsigned char*       iPathSegmentTypeArray;
       
   361         TUint8               iCount;
       
   362         RArray<TFloatFixPt>*     iPointCoords;
       
   363 
       
   364         TFloatFixPt              iLastX;
       
   365         TFloatFixPt              iLastY;
       
   366 
       
   367     private:
       
   368         friend class        CGfxGeneralPathIteratorP;
       
   369     };
       
   370 
       
   371 #endif      // GFXGENERALPATH_H