BrushRefBlender Class Reference

An instance of this class is designed to take two BrushRef objects and blend together their paths and attributes, churning out a BlendedBrushRef object at the end. It essentially rips off a lot of what the NodeBlender does, except that instead of rendering anything or existing in the tree it just produces a blended object. More...

#include <brushref.h>

List of all members.

Public Member Functions

 BrushRefBlender ()
 Default constructor.
 ~BrushRefBlender ()
 Default destructor.
void SetBrushRef (BrushRef *pBrushRef, BOOL First)
 Default destructor.
BrushRefBlend (BrushRef *pStartBrushRef, BrushRef *pOther, double Ratio)
 as above. A lot of this code is similar to that of NodeBlender::CreateBlends, however it is actuall used by the BrushComponent

Protected Member Functions

BOOL BlendPaths (BlendPath *pBlendPathStart, BlendPath *pBlendPathEnd, double BlendRatio)
 Blends two BlendPath objects by the amount specified in BlendRatio This is pretty much the same as the fn. by the same name in NodeBlender.
BOOL BlendAttributes (BlendPath *pBlendPathStart, BlendPath *pBlendPathEnd, CCAttrMap *pBlendedAttribMap, double BlendRatio)
 Blends the attributes of the two BlendPath objects by the amount specified in BlendRatio This is pretty much the same as the fn. by the same name in NodeBlender.
BOOL ReallocTempBuffers (UINT32 Size)
 Allocates memory for the temp path arrays, and sets the size var to 0 You can use calls to GetCoordArray(), GetVerbArray() and GetFlagArray() to get the alloced arrays.
void DeallocTempBuffers ()
 Releases memory allocated for the temp path arrays, and sets the size var to 0.
DocCoordGetCoordArray (UINT32 MinSize)
 Used to get an array you can write to.
PathVerbGetVerbArray (UINT32 MinSize)
 Used to get an array you can write to.
PathFlagsGetFlagArray (UINT32 MinSize)
 Used to get an array you can write to.
UINT32GetGBlendBuff (UINT32 MinSize)
 Used to get a buffer you can write to.

Protected Attributes

BrushRefm_pStartBrushRef
BrushRefm_pEndBrushRef
UINT32 m_TempArraySize
DocCoordm_pTempCoords
PathVerbm_pTempVerbs
PathFlagsm_pTempFlags
UINT32 m_GBlendBuffSize
UINT32m_pGBlendBuff
UINT32 m_ArrayLength

Private Member Functions

 CC_DECLARE_MEMDUMP (BrushRefBlender)


Detailed Description

An instance of this class is designed to take two BrushRef objects and blend together their paths and attributes, churning out a BlendedBrushRef object at the end. It essentially rips off a lot of what the NodeBlender does, except that instead of rendering anything or existing in the tree it just produces a blended object.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/12/99

Definition at line 223 of file brushref.h.


Constructor & Destructor Documentation

BrushRefBlender::BrushRefBlender  ) 
 

Default constructor.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/3/2000
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Definition at line 928 of file brushref.cpp.

00929 {
00930     m_pStartBrushRef    = NULL;  
00931     m_pEndBrushRef      = NULL;
00932 
00933     m_pTempCoords       = NULL;
00934     m_pTempVerbs        = NULL;
00935     m_pTempFlags        = NULL;
00936     m_GBlendBuffSize    = 0;
00937     m_pGBlendBuff       = NULL;
00938     m_ArrayLength       = 0;
00939 }

BrushRefBlender::~BrushRefBlender  ) 
 

Default destructor.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/3/2000
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Definition at line 955 of file brushref.cpp.

00956 {
00957     DeallocTempBuffers();
00958 }


Member Function Documentation

BrushRef * BrushRefBlender::Blend BrushRef pStartBrush,
BrushRef pEndBrush,
double  Ratio
 

as above. A lot of this code is similar to that of NodeBlender::CreateBlends, however it is actuall used by the BrushComponent

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/12/99
Parameters:
pStartBrush - the first brushref to blend [INPUTS] pEndBrush - the other brushref to blend to Ratio - the ratio of that to this
[OUTPUTS] 
Returns:
a newly allocated brushref created by blending this with pOther

Definition at line 999 of file brushref.cpp.

01000 {
01001     if (pStartBrush == NULL || pEndBrush == NULL)
01002     {
01003         ERROR3("brush ref is NULL in BrushRef::Blend");
01004         return NULL;
01005     }
01006 
01007     if (Ratio < 0 || Ratio > 1)
01008     {
01009         ERROR3("Invalid blend ratio");
01010         return NULL;
01011     }
01012 
01013     // allocate the extra memory that we need
01014     if (!ReallocTempBuffers(1000))
01015         return NULL;
01016 
01017     // right, lets go to work.  The first thing to do is translate both sets of paths to 0,0
01018     // the reason for this is that in the course of its normal existence the blendpaths can get
01019     // translated all over the place, so in order for our blend to make sense they should at least
01020     // be centered in the same place
01021     // We will also want to store their current location in order to translate them back when we're done
01022 //  DocRect StartRect = pStartBrush->GetBoundingRect();
01023 //  DocRect EndRect   = pEndBrush->GetBoundingRect();
01024 //  DocCoord StartCoord = StartRect.Centre();
01025 //  DocCoord EndCoord   = EndRect.Centre();
01026 
01027 //  pStartBrush->TranslateTo(DocCoord(0,0));
01028 //  pEndBrush->TranslateTo(DocCoord(0,0));
01029 
01030 
01031     // Find num blend paths in start and end, and keep hold of the MAX value
01032     UINT32 NumPathsInStart = pStartBrush->GetNumBlendPaths();
01033     UINT32 NumPathsInEnd   = pEndBrush->GetNumBlendPaths();
01034     UINT32 MaxNumPaths   = max(NumPathsInStart,NumPathsInEnd);
01035 
01036     if (NumPathsInStart == 0 || NumPathsInEnd == 0)
01037         return NULL;
01038 
01039     // This object is used to step along the the two lists of objects choosing a pair to go and blend.
01040     // It mainly comes into play when there are different numbers of objects in the two lists.
01041     ListStepper Stepper;
01042     Stepper.Init(NumPathsInStart, NumPathsInEnd, 0);
01043     INT32 NextPathStart, NextPathEnd;
01044 
01045     //allocate our new brushref
01046     BrushRef* pBlendedBrushRef = new BrushRef;
01047     if (pBlendedBrushRef == NULL)
01048         return NULL;
01049 
01050     // set up our variables, they will be allocated in the loop (slow I know)
01051     Path*      pBlendedPath = NULL;
01052     BlendPath* pNewBlendPath = NULL;
01053     CCAttrMap* pBlendedAttrMap = NULL;
01054 
01055     // Get the first pair of objects to blend
01056     Stepper.GetNext(&NextPathStart,&NextPathEnd);
01057 
01058     // The first pair of blend paths become the current blend path pair
01059     // Get ptrs to these, plus the subpath IDs of these
01060     BlendPath*  pCurrBlendPathStart = pStartBrush->GetBlendPath(NextPathStart);
01061     BlendPath*  pCurrBlendPathEnd   = pEndBrush->GetBlendPath(NextPathEnd  );
01062     UINT32      CurrSubPathIDStart  = pCurrBlendPathStart->GetSubPathID();
01063     UINT32      CurrSubPathIDEnd    = pCurrBlendPathEnd  ->GetSubPathID();
01064 
01065     // We also need info on the next blend path pair, so get some vars ready
01066     BlendPath*  pNextBlendPathStart = NULL;
01067     BlendPath*  pNextBlendPathEnd   = NULL;
01068     UINT32      NextSubPathIDStart = CurrSubPathIDStart; // This was uninitialized - AMB guessed a good value
01069     UINT32      NextSubPathIDEnd = CurrSubPathIDEnd; // This was uninitialized - AMB guessed a good value
01070 
01071     for (UINT32 NextPath = 0; NextPath < MaxNumPaths; NextPath++)
01072     {
01073         // allocate the variables
01074         pBlendedPath = new Path;
01075         pBlendedAttrMap = new CCAttrMap(30);
01076         
01077         if (pBlendedPath == NULL || pBlendedAttrMap == NULL )
01078             goto ExitNull;
01079         if (!pBlendedPath->Initialise())
01080             goto ExitNull;
01081 
01082         // Get the next pair of objects to blend
01083         Stepper.GetNext(&NextPathStart,&NextPathEnd);
01084         
01085         // if we haven't run out then assign the next path variables
01086         if (NextPathStart >= 0 && NextPathEnd >= 0)
01087         {
01088             pNextBlendPathStart = pStartBrush->GetBlendPath(NextPathStart);
01089             pNextBlendPathEnd   = pEndBrush->GetBlendPath(NextPathEnd);
01090             NextSubPathIDStart  = pNextBlendPathStart->GetSubPathID();
01091             NextSubPathIDEnd    = pNextBlendPathEnd->GetSubPathID();
01092         }
01093     
01094 
01095         if (BlendAttributes(pCurrBlendPathStart, pCurrBlendPathEnd, pBlendedAttrMap, Ratio))
01096         {
01097             // Blend the paths together, putting the blended path in BlendedPath
01098             if (BlendPaths(pCurrBlendPathStart,pCurrBlendPathEnd,Ratio))
01099             {
01100                 // The blended path will be filled  if either of the paths are filled
01101                 // The blended path will be stroked if either of the paths are stroked
01102                 BOOL Filled  = pCurrBlendPathStart->IsFilled()  || pCurrBlendPathEnd->IsFilled();
01103                 BOOL Stroked = pCurrBlendPathStart->IsStroked() || pCurrBlendPathEnd->IsStroked();
01104                     
01105                 if (!pBlendedPath->MakeSpaceInPath(m_ArrayLength)) 
01106                     goto ExitNull;
01107                 pBlendedPath->MergeTwoPaths(m_pTempCoords,m_pTempVerbs,m_pTempFlags,m_ArrayLength,Filled);
01108                 pBlendedPath->IsFilled  = Filled;
01109                 pBlendedPath->IsStroked = Stroked;
01110                 
01111                 // We haven't yet got a complete path to render or pass back if next path has the same ID and is
01112                 // a different path
01113                 // (this applies to the start OR the end path)
01114                 BOOL NotACompletePath = ((CurrSubPathIDStart == NextSubPathIDStart && pCurrBlendPathStart != pNextBlendPathStart) ||
01115                     (CurrSubPathIDEnd   == NextSubPathIDEnd   && pCurrBlendPathEnd   != pNextBlendPathEnd  ));
01116                 
01117                 if (!NotACompletePath)
01118                 {   
01119                     // it all worked, lets allocate a new blendpath
01120                     pNewBlendPath = new BlendPath;
01121                     if (pNewBlendPath == NULL)
01122                         goto ExitNull;
01123                 
01124                     // tell it to use our blended path and attributes
01125                     pNewBlendPath->SetPath(pBlendedPath);
01126                     pNewBlendPath->SetAppliedAttributes(pBlendedAttrMap);
01127 
01128                     // give it to the brushref
01129                     pBlendedBrushRef->AddBlendPath(pNewBlendPath);
01130                 }
01131                 else
01132                     goto ExitNull;
01133 
01134                 pNewBlendPath = NULL;
01135                 pBlendedPath = NULL;
01136                 pBlendedAttrMap = NULL;
01137             }
01138             else // end if blendpaths
01139                 goto ExitNull;
01140         } // end if blendattributes
01141         else
01142             goto ExitNull;
01143     } // end for
01144 
01145 //  DeallocTempBuffers();
01146     
01147     // translate the brushes back
01148     //pStartBrush->TranslateTo(StartCoord);
01149     //pEndBrush->TranslateTo(EndCoord);
01150     return pBlendedBrushRef;
01151 
01152 // just so I don't have to keep repeating this code, if an allocation fails then come here where everything is deleted
01153 ExitNull:
01154     if (pBlendedPath != NULL)
01155         delete pBlendedPath;
01156     if (pBlendedBrushRef != NULL)
01157         delete pBlendedBrushRef;
01158     if (pBlendedAttrMap != NULL)
01159         delete pBlendedAttrMap;
01160     if (pNewBlendPath != NULL)
01161         delete pNewBlendPath;
01162     ERROR3("Something went wrong in BrushRefBlender::Blend");
01163     return NULL;
01164 }

BOOL BrushRefBlender::BlendAttributes BlendPath pBlendPathStart,
BlendPath pBlendPathEnd,
CCAttrMap pBlendedAttrMap,
double  BlendRatio
[protected]
 

Blends the attributes of the two BlendPath objects by the amount specified in BlendRatio This is pretty much the same as the fn. by the same name in NodeBlender.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/3/2000
Parameters:
[INPUTS] pBlendPathStart = ptr to blend path to blend from pBlendPathEnd = ptr to blend path to blend to pBlendedAttrMap = ptr to map to store the blended attributes in BlendRatio = amount to blend by (0.0 <= BlendPath <= 1.0)
- [OUTPUTS]
Returns:
TRUE if successful, FALSE otherwise
See also:
-

Definition at line 1357 of file brushref.cpp.

01359 {
01360     // Check entry params
01361     BOOL ok = (pBlendPathStart != NULL &&
01362                 pBlendPathEnd != NULL && pBlendedAttrMap != NULL);
01363     ERROR3IF(!ok,"One or more NULL entry params");
01364     if (!ok) return FALSE;
01365 
01366     // Find the attributes that are applied to the blend paths
01367     CCAttrMap* pAttrMapStart = pBlendPathStart->FindAppliedAttributes();
01368     CCAttrMap* pAttrMapEnd   = pBlendPathEnd->FindAppliedAttributes();
01369 
01370     // If either are NULL, return FALSE
01371     if (pAttrMapStart == NULL || pAttrMapEnd == NULL) return FALSE;
01372 
01373     // These vars are used as params to the CCAttrMap funcs
01374     CCRuntimeClass     *pTypeStart;
01375     void               *pValStart;
01376     void               *pValEnd;
01377     double              OldBlendRatio = BlendRatio;
01378     // Process each attribute in turn
01379     CCAttrMap::iterator PosStart = pAttrMapStart->GetStartPosition();
01380     for (;PosStart != pAttrMapStart->GetEndPosition();)
01381     {
01382         // Get a ptr to the attr at position PosStart in the start node's attr map
01383         pAttrMapStart->GetNextAssoc( PosStart, pTypeStart, pValStart );
01384         NodeAttribute* pNodeAttrStart = (NodeAttribute *)pValStart;
01385     
01386         BlendRatio = OldBlendRatio; 
01387         // Diccon 10/99 When using non-linear profiles for the objects those attributes
01388         // that make use of control points were not being profiled, making the objects look strange.
01389         // to avoid this those attributes now share the same profiles as the objects.
01390     /*  if (pNodeAttrStart->IsAGradFill())
01391         {
01392         
01393             if (!((AttrFillGeometry*)pNodeAttrStart)->IsAColourFill())
01394             {
01395                 
01396                 BlendRatio = GetObjectRatio();
01397             
01398             }
01399             else
01400             {
01401                 BlendRatio = GetInvertedAttributeRatio();
01402             
01403             }
01404 
01405         }
01406         if (pNodeAttrStart->IsAFlatFill() || (pNodeAttrStart->GetRuntimeClass() == CC_RUNTIME_CLASS(AttrLineWidth)))
01407         {
01408             BlendRatio = GetInvertedAttributeRatio();
01409         }
01410 
01411         */      
01412         // Get a blended attribute
01413         NodeAttribute* pBlendedNodeAttr = NULL;
01414 
01415         // Find an attr of the same type in the end object's attr list,
01416         // and blend the two attrs together
01417         if( pAttrMapEnd->Lookup( pTypeStart, pValEnd ) )
01418         {
01419             // We've found a matching end attr, so try to blend it with the start attr
01420 
01421             // Set up the param object to pass to the start attr's blend method
01422             BlendAttrParam BlendParam;
01423             
01424             // Initialise the BlendParam with the end attr and blend ratio
01425             if (BlendParam.Init(NULL,
01426                                 (NodeAttribute *)pValEnd,BlendRatio,COLOURBLEND_FADE,
01427                                 pAttrMapStart, pAttrMapEnd))
01428             {
01429                 // Successfully initialised, so now try blending the attributes
01430                 if (pNodeAttrStart->Blend(&BlendParam))
01431                 {
01432                     // Attrs successfully blended, now get a ptr to the new attr.
01433                     // Once we get the blended attr ptr, it belongs to us, so we have
01434                     // to delete it when it is not needed
01435                     pBlendedNodeAttr = BlendParam.GetBlendedAttr();
01436                 }
01437             }
01438         }
01439 
01440         // If we have a blended attr, pBlendedNodeAttr != NULL
01441         if (pBlendedNodeAttr != NULL)
01442         {
01443             // Get the type of the blended attr
01444             CCRuntimeClass *pTypeBlend = pBlendedNodeAttr->GetAttributeType();
01445             void       *pValBlend;
01446 
01447             // If we already have an attr in the blended attr map of the same type,
01448             // remove it and delete it, before inserting a new attr of this type
01449             if (pBlendedAttrMap->Lookup(pTypeBlend,pValBlend))
01450             {
01451                 if (pValBlend != NULL)
01452                 {
01453                     pBlendedAttrMap->RemoveKey(pTypeBlend);
01454                     delete (NodeAttribute*)pValBlend;
01455                 }
01456             }
01457             // add it to the blend map
01458             pBlendedAttrMap->SetAt( pTypeBlend, pBlendedNodeAttr );
01459         }
01460     }
01461 
01462 
01463     return TRUE;
01464 }

BOOL BrushRefBlender::BlendPaths BlendPath pBlendPathStart,
BlendPath pBlendPathEnd,
double  BlendRatio
[protected]
 

Blends two BlendPath objects by the amount specified in BlendRatio This is pretty much the same as the fn. by the same name in NodeBlender.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/3/2000
Parameters:
pBlendPathStart = ptr to blend path to blend from [INPUTS] pBlendPathEnd = ptr to blend path to blend to BlendRatio = amount to blend by (0.0 <= BlendPath <= 1.0)
The blended path is stored in three arrays: the coords, the verbs, and the flags. [OUTPUTS] The arrays are:
pTempCoords pTempVerbs pTempFlags

ArrayLength = the length of all three arrays

This allows the caller to decide what to do with the blended path in a very flexible way.

Returns:
TRUE if successful, FALSE otherwise
See also:

Definition at line 1494 of file brushref.cpp.

01495 {
01496     // Check entry params
01497     BOOL    ok = (pBlendPathStart != NULL && pBlendPathEnd != NULL);
01498     if (ok) ok = (pBlendPathStart->GetBlendNode() != NULL && pBlendPathEnd->GetBlendNode() != NULL);
01499     ERROR3IF(!ok,"One or more NULL entry params");
01500     if (!ok) return FALSE;
01501 
01502     // Get the types of the two paths
01503     PathTypeEnum PathTypeStart = pBlendPathStart->GetPathType();
01504     PathTypeEnum PathTypeEnd   = pBlendPathEnd  ->GetPathType();
01505 
01506     // The blended path will be closed if either of the paths is a shape
01507     BOOL Closed = (PathTypeStart == PATHTYPE_SHAPE) || (PathTypeEnd == PATHTYPE_SHAPE);
01508 
01509     Path * pPathStart = NULL;
01510 
01511     // Find the paths associated with the start and end blend paths
01512     if (pBlendPathStart->GetBlendNode()->IsNodePath())
01513     {
01514         pPathStart = &(((NodePath *)pBlendPathStart->GetBlendNode())->InkPath);
01515     }
01516     else
01517     {
01518         pPathStart = &(((NodePath *)((NodeCompound *)pBlendPathStart->GetBlendNode())->GetNodeToBlend())->InkPath);
01519     }
01520 
01521     Path * pPathEnd = NULL;
01522 
01523     if (pBlendPathEnd->GetBlendNode()->IsNodePath())
01524     {
01525         pPathEnd   = &(((NodePath *)pBlendPathEnd->GetBlendNode())->InkPath);
01526     }
01527     else
01528     {
01529         pPathEnd = &(((NodePath *)((NodeCompound *)pBlendPathEnd->GetBlendNode())->GetNodeToBlend())->InkPath);
01530     }
01531 
01532     // Calculate how large the arrays have to be to store the blended path definition
01533     INT32 DestPathSize = ((pPathStart->GetNumCoords()+pPathEnd->GetNumCoords())*3)+500;
01534 
01535     // Get some arrays used to hold the blended path data, and error if any are NULL
01536     DocCoord*   pDestCoords = GetCoordArray(DestPathSize);
01537     PathVerb*   pDestVerbs  = GetVerbArray(DestPathSize);
01538     PathFlags*  pDestFlags  = GetFlagArray(DestPathSize);
01539     UINT32*         pBuff       = GetGBlendBuff(DestPathSize);
01540     if (pDestCoords == NULL || pDestVerbs == NULL || pDestFlags == NULL || pBuff == NULL)
01541         return FALSE;
01542 
01543     // This section copes with the case when blending a line with a shape.
01544     // In this case we need to get a temp path the is actually a shape version of the line.
01545     // The line is simply reversed back onto itself to form a shape that would look identical to the 
01546     // line if rendered.  This allows the line to appear to open up to the shape when blended.
01547     Path Shape;
01548     if (PathTypeStart != PathTypeEnd)
01549     {
01550         BOOL ok = FALSE;
01551         if (!Shape.Initialise()) return FALSE;
01552 
01553         // if going from a line to a shape, convert the start path to a shape
01554         if (PathTypeStart == PATHTYPE_LINE && PathTypeEnd == PATHTYPE_SHAPE)
01555         {
01556             ok = NodeBlender::ConvertLineToShape(pPathStart,&Shape);
01557             pPathStart = &Shape;
01558         }
01559 
01560         // if going from a shape to a line, convert the end path to a shape
01561         if (PathTypeStart == PATHTYPE_SHAPE && PathTypeEnd == PATHTYPE_LINE)
01562         {
01563             ok = NodeBlender::ConvertLineToShape(pPathEnd,&Shape);
01564             pPathEnd = &Shape;
01565         }
01566 
01567         if (!ok) return FALSE;
01568     }
01569 
01570     BOOL OneToOne = FALSE;
01571     // Now actually blend the two paths
01572 
01573     GBlend GBlendObj;
01574 
01575     // Define the blend
01576     GBlendObj.Define(   (PPOINT)pPathStart->GetCoordArray(),    // Specify the start path
01577                         pPathStart->GetVerbArray(),
01578                         pPathStart->GetNumCoords(),
01579 
01580                         (PPOINT)pPathEnd  ->GetCoordArray(),    // Specify the end path
01581                         pPathEnd  ->GetVerbArray(),
01582                         pPathEnd  ->GetNumCoords(),
01583 
01584                         OneToOne,                               // The one-to-one flag
01585                         FLATNESS,                               // Flatness
01586 
01587                         pBuff,                                  // Buffer for GBlend to use
01588                         DestPathSize*sizeof(UINT32));           // The buffer size
01589 
01590     // Blend the paths
01591     m_ArrayLength = GBlendObj.Blend(BlendRatio,                 // The blend ratio, 0.0 < BlendRatio < 1.0
01592                                     (PPOINT)pDestCoords,        // Array to store blended coords
01593                                     pDestVerbs,                 // Array to store blended verbs
01594                                     DestPathSize);              // The num elements in the two arrays
01595 
01596 
01597     // If we're blending a line to another line, we need to make sure that the blended line
01598     // is going in a direction that corresponds to the source lines.  This ensures attributes
01599     // that depend on this direction (e.g. start and end arrows) look correct.
01600     //
01601     // When creating blend paths of lines, we can detect if the blend path has been reversed,
01602     // in relation to the original path, by the original mapping value.
01603     // If it's 0 it has NOT been reversed, otherwise it's been reversed.
01604     //
01605     // If the blend ratio is <=0.5, the blended path is closest to the start blend path,
01606     // so we look at the start blend path's original mapping.
01607     //
01608     // If blend ration > 0.5, look at the end blend path's original mapping.
01609     //
01610     // The (BlendRation <= 0.5) cut-off point is the same as the cut-off point used in the blending
01611     // of attributes.
01612     if (pBlendPathStart->IsLine() && pBlendPathEnd->IsLine())
01613     {
01614         BlendPath* pBlendPath;
01615         if (BlendRatio <= 0.5) 
01616             pBlendPath = pBlendPathStart;
01617         else
01618             pBlendPath = pBlendPathEnd;
01619 
01620         if (pBlendPath->GetOrigMapping() != 0)
01621             NodeBlender::ReversePath(pDestCoords,pDestVerbs,m_ArrayLength);
01622     }
01623 
01624     // We need to do some work on the blended path
01625     if (!NodeBlender::ProcessBlendedPath(pDestCoords,pDestVerbs,pDestFlags,m_ArrayLength,Closed))
01626         return FALSE;
01627 
01628     return TRUE;
01629 }

BrushRefBlender::CC_DECLARE_MEMDUMP BrushRefBlender   )  [private]
 

void BrushRefBlender::DeallocTempBuffers  )  [protected]
 

Releases memory allocated for the temp path arrays, and sets the size var to 0.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/3/2000
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-
See also:
-

Definition at line 1325 of file brushref.cpp.

01326 {
01327     if (m_pTempCoords != NULL) { CCFree(m_pTempCoords); m_pTempCoords = NULL; }
01328     if (m_pTempVerbs  != NULL) { CCFree(m_pTempVerbs);  m_pTempVerbs  = NULL; }
01329     if (m_pTempFlags  != NULL) { CCFree(m_pTempFlags);  m_pTempFlags  = NULL; }
01330     m_TempArraySize = 0;
01331 
01332     if (m_pGBlendBuff != NULL) { CCFree(m_pGBlendBuff); m_pGBlendBuff = NULL; }
01333     m_GBlendBuffSize = 0;
01334 }

DocCoord * BrushRefBlender::GetCoordArray UINT32  MinSize  )  [protected]
 

Used to get an array you can write to.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/11/94
Parameters:
MinSize = min size the array should be [INPUTS]
- [OUTPUTS]
Returns:
Ptr to the array, or NULL if can't get memory
See also:
-

Definition at line 1182 of file brushref.cpp.

01183 {
01184     MinSize++;
01185     if (m_TempArraySize >= MinSize) return m_pTempCoords;
01186 
01187     if (ReallocTempBuffers(MinSize))
01188         return m_pTempCoords;
01189     else
01190         return NULL;
01191 }

PathFlags * BrushRefBlender::GetFlagArray UINT32  MinSize  )  [protected]
 

Used to get an array you can write to.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/11/94
Parameters:
MinSize = min size the array should be [INPUTS]
- [OUTPUTS]
Returns:
Ptr to the array, or NULL if can't get memory
See also:
-

Definition at line 1232 of file brushref.cpp.

01233 {
01234     MinSize++;
01235     if (m_TempArraySize >= MinSize) return m_pTempFlags;
01236 
01237     if (ReallocTempBuffers(MinSize))
01238         return m_pTempFlags;
01239     else
01240         return NULL;
01241 }

UINT32 * BrushRefBlender::GetGBlendBuff UINT32  MinSize  )  [protected]
 

Used to get a buffer you can write to.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/11/94
Parameters:
MinSize = min size the buffer should be [INPUTS]
- [OUTPUTS]
Returns:
Ptr to the buffer, or NULL if can't get memory
See also:
-

Definition at line 1257 of file brushref.cpp.

01258 {
01259     MinSize++;
01260     if (m_GBlendBuffSize >= MinSize) return m_pGBlendBuff;
01261 
01262     if (m_pGBlendBuff != NULL) CCFree(m_pGBlendBuff);
01263 
01264     m_pGBlendBuff = (UINT32*) CCMalloc(MinSize*sizeof(UINT32));
01265 
01266     if (m_pGBlendBuff != NULL)
01267         m_GBlendBuffSize = MinSize;
01268     else
01269         m_GBlendBuffSize = 0;
01270 
01271     return m_pGBlendBuff;
01272 }

PathVerb * BrushRefBlender::GetVerbArray UINT32  MinSize  )  [protected]
 

Used to get an array you can write to.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/11/94
Parameters:
MinSize = min size the array should be [INPUTS]
- [OUTPUTS]
Returns:
Ptr to the array, or NULL if can't get memory
See also:
-

Definition at line 1207 of file brushref.cpp.

01208 {
01209     MinSize++;
01210     if (m_TempArraySize >= MinSize) return m_pTempVerbs;
01211 
01212     if (ReallocTempBuffers(MinSize))
01213         return m_pTempVerbs;
01214     else
01215         return NULL;
01216 }

BOOL BrushRefBlender::ReallocTempBuffers UINT32  Size  )  [protected]
 

Allocates memory for the temp path arrays, and sets the size var to 0 You can use calls to GetCoordArray(), GetVerbArray() and GetFlagArray() to get the alloced arrays.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/3/2000
Parameters:
Size = Size the temp arrays should be [INPUTS]
- [OUTPUTS]
Returns:
-
See also:
-

Definition at line 1290 of file brushref.cpp.

01291 {
01292     DeallocTempBuffers();
01293 
01294     // Allocate the arrays
01295     m_TempArraySize = Size;
01296     m_pTempCoords   = (DocCoord*)  CCMalloc(Size*sizeof(DocCoord));
01297     m_pTempVerbs    = (PathVerb*)  CCMalloc(Size*sizeof(PathVerb));
01298     m_pTempFlags    = (PathFlags*) CCMalloc(Size*sizeof(PathFlags));
01299 
01300     // If any of the arrays are not allocated, dealloc the alloced ones, and return FALSE
01301     if (m_pTempCoords == NULL || m_pTempVerbs == NULL || m_pTempFlags == NULL)
01302     {
01303         DeallocTempBuffers();
01304         return FALSE;
01305     }
01306 
01307     // It's all OK, so return TRUE
01308     return TRUE;
01309 }

void BrushRefBlender::SetBrushRef BrushRef pBrushRef,
BOOL  Start
 

Default destructor.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/3/2000
Parameters:
the brushref to set, and whether it is the first or last brushref [INPUTS]
- [OUTPUTS]
Returns:
-

Definition at line 973 of file brushref.cpp.

00974 {
00975     if (pBrushRef == NULL)
00976         return;
00977     if (Start)
00978         m_pStartBrushRef = pBrushRef;
00979     else
00980         m_pEndBrushRef = pBrushRef;
00981 }


Member Data Documentation

UINT32 BrushRefBlender::m_ArrayLength [protected]
 

Definition at line 262 of file brushref.h.

UINT32 BrushRefBlender::m_GBlendBuffSize [protected]
 

Definition at line 260 of file brushref.h.

BrushRef* BrushRefBlender::m_pEndBrushRef [protected]
 

Definition at line 252 of file brushref.h.

UINT32* BrushRefBlender::m_pGBlendBuff [protected]
 

Definition at line 261 of file brushref.h.

BrushRef* BrushRefBlender::m_pStartBrushRef [protected]
 

Definition at line 251 of file brushref.h.

DocCoord* BrushRefBlender::m_pTempCoords [protected]
 

Definition at line 257 of file brushref.h.

PathFlags* BrushRefBlender::m_pTempFlags [protected]
 

Definition at line 259 of file brushref.h.

PathVerb* BrushRefBlender::m_pTempVerbs [protected]
 

Definition at line 258 of file brushref.h.

UINT32 BrushRefBlender::m_TempArraySize [protected]
 

Definition at line 256 of file brushref.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:51:42 2007 for Camelot by  doxygen 1.4.4