00001 // $Id: moldenv.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 // Header for the envelope mould shapes implementation 00099 00100 #ifndef INC_ENVELOPE 00101 #define INC_ENVELOPE 00102 00103 #include "moldshap.h" 00104 //#include "ops.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00105 #include "nodemold.h" 00106 #include "gmould.h" 00107 00108 #define ENV_NUMCOORDS 12 00109 #define ENV_NUMCOORDS2X2 24 00110 #define ENV_MAXCOORDS 24 00111 00112 /******************************************************************************************** 00113 00114 > class MouldEnvelopeBase : public MouldGeometry 00115 00116 Author: Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com> 00117 Created: 5/12/94 00118 Purpose: The envelope mould node. Provides control over a coons patch shape made 00119 from 4 connected 3rd order bezier splines. 00120 00121 ********************************************************************************************/ 00122 00123 class MouldEnvelopeBase : public MouldGeometry 00124 { 00125 friend class RecordEnvelopeAction; 00126 00127 CC_DECLARE_DYNAMIC(MouldEnvelopeBase); 00128 00129 public: 00130 MouldEnvelopeBase(); 00131 ~MouldEnvelopeBase(); 00132 00133 virtual void RenderControlBlobs(RenderRegion* pRegion); 00134 virtual void RenderDragBlobs(Spread* pSpread); 00135 virtual void DisableControlBlobs(); 00136 virtual void EnableControlBlobs(); 00137 virtual void ToggleControlBlobs(Spread* pSpread); 00138 00139 // functions to create a moulded object 00140 virtual BOOL MouldPathToPath(Path* pSourcePath, Path* PDestinPath); 00141 virtual BOOL MouldBitmapToTile(KernelBitmap* pSourceBlit, KernelBitmap* pDestinBlit); 00142 virtual BOOL MouldPoint(DocCoord p,DocCoord& q); 00143 00144 // functions to render an object through the mould 00145 virtual void MouldPathRender(Path* pPath, Spread* pSpread); 00146 virtual void MouldBitmapRender(KernelBitmap* pBlit, DocCoord* pParallel, RenderRegion* pRegion); 00147 00148 virtual DocRect GetSourceRect(); 00149 00150 protected: 00151 BOOL Define(Path* const pPath, DocRect* const pOrigBBox, INT32 ncoords); 00152 00153 RECT BuildRectangle(DocRect* const pOrigBBox); 00154 BOOL BuildShape(POINT* pPoints, DocRect* const pOrigBBox); 00155 BOOL ConvertShape(INT32 ncoords, POINT* dPoints, Path* const pPath, const INT32 numcoords); 00156 00157 void RenderGrid(Spread* pSpread); 00158 void RenderGrid(RenderRegion* pRegion); 00159 void RenderGridPoints(RenderRegion* pRegion); 00160 00161 BOOL ValidMouldingPath(INT32 ncoords, INT32 nelements, Path* const pPath, UINT32& errorID); 00162 static BOOL WillBeValid(INT32 ncoords, POINT* P); 00163 00164 protected: 00165 GMould *pEnvelope; 00166 00167 private: 00168 INT32 BlobState; 00169 }; 00170 00171 00172 00173 /******************************************************************************************** 00174 00175 > class MouldEnvelope : public MouldEnvelopeBase 00176 00177 Author: Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com> 00178 Created: 5/12/94 00179 Purpose: The envelope mould node. Provides control over a coons patch shape made 00180 from 4 connected 3rd order bezier splines. 00181 00182 ********************************************************************************************/ 00183 00184 class MouldEnvelope : public MouldEnvelopeBase 00185 { 00186 CC_DECLARE_DYNAMIC(MouldEnvelope); 00187 00188 public: 00189 MouldEnvelope(); 00190 ~MouldEnvelope(); 00191 00192 virtual BOOL Initialise(); 00193 00194 virtual BOOL Validate(Path* const pPath, UINT32& errorID); 00195 virtual BOOL Define(Path* const pPath, DocRect* const pRect); 00196 virtual BOOL MakeValidFrom(Path **Out, Path *In, INT32 *CornersHint = 0); 00197 virtual MouldSpace Describe() {return MOULDSPACE_ENVELOPE;} 00198 00199 virtual void Transform(Path* const pPath, DocRect* const pRect, TransformBase& Trans); 00200 virtual ChangeCode RecordContext(UndoableOperation*); 00201 virtual UINT32 GetByteSize() const { return sizeof(MouldEnvelope); }; 00202 00203 virtual MouldGeometry* MakeCopy(); 00204 00205 public: 00206 // none virtual functions local to this class. 00207 static BOOL WillBeValid(POINT* P); 00208 00209 protected: 00210 BOOL CopyContents(MouldEnvelope* pGeom); 00211 00212 private: 00213 const INT32 EnvNumCoords; 00214 }; 00215 00216 00217 00218 /******************************************************************************************** 00219 00220 > class MouldEnvelope2x2 : public MouldEnvelopeBase 00221 00222 Author: Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com> 00223 Created: 22/11/95 00224 Purpose: Another envelope mould. Provides control over a coons patch shape made 00225 from 2x2 4 connected 3rd order bezier splines. 00226 00227 ********************************************************************************************/ 00228 00229 class MouldEnvelope2x2 : public MouldEnvelopeBase 00230 { 00231 CC_DECLARE_DYNAMIC(MouldEnvelope2x2); 00232 00233 public: 00234 MouldEnvelope2x2(); 00235 ~MouldEnvelope2x2(); 00236 00237 virtual BOOL Initialise(); 00238 00239 virtual BOOL Validate(Path* const pPath, UINT32& errorID); 00240 virtual BOOL Define(Path* const pPath, DocRect* const pRect); 00241 virtual BOOL MakeValidFrom(Path **Out, Path *In, INT32 *CornersHint = 0); 00242 virtual MouldSpace Describe() {return MOULDSPACE_ENVELOPE2X2;} 00243 00244 virtual void Transform(Path* const pPath, DocRect* const pRect, TransformBase& Trans); 00245 virtual ChangeCode RecordContext(UndoableOperation*); 00246 virtual UINT32 GetByteSize() const { return sizeof(MouldEnvelope2x2); }; 00247 00248 virtual MouldGeometry* MakeCopy(); 00249 00250 public: 00251 // none virtual functions local to this class. 00252 static BOOL WillBeValid(POINT* P); 00253 00254 protected: 00255 BOOL CopyContents(MouldEnvelope2x2* pGeom); 00256 00257 private: 00258 const INT32 EnvNumCoords; 00259 }; 00260 00261 00262 /******************************************************************************************** 00263 00264 > class EnvelopeShapes 00265 00266 Author: Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com> 00267 Created: 11/12/94 00268 Purpose: The default envelope shapes class. This class provides a bunch of static 00269 functions to create some default shapes. All shapes are defined on a 00270 (0,0),(72000,72000) coordinate system. 00271 00272 ********************************************************************************************/ 00273 00274 class EnvelopeShapes 00275 { 00276 public: 00277 static BOOL Rectangular(Path* pPath); 00278 static BOOL Rectangular2x2(Path* pPath); 00279 static BOOL Circular(Path* pPath); 00280 static BOOL Concave(Path* pPath); 00281 static BOOL Banner(Path* pPath); 00282 00283 private: 00284 static BOOL MakeEllipse(DocRect* pRect, Path* pPath,PathFlags* pFlags); 00285 }; 00286 00287 00288 00289 /******************************************************************************************** 00290 00291 class RecordEnvelopeAction : public Action 00292 00293 Author: Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com> 00294 Created: 16/01/95 00295 Purpose: This class records undo/redo information for the Envelope shape object. 00296 00297 ********************************************************************************************/ 00298 00299 class RecordEnvelopeAction : public Action 00300 { 00301 CC_DECLARE_DYNCREATE(RecordEnvelopeAction) 00302 00303 public: 00304 RecordEnvelopeAction(); 00305 ~RecordEnvelopeAction(); 00306 virtual ActionCode Execute(); 00307 static ActionCode Init( Operation* pOp, 00308 ActionList* pActionList, 00309 MouldEnvelopeBase* pRecEnvelope, 00310 Action** NewAction); 00311 private: 00312 MouldEnvelopeBase* pCEnvelope; 00313 POINT RecordArray[ENV_MAXCOORDS]; 00314 }; 00315 00316 #endif