Cleanup: rename dot to dot_export namespace

Without this, including `BLI_dot_export.hh` in `delaunay_2d.cc` causes a
compile error because the name `dot` is ambiguous.

Pull Request: https://projects.blender.org/blender/blender/pulls/136385
This commit is contained in:
Jacques Lucke
2025-03-23 13:34:07 +01:00
parent 0c9f0709d3
commit 3943a39c08
11 changed files with 118 additions and 109 deletions

View File

@@ -9,7 +9,7 @@
#include "DNA_node_types.h"
namespace blender::dot {
namespace blender::dot_export {
class DirectedEdge;
}
@@ -22,7 +22,8 @@ class bNodeTreeToDotOptions {
public:
virtual std::string socket_name(const bNodeSocket &socket) const;
virtual std::optional<std::string> socket_font_color(const bNodeSocket &socket) const;
virtual void add_edge_attributes(const bNodeLink &link, dot::DirectedEdge &dot_edge) const;
virtual void add_edge_attributes(const bNodeLink &link,
dot_export::DirectedEdge &dot_edge) const;
};
/**

View File

@@ -24,7 +24,7 @@ std::optional<std::string> bNodeTreeToDotOptions::socket_font_color(
}
void bNodeTreeToDotOptions::add_edge_attributes(const bNodeLink &link,
dot::DirectedEdge &dot_edge) const
dot_export::DirectedEdge &dot_edge) const
{
if (!link.is_used()) {
dot_edge.attributes.set("color", "#999999");
@@ -33,37 +33,38 @@ void bNodeTreeToDotOptions::add_edge_attributes(const bNodeLink &link,
std::string node_tree_to_dot(const bNodeTree &tree, const bNodeTreeToDotOptions &options)
{
namespace dot = blender::dot_export;
tree.ensure_topology_cache();
dot::DirectedGraph digraph;
digraph.set_rankdir(dot::Attr_rankdir::LeftToRight);
dot_export::DirectedGraph digraph;
digraph.set_rankdir(dot_export::Attr_rankdir::LeftToRight);
Map<const bNode *, dot::NodeWithSocketsRef> dot_nodes;
Map<const bNode *, dot_export::NodeWithSocketsRef> dot_nodes;
for (const bNode *node : tree.all_nodes()) {
dot::Node &dot_node = digraph.new_node("");
dot::NodeWithSockets dot_node_with_sockets;
dot_export::Node &dot_node = digraph.new_node("");
dot_export::NodeWithSockets dot_node_with_sockets;
dot_node_with_sockets.node_name = node->label_or_name();
for (const bNodeSocket *socket : node->input_sockets()) {
dot::NodeWithSockets::Input &dot_input = dot_node_with_sockets.add_input(
dot_export::NodeWithSockets::Input &dot_input = dot_node_with_sockets.add_input(
options.socket_name(*socket));
dot_input.fontcolor = options.socket_font_color(*socket);
}
for (const bNodeSocket *socket : node->output_sockets()) {
dot::NodeWithSockets::Output &dot_output = dot_node_with_sockets.add_output(
dot_export::NodeWithSockets::Output &dot_output = dot_node_with_sockets.add_output(
options.socket_name(*socket));
dot_output.fontcolor = options.socket_font_color(*socket);
}
dot_nodes.add_new(node, dot::NodeWithSocketsRef(dot_node, dot_node_with_sockets));
dot_nodes.add_new(node, dot_export::NodeWithSocketsRef(dot_node, dot_node_with_sockets));
}
for (const bNodeLink *link : tree.all_links()) {
const dot::NodeWithSocketsRef &from_dot_node = dot_nodes.lookup(link->fromnode);
const dot::NodeWithSocketsRef &to_dot_node = dot_nodes.lookup(link->tonode);
const dot::NodePort from_dot_port = from_dot_node.output(link->fromsock->index());
const dot::NodePort to_dot_port = to_dot_node.input(link->tosock->index());
const dot_export::NodeWithSocketsRef &from_dot_node = dot_nodes.lookup(link->fromnode);
const dot_export::NodeWithSocketsRef &to_dot_node = dot_nodes.lookup(link->tonode);
const dot_export::NodePort from_dot_port = from_dot_node.output(link->fromsock->index());
const dot_export::NodePort to_dot_port = to_dot_node.input(link->tosock->index());
dot::DirectedEdge &dot_edge = digraph.new_edge(from_dot_port, to_dot_port);
dot_export::DirectedEdge &dot_edge = digraph.new_edge(from_dot_port, to_dot_port);
options.add_edge_attributes(*link, dot_edge);
}

View File

@@ -21,7 +21,7 @@
#include <iosfwd>
#include <optional>
namespace blender::dot {
namespace blender::dot_export {
class Graph;
class DirectedGraph;
@@ -293,4 +293,4 @@ class NodeWithSocketsRef {
}
};
} // namespace blender::dot
} // namespace blender::dot_export

View File

@@ -6,7 +6,7 @@
#include "BLI_string_ref.hh"
namespace blender ::dot {
namespace blender::dot_export {
enum class Attr_rankdir {
LeftToRight,
@@ -105,4 +105,4 @@ inline StringRef dirType_to_string(Attr_dirType value)
return "";
}
} // namespace blender::dot
} // namespace blender::dot_export

View File

@@ -272,14 +272,14 @@ class InplacePriorityQueue {
std::string partial_to_dot(const int size) const
{
dot::DirectedGraph digraph;
Array<dot::Node *> dot_nodes(size);
dot_export::DirectedGraph digraph;
Array<dot_export::Node *> dot_nodes(size);
for (const int i : IndexRange(size)) {
std::stringstream ss;
ss << data_[heap_to_orig_[i]];
const std::string name = ss.str();
dot::Node &node = digraph.new_node(name);
node.set_shape(dot::Attr_shape::Rectangle);
dot_export::Node &node = digraph.new_node(name);
node.set_shape(dot_export::Attr_shape::Rectangle);
node.attributes.set("ordering", "out");
dot_nodes[i] = &node;
if (i > 0) {

View File

@@ -8,7 +8,7 @@
#include <sstream>
namespace blender::dot {
namespace blender::dot_export {
/* Graph Building
************************************************/
@@ -315,4 +315,4 @@ NodeWithSocketsRef::NodeWithSocketsRef(Node &node, const NodeWithSockets &data)
node_->set_shape(Attr_shape::Rectangle);
}
} // namespace blender::dot
} // namespace blender::dot_export

View File

@@ -26,7 +26,7 @@
#include <sstream>
namespace deg = blender::deg;
namespace dot = blender::dot;
namespace dot_export = blender::dot_export;
/* ****************** */
/* Graphviz Debugging */
@@ -141,9 +141,9 @@ static int deg_debug_node_color_index(const Node *node)
struct DotExportContext {
bool show_tags;
dot::DirectedGraph &digraph;
Map<const Node *, dot::Node *> nodes_map;
Map<const Node *, dot::Cluster *> clusters_map;
dot_export::DirectedGraph &digraph;
Map<const Node *, dot_export::Node *> nodes_map;
Map<const Node *, dot_export::Cluster *> clusters_map;
};
static void deg_debug_graphviz_legend_color(const char *name,
@@ -159,7 +159,7 @@ static void deg_debug_graphviz_legend_color(const char *name,
static void deg_debug_graphviz_legend(DotExportContext &ctx)
{
dot::Node &legend_node = ctx.digraph.new_node("");
dot_export::Node &legend_node = ctx.digraph.new_node("");
legend_node.attributes.set("rank", "sink");
legend_node.attributes.set("shape", "none");
legend_node.attributes.set("margin", 0);
@@ -195,7 +195,7 @@ static void deg_debug_graphviz_legend(DotExportContext &ctx)
static void deg_debug_graphviz_node_color(DotExportContext &ctx,
const Node *node,
dot::Attributes &dot_attributes)
dot_export::Attributes &dot_attributes)
{
const char *color_default = "black";
const char *color_modified = "orangered4";
@@ -217,7 +217,7 @@ static void deg_debug_graphviz_node_color(DotExportContext &ctx,
static void deg_debug_graphviz_node_penwidth(DotExportContext &ctx,
const Node *node,
dot::Attributes &dot_attributes)
dot_export::Attributes &dot_attributes)
{
float penwidth_default = 1.0f;
float penwidth_modified = 4.0f;
@@ -237,7 +237,8 @@ static void deg_debug_graphviz_node_penwidth(DotExportContext &ctx,
dot_attributes.set("penwidth", penwidth);
}
static void deg_debug_graphviz_node_fillcolor(const Node *node, dot::Attributes &dot_attributes)
static void deg_debug_graphviz_node_fillcolor(const Node *node,
dot_export::Attributes &dot_attributes)
{
const char *defaultcolor = "gainsboro";
int color_index = deg_debug_node_color_index(node);
@@ -247,7 +248,7 @@ static void deg_debug_graphviz_node_fillcolor(const Node *node, dot::Attributes
dot_attributes.set("fillcolor", fillcolor);
}
static void deg_debug_graphviz_relation_color(const Relation *rel, dot::DirectedEdge &edge)
static void deg_debug_graphviz_relation_color(const Relation *rel, dot_export::DirectedEdge &edge)
{
const char *color_default = "black";
const char *color_cyclic = "red4"; /* The color of crime scene. */
@@ -262,7 +263,7 @@ static void deg_debug_graphviz_relation_color(const Relation *rel, dot::Directed
edge.attributes.set("color", color);
}
static void deg_debug_graphviz_relation_style(const Relation *rel, dot::DirectedEdge &edge)
static void deg_debug_graphviz_relation_style(const Relation *rel, dot_export::DirectedEdge &edge)
{
const char *style_default = "solid";
const char *style_no_flush = "dashed";
@@ -277,7 +278,8 @@ static void deg_debug_graphviz_relation_style(const Relation *rel, dot::Directed
edge.attributes.set("style", style);
}
static void deg_debug_graphviz_relation_arrowhead(const Relation *rel, dot::DirectedEdge &edge)
static void deg_debug_graphviz_relation_arrowhead(const Relation *rel,
dot_export::DirectedEdge &edge)
{
const char *shape_default = "normal";
const char *shape_no_cow = "box";
@@ -300,7 +302,7 @@ static void deg_debug_graphviz_relation_arrowhead(const Relation *rel, dot::Dire
static void deg_debug_graphviz_node_style(DotExportContext &ctx,
const Node *node,
dot::Attributes &dot_attributes)
dot_export::Attributes &dot_attributes)
{
StringRef base_style = "filled"; /* default style */
if (ctx.show_tags) {
@@ -326,11 +328,11 @@ static void deg_debug_graphviz_node_style(DotExportContext &ctx,
static void deg_debug_graphviz_node_single(DotExportContext &ctx,
const Node *node,
dot::Cluster *parent_cluster)
dot_export::Cluster *parent_cluster)
{
std::string name = node->identifier();
dot::Node &dot_node = ctx.digraph.new_node(name);
dot_export::Node &dot_node = ctx.digraph.new_node(name);
ctx.nodes_map.add_new(node, &dot_node);
dot_node.set_parent_cluster(parent_cluster);
dot_node.attributes.set("fontname", deg_debug_graphviz_fontname);
@@ -343,12 +345,11 @@ static void deg_debug_graphviz_node_single(DotExportContext &ctx,
deg_debug_graphviz_node_penwidth(ctx, node, dot_node.attributes);
}
static dot::Cluster &deg_debug_graphviz_node_cluster_create(DotExportContext &ctx,
const Node *node,
dot::Cluster *parent_cluster)
static dot_export::Cluster &deg_debug_graphviz_node_cluster_create(
DotExportContext &ctx, const Node *node, dot_export::Cluster *parent_cluster)
{
std::string name = node->identifier();
dot::Cluster &cluster = ctx.digraph.new_cluster(name);
dot_export::Cluster &cluster = ctx.digraph.new_cluster(name);
cluster.set_parent_cluster(parent_cluster);
cluster.attributes.set("fontname", deg_debug_graphviz_fontname);
cluster.attributes.set("fontsize", deg_debug_graphviz_node_label_size);
@@ -358,7 +359,7 @@ static dot::Cluster &deg_debug_graphviz_node_cluster_create(DotExportContext &ct
deg_debug_graphviz_node_fillcolor(node, cluster.attributes);
deg_debug_graphviz_node_penwidth(ctx, node, cluster.attributes);
/* dummy node, so we can add edges between clusters */
dot::Node &dot_node = ctx.digraph.new_node("");
dot_export::Node &dot_node = ctx.digraph.new_node("");
dot_node.attributes.set("shape", "point");
dot_node.attributes.set("style", "invis");
dot_node.set_parent_cluster(&cluster);
@@ -372,7 +373,7 @@ static void deg_debug_graphviz_graph_relations(DotExportContext &ctx, const Deps
static void deg_debug_graphviz_node(DotExportContext &ctx,
const Node *node,
dot::Cluster *parent_cluster)
dot_export::Cluster *parent_cluster)
{
switch (node->type) {
case NodeType::ID_REF: {
@@ -381,7 +382,8 @@ static void deg_debug_graphviz_node(DotExportContext &ctx,
deg_debug_graphviz_node_single(ctx, node, parent_cluster);
}
else {
dot::Cluster &cluster = deg_debug_graphviz_node_cluster_create(ctx, node, parent_cluster);
dot_export::Cluster &cluster = deg_debug_graphviz_node_cluster_create(
ctx, node, parent_cluster);
for (const ComponentNode *comp : id_node->components.values()) {
deg_debug_graphviz_node(ctx, comp, &cluster);
}
@@ -420,7 +422,8 @@ static void deg_debug_graphviz_node(DotExportContext &ctx,
deg_debug_graphviz_node_single(ctx, node, parent_cluster);
}
else {
dot::Cluster &cluster = deg_debug_graphviz_node_cluster_create(ctx, node, parent_cluster);
dot_export::Cluster &cluster = deg_debug_graphviz_node_cluster_create(
ctx, node, parent_cluster);
for (Node *op_node : comp_node->operations) {
deg_debug_graphviz_node(ctx, op_node, &cluster);
}
@@ -444,10 +447,10 @@ static void deg_debug_graphviz_node_relations(DotExportContext &ctx, const Node
const Node *head = rel->to; /* same as node */
const Node *tail = rel->from;
dot::Node &dot_tail = *ctx.nodes_map.lookup(tail);
dot::Node &dot_head = *ctx.nodes_map.lookup(head);
dot_export::Node &dot_tail = *ctx.nodes_map.lookup(tail);
dot_export::Node &dot_head = *ctx.nodes_map.lookup(head);
dot::DirectedEdge &edge = ctx.digraph.new_edge(dot_tail, dot_head);
dot_export::DirectedEdge &edge = ctx.digraph.new_edge(dot_tail, dot_head);
/* NOTE: without label an id seem necessary to avoid bugs in graphviz/dot. */
edge.attributes.set("id", rel->name);
@@ -459,11 +462,11 @@ static void deg_debug_graphviz_node_relations(DotExportContext &ctx, const Node
/* NOTE: edge from node to our own cluster is not possible and gives graphviz
* warning, avoid this here by just linking directly to the invisible
* placeholder node. */
dot::Cluster *tail_cluster = ctx.clusters_map.lookup_default(tail, nullptr);
dot_export::Cluster *tail_cluster = ctx.clusters_map.lookup_default(tail, nullptr);
if (tail_cluster != nullptr && tail_cluster->contains(dot_head)) {
edge.attributes.set("ltail", tail_cluster->name());
}
dot::Cluster *head_cluster = ctx.clusters_map.lookup_default(head, nullptr);
dot_export::Cluster *head_cluster = ctx.clusters_map.lookup_default(head, nullptr);
if (head_cluster != nullptr && head_cluster->contains(dot_tail)) {
edge.attributes.set("lhead", head_cluster->name());
}
@@ -503,10 +506,10 @@ std::string DEG_debug_graph_to_dot(const Depsgraph &graph, const blender::String
{
const deg::Depsgraph &deg_graph = reinterpret_cast<const deg::Depsgraph &>(graph);
dot::DirectedGraph digraph;
dot_export::DirectedGraph digraph;
deg::DotExportContext ctx{false, digraph};
digraph.set_rankdir(dot::Attr_rankdir::LeftToRight);
digraph.set_rankdir(dot_export::Attr_rankdir::LeftToRight);
digraph.attributes.set("compound", "true");
digraph.attributes.set("labelloc", "t");
digraph.attributes.set("fontsize", deg::deg_debug_graphviz_graph_label_size);

View File

@@ -21,7 +21,7 @@
#include "FN_lazy_function.hh"
namespace blender::dot {
namespace blender::dot_export {
class DirectedEdge;
}
@@ -302,7 +302,7 @@ class Graph : NonCopyable, NonMovable {
virtual std::optional<std::string> socket_font_color(const Socket &socket) const;
virtual void add_edge_attributes(const OutputSocket &from,
const InputSocket &to,
dot::DirectedEdge &dot_edge) const;
dot_export::DirectedEdge &dot_edge) const;
};
/**

View File

@@ -185,19 +185,19 @@ std::optional<std::string> Graph::ToDotOptions::socket_font_color(const Socket &
void Graph::ToDotOptions::add_edge_attributes(const OutputSocket & /*from*/,
const InputSocket & /*to*/,
dot::DirectedEdge & /*dot_edge*/) const
dot_export::DirectedEdge & /*dot_edge*/) const
{
}
std::string Graph::to_dot(const ToDotOptions &options) const
{
dot::DirectedGraph digraph;
digraph.set_rankdir(dot::Attr_rankdir::LeftToRight);
dot_export::DirectedGraph digraph;
digraph.set_rankdir(dot_export::Attr_rankdir::LeftToRight);
Map<const Node *, dot::NodeWithSocketsRef> dot_nodes;
Map<const Node *, dot_export::NodeWithSocketsRef> dot_nodes;
for (const Node *node : nodes_) {
dot::Node &dot_node = digraph.new_node("");
dot_export::Node &dot_node = digraph.new_node("");
if (node->is_interface()) {
dot_node.set_background_color("lightblue");
}
@@ -205,31 +205,31 @@ std::string Graph::to_dot(const ToDotOptions &options) const
dot_node.set_background_color("white");
}
dot::NodeWithSockets dot_node_with_sockets;
dot_export::NodeWithSockets dot_node_with_sockets;
dot_node_with_sockets.node_name = node->name();
for (const InputSocket *socket : node->inputs()) {
dot::NodeWithSockets::Input &dot_input = dot_node_with_sockets.add_input(
dot_export::NodeWithSockets::Input &dot_input = dot_node_with_sockets.add_input(
options.socket_name(*socket));
dot_input.fontcolor = options.socket_font_color(*socket);
}
for (const OutputSocket *socket : node->outputs()) {
dot::NodeWithSockets::Output &dot_output = dot_node_with_sockets.add_output(
dot_export::NodeWithSockets::Output &dot_output = dot_node_with_sockets.add_output(
options.socket_name(*socket));
dot_output.fontcolor = options.socket_font_color(*socket);
}
dot_nodes.add_new(node, dot::NodeWithSocketsRef(dot_node, dot_node_with_sockets));
dot_nodes.add_new(node, dot_export::NodeWithSocketsRef(dot_node, dot_node_with_sockets));
}
for (const Node *node : nodes_) {
for (const InputSocket *socket : node->inputs()) {
const dot::NodeWithSocketsRef &to_dot_node = dot_nodes.lookup(&socket->node());
const dot::NodePort to_dot_port = to_dot_node.input(socket->index());
const dot_export::NodeWithSocketsRef &to_dot_node = dot_nodes.lookup(&socket->node());
const dot_export::NodePort to_dot_port = to_dot_node.input(socket->index());
if (const OutputSocket *origin = socket->origin()) {
dot::NodeWithSocketsRef &from_dot_node = dot_nodes.lookup(&origin->node());
dot::DirectedEdge &dot_edge = digraph.new_edge(from_dot_node.output(origin->index()),
to_dot_port);
dot_export::NodeWithSocketsRef &from_dot_node = dot_nodes.lookup(&origin->node());
dot_export::DirectedEdge &dot_edge = digraph.new_edge(
from_dot_node.output(origin->index()), to_dot_port);
options.add_edge_attributes(*origin, *socket, dot_edge);
}
else if (const void *default_value = socket->default_value()) {
@@ -241,8 +241,8 @@ std::string Graph::to_dot(const ToDotOptions &options) const
else {
value_string = type.name();
}
dot::Node &default_value_dot_node = digraph.new_node(value_string);
default_value_dot_node.set_shape(dot::Attr_shape::Ellipse);
dot_export::Node &default_value_dot_node = digraph.new_node(value_string);
default_value_dot_node.set_shape(dot_export::Attr_shape::Ellipse);
default_value_dot_node.attributes.set("color", "#00000055");
digraph.new_edge(default_value_dot_node, to_dot_port);
}

View File

@@ -555,9 +555,9 @@ Procedure::InitState Procedure::find_initialization_state_before_instruction(
class ProcedureDotExport {
private:
const Procedure &procedure_;
dot::DirectedGraph digraph_;
Map<const Instruction *, dot::Node *> dot_nodes_by_begin_;
Map<const Instruction *, dot::Node *> dot_nodes_by_end_;
dot_export::DirectedGraph digraph_;
Map<const Instruction *, dot_export::Node *> dot_nodes_by_begin_;
Map<const Instruction *, dot_export::Node *> dot_nodes_by_end_;
public:
ProcedureDotExport(const Procedure &procedure) : procedure_(procedure) {}
@@ -620,8 +620,8 @@ class ProcedureDotExport {
}
ss << ">";
dot::Node &dot_node = digraph_.new_node(ss.str());
dot_node.set_shape(dot::Attr_shape::Rectangle);
dot_export::Node &dot_node = digraph_.new_node(ss.str());
dot_node.set_shape(dot_export::Attr_shape::Rectangle);
dot_nodes_by_begin_.add_new(block_instructions.first(), &dot_node);
dot_nodes_by_end_.add_new(block_instructions.last(), &dot_node);
}
@@ -629,20 +629,20 @@ class ProcedureDotExport {
void create_edges()
{
auto create_edge = [&](dot::Node &from_node,
const Instruction *to_instruction) -> dot::DirectedEdge & {
auto create_edge = [&](dot_export::Node &from_node,
const Instruction *to_instruction) -> dot_export::DirectedEdge & {
if (to_instruction == nullptr) {
dot::Node &to_node = digraph_.new_node("missing");
to_node.set_shape(dot::Attr_shape::Diamond);
dot_export::Node &to_node = digraph_.new_node("missing");
to_node.set_shape(dot_export::Attr_shape::Diamond);
return digraph_.new_edge(from_node, to_node);
}
dot::Node &to_node = *dot_nodes_by_begin_.lookup(to_instruction);
dot_export::Node &to_node = *dot_nodes_by_begin_.lookup(to_instruction);
return digraph_.new_edge(from_node, to_node);
};
for (auto item : dot_nodes_by_end_.items()) {
const Instruction &from_instruction = *item.key;
dot::Node &from_node = *item.value;
dot_export::Node &from_node = *item.value;
switch (from_instruction.type()) {
case InstructionType::Call: {
const Instruction *to_instruction =
@@ -677,7 +677,7 @@ class ProcedureDotExport {
}
}
dot::Node &entry_node = this->create_entry_node();
dot_export::Node &entry_node = this->create_entry_node();
create_edge(entry_node, procedure_.entry());
}
@@ -838,7 +838,7 @@ class ProcedureDotExport {
variable_to_string(instruction.condition(), ss);
}
dot::Node &create_entry_node()
dot_export::Node &create_entry_node()
{
std::stringstream ss;
ss << "Entry: ";
@@ -856,8 +856,8 @@ class ProcedureDotExport {
}
}
dot::Node &node = digraph_.new_node(ss.str());
node.set_shape(dot::Attr_shape::Ellipse);
dot_export::Node &node = digraph_.new_node(ss.str());
node.set_shape(dot_export::Attr_shape::Ellipse);
return node;
}
};

View File

@@ -354,21 +354,21 @@ const DTreeContext &DerivedNodeTree::active_context() const
}
/* Each nested node group gets its own cluster. Just as node groups, clusters can be nested. */
static dot::Cluster *get_dot_cluster_for_context(
dot::DirectedGraph &digraph,
static dot_export::Cluster *get_dot_cluster_for_context(
dot_export::DirectedGraph &digraph,
const DTreeContext *context,
Map<const DTreeContext *, dot::Cluster *> &dot_clusters)
Map<const DTreeContext *, dot_export::Cluster *> &dot_clusters)
{
return dot_clusters.lookup_or_add_cb(context, [&]() -> dot::Cluster * {
return dot_clusters.lookup_or_add_cb(context, [&]() -> dot_export::Cluster * {
const DTreeContext *parent_context = context->parent_context();
if (parent_context == nullptr) {
return nullptr;
}
dot::Cluster *parent_cluster = get_dot_cluster_for_context(
dot_export::Cluster *parent_cluster = get_dot_cluster_for_context(
digraph, parent_context, dot_clusters);
std::string cluster_name = StringRef(context->btree().id.name + 2) + " / " +
context->parent_node()->name;
dot::Cluster &cluster = digraph.new_cluster(cluster_name);
dot_export::Cluster &cluster = digraph.new_cluster(cluster_name);
cluster.set_parent_cluster(parent_cluster);
return &cluster;
});
@@ -376,12 +376,14 @@ static dot::Cluster *get_dot_cluster_for_context(
std::string DerivedNodeTree::to_dot() const
{
dot::DirectedGraph digraph;
digraph.set_rankdir(dot::Attr_rankdir::LeftToRight);
namespace dot = dot_export;
Map<const DTreeContext *, dot::Cluster *> dot_clusters;
Map<DInputSocket, dot::NodePort> dot_input_sockets;
Map<DOutputSocket, dot::NodePort> dot_output_sockets;
dot_export::DirectedGraph digraph;
digraph.set_rankdir(dot_export::Attr_rankdir::LeftToRight);
Map<const DTreeContext *, dot_export::Cluster *> dot_clusters;
Map<DInputSocket, dot_export::NodePort> dot_input_sockets;
Map<DOutputSocket, dot_export::NodePort> dot_output_sockets;
this->foreach_node([&](DNode node) {
/* Ignore nodes that should not show up in the final output. */
@@ -394,13 +396,14 @@ std::string DerivedNodeTree::to_dot() const
}
}
dot::Cluster *cluster = get_dot_cluster_for_context(digraph, node.context(), dot_clusters);
dot_export::Cluster *cluster = get_dot_cluster_for_context(
digraph, node.context(), dot_clusters);
dot::Node &dot_node = digraph.new_node("");
dot_export::Node &dot_node = digraph.new_node("");
dot_node.set_parent_cluster(cluster);
dot_node.set_background_color("white");
dot::NodeWithSockets dot_node_with_sockets;
dot_export::NodeWithSockets dot_node_with_sockets;
for (const bNodeSocket *socket : node->input_sockets()) {
if (socket->is_available()) {
dot_node_with_sockets.add_input(socket->name);
@@ -412,7 +415,7 @@ std::string DerivedNodeTree::to_dot() const
}
}
dot::NodeWithSocketsRef dot_node_with_sockets_ref = dot::NodeWithSocketsRef(
dot_export::NodeWithSocketsRef dot_node_with_sockets_ref = dot_export::NodeWithSocketsRef(
dot_node, dot_node_with_sockets);
int input_index = 0;
@@ -434,23 +437,24 @@ std::string DerivedNodeTree::to_dot() const
});
/* Floating inputs are used for example to visualize unlinked group node inputs. */
Map<DSocket, dot::Node *> dot_floating_inputs;
Map<DSocket, dot_export::Node *> dot_floating_inputs;
for (const auto item : dot_input_sockets.items()) {
DInputSocket to_socket = item.key;
dot::NodePort dot_to_port = item.value;
dot_export::NodePort dot_to_port = item.value;
to_socket.foreach_origin_socket([&](DSocket from_socket) {
if (from_socket->is_output()) {
dot::NodePort *dot_from_port = dot_output_sockets.lookup_ptr(DOutputSocket(from_socket));
dot_export::NodePort *dot_from_port = dot_output_sockets.lookup_ptr(
DOutputSocket(from_socket));
if (dot_from_port != nullptr) {
digraph.new_edge(*dot_from_port, dot_to_port);
return;
}
}
dot::Node &dot_node = *dot_floating_inputs.lookup_or_add_cb(from_socket, [&]() {
dot::Node &dot_node = digraph.new_node(from_socket->name);
dot_export::Node &dot_node = *dot_floating_inputs.lookup_or_add_cb(from_socket, [&]() {
dot_export::Node &dot_node = digraph.new_node(from_socket->name);
dot_node.set_background_color("white");
dot_node.set_shape(dot::Attr_shape::Ellipse);
dot_node.set_shape(dot_export::Attr_shape::Ellipse);
dot_node.set_parent_cluster(
get_dot_cluster_for_context(digraph, from_socket.context(), dot_clusters));
return &dot_node;