19 nodes_.append(std::unique_ptr<Node>(node));
20 top_level_nodes_.add_new(node);
21 node->attributes.set(
"label",
label);
28 clusters_.append(std::unique_ptr<Cluster>(cluster));
29 top_level_clusters_.add_new(cluster);
37 edges_.append(std::unique_ptr<UndirectedEdge>(edge));
44 edges_.append(std::unique_ptr<DirectedEdge>(edge));
50 if (parent_ == new_parent) {
53 if (parent_ ==
nullptr) {
54 graph_.top_level_clusters_.remove(
this);
55 new_parent->children_.add_new(
this);
57 else if (new_parent ==
nullptr) {
58 parent_->children_.remove(
this);
59 graph_.top_level_clusters_.add_new(
this);
62 parent_->children_.remove(
this);
63 new_parent->children_.add_new(
this);
70 if (cluster_ == cluster) {
73 if (cluster_ ==
nullptr) {
74 graph_.top_level_nodes_.remove(
this);
75 cluster->nodes_.add_new(
this);
77 else if (cluster ==
nullptr) {
78 cluster_->nodes_.remove(
this);
79 graph_.top_level_nodes_.add_new(
this);
82 cluster_->nodes_.remove(
this);
83 cluster->nodes_.add_new(
this);
93 for (
Cluster *cluster : top_level_clusters_) {
100 float hue = rand() /
float(RAND_MAX);
101 float staturation = 0.3f;
105 for (
Cluster *cluster : children_) {
106 cluster->set_random_cluster_bgcolors();
113 while (current !=
nullptr) {
114 if (current ==
this) {
117 current = current->parent_;
127 std::stringstream ss;
132 for (
const std::unique_ptr<DirectedEdge> &edge : edges_) {
133 edge->export__as_edge_statement(ss);
143 std::stringstream ss;
148 for (
const std::unique_ptr<UndirectedEdge> &edge : edges_) {
149 edge->export__as_edge_statement(ss);
160 attributes.export__as_bracket_list(ss);
163 for (
Node *node : top_level_nodes_) {
164 node->export__as_declaration(ss);
167 for (
Cluster *cluster : top_level_clusters_) {
168 cluster->export__declare_nodes_and_clusters(ss);
174 ss <<
"subgraph " << this->
name() <<
" {\n";
177 attributes.export__as_bracket_list(ss);
180 for (
Node *node : nodes_) {
181 node->export__as_declaration(ss);
184 for (
Cluster *cluster : children_) {
185 cluster->export__declare_nodes_and_clusters(ss);
197 attributes.export__as_bracket_list(ss);
206 attributes.export__as_bracket_list(ss);
215 ss << key <<
"=" << value <<
", ";
219 for (
char c : value) {
241 attributes.export__as_bracket_list(ss);
248 if (port_name_.has_value()) {
249 ss <<
":" << *port_name_;
251 if (port_position_.has_value()) {
252 ss <<
":" << *port_position_;
258 std::stringstream ss;
259 ss << std::setprecision(4) << h <<
' ' << s <<
' ' <<
v;
265 std::stringstream ss;
267 ss << R
"(<<table border="0" cellspacing="3">)";
270 ss << R
"(<tr><td colspan="3" align="center"><b>)";
271 ss << (data.node_name.empty() ? "No Name" : data.node_name);
272 ss <<
"</b></td></tr>";
275 int socket_max_amount = std::max(data.inputs.size(), data.outputs.size());
276 for (
int i = 0; i < socket_max_amount; i++) {
278 if (i < data.inputs.size()) {
280 ss << R
"(<td align="left" port="in)" << i << "\">";
281 if (input.fontcolor) {
282 ss << R
"(<font color=")" << *input.fontcolor << "\">";
284 ss << (input.name.empty() ?
"No Name" : input.name);
285 if (input.fontcolor) {
294 if (i < data.outputs.size()) {
296 ss << R
"(<td align="right" port="out)" << i << "\">";
297 if (output.fontcolor) {
298 ss << R
"(<font color=")" << *output.fontcolor << "\">";
300 ss << (output.name.empty() ?
"No Name" : output.name);
301 if (output.fontcolor) {
ATTR_WARN_UNUSED_RESULT const BMVert * v
void foreach_item(const FuncT &func) const
void export__as_bracket_list(std::stringstream &ss) const
void set(StringRef key, StringRef value)
void set_parent_cluster(Cluster *new_parent)
bool contains(Node &node) const
void export__declare_nodes_and_clusters(std::stringstream &ss) const
Cluster * parent_cluster()
void set_random_cluster_bgcolors()
void export__as_edge_statement(std::stringstream &ss) const
DirectedEdge & new_edge(NodePort from, NodePort to)
std::string to_dot_string() const
Cluster & new_cluster(StringRef label="")
void set_random_cluster_bgcolors()
Node & new_node(StringRef label)
void export__declare_nodes_and_clusters(std::stringstream &ss) const
void to_dot_string(std::stringstream &ss) const
NodeWithSocketsRef(Node &node, const NodeWithSockets &data)
void set_shape(Attr_shape shape)
void export__as_declaration(std::stringstream &ss) const
void export__as_id(std::stringstream &ss) const
void set_parent_cluster(Cluster *cluster)
void export__as_edge_statement(std::stringstream &ss) const
UndirectedEdge & new_edge(NodePort a, NodePort b)
std::string to_dot_string() const
local_group_size(16, 16) .push_constant(Type b
draw_view in_light_buf[] float
std::string color_attr_from_hsv(float h, float s, float v)
_W64 unsigned int uintptr_t
std::optional< std::string > fontcolor