Zoom/Scroll aware Grid #316
Replies: 3 comments 2 replies
-
Hi @frankbenoit , that's interesting and thanks for your contribution! But how did you solve the dimensions problem of the diagram plane. In my test the grid is not filling the visible part of the plane. I had a similar problem with my helper-line feature. Also here my helper lines are sometimes not filling the complete plane and are starting somewhere in the middle of the diagram. |
Beta Was this translation helpful? Give feedback.
-
I think there is just an incorrect offset in the rect with the fill. The grid seems to be fine and the elements align with the dots. Just the x/y of the rect which limits the pattern shown seems to be wrong coordinates. |
Beta Was this translation helpful? Give feedback.
-
Yes I think the start position should be the @injectable()
export class BPMNGraphView implements IView {
@inject(EdgeRouterRegistry) edgeRouterRegistry: EdgeRouterRegistry;
render(model: Readonly<SGraphImpl>, context: RenderingContext): VNode {
const edgeRouting = this.edgeRouterRegistry.routeAllChildren(model);
const gridBounds: Bounds = {
x: model.scroll.x,
y: model.scroll.y,
width: Math.max(10, model.canvasBounds.width / model.zoom),
height: Math.max(10, model.canvasBounds.height / model.zoom)
};
const transform = `scale(${model.zoom}) translate(${-model.scroll.x},${-model.scroll.y})`;
return (
<svg class-sprotty-graph={true}>
<defs>
<pattern id='bpmn-grid-pattern' x='-5' y='-5' width='10' height='10' patternUnits='userSpaceOnUse'>
<line x1="0" y1="5" x2="10" y2="5" class-bpmn-grid-line={true} />
<line x1="5" y1="0" x2="5" y2="10" class-bpmn-grid-line={true} />
</pattern>
</defs>
<g transform={transform}>
<rect
x={gridBounds.x}
y={gridBounds.y}
width={gridBounds.width}
height={gridBounds.height}
fill='url(#bpmn-grid-pattern)'
/>
<g class-graph-content={true}>{context.renderChildren(model, { edgeRouting })}</g>
</g>
</svg>
);
}
} I am using lines instead of dots. In my CSS file I also use the theia/vscode vars for coloring: .bpmn-grid-line {
stroke-width: 0.5;
stroke: var(--theia-titleBar-activeBackground);
} This adapts the line color to the current theme: To configure the view in my Diagram Container I use configureModelElement(context, DefaultTypes.GRAPH, GLSPGraph, BPMNGraphView); this may depend on the GLSP version you are using... Which GLSP version are you using currently? And still I have the issue that opening a new diagram the grid is lost for some reason.... |
Beta Was this translation helpful? Give feedback.
-
Hi
i come across Open-BPMN as a GLSP example that we (me and my collegue) can take inspiration for our project.
I noticed that the visible grid in Open-BPMN is not yet aware of zooming and scroll.
We solved this with
Beta Was this translation helpful? Give feedback.
All reactions