bpmn-io / bpmn-auto-layout

Layout BPMN diagrams, generating missing DI information.
https://bpmn-io.github.io/bpmn-auto-layout/
50 stars 41 forks source link

Gateway with three outgoing sequence flows can cause chaos #49

Closed till-stadtler closed 1 month ago

till-stadtler commented 2 months ago

Describe the Bug

This example shows a simple process with two splitting gateways (my version on top, layouted version on the bottom). The first gateway will populate the second row. When the third gateway is processed, the second "outgoing element" is added to the second row. This is not perfect, with the sequence flow having to snake its way to the task.

But the third "outgoing element" will now be placed in the third row which causes a quite messy layout.

image

Steps to Reproduce

Layout the process shown above.

Expected Behavior

I expect the layout to roughly follow my version.

A splitting gateway should occupy/require as many vertical grid nodes as it has outgoing sequence flows. When placing it, it should be moved to the right until the required number of grid points are available. Like this, the outgoing sequence flows can use these nodes to form a clean gateway pattern, as in my example.

Environment

till-stadtler commented 2 months ago

I solved this issue on my local machine. I will explain more details later. We can also have a meeting to discuss this.

till-stadtler commented 2 months ago

In this case, we will make use of the "skipped" array discussed in #48. This allows us to first place all elements on the stack until the splitting gateway is the next and only element to place. We revisit the first gateway to place the splitting gateway. We place it by looking for an "empty column" which means we are looking for as many free vertical nodes as there are outgoing sequence flows from the splitting gateway. Maybe we should look for more vertical free space, given that the "empty row" functionality described in #48 can lead to splitting gateways to be "higher" in nodes than the number of outgoing sequence flows.

In the end, this issue is solved quite elegantly by using the "skipped" array.

nikku commented 1 month ago

Closed via https://github.com/bpmn-io/bpmn-auto-layout/pull/68