HandleBecomeA Class Reference

Objects of this class are passed into NodeBlender::CreateBlends() so that they can receive all the paths the blender generates in order to convert the blender into shapes (or more specifically NodePaths). More...

#include <nodebldr.h>

List of all members.

Public Member Functions

 HandleBecomeA (NodeBlender *pThisNodeBlender, Node *pThisContextNode, BecomeA *pThisBecomeA)
BOOL PassBack (Path *pBlendedPath, CCAttrMap *pBlendedAttrMap, UINT32 Step)
 This takes a path and an attribute map generated by a NodeBlender object, and generates a NodePath object, if it wants to become a path object If pBecomeA->Reason == BECOMEA_REPLACE, the NodePath and attributes are added to the tree. If pBecomeA->Reason == BECOMEA_PASSBACK, the NodePath is passed to the routine.
void SetNumPathsPerStep (UINT32 Num)
BOOL MakeGroupPerStep ()
BecomeAGetBecomeA ()
NodeGetContextNode ()

Private Member Functions

 CC_DECLARE_MEMDUMP (HandleBecomeA)

Private Attributes

NodeBlenderpNodeBlender
BecomeApBecomeA
NodepContextNode
NodeGrouppNodeGroup
UINT32 LastStep
UINT32 NumPathsPerStep


Detailed Description

Objects of this class are passed into NodeBlender::CreateBlends() so that they can receive all the paths the blender generates in order to convert the blender into shapes (or more specifically NodePaths).

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/10/94

Definition at line 728 of file nodebldr.h.


Constructor & Destructor Documentation

HandleBecomeA::HandleBecomeA NodeBlender pThisNodeBlender,
Node pThisContextNode,
BecomeA pThisBecomeA
[inline]
 

Definition at line 732 of file nodebldr.h.

00734                                                   : 
00735                     pNodeBlender(pThisNodeBlender), 
00736                     pBecomeA(pThisBecomeA),
00737                     pContextNode(pThisContextNode),
00738                     pNodeGroup(NULL),
00739                     LastStep(0),
00740                     NumPathsPerStep(0) {}


Member Function Documentation

HandleBecomeA::CC_DECLARE_MEMDUMP HandleBecomeA   )  [private]
 

BecomeA* HandleBecomeA::GetBecomeA  )  [inline]
 

Definition at line 747 of file nodebldr.h.

00747 { return (pBecomeA); }

Node* HandleBecomeA::GetContextNode  )  [inline]
 

Definition at line 748 of file nodebldr.h.

00748 { return (pContextNode); }

BOOL HandleBecomeA::MakeGroupPerStep  )  [inline]
 

Definition at line 745 of file nodebldr.h.

00745 { return (NumPathsPerStep > 1); }

BOOL HandleBecomeA::PassBack Path pBlendedPath,
CCAttrMap pBlendedAttrMap,
UINT32  Step
 

This takes a path and an attribute map generated by a NodeBlender object, and generates a NodePath object, if it wants to become a path object If pBecomeA->Reason == BECOMEA_REPLACE, the NodePath and attributes are added to the tree. If pBecomeA->Reason == BECOMEA_PASSBACK, the NodePath is passed to the routine.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/10/94
Parameters:
pBlendedPath = ptr to a blended path object [INPUTS] pBlendedAttrMap = ptr to the blended attributes for this path Step = The step number this path belongs to
- [OUTPUTS]
Returns:
TRUE if successful, FALSE otherwise

Definition at line 6708 of file nodebldr.cpp.

06709 {
06710     // Check BecomeA mechanism has been set up
06711     ERROR3IF(pBecomeA     == NULL,"pBecomeA is NULL");
06712     ERROR3IF(pNodeBlender == NULL,"pNodeBlender is NULL");
06713     if (pBecomeA == NULL || pNodeBlender == NULL)
06714         return FALSE;
06715 
06716     // Check for a NULL entry params
06717     ERROR3IF(pBlendedPath      == NULL,"pBlendedPath is NULL");
06718     ERROR3IF(pBlendedAttrMap == NULL,"pBlendedAttrMap is NULL");
06719     if (pBlendedPath == NULL || pBlendedAttrMap == NULL) return FALSE;
06720 
06721     // This lump checks that the Reason is one that we understand
06722     // It also makes sure that we don't have a NULL UndoOp ptr
06723     BOOL ValidReason = (pBecomeA->GetReason() == BECOMEA_REPLACE || pBecomeA->GetReason() == BECOMEA_PASSBACK);
06724     ERROR3IF_PF(!ValidReason,("Unkown BecomeA reason %d",pBecomeA->GetReason()));
06725     if (!ValidReason) return FALSE;
06726 
06727     // pBecomeA->Reason is one that we understand.
06728 
06729     BOOL        Success = TRUE;         // Our success flag (Important that this defaults to TRUE)
06730     NodePath*   pNewNodePath = NULL;    // Ptr to a new NodePath, if we get to make one.
06731 
06732     if (pBecomeA->BAPath())
06733     {
06734         // We need to create a new NodePath, no matter what the reason.
06735         
06736         // Allocate a new NodePath node
06737         ALLOC_WITH_FAIL(pNewNodePath, (new NodePath), pBecomeA->GetUndoOp());
06738         Success = (pNewNodePath != NULL);
06739 
06740         // Initialise the path
06741         if (Success) CALL_WITH_FAIL(pNewNodePath->InkPath.Initialise(pBlendedPath->GetNumCoords(),12), pBecomeA->GetUndoOp(), Success);
06742         if (Success) CALL_WITH_FAIL(pNewNodePath->InkPath.CopyPathDataFrom(pBlendedPath), pBecomeA->GetUndoOp(), Success);
06743 
06744         // If Success is TRUE, then we now have a new NodePath object that contains this shape's path
06745 
06746         if (Success)
06747         {
06748             switch (pBecomeA->GetReason())
06749             {
06750                 case BECOMEA_REPLACE :
06751                 {
06752                     // It's a BECOMEA_REPLACE, so put the new NodePath in the tree in an undoable way
06753 
06754                     // Can't do it in an undoable way without an Undo Op
06755 //                  ERROR2IF_PF(pBecomeA->GetUndoOp() == NULL,FALSE,("GetUndoOp() returned NULL"));
06756 
06757                     // Can't do it if we don't have a context node
06758                     ERROR2IF(pContextNode == NULL,FALSE,"pContextNode is NULL");
06759 
06760                     // By default, attach the new path as the previous child of the context node
06761                     Node*               pAttachNode = pContextNode;
06762                     AttachNodeDirection AttachDir   = PREV;
06763 
06764                     // By default, create a hide node action for the new path we're attaching to the tree
06765                     BOOL    HideNode    = TRUE;
06766                     Node*   pNodeToHide = pNewNodePath;
06767 
06768                     // Should we be placing all created paths inside a group?
06769                     if (MakeGroupPerStep())
06770                     {
06771                         // Do we need to create a new group? I.e. is this the first path created for this step of the blend?
06772                         if (Step != LastStep)
06773                         {
06774                             // Remember this step value so we can tell if the next path we receive belongs to the
06775                             // same blend step
06776                             LastStep = Step;
06777 
06778                             // Create a new group and place it in the tree next to the context node
06779                             pNodeGroup  = new NodeGroup;
06780                             Success     = (pNodeGroup != NULL);
06781                             if (Success)
06782                             {
06783                                 // Put group into the tree
06784                                 pNodeGroup->AttachNode(pContextNode,PREV);
06785 
06786                                 // Make a hide node action for this group
06787                                 HideNode = TRUE;
06788                                 pNodeToHide = pNodeGroup;
06789                             }
06790                         }
06791                         else
06792                             HideNode = FALSE;   // We created a hide node action when this group was created
06793 
06794                         // If we have a group node, make sure the new path gets placed in the tree as the
06795                         // group's last child
06796                         if (Success)
06797                         {
06798                             pAttachNode = pNodeGroup;
06799                             AttachDir   = LASTCHILD;
06800                         }
06801                     }
06802                                 
06803                     if (Success)
06804                     {
06805                         ERROR2IF(pAttachNode == NULL,FALSE,"The attach node is NULL!!!");
06806 
06807                         // Insert the new NodePath into the tree
06808                         pNewNodePath->AttachNode(pAttachNode,AttachDir);
06809 
06810                         // Apply all the attributes to the new path
06811                         pNewNodePath->ApplyAttributes(pBlendedAttrMap,TRUE);
06812 
06813                         // Set the bounds  
06814                         pNewNodePath->ValidateBoundingRect();
06815                         pNewNodePath->InvalidateBoundingRect();
06816 
06817                         // Create a hide node action to hide the node when we undo 
06818                         if (HideNode)
06819                         {
06820                             ERROR2IF(pNodeToHide == NULL,FALSE,"pNodeToHide is NULL");
06821 
06822                             if (pBecomeA->GetUndoOp())
06823                             {
06824                                 HideNodeAction* UndoHideNodeAction;     
06825                                 Success = (HideNodeAction::Init(pBecomeA->GetUndoOp(),
06826                                                          pBecomeA->GetUndoOp()->GetUndoActionList(),
06827                                                          pNodeToHide,
06828                                                          TRUE,       // Include subtree size 
06829                                                          ( Action**)(&UndoHideNodeAction))
06830                                                          != AC_FAIL);
06831                             }
06832                         }
06833 
06834                         CCAttrMap* pNewAttrMap = pBlendedAttrMap->Copy();
06835                         if (pNewAttrMap != NULL)
06836                             pBecomeA->PassBack(pNewNodePath, pNodeBlender, pNewAttrMap);
06837                     }
06838                 }
06839                 break;
06840 
06841                 case BECOMEA_PASSBACK :
06842                 {
06843                     // We need to create a copy of the blended attributes to give to the caller
06844                     // as they don't exist in the tree, and the ones in pBlendedAttrMap will be
06845                     // deleted eventually.
06846                     CCAttrMap* pNewAttrMap = pBlendedAttrMap->Copy();
06847                     if (pNewAttrMap != NULL)
06848                         Success = pBecomeA->PassBack(pNewNodePath,pNodeBlender,pNewAttrMap);
06849                     else
06850                         Success = FALSE;
06851                     break;
06852                 }
06853 
06854                 default:
06855                     break;
06856             }
06857         }
06858     }
06859 
06860     if (!Success)
06861     {
06862         if (pNodeGroup != NULL)
06863         {
06864             // Delete all the groups children (if it has any) and unlink it from the tree (if it's linked)
06865             // This is all done by CascadeDelete()
06866             pNodeGroup->CascadeDelete(); 
06867             delete pNodeGroup;
06868             pNodeGroup = NULL;
06869         }
06870         else if (pNewNodePath != NULL)
06871         {
06872             // Delete all the NodePath's children (if it has any) and unlink it from the tree (if it's linked)
06873             // This is all done by CascadeDelete()
06874             pNewNodePath->CascadeDelete(); 
06875             delete pNewNodePath;
06876             pNewNodePath = NULL;
06877         }
06878     }
06879 
06880     return Success;
06881 }

void HandleBecomeA::SetNumPathsPerStep UINT32  Num  )  [inline]
 

Definition at line 744 of file nodebldr.h.

00744 { NumPathsPerStep = Num; }


Member Data Documentation

UINT32 HandleBecomeA::LastStep [private]
 

Definition at line 755 of file nodebldr.h.

UINT32 HandleBecomeA::NumPathsPerStep [private]
 

Definition at line 756 of file nodebldr.h.

BecomeA* HandleBecomeA::pBecomeA [private]
 

Definition at line 752 of file nodebldr.h.

Node* HandleBecomeA::pContextNode [private]
 

Definition at line 753 of file nodebldr.h.

NodeBlender* HandleBecomeA::pNodeBlender [private]
 

Definition at line 751 of file nodebldr.h.

NodeGroup* HandleBecomeA::pNodeGroup [private]
 

Definition at line 754 of file nodebldr.h.


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