Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal for new way to draw Wires in the Wire box #352

Open
tobiasfalk opened this issue May 20, 2024 · 12 comments
Open

Proposal for new way to draw Wires in the Wire box #352

tobiasfalk opened this issue May 20, 2024 · 12 comments

Comments

@tobiasfalk
Copy link

Currently, the Wires inside the Wire box are done by coloring table rows, I would propose to change this and do those wires to edges (actual wires) that start at one side of the box and go to the other side.
This would mainly bring the benefit of removing the slide but existing miss alignment between the wires outside and inside the box. But also bring everything that can be done to the wires (edges) to the inside of the wire box.

Here is a comparison, look at the border of the box and where the wire goes into the box:
Current:
test_demo
Proposal:
test_edited

To see it better, one can download them and switch between them with an image viewer.

Implementation

This uses the same method of straitening edges as the dashed lines in #350.

Table

First, the three rows (each with a height of 2) in the table are replaced with one row (with a height of 6) that is completely white (not colored)
Current:

    <tr>
    <td><!-- 1_in --></td>
    <td>
     1:RD
    </td>
    <td>X2:1:+28VDC</td>
   </tr>
   <tr>
    <td colspan="3" border="0" cellspacing="0" cellpadding="0" port="w1" height="6">
     <table cellspacing="0" cellborder="0" border="0">
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#000000" border="0"></td></tr>
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#ff0000" border="0"></td></tr>
      <tr><td colspan="3" cellpadding="0" height="2" bgcolor="#000000" border="0"></td></tr>
     </table>
    </td>
   </tr>

Proposal:

   <tr>
    <td><!-- 1_in --></td>
    <td>
     1:RD
    </td>
    <td>X2:1:+28VDC</td>
   </tr>
   <tr>
    <td colspan="3" border="0" cellspacing="0" port="w1"  cellpadding="0" height="6"></td>
   </tr>

Wire

Then the actual wire is drawn from the right (east) to the left (west) side, this needs to be done with two wire because the straitening method causes problems (see later).
Here the "border" of the wire is drawn first, and the colored inside is drawn on top of it:
Proposal:

	edge [color="#000000" label=" "  penwidth=6]
	W1:w1:e -- W1:w1:w[straight=straight]
	edge [color="#ff0000" label=" "  penwidth=2]
	W1:w1:e -- W1:w1:w[straight=straight]

Problem with the straitening method

test_edited_problem

or:

test_edited_problem

@martinrieder
Copy link
Contributor

I thought about this as well, though I wonder whether it really brings advantages over the current implementation. Graphviz treats nodes (cables and wires) both the same way. They will be laid out based on the edges (connections) that connect them. Introducing these additional edges would have a major impact on the ranking algorithm.

@tobiasfalk
Copy link
Author

I thought about this as well, though I wonder whether it really brings advantages over the current implementation. Graphviz treats nodes (cables and wires) both the same way. They will be laid out based on the edges (connections) that connect them. Introducing these additional edges would have a major impact on the ranking algorithm.

I think especially when someone wants to really have twisted wires(#353) it would really be the only option, additionally I just can not unsee the small misalignment between the out and inside wire.

With constraint=false one can take those line out of the ranking(https://graphviz.org/docs/attrs/constraint/).

@martinrieder
Copy link
Contributor

I think especially when someone wants to really have twisted wires(#353) it would really be the only option,

I can confirm that. See my proposal here

In simple cases, it might be sufficient to show the twisting outside and just hide the cable and connector boxes using a tweak.
Test

Note the difference between styles none and plain, whereof the latter supports HTML, just without the surrounding box style.
The trick here is to set fixedsize to "true" (as a string), which apparently sets the width attribute to its minimum value of 0.01.

@martinrieder in #3 (comment)

Thanks for pointing out the following, because I noticed that my approach would not work in every case. The fixedsize tweak would not shrink the nodes when there is some other node in parallel on the same rank.

With constraint=false one can take those line out of the ranking(https://graphviz.org/docs/attrs/constraint/).

Setting this on the node might be required as well. Would the need to be merged into a subgraph? Does this need to be a cluster then?

@kvid
Copy link
Collaborator

kvid commented May 20, 2024

@tobiasfalk wrote:

Then the actual wire is drawn from the right (east) to the left (west) side, this needs to be done with two wire because the straitening method causes problems (see later).
Here the "border" of the wire is drawn first, and the colored inside is drawn on top of it:

Is there a reason drawing from east to west and not the opposite?

Could you also show the edge codes generating the problem images?

@tobiasfalk
Copy link
Author

tobiasfalk commented May 20, 2024

Is there a reason drawing from east to west and not the opposite?

Not realy, just did it this way also works the other way around.(Maybe I have read too many mangas lately)

Could you also show the edge codes generating the problem images?

1:

	edge [color="#000000:#ff0000:#000000" label=" "]
	W1:w1:e -- W1:w1:w[straight=straight]

2:

	edge [color="#000000:#ff0000:#000000" label=" "  penwidth=6]
	W1:w1:e -- W1:w1:w[straight=straight]

This has to do with the fact that graphviz is drawing this as three lines that are offset to each others and that the "filtering" with the gvpr removes may line points in between the start and end

@martinrieder
Copy link
Contributor

Is there a reason drawing from east to west and not the opposite?
Not realy, just did it this way also works the other way around.

This would only make difference for arrowheads and the ranking in a digraph.

@tobiasfalk about replacing the ugly table tricks, note that the Graphviz docs mention using <HR> instead of the rows in a table.

https://graphviz.org/doc/info/shapes.html#hr

@tobiasfalk
Copy link
Author

tobiasfalk commented May 20, 2024

Is there a reason drawing from east to west and not the opposite?
Not realy, just did it this way also works the other way around.

This would only make difference for arrowheads and the ranking in a digraph.

@tobiasfalk about replacing the ugly table tricks, note that the Graphviz docs mention using <HR> instead of the rows in a table.

https://graphviz.org/doc/info/shapes.html#hr

Ok, thx did not know about this, would also work but this would limit to a solid line, as far as I can see

Edit: was at twisted pairs when writing this, would not work for wires, since this is meant to vreate solid black lines through the table and we would most likely still have the missalaiment problem

@kvid
Copy link
Collaborator

kvid commented May 21, 2024

@tobiasfalk wrote:

Here the "border" of the wire is drawn first, and the colored inside is drawn on top of it:
Proposal:

	edge [color="#000000" label=" "  penwidth=6]
	W1:w1:e -- W1:w1:w[straight=straight]
	edge [color="#ff0000" label=" "  penwidth=2]
	W1:w1:e -- W1:w1:w[straight=straight]

How would your proposal work when a wire has more than two colors? WireViz doesn't limit the number of colors specified for a wire. It does, however, treat a two-colored one as if it is three-colored with primary:secondary:primary colors as a special case for a prettier result.

Try making a 60-wire cable with color_code: DIN to see three-colored examples.

@tobiasfalk
Copy link
Author

If you mean this, then this is just an additional wire over these two. But I see that multicolor cable are a problem.
ex07

@tobiasfalk
Copy link
Author

Multicolor cables are now solved.
Thanks to the fokes at the forum, https://forum.graphviz.org/t/straitening-one-line-throu-a-table/2196/19
I think @ferdnyc. thx

@tobiasfalk
Copy link
Author

See latest comit to #369

@martinrieder
Copy link
Contributor

martinrieder commented Jun 19, 2024

I would like to include this into

(simply noting this here for reference)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants