Plasma Engine  2.0
Loading...
Searching...
No Matches
DGMLWriter.h
1#pragma once
2
3#include <Foundation/Math/Color.h>
4#include <Foundation/Strings/String.h>
5
7
9class PL_FOUNDATION_DLL plDGMLGraph
10{
11public:
12 enum class Direction : plUInt8
13 {
14 TopToBottom,
15 BottomToTop,
16 LeftToRight,
17 RightToLeft
18 };
19
20 enum class Layout : plUInt8
21 {
22 Free,
23 Tree,
24 DependencyMatrix
25 };
26
27 enum class NodeShape : plUInt8
28 {
29 None,
30 Rectangle,
31 RoundedRectangle,
32 Button
33 };
34
35 enum class GroupType : plUInt8
36 {
37 None,
38 Expanded,
39 Collapsed,
40 };
41
42 using NodeId = plUInt32;
43 using PropertyId = plUInt32;
44 using ConnectionId = plUInt32;
45
46 struct NodeDesc
47 {
48 plColor m_Color = plColor::White;
49 NodeShape m_Shape = NodeShape::Rectangle;
50 };
51
53 plDGMLGraph(Direction graphDirection = Direction::LeftToRight, Layout graphLayout = Layout::Tree);
54
57 NodeId AddNode(plStringView sTitle, const NodeDesc* pDesc = nullptr);
58
60 NodeId AddGroup(plStringView sTitle, GroupType type, const NodeDesc* pDesc = nullptr);
61
63 void AddNodeToGroup(NodeId node, NodeId group);
64
66 ConnectionId AddConnection(NodeId source, NodeId target, plStringView sLabel = {});
67
69 PropertyId AddPropertyType(plStringView sName);
70
72 void AddNodeProperty(NodeId node, PropertyId property, const plFormatString& fmt);
73
74protected:
75 friend class plDGMLGraphWriter;
76
78 {
79 NodeId m_Source;
80 NodeId m_Target;
81 plString m_sLabel;
82 };
83
85 {
86 plString m_Name;
87 };
88
90 {
91 PropertyId m_PropertyId;
92 plString m_sValue;
93 };
94
95 struct Node
96 {
97 plString m_Title;
98 GroupType m_GroupType = GroupType::None;
99 NodeId m_ParentGroup = 0xFFFFFFFF;
100 NodeDesc m_Desc;
102 };
103
105
106 plHybridArray<Connection, 32> m_Connections;
107
108 plHybridArray<PropertyType, 16> m_PropertyTypes;
109
110 Direction m_Direction;
111
112 Layout m_Layout;
113};
114
116class PL_FOUNDATION_DLL plDGMLGraphWriter
117{
118public:
120 static plResult WriteGraphToFile(plStringView sFileName, const plDGMLGraph& graph);
121
123 static plResult WriteGraphToString(plStringBuilder& ref_sStringBuilder, const plDGMLGraph& graph);
124};
plColor represents an RGBA color in linear color space. Values are stored as float,...
Definition Color.h:44
static const plColor White
#FFFFFF
Definition Color.h:194
This class encapsulates building a DGML compatible graph.
Definition DGMLWriter.h:10
This class encapsulates the output of DGML compatible graphs to files and streams.
Definition DGMLWriter.h:117
Definition DynamicArray.h:81
Implements formating of strings with placeholders and formatting options.
Definition FormatString.h:59
A hybrid array uses in-place storage to handle the first few elements without any allocation....
Definition HybridArray.h:12
plStringBuilder is a class that is meant for creating and modifying strings.
Definition StringBuilder.h:35
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
Definition DGMLWriter.h:78
Definition DGMLWriter.h:47
Definition DGMLWriter.h:96
Definition DGMLWriter.h:85
Definition DGMLWriter.h:90
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54