blendatt.h

Go to the documentation of this file.
00001 // $Id: blendatt.h 1273 2006-06-08 19:41:59Z 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 // Defines a class that is supplied as a parameter to the NodeAttribute::Blend() and 
00100 // AttributeValue::Blend() functions
00101 //
00102 // Implemented in attr.cpp
00103 
00104 #ifndef INC_BLENDATTRPARAM
00105 #define INC_BLENDATTRPARAM
00106 
00107 class CCAttrMap;
00108 class NodeAttribute;
00109 class AttributeValue;
00110 class NodeRenderableInk;
00111 class BlendPath;
00112 class NodeBlendPath;
00113 class HandleBecomeA;
00114 class SumAllPathsPathProcessor;
00115 class NodeBlend;
00116 
00117 enum ColourBlendType    {   COLOURBLEND_FADE,
00118                             COLOURBLEND_RAINBOW,
00119                             COLOURBLEND_ALTRAINBOW,
00120                             COLOURBLEND_NONE
00121                         };
00122 
00123 enum EditState {EDIT_STEPS, EDIT_DISTANCE,};
00124 enum EndObject {NONE, FIRST, LAST};
00125 
00126 /********************************************************************************************
00127 
00128 >   class BlendAttrParam : public CC_CLASS_MEMDUMP
00129 
00130     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00131     Created:    25/10/94
00132     Purpose:    Class that encapsulates the params needed by virtual NodeAttribute::Blend()
00133 
00134     NOTE:  GCS (27/7/2000):  I have ammended this class to allow blends to specify whether
00135     blending should affect all attributes data excluding position stuff.  The type of blending
00136     now done is determined by the slider that is dragged within the blend tool.
00137 
00138     This is particularly true of fills - who contain both 'colour' data and position data.
00139     When profiling the attributes of the blend, we do not want to alter the position data with
00140     respect to the attribute profile.
00141 
00142 ********************************************************************************************/
00143 
00144 class BlendAttrParam : public CC_CLASS_MEMDUMP
00145 {
00146 CC_DECLARE_MEMDUMP(BlendAttrParam);
00147 public:
00148     BlendAttrParam();
00149 
00150     // The destructor will delete it's internal node attr and attr val ptrs (set by SetBlendedAttr()
00151     // and SetBlendedAttrVal() repectively) if they are not NULL
00152     ~BlendAttrParam();
00153 
00154     // This sets up the object - See attr.cpp for the implementation of this function
00155     BOOL Init(RenderRegion *pThisRenderRegion,
00156               NodeAttribute* pThisOtherAttr, double ThisBlendRatio,
00157               ColourBlendType ColBlend, CCAttrMap* pStartAttrMap, CCAttrMap* pEndAttrMap, BOOL LastStep=FALSE);
00158 
00159     BOOL Init(RenderRegion *pThisRenderRegion,
00160               NodeAttribute* pThisOtherAttr, double ThisBlendRatio, double thisObjectRatio, BOOL objProcess,
00161               ColourBlendType ColBlend, CCAttrMap* pStartAttrMap, CCAttrMap* pEndAttrMap, BOOL LastStep=FALSE);
00162 
00163     // Member variable access functions
00164     RenderRegion*       GetRenderRegion()   { return pRenderRegion; }
00165     NodeAttribute*      GetOtherAttr()      { return pOtherNodeAttr; }
00166     AttributeValue*     GetOtherAttrVal()   { return pOtherAttrVal; }
00167     double              GetBlendRatio()     { return BlendRatio; }
00168     double              GetObjectRatio()    { return objectRatio; }
00169     BOOL                GetObjectProfileProcessing () { return (objectProfileProcessing); }
00170     ColourBlendType     GetColourBlend()    { return ColourBlend; }
00171 
00172     CCAttrMap*          GetStartAttrMap()   { return pAttrMapStart; }
00173     CCAttrMap*          GetEndAttrMap()     { return pAttrMapEnd; }
00174 
00175     // When you call these two get funcs, the pointer passed back becomes your responsibility (if its not NULL).
00176     // This means that you will have to delete it if you don't want to cause memory leaks.
00177     // Also, you will get NULL for all subsequent calls to the 'Get' func, until a new value is set by
00178     // it's sister 'Set' func.
00179     //
00180     // I.e. GetBlendedAttr() returns it's internal node attr ptr, then sets it to NULL
00181     NodeAttribute*      GetBlendedAttr();
00182     AttributeValue*     GetBlendedAttrVal();
00183 
00184     // When you call these funcs, the object you pass it becomes the property of the BlendAttrParam object.
00185     // 
00186     // If it's internal pointer is the same as the entry param, nothing happends
00187     // If it's internal pointer is not NULL and different to the entry param, the old one is deleted first.
00188     void SetBlendedAttr(NodeAttribute* pAttr);
00189     void SetBlendedAttrVal(AttributeValue* pAttrVal);
00190 
00191     // See if we are blending the last blend step
00192     // NB you need to call Init(..) with an accurately calcualted LastStep param
00193     // (see NodeBlend::BlendAttributes for an example)
00194     BOOL                    IsLastBlendStep() { return m_bLastStep; }
00195 
00196 private:
00197     RenderRegion*           pRenderRegion;
00198 
00199     NodeAttribute*          pOtherNodeAttr;
00200     AttributeValue*         pOtherAttrVal;
00201     double                  BlendRatio;
00202 
00203     NodeAttribute*          pBlendedNodeAttr;
00204     AttributeValue*         pBlendedAttrVal;
00205 
00206     CCAttrMap*              pAttrMapStart;
00207     CCAttrMap*              pAttrMapEnd;
00208 
00209     ColourBlendType         ColourBlend;
00210 
00211     BOOL                    m_bLastStep;
00212 
00213     // CGS ....
00214     
00215     double objectRatio;             // the 'matching' object ratio
00216     
00217     BOOL objectProfileProcessing;   // are we blending with respect to position data?
00218 };
00219 
00220 /********************************************************************************************
00221 
00222 >   class BlendNodeParam : public CC_CLASS_MEMDUMP
00223 
00224     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
00225     Created:    22/2/2000
00226     Purpose:    Class which encapsulates data for blending between nodes
00227                 We need all these so we don't duplicate code between this node
00228                 and the blender (unfortunately)
00229 
00230 ********************************************************************************************/
00231 class BlendNodeParam
00232 {
00233 public:
00234     BlendNodeParam()
00235     {
00236         m_pNodeBlend = NULL;
00237         m_pStartPath = NULL;
00238         m_pEndPath = NULL;
00239         m_BlendRatio = 0;
00240         m_AttrBlendRatio = 0;
00241         m_pRegion = NULL;
00242         m_pBlenderPath = NULL;
00243         m_AngleStart = 0;
00244         m_AngleEnd = 0;
00245         m_ObjectRatio = 0;
00246         m_InvObjectRatio = 0;
00247         m_ColourBlendType = COLOURBLEND_FADE;
00248         m_pNodeStart = NULL;
00249         m_pNodeEnd   = NULL;
00250         m_bIsOneToOne = FALSE;
00251         m_pHandleBecomeA = NULL;
00252         m_pPathProcessor = NULL;
00253     }
00254 
00255     void Init(NodeBlend* pBlender, RenderRegion * pRegion, BlendPath * pStartPath, BlendPath * pEndPath,
00256         double BlendRatio, double AttrBlendRatio,
00257         double AngleStart, double AngleEnd, double ObjectRatio,
00258         double InvObjectRatio, ColourBlendType ColBType,
00259         NodeRenderableInk * pNodeStart,
00260         NodeRenderableInk * pNodeEnd,
00261         BOOL IsOneToOne,
00262         NodeBlendPath * pBlenderPath = NULL,
00263         HandleBecomeA* pHandleBecomeA = NULL,
00264         SumAllPathsPathProcessor* pPathProcessor = NULL)
00265     {
00266         m_pNodeBlend        = pBlender;
00267         m_pStartPath        = pStartPath;
00268         m_pEndPath          = pEndPath;
00269         m_BlendRatio        = BlendRatio;
00270         m_pRegion           = pRegion;
00271         m_pBlenderPath      = pBlenderPath;
00272         m_AngleStart        = AngleStart;
00273         m_AngleEnd          = AngleEnd;
00274         m_ObjectRatio       = ObjectRatio;
00275         m_InvObjectRatio    = InvObjectRatio;
00276         m_ColourBlendType   = ColBType;
00277         m_pNodeStart        = pNodeStart;
00278         m_pNodeEnd          = pNodeEnd;
00279         m_bIsOneToOne       = IsOneToOne;
00280         m_AttrBlendRatio    = AttrBlendRatio;
00281         m_pHandleBecomeA    = pHandleBecomeA;
00282         m_pPathProcessor    = pPathProcessor;
00283     }
00284 
00285     // alternative way of initialising
00286     // takes all values from the blend node param, but just takes 2 blend paths
00287     void Init(BlendNodeParam *pParam, BlendPath * pStartPath, BlendPath * pEndPath,
00288         BOOL bInverse = FALSE)
00289     {
00290         m_pNodeBlend        = pParam->GetNodeBlend ();
00291         m_pStartPath        = pStartPath;
00292         m_pEndPath          = pEndPath;
00293 
00294         m_pRegion           = pParam->GetRenderRegion();
00295         m_pBlenderPath      = pParam->GetNodeBlendPath();
00296         m_AngleStart        = pParam->GetAngleEnd();
00297         m_AngleEnd          = pParam->GetAngleStart();
00298         m_ObjectRatio       = pParam->GetObjectRatio();
00299         m_InvObjectRatio    = pParam->GetInvertedAttributeRatio();
00300         m_ColourBlendType   = pParam->GetColourBlendType();
00301         m_pNodeStart        = pParam->GetNodeStart();
00302         m_pNodeEnd          = pParam->GetNodeEnd();
00303         m_bIsOneToOne       = pParam->GetOneToOne();
00304         m_pHandleBecomeA    = pParam->GetHandleBecomeA ();
00305         m_pPathProcessor    = pParam->GetPathProcessor ();
00306         
00307         if (!bInverse)
00308         {
00309             m_AttrBlendRatio    = pParam->GetAttrBlendRatio();
00310             m_BlendRatio        = pParam->GetBlendRatio();
00311         }
00312         else
00313         {
00314             m_AttrBlendRatio    = 1.0 - pParam->GetAttrBlendRatio();
00315             m_BlendRatio        = 1.0 - pParam->GetBlendRatio();
00316         }
00317 
00318     }
00319 
00320     BlendPath * GetStartBlendPath()     { return m_pStartPath; }
00321     BlendPath * GetEndBlendPath()       { return m_pEndPath; }
00322     double GetBlendRatio()              { return m_BlendRatio; }
00323     double GetAttrBlendRatio()          { return m_AttrBlendRatio; }
00324     RenderRegion * GetRenderRegion()    { return m_pRegion; }
00325     NodeBlendPath* GetNodeBlendPath()   { return m_pBlenderPath; }
00326     double GetAngleStart()              { return m_AngleStart; }
00327     double GetAngleEnd()                { return m_AngleEnd; }
00328     double GetObjectRatio()             { return m_ObjectRatio; }
00329     double GetInvertedAttributeRatio()  { return m_InvObjectRatio; }
00330     ColourBlendType GetColourBlendType() { return m_ColourBlendType; }
00331     BOOL GetOneToOne()                  { return m_bIsOneToOne; }
00332 
00333     void SetBlendRatio(double Ratio)    { m_BlendRatio = Ratio; }
00334 
00335     NodeRenderableInk * GetNodeStart()  { return m_pNodeStart; }
00336     NodeRenderableInk * GetNodeEnd()    { return m_pNodeEnd; }
00337 
00338     HandleBecomeA* GetHandleBecomeA () { return (m_pHandleBecomeA); }
00339 
00340     // CGS:  support for convert to editable shapes ....
00341 
00342     SumAllPathsPathProcessor* GetPathProcessor () { return (m_pPathProcessor); }
00343     void SetPathProcessor (SumAllPathsPathProcessor* proc) { m_pPathProcessor = proc; }
00344 
00345     NodeBlend* GetNodeBlend () { return (m_pNodeBlend); }
00346 
00347 private:
00348     NodeBlend* m_pNodeBlend;        // CGS:  ptr to the creator NodeBlend.  I need this so
00349                                     // that I may delete things correctly ....
00350     
00351     BlendPath * m_pStartPath;
00352     BlendPath * m_pEndPath;
00353     NodeBlendPath * m_pBlenderPath; // the path for the blender
00354     RenderRegion * m_pRegion;
00355     double m_BlendRatio;
00356     double m_AttrBlendRatio;
00357     double m_AngleStart;
00358     double m_AngleEnd;
00359     double m_ObjectRatio;
00360     double m_InvObjectRatio;
00361     ColourBlendType m_ColourBlendType;
00362     NodeRenderableInk * m_pNodeStart;
00363     NodeRenderableInk * m_pNodeEnd;
00364     BOOL m_bIsOneToOne;
00365     
00366     // CGS:  allows us to detect whether we are rendering, or whether we are
00367     // converting to editable shapes
00368     HandleBecomeA* m_pHandleBecomeA;
00369     
00370     // CGS:  by storing a ptr to the path processor we can convert to editable shapes
00371     SumAllPathsPathProcessor* m_pPathProcessor;
00372 } ;
00373 
00374 #endif  // INC_BLENDATTRPARAM
00375 
00376 

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