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

72 happy path first #73

Merged
merged 4 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions lib/utils/layoutUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ export function connectElements(source, target, layoutGrid) {
if (dY === 0) {
if (isDirectPathBlocked(source, target, layoutGrid)) {

// Route on top
// Route on bottom
return [
getDockingPoint(sourceMid, sourceBounds, 't'),
{ x: sourceMid.x, y: sourceMid.y - DEFAULT_CELL_HEIGHT / 2 },
{ x: targetMid.x, y: sourceMid.y - DEFAULT_CELL_HEIGHT / 2 },
getDockingPoint(targetMid, targetBounds, 't')
getDockingPoint(sourceMid, sourceBounds, 'b'),
{ x: sourceMid.x, y: sourceMid.y + DEFAULT_CELL_HEIGHT / 2 },
{ x: targetMid.x, y: sourceMid.y + DEFAULT_CELL_HEIGHT / 2 },
getDockingPoint(targetMid, targetBounds, 'b')
];
} else {

Expand Down Expand Up @@ -120,6 +120,15 @@ export function connectElements(source, target, layoutGrid) {
}
}

// negative dX indicates connection from future to past
if (dX < 0 && dY <= 0) {
return [
getDockingPoint(sourceMid, sourceBounds, 'b'),
{ x: sourceMid.x, y: sourceMid.y + DEFAULT_CELL_HEIGHT / 2 },
{ x: targetMid.x, y: sourceMid.y + DEFAULT_CELL_HEIGHT / 2 },
getDockingPoint(targetMid, targetBounds, 'b')
];
}
Comment on lines +123 to +131
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nikku Not exactly sure if this is the right approach. I have added the condition when it's a loop (future to past) means dX will be negative and the connection can be either on the same row or row less than the current element (dY <=0).

For reference, It solves this case.
image

const directManhattan = directManhattanConnect(source, target, layoutGrid);

if (directManhattan) {
Expand Down
32 changes: 16 additions & 16 deletions test/snapshots/gateway.multiple-complex.bpmn
Original file line number Diff line number Diff line change
Expand Up @@ -138,20 +138,20 @@
<di:waypoint x="500" y="70" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0tifn2t_di" bpmnElement="Flow_0tifn2t">
<di:waypoint x="375" y="45" />
<di:waypoint x="375" y="0" />
<di:waypoint x="1425" y="0" />
<di:waypoint x="1425" y="45" />
<di:waypoint x="375" y="95" />
<di:waypoint x="375" y="140" />
<di:waypoint x="1425" y="140" />
<di:waypoint x="1425" y="95" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_09zvkbl_di" bpmnElement="Flow_09zvkbl">
<di:waypoint x="550" y="70" />
<di:waypoint x="625" y="70" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1ceaqcv_di" bpmnElement="Flow_1ceaqcv">
<di:waypoint x="525" y="45" />
<di:waypoint x="525" y="0" />
<di:waypoint x="1725" y="0" />
<di:waypoint x="1725" y="45" />
<di:waypoint x="525" y="95" />
<di:waypoint x="525" y="140" />
<di:waypoint x="1725" y="140" />
<di:waypoint x="1725" y="95" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0srpkls_di" bpmnElement="Flow_0srpkls">
<di:waypoint x="725" y="70" />
Expand All @@ -162,10 +162,10 @@
<di:waypoint x="925" y="70" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0noq65r_di" bpmnElement="Flow_0noq65r">
<di:waypoint x="825" y="45" />
<di:waypoint x="825" y="0" />
<di:waypoint x="1725" y="0" />
<di:waypoint x="1725" y="45" />
<di:waypoint x="825" y="95" />
<di:waypoint x="825" y="140" />
<di:waypoint x="1725" y="140" />
<di:waypoint x="1725" y="95" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1o0idpq_di" bpmnElement="Flow_1o0idpq">
<di:waypoint x="1025" y="70" />
Expand All @@ -176,10 +176,10 @@
<di:waypoint x="1225" y="70" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_13am6r7_di" bpmnElement="Flow_13am6r7">
<di:waypoint x="1125" y="45" />
<di:waypoint x="1125" y="0" />
<di:waypoint x="1725" y="0" />
<di:waypoint x="1725" y="45" />
<di:waypoint x="1125" y="95" />
<di:waypoint x="1125" y="140" />
<di:waypoint x="1725" y="140" />
<di:waypoint x="1725" y="95" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1wkajd8_di" bpmnElement="Flow_1wkajd8">
<di:waypoint x="1325" y="70" />
Expand Down
10 changes: 4 additions & 6 deletions test/snapshots/gateway.multiple.bpmn
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,10 @@
<di:waypoint x="657" y="210" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_137be2r_di" bpmnElement="Flow_137be2r">
<di:waypoint x="1025" y="210" />
<di:waypoint x="1050" y="210" />
<di:waypoint x="1050" y="140" />
<di:waypoint x="150" y="140" />
<di:waypoint x="150" y="70" />
<di:waypoint x="200" y="70" />
<di:waypoint x="975" y="250" />
<di:waypoint x="975" y="280" />
<di:waypoint x="225" y="280" />
<di:waypoint x="225" y="95" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
Expand Down
16 changes: 8 additions & 8 deletions test/snapshots/gateway.parallel.bpmn
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,16 @@
<di:waypoint x="350" y="210" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_15k0y3x_di" bpmnElement="SequenceFlow_15k0y3x">
<di:waypoint x="225" y="45" />
<di:waypoint x="225" y="0" />
<di:waypoint x="825" y="0" />
<di:waypoint x="825" y="45" />
<di:waypoint x="225" y="95" />
<di:waypoint x="225" y="140" />
<di:waypoint x="825" y="140" />
<di:waypoint x="825" y="95" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_00ndemc_di" bpmnElement="SequenceFlow_00ndemc">
<di:waypoint x="225" y="45" />
<di:waypoint x="225" y="0" />
<di:waypoint x="825" y="0" />
<di:waypoint x="825" y="45" />
<di:waypoint x="225" y="95" />
<di:waypoint x="225" y="140" />
<di:waypoint x="825" y="140" />
<di:waypoint x="825" y="95" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_1b1x3wc_di" bpmnElement="SequenceFlow_1b1x3wc">
<di:waypoint x="425" y="70" />
Expand Down
8 changes: 4 additions & 4 deletions test/snapshots/scenario.happy-path.bpmn
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@
<di:waypoint x="325" y="70" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1cp2keh_di" bpmnElement="Flow_1cp2keh">
<di:waypoint x="225" y="30" />
<di:waypoint x="225" y="0" />
<di:waypoint x="525" y="0" />
<di:waypoint x="525" y="45" />
<di:waypoint x="225" y="110" />
<di:waypoint x="225" y="140" />
<di:waypoint x="525" y="140" />
<di:waypoint x="525" y="95" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_04fevuo_di" bpmnElement="Flow_04fevuo">
<di:waypoint x="425" y="70" />
Expand Down
8 changes: 4 additions & 4 deletions test/snapshots/scenario.issue-32.bpmn
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@
<di:waypoint x="1550" y="70" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="exclusiveGateway4-exclusiveGateway1_di" bpmnElement="exclusiveGateway4-exclusiveGateway1">
<di:waypoint x="1575" y="45" />
<di:waypoint x="1575" y="0" />
<di:waypoint x="225" y="0" />
<di:waypoint x="225" y="45" />
<di:waypoint x="1575" y="95" />
<di:waypoint x="1575" y="140" />
<di:waypoint x="225" y="140" />
<di:waypoint x="225" y="95" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="exclusiveGateway4-endEvent_di" bpmnElement="exclusiveGateway4-endEvent">
<di:waypoint x="1600" y="70" />
Expand Down
16 changes: 8 additions & 8 deletions test/snapshots/scenario.multiple-task-gateways-columns.bpmn
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@
<di:waypoint x="475" y="70" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1sfyni0_di" bpmnElement="Flow_1sfyni0">
<di:waypoint x="375" y="45" />
<di:waypoint x="375" y="0" />
<di:waypoint x="675" y="0" />
<di:waypoint x="675" y="45" />
<di:waypoint x="375" y="95" />
<di:waypoint x="375" y="140" />
<di:waypoint x="675" y="140" />
<di:waypoint x="675" y="95" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_17elf2q_di" bpmnElement="Flow_17elf2q">
<di:waypoint x="575" y="70" />
Expand Down Expand Up @@ -174,10 +174,10 @@
<di:waypoint x="950" y="210" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_17rgrid_di" bpmnElement="Flow_17rgrid">
<di:waypoint x="975" y="185" />
<di:waypoint x="975" y="140" />
<di:waypoint x="1275" y="140" />
<di:waypoint x="1275" y="185" />
<di:waypoint x="975" y="235" />
<di:waypoint x="975" y="280" />
<di:waypoint x="1275" y="280" />
<di:waypoint x="1275" y="235" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0ynot5k_di" bpmnElement="Flow_0ynot5k">
<di:waypoint x="1000" y="210" />
Expand Down