wv_graphviz: better connector template
This commit is contained in:
parent
f7ce022372
commit
62e0d798ac
@ -50,15 +50,18 @@ def gv_node_connector(connector: Connector) -> Table:
|
|||||||
pins = []
|
pins = []
|
||||||
use_left = bool(connector.ports_left)
|
use_left = bool(connector.ports_left)
|
||||||
use_right = bool(connector.ports_right)
|
use_right = bool(connector.ports_right)
|
||||||
|
has_pincolors = any([_pin.color for _pin in connector.pin_objects.values()])
|
||||||
for pin in connector.pin_objects.values():
|
for pin in connector.pin_objects.values():
|
||||||
if not connector.should_show_pin(pin.id):
|
if not connector.should_show_pin(pin.id):
|
||||||
continue
|
continue
|
||||||
|
color = str(pin.color) if pin.color else "" if has_pincolors else None
|
||||||
pins.append({
|
pins.append({
|
||||||
'id': pin.id,
|
'id': pin.id,
|
||||||
'index': pin.index,
|
'index': pin.index,
|
||||||
'label': pin.label,
|
'label': pin.label,
|
||||||
#'color': pin.color,
|
'color': color,
|
||||||
#TODO: support color minitable?
|
'color_len': len(pin.color),
|
||||||
|
'has_pincolors': has_pincolors,
|
||||||
})
|
})
|
||||||
columns = 2 + (1 if use_left else 0) + (1 if use_right else 0)
|
columns = 2 + (1 if use_left else 0) + (1 if use_right else 0)
|
||||||
params = {
|
params = {
|
||||||
@ -71,9 +74,19 @@ def gv_node_connector(connector: Connector) -> Table:
|
|||||||
'type': html_line_breaks(connector.type),
|
'type': html_line_breaks(connector.type),
|
||||||
'subtype': html_line_breaks(connector.subtype),
|
'subtype': html_line_breaks(connector.subtype),
|
||||||
'pincount': connector.pincount,
|
'pincount': connector.pincount,
|
||||||
'show_pincount': connector.show_pincount
|
'show_pincount': connector.show_pincount,
|
||||||
|
'color': connector.color,
|
||||||
|
'color_len': len(connector.color),
|
||||||
}
|
}
|
||||||
return get_template("connector.html").render(params)
|
# TODO: extend connector style support
|
||||||
|
is_simple_connector = connector.style == 'simple'
|
||||||
|
template_name = "connector.html"
|
||||||
|
if is_simple_connector:
|
||||||
|
template_name = "simple-connector.html"
|
||||||
|
|
||||||
|
rendered = get_template(template_name).render(params)
|
||||||
|
cleaned_render = '\n'.join([l.rstrip() for l in rendered.split('\n') if l.strip()])
|
||||||
|
return cleaned_render
|
||||||
## If no wires connected (except maybe loop wires)?
|
## If no wires connected (except maybe loop wires)?
|
||||||
#if isinstance(connector, Connector):
|
#if isinstance(connector, Connector):
|
||||||
# if not (connector.ports_left or connector.ports_right):
|
# if not (connector.ports_left or connector.ports_right):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user