9 .. module:: pydotfactory 11 :synopsis: Repackaging of the limiting ROS qt_dotgraph.pydotfactory module. 13 Oh my spaghettified magnificence, 14 Bless my noggin with a tickle from your noodly appendages! 22 from distutils.version
import LooseVersion
28 pyparsing._noncomma =
"".join([c
for c
in pyparsing.printables
if c !=
","])
42 if name
in [
'graph',
'subgraph',
'node',
'edge']:
49 ret = urllib.quote(name.strip())
50 ret = ret.replace(
'/',
'_')
51 ret = ret.replace(
'%',
'_')
52 ret = ret.replace(
'-',
'_')
55 def get_graph(self, graph_type='digraph', rank='same', simplify=True, rankdir='TB', ranksep=0.2, compound=True):
57 if LooseVersion(pydot.__version__) > LooseVersion(
'1.0.10'):
58 graph = pydot.Dot(
'graphname',
59 graph_type=graph_type,
64 graph.set_ranksep(ranksep)
65 graph.set_compound(compound)
67 graph = pydot.Dot(
'graphname',
68 graph_type=graph_type,
82 creates a node item for this factory, adds it to the graph. 83 Node name can vary from label but must always be same for the same node label 85 if nodename
is None or nodename ==
'':
86 raise ValueError(
'Empty Node name')
92 if tooltip
is not None:
93 node.set_tooltip(tooltip)
113 creates a cluster subgraph item for this factory, adds it to the graph. 114 cluster name can vary from label but must always be same for the same node label. 115 Most layouters require cluster names to start with cluster. 117 if subgraphname
is None or subgraphname ==
'':
118 raise ValueError(
'Empty subgraph name')
119 g = pydot.Cluster(self.
escape_name(subgraphname), rank=rank, rankdir=rankdir, simplify=simplify, color=color)
120 if 'set_style' in g.__dict__:
122 if 'set_shape' in g.__dict__:
124 if LooseVersion(pydot.__version__) > LooseVersion(
'1.0.10'):
125 g.set_compound(compound)
126 g.set_ranksep(ranksep)
127 subgraphlabel = subgraphname
if subgraphlabel
is None else subgraphlabel
130 g.set_label(subgraphlabel)
131 if 'set_color' in g.__dict__:
132 if color
is not None:
134 graph.add_subgraph(g)
137 def add_edge_to_graph(self, graph, nodename1, nodename2, label=None, url=None, simplify=True, style=None, penwidth=1, color=None):
138 if simplify
and LooseVersion(pydot.__version__) < LooseVersion(
'1.0.10'):
142 if label
is not None and label !=
'':
143 edge.set_label(label)
146 if style
is not None:
147 edge.set_style(style)
148 edge.obj_dict[
'attributes'][
'penwidth'] = str(penwidth)
149 if color
is not None:
150 edge.obj_dict[
'attributes'][
'colorR'] = str(color[0])
151 edge.obj_dict[
'attributes'][
'colorG'] = str(color[1])
152 edge.obj_dict[
'attributes'][
'colorB'] = str(color[2])
156 dot = graph.create_dot()
158 return dot.replace(
"\\\n",
"")
def escape_name(self, name)
def add_subgraph_to_graph(self, graph, subgraphname, rank='same', simplify=True, rankdir='TB', ranksep=0.2, compound=True, color=None, shape='box', style='bold', subgraphlabel=None)
def add_edge_to_graph(self, graph, nodename1, nodename2, label=None, url=None, simplify=True, style=None, penwidth=1, color=None)
def escape_label(self, name)
def create_dot(self, graph)
def get_graph(self, graph_type='digraph', rank='same', simplify=True, rankdir='TB', ranksep=0.2, compound=True)
def add_node_to_graph(self, graph, nodename, nodelabel=None, shape='box', color=None, url=None, tooltip=None)