#include <brshbeca.h>
Public Member Functions | |
HandleBrushBecomeA () | |
Default constructor. | |
virtual | ~HandleBrushBecomeA () |
destructor | |
BOOL | Initialise (BecomeA *pBecomeA, Node *pContextNode, Node *pCreatedBy) |
initialises the HBecA object ready for use | |
BOOL | Passback (Path *pPath, CCAttrMap *pAttrMap, UINT32 Step) |
This takes a path and an attribute map generated by a PathProcessorBrush, 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. | |
BOOL | HideContextNode () |
inserts an action to hide the context node | |
BOOL | HideCreatedByNode () |
inserts an action to hide the context node | |
BOOL | FinishPassback () |
Somewhat devious this, and to be used with care. Basically after we have completed all our passbacks we have accumulated a nodegroup containiing all the brush objects converted to nodepaths. This function indicates that we have finished and can then passback this nodegroup to our becomeA object. This is a bit bad as we're never supposed to pass nodegroups back, so you must make sure your becomeA object can handle it. It also nulls the group pointer so that it doesn't get deleted on destruction. | |
void | SetNumBlendPaths (UINT32 NumPaths) |
BOOL | MakeGroupForThisStep () |
virtual BOOL | IsSecondary () const |
virtual void | SetSecondary (BOOL bNewValue=TRUE) |
Protected Attributes | |
BecomeA * | m_pBecomeA |
Node * | m_pContextNode |
Node * | m_pCreatedByNode |
NodeGroup * | m_pNodeGroup |
UINT32 | m_NumBlendPaths |
INT32 | m_LastStep |
BOOL | m_bFirst |
BOOL | m_bSecondary |
Private Member Functions | |
CC_DECLARE_MEMDUMP (HandleBrushBecomeA) |
Definition at line 128 of file brshbeca.h.
|
Default constructor.
Definition at line 130 of file brshbeca.cpp. 00131 { 00132 m_pContextNode = NULL; 00133 m_pCreatedByNode = NULL; 00134 m_pNodeGroup = NULL; 00135 m_pBecomeA = NULL; 00136 m_LastStep = -1; 00137 m_NumBlendPaths = 0; 00138 m_bFirst = TRUE; 00139 m_bSecondary = FALSE; 00140 }
|
|
destructor
Definition at line 156 of file brshbeca.cpp. 00157 { 00158 if (m_pContextNode != NULL) 00159 { 00160 m_pContextNode->CascadeDelete(); 00161 delete m_pContextNode; 00162 m_pContextNode = NULL; 00163 } 00164 }
|
|
|
|
Somewhat devious this, and to be used with care. Basically after we have completed all our passbacks we have accumulated a nodegroup containiing all the brush objects converted to nodepaths. This function indicates that we have finished and can then passback this nodegroup to our becomeA object. This is a bit bad as we're never supposed to pass nodegroups back, so you must make sure your becomeA object can handle it. It also nulls the group pointer so that it doesn't get deleted on destruction.
Definition at line 487 of file brshbeca.cpp. 00488 { 00489 ERROR2IF(m_pBecomeA == NULL, FALSE, "BecomeA is NULL in HandleBecomeA::FinishPassback"); 00490 ERROR2IF(m_pContextNode == NULL, FALSE, "Context node is NULL in HandleBecomeA::FinishPassback"); 00491 00492 if (m_pBecomeA->GetReason() == BECOMEA_REPLACE) 00493 { 00494 // Select the newly created node 00495 if (m_pContextNode) 00496 m_pContextNode->SetSelected(TRUE); 00497 } 00498 00499 if (m_pBecomeA->GetReason() == BECOMEA_REPLACE) 00500 { 00501 // Select the newly created node 00502 if (m_pContextNode) 00503 m_pContextNode->SetSelected(TRUE); 00504 } 00505 00506 // We really shouldn't be passing this group back to anyone apart from our special becomeA 00507 if (!m_pBecomeA->IsBrushBecomeAGroup()) 00508 { 00509 m_pContextNode = NULL; 00510 return TRUE; 00511 } 00512 00513 BOOL ok = m_pBecomeA->PassBack((NodeRenderableInk*)m_pContextNode,(NodeRenderableInk*)m_pCreatedByNode,NULL); 00514 00515 if (ok) 00516 m_pContextNode = NULL; 00517 00518 return ok; 00519 }
|
|
inserts an action to hide the context node
Definition at line 414 of file brshbeca.cpp. 00415 { 00416 ERROR2IF(m_pBecomeA == NULL, FALSE, "BecomeA is NULL in HandleBecomeA::HideContextNode"); 00417 ERROR2IF(m_pContextNode == NULL, FALSE, "Context node is NULL in HandleBecomeA::HideContextNode"); 00418 ERROR2IF(m_pBecomeA->GetUndoOp() == NULL,FALSE,"GetUndoOp() returned NULL in HandleBecomeA::HideContextNode"); 00419 00420 UndoableOperation* pUndoOp = m_pBecomeA->GetUndoOp(); 00421 00422 return pUndoOp->DoHideNode(m_pContextNode, TRUE); 00423 00424 00425 }
|
|
inserts an action to hide the context node
Definition at line 441 of file brshbeca.cpp. 00442 { 00443 ERROR2IF(m_pBecomeA == NULL, FALSE, "BecomeA is NULL in HandleBecomeA::HideContextNode"); 00444 ERROR2IF(m_pCreatedByNode == NULL, FALSE, "Context node is NULL in HandleBecomeA::HideContextNode"); 00445 // ERROR2IF(m_pBecomeA->GetUndoOp() == NULL,FALSE,"GetUndoOp() returned NULL in HandleBecomeA::HideContextNode"); 00446 00447 // set the context node selected 00448 if (m_pContextNode) 00449 m_pContextNode->SetSelected(TRUE); 00450 00451 m_pContextNode = NULL; // so our destructor doesn't delete it 00452 00453 UndoableOperation* pUndoOp = m_pBecomeA->GetUndoOp(); 00454 00455 if (!m_bSecondary) 00456 { 00457 if (pUndoOp) 00458 return pUndoOp->DoHideNode(m_pCreatedByNode, TRUE); 00459 00460 m_pCreatedByNode->CascadeDelete(); 00461 delete m_pCreatedByNode; 00462 } 00463 00464 return(TRUE); 00465 }
|
|
initialises the HBecA object ready for use
Definition at line 182 of file brshbeca.cpp. 00183 { 00184 ERROR2IF(pBecomeA == NULL, FALSE, "BecomeA pointer is NULL in HandleBrushBecomeA::Initialise"); 00185 ERROR2IF(pCreatedBy == NULL, FALSE, "Parent node is NULL in HandleBrushBecomeA::Initialise"); 00186 // if we are replacing a node in the tree then we need to ha 00187 if (pBecomeA->GetReason() == BECOMEA_REPLACE) 00188 ERROR2IF(pContextNode == NULL, FALSE, "Context Node is NULL in HandleBrushBecomeA::Initialise"); 00189 00190 m_pBecomeA = pBecomeA; 00191 m_pContextNode = pContextNode; 00192 m_pCreatedByNode = pCreatedBy; 00193 return TRUE; 00194 }
|
|
Definition at line 145 of file brshbeca.h. 00145 {return m_bSecondary;}
|
|
Definition at line 143 of file brshbeca.h. 00143 {return m_NumBlendPaths > 1;}
|
|
This takes a path and an attribute map generated by a PathProcessorBrush, 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.
Definition at line 216 of file brshbeca.cpp. 00217 { 00218 ERROR2IF(pPath == NULL, FALSE, "pPath is NULL in HandleBecomeA::Passback"); 00219 ERROR2IF(pAttrMap == NULL, FALSE, "pAttrMap is NULL in HandleBecomeA::Passback"); 00220 ERROR2IF(m_pBecomeA == NULL, FALSE, "BecomeA is NULL in HandleBecomeA::Passback"); 00221 00222 BOOL ValidReason = (m_pBecomeA->GetReason() == BECOMEA_REPLACE || m_pBecomeA->GetReason() == BECOMEA_PASSBACK); 00223 ERROR3IF_PF(!ValidReason,("Unkown BecomeA reason %d",m_pBecomeA->GetReason())); 00224 if (!ValidReason) return FALSE; 00225 00226 if (m_pBecomeA->GetReason()== BECOMEA_REPLACE) 00227 ERROR2IF(m_pContextNode == NULL, FALSE, "Context Node is NULL in HandleBrushBecomeA::Passback"); 00228 00229 BOOL Success = FALSE; 00230 NodePath* pNewNodePath = NULL; 00231 if (m_pBecomeA->BAPath()) 00232 { 00233 // We need to create a new NodePath, no matter what the reason. 00234 00235 // Allocate a new NodePath node 00236 ALLOC_WITH_FAIL(pNewNodePath, (new NodePath), m_pBecomeA->GetUndoOp()); 00237 Success = (pNewNodePath != NULL); 00238 00239 // Initialise the path 00240 if (Success) CALL_WITH_FAIL(pNewNodePath->InkPath.Initialise(pPath->GetNumCoords(),12), m_pBecomeA->GetUndoOp(), Success); 00241 if (Success) CALL_WITH_FAIL(pNewNodePath->InkPath.CopyPathDataFrom(pPath), m_pBecomeA->GetUndoOp(), Success); 00242 00243 // If Success is TRUE, then we now have a new NodePath object that contains this shape's path 00244 00245 // By default, attach the new path as the previous child of the context node 00246 Node* pAttachNode = m_pContextNode; 00247 AttachNodeDirection AttachDir = NEXT; 00248 00249 // if this is the very first item then insert at first child 00250 if (m_bFirst) 00251 { 00252 AttachDir = LASTCHILD; 00253 m_bFirst = FALSE; 00254 } 00255 00256 00257 // By default, create a hide node action for the new path we're attaching to the tree 00258 // note - I've Changed my mind - because brushes can contain so many objects, by inserting an action 00259 // for each one we're eating up tons of unneccessary space. Instead call HideNode when 00260 // you're done so ou only do it once. 00261 BOOL HideNode = TRUE; 00262 Node* pNodeToHide = pNewNodePath; 00263 00264 00265 // Should we be placing all created paths inside a group? 00266 if (MakeGroupForThisStep()) 00267 { 00268 // Do we need to create a new group? I.e. is this the first path created for this step of the blend? 00269 if (StepNum == 1) 00270 { 00271 // Create a new group and place it in the tree next to the context node 00272 m_pNodeGroup = new NodeGroup; 00273 Success = (m_pNodeGroup != NULL); 00274 if (Success) 00275 { 00276 // attach group to our context node 00277 m_pNodeGroup->AttachNode(m_pContextNode,LASTCHILD); 00278 00279 // Make a hide node action for this group 00280 HideNode = TRUE; 00281 pNodeToHide = m_pNodeGroup; 00282 } 00283 } 00284 else 00285 { 00286 pAttachNode = m_pNodeGroup; 00287 HideNode = FALSE; // We created a hide node action when this group was created 00288 } 00289 00290 // If we have a group node, make sure the new path gets placed in the tree as the 00291 // group's last child 00292 if (Success) 00293 { 00294 pAttachNode = m_pNodeGroup; 00295 AttachDir = LASTCHILD; 00296 } 00297 } 00298 else 00299 AttachDir = LASTCHILD; 00300 00301 00302 if (Success) 00303 { 00304 switch (m_pBecomeA->GetReason()) 00305 { 00306 case BECOMEA_REPLACE : 00307 { 00308 // It's a BECOMEA_REPLACE, so put the new NodePath in the tree in an undoable way 00309 00310 // Can't do it in an undoable way without an Undo Op 00311 // ERROR2IF_PF(m_pBecomeA->GetUndoOp() == NULL,FALSE,("GetUndoOp() returned NULL")); 00312 00313 if (Success) 00314 { 00315 ERROR2IF(pAttachNode == NULL,FALSE,"The attach node is NULL!!!"); 00316 00317 // Insert the new NodePath into the tree 00318 pNewNodePath->AttachNode(pAttachNode,AttachDir); 00319 00320 // Apply all the attributes to the new path 00321 pNewNodePath->ApplyAttributes(pAttrMap,TRUE); 00322 00323 if (m_pBecomeA->GetUndoOp()) 00324 { 00325 // Set the bounds 00326 pNewNodePath->ValidateBoundingRect(); 00327 pNewNodePath->InvalidateBoundingRect(); 00328 00329 // Create a hide node action to hide the node when we undo 00330 if (HideNode) 00331 { 00332 ERROR2IF(pNodeToHide == NULL,FALSE,"pNodeToHide is NULL"); 00333 00334 HideNodeAction* UndoHideNodeAction; 00335 Success = (HideNodeAction::Init(m_pBecomeA->GetUndoOp(), 00336 m_pBecomeA->GetUndoOp()->GetUndoActionList(), 00337 pNodeToHide, 00338 TRUE, // Include subtree size 00339 ( Action**)(&UndoHideNodeAction)) 00340 != AC_FAIL); 00341 } 00342 } 00343 } 00344 00345 // We need to create a copy of the blended attributes to give to the caller 00346 // as they don't exist in the tree, and the ones in pAttrMap will be 00347 // deleted eventually. 00348 ERROR2IF(m_pCreatedByNode == NULL, FALSE, "Parent node is NULL in HandleBrushBecomeA::Passback"); 00349 CCAttrMap* pNewAttrMap = pAttrMap->Copy(); // was causing memory leaks 00350 if (pNewAttrMap != NULL) 00351 m_pBecomeA->PassBack(pNewNodePath,(NodeRenderableInk*)m_pCreatedByNode,pNewAttrMap); 00352 } 00353 break; 00354 00355 case BECOMEA_PASSBACK : 00356 { 00357 if (Success) 00358 { 00359 ERROR2IF(pAttachNode == NULL,FALSE,"The attach node is NULL!!!"); 00360 00361 // Insert the new NodePath into the tree 00362 pNewNodePath->AttachNode(pAttachNode,AttachDir); 00363 00364 // Apply all the attributes to the new path 00365 pNewNodePath->ApplyAttributes(pAttrMap,TRUE); 00366 00367 // Set the bounds 00368 pNewNodePath->ValidateBoundingRect(); 00369 pNewNodePath->InvalidateBoundingRect(); 00370 } 00371 00372 // We need to create a copy of the blended attributes to give to the caller 00373 // as they don't exist in the tree, and the ones in pAttrMap will be 00374 // deleted eventually. 00375 ERROR2IF(m_pCreatedByNode == NULL, FALSE, "Parent node is NULL in HandleBrushBecomeA::Passback"); 00376 CCAttrMap* pNewAttrMap = pAttrMap->Copy(); // was causing memory leaks 00377 if (pNewAttrMap != NULL) 00378 Success = m_pBecomeA->PassBack(pNewNodePath,(NodeRenderableInk*)m_pCreatedByNode,pNewAttrMap); 00379 else 00380 Success = FALSE; 00381 } 00382 break; 00383 00384 case BECOMEA_TEST : 00385 ERROR3("This case wasn't handled by the switch and generated a warning"); 00386 break; 00387 } // end switch 00388 00389 } //end if 00390 else //not success so delete our nodepath 00391 { 00392 if (pNewNodePath != NULL) 00393 delete pNewNodePath; 00394 } 00395 } // end if pBecomeA->BAPath() 00396 00397 return Success; 00398 }
|
|
Definition at line 142 of file brshbeca.h. 00142 {m_NumBlendPaths = (INT32)NumPaths;}
|
|
Definition at line 146 of file brshbeca.h. 00146 {m_bSecondary = bNewValue;}
|
|
Definition at line 155 of file brshbeca.h. |
|
Definition at line 156 of file brshbeca.h. |
|
Definition at line 154 of file brshbeca.h. |
|
Definition at line 153 of file brshbeca.h. |
|
Definition at line 149 of file brshbeca.h. |
|
Definition at line 150 of file brshbeca.h. |
|
Definition at line 151 of file brshbeca.h. |
|
Definition at line 152 of file brshbeca.h. |