feat: uniform styling elements between simplified and full graph
This commit is contained in:
+35
-23
@@ -159,13 +159,14 @@ def __doc_iogam__(id, obj, edges, thread):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
orows.append(orow)
|
orows.append(orow)
|
||||||
fill = "#fff"
|
fill = "#eee"
|
||||||
|
fcolor = "#000"
|
||||||
total = max(len(orows), len(irows))
|
total = max(len(orows), len(irows))
|
||||||
if bold or total > 1:
|
if bold or total > 1:
|
||||||
fill = "#333"
|
fill = "#eee"
|
||||||
bold = True
|
bold = True
|
||||||
else:
|
else:
|
||||||
fill = "#666"
|
fill = "#eee"
|
||||||
|
|
||||||
inode = f"{id}_{counter} [shape=plaintext,"
|
inode = f"{id}_{counter} [shape=plaintext,"
|
||||||
inode += f'tooltip=" IOGAM::{id} ", label=<'
|
inode += f'tooltip=" IOGAM::{id} ", label=<'
|
||||||
@@ -180,7 +181,7 @@ def __doc_iogam__(id, obj, edges, thread):
|
|||||||
if len(orows) > len(irows):
|
if len(orows) > len(irows):
|
||||||
inode += f' rowspan="{len(orows)}"'
|
inode += f' rowspan="{len(orows)}"'
|
||||||
inode += ">"
|
inode += ">"
|
||||||
inode += '<font color="#fff">'
|
inode += f'<font color="{fcolor}">'
|
||||||
inode += irows[i]
|
inode += irows[i]
|
||||||
inode += "</font></td>"
|
inode += "</font></td>"
|
||||||
if i < len(orows):
|
if i < len(orows):
|
||||||
@@ -188,7 +189,7 @@ def __doc_iogam__(id, obj, edges, thread):
|
|||||||
if len(orows) < len(irows):
|
if len(orows) < len(irows):
|
||||||
inode += f' rowspan="{len(irows)}"'
|
inode += f' rowspan="{len(irows)}"'
|
||||||
inode += ">"
|
inode += ">"
|
||||||
inode += '<font color="#fff">'
|
inode += f'<font color="{fcolor}">'
|
||||||
inode += orows[i]
|
inode += orows[i]
|
||||||
inode += "</font></td>"
|
inode += "</font></td>"
|
||||||
inode += "</tr>"
|
inode += "</tr>"
|
||||||
@@ -252,7 +253,7 @@ def __doc_message_gam__(id, obj, edges, thread):
|
|||||||
inputs += " | "
|
inputs += " | "
|
||||||
inputs += f"<in_{doc.format_name(l)}> {l}"
|
inputs += f"<in_{doc.format_name(l)}> {l}"
|
||||||
if inputs:
|
if inputs:
|
||||||
node += inputs + '"];'
|
node += inputs + '", style=filled, fillcolor=lightyellow];'
|
||||||
else:
|
else:
|
||||||
node = ""
|
node = ""
|
||||||
|
|
||||||
@@ -264,6 +265,7 @@ def __doc_message_gam__(id, obj, edges, thread):
|
|||||||
|
|
||||||
def __doc_events__(id, obj, edges, thread):
|
def __doc_events__(id, obj, edges, thread):
|
||||||
nodes = ""
|
nodes = ""
|
||||||
|
bgcolor = "lightyellow"
|
||||||
for event_id, event in obj["+Events"].items():
|
for event_id, event in obj["+Events"].items():
|
||||||
if event_id[0] == "+":
|
if event_id[0] == "+":
|
||||||
event_id = event_id[1:]
|
event_id = event_id[1:]
|
||||||
@@ -272,22 +274,20 @@ def __doc_events__(id, obj, edges, thread):
|
|||||||
for msg_id in message_ids:
|
for msg_id in message_ids:
|
||||||
nodes += f" {id}_{event_id}_{msg_id} [shape=plaintext, label=<"
|
nodes += f" {id}_{event_id}_{msg_id} [shape=plaintext, label=<"
|
||||||
nodes += '<table cellspacing="0" cellborder="1" border="0" cellpadding="4"><tr>'
|
nodes += '<table cellspacing="0" cellborder="1" border="0" cellpadding="4"><tr>'
|
||||||
nodes += (
|
nodes += f"<td bgcolor='{bgcolor}' align='left'><b>When</b></td><td balign='left'>"
|
||||||
"<td bgcolor='#ccc' align='left'><b>When</b></td><td balign='left'>"
|
|
||||||
)
|
|
||||||
for i, (sig, val) in enumerate(trigger.items()):
|
for i, (sig, val) in enumerate(trigger.items()):
|
||||||
if i > 0:
|
if i > 0:
|
||||||
nodes += "<br/>"
|
nodes += "<br/>"
|
||||||
nodes += f"{sig} == {val}"
|
nodes += f"{sig} == {val}"
|
||||||
|
|
||||||
nodes += "</td></tr><tr><td bgcolor='#ccc' align='left'><b>Destination</b></td>"
|
nodes += f"</td></tr><tr><td bgcolor='{bgcolor}' align='left'><b>Destination</b></td>"
|
||||||
msg = event[f"+{msg_id}"]
|
msg = event[f"+{msg_id}"]
|
||||||
fn = msg["Function"]
|
fn = msg["Function"]
|
||||||
nodes += f"<td align='left'>{msg['Destination']}</td></tr>"
|
nodes += f"<td align='left'>{msg['Destination']}</td></tr>"
|
||||||
nodes += "<tr><td bgcolor='#ccc' align='left'><b>Function</b></td><td align='left'>"
|
nodes += f"<tr><td bgcolor='{bgcolor}' align='left'><b>Message</b></td><td align='left'>"
|
||||||
if fn == "SetOutput":
|
if fn == "SetOutput":
|
||||||
params = msg["+Parameters"]
|
params = msg["+Parameters"]
|
||||||
nodes += f"{params['SignalName']} = {params['SignalValue']}"
|
nodes += f"<i>set</i> {params['SignalName']} <i>to</i> {params['SignalValue']}"
|
||||||
else:
|
else:
|
||||||
nodes += f"{fn} "
|
nodes += f"{fn} "
|
||||||
nodes += "</td></tr></table>>];\n"
|
nodes += "</td></tr></table>>];\n"
|
||||||
@@ -388,10 +388,17 @@ def __process_gamds__(name, cls, signals, edges):
|
|||||||
node += " | "
|
node += " | "
|
||||||
sig_type = signals[sig_name]
|
sig_type = signals[sig_name]
|
||||||
node += (
|
node += (
|
||||||
f"<{doc.format_name(sig_name)}> {sig_name} ({doc.type_to_string(sig_type)})"
|
f'<tr><td port="{doc.format_name(sig_name)}">'
|
||||||
|
f"{sig_name} ({doc.type_to_string(sig_type)})"
|
||||||
|
"</td></tr>"
|
||||||
)
|
)
|
||||||
if node:
|
if node:
|
||||||
node = f'{name} [label="{name}\n{cls} | {node}", color=blue, style=filled, fillcolor=lightyellow];\n'
|
label = f"""<table border="0" cellpadding="4" cellborder="1" cellspacing="0" bgcolor="#eee">
|
||||||
|
<tr><td><b>{name}</b><br/>{cls}</td></tr>
|
||||||
|
{node}
|
||||||
|
</table>
|
||||||
|
"""
|
||||||
|
node = f'{name} [shape=plaintext, label=<{label}>, color="#0af"];\n'
|
||||||
return node, edges
|
return node, edges
|
||||||
|
|
||||||
|
|
||||||
@@ -430,9 +437,7 @@ def __process_ds__(name, obj, edges):
|
|||||||
if sig not in order:
|
if sig not in order:
|
||||||
lost.append(sig)
|
lost.append(sig)
|
||||||
node = f"{name} [shape=plaintext; label=<"
|
node = f"{name} [shape=plaintext; label=<"
|
||||||
node += (
|
node += '<table border="0" cellpadding="4" cellborder="1" cellspacing="0" bgcolor="lightblue">\n'
|
||||||
'<table border="0" cellpadding="4" cellborder="1" cellspacing="0">\n'
|
|
||||||
)
|
|
||||||
node += f"<tr><td><b>{name}</b><br/>{cls}</td></tr>\n"
|
node += f"<tr><td><b>{name}</b><br/>{cls}</td></tr>\n"
|
||||||
for i, sig_name in enumerate(order):
|
for i, sig_name in enumerate(order):
|
||||||
node += f'<tr><td port="{doc.format_name(sig_name)}">'
|
node += f'<tr><td port="{doc.format_name(sig_name)}">'
|
||||||
@@ -445,7 +450,7 @@ def __process_ds__(name, obj, edges):
|
|||||||
sig_type = sigs[sig_name]
|
sig_type = sigs[sig_name]
|
||||||
node += f"{sig_name} ({doc.type_to_string(sig_type)})"
|
node += f"{sig_name} ({doc.type_to_string(sig_type)})"
|
||||||
node += "</td></tr>\n"
|
node += "</td></tr>\n"
|
||||||
node += "</table>>, color=blue];\n"
|
node += '</table>>, color="#0af"];\n'
|
||||||
if not multi_thread and node:
|
if not multi_thread and node:
|
||||||
node = f"subgraph cluster_{thread}" + "{\n" + node + "};\n"
|
node = f"subgraph cluster_{thread}" + "{\n" + node + "};\n"
|
||||||
return node, edges
|
return node, edges
|
||||||
@@ -532,18 +537,18 @@ def __state_full_graph__(label, state, app):
|
|||||||
def __simple_gam__(label, obj):
|
def __simple_gam__(label, obj):
|
||||||
cls = obj["Class"]
|
cls = obj["Class"]
|
||||||
id = f"fn{doc.format_name(label)}"
|
id = f"fn{doc.format_name(label)}"
|
||||||
style = ""
|
style = "style=rounded"
|
||||||
if cls == "IOGAM":
|
if cls == "IOGAM":
|
||||||
style = ", style=filled, fillcolor=lightgray"
|
style = 'style="rounded,filled", fillcolor="#eee"'
|
||||||
elif cls == "MessageGAM":
|
elif cls == "MessageGAM":
|
||||||
style = ", style=filled, fillcolor=yellow"
|
style = 'style="rounded,filled", fillcolor=lightyellow'
|
||||||
if "InputSignals" in obj:
|
if "InputSignals" in obj:
|
||||||
for _, signal in obj["InputSignals"].items():
|
for _, signal in obj["InputSignals"].items():
|
||||||
ds = f'ds{doc.format_name(signal["DataSource"])}'
|
ds = f'ds{doc.format_name(signal["DataSource"])}'
|
||||||
if "OutputSignals" in obj:
|
if "OutputSignals" in obj:
|
||||||
for _, signal in obj["OutputSignals"].items():
|
for _, signal in obj["OutputSignals"].items():
|
||||||
ds = f'ds{doc.format_name(signal["DataSource"])}'
|
ds = f'ds{doc.format_name(signal["DataSource"])}'
|
||||||
return f"{id}[label=<<B>{label}</B><BR/>{cls}> {style}]\n"
|
return f"{id}[label=<<B>{label}</B><BR/>{cls}>, {style}]\n"
|
||||||
|
|
||||||
|
|
||||||
def __simple_ds__(label, obj, edges):
|
def __simple_ds__(label, obj, edges):
|
||||||
@@ -564,7 +569,14 @@ def __simple_ds__(label, obj, edges):
|
|||||||
thread = edge[-1]
|
thread = edge[-1]
|
||||||
elif thread != edge[-1]:
|
elif thread != edge[-1]:
|
||||||
multi_thread = True
|
multi_thread = True
|
||||||
node = f"{id}[label=<<B>{label}</B><BR/>{cls}>, fillcolor=lightblue]\n"
|
|
||||||
|
fillcolor = "lightblue"
|
||||||
|
bordercolor = "#0af"
|
||||||
|
style = "penwidth=2"
|
||||||
|
if cls == "GAMDataSource":
|
||||||
|
fillcolor = "#eee"
|
||||||
|
node = f"{id}[label=<<B>{label}</B><BR/>{cls}>, "
|
||||||
|
node += f'{style}, fillcolor="{fillcolor}", color="{bordercolor}"]\n'
|
||||||
if thread and not multi_thread:
|
if thread and not multi_thread:
|
||||||
node = f"subgraph cluster_{thread}" + "{\n " + node + "}"
|
node = f"subgraph cluster_{thread}" + "{\n " + node + "}"
|
||||||
return node
|
return node
|
||||||
|
|||||||
Reference in New Issue
Block a user