24 nodes_.append(std::unique_ptr<Node>(
node));
25 top_level_nodes_.add_new(
node);
26 node->attributes.set(
"label", label);
32 Cluster *cluster =
new Cluster(*
this);
33 clusters_.append(std::unique_ptr<Cluster>(cluster));
34 top_level_clusters_.add_new(cluster);
42 edges_.append(std::unique_ptr<UndirectedEdge>(edge));
49 edges_.append(std::unique_ptr<DirectedEdge>(edge));
55 if (parent_ == new_parent) {
58 if (parent_ ==
nullptr) {
59 graph_.top_level_clusters_.remove(
this);
60 new_parent->children_.add_new(
this);
62 else if (new_parent ==
nullptr) {
63 parent_->children_.remove(
this);
64 graph_.top_level_clusters_.add_new(
this);
67 parent_->children_.remove(
this);
68 new_parent->children_.add_new(
this);
75 if (cluster_ == cluster) {
78 if (cluster_ ==
nullptr) {
79 graph_.top_level_nodes_.remove(
this);
80 cluster->nodes_.add_new(
this);
82 else if (cluster ==
nullptr) {
83 cluster_->nodes_.remove(
this);
84 graph_.top_level_nodes_.add_new(
this);
87 cluster_->nodes_.remove(
this);
88 cluster->nodes_.add_new(
this);
101 for (Cluster *cluster : top_level_clusters_) {
102 cluster->set_random_cluster_bgcolors();
108 float hue = rand() /
float(RAND_MAX);
109 float staturation = 0.3f;
113 for (
Cluster *cluster : children_) {
114 cluster->set_random_cluster_bgcolors();
121 while (current !=
nullptr) {
122 if (current ==
this) {
125 current = current->parent_;
138 std::stringstream ss;
143 for (
const std::unique_ptr<DirectedEdge> &edge : edges_) {
144 edge->export__as_edge_statement(ss);
154 std::stringstream ss;
159 for (
const std::unique_ptr<UndirectedEdge> &edge : edges_) {
160 edge->export__as_edge_statement(ss);
174 for (Node *
node : top_level_nodes_) {
175 node->export__as_declaration(ss);
178 for (Cluster *cluster : top_level_clusters_) {
179 cluster->export__declare_nodes_and_clusters(ss);
185 ss <<
"subgraph " << this->
name() <<
" {\n";
191 for (Node *
node : nodes_) {
192 node->export__as_declaration(ss);
195 for (
Cluster *cluster : children_) {
196 cluster->export__declare_nodes_and_clusters(ss);
226 ss << key <<
"=" << value <<
", ";
230 for (
char c : value) {
258 node_->export__as_id(ss);
259 if (port_name_.has_value()) {
260 ss <<
":" << *port_name_;
262 if (port_position_.has_value()) {
263 ss <<
":" << *port_position_;
269 std::stringstream ss;
270 ss << std::setprecision(4) << h <<
' ' << s <<
' ' <<
v;
276 std::stringstream ss;
278 ss << R
"(<<table border="0" cellspacing="3">)";
281 ss << R
"(<tr><td colspan="3" align="center"><b>)";
282 ss << (data.node_name.empty() ? "No Name" :
data.node_name);
283 ss <<
"</b></td></tr>";
286 int socket_max_amount = std::max(
data.inputs.size(),
data.outputs.size());
287 for (
int i = 0; i < socket_max_amount; i++) {
289 if (i <
data.inputs.size()) {
291 ss << R
"(<td align="left" port="in)" << i << "\">";
305 if (i <
data.outputs.size()) {
307 ss << R
"(<td align="right" port="out)" << i << "\">";
309 ss << R
"(<font color=")" << *output.fontcolor << "\">";
325 node_->attributes.set(
"label", ss.str());
void set(StringRef key, StringRef value)
void export__as_bracket_list(std::stringstream &ss) const
void set_random_cluster_bgcolors()
bool contains(Node &node) const
void set_parent_cluster(Cluster *new_parent)
void export__declare_nodes_and_clusters(std::stringstream &ss) const
DirectedEdge(NodePort from, NodePort to)
void export__as_edge_statement(std::stringstream &ss) const
std::string to_dot_string() const
DirectedEdge & new_edge(NodePort from, NodePort to)
Cluster & new_cluster(StringRef label="")
void set_random_cluster_bgcolors()
void export__declare_nodes_and_clusters(std::stringstream &ss) const
Node & new_node(StringRef label)
void to_dot_string(std::stringstream &ss) const
NodeWithSocketsRef(Node &node, const NodeWithSockets &data)
NodePort output(int index) const
NodePort input(int index) const
void export__as_declaration(std::stringstream &ss) const
void export__as_id(std::stringstream &ss) const
void set_parent_cluster(Cluster *cluster)
UndirectedEdge(NodePort a, NodePort b)
void export__as_edge_statement(std::stringstream &ss) const
UndirectedEdge & new_edge(NodePort a, NodePort b)
std::string to_dot_string() const
std::string color_attr_from_hsv(float h, float s, float v)
ATTR_WARN_UNUSED_RESULT const BMVert * v
BMesh const char void * data
_W64 unsigned int uintptr_t
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
std::optional< std::string > fontcolor