/
redgpu
/
ezEngine
Обзор
Документация
Войти
/
redgpu
/
ezEngine
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
Code/Engine/Foundation/Utilities/DGMLWriter.h
138 строк
3 KB
Jan Krassnigg
Command history now resets modified state when undoing to a saved state (#1824)
22 фев 2026, 20:03
Не верифицирован
22 фев 2026, 20:03
288fa6b
Код
Авторство
О чём код?
#pragma once #include <Foundation/Math/Color.h> #include <Foundation/Strings/String.h> #include <Foundation/Types/ArrayPtr.h> class ezFormatString; /// \brief This class encapsulates building a DGML compatible graph. class EZ_FOUNDATION_DLL ezDGMLGraph { public: enum class Direction : ezUInt8 { TopToBottom, BottomToTop, LeftToRight, RightToLeft }; enum class Layout : ezUInt8 { Free, Tree, DependencyMatrix }; enum class NodeShape : ezUInt8 { None, Rectangle, RoundedRectangle, Button }; enum class GroupType : ezUInt8 { None, Expanded, Collapsed, }; using NodeId = ezUInt32; using PropertyId = ezUInt32; using ConnectionId = ezUInt32; using CategoryId = ezUInt32; struct NodeDesc { ezColor m_Color = ezColor::White; NodeShape m_Shape = NodeShape::Rectangle; }; /// \brief Constructor for the graph. ezDGMLGraph(Direction graphDirection = Direction::LeftToRight, Layout graphLayout = Layout::Tree); /// \brief Adds a node to the graph. /// Adds a node to the graph and returns the node id which can be used to reference the node later to add connections etc. NodeId AddNode(ezStringView sTitle, const NodeDesc* pDesc = nullptr); /// \brief Adds a DGML node that can act as a group for other nodes NodeId AddGroup(ezStringView sTitle, GroupType type, const NodeDesc* pDesc = nullptr); /// \brief Inserts a node into an existing group node. void AddNodeToGroup(NodeId node, NodeId group); /// \brief Adds a category with a display color. Returns the category id for use with AddConnection. CategoryId AddConnectionCategory(ezStringView sName, const ezColor& color); /// \brief Adds a directed connection to the graph (an arrow pointing from source to target node). ConnectionId AddConnection(NodeId source, NodeId target, ezStringView sLabel = {}, CategoryId category = ezInvalidIndex); /// \brief Adds a property type. All properties currently use the data type 'string' PropertyId AddPropertyType(ezStringView sName); /// \brief Adds a property of the specified type with the given value to a node void AddNodeProperty(NodeId node, PropertyId property, const ezFormatString& fmt); protected: friend class ezDGMLGraphWriter; struct ConnectionCategory { ezString m_sName; ezColor m_Color; }; struct Connection { NodeId m_Source; NodeId m_Target; ezString m_sLabel; CategoryId m_uiCategory = ezInvalidIndex; }; struct PropertyType { ezString m_Name; }; struct PropertyValue { PropertyId m_PropertyId; ezString m_sValue; }; struct Node { ezString m_Title; GroupType m_GroupType = GroupType::None; NodeId m_ParentGroup = 0xFFFFFFFF; NodeDesc m_Desc; ezDynamicArray<PropertyValue> m_Properties; }; ezHybridArray<Node, 16> m_Nodes; ezHybridArray<Connection, 32> m_Connections; ezHybridArray<ConnectionCategory, 16> m_ConnectionCategories; ezHybridArray<PropertyType, 16> m_PropertyTypes; Direction m_Direction; Layout m_Layout; }; /// \brief This class encapsulates the output of DGML compatible graphs to files and streams. class EZ_FOUNDATION_DLL ezDGMLGraphWriter { public: /// \brief Helper method to write the graph to a file. static ezResult WriteGraphToFile(ezStringView sFileName, const ezDGMLGraph& graph); /// \brief Writes the graph as a DGML formatted document to the given string builder. static ezResult WriteGraphToString(ezStringBuilder& ref_sStringBuilder, const ezDGMLGraph& graph); };