本文整理汇总了C++中NodePath::CascadeDelete方法的典型用法代码示例。如果您正苦于以下问题:C++ NodePath::CascadeDelete方法的具体用法?C++ NodePath::CascadeDelete怎么用?C++ NodePath::CascadeDelete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodePath
的用法示例。
在下文中一共展示了NodePath::CascadeDelete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoBecomeA
BOOL NodeSimpleShape::DoBecomeA(BecomeA* pBecomeA)
{
// Check for a NULL entry param
ERROR2IF_PF(pBecomeA == NULL,FALSE,("pBecomeA is NULL"));
// This lump checks that the Reason is one that we understand
// It also makes sure that we don't have a NULL UndoOp ptr
BOOL ValidReason = (pBecomeA->GetReason() == BECOMEA_REPLACE || pBecomeA->GetReason() == BECOMEA_PASSBACK);
ERROR2IF_PF(!ValidReason,FALSE,("Unkown BecomeA reason %d",pBecomeA->GetReason()));
// pBecomeA->Reason is one that we understand.
BOOL Success = TRUE; // Our success flag (Important that this defaults to TRUE)
NodePath* pNewNodePath = NULL; // Ptr to a new NodePath, if we get to make one.
if (pBecomeA->BAPath())
{
// We need to create a new NodePath, no matter what the reason.
// Allocate a new NodePath node
ALLOC_WITH_FAIL(pNewNodePath, (new NodePath), pBecomeA->GetUndoOp());
Success = (pNewNodePath != NULL);
// Initialise the path
if (Success) CALL_WITH_FAIL(pNewNodePath->InkPath.Initialise(InkPath.GetNumCoords(),12), pBecomeA->GetUndoOp(), Success);
if (Success) CALL_WITH_FAIL(pNewNodePath->InkPath.CopyPathDataFrom(&InkPath), pBecomeA->GetUndoOp(), Success);
// If Success is TRUE, then we now have a new NodePath object that contains this shape's path
if (Success)
{
switch (pBecomeA->GetReason())
{
case BECOMEA_REPLACE :
{
// It's a BECOMEA_REPLACE, so replace this node with the new NodePath in an undoable way
// Can't do it in an undoable way without an Undo Op
ERROR2IF_PF(pBecomeA->GetUndoOp() == NULL,FALSE,("GetUndoOp() returned NULL"));
// Firstly, hide this node
NodeHidden* pNodeHidden;
Success = pBecomeA->GetUndoOp()->DoHideNode(this, TRUE, &pNodeHidden);
if (Success)
{
// Insert the new NodePath into the tree, next to the hidden node
pNewNodePath->AttachNode(pNodeHidden,NEXT);
// Copy the node's attributes
CALL_WITH_FAIL(CopyChildrenTo(pNewNodePath), pBecomeA->GetUndoOp(), Success);
if (Success)
{
// Set the bounds
pNewNodePath->InvalidateBoundingRect();
pNewNodePath->SetSelected(IsSelected());
// Create a hide node action to hide the node when we undo
HideNodeAction* UndoHideNodeAction;
Success = (HideNodeAction::Init(pBecomeA->GetUndoOp(),
pBecomeA->GetUndoOp()->GetUndoActionList(),
pNewNodePath,
TRUE, // Include subtree size
( Action**)(&UndoHideNodeAction))
!= AC_FAIL);
}
}
if (Success)
pBecomeA->PassBack(pNewNodePath, this);
}
break;
case BECOMEA_PASSBACK :
Success = pBecomeA->PassBack(pNewNodePath,this);
break;
default:
break;
}
}
}
if (!Success)
{
if (pNewNodePath != NULL)
{
// Delete all the NodePath's children (if it has any) and unlink it from the tree (if it's linked)
// This is all done by CascadeDelete()
pNewNodePath->CascadeDelete();
delete pNewNodePath;
pNewNodePath = NULL;
}
}
return Success;
}
示例2: Do
//.........这里部分代码省略.........
pSplitNode->InvalidateBoundingRect();
// Create a new nodepath.
NodePath* pChildNode;
ALLOC_WITH_FAIL(pChildNode, new NodePath(), this);
if (!pChildNode)
{
delete pChildPath;
goto DeleteList;
}
// make room for the new path in the node path.
CALL_WITH_FAIL
(
pChildNode->SetUpPath(pChildPath->GetNumCoords(),12),
this,ok
);
if (!ok)
{
delete pChildNode;
delete pChildPath;
goto DeleteList;
}
// now copy the path data in there.
pChildNode->InkPath.CopyPathDataFrom(pChildPath);
delete pChildPath;
// Clear the selection flag from the first element in both the split
// and child paths. All others apart from the last will be unselected
// by definition. Also select the last element in the child
(pSplitNode->InkPath.GetFlagArray())[0].IsSelected = FALSE;
(pChildNode->InkPath.GetFlagArray())[0].IsSelected = FALSE;
(pChildNode->InkPath.GetFlagArray())[(pChildNode->InkPath.GetNumCoords()-1)].IsSelected = TRUE;
pChildNode->InkPath.IsFilled = FALSE;
// now, copy all attributes from the parent split to the child split
Node* pAttr = pSplitNode->FindFirstChild();
while (pAttr != NULL)
{
if (pAttr->IsKindOf(CC_RUNTIME_CLASS(NodeAttribute)))
{
Node* pAttrCopy;
CALL_WITH_FAIL(pAttr->NodeCopy(&pAttrCopy), this,ok);
if (!ok)
{
pChildNode->CascadeDelete();
delete pChildNode;
goto DeleteList;
}
pAttrCopy->AttachNode(pChildNode, FIRSTCHILD);
}
pAttr = pAttr->FindNext();
}
for (INT32 loop = 0; loop < pChildNode->InkPath.GetNumCoords(); loop ++)
{
pChildNode->InkPath.GetVerbArray()[loop] = pChildNode->InkPath.GetVerbArray()[loop] & ~PT_CLOSEFIGURE;
}
// Now stick the new path into the tree
CALL_WITH_FAIL
(
DoInsertNewNode(pChildNode, pSplitNode, NEXT, TRUE, FALSE),
this,ok
);
if (!ok)
{
pChildNode->CascadeDelete();
delete pChildNode;
goto DeleteList;
}
pSplitNode = pChildNode;
}
// Karim 05/12/2000
// Fix for memory leak.
else
{
delete pChildPath;
}
}
while (split);
// Clear out any remaining closefigures on the last bit of the path
for (INT32 loop = 0; loop < pSplitNode->InkPath.GetNumCoords(); loop ++)
{
pSplitNode->InkPath.GetVerbArray()[loop] = pSplitNode->InkPath.GetVerbArray()[loop] & ~PT_CLOSEFIGURE;
}
// Now we've broken up this path, let's hide it
CALL_WITH_FAIL(DoHideNode(pThisNode,TRUE), this, ok)
if (!ok) goto DeleteList;
}
}
CurItem = (NodeListItem*)(NodeList->GetNext(CurItem));
}