wireviz / WireViz

Easily document cables and wiring harnesses.
GNU General Public License v3.0
4.22k stars 219 forks source link

[feature] Single wire cable drawn without table #376

Open martinrieder opened 1 month ago

martinrieder commented 1 month ago

The following example brings up an interesting (and quite common?) use case for cables containing only a single wire. Similar to the way that connectors can be defined with style: simple, I suggest to implement cables with this attribute. They would be displayed without a box and should optionally show the wire name/label.

Credits to @EloiVilalta in https://github.com/wireviz/WireViz/issues/293#issuecomment-2150401138

connectors:
  C1:
    style: simple
    type: Connector
  C2:
    style: simple
    type: Connector      
cables:  
  W1:
    wirecount: 1
    show_name: false
    show_wirecount: false
    colors: [RD]

connections:
  -
    - C1: [1]
    - W1: [1]
    - C2: [1]

The issue with the current implementation is that it requires a lot of space in the graph due to the HTML table. This is not needed for only displaying the label/name as a text.

image

This would allow for the same principle as virtual splices to be applied to wires instead of connectors. It enables simplified layouts and possibly also grouping of wires into clusters. The latter enforces some structure, but leaves the order of the wires up to the Graphviz engine.

@kvid in https://github.com/wireviz/WireViz/issues/270#issuecomment-2123078659

When I use the term virtual splice, I mean a connection between two matching wires in WireViz that in real life represents a continuation of the same wire (no physical cut) and visualized in the diagram as such.

This suggestion also complements https://github.com/wireviz/WireViz/issues/268#issuecomment-2110978294, which refers to an example provided by @Halfwalker, who called this feature compact_view.

image

Similar arrangements should be produced for wires being grouped into a cluster. Splicing a wire in a similar fashion should also be possible.

martinrieder commented 1 month ago

@kvid I noticed that you discussed some similar idea with @formatc1702 a few years back in #31. Do you have any updates on the topic?

Another thing that might help, is to combine all invisible nodes on the same rank inside a sheathing into a common invisible node to avoid that Graphviz swap their order.

Taking the picture by @SnowMB as an example from this:

You can use rank=same to clean up node placement.

graph(2)

kvid commented 1 month ago

See also https://github.com/wireviz/WireViz/issues/225#issuecomment-951164193 where @formatc1702 strongly considers consolidating the optional style attribute into category that already exists for both connectors and cables.

Maybe this issue is an extra argument for such a consolidation?

martinrieder commented 1 month ago

I like the idea of consolidating. If connector type: would not already be in use, I would suggest to use this instead of category: for both cables and connectors.

kvid commented 1 month ago

@martinrieder wrote:

I like the idea of consolidating. If connector type: would not already be in use, I would suggest to use this instead of category: for both cables and connectors.

When consolidating, we might end up with allowing more than one value for the same connector/cable, and if so, then flags or class might be alternative names? I suggest we try collecting different values that might be useful in a consolidated attribute, and see if they are mutually exclusive or not.

martinrieder commented 1 month ago

I went through the list of Graphviz attributes and found that class is used in the context of stylesheets, so it might be reserved for also implementing these in WireViz.

I cannot think of an example for flags, which implies multiple settings being combined... What about model?

kvid commented 1 month ago

Maybe just stick with category for now? It's perfectly legal to be member of more than one category if needed.

martinrieder commented 1 month ago

Okay, what is the default category called then? Would it be defined as sheathed, generic or simply leave it undefined?

I suggest the following categories

  1. Single conductor
  2. Wire pairs
    • twisted
    • coaxial
  3. Multi-core
    • sheathed/generic
    • bundle

Twisted pairs could have either sheathing and/or shielding. Coaxial cable would normally have both. Even single wires are sometimes shielded, though this comes close to the definition of a coaxial cable then.

Please also see https://github.com/wireviz/WireViz/issues/353#issuecomment-2121173915 where I suggested a category for twisted pairs.
There is also a quite detailed discussion about different cable properties in #56...

My intention with this issue is only to add some way to display simple cables with a single conductor/wire. You may therefore consider my question above only hypothetical. ;-)

martinrieder commented 1 month ago

For this kind of cable, wire count and number are implicitly hidden. In the same way, I would omit the color label by default. Having it explicitly displayed would require adding show_color to the syntax. If there is no wirelabel defined, then no text would be displayed at all.

In https://github.com/wireviz/WireViz/issues/155#issuecomment-2155874534, I suggested adding connectorlabel, but I realize that maybe cablelabel might be needed as well. In case of a single wire, this would be equal to the wirelabel, of course.

EDIT: also compare https://github.com/wireviz/WireViz/issues/286#issuecomment-2116112620