You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Graph Visualizer: Replacing Control Rig AST visualizer with common service
#rb halfdan.ingvarsson #jira na #preflight https://horde.devtools.epicgames.com/job/614382398169560001036499 #ROBOMERGE-AUTHOR: helge.mathee #ROBOMERGE-SOURCE: CL 17735754 in //UE5/Main/... #ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v879-17706426) [CL 17735765 by helge mathee in ue5-release-engine-test branch]
This commit is contained in:
135
Engine/Source/Developer/VisualGraphUtils/Public/VisualGraph.h
Normal file
135
Engine/Source/Developer/VisualGraphUtils/Public/VisualGraph.h
Normal file
@@ -0,0 +1,135 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "VisualGraphElement.h"
|
||||
#include "VisualGraphNode.h"
|
||||
#include "VisualGraphEdge.h"
|
||||
|
||||
class FVisualGraph;
|
||||
|
||||
class VISUALGRAPHUTILS_API FVisualGraphSubGraph : public FVisualGraphElement
|
||||
{
|
||||
public:
|
||||
|
||||
FVisualGraphSubGraph()
|
||||
: FVisualGraphElement()
|
||||
, ParentGraphIndex(INDEX_NONE)
|
||||
{}
|
||||
|
||||
virtual ~FVisualGraphSubGraph() override {}
|
||||
|
||||
int32 GetParentGraphIndex() const { return ParentGraphIndex; }
|
||||
const TArray<int32>& GetNodes() const { return Nodes; }
|
||||
|
||||
protected:
|
||||
|
||||
virtual FString DumpDot(const FVisualGraph* InGraph, int32 InIndendation) const override;
|
||||
|
||||
int32 ParentGraphIndex;
|
||||
TArray<int32> Nodes;
|
||||
|
||||
friend class FVisualGraph;
|
||||
};
|
||||
|
||||
class VISUALGRAPHUTILS_API FVisualGraph : public FVisualGraphElement
|
||||
{
|
||||
public:
|
||||
|
||||
FVisualGraph()
|
||||
: FVisualGraphElement()
|
||||
{}
|
||||
|
||||
virtual ~FVisualGraph() override {}
|
||||
|
||||
FVisualGraph(const FName& InName, const FName& InDisplayName = NAME_None);
|
||||
|
||||
const TArray<FVisualGraphNode>& GetNodes() const { return Nodes; }
|
||||
const TArray<FVisualGraphEdge>& GetEdges() const { return Edges; }
|
||||
const TArray<FVisualGraphSubGraph>& GetSubGraphs() const { return SubGraphs; }
|
||||
|
||||
int32 AddNode(
|
||||
const FName& InName,
|
||||
TOptional<FName> InDisplayName = TOptional<FName>(),
|
||||
TOptional<FLinearColor> InColor = TOptional<FLinearColor>(),
|
||||
TOptional<EVisualGraphShape> InShape = TOptional<EVisualGraphShape>(),
|
||||
TOptional<EVisualGraphStyle> InStyle = TOptional<EVisualGraphStyle>());
|
||||
|
||||
int32 AddEdge(
|
||||
int32 InSourceNode,
|
||||
int32 InTargetNode,
|
||||
EVisualGraphEdgeDirection InDirection,
|
||||
const FName& InName = NAME_None,
|
||||
TOptional<FName> InDisplayName = TOptional<FName>(),
|
||||
TOptional<FLinearColor> InColor = TOptional<FLinearColor>(),
|
||||
TOptional<EVisualGraphStyle> InStyle = TOptional<EVisualGraphStyle>());
|
||||
|
||||
int32 AddSubGraph(
|
||||
const FName& InName,
|
||||
TOptional<FName> InDisplayName = TOptional<FName>(),
|
||||
int32 InParentGraphIndex = INDEX_NONE,
|
||||
TOptional<FLinearColor> InColor = TOptional<FLinearColor>(),
|
||||
TOptional<EVisualGraphStyle> InStyle = TOptional<EVisualGraphStyle>(),
|
||||
const TArray<int32> InNodes = TArray<int32>());
|
||||
|
||||
int32 FindNode(const FName& InName) const;
|
||||
int32 FindEdge(const FName& InName) const;
|
||||
int32 FindSubGraph(const FName& InName) const;
|
||||
|
||||
bool AddNodeToSubGraph(int32 InNodeIndex, int32 InSubGraphIndex);
|
||||
bool RemoveNodeFromSubGraph(int32 InNodeIndex);
|
||||
|
||||
void TransitiveReduction(TFunction<bool(FVisualGraphEdge&)> KeepEdgeFunction);
|
||||
|
||||
FORCEINLINE FString DumpDot() const
|
||||
{
|
||||
return DumpDot(this, 0);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
virtual FString DumpDot(const FVisualGraph* InGraph, int32 InIndendation) const override;
|
||||
|
||||
template<typename T>
|
||||
FORCEINLINE static void RefreshNameMap(const TArray<T>& InElements, TMap<FName, int32>& OutMap)
|
||||
{
|
||||
OutMap.Reset();
|
||||
for(const T& Element: InElements)
|
||||
{
|
||||
OutMap.Add(Element.Name, Element.Index);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
FORCEINLINE static void RefreshNameMapIfNeeded(const TArray<T>& InElements, TMap<FName, int32>& OutMap)
|
||||
{
|
||||
if(OutMap.Num() == InElements.Num())
|
||||
{
|
||||
return;
|
||||
}
|
||||
RefreshNameMap(InElements, OutMap);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
FORCEINLINE static int32 AddElement(const T& InElement, TArray<T>& OutElements, TMap<FName, int32>& OutMap)
|
||||
{
|
||||
const int32 AddedIndex = OutElements.Add(InElement);
|
||||
if(OutElements.IsValidIndex(AddedIndex))
|
||||
{
|
||||
OutElements[AddedIndex].Index = AddedIndex;
|
||||
OutMap.Add(InElement.Name, AddedIndex);
|
||||
}
|
||||
return AddedIndex;
|
||||
}
|
||||
|
||||
static bool IsNameAvailable(const FName& InName, const TMap<FName, int32>& InMap);
|
||||
static FName GetUniqueName(const FName& InName, const TMap<FName, int32>& InMap);
|
||||
|
||||
TArray<FVisualGraphNode> Nodes;
|
||||
TArray<FVisualGraphEdge> Edges;
|
||||
TArray<FVisualGraphSubGraph> SubGraphs;
|
||||
|
||||
TMap<FName,int32> NodeNameMap;
|
||||
TMap<FName,int32> EdgeNameMap;
|
||||
TMap<FName,int32> SubGraphNameMap;
|
||||
};
|
||||
@@ -0,0 +1,42 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "VisualGraphElement.h"
|
||||
#include "VisualGraphEdge.generated.h"
|
||||
|
||||
UENUM()
|
||||
enum class EVisualGraphEdgeDirection : uint8
|
||||
{
|
||||
SourceToTarget,
|
||||
TargetToSource,
|
||||
BothWays
|
||||
};
|
||||
|
||||
class VISUALGRAPHUTILS_API FVisualGraphEdge : public FVisualGraphElement
|
||||
{
|
||||
public:
|
||||
|
||||
FVisualGraphEdge()
|
||||
: FVisualGraphElement()
|
||||
, Direction(EVisualGraphEdgeDirection::SourceToTarget)
|
||||
{}
|
||||
|
||||
virtual ~FVisualGraphEdge() override {}
|
||||
|
||||
int32 GetSourceNode() const { return SourceNode; }
|
||||
int32 GetTargetNode() const { return TargetNode; }
|
||||
EVisualGraphEdgeDirection GetDirection() const { return Direction; }
|
||||
|
||||
protected:
|
||||
|
||||
virtual FString DumpDot(const FVisualGraph* InGraph, int32 InIndendation) const override;
|
||||
|
||||
int32 SourceNode;
|
||||
int32 TargetNode;
|
||||
EVisualGraphEdgeDirection Direction;
|
||||
|
||||
friend class FVisualGraph;
|
||||
friend class FVisualGraphSubGraph;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "VisualGraphElement.generated.h"
|
||||
|
||||
class FVisualGraph;
|
||||
|
||||
UENUM()
|
||||
enum class EVisualGraphShape : uint8
|
||||
{
|
||||
Box,
|
||||
Polygon,
|
||||
Ellipse,
|
||||
Circle,
|
||||
Triangle,
|
||||
PlainText,
|
||||
Diamond,
|
||||
Parallelogram,
|
||||
House
|
||||
};
|
||||
|
||||
UENUM()
|
||||
enum class EVisualGraphStyle : uint8
|
||||
{
|
||||
Filled,
|
||||
Diagonals,
|
||||
Rounded,
|
||||
Dashed,
|
||||
Dotted,
|
||||
Solid,
|
||||
Bold
|
||||
};
|
||||
|
||||
class VISUALGRAPHUTILS_API FVisualGraphElement
|
||||
{
|
||||
public:
|
||||
|
||||
FVisualGraphElement()
|
||||
: Name(NAME_None)
|
||||
, DisplayName()
|
||||
, Index(INDEX_NONE)
|
||||
, Color()
|
||||
, Style()
|
||||
{}
|
||||
|
||||
virtual ~FVisualGraphElement() {}
|
||||
|
||||
FName GetName() const { return Name; }
|
||||
FName GetDisplayName() const { return DisplayName.IsSet() ? DisplayName.GetValue() : Name; }
|
||||
TOptional<FString> GetTooltip() const { return Tooltip; }
|
||||
void SetTooltip(const FString& InTooltip) const { Tooltip = InTooltip; }
|
||||
int32 GetIndex() const { return Index; }
|
||||
TOptional<FLinearColor> GetColor() const { return Color; }
|
||||
void SetColor(FLinearColor InValue) { Color = InValue; }
|
||||
TOptional<EVisualGraphStyle> GetStyle() const { return Style; }
|
||||
void SetStyle(EVisualGraphStyle InValue) { Style = InValue; }
|
||||
|
||||
protected:
|
||||
|
||||
virtual FString DumpDot(const FVisualGraph* InGraph, int32 InIndendation) const = 0;
|
||||
static FString DumpDotIndentation(int32 InIndentation);
|
||||
static FString DumpDotColor(const TOptional<FLinearColor>& InColor);
|
||||
static FString DumpDotShape(const TOptional<EVisualGraphShape>& InShape);
|
||||
static FString DumpDotStyle(const TOptional<EVisualGraphStyle>& InStyle);
|
||||
|
||||
FName Name;
|
||||
TOptional<FName> DisplayName;
|
||||
mutable TOptional<FString> Tooltip;
|
||||
int32 Index;
|
||||
TOptional<FLinearColor> Color;
|
||||
TOptional<EVisualGraphStyle> Style;
|
||||
|
||||
friend class FVisualGraph;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "VisualGraphElement.h"
|
||||
|
||||
class VISUALGRAPHUTILS_API FVisualGraphNode : public FVisualGraphElement
|
||||
{
|
||||
public:
|
||||
|
||||
FVisualGraphNode()
|
||||
: FVisualGraphElement()
|
||||
, Shape()
|
||||
, SubGraphIndex(INDEX_NONE)
|
||||
{}
|
||||
|
||||
virtual ~FVisualGraphNode() override {}
|
||||
|
||||
TOptional<EVisualGraphShape> GetShape() const { return Shape; }
|
||||
void SetShape(EVisualGraphShape InValue) { Shape = InValue; }
|
||||
|
||||
protected:
|
||||
|
||||
virtual FString DumpDot(const FVisualGraph* InGraph, int32 InIndendation) const override;
|
||||
|
||||
TOptional<EVisualGraphShape> Shape;
|
||||
int32 SubGraphIndex;
|
||||
|
||||
friend class FVisualGraph;
|
||||
friend class FVisualGraphSubGraph;
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "VisualGraph.h"
|
||||
|
||||
class VISUALGRAPHUTILS_API FVisualGraphObjectUtils
|
||||
{
|
||||
public:
|
||||
|
||||
static FVisualGraph TraverseUObjectReferences(
|
||||
const TArray<UObject*>& InObjects,
|
||||
const TArray<UClass*>& InClassesToSkip = TArray<UClass*>(),
|
||||
const TArray<UObject*>& InOutersToSkip = TArray<UObject*>(),
|
||||
const TArray<UObject*>& InOutersToUse = TArray<UObject*>(),
|
||||
bool bTraverseObjectsInOuter = true,
|
||||
bool bCollectReferencesBySerialize = true,
|
||||
bool bRecursive = true
|
||||
);
|
||||
|
||||
static FVisualGraph TraverseTickOrder(
|
||||
const TArray<UObject*>& InObjects
|
||||
);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "VisualGraphNode.h"
|
||||
#include "VisualGraphEdge.h"
|
||||
#include "VisualGraph.h"
|
||||
@@ -0,0 +1,8 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
|
||||
DECLARE_LOG_CATEGORY_EXTERN(LogVisualGraphUtils, Log, All);
|
||||
|
||||
Reference in New Issue
Block a user