Skip to content

Commit

Permalink
improved grid snapping for waypoints
Browse files Browse the repository at this point in the history
Issue #319
  • Loading branch information
rsoika committed Feb 7, 2024
1 parent 85cdb27 commit 33d2083
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import {
import {
isBPMNLabelNode,
isBoundaryEvent,
isEventNode,
isLaneNode,
isPoolNode,
isTaskNode
Expand All @@ -41,8 +40,6 @@ import { inject, injectable } from 'inversify';
*
****************************************************************************/



/**
* A {@link ISnapper} implementation that snaps BPMN elements onto a fixed gride size.
* This snapper calulates the grid size based on the selected element to allign tasks, gateways and events.
Expand All @@ -53,11 +50,13 @@ export class BPMNElementSnapper implements ISnapper {
constructor(public grid: { x: number; y: number } = { x: 10, y: 10 }) { }

snap(position: Point, _element: GModelElement): Point {
// events are moved by 1x1
if (isEventNode(_element)) {

// move routing-points by 5x5
if ('volatile-routing-point' === _element.type) {
//console.log(' --bin drin im routingpoint');
return {
x: Math.round(position.x / 1) * 1,
y: Math.round(position.y / 1) * 1
x: Math.round(position.x / 5) * 5,
y: Math.round(position.y / 5) * 5
};
}

Expand All @@ -69,7 +68,6 @@ export class BPMNElementSnapper implements ISnapper {
}
}


/**
* This selectionListener selects additional associated BoundaryEvents and BPMNLabels.
* This allows to move both independent Nodes (TaskNode and BoundaryEvent, Event|Gateway and BPMNLabel)
Expand Down Expand Up @@ -154,4 +152,4 @@ export class BPMNMultiNodeSelectionListener implements ISelectionListener {
// finally dispatch the updated selected and unselected IDs...
this.actionDispatcher.dispatch(SelectAction.create({ selectedElementsIDs: selectedElements, deselectedElementsIDs: containerIDs }));
}
}
}
5 changes: 3 additions & 2 deletions open-bpmn.glsp-client/open-bpmn-glsp/src/di.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ import {
MultiLineTextNode,
PoolNode, TaskNode,
TextAnnotationNode,
isBPMNNode
isBPMNNode,
isBoundaryEvent
} from '@open-bpmn/open-bpmn-model';
import 'balloon-css/balloon.min.css';
import { Container, ContainerModule } from 'inversify';
Expand Down Expand Up @@ -105,7 +106,7 @@ const bpmnDiagramModule = new ContainerModule((bind, unbind, isBound, rebind) =>
//bind(TYPES.ISnapper).toConstantValue(new GridSnapper({ x: 5, y: 5 }));
bind<IHelperLineOptions>(TYPES.IHelperLineOptions).toConstantValue({
alignmentElementFilter: element =>
isBPMNNode(element),
isBPMNNode(element) && !isBoundaryEvent(element),
minimumMoveDelta: { x: 10, y: 10 }
});

Expand Down

0 comments on commit 33d2083

Please sign in to comment.