pathproc.h

Go to the documentation of this file.
00001 // $Id: pathproc.h 1282 2006-06-09 09:46: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 // Definition of the processpath classes
00099 
00100 #ifndef INC_PATHPROC
00101 #define INC_PATHPROC
00102 
00103 //#include "paths.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00104 //#include "ccobject.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00105 
00106 #define PROC_CACHE_SIZE 0x1000
00107 
00108 
00109 /******************************************************************************************
00110 
00111 >   class ProcessFlags
00112 
00113     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00114     Created:    25/10/94
00115     Purpose:    
00116 
00117 ******************************************************************************************/
00118 
00119 class ProcessFlags
00120 {
00121 public:
00122     ProcessFlags(BOOL flatten = TRUE, BOOL quantise = FALSE, BOOL quantiseall = FALSE);
00123 
00124     BYTE FlattenCurves : 1;
00125     BYTE QuantiseLines : 1;
00126     BYTE QuantiseAll : 1;
00127 };
00128 
00129 
00130 
00131 /******************************************************************************************
00132 
00133 >   class ProcessPath
00134 
00135     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00136     Created:    25/10/94
00137     Purpose:    
00138 
00139 ******************************************************************************************/
00140 
00141 class ProcessPath : public CCObject
00142 {
00143     CC_DECLARE_DYNAMIC(ProcessPath);
00144 
00145     public:
00146         ProcessPath(const double flat);
00147         ~ProcessPath();
00148 
00149         BOOL    Init(Path* pSource);
00150         BOOL    Process(const ProcessFlags& PFlags);
00151         
00152         virtual void OpenElement(PathVerb Verb, INT32 index);
00153         virtual BOOL NewPoint(PathVerb Verb, DocCoord* pCoord) = 0;
00154         virtual BOOL CloseElement(BOOL ok, PathVerb Verb, INT32 index);
00155         virtual void CloseFigure(void);
00156         
00157     protected:
00158         BOOL    FlattenCurve(INT32 Px0,INT32 Py0, INT32 Px1,INT32 Py1,
00159                              INT32 Px2,INT32 Py2, INT32 Px3,INT32 Py3, BOOL QuantiseAll=FALSE);
00160         BOOL    FlattenSplit(INT32 Px0,INT32 Py0, INT32 Px1,INT32 Py1,
00161                              INT32 Px2,INT32 Py2, INT32 Px3,INT32 Py3, BOOL QuantiseAll=FALSE);
00162         virtual BOOL InsertQuantisedLineTo(DocCoord * pEnd, DocCoord * pStart);
00163 
00164     protected:
00165         Path*       ProcSource;
00166         INT32*      ProcCache;              // Cache pointer for flattening
00167         INT32       ProcNumCached;          // Number of entries in cache
00168         BOOL        ProcFirstPoint;         // True if first point not processed yet
00169         double      ProcFlatness;           // <0 then dont flatten curves, approx 64 is good
00170 
00171         DocCoord    ProcPreviousEl;         // coord of previous element point
00172         
00173 };
00174 
00175 
00176 /******************************************************************************************
00177 
00178 >   class FlattenPath
00179 
00180     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00181     Created:    25/10/94
00182     Purpose:    Flattens a path to the user specified output buffer using a 
00183                 given flatness
00184 
00185 ******************************************************************************************/
00186 
00187 class ProcessFlatten : public ProcessPath
00188 {
00189     public:
00190         ProcessFlatten(const double flat);
00191         BOOL FlattenPath(const ProcessFlags& PFlags, Path* pSource, Path* pDestin);
00192         virtual BOOL NewPoint(PathVerb Verb, DocCoord* pCoord);
00193 
00194     private:
00195         Path*   FlattenOutput;
00196 
00197 };
00198 
00199 
00200 
00201 /******************************************************************************************
00202 
00203 >   class ProcessLength
00204 
00205     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00206     Created:    25/10/94
00207     Purpose:    Calculates the length of a path
00208 
00209 ******************************************************************************************/
00210 
00211 class ProcessLength : public ProcessPath
00212 {
00213     public:
00214         ProcessLength(const double flat);
00215         BOOL PathLength(Path* Input, double* Length, INT32 Index = -1);
00216         virtual void OpenElement(PathVerb Verb, INT32 index);
00217         virtual BOOL NewPoint(PathVerb Verb, DocCoord* pCoord);
00218         virtual BOOL CloseElement(BOOL ok, PathVerb Verb, INT32 index);
00219 
00220     private:
00221         DocCoord PrevCoord;
00222         double   ElementLength;
00223         double   CurrLength;
00224         INT32    UserIndex;
00225 };
00226 
00227 
00228 
00229 /******************************************************************************************
00230 
00231 >   class ProcessDistance
00232 
00233     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00234     Created:    25/10/94
00235     Purpose:    If a platonic piece of string whose length l and endpoints (p0,p1) is laid 
00236                 along a path [e0,e1,e2,....en], this class calculates the index of the 
00237                 element ei, which contains p1 and the parameter mu (0<=mu<1) which can be 
00238                 used to calculate the actual coordinate value of p1.
00239                 
00240 ******************************************************************************************/
00241 
00242 class ProcessDistance : public ProcessPath
00243 {
00244     public:
00245         ProcessDistance(const double flat);
00246         double PathDistance(const double dist, Path* Input, INT32* index);
00247         virtual void OpenElement(PathVerb Verb, INT32 index);
00248         virtual BOOL NewPoint(PathVerb Verb, DocCoord* pCoord);
00249         virtual BOOL CloseElement(BOOL ok, PathVerb Verb, INT32 index);
00250 
00251     private:
00252         double      Distance;
00253         INT32       ElementIndex;
00254         double      ElementLength;
00255         double      ElementParam;
00256         DocCoord    PrevCoord;
00257 };
00258 
00259 
00260 /******************************************************************************************
00261 >   class ProcessPathDistance : ProcessPath
00262 
00263     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
00264     Created:    9/4/95
00265     Purpose:    Process path to find Coord and Tangent at specified distance along path
00266 
00267     Additional: Diccon 2/12/99 - I have made some additions to this class with the intention
00268                 of making it so that you can instantiate a PPD object and use it repeatedly
00269                 to find points on a path without always traversing the path form the beginning.
00270                 Unfortunately time pressure means that at the moment it is not finished except 
00271                 for its particular application to the Brush.  If I get time I will 
00272                 endeavour to make it generalised, but for now use with care.
00273     
00274 ******************************************************************************************/
00275 
00276 class ProcessPathDistance : public ProcessPath
00277 {
00278     public:
00279         ProcessPathDistance(const double flat);
00280         BOOL GetCoordAndTangent(DocCoord* pCoord, double* pTangent, BOOL* pFound,
00281                                 double dist, Path* pPath, UINT32* pPressure = NULL);
00282         
00283 
00284         // version called by the nodebrushpath where previous results are cached
00285         INT32 GetCoordAndTangentWithCache(DocCoord* pCoord, double* pTangent, BOOL* pFound,
00286                                     double dist, Path* pPath, UINT32* pPressure = NULL);
00287 
00288         //INT32 GetCoordTangentAndPressure(DocCoord* pCoord, double* pTangent, UINT32* pPressure,
00289         //                              BOOL* pFound, double Dist, Path* pPath);
00290         virtual BOOL NewPoint(PathVerb Verb, DocCoord* pCoord);
00291         BOOL NewPointA(PathVerb Verb, DocCoord* pCoord, UINT32* pPressure = NULL);
00292         
00293         // the cached version of process
00294         INT32   Process(const ProcessFlags& PFlags, INT32 AlreadyProcessed);
00295     private:
00296         double   DesiredDist;
00297         double   CurrentDist;
00298         double   TangentAtDist;
00299         DocCoord CoordAtDist;
00300         UINT32   PressureAtDist;
00301         BOOL     Found;
00302         DocCoord PrevCoord;
00303         UINT32     m_PrevPressure;
00304 
00305         // members used to cache previous results
00306         INT32    m_LastFoundIndex;
00307         BOOL     m_bDrawingBrush;
00308         double   m_LastFoundDistance;
00309 
00310 };
00311 
00312 #endif
00313 

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