extender.h

Go to the documentation of this file.
00001 // $Id: extender.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 //
00099 
00100 #ifndef INC_EXTENDER
00101 #define INC_EXTENDER
00102 
00103 //#include "doccoord.h" // for DocCoord member variables - in camtypes.h [AUTOMATICALLY REMOVED]
00104 
00105 // types of extend-action.
00106 static const BYTE X_EXTEND  = 1;
00107 static const BYTE Y_EXTEND  = 2;
00108 static const BYTE X_STRETCH = 4;
00109 static const BYTE Y_STRETCH = 8;
00110 
00111 // an extend buffer-zone constant, in DocCoord units (millipoints).
00112 // points on or within this distance from the centre-point must not extend out.
00113 static const INT32      EXT_EXPAND_BUFFER = 10;
00114 
00115 // an extend shrinking buffer-zone constant. this must be 1mp bigger than the expanding
00116 // buffer-zone, so that coords are never shrunk down to be next to that zone. this is
00117 // because rounding errors may arbitrarily shift coords by 1mp, thus making previously
00118 // valid points invariant under expansion.
00119 static const INT32      EXT_SHRINK_BUFFER = EXT_EXPAND_BUFFER + 1;
00120 
00121 /********************************************************************************************
00122 
00123 >   class ExtendParams : public CC_CLASS_MEMDUMP
00124 
00125     Author:     Karim_MacDonald (Xara Group Ltd) <camelotdev@xara.com>
00126     Created:    10/09/1999
00127     Purpose:    Parameter container for extension operation.
00128     See also:   
00129 
00130 ********************************************************************************************/
00131 
00132 class ExtendParams : public CC_CLASS_MEMDUMP
00133 {
00134     // Declare the class for memory tracking
00135     CC_DECLARE_MEMDUMP(ExtendParams);
00136 
00137 public:
00138     // default and copy constructor.
00139     ExtendParams() {}
00140     ExtendParams(const ExtendParams& other)
00141     {
00142         fExtendFlags    = other.fExtendFlags;
00143         xinc            = other.xinc;
00144         xdec            = other.xdec;
00145         yinc            = other.yinc;
00146         ydec            = other.ydec;
00147         doccEndCentre   = other.doccEndCentre;
00148         doccStartCentre = other.doccStartCentre;
00149         doccOffset      = other.doccOffset;
00150         xscale          = other.xscale;
00151         yscale          = other.yscale;
00152         doccScaleStart  = other.doccScaleStart;
00153         doccScaleEnd    = other.doccScaleEnd;
00154         xincExtendBuffer= other.xincExtendBuffer;
00155         xdecExtendBuffer= other.xdecExtendBuffer;
00156         yincExtendBuffer= other.yincExtendBuffer;
00157         ydecExtendBuffer= other.ydecExtendBuffer;
00158         pOp             = other.pOp;
00159     }
00160 
00161     // data.
00162     BYTE fExtendFlags;          // the type of extending required.
00163     INT32 xinc;                 // displacement of points in the positive x-direction
00164     INT32 xdec;                 // displacement of points in the negative x-direction
00165     INT32 yinc;                 // displacement of points in the positive y-direction
00166     INT32 ydec;                 // displacement of points in the negative y-direction
00167     DocCoord doccEndCentre;     // end-centre of extension; defines extension limits.
00168     DocCoord doccStartCentre;   // start-centre of extension; defines extension behaviour.
00169     DocCoord doccOffset;        // the displacement vector from start- to end- centres.
00170     double xscale;              // x-direction scaling factor
00171     double yscale;              // y-direction scaling factor
00172     DocCoord doccScaleStart;    // the scaling origin of the Node.
00173     DocCoord doccScaleEnd;      // the result of transforming doccScaleStart.
00174     INT32 xincExtendBuffer;     // the size of the dead zone in the +ve x-direction.
00175     INT32 xdecExtendBuffer;     // the size of the dead zone in the -ve x-direction.
00176     INT32 yincExtendBuffer;     // the size of the dead zone in the +ve y-direction.
00177     INT32 ydecExtendBuffer;     // the size of the dead zone in the -ve y-direction.
00178     UndoableOperation * pOp;
00179 };
00180 
00181 
00182 
00183 /********************************************************************************************
00184 
00185 >   class Extender : public CC_CLASS_MEMDUMP
00186 
00187     Author:     Karim_MacDonald (Xara Group Ltd) <camelotdev@xara.com>
00188     Created:    10/09/1999
00189     Purpose:    Preliminary container class for Extend() function.
00190                 This performs automatic extension and stretching of nodes.
00191 
00192                 Stretching is defined as application of a matrix transformation to control
00193                 points, causing the points to scale and translate. The distance a point is
00194                 moved depends on its own distance from some centre - think 'x -> ax+b'.
00195 
00196                 Extension is defined as translation of control points, depending on their
00197                 initial position. All points are moved by the same fixed amount, although the
00198                 *direction* follows the same rules as for stretching - 'x -> x +/- delta'.
00199     See also:   
00200 
00201 ********************************************************************************************/
00202 
00203 class Extender : public CC_CLASS_MEMDUMP
00204 {
00205 
00206 // Declare the class for memory tracking
00207 CC_DECLARE_MEMDUMP(Extender);
00208 
00209 public:
00210     static DocRect CheckValidExtend(NodeRenderableInk* pNode, BYTE fExtendFlags,
00211                                     const DocRect& drTriggerRelation,
00212                                     const DocRect& drTargetRelation,
00213                                     const DocRect& drThisTrigger,
00214                                     const DocRect& drLastTrigger,
00215                                     const DocRect& drLastTarget,
00216                                     BOOL * pOK = NULL,
00217                                     const BOOL ExtendAroundTarget = FALSE);
00218 
00219     static void Extend( NodeRenderableInk* pNode, BYTE fExtendFlags,
00220                         const DocRect& drTriggerRelation, const DocRect& drTargetRelation,
00221                         const DocRect& drNewTrigger, const DocRect& drLastTrigger,
00222                         const DocRect& drLastTarget, const DocRect* pdrDifference = NULL,
00223                         const BOOL ExtendAroundTarget = FALSE,
00224                         UndoableOperation * pOp = NULL);
00225 
00226     static BOOL ConvertQuickShapesInSelRangeToPaths(    UndoableOperation* pUndoOp,
00227                                                         Range* pRange );
00228 
00229     static BOOL CheckValidExtend(   NodeRenderableInk* pNode,
00230                                     DocRect* pStartRect,
00231                                     DocRect* pEndRect,
00232                                     BYTE fStretchType,
00233                                     DocRect* pOldStartRect = NULL);
00234 
00235     static void Extend( NodeRenderableInk* pNode,
00236                         DocRect* pStartRect,
00237                         DocRect* pEndRect,
00238                         BYTE fStretchType,
00239                         DocRect* pOldStartRect = NULL );
00240 
00241     static DocRect ValidateControlPoints(INT32 numPoints, const DocCoord* doccArray, const ExtendParams& ExtParams);
00242 
00243     static void CalculateExtendParams(ExtendParams* pEPS, BYTE fExtendFlags,
00244                         const DocRect& drTriggerRelation, const DocRect& drTargetRelation,
00245                         const DocRect& drNewTrigger, const DocRect& drLastTrigger,
00246                         const DocRect& drLastTarget, const DocRect* pdrDifference = NULL,
00247                         const BOOL ExtendAroundTarget = FALSE);
00248 
00249 private:
00250     static INT32 CheckInvalidShrinkingPoints(INT32 nCentre, INT32 nDelta, INT32 nOffset,
00251                                             INT32 nNumPoints, const DocCoord* doccArray,
00252                                             BOOL bExamineX);
00253     static INT32 CheckInvalidExpandingPoints(INT32 nCentre, INT32 nDelta, INT32 nOffset,
00254                                             INT32 nNumPoints, const DocCoord* doccArray,
00255                                             BOOL bExamineX);
00256     static INT32 CheckLimits(const INT32 limit, const INT32 delta, const INT32 value);
00257 };
00258 
00259 #endif  // !INC_EXTENDER

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