Fine-tune multicolor wire PR
- Remove modified background color -> should be discusses as a separate feature - Render shields as thin tinned wire with black border, safer for b&w priting than single light-gray line - Remove PE as color definition, since it is not, and should be called with GNYE - Clean up minor things
This commit is contained in:
parent
c94d3eed0e
commit
3732597ded
1
setup.py
1
setup.py
@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
|
|||||||
@ -67,7 +67,7 @@ class Harness:
|
|||||||
font = 'arial'
|
font = 'arial'
|
||||||
dot.attr('graph', rankdir='LR',
|
dot.attr('graph', rankdir='LR',
|
||||||
ranksep='2',
|
ranksep='2',
|
||||||
bgcolor=wv_colors.default_bknd_color,
|
bgcolor='white',
|
||||||
nodesep='0.33',
|
nodesep='0.33',
|
||||||
fontname=font)
|
fontname=font)
|
||||||
dot.attr('node', shape='record',
|
dot.attr('node', shape='record',
|
||||||
@ -204,7 +204,6 @@ class Harness:
|
|||||||
html = f'{html}<td>{bla}</td>'
|
html = f'{html}<td>{bla}</td>'
|
||||||
html = f'{html}</tr>'
|
html = f'{html}</tr>'
|
||||||
|
|
||||||
|
|
||||||
bgcolors = ['#000000'] + get_color_hex(connection_color) + ['#000000']
|
bgcolors = ['#000000'] + get_color_hex(connection_color) + ['#000000']
|
||||||
html = f'{html}<tr><td colspan="{len(p)}" border="0" cellspacing="0" cellpadding="0" port="w{i}" height="{(2 * len(bgcolors))}"><table cellspacing="0" cellborder="0" border = "0">'
|
html = f'{html}<tr><td colspan="{len(p)}" border="0" cellspacing="0" cellpadding="0" port="w{i}" height="{(2 * len(bgcolors))}"><table cellspacing="0" cellborder="0" border = "0">'
|
||||||
for j, bgcolor in enumerate(bgcolors[::-1]): # Reverse to match the curved wires when more than 2 colors
|
for j, bgcolor in enumerate(bgcolors[::-1]): # Reverse to match the curved wires when more than 2 colors
|
||||||
@ -225,7 +224,6 @@ class Harness:
|
|||||||
for attrib in wireidentification:
|
for attrib in wireidentification:
|
||||||
html = f'{html}<td>{attrib}</td>'
|
html = f'{html}<td>{attrib}</td>'
|
||||||
html = f'{html}</tr></table></td></tr>'
|
html = f'{html}</tr></table></td></tr>'
|
||||||
# html = html + '</table></td></tr>'
|
|
||||||
|
|
||||||
if cable.shield:
|
if cable.shield:
|
||||||
p = ['<!-- s_in -->', 'Shield', '<!-- s_out -->']
|
p = ['<!-- s_in -->', 'Shield', '<!-- s_out -->']
|
||||||
@ -252,8 +250,8 @@ class Harness:
|
|||||||
if isinstance(connection_color.via_port, int): # check if it's an actual wire and not a shield
|
if isinstance(connection_color.via_port, int): # check if it's an actual wire and not a shield
|
||||||
dot.attr('edge', color=':'.join(['#000000'] + wv_colors.get_color_hex(cable.colors[connection_color.via_port - 1]) + ['#000000']))
|
dot.attr('edge', color=':'.join(['#000000'] + wv_colors.get_color_hex(cable.colors[connection_color.via_port - 1]) + ['#000000']))
|
||||||
else: # it's a shield connection
|
else: # it's a shield connection
|
||||||
dot.attr('edge', color='#000000')
|
# shield is shown as a thin tinned wire
|
||||||
|
dot.attr('edge', color=':'.join(['#000000', wv_colors.get_color_hex('SN')[0], '#000000']))
|
||||||
if connection_color.from_port is not None: # connect to left
|
if connection_color.from_port is not None: # connect to left
|
||||||
from_ferrule = self.connectors[connection_color.from_name].category == 'ferrule'
|
from_ferrule = self.connectors[connection_color.from_name].category == 'ferrule'
|
||||||
port = f':p{connection_color.from_port}r' if not from_ferrule else ''
|
port = f':p{connection_color.from_port}r' if not from_ferrule else ''
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
COLOR_CODES = {
|
COLOR_CODES = {
|
||||||
@ -22,15 +23,8 @@ COLOR_CODES = {
|
|||||||
'T568B': ['WHOG', 'OG', 'WHGN', 'BU', 'WHBU', 'GN', 'WHBN', 'BN'],
|
'T568B': ['WHOG', 'OG', 'WHGN', 'BU', 'WHBU', 'GN', 'WHBN', 'BN'],
|
||||||
}
|
}
|
||||||
|
|
||||||
default_color = '#ffffff'
|
|
||||||
|
|
||||||
# default_bkgnd_color = '#ffffff' # white
|
|
||||||
default_bknd_color = '#fffbf8' # off-white beige-ish
|
|
||||||
|
|
||||||
# Convention: Color names should be 2 letters long, to allow for multicolored wires
|
# Convention: Color names should be 2 letters long, to allow for multicolored wires
|
||||||
|
|
||||||
shield_color = '#aaaaaa' # Tinned wire
|
|
||||||
|
|
||||||
_color_hex = {
|
_color_hex = {
|
||||||
'BK': '#000000',
|
'BK': '#000000',
|
||||||
'WH': '#ffffff',
|
'WH': '#ffffff',
|
||||||
@ -45,16 +39,10 @@ _color_hex = {
|
|||||||
'VT': '#8000ff',
|
'VT': '#8000ff',
|
||||||
'BN': '#895956',
|
'BN': '#895956',
|
||||||
'SL': '#708090',
|
'SL': '#708090',
|
||||||
# Faux-copper look, for bare CU wire
|
'CU': '#d6775e', # Faux-copper look, for bare CU wire
|
||||||
'CU': '#d6775e',
|
'SN': '#aaaaaa', # Silvery look for tinned bare wire
|
||||||
# Silvery look for tinned bare wire
|
'AG': '#84878c', # Darker silver for silvered wire
|
||||||
'SN': '#aaaaaa',
|
'AU': '#ffcf80', # Golden color for gold
|
||||||
# Darker silver for silvered wire
|
|
||||||
'AG': '#84878c',
|
|
||||||
# Golden color for gold
|
|
||||||
'AU': '#ffcf80',
|
|
||||||
# Yellow-green PE wire (matching actual wire colors, should prevent confusion with a yellow-green dual color wire
|
|
||||||
'PE': '#54aa85:#f7f854:#54aa85',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_color_full = {
|
_color_full = {
|
||||||
@ -75,10 +63,8 @@ _color_full = {
|
|||||||
'SN': 'tinned copper',
|
'SN': 'tinned copper',
|
||||||
'AG': 'silver wire',
|
'AG': 'silver wire',
|
||||||
'AU': 'gold wire',
|
'AU': 'gold wire',
|
||||||
'PE': 'earth'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# TODO Help wanted: can someone check the german translation?
|
|
||||||
_color_ger = {
|
_color_ger = {
|
||||||
'BK': 'sw',
|
'BK': 'sw',
|
||||||
'WH': 'ws',
|
'WH': 'ws',
|
||||||
@ -92,28 +78,20 @@ _color_ger = {
|
|||||||
'BU': 'bl',
|
'BU': 'bl',
|
||||||
'VT': 'vi',
|
'VT': 'vi',
|
||||||
'BN': 'br',
|
'BN': 'br',
|
||||||
# To the best of my ability, likely incorrect:
|
'SL': 'si', # Slate/Schiefer?
|
||||||
|
'CU': 'ku', # Copper/Kupfer
|
||||||
# Slate --> Schieferfarbe --> SI ??
|
'SN': 'vz', # Tinned/verzinkt
|
||||||
'SL': 'si',
|
'AG': 'ag', # Silver
|
||||||
# Copper
|
'AU': 'au', # Gold
|
||||||
'CU': 'cu',
|
|
||||||
# Tinned
|
|
||||||
'SN': 'sn',
|
|
||||||
# Silver
|
|
||||||
'AG': 'ag',
|
|
||||||
# Gold
|
|
||||||
'AU': 'au',
|
|
||||||
# Earth
|
|
||||||
'PE': 'pe'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
color_default = '#ffffff'
|
||||||
|
|
||||||
|
|
||||||
def get_color_hex(input, pad=True):
|
def get_color_hex(input, pad=True):
|
||||||
if input is None or input == '':
|
if input is None or input == '':
|
||||||
# print('Unspecified color requested', file=sys.stderr)
|
return [color_default]
|
||||||
return [default_color]
|
|
||||||
if len(input) == 4: # give wires with EXACTLY 2 colors that striped/banded look
|
if len(input) == 4: # give wires with EXACTLY 2 colors that striped/banded look
|
||||||
input = input + input[:2]
|
input = input + input[:2]
|
||||||
# hacky style fix: give single color wires a triple-up so that wires are the same size
|
# hacky style fix: give single color wires a triple-up so that wires are the same size
|
||||||
@ -122,16 +100,14 @@ def get_color_hex(input, pad=True):
|
|||||||
try:
|
try:
|
||||||
output = [_color_hex[input[i:i + 2]] for i in range(0, len(input), 2)]
|
output = [_color_hex[input[i:i + 2]] for i in range(0, len(input), 2)]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
print("Unknown Color Specified", file=sys.stderr)
|
print("Unknown color specified")
|
||||||
output = [default_color]
|
output = [color_default]
|
||||||
# raise Exception('Unknown Color Name')
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
def translate_color(input, color_mode):
|
def translate_color(input, color_mode):
|
||||||
if input == '' or input is None:
|
if input == '' or input is None:
|
||||||
# print('Unspecified color requested', file=sys.stderr)
|
return color_default
|
||||||
return default_color
|
|
||||||
upper = color_mode.isupper()
|
upper = color_mode.isupper()
|
||||||
if not (color_mode.isupper() or color_mode.islower()):
|
if not (color_mode.isupper() or color_mode.islower()):
|
||||||
raise Exception('Unknown color mode capitalization')
|
raise Exception('Unknown color mode capitalization')
|
||||||
@ -151,4 +127,3 @@ def translate_color(input, color_mode):
|
|||||||
return output.upper()
|
return output.upper()
|
||||||
else:
|
else:
|
||||||
return output.lower()
|
return output.lower()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user