本文整理汇总了C++中NodePath::AllowOp方法的典型用法代码示例。如果您正苦于以下问题:C++ NodePath::AllowOp方法的具体用法?C++ NodePath::AllowOp怎么用?C++ NodePath::AllowOp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodePath
的用法示例。
在下文中一共展示了NodePath::AllowOp方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: optokenstring
OpState OpBreakAtPoints::GetState(String_256* UIDescription, OpDescriptor*)
{
OpState OpSt;
String_256 DisableReason;
OpSt.Greyed = FALSE;
BOOL FoundSelected = FALSE;
// Go through the selection until we find a selected point
SelRange* Selected = GetApplication()->FindSelection();
Node* pNode = Selected->FindFirst();
while (pNode)
{
if (IS_A(pNode,NodePath) || IS_A(pNode,NodeBlendPath))
{
NodePath* pNodePath = (NodePath*)pNode;
INT32 NumSplinters = pNodePath->InkPath.NumSplinters();
if (NumSplinters > 0)
{
// We need to ask the effected nodes if they (and their parents) can handle this node being replaced
ObjChangeFlags cFlags;
if (NumSplinters > 1)
cFlags.MultiReplaceNode = TRUE; // Node will be replaced with more than one node.
else
cFlags.ReplaceNode = TRUE; // Node will be replaced with one node only.
String_32 optokenstring(OPTOKEN_BREAKATPOINTS);
ObjChangeParamWithToken ObjChange(OBJCHANGE_STARTING,cFlags,pNodePath,NULL,&optokenstring);
// Will the node allow this op to happen?
if (pNodePath->AllowOp(&ObjChange,FALSE))
{
FoundSelected = TRUE;
break;
}
}
}
pNode = Selected->FindNext(pNode);
}
// The operation is disabled if there are no complex paths selected
if (!FoundSelected)
{
OpSt.Greyed = TRUE;
DisableReason = String_256(_R(IDS_NEEDS_SELECTED_POINT));
*UIDescription = DisableReason;
}
return(OpSt);
}
示例2: Do
void OpBreakAtPoints::Do(OpDescriptor*)
{
// Obtain the current selections
SelRange* Selected = GetApplication()->FindSelection();
NodePath* pSplitNode;
// Now, because we're going to be doing mad things to the selection, we have to make a list
// of all the selected nodes, so that adding nodes into the tree won't confuse us
List* NodeList = Selected->MakeListOfNodes();
NodeListItem* CurItem = (NodeListItem*)(NodeList->GetHead());
if (!CurItem)
goto FailAndDeleteList;
if (!DoStartSelOp(TRUE,TRUE))
goto FailAndDeleteList;
while (CurItem)
{
// get a pointer to the NodePath
NodePath* pThisNode = (NodePath*)(CurItem->pNode);
// Only interested in NodePaths that have a sub selection, and that will allow the op to happen
if ((IS_A(pThisNode,NodePath) || IS_A(pThisNode,NodeBlendPath)) && pThisNode->InkPath.IsSubSelection())
{
// Find out how many nodes this op will reproduce
INT32 NumSplinters = pThisNode->InkPath.NumSplinters();
BOOL DoThisNode = FALSE;
if (NumSplinters > 0)
{
// We need to ask the effected nodes if they (and their parents) can handle this node being replaced
ObjChangeFlags cFlags;
if (NumSplinters > 1)
cFlags.MultiReplaceNode = TRUE; // Node will be replaced with more than one node.
else
cFlags.ReplaceNode = TRUE; // Node will be replaced with one node only.
ObjChangeParam ObjChange(OBJCHANGE_STARTING,cFlags,NULL,this);
DoThisNode = pThisNode->AllowOp(&ObjChange);
}
if (DoThisNode)
{
BOOL ok;
Node* pnode;
// Copy the nodepath and all its children, without placing the copy in the tree
CALL_WITH_FAIL(pThisNode->NodeCopy(&pnode), this, ok);
if (!ok) goto DeleteList;
pSplitNode = (NodePath*)pnode;
// remove the fill from this path as we're about to open it
pSplitNode->InkPath.IsFilled = FALSE;
// Now stick the new path into the tree
CALL_WITH_FAIL
(
DoInsertNewNode(pSplitNode, pThisNode, NEXT, TRUE, FALSE),
this,ok
);
if (!ok)
goto DeleteListAndPath;
// Now breakup this copy of the path where necessary
Path* pChildPath;
INT32 split;
do
{
// Create a new path, ready for split
ALLOC_WITH_FAIL(pChildPath, new Path, this);
if (!pChildPath)
goto DeleteList;
// Now split the path, possibly into two pieces.
split = pSplitNode->InkPath.BreakInTwo(pChildPath);
if (split==-1)
{
InformError(_R(IDS_OUT_OF_MEMORY), _R(IDS_OK));
delete pChildPath;
goto FailAndDeleteList;
}
/* Karim 05/12/2000
No longer required - see code addition at the bottom of this loop.
if (split==1)
{
delete pChildPath;
continue;
}
*/
//.........这里部分代码省略.........
示例3: Do
void OpReversePath::Do (OpDescriptor*)
{
// Obtain the current selections and the first node in the selection
SelRange* Selected = GetApplication()->FindSelection();
BOOL ok = (Selected != NULL);
// Start the op
BeginSlowJob();
if (ok)
ok = DoStartSelOp(TRUE,TRUE);
// Check with the selrange it is ok to run this op
ObjChangeFlags cFlags;
ObjChangeParam ObjChange(OBJCHANGE_STARTING,cFlags,NULL,this);
if (ok)
{
if (!Selected->AllowOp(&ObjChange))
{
EndSlowJob();
FailAndExecute();
End();
return;
}
}
Node* pNode = Selected->FindFirst();
NodePath* ThisPath = NULL;
//Document* pDocument = GetWorkingDoc();
while (ok && (pNode != NULL))
{ // we're only interested in NodePaths which have selected points
BOOL DoThisNode = pNode->IsNodePath();
//if (DoThisNode)
// DoThisNode = (((NodePath*)pNode)->InkPath.IsSubSelection());
if (DoThisNode)
DoThisNode = (((NodePath*)pNode)->IsPathAllowable());
if ( DoThisNode )
{
// for convenience, cast the pointer to a pointer to a NodePath
ThisPath = (NodePath*)pNode;
// First get pointers to the arrays
PathVerb* Verbs = NULL;
PathFlags* Flags = NULL;
DocCoord* Coords = NULL;
ThisPath->InkPath.GetPathArrays(&Verbs, &Coords, &Flags);
INT32 NumCoords = ThisPath->InkPath.GetNumCoords();
// BOOL PrevSelected = FALSE;
// INT32 PrevPos = 0;
ObjChangeFlags cFlags;
cFlags.TransformNode = TRUE;
ObjChangeParam ObjChange(OBJCHANGE_STARTING,cFlags,ThisPath,this);
if (!ThisPath->AllowOp(&ObjChange, TRUE))
{
return;
}
// Set the NeedToRender flags
for (INT32 loop = 0; loop < NumCoords; loop++)
{
if (Flags[loop].IsEndPoint && Flags[loop].IsSelected)
Flags[loop].NeedToRender = TRUE;
else
Flags[loop].NeedToRender = FALSE;
}
// Force a re-draw of the place where the path used to be
if (ok)
ok = (RecalcBoundsAction::DoRecalc(this, &UndoActions, ThisPath, TRUE) != AC_FAIL);
DoReversePath (ThisPath);
// Force a redraw of the place where the path is now.
if (ok)
ok = (RecordBoundsAction::DoRecord(this, &UndoActions, ThisPath, TRUE) != AC_FAIL);
}
pNode = Selected->FindNext(pNode);
}
if (ok)
{
ObjChange.Define(OBJCHANGE_FINISHED,cFlags,NULL,this);
if (!UpdateChangedNodes(&ObjChange))
{
FailAndExecute();
End();
return;
}
}
EndSlowJob();
if (!ok)
{
FailAndExecute();
InformError();
}
//.........这里部分代码省略.........