Automated line routing?

1 view
Skip to first unread message

John Pye

unread,
Jun 12, 2008, 3:35:10 AM6/12/08
to gapho...@googlegroups.com
Hi all

I showed the progress that we've made on blocks and ports to the other
members of the ASCEND project and they suggested that we might need to
look at automated line routing.

Can I have your suggestions on how I might tackle this? I would like to
have a PlacementTool or ItemTool that gets activated when I drag from a
port to another port. I would like this action to result in a line
between the two ports, but I want the line to take an orthogonal route
between the two ports, and I want it to avoid any obstacles en route if
that is reasonably possible.

For example, if I connect an output of a block back to one of its
inputs, then I would like a line with 5 segments like this

_________
| line |
| ____ |
|__|blok|_|
. |____|


I think that once a line has been placed, it would be OK for the line
routing not to be recalculated every time something was moved.

I suspect that this problem might be rather difficult to solve in an
simple way...

Cheers
JP

Arjan Molenaar

unread,
Jun 12, 2008, 6:24:42 AM6/12/08
to gapho...@googlegroups.com
On Thu, Jun 12, 2008 at 9:35 AM, John Pye <jo...@curioussymbols.com> wrote:
>
> Hi all
>
> I showed the progress that we've made on blocks and ports to the other
> members of the ASCEND project and they suggested that we might need to
> look at automated line routing.

This is an issue that I avoided so far ;). It looks really difficult
to me (you have to set up some sort of rules).
Isn't there a library out there that does some automatic placement and
routing? We have a very simple version in Gaphor (the UML tool), which
is used to place classes and relations on a canvas when reverse
engineering Python code.

> Can I have your suggestions on how I might tackle this? I would like to
> have a PlacementTool or ItemTool that gets activated when I drag from a
> port to another port. I would like this action to result in a line
> between the two ports, but I want the line to take an orthogonal route
> between the two ports, and I want it to avoid any obstacles en route if
> that is reasonably possible.

Activate PlacementTool for example when you start dragging with a
modifier key (Ctrl, Shift) pressed? That can be implemented basically
the same way the placementTool is implemented. The placementTool
contains a HandleTool, that's called as soon as an item is placed on
the canvas.

You should probably do the same thing for ItemTool then: delegate
calls to a PlacementTool.

> For example, if I connect an output of a block back to one of its
> inputs, then I would like a line with 5 segments like this
>
> _________
> | line |
> | ____ |
> |__|blok|_|
> . |____|

You'll need to set up some rules. In this case something like:
if (line.end.connected_to == line.begin.connectedTo):
... and then do some trickery to ensure the line is placed right...

Of course Python is a great language to define such rules (and the
conditions that should be met in order to activate a rule). But when
to enforce rules? when moving an item? On a button release action?
Depends a but on the rule.

Thinking of it. We're thinking about some sort of alginement tool (so
items can easely be vertically or horizontally aligned, a but like
Apple's Pages). That may be very well implemented with rules.


> I think that once a line has been placed, it would be OK for the line
> routing not to be recalculated every time something was moved.
>
> I suspect that this problem might be rather difficult to solve in an
> simple way...

It's a complex and interresting issue, that may be solved in a more generic way.

gr.

Arjan

Reply all
Reply to author
Forward
0 new messages