diff --git a/docs/syntax.md b/docs/syntax.md index 92d4168..d5db109 100644 --- a/docs/syntax.md +++ b/docs/syntax.md @@ -88,13 +88,20 @@ tweak: # optional tweaking of .gv output # on the connector that are to be shorted with a cable loop # more information about the loop can be added by additional # components definition (see below) + # OR + - # a list of pins to be looped # Shorts shorts: # a list(dict) of shorts - - : # every list item is itself a list of pins + : # every list item is itself a list of pins # on the connector that are to be shorted represented inside # the connector table # more information about the loop can be added by additional # components definition (see below) + # OR + - # a list of pins to be shorted + # it is not posable to combine those two + shorts_hide_lable: # A Boolean to control if the lable of the shorts should be shown, if a list is used this is automatically turned true. + ``` ## Cable attributes diff --git a/examples/ex15.gv b/examples/ex15.gv index f0b542e..bbe9924 100644 --- a/examples/ex15.gv +++ b/examples/ex15.gv @@ -106,9 +106,9 @@ graph { > shape=box style=filled] edge [color="#000000"] - X1:p1j:c -- X1:p5j:c [addPTS=.18 color="#FF66CC" colorPTS="#FF66CC" headclip=false straight=straight tailclip=false] - X1:p5j:c -- X1:p7j:c [addPTS=.18 color="#FF66CC" colorPTS="#FF66CC" headclip=false straight=straight tailclip=false] - X1:p2j:c -- X1:p6j:c [addPTS=.18 color="#FF0000" colorPTS="#FF0000" headclip=false straight=straight tailclip=false] + X1:p1j:c -- X1:p5j:c [addPTS=.18 color="#FFFFFF:#FF66CC:#FFFFFF" colorPTS="#FF66CC:#FFFFFF" headclip=false straight=straight tailclip=false] + X1:p5j:c -- X1:p7j:c [addPTS=.18 color="#FFFFFF:#FF66CC:#FFFFFF" colorPTS="#FF66CC:#FFFFFF" headclip=false straight=straight tailclip=false] + X1:p2j:c -- X1:p6j:c [addPTS=.18 color="#FFFFFF:#FF0000:#FFFFFF" colorPTS="#FF0000:#FFFFFF" headclip=false straight=straight tailclip=false] X2 [label=< @@ -181,9 +181,9 @@ graph {
> shape=box style=filled] edge [color="#000000"] - X2:p1j:c -- X2:p5j:c [addPTS=.18 color="#000000" colorPTS="#000000" headclip=false straight=straight tailclip=false] - X2:p5j:c -- X2:p7j:c [addPTS=.18 color="#000000" colorPTS="#000000" headclip=false straight=straight tailclip=false] - X2:p2j:c -- X2:p6j:c [addPTS=.18 color="#000000" colorPTS="#000000" headclip=false straight=straight tailclip=false] + X2:p1j:c -- X2:p5j:c [addPTS=.18 color="#FFFFFF:#000000:#FFFFFF" colorPTS="#000000:#FFFFFF" headclip=false straight=straight tailclip=false] + X2:p5j:c -- X2:p7j:c [addPTS=.18 color="#FFFFFF:#000000:#FFFFFF" colorPTS="#000000:#FFFFFF" headclip=false straight=straight tailclip=false] + X2:p2j:c -- X2:p6j:c [addPTS=.18 color="#FFFFFF:#000000:#FFFFFF" colorPTS="#000000:#FFFFFF" headclip=false straight=straight tailclip=false] W1 [label=< diff --git a/examples/ex15.html b/examples/ex15.html index acd1525..1e99532 100644 --- a/examples/ex15.html +++ b/examples/ex15.html @@ -111,17 +111,23 @@ X1:c--X1:c + + X1:c--X1:c + + X1:c--X1:c + + @@ -373,17 +379,23 @@ X2:c--X2:c + + X2:c--X2:c + + X2:c--X2:c + + diff --git a/examples/ex15.png b/examples/ex15.png index 89562b1..621ab24 100644 Binary files a/examples/ex15.png and b/examples/ex15.png differ diff --git a/examples/ex15.svg b/examples/ex15.svg index 800b9bf..8c63e61 100644 --- a/examples/ex15.svg +++ b/examples/ex15.svg @@ -82,17 +82,23 @@ X1:c--X1:c + + X1:c--X1:c + + X1:c--X1:c + + @@ -344,17 +350,23 @@ X2:c--X2:c + + X2:c--X2:c + + X2:c--X2:c + + diff --git a/src/wireviz/wv_dataclasses.py b/src/wireviz/wv_dataclasses.py index f71b627..ce9c5ae 100644 --- a/src/wireviz/wv_dataclasses.py +++ b/src/wireviz/wv_dataclasses.py @@ -312,8 +312,9 @@ class Connector(TopLevelGraphicalComponent): # connector-specific properties style: Optional[str] = None # TODO: Move shorts and loops to PinClass - loops: Dict[str, List[int]] = field(default_factory=dict) - shorts: Dict[str, List[int]] = field(default_factory=dict) + loops: Union[Dict[str, List[int]], List[List[int]]] = field(default_factory=dict) + shorts: Union[Dict[str, List[int]], List[List[int]]] = field(default_factory=dict) + shorts_hide_lable: bool = False # pin information in particular pincount: Optional[int] = None pins: List[Pin] = field(default_factory=list) # legacy @@ -417,6 +418,23 @@ class Connector(TopLevelGraphicalComponent): if self.show_pincount is None: # hide pincount for simple (1 pin) connectors by default self.show_pincount = self.style != "simple" + + # Convert short List to Short Dict + if type(self.shorts) == list: + self.shorts_hide_lable = True + shDict = dict() + for shIndex in range(0, len(self.shorts)): + key = "AutoSH" + str(shIndex) + shDict[key] = self.shorts[shIndex] + self.shorts = shDict + + # Convert loop List to loop Dict + if type(self.loops) == list: + loDict = dict() + for loIndex in range(0, len(self.loops)): + key = "AutoLO" + str(loIndex) + loDict[key] = self.loops[loIndex] + self.loops = loDict # TODO: allow using pin labels in addition to pin numbers, # just like when defining regular connections diff --git a/src/wireviz/wv_graphviz.py b/src/wireviz/wv_graphviz.py index 918b34a..1e91250 100644 --- a/src/wireviz/wv_graphviz.py +++ b/src/wireviz/wv_graphviz.py @@ -277,7 +277,7 @@ def gv_shorts_info_row(component) -> Tr: def gv_pin_table(component) -> Table: pin_rows = [] - if len(component.shorts) > 0: + if len(component.shorts) > 0 and not component.shorts_hide_lable: pin_rows.append(gv_shorts_info_row(component)) for pin in component.pin_objects.values(): @@ -343,9 +343,9 @@ def gv_connector_shorts(connector: Connector) -> List: for short, shPins in connector.shorts.items(): comp = getAddCompFromRef(short, connector) - shColor = "#000000" + shColor = "#FFFFFF:#000000:#FFFFFF" if comp != None and comp.color != None: - shColor = comp.color.html + shColor = f"#FFFFFF:{comp.color.html}:#FFFFFF" for i in range(1, len(shPins)): head = f"{connector.designator}:p{shPins[i - 1]}j:c" diff --git a/src/wireviz/wv_harness.py b/src/wireviz/wv_harness.py index 3c9cc82..1e29706 100644 --- a/src/wireviz/wv_harness.py +++ b/src/wireviz/wv_harness.py @@ -339,7 +339,7 @@ class Harness: color=color, straight="straight", addPTS=".18", # Size of the point at the end of the straight line/edge, it also enables the drawing of it - colorPTS=color, + colorPTS=color.replace("#FFFFFF:", ""), headclip="false", tailclip="false") # determine if there are double- or triple-colored wires in the harness;