nodebldr.h

Go to the documentation of this file.
00001 // $Id: nodebldr.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 // NodeBlender class. 
00099 
00100 #ifndef INC_NODEBLDR
00101 #define INC_NODEBLDR
00102 
00103 //#include "tranform.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00104 //#include "doccoord.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00105 //#include "docrect.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00106 //#include "ink.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00107 //#include "paths.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00108 #include "blendatt.h"
00109 //#include "becomea.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00110 
00111 class RenderRegion;
00112 class Spread;
00113 class BecomeA;
00114 class HandleBecomeA;
00115 class CCAttrMap;
00116 class Progress;
00117 class BaseCamelotFilter;
00118 class NodeBlendPath;
00119 class NodeBlend;
00120 class Trans2DMatrix;
00121 class BevelNodeParam;
00122 class NodeCompound;
00123 class BitmapFillAttribute;
00124 class AttrBitmapFill;
00125 class NodeGroup;
00126 class SumAllPathsElem;
00127 
00128 /***********************************************************************************************
00129 
00130 >   class BlendPath: public ListItem
00131 
00132     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00133     Created:    11/10/94
00134     Purpose:    This contains a NodePath, plus other data, generated by an object that is blended
00135 
00136 ***********************************************************************************************/
00137 
00138 class BlendPath: public ListItem
00139 {
00140     CC_DECLARE_MEMDUMP(BlendPath);
00141 public:
00142     BlendPath();
00143     ~BlendPath();
00144 
00145     // DMc change
00146     // previously this operated purely on node paths (see the commented out areas)
00147     // however, to cope with compound nodes such as contours, bevels & shadows this
00148     // is now impossible so it has to work on NodeRenderableInks
00149 
00150     /*
00151     BOOL                Initialise( NodePath* pThisNodePath,
00152                                     INT32 Index,
00153                                     NodeRenderableInk* pThisCreatedByNode,
00154                                     UINT32 SubpathID,
00155                                     UINT32 SubPathNum,
00156                                     CCAttrMap* pAttrMap);
00157                                     */
00158 
00159     BOOL                Initialise( NodeRenderableInk* pThisBlendNode,
00160                                     INT32 Index,
00161                                     NodeRenderableInk* pThisCreatedByNode,
00162                                     UINT32 SubpathID,
00163                                     UINT32 SubPathNum,
00164                                     CCAttrMap* pAttrMap,
00165                                     BOOL CheckDirection = TRUE);
00166 
00167     // DMc
00168     // alternative initialisation function, replacing the blend node & path
00169     BOOL                Initialise( BlendPath *pBlendPath, NodeRenderableInk * pNodeToBlend);   
00170 
00171     // NodeRenderableInk*   GetNodePath()       { return m_pNodePath; }
00172     NodeRenderableInk*  GetBlendNode()      { return m_pBlendNode; }
00173     Path*               GetPath()           { return m_pPath; }
00174     NodeRenderableInk*  GetCreatedByNode()  { return m_pCreatedByNode; }
00175     INT32               GetOrigMapping()    { return m_OrigMapping; }
00176     PathTypeEnum        GetPathType()       { return m_PathType; }
00177     UINT32              GetSubPathID()      { return m_SubPathID; }
00178     UINT32              GetSubPathNum()     { return m_SubPathNum; }
00179     INT32               GetNumElements()    { return m_NumElements; }
00180     BOOL                UniqueAppliedAttrs(){ return m_UniqueAttrs; }
00181     MILLIPOINT          GetAppliedLineWidth();
00182 
00183     BOOL                IsLine()  { return m_PathType == PATHTYPE_LINE;  }
00184     BOOL                IsShape() { return m_PathType == PATHTYPE_SHAPE; }
00185 
00186     void                Transform( TransformBase& Trans );
00187     void                RenderBlendBlobs(RenderRegion* pRender,Trans2DMatrix* pMatrix);
00188     BOOL                IsFilled();
00189     BOOL                IsStroked();
00190     DocCoord            GetPathCoord(INT32 Index);
00191     BOOL                IsPointOverBlob(DocCoord* pPointerPos,INT32* pIndex,Trans2DMatrix* pMatrix);
00192     INT32               MapPath(INT32 Index);
00193     DocCoord            MapPath(DocCoord Index);
00194     INT32               FindBottomLeft();
00195 
00196     CCAttrMap*          FindAppliedAttributes();
00197     void                FreeAppliedAttributes();
00198     AttrBitmapFill*     GetAppliedBitmapColourFill();
00199     AttrBitmapFill*     GetAppliedBitmapTranspFill();
00200 
00201     // DY, when blending brushes we need to generate the paths and AttrMap ourselves 
00202     // and then set it to a blendpath.  I don't recommend using these functions under
00203     // other circumstances.
00204     void                SetAppliedAttributes(CCAttrMap* pMap);
00205     void                SetPath(Path* pPath);
00206     void                DeleteAttributesAndPath();
00207 
00208     // DMc - we sometimes need to set this externally
00209     void                SetPathType(PathTypeEnum PathType) { m_PathType = PathType; }
00210 
00211     // new transform function also records cumulative transformations
00212     void                Transform(Matrix* pTransMatrix, BOOL TransformLines, BOOL Tile = FALSE);
00213     BOOL                TransformBrushAttributesBeforeSave();
00214     BOOL                TransformBrushAttributesAfterSave();
00215     Path*               m_pPath;
00216 
00217     void SetBlendNode(NodeRenderableInk *pInk) { m_pBlendNode = pInk; }
00218     
00219     void                SetFreeAttributeFlag(BOOL Value);
00220     void                SetCreatedViaNodeBlendPath (BOOL val)   { m_bCreatedViaNodeBlendPath = val; }
00221     BOOL                GetCreatedViaNodeBlendPath ()           { return (m_bCreatedViaNodeBlendPath); }
00222 
00223     
00224     // Access the copy data used for brush rendering
00225     BOOL MakeCopyPathAndAttributes();
00226     BOOL UpdateCopyPathAndAttributes();
00227     CCAttrMap* MakeAttributeMapCopy();
00228     CCAttrMap* UpdateAttributeMapCopy(CCAttrMap* pCopyMap);
00229     void DeleteCopyPathAndAttributes();
00230     void DeleteAttributeMapAndAttributes(CCAttrMap* pMap);
00231     Path* GetCopyPath();
00232     CCAttrMap* GetCopyAttributes();
00233 
00234 
00235 private:
00236     void                ProcessVerbs();
00237     void                CorrectDirection(INT32 Index);
00238 
00239     // NodePath         * m_pNodePath;
00240     NodeRenderableInk*  m_pBlendNode;
00241     
00242     NodeRenderableInk*  m_pCreatedByNode;
00243     CCAttrMap*          m_pAppliedAttrs;
00244 
00245     UINT32              m_CloseFigure;
00246     INT32               m_OrigMapping;
00247     PathTypeEnum        m_PathType;
00248     BOOL                m_DirChanged;
00249     BOOL                m_UniqueAttrs;
00250 
00251     UINT32              m_SubPathID;
00252     UINT32              m_SubPathNum;
00253     INT32               m_NumElements;
00254 
00255     DocCoord            m_BrushStartCoord;  //the starting position of the blendpath when 
00256                                             // it is created as part of a brush
00257     DocCoord            m_BrushCurrentCoord; // used to record the position of the blendpath just 
00258                                              // before it is saved as part of a brush
00259 
00260     BOOL                m_bDeleteAll;      // bodgey flag to indicate that we should delete everything upon destruction
00261     BOOL                m_bFreeAttrMapOnDestruct; // another bodgey flag to indicate that we should definitely delete 
00262                                                   // the attribute map upon destruction
00263 
00264     MILLIPOINT          m_AppliedLineWidth;  // caches the line width applied to this BP
00265 
00266     BOOL                m_bCreatedViaNodeBlendPath;     // CGS:  NEED TO KNOW this now!
00267 
00268     
00269     // Copies of the path and attributes used for brush rendering
00270     Path* m_pCopyPath;
00271     CCAttrMap* m_pCopyAttrs;
00272 };
00273 
00274 /***********************************************************************************************
00275 
00276 >   class BlendRef : public CC_CLASS_MEMDUMP
00277 
00278     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00279     Created:    11/10/94
00280     Purpose:    Contains all the data that a NodeBlender needs about another node in the tree
00281                 which it is blending.
00282 
00283 ***********************************************************************************************/
00284 
00285 class BlendRef : public CC_CLASS_MEMDUMP
00286 {
00287     CC_DECLARE_MEMDUMP(BlendRef);
00288 
00289 public:
00290     BlendRef();
00291     ~BlendRef();
00292 
00293 /*  BOOL                Initialise( NodeRenderableInk* pThisNode,
00294                                     INT32 Index,
00295                                     UndoableOperation* pUndoOp,
00296                                     Progress* pProgress,
00297                                     BOOL IgnoreEscape,
00298                                     Trans2DMatrix* pMatrix 
00299                                     );
00300 */  
00301     // overridden version for getting paths out of nodes with brush attributes
00302     BOOL                Initialise( NodeRenderableInk* pThisNode,
00303                                     INT32 Index,
00304                                     UndoableOperation* pUndoOp,
00305                                     Progress* pProgress,
00306                                     BOOL IgnoreEscape,
00307                                     Trans2DMatrix* pMatrix,
00308                                     AttrBrushType* pAttrBrush = NULL);
00309 
00310     BOOL                InitialiseForBrush(NodeRenderableInk* pThisNode);
00311 
00312     NodeRenderableInk*  GetNode() { return m_pNode; }
00313     void                Transform( TransformBase& Trans );
00314     void                RenderBlendBlobs(RenderRegion* pRender,Trans2DMatrix* pMatrix);
00315     void                PreBlend();
00316     void                PostBlend();
00317     CCAttrMap*          FindAppliedAttributes(BlendPath* pBlendPath);
00318 
00319     BOOL        AddBlendPath(BlendPath* pBlendPath);
00320     UINT32      GetNumBlendPaths()  { return m_NumBlendPaths; }
00321     BlendPath*  GetFirstBlendPath();
00322     BlendPath*  GetNextBlendPath(BlendPath* pCurrentBlendPath);
00323     BlendPath*  GetBlendPath(INT32 Index);
00324     BOOL        IsPointOverBlob(DocCoord* pPointerPos,BlendPath** ppBlendPath,INT32* pIndex,Trans2DMatrix* pMatrix);
00325     INT32       GetOrigMapping();
00326     void        SetAWComplex(BOOL state)    { m_AWComplex = state; }
00327     BOOL        GetAWComplex()              { return m_AWComplex; }
00328 
00329     DocRect     GetBoundingRect();
00330 
00331     BOOL        RemoveLastBlendPath();
00332 //  static void InitAddNode(BlendRef* pRef);
00333 //  static void DeinitAddNode();
00334 //  static BOOL AddNode(NodeRenderableInk* pNewNode,NodeRenderableInk* pCreatedBy);
00335 
00336     void StripRedundantNodeBlendPaths (BlendRef* spouse);
00337 
00338 protected:
00339 //  static BlendRef* pRefAddNode;   
00340 
00341     NodeRenderableInk*  m_pNode;
00342     List                m_BlendPathList;
00343     UINT32              m_NumBlendPaths;
00344     CMapPtrToPtr*       m_pBlendPathAttrMap;
00345     BOOL                m_AWComplex;
00346 };
00347 
00348 
00349 /***********************************************************************************************
00350 
00351 >   class NodeBlender : public NodeRenderableInk
00352 
00353     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00354     Created:    11/10/94
00355     Purpose:    A NodeBlender is the class that actually renders the blend stages of a blend object.
00356                 It also generates NodePath objects when the user does a 'make shapes' on a blend
00357 
00358 ***********************************************************************************************/
00359 
00360 class NodeBlender : public NodeRenderableInk
00361 {
00362 // Give my name out in memory dumps
00363 CC_DECLARE_DYNCREATE(NodeBlender);
00364 
00365 public:
00366     // Default constructor and Destructor
00367     NodeBlender(); 
00368     ~NodeBlender(); 
00369     
00370     NodeBlender(Node* ContextNode,  
00371                 AttachNodeDirection Direction,  
00372                 BOOL Locked = FALSE, 
00373                 BOOL Mangled = FALSE,  
00374                 BOOL Marked = FALSE, 
00375                 BOOL Selected = FALSE    
00376               );
00377 
00378     // NodeBlender-specific functions
00379     BOOL Initialise(NodeRenderableInk*  pNodeStart,
00380                     NodeRenderableInk*  pNodeEnd,
00381                     INT32               PathIndexStart,
00382                     INT32               PathIndexEnd,
00383                     UndoableOperation*  pUndoOp,
00384                     Progress*           pProgress,
00385                     BOOL                IgnoreEscape);
00386 
00387     // This sets the Initialised flag to FALSE, and deletes any memory created during initialisation.
00388     // The ObjIndexStart, ObjIndexEnd and NumBlendSteps remain the same, so the Reinit() func can exactly
00389     // recreate the blender node.
00390     // Mainly used to free up some memory when hiding NodeBlender objects in the tree
00391     void Deinit(BOOL bNodesMayBeChanged = FALSE);
00392 
00393     // If the blender is not initialised (usu. after a call to Deinit()) this call will reinitialise
00394     // if possible.
00395     // The two params point to the two nodes the blender should initialise.
00396     // You can get ptrs to the current nodes that blender is referencing using GetNodeStart() & GetNodeEnd().
00397     BOOL Reinit(NodeRenderableInk* pInkNodeStart = NULL,NodeRenderableInk* pInkNodeEnd = NULL,BOOL ProgressBar = TRUE);
00398 
00399     // These return to the two nodes tha blender is blending together
00400     NodeRenderableInk*  GetNodeStart()  { return m_pNodeStart; }
00401     NodeRenderableInk*  GetNodeEnd()    { return m_pNodeEnd; }  
00402 
00403     // The copy function
00404     virtual Node* SimpleCopy();
00405 
00406     // virtual Functions to deal with bounding boxes
00407     virtual DocRect GetBoundingRect(BOOL DontUseAttrs=FALSE, BOOL HitTest=FALSE);
00408     virtual DocRect GetBlobBoundingRect();
00409     DocRect GetUnionBlendedBounds(DocRect& BoundsStart,DocRect& BoundsEnd);
00410 
00411     // Rendering Functions
00412     virtual void Render( RenderRegion* pRender );
00413     virtual void RenderEorDrag( RenderRegion* );
00414     virtual void RenderBlendBlobs(RenderRegion* pRender,BOOL RenderStart,BOOL RenderEnd);
00415     virtual void PreExportRender( RenderRegion* pRender ); 
00416     virtual BOOL ExportRender( RenderRegion* pRender ); 
00417 
00418     // Export-related funcs
00419     BOOL IsArtWorksEPSCompatible();
00420     BOOL IsComplex();
00421     INT32 GetAWStartPathIndex();
00422     INT32 GetAWEndPathIndex();
00423     INT32 GetAWPathIndex(BlendRef* pRef,INT32 PathIndex);
00424 
00425     // Functions to transform the shape
00426     virtual void Transform( TransformBase& );
00427 
00428     // Utility funcs 
00429     BOOL IsPointOverBlob(DocCoord* pPointerPos,BlendPath** ppBlendPath,INT32* pIndex,BOOL* pAStart);
00430     BOOL Remap(DocCoord PosStart,DocCoord PosEnd,DocCoord * pInvPosStart,DocCoord * pInvPosEnd);
00431     BOOL ConvertAWPathIndexesToCamelot(INT32 *pPathIndexStart,INT32* pPathIndexEnd);
00432     BOOL FindPathEndPoint(Node* pNodePath,INT32* pIndex);
00433     NodeRenderableInk* FindObjIndexedNode(INT32 ObjIndex);
00434     virtual BOOL CanSelectAsSimple();
00435 
00436     // Returns the NodeBlend that this blender belongs to.
00437     NodeBlend* GetNodeBlend();
00438 
00439     // The OneToOne flag (asks parent NodeBlend node)
00440     BOOL IsOneToOne();
00441 
00442     // The NotAntialiased flag - TRUE when we don't want the blend steps to antialiased (asks parent NodeBlend node)
00443     BOOL IsNotAntialiased();
00444 
00445     // Information functions
00446     virtual UINT32 GetNodeSize() const;             // Returns size of node in bytes
00447  
00448     // Make Shapes functions
00449     virtual BOOL CanBecomeA(BecomeA* pBecomeA);
00450     virtual BOOL DoBecomeA(BecomeA* pBecomeA);
00451 
00452     // Debugging function
00453     #ifdef _DEBUG
00454     void    ShowDebugTreeDetails() const;
00455     #endif
00456     void GetDebugDetails( StringBase* Str );
00457     void GetDebugDetails( StringBase* Str,BlendRef* pBlendRef );
00458 
00459     // Functions to deal with messages
00460     virtual BOOL OnClick( DocCoord, ClickType, ClickModifiers, Spread* );
00461     virtual BOOL HidingNode();
00462     virtual BOOL ShowingNode();
00463  
00464     // The natty Snap functions
00465     virtual BOOL Snap(DocCoord* pDocCoord);
00466     virtual BOOL Snap(DocRect* pDocRect,const DocCoord& PrevCoord,const DocCoord& CurCoord);
00467 
00468     // This extracts the num blend steps from the parent blend node
00469     UINT32 GetNumBlendSteps();
00470 
00471     // Find out how to blend colours by calling the same func in the parent blend node
00472     ColourBlendType GetColourBlendType();
00473 
00474     // Allows the path start and end indexes to be manipulated (only use if you know what you're doing)
00475     void SetPathIndexStart(INT32 Index)     { m_PathIndexStart = Index; }
00476     void SetPathIndexEnd  (INT32 Index)     { m_PathIndexEnd   = Index; }
00477     INT32 GetPathIndexStart()           { return m_PathIndexStart; }
00478     INT32 GetPathIndexEnd()                 { return m_PathIndexEnd; }
00479     
00480     // Allows the start and end indexes referencing the two objects this blender is blending to be set and retreived
00481     //  (only use if you know what you're doing)
00482     void SetObjIndexStart(INT32 ObjIndex)   { m_ObjIndexStart = ObjIndex; }
00483     void SetObjIndexEnd  (INT32 ObjIndex)   { m_ObjIndexEnd   = ObjIndex; }
00484     INT32 GetObjIndexStart()                { return m_ObjIndexStart; }
00485     INT32 GetObjIndexEnd()                  { return m_ObjIndexEnd; }
00486     
00487     // Version 2 file format functions
00488     virtual BOOL WritePreChildrenWeb(BaseCamelotFilter* pFilter);
00489     virtual BOOL WritePreChildrenNative(BaseCamelotFilter* pFilter);
00490     virtual BOOL WriteBeginChildRecordsWeb(BaseCamelotFilter* pFilter);
00491     virtual BOOL WriteBeginChildRecordsNative(BaseCamelotFilter* pFilter);
00492     virtual BOOL WriteEndChildRecordsWeb(BaseCamelotFilter* pFilter);
00493     virtual BOOL WriteEndChildRecordsNative(BaseCamelotFilter* pFilter);
00494 
00495     // Override this to ensure that bounds never get written out for this node
00496     virtual BOOL WriteBoundsRecord(BaseCamelotFilter* pFilter) { return(TRUE); }
00497 
00498     // Blend on a path functions
00499     BOOL            GetPointOnNodeBlendPath(double BlendRatio,DocCoord* pPoint,double* pAngle);
00500     BOOL            GetPointFromDistance(double Distance, DocCoord* pPoint, double* pAngle);
00501     NodeBlendPath*  GetNodeBlendPath();
00502     Trans2DMatrix*  GetRotateMatrix(NodeRenderableBounded* pNode,double Angle);
00503 
00504     double  GetProportionOfPathDistStart();
00505     double  GetProportionOfPathDistEnd();
00506     void    SetProportionOfPathDistStart(double p);
00507     void    SetProportionOfPathDistEnd(double p);
00508 
00509     double  GetAngleStart();
00510     double  GetAngleEnd();
00511     void    SetAngleStart(double Angle);
00512     void    SetAngleEnd(double Angle);
00513     void    RotateBounds(DocRect& Bounds,double Angle);
00514     
00515 
00516     //Diccon 26/9/99
00517     double  GetLinearDistance();  // returns the distance between the start and end nodes
00518     BOOL    GetBlendDirection(double* Gradient);
00519     BOOL    GetBlendObjectCentres(DocCoord* FirstCentre, DocCoord* LastCentre);
00520     
00521     BOOL    IsTangential();
00522     void    SetUninitialised() { m_Initialised = FALSE;}
00523 
00524     void    SetBlendedOnCurve(BOOL value)   { m_BlendedOnCurve = value;}
00525     BOOL    IsBlendedOnCurve()              { return m_BlendedOnCurve;}
00526 
00527     // Karim 01/02/2000     Mutate/access methods for m_Reversed.
00528     //                      NB - this can ONLY be set if we're already blended on a curve.
00529     void    SetReversed(BOOL value)     { m_Reversed = m_BlendedOnCurve ? value : FALSE; }
00530     BOOL    IsReversed()                { return m_Reversed; }
00531 
00532     void    SetNodeBlendPathIndex(INT32 Index);
00533     INT32    GetNodeBlendPathIndex();
00534 
00535     // reverses the end objects of the blender
00536     BOOL    ReverseEnds();
00537 
00538     // DMc moved - since NodePath need these now
00539     static BOOL ConvertLineToShape(Path* pPath,Path* pShapePath);
00540 
00541     // Path processing functions
00542     static BOOL ProcessBlendedPath(DocCoord* pCoords,PathVerb* pVerbs,PathFlags* pFlags,UINT32 Len,BOOL Filled);
00543     static void SetPathFlags(PathVerb* pVerbs,PathFlags* pFlags,UINT32 Len);
00544     static void ReversePath(DocCoord* Coords,PathVerb* Verbs,UINT32 Len);
00545 
00546     void UpdateBlendStartAngles (Trans2DMatrix& trans);
00547 
00548     virtual INT32 EstimateNodeComplexity (OpParam* details);
00549 
00550     virtual void PolyCopyNodeContents(NodeRenderable* pNodeCopy);
00551 
00552 private:
00553     // ResetVars() is called by all constructors to centralise member var initialisation
00554     void ResetVars();
00555 
00556     // Standard copy function
00557     void CopyNodeContents(NodeBlender* NodeCopy);
00558 
00559     // Other private functions.    
00560     BOOL                InitBlendRef(   NodeRenderableInk* pNode,
00561                                         BlendRef** ppRef,
00562                                         INT32 Index,
00563                                         UndoableOperation* pUndoOp,
00564                                         Progress* pProgress,
00565                                         BOOL IgnoreEscape,
00566                                         Trans2DMatrix* pMatrix);
00567     BOOL                CalcObjIndex(NodeRenderableInk* pInkNode,INT32* pObjIndex);
00568     void                CheckFullyInitialised();
00569     BOOL                BlendPaths(BlendPath* pBlendPathStart,BlendPath* pBlendPathEnd,double BlendRatio);
00570     void                CreateBlends(RenderRegion* pRender,HandleBecomeA* pHandleBecomeA);
00571     Matrix              MakeMatrix(BlendPath* pBlendPathStart,BlendPath* pBlendPathEnd,double BlendRatio);
00572     BOOL                CheckBoundsIntersect(RenderRegion* pRender,DocRect& BoundsStart,DocRect& BoundsEnd,double BlendRatio);
00573     DocRect             BlendBounds(DocRect& BoundsStart,DocRect& BoundsEnd,double BlendRatio,BOOL UseBlendPath);
00574 
00575     // Attribute funcs
00576     BOOL BlendAttributes(RenderRegion *pRender, BlendPath* pBlendPathStart,
00577                          BlendPath* pBlendPathEnd,CCAttrMap* pBlendedAttribMap,double BlendRatio,
00578                          double objectRatio, BOOL objectProfileProcessing);
00579     //void DeleteAttributes(CCAttrMap* pAttribMap);
00580     void RenderAttributes(RenderRegion* pRender,CCAttrMap* pAttribMap);
00581 
00582     // Pre and post blend funcs
00583     BOOL        PreBlend();
00584     void        PostBlend();
00585     BOOL        ReallocTempBuffers(UINT32 Size);
00586     void        DeallocTempBuffers();
00587 
00588     // Access funcs for the path arrays
00589     DocCoord*   GetCoordArray(UINT32 MinSize);
00590     PathVerb*   GetVerbArray(UINT32 MinSize);
00591     PathFlags*  GetFlagArray(UINT32 MinSize);
00592     UINT32*         GetGBlendBuff(UINT32 MinSize);
00593 
00594     // Profile functions
00595     double MapObjectBlendRatio(double BlendRatio);
00596     double MapAttrBlendRatio(double BlendRatio);
00597     double MapPositionBlendRatio(double BlendRatio);
00598 
00599     // bodge functions to deal with transparencies and fill profile problem
00600     double GetObjectRatio();  
00601     double GetInvertedAttributeRatio();
00602 
00603     // These two vars point to reference data for the start and end objects that this blender
00604     // is interested in.
00605     BlendRef *m_pRefStart;
00606     BlendRef *m_pRefEnd;
00607 
00608     // These are the to ink nodes that we are blending
00609     // They are set in initialisation
00610     NodeRenderableInk* m_pNodeStart;
00611     NodeRenderableInk* m_pNodeEnd;
00612 
00613     // These two vars hold a value that is relative to the parent node (NodeBlend) 
00614     // indicating which object the blend references.
00615     // E.g. If ObjIndexStart = 2, then the start object that this blender will blend is the third NodeRenderableInk
00616     // node (starting from the first child) under the parent NodeBlend node.
00617     // This allows use to re-initialise the blender after a copy has been made (via SimpleCopy).
00618     // When any public function of NodeBlender is called (e.g. Render(), Transform() etc), Reinit() should be 
00619     // the first thing the func should do, just in case the blender has to reinit itself.
00620     INT32 m_ObjIndexStart;
00621     INT32 m_ObjIndexEnd;
00622 
00623     // This will remain FALSE until the blender is fully initialised, i.e. after both pRefStart
00624     // and pRefEnd point to filled-in BlendRef structs, and ObjIndexStart and ObjIndexEnd are >=0
00625     // (i.e. they reference the nodes stored in pRefStart and pRefEnd in a relative manner)
00626     BOOL m_Initialised;
00627 
00628     // This is the current blend step to render. This will allow interruptable blend rendering, when we
00629     // get round to doing it.
00630     UINT32 m_BlendStep;
00631 
00632     // The following set of vars deal with arrays that are set up by the PreBlend() routine
00633     // Also, these arrays can also change by calls to the access funcs GetCoordArray(), GetVerbArray() and GetFlagArray()
00634     UINT32      m_TempArraySize;
00635     DocCoord*   m_pTempCoords;
00636     PathVerb*   m_pTempVerbs;
00637     PathFlags*  m_pTempFlags;
00638     UINT32      m_GBlendBuffSize;
00639     UINT32*     m_pGBlendBuff;
00640     UINT32      m_ArrayLength;
00641 
00642     // These hold the indexes of the path elements that reference the path blobs the user dragged
00643     // on when generating the blend.  These will only be != -1 when blending from a path to a path,
00644     // and both paths are selected and the user started the drag on one blob and ended it on another.
00645     INT32       m_PathIndexStart;
00646     INT32       m_PathIndexEnd;
00647 
00648     // These hold the proportion of the distance of the path where the start and end objects appear.
00649     // e.g. values of 0.2 and 0.5 would mean this blender starts a 5th of the way along the path,
00650     // and ends half way along the path.
00651     // Used to calculate where blended paths are positioned.
00652     double      m_ProportionOfPathDistStart;
00653     double      m_ProportionOfPathDistEnd;
00654 
00655     double      m_AngleStart;
00656     double      m_AngleEnd;
00657 
00658     // Diccon 9/99 Identifies whether this blend is between a blend on a curve and
00659     // another object.
00660     BOOL    m_BlendedOnCurve;
00661     BOOL    m_Reversed;
00662     
00663     // if we are on a path then this identifies which one (-1 means none)
00664     INT32    m_NodeBlendPathIndex;
00665 
00666     BOOL CallBeginBlendStep(BlendNodeParam * pParam, BOOL* usingSumAllPathsPathProcessor);
00667     BOOL CallEndBlendStep(BlendNodeParam * pParam);
00668 
00669 }; 
00670 
00671 
00672 /***********************************************************************************************
00673 
00674 >   class ListStepper
00675 
00676     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00677     Created:    17/11/94
00678     Purpose:    This class it used to step along two lists, choosing matching pairs.
00679                 This really comes into play when you have different numbers of items in the two
00680                 lists, and you want to step along them without missing out any items.
00681                 E.g. List A contains 4 items, list B contains 2 items
00682                     this would produce the following pairs:
00683                         A   B
00684                         0   0
00685                         1   0
00686                         2   1
00687                         3   1
00688                 E.g. List A contains 3 List B contains 5
00689                         A   B
00690                         0   0
00691                         0   1
00692                         1   2
00693                         1   3
00694                         2   4
00695 
00696 ***********************************************************************************************/
00697 
00698 class ListStepper
00699 {
00700 public:
00701     ListStepper() { Min = Max = NextInStart = NextInEnd = Inc = 0; pNextInMin = pNextInMax = NULL;}
00702 
00703     void Init(UINT32 NumInStart,UINT32 NumInEnd,UINT32 Start);
00704     void GetNext(INT32* pNextInStart,INT32* pNextInEnd);
00705 
00706 private:
00707     UINT32 Min;
00708     UINT32 Max;
00709     UINT32 NextInStart;
00710     UINT32 NextInEnd;
00711     UINT32 Inc;
00712     UINT32* pNextInMin;
00713     UINT32* pNextInMax;
00714 };
00715 
00716 /***********************************************************************************************
00717 
00718 >   class HandleBecomeA: public CC_CLASS_MEMDUMP
00719 
00720     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00721     Created:    18/10/94
00722     Purpose:    Objects of this class are passed into NodeBlender::CreateBlends() so that they can
00723                 receive all the paths the blender generates in order to convert the blender into
00724                 shapes (or more specifically NodePaths)
00725 
00726 ***********************************************************************************************/
00727 
00728 class HandleBecomeA : public CC_CLASS_MEMDUMP
00729 {
00730 CC_DECLARE_MEMDUMP(HandleBecomeA);
00731 public:
00732     HandleBecomeA(  NodeBlender*    pThisNodeBlender,
00733                     Node*           pThisContextNode,
00734                     BecomeA*        pThisBecomeA) : 
00735                     pNodeBlender(pThisNodeBlender), 
00736                     pBecomeA(pThisBecomeA),
00737                     pContextNode(pThisContextNode),
00738                     pNodeGroup(NULL),
00739                     LastStep(0),
00740                     NumPathsPerStep(0) {}
00741 
00742     BOOL PassBack(Path* pBlendedPath,CCAttrMap* pBlendedAttrMap,UINT32 Step);
00743 
00744     void SetNumPathsPerStep(UINT32 Num) { NumPathsPerStep = Num; }
00745     BOOL MakeGroupPerStep()             { return (NumPathsPerStep > 1); }
00746 
00747     BecomeA* GetBecomeA () { return (pBecomeA); }
00748     Node*    GetContextNode () { return (pContextNode); }
00749 
00750 private:
00751     NodeBlender* pNodeBlender;
00752     BecomeA*     pBecomeA;
00753     Node*        pContextNode;
00754     NodeGroup*   pNodeGroup;
00755     UINT32       LastStep;
00756     UINT32       NumPathsPerStep;
00757 };
00758 
00759 class NodeCompoundBlendBecomeA : public BecomeA
00760 {
00761 CC_DECLARE_MEMDUMP(NodeCompoundBlendBecomeA);
00762 public:
00763     NodeCompoundBlendBecomeA(   BecomeAReason Reason,
00764                                 CCRuntimeClass* pClass, 
00765                                 UndoableOperation* pOp, 
00766                                 BOOL Sel,
00767                                 Node* pContext
00768                             ) :
00769 
00770                 BecomeA (Reason,pClass,pOp, Sel)
00771                 {
00772                     pContextNode = pContext;
00773                     pPathsToBecome = NULL;
00774                 }
00775 
00776     // This function should be called when Reason == BECOMEA_PASSBACK 
00777     //virtual BOOL PassBack(NodeRenderableInk* pNewNode,NodeRenderableInk* pCreatedByNode,CCAttrMap* pAttrMap);
00778 
00779     Node* GetContextNode () { return (pContextNode); }
00780     List* GetPathsToBecome () { return (pPathsToBecome); }
00781 
00782     void SetPathsToBecome (List* pathsList) { pPathsToBecome = pathsList; } //SumAllPathsElem* become) { pPathToBecome = become; }
00783 
00784 private:
00785     Node* pContextNode;         // the context node that we are to attach to
00786     List* pPathsToBecome;       // the node that we are to become
00787 };
00788 
00789 //-----------------------------------------------------------
00790 /***********************************************************************************************
00791 
00792 >   class BlendBecomeA: public BecomeA
00793 
00794     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00795     Created:    18/10/94
00796     Purpose:    This is the class that is passed to other nodes when blenders try and get them to 
00797                 to turn into other types via their DoBecomeA() method
00798 
00799 ***********************************************************************************************/
00800 
00801 class BlendBecomeA : public BecomeA
00802 {
00803 CC_DECLARE_MEMDUMP(BlendBecomeA);
00804 public:
00805     BlendBecomeA(   BecomeAReason Reason,
00806                     CCRuntimeClass* pClass, 
00807                     UndoableOperation* pOp, 
00808                     BlendRef* pThisBlendRef, 
00809                     INT32 ThisIndex,
00810                     Progress* pThisProgress,
00811                     BOOL IgnoreEsc,
00812                     Trans2DMatrix* pMatrix) :
00813 
00814                 BecomeA(Reason,pClass,pOp), 
00815                 pBlendRef(pThisBlendRef), 
00816                 Index(ThisIndex), 
00817                 SubPathID(0), 
00818                 pProgress(pThisProgress),
00819                 IgnoreEscape(IgnoreEsc),
00820                 m_pMatrix(pMatrix)      { } ;
00821 
00822     BOOL IsBlendBecomeA() { return TRUE; }
00823 
00824     // This function should be called when Reason == BECOMEA_PASSBACK 
00825     virtual BOOL PassBack(NodeRenderableInk* pNewNode,NodeRenderableInk* pCreatedByNode,CCAttrMap* pAttrMap);
00826 
00827 private:
00828     BlendRef*       pBlendRef;
00829     INT32           Index;
00830     UINT32          SubPathID;
00831     Progress*       pProgress;
00832     BOOL            IgnoreEscape;
00833     Trans2DMatrix*  m_pMatrix;
00834 
00835     NodeRenderableInk * CreateWrapNode(NodeRenderableInk * pNode, NodeCompound *pTree,
00836                                                         CCAttrMap * pMap);
00837 };
00838 
00839 #endif  // INC_NODEBLDR

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