Stefan Koenen
Stefan Koenen

Reputation: 2337

c# draw (connection) lines without crossing any other line

I got a small problem with making a connection display. It has to be dynamic so i can't use paint :P. Lets say i have some connectors at the left side and some other at the right side, how can i draw lines between them without crossing any other lines.

note: its possible to got more then 2 lines of connectors like:

┌---------------------------┐
| o------------o            o
└-o            o            o
  o            o            o
  o            o            o

somebody got any ideas? thnx!

stefan

Upvotes: 2

Views: 2076

Answers (2)

Justin
Justin

Reputation: 86729

I think you are going to be disappointed - in the general case this is impossible to do even with two lines of connectors, for example:

┌────────────────┐
│ o*           o─┘
|              |
| o────────────o
| |
└─o            o*

(Updated in response to comment)

How do you then connect the two connectors marked with a * without crossing over any existing lines?

Just come up with a way to represent lines that cross without intersecting.

Upvotes: 1

DarkSquirrel42
DarkSquirrel42

Reputation: 10257

that is only possible if your connection network shows a planar graph

maybe this will help you: http://www.cs.brown.edu/~rt/papers/gd-tutorial/gd-constraints.pdf

Upvotes: 3

Related Questions