本文整理汇总了C++中UEdGraphNode::SnapToGrid方法的典型用法代码示例。如果您正苦于以下问题:C++ UEdGraphNode::SnapToGrid方法的具体用法?C++ UEdGraphNode::SnapToGrid怎么用?C++ UEdGraphNode::SnapToGrid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UEdGraphNode
的用法示例。
在下文中一共展示了UEdGraphNode::SnapToGrid方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InvokeAction
//------------------------------------------------------------------------------
static UEdGraphNode* FBlueprintMenuActionItemImpl::InvokeAction(const UBlueprintNodeSpawner* Action, UEdGraph* ParentGraph, FVector2D const Location, IBlueprintNodeBinder::FBindingSet const& Bindings, bool& bOutNewNode)
{
int32 const PreSpawnNodeCount = ParentGraph->Nodes.Num();
// this could return an existing node
UEdGraphNode* SpawnedNode = Action->Invoke(ParentGraph, Bindings, Location);
// if a returned node wasn't one that previously existed in the graph
const bool bNewNode = PreSpawnNodeCount < ParentGraph->Nodes.Num();
bOutNewNode = bNewNode;
if (bNewNode)
{
check(SpawnedNode != nullptr);
SpawnedNode->SnapToGrid(SNodePanel::GetSnapGridSize());
FBlueprintEditorUtils::AnalyticsTrackNewNode(SpawnedNode);
}
// if this node already existed, then we just want to focus on that node...
// some node types are only allowed one instance per blueprint (like events)
else if (SpawnedNode != nullptr)
{
FKismetEditorUtilities::BringKismetToFocusAttentionOnObject(SpawnedNode);
}
return SpawnedNode;
}
示例2:
UEdGraphNode* FEdGraphSchemaAction_K2NewNode::CreateNode(class UEdGraph* ParentGraph, UEdGraphPin* FromPin, const FVector2D Location, class UK2Node* NodeTemplate, bool bSelectNewNode/* = true*/)
{
// Smart pointer that handles fixup after potential node reconstruction
FWeakGraphPinPtr FromPinPtr = FromPin;
// Duplicate template node to create new node
UEdGraphNode* ResultNode = DuplicateObject<UK2Node>(NodeTemplate, ParentGraph);
ResultNode->SetFlags(RF_Transactional);
ParentGraph->AddNode(ResultNode, true, bSelectNewNode);
ResultNode->CreateNewGuid();
ResultNode->PostPlacedNewNode();
ResultNode->AllocateDefaultPins();
// For input pins, new node will generally overlap node being dragged off
// Work out if we want to visually push away from connected node
int32 XLocation = Location.X;
if (FromPinPtr.IsValid() && FromPinPtr->Direction == EGPD_Input)
{
UEdGraphNode* PinNode = FromPinPtr->GetOwningNode();
const float XDelta = FMath::Abs(PinNode->NodePosX - Location.X);
if (XDelta < NodeDistance)
{
// Set location to edge of current node minus the max move distance
// to force node to push off from connect node enough to give selection handle
XLocation = PinNode->NodePosX - NodeDistance;
}
}
ResultNode->NodePosX = XLocation;
ResultNode->NodePosY = Location.Y;
ResultNode->SnapToGrid(SNAP_GRID);
// make sure to auto-wire after we position the new node (in case the
// auto-wire creates a conversion node to put between them)
ResultNode->AutowireNewNode(FromPinPtr);
// Update Analytics for the new nodes
FBlueprintEditorUtils::AnalyticsTrackNewNode( ResultNode );
// NOTE: At this point the node may have been reconstructed, depending on node type!
return ResultNode;
}
示例3: CreateNode
UEdGraphNode* FEdGraphSchemaAction_NewNode::CreateNode(class UEdGraph* ParentGraph, UEdGraphPin* FromPin, const FVector2D Location, class UEdGraphNode* NodeTemplate)
{
// Duplicate template node to create new node
UEdGraphNode* ResultNode = NULL;
#if WITH_EDITOR
ResultNode = DuplicateObject<UEdGraphNode>(NodeTemplate, ParentGraph);
ResultNode->SetFlags(RF_Transactional);
ParentGraph->AddNode(ResultNode, true);
ResultNode->CreateNewGuid();
ResultNode->PostPlacedNewNode();
ResultNode->AllocateDefaultPins();
ResultNode->AutowireNewNode(FromPin);
// For input pins, new node will generally overlap node being dragged off
// Work out if we want to visually push away from connected node
int32 XLocation = Location.X;
if (FromPin && FromPin->Direction == EGPD_Input)
{
UEdGraphNode* PinNode = FromPin->GetOwningNode();
const float XDelta = FMath::Abs(PinNode->NodePosX - Location.X);
if (XDelta < NodeDistance)
{
// Set location to edge of current node minus the max move distance
// to force node to push off from connect node enough to give selection handle
XLocation = PinNode->NodePosX - NodeDistance;
}
}
ResultNode->NodePosX = XLocation;
ResultNode->NodePosY = Location.Y;
ResultNode->SnapToGrid(SNAP_GRID);
#endif // WITH_EDITOR
return ResultNode;
}
示例4: PasteNodesHere
void FSoundCueEditor::PasteNodesHere(const FVector2D& Location)
{
// Undo/Redo support
const FScopedTransaction Transaction( NSLOCTEXT("UnrealEd", "SoundCueEditorPaste", "Paste Sound Cue Node") );
SoundCue->GetGraph()->Modify();
SoundCue->Modify();
// Clear the selection set (newly pasted stuff will be selected)
SoundCueGraphEditor->ClearSelectionSet();
// Grab the text to paste from the clipboard.
FString TextToImport;
FPlatformMisc::ClipboardPaste(TextToImport);
// Import the nodes
TSet<UEdGraphNode*> PastedNodes;
FEdGraphUtilities::ImportNodesFromText(SoundCue->GetGraph(), TextToImport, /*out*/ PastedNodes);
//Average position of nodes so we can move them while still maintaining relative distances to each other
FVector2D AvgNodePosition(0.0f,0.0f);
for (TSet<UEdGraphNode*>::TIterator It(PastedNodes); It; ++It)
{
UEdGraphNode* Node = *It;
AvgNodePosition.X += Node->NodePosX;
AvgNodePosition.Y += Node->NodePosY;
}
if ( PastedNodes.Num() > 0 )
{
float InvNumNodes = 1.0f/float(PastedNodes.Num());
AvgNodePosition.X *= InvNumNodes;
AvgNodePosition.Y *= InvNumNodes;
}
for (TSet<UEdGraphNode*>::TIterator It(PastedNodes); It; ++It)
{
UEdGraphNode* Node = *It;
if (USoundCueGraphNode* SoundGraphNode = Cast<USoundCueGraphNode>(Node))
{
SoundCue->AllNodes.Add(SoundGraphNode->SoundNode);
}
// Select the newly pasted stuff
SoundCueGraphEditor->SetNodeSelection(Node, true);
Node->NodePosX = (Node->NodePosX - AvgNodePosition.X) + Location.X ;
Node->NodePosY = (Node->NodePosY - AvgNodePosition.Y) + Location.Y ;
Node->SnapToGrid(SNodePanel::GetSnapGridSize());
// Give new node a different Guid from the old one
Node->CreateNewGuid();
}
// Force new pasted SoundNodes to have same connections as graph nodes
SoundCue->CompileSoundNodesFromGraphNodes();
// Update UI
SoundCueGraphEditor->NotifyGraphChanged();
SoundCue->PostEditChange();
SoundCue->MarkPackageDirty();
}
示例5: PasteNodesHere
void FNiagaraEditor::PasteNodesHere(const FVector2D& Location)
{
TSharedPtr<SGraphEditor> CurrentGraphEditor = NodeGraphEditorPtr.Pin();
if (!CurrentGraphEditor.IsValid())
{
return;
}
// Undo/Redo support
const FScopedTransaction Transaction(FGenericCommands::Get().Paste->GetDescription());
UEdGraph* EdGraph = Cast<UEdGraph>(CurrentGraphEditor->GetCurrentGraph());
EdGraph->Modify();
const FGraphPanelSelectionSet SelectedNodes = CurrentGraphEditor->GetSelectedNodes();
// Clear the selection set (newly pasted stuff will be selected)
CurrentGraphEditor->ClearSelectionSet();
// Grab the text to paste from the clipboard.
FString TextToImport;
FPlatformMisc::ClipboardPaste(TextToImport);
// Import the nodes
TSet<UEdGraphNode*> PastedNodes;
FEdGraphUtilities::ImportNodesFromText(EdGraph, TextToImport, /*out*/ PastedNodes);
//Average position of nodes so we can move them while still maintaining relative distances to each other
FVector2D AvgNodePosition(0.0f, 0.0f);
for (TSet<UEdGraphNode*>::TIterator It(PastedNodes); It; ++It)
{
UEdGraphNode* Node = (*It);
if (Node)
{
AvgNodePosition.X += Node->NodePosX;
AvgNodePosition.Y += Node->NodePosY;
}
}
if (PastedNodes.Num() > 0)
{
float InvNumNodes = 1.0f / float(PastedNodes.Num());
AvgNodePosition.X *= InvNumNodes;
AvgNodePosition.Y *= InvNumNodes;
}
for (TSet<UEdGraphNode*>::TIterator It(PastedNodes); It; ++It)
{
UEdGraphNode* PasteNode = (*It);
if (PasteNode)
{
// Select the newly pasted stuff
CurrentGraphEditor->SetNodeSelection(PasteNode, true);
PasteNode->NodePosX = (PasteNode->NodePosX - AvgNodePosition.X) + Location.X;
PasteNode->NodePosY = (PasteNode->NodePosY - AvgNodePosition.Y) + Location.Y;
PasteNode->SnapToGrid(16);
// Give new node a different Guid from the old one
PasteNode->CreateNewGuid();
}
}
// Update UI
CurrentGraphEditor->NotifyGraphChanged();
UObject* GraphOwner = EdGraph->GetOuter();
if (GraphOwner)
{
GraphOwner->PostEditChange();
GraphOwner->MarkPackageDirty();
}
}