gmould.h

Go to the documentation of this file.
00001 // $Id: gmould.h 751 2006-03-31 15:43:49Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 // Header for the base class mould shapes implementation
00099 
00100 #ifndef INC_GMOULD
00101 #define INC_GMOULD
00102 
00103 /********************************************************************************************
00104 
00105 >   class GMould : public CCObject
00106 
00107     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com> / Peter
00108     Created:    21/01/97
00109     Purpose:    common functions used GEnvelope and GPerspective are held in this base class.
00110 
00111 ********************************************************************************************/
00112 
00113 /*
00114 
00115 void Define( POINT *P, RECT *pBBox, DWORD pTolerance = 0 ) ;
00116 
00117     Define the envelope with twelve control points P. The source path has bounding box pBBox.
00118     pTolerance defines the accuracy with which curves are moulded. If pTolerance is zero then
00119     curves are never split.
00120 
00121 void FitPoint(  POINT a, POINT& b ) ;
00122 
00123     This will mould the point a returning the result in b. Note that a may be outside the
00124     original bounding box.
00125 
00126 void FitPoint( DPOINT a, POINT& b ) ;
00127 
00128     This will mould the point a specified as two values in the range 0 to 1. The result is
00129     returned in b. This call can be used for drawing grid points.
00130 
00131 void PlotTile(
00132     void* pData,
00133     void PlotTriangle(
00134         void* pData,
00135         CONST POINT *PointA, CONST POINT *PointB, CONST POINT *PointC,
00136         CONST POINT *Point0, CONST POINT *Point1, CONST POINT *Point2
00137     ),
00138     CONST POINT *PointA, CONST POINT *PointB, CONST POINT *PointC,
00139     CONST INT32 Steps
00140 ) ;
00141 
00142     This call can be used to plot a bitmap by splitting the bitmap into triangles. The bitmap
00143     area is defined by the three points PointA, PointB and PointC. Steps controls the fineness of
00144     the approximation. The PlotTriangle routine is called to plot each triangle in turn. It is
00145     passed pData and the new bitmap control points PointA, PointB, PointC and the triangle
00146     boundary points Point0, Point1, Point2. pData can be used as a pointer to a data block
00147     containing such information as the bitmap size.
00148 
00149 void PlotTile4(
00150     void* pData,
00151     void PlotTriangle(
00152         void* pData,
00153         CONST POINT *PointA, CONST POINT *PointB, CONST POINT *PointC,
00154         CONST POINT *Point0, CONST POINT *Point1, CONST POINT *Point2
00155     ),
00156     CONST POINT *PointA, CONST POINT *PointB, CONST POINT *PointC, CONST POINT *PointD,
00157     CONST INT32 Steps
00158 ) ;
00159 
00160     This call can be used to plot a bitmap by splitting the bitmap into triangles. The bitmap
00161     area is defined by the three points PointA, PointB, PointC and PointD. Other parameters are
00162     as for PlotTile.
00163 
00164 */
00165 
00166 
00167 class GPerspective ;
00168 
00169 class GMould : public CCObject
00170 {
00171     CC_DECLARE_DYNAMIC(GMould)
00172     
00173     public:
00174         GMould();
00175 
00176         BOOL Define( POINT *P, RECT *pBBox, DWORD pTolerance = 0 );
00177         
00178         virtual void CopyShape( POINT *P ) = 0;
00179         virtual BOOL Redefine( POINT *P ) = 0 ;
00180         virtual BOOL FitPath(CONST POINT *IPoints,  
00181                              CONST BYTE  *ITypes, 
00182                              DWORD ILength,
00183                              LPPOINT OPoints, 
00184                              LPBYTE  OTypes, 
00185                              DWORD OLength, 
00186                              BOOL Close = FALSE) = 0;
00187 
00188         void    FitPoint( POINT a, POINT& b );
00189         void    FitPoint( DPOINT a, POINT& b );
00190         DocRect GetBoundingRect();
00191         RECT    GetSourceBBox() const { return SrcBBox; }
00192 
00193     /*
00194         void PlotTile(
00195             void* pData,
00196             void PlotTriangle(
00197                 void* pData,
00198                 CONST POINT *PointA, CONST POINT *PointB, CONST POINT *PointC,
00199                 CONST POINT *Point0, CONST POINT *Point1, CONST POINT *Point2
00200             ),
00201             CONST POINT *PointA, CONST POINT *PointB, CONST POINT *PointC,
00202             CONST INT32 Steps
00203         ) ;
00204         void PlotTile4(
00205             void* pData,
00206             void PlotTriangle(
00207                 void* pData,
00208                 CONST POINT *PointA, CONST POINT *PointB, CONST POINT *PointC,
00209                 CONST POINT *Point0, CONST POINT *Point1, CONST POINT *Point2
00210             ),
00211             CONST POINT *PointA, CONST POINT *PointB, CONST POINT *PointC, CONST POINT *PointD,
00212             CONST INT32 Steps
00213         ) ;
00214     */
00215 
00216 
00217     protected:
00218         double CalcTolerance( DWORD pTolerance );
00219         
00220         inline BOOL GenOp( BYTE Op, DPOINT T );
00221         inline BOOL GenMove( DPOINT T );
00222         inline BOOL GenLine( DPOINT T );
00223         
00224         void        ScaleSrc(  POINT a, DPOINT& b ) ;
00225         void           Scale(  POINT a, DPOINT& b ) ;
00226         void    InverseScale( DPOINT a,  POINT& b ) ;
00227 
00228         BOOL    GenCurve( DPOINT C2, DPOINT C4, 
00229                           DPOINT P0, DPOINT P2, DPOINT P4, DPOINT P6,
00230                           DPOINT T0, DPOINT T2, DPOINT T4, DPOINT T6 );
00231 
00232         virtual void ScaleView() = 0;
00233         virtual void CalcViewBBox() = 0;
00234         virtual void CalcViewConsts() = 0;
00235         virtual void Transform( DPOINT a, DPOINT& b ) = 0;
00236 
00237     protected:
00238         RECT    SrcBBox ;
00239         INT32    MinX, MaxX, MinY, MaxY;
00240         INT32   Width, Depth ;
00241 
00242         double  Tolerance ;
00243         LPPOINT OPoints ; 
00244         LPBYTE  OTypes ; 
00245         DWORD   OLength ;
00246 
00247 
00248     /*
00249         void PlotTile(
00250             void* pData,
00251             void PlotTriangle(
00252                 void* pData,
00253                 CONST POINT *PointA, CONST POINT *PointB, CONST POINT *PointC,
00254                 CONST POINT *Point0, CONST POINT *Point1, CONST POINT *Point2
00255             ),
00256             CONST INT32 Tolerance,
00257             INT32 i, INT32 j, INT32 s,
00258             POINT p00, POINT p10, POINT p11, POINT p01,
00259             POINT q00, POINT q10, POINT q11, POINT q01,
00260             BOOL f00_10, BOOL f10_11, BOOL f01_11, BOOL f00_01
00261         ) ;
00262         void PlotTile4(
00263             void* pData,
00264             void PlotTriangle(
00265                 void* pData,
00266                 CONST POINT *PointA, CONST POINT *PointB, CONST POINT *PointC,
00267                 CONST POINT *Point0, CONST POINT *Point1, CONST POINT *Point2
00268             ),
00269             CONST INT32 Tolerance,
00270             GPerspective* Per,
00271             INT32 i, INT32 j, INT32 s,
00272             POINT p00, POINT p10, POINT p11, POINT p01,
00273             POINT q00, POINT q10, POINT q11, POINT q01,
00274             BOOL f00_10, BOOL f10_11, BOOL f01_11, BOOL f00_01
00275         ) ;
00276         void PlotTriangles(
00277             void* pData,
00278             void PlotTriangle(
00279                 void* pData,
00280                 CONST POINT *PointA, CONST POINT *PointB, CONST POINT *PointC,
00281                 CONST POINT *Point0, CONST POINT *Point1, CONST POINT *Point2
00282             ),
00283             INT32 i, INT32 j, INT32 s,
00284             POINT q00, POINT q10, POINT q11, POINT q01
00285         ) ;
00286     */
00287 
00288 };
00289 
00290 
00291 inline BOOL GMould::GenOp( BYTE Op, DPOINT T )
00292 {
00293     if ( OLength-- < 1 ) return FALSE ;
00294     InverseScale( T, *OPoints++ ) ; *OTypes++ = Op ;
00295     return TRUE ;
00296 }
00297 
00298 inline BOOL GMould::GenMove( DPOINT T )
00299 {
00300     return GenOp( PT_MOVETO, T );
00301 }
00302 
00303 inline BOOL GMould::GenLine( DPOINT T )
00304 {
00305     return GenOp( PT_LINETO, T );
00306 }
00307 
00308 
00309 #endif

Generated on Sat Nov 10 03:45:27 2007 for Camelot by  doxygen 1.4.4