22 Node *node =
new Node(*
this);
23 nodes_.append(std::unique_ptr<Node>(node));
24 top_level_nodes_.add_new(node);
31 Cluster *cluster =
new Cluster(*
this);
32 clusters_.append(std::unique_ptr<Cluster>(cluster));
33 top_level_clusters_.add_new(cluster);
41 edges_.append(std::unique_ptr<UndirectedEdge>(edge));
48 edges_.append(std::unique_ptr<DirectedEdge>(edge));
54 if (parent_ == new_parent) {
57 if (parent_ ==
nullptr) {
58 graph_.top_level_clusters_.remove(
this);
59 new_parent->children_.add_new(
this);
61 else if (new_parent ==
nullptr) {
62 parent_->children_.remove(
this);
63 graph_.top_level_clusters_.add_new(
this);
66 parent_->children_.remove(
this);
67 new_parent->children_.add_new(
this);
74 if (cluster_ == cluster) {
77 if (cluster_ ==
nullptr) {
78 graph_.top_level_nodes_.remove(
this);
79 cluster->nodes_.add_new(
this);
81 else if (cluster ==
nullptr) {
82 cluster_->nodes_.remove(
this);
83 graph_.top_level_nodes_.add_new(
this);
86 cluster_->nodes_.remove(
this);
87 cluster->nodes_.add_new(
this);
97 for (Cluster *cluster : top_level_clusters_) {
98 cluster->set_random_cluster_bgcolors();
104 float hue = rand() /
float(RAND_MAX);
105 float staturation = 0.3f;
109 for (
Cluster *cluster : children_) {
110 cluster->set_random_cluster_bgcolors();
117 while (current !=
nullptr) {
118 if (current ==
this) {
121 current = current->parent_;
131 std::stringstream ss;
136 for (
const std::unique_ptr<DirectedEdge> &edge : edges_) {
137 edge->export__as_edge_statement(ss);
147 std::stringstream ss;
152 for (
const std::unique_ptr<UndirectedEdge> &edge : edges_) {
153 edge->export__as_edge_statement(ss);
167 for (Node *node : top_level_nodes_) {
168 node->export__as_declaration(ss);
171 for (Cluster *cluster : top_level_clusters_) {
172 cluster->export__declare_nodes_and_clusters(ss);
178 ss <<
"subgraph " << this->
name() <<
" {\n";
184 for (Node *node : nodes_) {
185 node->export__as_declaration(ss);
188 for (
Cluster *cluster : children_) {
189 cluster->export__declare_nodes_and_clusters(ss);
197 a_.to_dot_string(ss);
199 b_.to_dot_string(ss);
206 a_.to_dot_string(ss);
208 b_.to_dot_string(ss);
219 ss << key <<
"=" << value <<
", ";
223 for (
char c : value) {
238 ss <<
'"' << uintptr_t(
this) <<
'"';
251 node_->export__as_id(ss);
252 if (port_name_.has_value()) {
253 ss <<
":" << *port_name_;
255 if (port_position_.has_value()) {
256 ss <<
":" << *port_position_;
262 std::stringstream ss;
263 ss << std::setprecision(4) << h <<
' ' << s <<
' ' <<
v;
269 std::stringstream ss;
271 ss << R
"(<<table border="0" cellspacing="3">)";
274 ss << R
"(<tr><td colspan="3" align="center"><b>)";
275 ss << (data.node_name.empty() ? "No Name" :
data.node_name);
276 ss <<
"</b></td></tr>";
279 int socket_max_amount = std::max(
data.inputs.size(),
data.outputs.size());
280 for (
int i = 0;
i < socket_max_amount;
i++) {
282 if (
i <
data.inputs.size()) {
284 ss << R
"(<td align="left" port="in)" << i << "\">";
285 if (
input.fontcolor) {
286 ss << R
"(<font color=")" << *input.fontcolor << "\">";
288 ss << (
input.name.empty() ?
"No Name" :
input.name);
289 if (
input.fontcolor) {
298 if (
i <
data.outputs.size()) {
300 ss << R
"(<td align="right" port="out)" << i << "\">";
302 ss << R
"(<font color=")" << *output.fontcolor << "\">";
318 node_->attributes.set(
"label", ss.str());
BMesh const char void * data
ATTR_WARN_UNUSED_RESULT const BMVert * v
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
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)
Cluster * parent_cluster()
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)