nodeblnd.h

Go to the documentation of this file.
00001 // $Id: nodeblnd.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 // NodeBlend definition
00099 
00100 #ifndef INC_BLEND
00101 #define INC_BLEND
00102 
00103 //#include "group.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00104 //#include "ops.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00105 #include "blendatt.h"
00106 //#include "biasgain.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00107 
00108 #pragma warning(disable: 4786)
00109 #include <list>
00110 #pragma warning(default: 4786)
00111 
00112 class RenderRegion;
00113 class String_32;
00114 class NodeRect; 
00115 class BlendPath; 
00116 class NodeBlendPath;
00117 class NodeBlender;
00118 
00119 /********************************************************************************************
00120 
00121 >   class NodeBlend: public NodeGroup
00122 
00123     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> M
00124     Created:    6/10/94
00125     Purpose:    The NodeBlend class
00126 
00127 ********************************************************************************************/
00128 
00129 class NodeBlend: public NodeGroup
00130 {
00131 public: 
00132     CC_DECLARE_DYNAMIC( NodeBlend )    
00133     
00134     NodeBlend(); 
00135     
00136     NodeBlend(Node* ContextNode,  
00137               AttachNodeDirection Direction,    
00138               BOOL Locked=FALSE, 
00139               BOOL Mangled=FALSE,  
00140               BOOL Marked=FALSE, 
00141               BOOL Selected=FALSE    
00142              ); 
00143              
00144     // Virtual rendering functions       
00145     virtual void PreExportRender( RenderRegion* pRender ); 
00146     virtual BOOL ExportRender( RenderRegion* pRender ); 
00147     virtual void RenderBlendBlobs(RenderRegion* pRender);
00148     virtual void RenderObjectBlobs(RenderRegion* pRegion);
00149 
00150     void RenderBlendOnCurveBlobs(RenderRegion* pRegion);
00151 
00152     // Bounds-related funcs
00153     void InvalidateBlendBoundingRect();
00154     DocRect GetBlobBoundingRect();
00155     BOOL AreBoundsValid() { return IsBoundingRectValid; }
00156     virtual DocRect GetBoundingRect(BOOL DontUseAttrs=FALSE, BOOL HitTest=FALSE);
00157 
00158     // Export-related funcs
00159     BOOL IsArtWorksEPSCompatible();
00160     INT32 GetNumInkObjects();
00161 
00162     // Other virtual functions
00163     virtual String Describe(BOOL Plural, BOOL Verbose); 
00164     virtual Node* SimpleCopy();  
00165     virtual UINT32 GetNodeSize() const;             // Returns size of node in bytes
00166     virtual BOOL OnNodePopUp(Spread* pSpread, DocCoord PointerPos, ContextMenu* pMenu);
00167     virtual BOOL PostImport();
00168     virtual BOOL IsABlend () { return (TRUE); }
00169 
00170     // Functions to deal with messages
00171     virtual BOOL OnClick( DocCoord, ClickType, ClickModifiers, Spread* );
00172     virtual BOOL HidingNode();
00173     virtual BOOL ShowingNode();
00174 
00175     // Fuctions that allows ops and other nodes to inform this node of events on it's children
00176     virtual ChangeCode  OnChildChange(ObjChangeParam* pParam);
00177     virtual BOOL        AllowOp(ObjChangeParam* pParam, BOOL SetOpPermissionState = TRUE,
00178                                                         BOOL DoPreTriggerEdit = TRUE);
00179 
00180     // Utility funcs 
00181     BOOL IsPointOverBlob(DocCoord* pPointerPos,
00182                          BlendPath** ppBlendPath,
00183                          INT32* pIndex,
00184                          BOOL* pAStart,
00185                          UINT32* pRemapRef);
00186 
00187     BOOL Remap(UINT32 RemapRef,DocCoord PosStart,DocCoord PosEnd,DocCoord* pInvPosStart, DocCoord* pInvPosEnd);
00188     UINT32 GetNumBlenders();
00189     NodeBlender* FindFirstBlender();
00190     NodeBlender* FindNextBlender(NodeBlender* pNodeBlender);
00191     NodeBlender* FindLastBlender();
00192     BOOL FindFirstAndLastBlenders(NodeBlender** ppFirstBlender, NodeBlender** ppLastBlender);
00193 
00194     // The OneToOne flag
00195     BOOL IsOneToOne();
00196     void SetOneToOne(BOOL state);
00197 
00198     // The NotAntialiased flag - TRUE when we don't want the blend steps to antialiased
00199     BOOL IsNotAntialiased();
00200     void SetNotAntialiased(BOOL state);
00201 
00202     // Replace DoBecomeA() so that the blend node can turn itself into a group
00203     virtual BOOL DoBecomeA(BecomeA* pBecomeA);
00204 
00205     // Access functions for the num blend steps
00206     UINT32 GetNumBlendSteps();
00207     void SetNumBlendSteps(UINT32 NumSteps);
00208 
00209     // Access functions for the way the blend does colours
00210     ColourBlendType GetColourBlendType();
00211     void            SetColourBlendType(ColourBlendType Type);
00212 
00213     //DY 27/9
00214     EditState GetEditState();
00215     void SetEditState(EditState State);
00216     
00217     BOOL Reinit(BOOL ProgressBar = TRUE);           // Calls Reinit() for all its child blenders
00218     void Deinit(BOOL bNodesMayBeChanged = FALSE);   // Calls Deinit() for all its child blenders
00219 
00220     static BOOL GetDefaultAntialias() { return !s_DefaultNotAntialiased; }
00221 
00222     // Version 2 file format functions
00223     virtual BOOL WritePreChildrenWeb(BaseCamelotFilter* pFilter);
00224     virtual BOOL WritePreChildrenNative(BaseCamelotFilter* pFilter);
00225     virtual BOOL WritePreChildren(BaseCamelotFilter* pFilter);
00226     virtual BOOL CanWriteChildrenWeb(BaseCamelotFilter* pFilter);
00227     virtual BOOL CanWriteChildrenNative(BaseCamelotFilter* pFilter);
00228 
00229     // Blend path functions
00230     NodeBlendPath*  GetNodeBlendPath(UINT32 Index);
00231     BOOL            BlendAlongThisPath(NodePath* pPath,CCAttrMap* pAttrMap,UndoableOperation* pUndoOp, BOOL BlendPathOnTop);    //DY added last parameter 16/9/99
00232     virtual Node*   HasEditableChild(CCRuntimeClass *ChildClass, Node* pPrevEditable);
00233     BOOL            TransformBlendEndObjects(UndoableOperation* pUndoOp);
00234     BOOL            RotateBlendEndObjectsBack(UndoableOperation* pUndoOp);
00235     BOOL            TransformNodeToPoint(NodeRenderableInk* pNode,DocCoord* pPoint,UndoableOperation* pUndoOp,double Angle);
00236     BOOL            InitBlenderPathProportions(UndoableOperation* pUndoOp);
00237     BOOL            DetachNodeBlendPath(Node* pContextNode, AttachNodeDirection AttDir,UndoableOperation* pUndoOp);
00238     BOOL            IsTangential();
00239     void            SetTangential(BOOL Tangential);
00240     BOOL            IsOnACurve();
00241     void            SetBlendedOnCurve(BOOL State);
00242     
00243     // Profile blending functions
00244     CProfileBiasGain* GetObjectProfile()    { return &m_ObjectProfile; }
00245     CProfileBiasGain* GetAttrProfile()      { return &m_AttrProfile; } 
00246     CProfileBiasGain* GetPositionProfile()  { return &m_PositionProfile; }
00247 
00248     // DY 26/9/99
00249     BOOL GetBlendDistance(BOOL GetFullDistance, double* Distance);  // returns the length of a blend in MP
00250     
00251     // works out how many steps would be required to achieve distance between steps of StepDistance 
00252     BOOL GetNumStepsFromDistance(double StepDistance, UINT32* NumSteps); 
00253 
00254     double GetStepDistance(); // returns the distance between steps in the blend
00255     void UpdateStepDistance();  // updates the actual distance between steps member variable
00256     double GetDistanceEntered(); 
00257     void SetDistanceEntered(double Distance);
00258 
00259     EndObject GetLastEdited();
00260     void SetLastEdited(EndObject ObjectEdited);
00261     BOOL GetStartAndEndProportions(double* StartProp, double* EndProp);
00262     BOOL GetStartAndEndNodes(Node** ppStart, Node** ppEnd);
00263     BOOL IsChildOfGroup();
00264     BOOL HitOnEndDragBlob(DocCoord Point, Node** ppHitNode);
00265 
00266     // if the blend is part of a bevel, shadow, or contour, this returns the controller node
00267     NodeCompound* GetParentController() const;
00268 
00269     // access functions to deal with multiple nodeblendpaths
00270     UINT32 GetNumNodeBlendPaths();
00271     void SetNumNodeBlendPathsInc(BOOL Increase);
00272     void SetNumNodeBlendPaths(INT32 Index);
00273     BOOL HitOnDragBlob(NodeRenderableInk* pInk, DocCoord PointerPos);
00274     
00275     // function to find out which blender a given node belongs to, the first is now  
00276     // obsolete and should not be used
00277     NodeBlender* NodeIsPartOfBlender(Node* pNode, BOOL First);
00278     
00279     // Function to find out which other blender in a blend uses pNode, given that it is als
00280     // used by pBlender
00281     NodeBlender* NodeIsPartOfBlender(Node* pNode, NodeBlender* pBlender, BOOL* First);
00282 
00283     // returns whether or not the blend currently has a non-linear object profile
00284     BOOL NonLinearObjectProfile();
00285 
00286     BOOL ContainsBrushedNode();
00287 
00288     // CGS (27/7/2000):  special profiling functions ....
00289     // these functions provide access to the new features described within blndattr.h
00290     
00291     void RequestObjectProfileProcessing (BOOL newVal) { objectProfileProcessing = newVal; }
00292     BOOL GetObjectProfileProcessing () { return (objectProfileProcessing); }
00293 
00294     virtual INT32 EstimateNodeComplexity (OpParam* details);
00295 
00296     // CGS:  NOTE the use of RequestObjectProfileProcessing may appear to be incorrect.
00297     // For example, when the user changes the object profile I call this function with TRUE
00298     // (thereby requesting object processing).  However, I also do exactly the same when the user
00299     // changes the attribute profile.  The reason for this is THAT when changing the attribute
00300     // profile, we MUST blend position data (e.g.  fill control points) with respect to the object
00301     // profile AND not of the attribute profile!  As can be seen, this approach works well.
00302 
00303     BOOL ReinitialiseOnChildChanged(UndoableOperation* pOp, NodeRenderableInk* pOldChild,
00304                                                             NodeRenderableInk* pNewChild);
00305 
00306     virtual void PolyCopyNodeContents(NodeRenderable* pNodeCopy);
00307 
00308     // Karim MacDonald 26/11/1999
00309     // Extend functions.
00310     // Note that if a sub-class returns TRUE from IsTypeExtendible, it must
00311     // also provide complete implementations of ValidateExtend and Extend,
00312     // which should usually check/extend its children.
00313 public:
00314     virtual BOOL IsTypeExtendible() const { return TRUE; }
00315     virtual DocRect ValidateExtend(const ExtendParams& ExtParams);
00316     virtual void Extend(const ExtendParams& ExtParams);
00317 protected:
00318     void FindExtendingChildren(std::list<NodeRenderableInk*>&, std::list<NodeBlendPath*>&);
00319 
00320 private:
00321     void CopyNodeContents(NodeBlend* pCopyOfNode);
00322     void ResetVars();
00323 
00324     BOOL objectProfileProcessing;       // do we want object profile processing capability?
00325 
00326     String_32 m_BlendName; // The name of the blend 
00327 
00328     // Number of blend steps all child blenders will render.
00329     // E.g if 1, then 1 intermediate step will be rendered. If 0, just the end objecs get rendered
00330     UINT32 m_NumBlendSteps;
00331 
00332     
00333     // DY 27/9/99
00334     double m_StepDistance; // distance between steps of the blend
00335     double m_DistanceEntered; //the last distance requested by the user
00336     EndObject m_LastEdited;  // 
00337 
00338     // These vars are used during exporting to ArtWorks EPS. They determine whether the whole blend is
00339     // AWEPS compatible, and whether this info is cached for this blend (for when blenders ask their 
00340     // parent for the info)
00341     BOOL m_AWEPSCompatible;
00342     BOOL m_AWEPSCompatibleCache;
00343 
00344     // The OneToOne flag is TRUE if the blend should be be done using a one-to-one node mapping
00345     BOOL m_OneToOne;
00346 
00347     // This flags is TRUE if we should NOT render blend steps antialiased
00348     BOOL m_NotAntialiased;
00349 
00350     // This specifies how the blend will blend colours (either fade, rainbow, or alt rainbow)
00351     ColourBlendType m_ColBlendType;
00352 
00353     // This is true if the blend should fit the objects on a curve tangentially
00354     BOOL m_Tangential;
00355     
00356     // is this blend currently on a curve?
00357     BOOL m_BlendedOnCurve;
00358 
00359     // when the blend is on a curve and we wish to edit the path do we keep the 
00360     EditState m_Edit;   // number of steps constant (or the distance between steps)
00361 
00362     CProfileBiasGain m_ObjectProfile;
00363     CProfileBiasGain m_AttrProfile;
00364     CProfileBiasGain m_PositionProfile;
00365 
00366     static BOOL s_DefaultNotAntialiased;
00367 
00368     UINT32 m_NumNodeBlendPaths;
00369 };
00370 
00371 
00372 /********************************************************************************************
00373 
00374 >   class InitBlendAction : public Action
00375 
00376     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00377     Created:    21/11/94
00378     Purpose:    An action which deinits or reinits a blend
00379     SeeAlso:    -
00380 
00381 ********************************************************************************************/
00382 
00383 enum InitBlendActionType { IBAT_INVALID, IBAT_INIT, IBAT_INITONBLENDER };
00384 
00385 class InitBlendAction : public Action
00386 {
00387 
00388 CC_DECLARE_DYNCREATE(InitBlendAction)
00389 
00390 public:
00391     InitBlendAction();
00392     ~InitBlendAction();
00393     virtual ActionCode Execute();
00394     static ActionCode Init( UndoableOperation* pOp,
00395                             ActionList* pActionList,
00396                             NodeBlend* pThisNodeBlend,
00397                             BOOL StoreStartAndEndNodes=FALSE, // DMc change so that the action                          
00398                                                               // can restore the blends start & end points
00399                             BOOL bReverse = FALSE,            // Instead of adding this action to the head of the action list
00400                                                               // add it to the tail
00401                             BOOL bNodesMayBeChanged = FALSE
00402                             );
00403 
00404     // CGS (14/7/2000)
00405     // allows us to initialise undo information based upon blenders (so that we store the CORRECT nodes)
00406     // this should only be called when we replace the geometry that starts/ends the blends (e.g.
00407     // remove the contour of a blends start node).
00408     static ActionCode InitOnBlender( UndoableOperation* pOp,
00409                             ActionList* pActionList,
00410                             NodeBlender* pThisNodeBlender,
00411                             BOOL StoreStartAndEndNodes=FALSE, // DMc change so that the action                          
00412                                                               // can restore the blends start & end points
00413                             BOOL bReverse = FALSE);           // Instead of adding this action to the head of the action list
00414                                                               // add it to the tail
00415 
00416 protected:
00417     NodeBlend* m_pNodeBlend;
00418     NodeBlender* m_pNodeBlender;
00419     Node * m_pStartNode;
00420     Node * m_pEndNode;
00421     BOOL m_bReverse;
00422     BOOL m_bStoreStartAndEndNodes;
00423     InitBlendActionType m_enInitType;
00424     BOOL m_bNodesMayBeChanged;
00425 };
00426 
00427 #endif

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