feat: uniform styling elements between simplified and full graph

This commit is contained in:
Ferrari Martino Giordano
2024-03-29 14:08:43 +01:00
parent f805788152
commit 47f7147e12
+35 -23
View File
@@ -159,13 +159,14 @@ def __doc_iogam__(id, obj, edges, thread):
)
)
orows.append(orow)
fill = "#fff"
fill = "#eee"
fcolor = "#000"
total = max(len(orows), len(irows))
if bold or total > 1:
fill = "#333"
fill = "#eee"
bold = True
else:
fill = "#666"
fill = "#eee"
inode = f"{id}_{counter} [shape=plaintext,"
inode += f'tooltip=" IOGAM::{id} ", label=<'
@@ -180,7 +181,7 @@ def __doc_iogam__(id, obj, edges, thread):
if len(orows) > len(irows):
inode += f' rowspan="{len(orows)}"'
inode += ">"
inode += '<font color="#fff">'
inode += f'<font color="{fcolor}">'
inode += irows[i]
inode += "</font></td>"
if i < len(orows):
@@ -188,7 +189,7 @@ def __doc_iogam__(id, obj, edges, thread):
if len(orows) < len(irows):
inode += f' rowspan="{len(irows)}"'
inode += ">"
inode += '<font color="#fff">'
inode += f'<font color="{fcolor}">'
inode += orows[i]
inode += "</font></td>"
inode += "</tr>"
@@ -252,7 +253,7 @@ def __doc_message_gam__(id, obj, edges, thread):
inputs += " | "
inputs += f"<in_{doc.format_name(l)}> {l}"
if inputs:
node += inputs + '"];'
node += inputs + '", style=filled, fillcolor=lightyellow];'
else:
node = ""
@@ -264,6 +265,7 @@ def __doc_message_gam__(id, obj, edges, thread):
def __doc_events__(id, obj, edges, thread):
nodes = ""
bgcolor = "lightyellow"
for event_id, event in obj["+Events"].items():
if event_id[0] == "+":
event_id = event_id[1:]
@@ -272,22 +274,20 @@ def __doc_events__(id, obj, edges, thread):
for msg_id in message_ids:
nodes += f" {id}_{event_id}_{msg_id} [shape=plaintext, label=<"
nodes += '<table cellspacing="0" cellborder="1" border="0" cellpadding="4"><tr>'
nodes += (
"<td bgcolor='#ccc' align='left'><b>When</b></td><td balign='left'>"
)
nodes += f"<td bgcolor='{bgcolor}' align='left'><b>When</b></td><td balign='left'>"
for i, (sig, val) in enumerate(trigger.items()):
if i > 0:
nodes += "<br/>"
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}"]
fn = msg["Function"]
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":
params = msg["+Parameters"]
nodes += f"{params['SignalName']} = {params['SignalValue']}"
nodes += f"<i>set</i> {params['SignalName']} <i>to</i> {params['SignalValue']}"
else:
nodes += f"{fn} "
nodes += "</td></tr></table>>];\n"
@@ -388,10 +388,17 @@ def __process_gamds__(name, cls, signals, edges):
node += " | "
sig_type = signals[sig_name]
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:
node = f'{name} [label="{name}&#92;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
@@ -430,9 +437,7 @@ def __process_ds__(name, obj, edges):
if sig not in order:
lost.append(sig)
node = f"{name} [shape=plaintext; label=<"
node += (
'<table border="0" cellpadding="4" cellborder="1" cellspacing="0">\n'
)
node += '<table border="0" cellpadding="4" cellborder="1" cellspacing="0" bgcolor="lightblue">\n'
node += f"<tr><td><b>{name}</b><br/>{cls}</td></tr>\n"
for i, sig_name in enumerate(order):
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]
node += f"{sig_name} ({doc.type_to_string(sig_type)})"
node += "</td></tr>\n"
node += "</table>>, color=blue];\n"
node += '</table>>, color="#0af"];\n'
if not multi_thread and node:
node = f"subgraph cluster_{thread}" + "{\n" + node + "};\n"
return node, edges
@@ -532,18 +537,18 @@ def __state_full_graph__(label, state, app):
def __simple_gam__(label, obj):
cls = obj["Class"]
id = f"fn{doc.format_name(label)}"
style = ""
style = "style=rounded"
if cls == "IOGAM":
style = ", style=filled, fillcolor=lightgray"
style = 'style="rounded,filled", fillcolor="#eee"'
elif cls == "MessageGAM":
style = ", style=filled, fillcolor=yellow"
style = 'style="rounded,filled", fillcolor=lightyellow'
if "InputSignals" in obj:
for _, signal in obj["InputSignals"].items():
ds = f'ds{doc.format_name(signal["DataSource"])}'
if "OutputSignals" in obj:
for _, signal in obj["OutputSignals"].items():
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):
@@ -564,7 +569,14 @@ def __simple_ds__(label, obj, edges):
thread = edge[-1]
elif thread != edge[-1]:
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:
node = f"subgraph cluster_{thread}" + "{\n " + node + "}"
return node