bpmn-io / bpmn-auto-layout

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

Add partial layout feature #53

Open philippfromme opened 2 months ago

philippfromme commented 2 months ago

Is your feature request related to a problem? Please describe.

layoutProcess assumes that no DI information exists. It is currently not possible to keep existing DI while creating new DI where none exists.

Describe the solution you'd like

Example

Input

<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_0iis8vl" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.26.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.5.0">
  <bpmn:process id="Process_03nxu37" isExecutable="true">
    <bpmn:startEvent id="StartEvent_1">
      <bpmn:outgoing>Flow_098x2rf</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:task id="Activity_0exnan2">
      <bpmn:incoming>Flow_098x2rf</bpmn:incoming>
      <bpmn:outgoing>Flow_055idb4</bpmn:outgoing>
    </bpmn:task>
    <bpmn:sequenceFlow id="Flow_098x2rf" sourceRef="StartEvent_1" targetRef="Activity_0exnan2" />
    <bpmn:endEvent id="Event_0vj6cki">
      <bpmn:incoming>Flow_055idb4</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="Flow_055idb4" sourceRef="Activity_0exnan2" targetRef="Event_0vj6cki" />
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_03nxu37">
      <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
        <dc:Bounds x="179" y="99" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_0exnan2_di" bpmnElement="Activity_0exnan2">
        <dc:Bounds x="270" y="77" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="Flow_098x2rf_di" bpmnElement="Flow_098x2rf">
        <di:waypoint x="215" y="117" />
        <di:waypoint x="270" y="117" />
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

Output

DI for end event and connecting sequence flow added.

<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_0iis8vl" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.26.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.5.0">
  <bpmn:process id="Process_03nxu37" isExecutable="true">
    <bpmn:startEvent id="StartEvent_1">
      <bpmn:outgoing>Flow_098x2rf</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:task id="Activity_0exnan2">
      <bpmn:incoming>Flow_098x2rf</bpmn:incoming>
      <bpmn:outgoing>Flow_055idb4</bpmn:outgoing>
    </bpmn:task>
    <bpmn:sequenceFlow id="Flow_098x2rf" sourceRef="StartEvent_1" targetRef="Activity_0exnan2" />
    <bpmn:endEvent id="Event_0vj6cki">
      <bpmn:incoming>Flow_055idb4</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="Flow_055idb4" sourceRef="Activity_0exnan2" targetRef="Event_0vj6cki" />
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_03nxu37">
      <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
        <dc:Bounds x="179" y="99" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_0exnan2_di" bpmnElement="Activity_0exnan2">
        <dc:Bounds x="270" y="77" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_0vj6cki_di" bpmnElement="Event_0vj6cki">
        <dc:Bounds x="432" y="99" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="Flow_098x2rf_di" bpmnElement="Flow_098x2rf">
        <di:waypoint x="215" y="117" />
        <di:waypoint x="270" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_055idb4_di" bpmnElement="Flow_055idb4">
        <di:waypoint x="370" y="117" />
        <di:waypoint x="432" y="117" />
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>
nikku commented 2 months ago

I can see how this is relevant in the context of "less obtrusive content additions", but I'm not sure yet if/how we need this. Let's see when / if we're going to pick this up.