moldpers.h

Go to the documentation of this file.
00001 // $Id: moldpers.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 perspective mould shapes implementation
00099 
00100 #ifndef INC_PERSPECTIVE
00101 #define INC_PERSPECTIVE
00102 
00103 #include "moldshap.h"
00104 #include "nodemold.h"
00105 #include "gmould.h"
00106 
00107 #define PER_NUMCOORDS 4
00108 #define PER_UNDEFINED ((INT32)(0x80000000))
00109 
00110 typedef enum PerspectiveClick 
00111 {
00112     PClick_DoNothing,
00113     PClick_EditVPoint0,
00114     PClick_EditVPoint1
00115 };
00116 
00117 
00118 /*******************************************************************************************
00119 
00120 >   class GPerspective : Public GMould
00121 
00122     Author:     Gavin_Theobald (Xara Group Ltd) <camelotdev@xara.com> & Mike
00123     Created:    12/02/94
00124     Purpose:    The perspective function class.
00125 
00126 ********************************************************************************************/
00127 
00128 class GPerspective : public GMould
00129 {
00130     CC_DECLARE_MEMDUMP(GPerspective)
00131 
00132     public:
00133         GPerspective();
00134 
00135         virtual BOOL Redefine( POINT *P ) ;
00136         virtual void CopyShape( POINT *P ) ;
00137         virtual BOOL FitPath(CONST POINT *IPoints,  
00138                              CONST BYTE  *ITypes, 
00139                              DWORD ILength,
00140                              LPPOINT OPoints, 
00141                              LPBYTE  OTypes, 
00142                              DWORD OLength, 
00143                              BOOL Close = FALSE);
00144 
00145         BOOL Valid() ;
00146         BOOL WhichVanishingPoint(POINT v, BOOL& b) ;
00147         void VanishingPoints( POINT& a, POINT& b ) ;
00148         INT32 GetVPointState();
00149         void DragVanishingPoints( POINT& NewI, BOOL Flag, LPPOINT P ) ;
00150 
00151     private:
00152         virtual void ScaleView();
00153         virtual void CalcViewBBox();
00154         virtual void CalcViewConsts();
00155         virtual void Transform( DPOINT a, DPOINT& b ) ;
00156 
00157         void Intersect( DPOINT I, DPOINT P0, DPOINT P1, DPOINT P2, POINT& O ) ;
00158 
00159     private:
00160         POINT  P0, P1, P2, P3 ;
00161         DPOINT V0, V1, V2, V3 ;
00162         BOOL   I0flag, I1flag ;
00163         BOOL   I0pos,  I1pos  ;
00164         DPOINT I0, I1 ;
00165         DPOINT A, B ;
00166 } ;
00167 
00168 
00169 
00170 
00171 /*******************************************************************************************
00172 
00173 >   class MouldPerspective: public MouldGeometry
00174 
00175     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00176     Created:    3/12/94
00177     Purpose:    The perspective mould class. This mould implements a rectangular transform
00178                 with true perspective.
00179 
00180 ********************************************************************************************/
00181 
00182 class MouldPerspective: public MouldGeometry
00183 {
00184     friend class RecordPerspectiveAction;
00185 
00186     CC_DECLARE_DYNAMIC(MouldPerspective);
00187 
00188     public:
00189          MouldPerspective();
00190         ~MouldPerspective();
00191     
00192         // funcs to initialise a perspective
00193         virtual BOOL Validate(Path* const pPath, UINT32& errorID);
00194         virtual BOOL Define(Path* const pPath, DocRect* const pRect);
00195         virtual MouldSpace Describe() {return MOULDSPACE_PERSPECTIVE;}
00196         
00197         // functions to create a moulded object
00198         virtual BOOL MouldPathToPath(Path* pSourcePath, Path* PDestinPath);
00199         virtual BOOL MouldBitmapToTile(KernelBitmap* pSourceBlit, KernelBitmap* pDestinBlit);
00200         virtual BOOL MouldPoint(DocCoord p, DocCoord& q);
00201 
00202         // functions to render an object through the mould
00203         virtual void MouldPathRender(Path* pPath, RenderRegion* pRegion);
00204         virtual void MouldBitmapRender(KernelBitmap* pBlit, DocCoord* pParallel, RenderRegion* pRegion);
00205 
00206         virtual void RenderControlBlobs(RenderRegion* pRegion);
00207         virtual void RenderDragBlobs(Spread* pSpread);
00208         virtual void DisableControlBlobs();
00209         virtual void EnableControlBlobs();
00210         virtual void ToggleControlBlobs(Spread* pSpread);
00211         virtual DocRect GetBlobBoundingRect();
00212         virtual DocRect GetSourceRect();
00213         virtual UINT32 GetByteSize() const { return sizeof(MouldPerspective); };
00214 
00215         virtual BOOL OnClick(DocCoord, ClickType, ClickModifiers, Spread*, NodeMould*);
00216         virtual BOOL OnMouseMove(DocCoord Coord, Spread* pSpread, ClickModifiers Mods, INT32* ctype, INT32* msgres);
00217         virtual void Transform(Path* const pPath, DocRect* const pRect, TransformBase& Trans );
00218         virtual MouldGeometry* MakeCopy();
00219         virtual ChangeCode RecordContext(UndoableOperation*);
00220         virtual ChangeCode RecordBlobs(UndoableOperation* pOp, Spread* pSpread);
00221 
00222     public:
00223         // none virtual functions local to this class.
00224         void GetVanishingPoints(DocCoord& p0, DocCoord& p1);
00225         void MoveVanishingPoints(DocCoord p0, DocCoord p1);
00226         void CopyShape(DocCoord* pCoords);
00227         BOOL MoveVanishingPoint(DocCoord OldPoint, DocCoord& NewPoint);
00228         DocRect CalcBlobClipRect(const DocCoord& p0);
00229 
00230         static BOOL WillBeValid(POINT* P);
00231 
00232     protected:
00233         BOOL CopyContents(MouldPerspective*);
00234         RECT BuildRectangle(DocRect* const pOrigBBox);
00235 
00236     private:
00237         void RenderGrid(Spread* pSpread);
00238         void RenderGrid(RenderRegion* pRegion);
00239         void RenderGridPoints(RenderRegion* pRegion);
00240         void RenderVanishingPoints(Spread* pSpread);
00241         void RenderVanishingPoints(RenderRegion* pRegion);
00242         void RenderVanishingPoint(Spread* pSpread, const DocCoord& dcPos);
00243         BOOL BuildShape(POINT* pPoints, DocRect* const pOrigBBox);
00244         void ShowVPoints();
00245         PerspectiveClick DetermineClickEffect(DocCoord PointerPos,Spread* pSpread);
00246         
00247     private:
00248         INT32 GridState;
00249         GPerspective Perspective;
00250 
00251 };
00252 
00253 
00254 
00255 /********************************************************************************************
00256 
00257 >   class PerspectiveShapes
00258 
00259     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00260     Created:    11/12/94
00261     Purpose:    The default perspective shapes class. This class provides a bunch of static
00262                 functions to create some default shapes. All shapes are defined on a 
00263                 (0,0),(72000,72000) coordinate system. 
00264 
00265 ********************************************************************************************/
00266 
00267 class PerspectiveShapes
00268 {
00269     public:
00270         static BOOL Rectangular(Path* pPath);
00271         static BOOL LeftWall(Path* pPath);
00272         static BOOL RightWall(Path* pPath);
00273         static BOOL Floor(Path* pPath);
00274         static BOOL Ceiling(Path* pPath);
00275 
00276     private:
00277         static BOOL MakeShape(Path* pPath, DocCoord* point);
00278 
00279 };
00280 
00281 
00282 /********************************************************************************************
00283 
00284     class RecordPerspectiveAction : public Action
00285 
00286     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00287     Created:    16/01/95
00288     Purpose:    This class records undo/redo information for the Perspective shape object.
00289     
00290 ********************************************************************************************/
00291 
00292 class RecordPerspectiveAction : public Action
00293 {
00294     CC_DECLARE_DYNCREATE(RecordPerspectiveAction)
00295 
00296     public:
00297          RecordPerspectiveAction();
00298         ~RecordPerspectiveAction();
00299         virtual ActionCode Execute();
00300         static ActionCode Init( Operation* pOp,
00301                                 ActionList* pActionList,
00302                                 MouldPerspective* pPerspective,
00303                                 Action** NewAction);
00304     private:
00305         MouldPerspective*   pCPerspective;
00306         POINT               RecordArray[PER_NUMCOORDS];
00307 };
00308 
00309 
00310 #endif

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