Cannot access SGraphPanel, SGraphEditorImpl outside of engine source?

I have inherited the FBlueprintEditor and setup a custom blueprint editor

MyBlueprintEditor : public FBlueprintEditor

From here I am trying to get a reference to the current SGraphPanel. AFAIK the only place to get it is like this: (this codi is in MyBlueprintEditor):

TSharedPtr<SGraphEditor> GraphEditor = FocusedGraphEdPtr.Pin();
if (!GraphEditor.IsValid()) return;
GraphEditor->Implementation; <- This is what is want and cannot access

So the Implementation variable within SGraphEditor is a private. Therefore I’m unable to access the classes SGraphPanel or SGraphEditorImpl at all.

Am I mistaken and there’s another place to access SGraphPanel & SGraphEditorImpl?

this is a tad late, but why do you need the SGraphPanelImpl? i’m creating my own blueprint editor and have not needed to acces that (yet)

could this delegate help you? UEdGraph::AddOnGraphChangedHandler | Unreal Engine Documentation

Also, if you want access to SGraphNode, you could do it by creating a UEdGraphNode subclass and implementing CreateVisualWidget() which expects a SGraphNode as a return parameter. If you want to check more, check the NodeFactory.cpp, on there they also use the connectionPolicies which describe how the arrows are drawn

I’m commenting here because is a little longer.

On the file NodeFactories.cpp the magic happens (it picks which SNode to use).

Specially this section

// First give a shot to the node itself
		TSharedPtr<SGraphNode> NodeCreatedResult = InNode->CreateVisualWidget();
		if (NodeCreatedResult.IsValid())
			return NodeCreatedResult;

	// First give a shot to the registered node factories
	for (auto FactoryIt = FEdGraphUtilities::VisualNodeFactories.CreateIterator(); FactoryIt; ++FactoryIt)
		TSharedPtr<FGraphPanelNodeFactory> FactoryPtr = *FactoryIt;
		if (FactoryPtr.IsValid())
			TSharedPtr<SGraphNode> ResultVisualNode = FactoryPtr->CreateNode(InNode);
			if (ResultVisualNode.IsValid())
				return ResultVisualNode;

As you can see, first, it lets the Custom node to choose it’s own Visual Widget… if it fails (every default node fails AFAIK) it will check the Visual Node Factories, this is your time to shine. You should create a visual node factory and register it to the FEdGraphUtilities (much like you would register another factory).

In there you could easily return a visual node of your choice.
Try to create the factory first and then check the registering.

Just remember, that this patch should work for now, but be careful because as they commented later on code

	//@TODO: Fold all of this code into registered factories for the various schemas!
	if (UAnimGraphNode_Base* BaseAnimNode = Cast<UAnimGraphNode_Base>(InNode))
		if (UAnimGraphNode_Root* RootAnimNode = Cast<UAnimGraphNode_Root>(InNode))
			return SNew(SGraphNodeAnimationResult, RootAnimNode);
		else if (UAnimGraphNode_StateMachineBase* StateMachineInstance = Cast<UAnimGraphNode_StateMachineBase>(InNode))

They plan to fold this if chains into registered factories. so plan carefully

thanks, if it helped you, mark it as answered… so people can check the answer

I want to get access to SGraphPanel and the only place which I have found this is inside SGraphPanelImpl. If you know of another place to get the SGraphPanel that would be great :stuck_out_tongue:

Inside SGraphPanel (in engine code) I’ve added this function which just gets the graph panel from the impl:

/** Get the graph panel if there is one **/
virtual TSharedPtr GetGraphPanel()
if (Implementation.IsValid())
return Implementation->GetGraphPanel();

	return TSharedPtr<SGraphPanel>();

If you were wondering why I need SGraphPanel, it has a really useful delegate “MyRegisteredGraphChangedDelegate” which is called when a node is added or deleted to the graph. Also has a lot of other helpful functions and easy access to SGraphNode and access to the context menu.

I’ve made a pull request to add this and a bunch of other changes with it here:

Ah I was actually using that AddOnChanged function :S Been a while since I’ve touched that code. Unfortunately I need to access SGraphNodes which are already on the graph instead of instantiating my new ones. So it is this function:

TSharedPtr SGraphPanel::GetNodeWidgetFromGuid(FGuid Guid)

If I could make a subclass of SGraphNode and tell UE4 to use my SGraphNode instead that would also be really useful. Do you know where to tell UE4 where to use the subclass (from a plugin)?

Oh this is sweet! Definitely going to give this a shot later, I really needed the OnDrop() function and being able to set colors. Plus I’m sure there’s going to be a ton of other useful stuff in there when I have a closer look. Thanks for the explaination :slight_smile: