wireviz / WireViz

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

[feature] Adding banded multicolor wires #109

Open SnowMB opened 4 years ago

SnowMB commented 4 years ago

Splitting out from #96 as requested:

I'm looking for a way to produce a banded output for two color wires. #96 introduced two colors by showing the second color as stripe along the wire.

I think with a banded representation it is easier to distinguish the colors and looks more visually appealing.

Here is an example (taken from #96):

image

I've just play around with the .gv files and the dot language.

Todo:

formatc1702 commented 4 years ago

Cables will probably require a new attribute to specify what style the user wants:

multicolor: lengthwise  # current look
multicolor: rings       # proposed new look

Since ethernet cables, for example, are striped lengthwise, whereas DIN 47100 specifies rings.

This raises another question, whether the colors should be split 50/50, or whether the second color defines thin rings over a base color? The wires I have lying around here have around a 3/1 ratio of base to rings, the following picture has around 2/1 ratio.

image

SnowMB commented 4 years ago

This raises another question, whether the colors should be split 50/50, or whether the second color defines thin rings over a base color? The wires I have lying around here have around a 3/1 ratio of base to rings, the following picture has around 2/1 ratio.

Arbitrary ratios are possible. But the yaml might grow very verbose if everything has to be specified. Maybe use 50/50 as starting point and add arbitrary values later if someone needs them? I think for the documentation purpose it might not be so important to exactly match the wire :smile:

In the mean time I also encountered 3 color wires, which also should be possible.

aakatz3 commented 4 years ago

Are there any thoughts on how to actually implement this? I assume we'd lose the outlines on the wires, as I didn't see any way to actually pattern the lines/paths in graphviz. Ideally, this could be done wiht a primary/secondary/(possibly tertiary) color, with the dashed connectors, but that didn't seem to be an attribute that could be specified.

Also, as a side note: there are different styles of banding, such as diagonal stripes instead of vertical stripes, though those are usually seen in UTP/STP cables.

SnowMB commented 4 years ago

Are there any thoughts on how to actually implement this?

Ideally there would be a way to layout the graph and ask graphviz how long the edges are, than fractions for the coloring could be computed and the graph could be redrawn with colors. Otherwise I am not sure yet. With a solid color and a style="dashed" edge on top we can achieve 2 colors but not more. Maybe using solid for color 1, dashed for color 2 and dotted for color 3? I have to check how this looks. :thinking:

I assume we'd lose the outlines on the wires

If we can reliably draw multiple edges on top of each other you can draw a wider black edge in the backround and the colors on top like my example, so this would not be an issue.

Also, as a side note: there are different styles of banding, such as diagonal stripes instead of vertical stripes, though those are usually seen in UTP/STP cables.

I don't think, that there are actually diagonal bands. For me it looks more like a twisted stripe. :stuck_out_tongue_closed_eyes:

SnowMB commented 4 years ago

So playing with the table for the wire I got some banded rendering inside the wire node and can match the dimension of the edge with a little bit trial and error. This also got me thinking of possibilities to improve the rendering of the existing multicolor stripe method. (instead of rendering 3 distinct wires for singlecolor to match multicolor width just play around with penwidth attribute of edges and height attribute of the table rows. I also would use the border attribute instead of drawing extra table rows for top and bottom borders.

ex10_with_table gv

For the time being I think in this particular case the differences in wire length and resulting band width are still ok. But I can see that mixing very long with very short wires can look ugly. I will start digging into the python scripts the next days to make a test implementation with the existing limitations so that you can try it out.

formatc1702 commented 4 years ago

How would your striped wires look if you made them the same thickness as the current single-color ones (see example gallery)?

I added in a feature that pads single-color wires to match the thickness of the current lengthwise striped ones, but only if there are any multicolor wires present at all, since I find the thinner style more appealing.

Could you attach a new render?

SnowMB commented 4 years ago

Sure this is an easy to change detail :smile:

Here you go:

graph(1)

myself248 commented 3 years ago

This raises another question, whether the colors should be split 50/50, or whether the second color defines thin rings over a base color?

Both styles are in use. Banded coloring may be 50/50 or may be unequal to differentiate "major" versus "minor" colors on each wire.

In the 25-pair code, for instance, each wire has a major and minor color, and it is paired with another wire that has the same two colors but flipped in dominance. So it's essential to be able to show the difference, but the precise ratio is not important and can be chosen for visual effect. (Something like 70/30 vs 30/70 is probably adequately distinct, without reducing the minor color's visibility too much. Overly-small pips of color could be problematic on a printer with poor registration.)

In my personal experience in telecom, some manufacturers use stripes, some use bands, and anyone reading the diagram should have no trouble mentally translating between the two. But it might be nice to be able to pick the visual style to match the wire in use.

There are also 3-band codes in use, for instance ICEA method 5, which is explained quite well here: https://www.buyawg.com/pdf/wire-cable-methods-of-color-coding.pdf

In this case, it's again important to differentiate the base (major) color from the tracers. (Look at wires 22 and 23 for instance.) I'm not personally experienced with this code but I've run across it in catalogs, so I don't know if there's a standard for the proportions.

[Appended by @kvid 2024-09-16]: It seems the PDF linked above disappeared some time before 2023-12-24, but this archived version from 2018-08-27 might be identical to what @myself248 referred to in 2021.

robotskirts commented 5 days ago

Adding this cable I had to work with which featured different quantities of banding.

CM1C1-xxxx

tobiasfalk commented 5 days ago

https://forum.graphviz.org/t/multicolor-edges-coloring-style-schemata/2438

kvid commented 2 days ago

@tobiasfalk wrote:

https://forum.graphviz.org/t/multicolor-edges-coloring-style-schemata/2438

Where steveroush links to: https://gitlab.com/graphviz/graphviz/-/issues/1069#note_1364067228

As far as I can see, up to now, the only suggestion is using stroke-dasharray for SVG output that can set the dash/gap lengths and a repeated pattern of those. However, only one color is used, so you still need to stack edges to obtain multicolored wires, I guess.

tobiasfalk commented 2 days ago

@kvid Yea, I think this is pretty much on hold until Graphviz implements some more advanced style definition, or someone finds some other way to hack this together with just one edge. I would also say a solution where multiple edges are overlapping are not really good and would lead to more problems than solution, I saw this with using the edge inside the table for the wire.