@eclipse-glsp/client 2.1.0-next.305 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/features/change-bounds/position-snapper.js +4 -4
- package/lib/features/change-bounds/position-snapper.js.map +1 -1
- package/lib/features/helper-lines/helper-line-feedback.d.ts +30 -11
- package/lib/features/helper-lines/helper-line-feedback.d.ts.map +1 -1
- package/lib/features/helper-lines/helper-line-feedback.js +93 -32
- package/lib/features/helper-lines/helper-line-feedback.js.map +1 -1
- package/lib/features/helper-lines/helper-line-manager-default.d.ts +42 -11
- package/lib/features/helper-lines/helper-line-manager-default.d.ts.map +1 -1
- package/lib/features/helper-lines/helper-line-manager-default.js +21 -16
- package/lib/features/helper-lines/helper-line-manager-default.js.map +1 -1
- package/lib/features/helper-lines/helper-line-manager.d.ts +8 -1
- package/lib/features/helper-lines/helper-line-manager.d.ts.map +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tool-feedback.js +1 -1
- package/lib/features/tools/change-bounds/change-bounds-tool-feedback.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils/gmodel-util.d.ts +1 -0
- package/lib/utils/gmodel-util.d.ts.map +1 -1
- package/lib/utils/gmodel-util.js +10 -1
- package/lib/utils/gmodel-util.js.map +1 -1
- package/package.json +3 -3
- package/src/features/change-bounds/position-snapper.ts +4 -4
- package/src/features/helper-lines/helper-line-feedback.ts +127 -45
- package/src/features/helper-lines/helper-line-manager-default.ts +68 -20
- package/src/features/helper-lines/helper-line-manager.ts +8 -1
- package/src/features/tools/change-bounds/change-bounds-tool-feedback.ts +1 -1
- package/src/utils/gmodel-util.ts +12 -0
|
@@ -172,4 +172,5 @@ export declare function calcRoute(element: GRoutableElement, routerRegistry: Edg
|
|
|
172
172
|
export declare function getElementTypeId(input: GModelElement | GModelElementSchema | string): string;
|
|
173
173
|
export declare function findTopLevelElementByFeature<T>(element: GModelElement, predicate: (t: GModelElement) => t is GModelElement & T, skip?: (t: GModelElement) => boolean): (GModelElement & T) | undefined;
|
|
174
174
|
export declare function calculateDeltaBetweenPoints(target: Point, source: Point, element: GModelElement): Point;
|
|
175
|
+
export declare function isVisibleOnCanvas(model: BoundsAwareModelElement): boolean;
|
|
175
176
|
//# sourceMappingURL=gmodel-util.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gmodel-util.d.ts","sourceRoot":"","sources":["../../src/utils/gmodel-util.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EACH,WAAW,EACX,kBAAkB,EAClB,gBAAgB,EAChB,uBAAuB,EACvB,cAAc,EAEd,aAAa,EACb,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,KAAK,EACL,WAAW,EACX,UAAU,EACV,SAAS,
|
|
1
|
+
{"version":3,"file":"gmodel-util.d.ts","sourceRoot":"","sources":["../../src/utils/gmodel-util.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EACH,WAAW,EACX,kBAAkB,EAClB,gBAAgB,EAChB,uBAAuB,EACvB,cAAc,EAEd,aAAa,EACb,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,KAAK,EACL,WAAW,EACX,UAAU,EACV,SAAS,EAUZ,MAAM,uBAAuB,CAAC;AAE/B;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,aAAa,KAAK,YAAY,IAAI,aAAa,GAAG,CAAC,CAAC;AAEzG;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,aAAa,GAAG,CAAC,CAAC,CAEtH;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAC5B,KAAK,EAAE,cAAc,E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AAG,MAAM,GAAG,MAAM,CAM5F;AAED,wBAAgB,4BAA4B,CAAC,CAAC,EAC1C,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,CAAC,IAAI,aAAa,GAAG,CAAC,EACvD,IAAI,GAAE,CAAC,CAAC,EAAE,aAAa,KAAK,OAAqB,GAClD,CAAC,aAAa,GAAG,CAAC,CAAC,GAAG,SAAS,CAcjC;AAED,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,aAAa,GAAG,KAAK,CAMvG;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CASzE"}
|
package/lib/utils/gmodel-util.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.calculateDeltaBetweenPoints = exports.findTopLevelElementByFeature = exports.getElementTypeId = exports.calcRoute = exports.calcElementAndRoute = exports.calcElementAndRoutingPoints = exports.ROUTE_KINDS = exports.ROUTING_POINT_KINDS = exports.ALL_ROUTING_POINTS = exports.toElementAndRoutingPoints = exports.toElementAndBounds = exports.isSelectableAndBoundsAware = exports.isRoutingHandle = exports.isRoutable = exports.isNonRoutableSelectedBoundsAware = exports.isNonRoutableSelectedMovableBoundsAware = exports.removeCssClasses = exports.addCssClasses = exports.isNotUndefined = exports.hasSelectedElements = exports.getSelectedElementCount = exports.getElements = exports.getMatchingElements = exports.forEachElement = exports.filter = void 0;
|
|
3
|
+
exports.isVisibleOnCanvas = exports.calculateDeltaBetweenPoints = exports.findTopLevelElementByFeature = exports.getElementTypeId = exports.calcRoute = exports.calcElementAndRoute = exports.calcElementAndRoutingPoints = exports.ROUTE_KINDS = exports.ROUTING_POINT_KINDS = exports.ALL_ROUTING_POINTS = exports.toElementAndRoutingPoints = exports.toElementAndBounds = exports.isSelectableAndBoundsAware = exports.isRoutingHandle = exports.isRoutable = exports.isNonRoutableSelectedBoundsAware = exports.isNonRoutableSelectedMovableBoundsAware = exports.removeCssClasses = exports.addCssClasses = exports.isNotUndefined = exports.hasSelectedElements = exports.getSelectedElementCount = exports.getElements = exports.getMatchingElements = exports.forEachElement = exports.filter = void 0;
|
|
4
4
|
/********************************************************************************
|
|
5
5
|
* Copyright (c) 2019-2023 EclipseSource and others.
|
|
6
6
|
*
|
|
@@ -301,4 +301,13 @@ function calculateDeltaBetweenPoints(target, source, element) {
|
|
|
301
301
|
return adaptedDelta;
|
|
302
302
|
}
|
|
303
303
|
exports.calculateDeltaBetweenPoints = calculateDeltaBetweenPoints;
|
|
304
|
+
function isVisibleOnCanvas(model) {
|
|
305
|
+
const modelBounds = (0, sprotty_1.getAbsoluteBounds)(model);
|
|
306
|
+
const canvasBounds = model.root.canvasBounds;
|
|
307
|
+
return (modelBounds.x <= canvasBounds.width &&
|
|
308
|
+
modelBounds.x + modelBounds.width >= 0 &&
|
|
309
|
+
modelBounds.y <= canvasBounds.height &&
|
|
310
|
+
modelBounds.y + modelBounds.height >= 0);
|
|
311
|
+
}
|
|
312
|
+
exports.isVisibleOnCanvas = isVisibleOnCanvas;
|
|
304
313
|
//# sourceMappingURL=gmodel-util.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gmodel-util.js","sourceRoot":"","sources":["../../src/utils/gmodel-util.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,
|
|
1
|
+
{"version":3,"file":"gmodel-util.js","sourceRoot":"","sources":["../../src/utils/gmodel-util.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,mDAyB+B;AAS/B;;;;;;GAMG;AACH,SAAgB,MAAM,CAAI,KAAqB,EAAE,SAAkC;IAC/E,OAAO,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,SAAS,CAAsC,CAAC;AAC9E,CAAC;AAFD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AAC,EAAE,KAAK,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC;IAC9D,OAAO,YAAY,CAAC;AACxB,CAAC;AAND,kEAMC;AAED,SAAgB,iBAAiB,CAAC,KAA8B;IAC5D,MAAM,WAAW,GAAG,IAAA,2BAAiB,EAAC,KAAK,CAAC,CAAC;IAC7C,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC;IAC7C,OAAO,CACH,WAAW,CAAC,CAAC,IAAI,YAAY,CAAC,KAAK;QACnC,WAAW,CAAC,CAAC,GAAG,WAAW,CAAC,KAAK,IAAI,CAAC;QACtC,WAAW,CAAC,CAAC,IAAI,YAAY,CAAC,MAAM;QACpC,WAAW,CAAC,CAAC,GAAG,WAAW,CAAC,MAAM,IAAI,CAAC,CAC1C,CAAC;AACN,CAAC;AATD,8CASC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eclipse-glsp/client",
|
|
3
|
-
"version": "2.1.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "A sprotty-based client for GLSP",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eclipse",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"watch": "tsc -w"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@eclipse-glsp/sprotty": "2.1.0
|
|
50
|
+
"@eclipse-glsp/sprotty": "2.1.0",
|
|
51
51
|
"autocompleter": "^9.1.0",
|
|
52
52
|
"file-saver": "^2.0.5",
|
|
53
53
|
"lodash": "4.17.21"
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"publishConfig": {
|
|
60
60
|
"access": "public"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "4e4db4be13e12dff413aaa0e6472dec4a4f24406"
|
|
63
63
|
}
|
|
@@ -55,14 +55,14 @@ export class PositionSnapper {
|
|
|
55
55
|
|
|
56
56
|
const minimum: Writable<Point> = { x: 0, y: 0 };
|
|
57
57
|
if (directions.includes(Direction.Left) && helperLines.some(line => line.isLeft || line.isCenter)) {
|
|
58
|
-
minimum.x = this.helperLineManager.
|
|
58
|
+
minimum.x = this.helperLineManager.getMinimumMoveDelta(target, isSnap, Direction.Left);
|
|
59
59
|
} else if (directions.includes(Direction.Right) && helperLines.some(line => line.isRight || line.isCenter)) {
|
|
60
|
-
minimum.x = this.helperLineManager.
|
|
60
|
+
minimum.x = this.helperLineManager.getMinimumMoveDelta(target, isSnap, Direction.Right);
|
|
61
61
|
}
|
|
62
62
|
if (directions.includes(Direction.Up) && helperLines.some(line => line.isTop || line.isMiddle)) {
|
|
63
|
-
minimum.y = this.helperLineManager.
|
|
63
|
+
minimum.y = this.helperLineManager.getMinimumMoveDelta(target, isSnap, Direction.Up);
|
|
64
64
|
} else if (directions.includes(Direction.Down) && helperLines.some(line => line.isBottom || line.isMiddle)) {
|
|
65
|
-
minimum.y = this.helperLineManager.
|
|
65
|
+
minimum.y = this.helperLineManager.getMinimumMoveDelta(target, isSnap, Direction.Down);
|
|
66
66
|
}
|
|
67
67
|
return minimum;
|
|
68
68
|
}
|
|
@@ -19,12 +19,17 @@ import {
|
|
|
19
19
|
Bounds,
|
|
20
20
|
CommandExecutionContext,
|
|
21
21
|
CommandReturn,
|
|
22
|
+
GChildElement,
|
|
23
|
+
GLabel,
|
|
22
24
|
GModelElement,
|
|
23
25
|
GModelRoot,
|
|
26
|
+
ILogger,
|
|
27
|
+
Point,
|
|
24
28
|
TYPES,
|
|
25
29
|
Viewport,
|
|
26
30
|
findParentByFeature,
|
|
27
31
|
isBoundsAware,
|
|
32
|
+
isDecoration,
|
|
28
33
|
isViewport
|
|
29
34
|
} from '@eclipse-glsp/sprotty';
|
|
30
35
|
import { inject, injectable } from 'inversify';
|
|
@@ -50,14 +55,23 @@ import {
|
|
|
50
55
|
topLeft,
|
|
51
56
|
topRight
|
|
52
57
|
} from '../../utils/geometry-util';
|
|
53
|
-
import {
|
|
54
|
-
|
|
58
|
+
import {
|
|
59
|
+
BoundsAwareModelElement,
|
|
60
|
+
findTopLevelElementByFeature,
|
|
61
|
+
forEachElement,
|
|
62
|
+
getMatchingElements,
|
|
63
|
+
isRoutable,
|
|
64
|
+
isVisibleOnCanvas
|
|
65
|
+
} from '../../utils/gmodel-util';
|
|
66
|
+
import { getViewportBounds, toAbsoluteBounds } from '../../utils/viewpoint-util';
|
|
55
67
|
import { HelperLine, HelperLineType, SelectionBounds, isHelperLine, isSelectionBounds } from './model';
|
|
56
68
|
|
|
57
69
|
export type ViewportLineType = typeof HelperLineType.Center | typeof HelperLineType.Middle | string;
|
|
58
70
|
|
|
59
|
-
export
|
|
60
|
-
|
|
71
|
+
export type AlignmentElementFilter = (element: BoundsAwareModelElement, referenceElementIds: string[]) => boolean;
|
|
72
|
+
|
|
73
|
+
export const isTopLevelBoundsAwareElement: AlignmentElementFilter = element =>
|
|
74
|
+
findTopLevelElementByFeature(element, isBoundsAware, isViewport) === element;
|
|
61
75
|
|
|
62
76
|
export interface DrawHelperLinesFeedbackAction extends Action {
|
|
63
77
|
kind: typeof DrawHelperLinesFeedbackAction.KIND;
|
|
@@ -65,8 +79,20 @@ export interface DrawHelperLinesFeedbackAction extends Action {
|
|
|
65
79
|
elementLines?: HelperLineType[];
|
|
66
80
|
viewportLines?: ViewportLineType[];
|
|
67
81
|
alignmentEpsilon?: number;
|
|
82
|
+
alignmentElementFilter?: AlignmentElementFilter;
|
|
83
|
+
debug?: boolean;
|
|
68
84
|
}
|
|
69
85
|
|
|
86
|
+
export const ALL_ELEMENT_LINE_TYPES = Object.values(HelperLineType);
|
|
87
|
+
export const ALL_VIEWPORT_LINE_TYPES = [HelperLineType.Center, HelperLineType.Middle];
|
|
88
|
+
|
|
89
|
+
export const DEFAULT_ELEMENT_LINES = ALL_ELEMENT_LINE_TYPES;
|
|
90
|
+
export const DEFAULT_VIEWPORT_LINES = ALL_VIEWPORT_LINE_TYPES;
|
|
91
|
+
export const DEFAULT_EPSILON = 1;
|
|
92
|
+
export const DEFAULT_ALIGNABLE_ELEMENT_FILTER = (element: BoundsAwareModelElement): boolean =>
|
|
93
|
+
isVisibleOnCanvas(element) && !isRoutable(element) && !(element instanceof GLabel) && !isDecoration(element);
|
|
94
|
+
export const DEFAULT_DEBUG = false;
|
|
95
|
+
|
|
70
96
|
export namespace DrawHelperLinesFeedbackAction {
|
|
71
97
|
export const KIND = 'drawHelperLines';
|
|
72
98
|
|
|
@@ -82,153 +108,200 @@ export namespace DrawHelperLinesFeedbackAction {
|
|
|
82
108
|
export class DrawHelperLinesFeedbackCommand extends FeedbackCommand {
|
|
83
109
|
static readonly KIND = DrawHelperLinesFeedbackAction.KIND;
|
|
84
110
|
|
|
85
|
-
|
|
111
|
+
protected elementIds: string[];
|
|
112
|
+
protected elementLines: HelperLineType[];
|
|
113
|
+
protected viewportLines: ViewportLineType[];
|
|
114
|
+
protected alignmentEpsilon: number;
|
|
115
|
+
protected alignableElementFilter: AlignmentElementFilter;
|
|
116
|
+
protected isAlignableElementPredicate: (element: GModelElement) => element is BoundsAwareModelElement;
|
|
117
|
+
protected debug: boolean;
|
|
118
|
+
|
|
119
|
+
constructor(
|
|
120
|
+
@inject(TYPES.Action) action: DrawHelperLinesFeedbackAction,
|
|
121
|
+
@inject(TYPES.ILogger) protected logger: ILogger
|
|
122
|
+
) {
|
|
86
123
|
super();
|
|
124
|
+
this.elementIds = action.elementIds;
|
|
125
|
+
this.elementLines = action.elementLines ?? DEFAULT_ELEMENT_LINES;
|
|
126
|
+
this.viewportLines = action.viewportLines ?? DEFAULT_VIEWPORT_LINES;
|
|
127
|
+
this.alignmentEpsilon = action.alignmentEpsilon ?? DEFAULT_EPSILON;
|
|
128
|
+
this.alignableElementFilter = action.alignmentElementFilter ?? DEFAULT_ALIGNABLE_ELEMENT_FILTER;
|
|
129
|
+
this.isAlignableElementPredicate = this.isAlignableElement.bind(this);
|
|
130
|
+
this.debug = action.debug ?? DEFAULT_DEBUG;
|
|
87
131
|
}
|
|
88
132
|
|
|
89
133
|
execute(context: CommandExecutionContext): CommandReturn {
|
|
90
134
|
removeHelperLines(context.root);
|
|
91
135
|
removeSelectionBounds(context.root);
|
|
92
|
-
const
|
|
93
|
-
|
|
136
|
+
const alignableElements = getMatchingElements(context.root.index, this.isAlignableElementPredicate);
|
|
137
|
+
this.log('All alignable elements: ', alignableElements);
|
|
138
|
+
const [referenceElements, elements] = partition(alignableElements, element => this.elementIds.includes(element.id));
|
|
139
|
+
this.log('Split alignable elements into reference elements and other elements: ', referenceElements, elements);
|
|
94
140
|
if (referenceElements.length === 0) {
|
|
141
|
+
this.log('--> No helper lines as we do not have any reference elements.');
|
|
95
142
|
return context.root;
|
|
96
143
|
}
|
|
97
144
|
const referenceBounds = this.calcReferenceBounds(referenceElements);
|
|
145
|
+
this.log('Bounds encompasing all reference elements: ', referenceBounds);
|
|
98
146
|
const helperLines = this.calcHelperLines(elements, referenceBounds, context);
|
|
99
147
|
if (referenceElements.length > 1) {
|
|
100
148
|
context.root.add(new SelectionBounds(referenceBounds));
|
|
149
|
+
this.log('Render selection bounds for more than one reference element:', referenceBounds);
|
|
101
150
|
}
|
|
102
151
|
helperLines.forEach(helperLine => context.root.add(helperLine));
|
|
152
|
+
if (helperLines.length > 0) {
|
|
153
|
+
this.log(`--> Add ${helperLines.length} helper lines to root:`, helperLines);
|
|
154
|
+
} else {
|
|
155
|
+
this.log('--> Add no helper lines to root.');
|
|
156
|
+
}
|
|
103
157
|
return context.root;
|
|
104
158
|
}
|
|
105
159
|
|
|
106
|
-
protected
|
|
107
|
-
return isBoundsAware(element) &&
|
|
160
|
+
protected isAlignableElement(element: GModelElement): element is BoundsAwareModelElement {
|
|
161
|
+
return isBoundsAware(element) && this.alignableElementFilter(element, this.elementIds);
|
|
108
162
|
}
|
|
109
163
|
|
|
110
164
|
protected calcReferenceBounds(referenceElements: BoundsAwareModelElement[]): Bounds {
|
|
111
|
-
return referenceElements.map(element => element
|
|
165
|
+
return referenceElements.map(element => this.calcBounds(element)).reduce(Bounds.combine, Bounds.EMPTY);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
protected calcBounds(element: BoundsAwareModelElement): Bounds {
|
|
169
|
+
return toAbsoluteBounds(element);
|
|
112
170
|
}
|
|
113
171
|
|
|
114
172
|
protected calcHelperLines(elements: BoundsAwareModelElement[], bounds: Bounds, context: CommandExecutionContext): HelperLine[] {
|
|
115
173
|
const helperLines: HelperLine[] = [];
|
|
116
174
|
const viewport = findParentByFeature(context.root, isViewport);
|
|
117
175
|
if (viewport) {
|
|
118
|
-
helperLines.push(...this.calcHelperLinesForViewport(viewport, bounds));
|
|
176
|
+
helperLines.push(...this.calcHelperLinesForViewport(viewport, bounds, this.viewportLines));
|
|
119
177
|
}
|
|
120
|
-
elements
|
|
178
|
+
elements
|
|
179
|
+
.flatMap(element => this.calcHelperLinesForElement(element, bounds, this.elementLines))
|
|
180
|
+
.forEach(line => helperLines.push(line));
|
|
121
181
|
return helperLines;
|
|
122
182
|
}
|
|
123
183
|
|
|
124
|
-
protected calcHelperLinesForViewport(
|
|
125
|
-
root: Viewport & GModelRoot,
|
|
126
|
-
bounds: Bounds,
|
|
127
|
-
lineTypes: HelperLineType[] = this.action.viewportLines ?? ALL_VIEWPORT_LINE_TYPES
|
|
128
|
-
): HelperLine[] {
|
|
184
|
+
protected calcHelperLinesForViewport(root: Viewport & GModelRoot, bounds: Bounds, lineTypes: HelperLineType[]): HelperLine[] {
|
|
129
185
|
const helperLines: HelperLine[] = [];
|
|
186
|
+
this.log('Find helperlines for viewport:', root);
|
|
130
187
|
const viewportBounds = getViewportBounds(root, root.canvasBounds);
|
|
131
188
|
if (lineTypes.includes(HelperLineType.Center) && this.isAligned(center, viewportBounds, bounds, 2)) {
|
|
132
189
|
helperLines.push(new HelperLine(topCenter(viewportBounds), bottomCenter(viewportBounds), HelperLineType.Center));
|
|
190
|
+
this.log('- Reference bounds center align with viewport.', viewportBounds);
|
|
133
191
|
}
|
|
134
192
|
if (lineTypes.includes(HelperLineType.Middle) && this.isAligned(middle, viewportBounds, bounds, 2)) {
|
|
135
193
|
helperLines.push(new HelperLine(middleLeft(viewportBounds), middleRight(viewportBounds), HelperLineType.Middle));
|
|
194
|
+
this.log('- Reference bounds middle align with viewport.', viewportBounds);
|
|
195
|
+
}
|
|
196
|
+
if (helperLines.length > 0) {
|
|
197
|
+
this.log(`--> Add ${helperLines.length} helperlines for viewport:`, helperLines);
|
|
136
198
|
}
|
|
137
199
|
return helperLines;
|
|
138
200
|
}
|
|
139
201
|
|
|
140
|
-
protected calcHelperLinesForElement(
|
|
141
|
-
element:
|
|
142
|
-
bounds
|
|
143
|
-
lineTypes: HelperLineType[] = this.action.elementLines ?? ALL_ELEMENT_LINE_TYPES
|
|
144
|
-
): HelperLine[] {
|
|
145
|
-
return this.calcHelperLinesForBounds(element.bounds, bounds, lineTypes);
|
|
202
|
+
protected calcHelperLinesForElement(element: BoundsAwareModelElement, bounds: Bounds, lineTypes: HelperLineType[]): HelperLine[] {
|
|
203
|
+
this.log('Find helperlines for element:', element);
|
|
204
|
+
return this.calcHelperLinesForBounds(this.calcBounds(element), bounds, lineTypes);
|
|
146
205
|
}
|
|
147
206
|
|
|
148
|
-
protected calcHelperLinesForBounds(
|
|
149
|
-
elementBounds: Bounds,
|
|
150
|
-
bounds: Bounds,
|
|
151
|
-
lineTypes: HelperLineType[] = this.action.elementLines ?? ALL_ELEMENT_LINE_TYPES
|
|
152
|
-
): HelperLine[] {
|
|
207
|
+
protected calcHelperLinesForBounds(elementBounds: Bounds, bounds: Bounds, lineTypes: HelperLineType[]): HelperLine[] {
|
|
153
208
|
const helperLines: HelperLine[] = [];
|
|
154
209
|
|
|
155
|
-
if (lineTypes.includes(HelperLineType.Left) && this.isAligned(left, elementBounds, bounds)) {
|
|
210
|
+
if (lineTypes.includes(HelperLineType.Left) && this.isAligned(left, elementBounds, bounds, this.alignmentEpsilon)) {
|
|
156
211
|
const [above, below] = sortBy(top, elementBounds, bounds); // higher top-value ==> lower
|
|
157
212
|
helperLines.push(new HelperLine(bottomLeft(below), topLeft(above), HelperLineType.Left));
|
|
213
|
+
this.log('- Reference bounds left align with element', elementBounds);
|
|
158
214
|
}
|
|
159
215
|
|
|
160
|
-
if (lineTypes.includes(HelperLineType.Center) && this.isAligned(center, elementBounds, bounds)) {
|
|
216
|
+
if (lineTypes.includes(HelperLineType.Center) && this.isAligned(center, elementBounds, bounds, this.alignmentEpsilon)) {
|
|
161
217
|
const [above, below] = sortBy(top, elementBounds, bounds); // higher top-value ==> lower
|
|
162
218
|
helperLines.push(new HelperLine(topCenter(above), bottomCenter(below), HelperLineType.Center));
|
|
219
|
+
this.log('- Reference bounds center align with element', elementBounds);
|
|
163
220
|
}
|
|
164
221
|
|
|
165
|
-
if (lineTypes.includes(HelperLineType.Right) && this.isAligned(right, elementBounds, bounds)) {
|
|
222
|
+
if (lineTypes.includes(HelperLineType.Right) && this.isAligned(right, elementBounds, bounds, this.alignmentEpsilon)) {
|
|
166
223
|
const [above, below] = sortBy(top, elementBounds, bounds); // higher top-value ==> lower
|
|
167
224
|
helperLines.push(new HelperLine(bottomRight(below), topRight(above), HelperLineType.Right));
|
|
225
|
+
this.log('- Reference bounds right align with element', elementBounds);
|
|
168
226
|
}
|
|
169
227
|
|
|
170
|
-
if (lineTypes.includes(HelperLineType.Bottom) && this.isAligned(bottom, elementBounds, bounds)) {
|
|
228
|
+
if (lineTypes.includes(HelperLineType.Bottom) && this.isAligned(bottom, elementBounds, bounds, this.alignmentEpsilon)) {
|
|
171
229
|
const [before, after] = sortBy(left, elementBounds, bounds); // higher left-value ==> more to the right
|
|
172
230
|
helperLines.push(new HelperLine(bottomLeft(before), bottomRight(after), HelperLineType.Bottom));
|
|
231
|
+
this.log('- Reference bounds bottom align with element', elementBounds);
|
|
173
232
|
}
|
|
174
233
|
|
|
175
|
-
if (lineTypes.includes(HelperLineType.Middle) && this.isAligned(middle, elementBounds, bounds)) {
|
|
234
|
+
if (lineTypes.includes(HelperLineType.Middle) && this.isAligned(middle, elementBounds, bounds, this.alignmentEpsilon)) {
|
|
176
235
|
const [before, after] = sortBy(left, elementBounds, bounds); // higher left-value ==> more to the right
|
|
177
236
|
helperLines.push(new HelperLine(middleLeft(before), middleRight(after), HelperLineType.Middle));
|
|
237
|
+
this.log('- Reference bounds middle align with element', elementBounds);
|
|
178
238
|
}
|
|
179
239
|
|
|
180
|
-
if (lineTypes.includes(HelperLineType.Top) && this.isAligned(top, elementBounds, bounds)) {
|
|
240
|
+
if (lineTypes.includes(HelperLineType.Top) && this.isAligned(top, elementBounds, bounds, this.alignmentEpsilon)) {
|
|
181
241
|
const [before, after] = sortBy(left, elementBounds, bounds); // higher left-value ==> more to the right
|
|
182
242
|
helperLines.push(new HelperLine(topLeft(before), topRight(after), HelperLineType.Top));
|
|
243
|
+
this.log('- Reference bounds top align with element', elementBounds);
|
|
183
244
|
}
|
|
184
245
|
|
|
185
|
-
if (lineTypes.includes(HelperLineType.LeftRight) && this.isMatch(left(elementBounds), right(bounds),
|
|
246
|
+
if (lineTypes.includes(HelperLineType.LeftRight) && this.isMatch(left(elementBounds), right(bounds), this.alignmentEpsilon)) {
|
|
186
247
|
if (isAbove(bounds, elementBounds)) {
|
|
187
248
|
helperLines.push(new HelperLine(bottomLeft(elementBounds), topRight(bounds), HelperLineType.RightLeft));
|
|
249
|
+
this.log('- Reference bounds right aligns with element left', elementBounds);
|
|
188
250
|
} else {
|
|
189
251
|
helperLines.push(new HelperLine(topLeft(elementBounds), bottomRight(bounds), HelperLineType.RightLeft));
|
|
252
|
+
this.log('- Reference bounds right aligns with element left', elementBounds);
|
|
190
253
|
}
|
|
191
254
|
}
|
|
192
255
|
|
|
193
|
-
if (lineTypes.includes(HelperLineType.LeftRight) && this.isMatch(right(elementBounds), left(bounds),
|
|
256
|
+
if (lineTypes.includes(HelperLineType.LeftRight) && this.isMatch(right(elementBounds), left(bounds), this.alignmentEpsilon)) {
|
|
194
257
|
if (isAbove(bounds, elementBounds)) {
|
|
195
258
|
helperLines.push(new HelperLine(bottomRight(elementBounds), topLeft(bounds), HelperLineType.LeftRight));
|
|
259
|
+
this.log('- Reference bounds left aligns with element right', elementBounds);
|
|
196
260
|
} else {
|
|
197
261
|
helperLines.push(new HelperLine(topRight(elementBounds), bottomLeft(bounds), HelperLineType.LeftRight));
|
|
262
|
+
this.log('- Reference bounds left aligns with element right', elementBounds);
|
|
198
263
|
}
|
|
199
264
|
}
|
|
200
265
|
|
|
201
|
-
if (lineTypes.includes(HelperLineType.TopBottom) && this.isMatch(top(elementBounds), bottom(bounds),
|
|
266
|
+
if (lineTypes.includes(HelperLineType.TopBottom) && this.isMatch(top(elementBounds), bottom(bounds), this.alignmentEpsilon)) {
|
|
202
267
|
if (isBefore(bounds, elementBounds)) {
|
|
203
268
|
helperLines.push(new HelperLine(topRight(elementBounds), bottomLeft(bounds), HelperLineType.BottomTop));
|
|
269
|
+
this.log('- Reference bounds bottom aligns with element top', elementBounds);
|
|
204
270
|
} else {
|
|
205
271
|
helperLines.push(new HelperLine(topLeft(elementBounds), bottomRight(bounds), HelperLineType.BottomTop));
|
|
272
|
+
this.log('- Reference bounds bottom aligns with element top', elementBounds);
|
|
206
273
|
}
|
|
207
274
|
}
|
|
208
275
|
|
|
209
|
-
if (lineTypes.includes(HelperLineType.TopBottom) && this.isMatch(bottom(elementBounds), top(bounds),
|
|
276
|
+
if (lineTypes.includes(HelperLineType.TopBottom) && this.isMatch(bottom(elementBounds), top(bounds), this.alignmentEpsilon)) {
|
|
210
277
|
if (isBefore(bounds, elementBounds)) {
|
|
211
278
|
helperLines.push(new HelperLine(bottomRight(elementBounds), topLeft(bounds), HelperLineType.TopBottom));
|
|
279
|
+
this.log('- Reference bounds top aligns with element bottom', elementBounds);
|
|
212
280
|
} else {
|
|
213
281
|
helperLines.push(new HelperLine(bottomLeft(elementBounds), topRight(bounds), HelperLineType.TopBottom));
|
|
282
|
+
this.log('- Reference bounds top aligns with element bottom', elementBounds);
|
|
214
283
|
}
|
|
215
284
|
}
|
|
285
|
+
if (helperLines.length > 0) {
|
|
286
|
+
this.log(`--> Add ${helperLines.length} helperlines for element:`, helperLines);
|
|
287
|
+
}
|
|
216
288
|
|
|
217
289
|
return helperLines;
|
|
218
290
|
}
|
|
219
291
|
|
|
220
|
-
protected isAligned(
|
|
221
|
-
coordinate: (elem: Bounds) => number,
|
|
222
|
-
leftBounds: Bounds,
|
|
223
|
-
rightBounds: Bounds,
|
|
224
|
-
epsilon = this.action.alignmentEpsilon ?? 1
|
|
225
|
-
): boolean {
|
|
292
|
+
protected isAligned(coordinate: (elem: Bounds) => number, leftBounds: Bounds, rightBounds: Bounds, epsilon: number): boolean {
|
|
226
293
|
return this.isMatch(coordinate(leftBounds), coordinate(rightBounds), epsilon);
|
|
227
294
|
}
|
|
228
295
|
|
|
229
|
-
protected isMatch(leftCoordinate: number, rightCoordinate: number, epsilon
|
|
296
|
+
protected isMatch(leftCoordinate: number, rightCoordinate: number, epsilon: number): boolean {
|
|
230
297
|
return Math.abs(leftCoordinate - rightCoordinate) < epsilon;
|
|
231
298
|
}
|
|
299
|
+
|
|
300
|
+
protected log(message: string, ...params: any[]): void {
|
|
301
|
+
if (this.debug) {
|
|
302
|
+
this.logger.log(this, message, params);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
232
305
|
}
|
|
233
306
|
|
|
234
307
|
export interface RemoveHelperLinesFeedbackAction extends Action {
|
|
@@ -253,6 +326,7 @@ export class RemoveHelperLinesFeedbackCommand extends FeedbackCommand {
|
|
|
253
326
|
constructor(@inject(TYPES.Action) public action: RemoveHelperLinesFeedbackAction) {
|
|
254
327
|
super();
|
|
255
328
|
}
|
|
329
|
+
|
|
256
330
|
override execute(context: CommandExecutionContext): CommandReturn {
|
|
257
331
|
removeHelperLines(context.root);
|
|
258
332
|
removeSelectionBounds(context.root);
|
|
@@ -267,3 +341,11 @@ export function removeHelperLines(root: GModelRoot): void {
|
|
|
267
341
|
export function removeSelectionBounds(root: GModelRoot): void {
|
|
268
342
|
forEachElement(root.index, isSelectionBounds, line => root.remove(line));
|
|
269
343
|
}
|
|
344
|
+
|
|
345
|
+
export function boundsInViewport(element: GModelElement, bounds: Bounds | Point): Bounds | Point {
|
|
346
|
+
if (element instanceof GChildElement && !isViewport(element.parent)) {
|
|
347
|
+
return boundsInViewport(element.parent, element.parent.localToParent(bounds) as Bounds);
|
|
348
|
+
} else {
|
|
349
|
+
return bounds;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
@@ -19,8 +19,8 @@ import {
|
|
|
19
19
|
GModelElement,
|
|
20
20
|
GModelRoot,
|
|
21
21
|
IActionHandler,
|
|
22
|
-
ISnapper,
|
|
23
22
|
MoveAction,
|
|
23
|
+
Point,
|
|
24
24
|
SetBoundsAction,
|
|
25
25
|
TYPES
|
|
26
26
|
} from '@eclipse-glsp/sprotty';
|
|
@@ -28,33 +28,81 @@ import { inject, injectable, optional, postConstruct } from 'inversify';
|
|
|
28
28
|
import { IFeedbackActionDispatcher } from '../../base/feedback/feedback-action-dispatcher';
|
|
29
29
|
import { ISelectionListener, SelectionService } from '../../base/selection-service';
|
|
30
30
|
import { SetBoundsFeedbackAction } from '../bounds/set-bounds-feedback-command';
|
|
31
|
-
import { GridSnapper } from '../change-bounds/snap';
|
|
32
31
|
import { MoveFinishedEventAction, MoveInitializedEventAction } from '../tools/change-bounds/change-bounds-tool-feedback';
|
|
33
|
-
import {
|
|
32
|
+
import {
|
|
33
|
+
AlignmentElementFilter,
|
|
34
|
+
DEFAULT_ALIGNABLE_ELEMENT_FILTER,
|
|
35
|
+
DEFAULT_DEBUG,
|
|
36
|
+
DEFAULT_ELEMENT_LINES,
|
|
37
|
+
DEFAULT_EPSILON,
|
|
38
|
+
DEFAULT_VIEWPORT_LINES,
|
|
39
|
+
DrawHelperLinesFeedbackAction,
|
|
40
|
+
RemoveHelperLinesFeedbackAction,
|
|
41
|
+
ViewportLineType
|
|
42
|
+
} from './helper-line-feedback';
|
|
34
43
|
import { IHelperLineManager } from './helper-line-manager';
|
|
35
44
|
import { Direction, HelperLineType } from './model';
|
|
36
45
|
|
|
46
|
+
export interface IHelperLineOptions {
|
|
47
|
+
/**
|
|
48
|
+
* A list of helper line types that should be rendered when elements are aligned.
|
|
49
|
+
* Defaults to all possible alignments.
|
|
50
|
+
*/
|
|
51
|
+
elementLines?: HelperLineType[];
|
|
52
|
+
/**
|
|
53
|
+
* A list of helper line types that should be rendered when an element is aligned with the viewport.
|
|
54
|
+
* Defaults to middle and center alignment.
|
|
55
|
+
*/
|
|
56
|
+
viewportLines?: ViewportLineType[];
|
|
57
|
+
/**
|
|
58
|
+
* The minimum difference between two coordinates
|
|
59
|
+
* Defaults to 1.
|
|
60
|
+
*/
|
|
61
|
+
alignmentEpsilon?: number;
|
|
62
|
+
/**
|
|
63
|
+
* A filter that is applied to determine on which elements the alignment calculation is performed.
|
|
64
|
+
* By default all top-level bounds-aware, non-routable elements that are visible on the canvas are considered.
|
|
65
|
+
*/
|
|
66
|
+
alignmentElementFilter?: AlignmentElementFilter;
|
|
67
|
+
/**
|
|
68
|
+
* The minimum move delta that is necessary for an element to break through a helper line.
|
|
69
|
+
* Defaults to { x: 1, y: 1 } whereas the x represents the horizontal distance and y represents the vertical distance.
|
|
70
|
+
*/
|
|
71
|
+
minimumMoveDelta?: Point;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Produces debug output.
|
|
75
|
+
* Defaults to false.
|
|
76
|
+
*/
|
|
77
|
+
debug?: boolean;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export const DEFAULT_MOVE_DELTA = { x: 1, y: 1 };
|
|
81
|
+
|
|
82
|
+
export const DEFAULT_HELPER_LINE_OPTIONS: Required<IHelperLineOptions> = {
|
|
83
|
+
elementLines: DEFAULT_ELEMENT_LINES,
|
|
84
|
+
viewportLines: DEFAULT_VIEWPORT_LINES,
|
|
85
|
+
alignmentEpsilon: DEFAULT_EPSILON,
|
|
86
|
+
alignmentElementFilter: DEFAULT_ALIGNABLE_ELEMENT_FILTER,
|
|
87
|
+
minimumMoveDelta: DEFAULT_MOVE_DELTA,
|
|
88
|
+
debug: DEFAULT_DEBUG
|
|
89
|
+
};
|
|
90
|
+
|
|
37
91
|
@injectable()
|
|
38
92
|
export class HelperLineManager implements IActionHandler, ISelectionListener, IHelperLineManager {
|
|
39
93
|
@inject(TYPES.IFeedbackActionDispatcher) protected feedbackDispatcher: IFeedbackActionDispatcher;
|
|
40
94
|
@inject(SelectionService) protected selectionService: SelectionService;
|
|
41
|
-
@optional() @inject(TYPES.
|
|
95
|
+
@optional() @inject(TYPES.IHelperLineOptions) protected userOptions?: IHelperLineOptions;
|
|
42
96
|
|
|
43
|
-
protected
|
|
97
|
+
protected options: Required<IHelperLineOptions>;
|
|
44
98
|
protected feedback: DisposableCollection = new DisposableCollection();
|
|
45
99
|
|
|
46
|
-
protected elementLines?: HelperLineType[];
|
|
47
|
-
protected viewportLines?: ViewportLineType[];
|
|
48
|
-
protected alignmentEpsilon?: number;
|
|
49
|
-
|
|
50
100
|
@postConstruct()
|
|
51
101
|
protected init(): void {
|
|
102
|
+
this.options = { ...DEFAULT_HELPER_LINE_OPTIONS, ...this.userOptions };
|
|
52
103
|
this.selectionService.onSelectionChanged(change =>
|
|
53
104
|
this.selectionChanged(change.root, change.selectedElements, change.deselectedElements)
|
|
54
105
|
);
|
|
55
|
-
if (this.snapper instanceof GridSnapper) {
|
|
56
|
-
this.snapSize = { x: this.snapper.grid.x * 2, y: this.snapper.grid.y * 2 };
|
|
57
|
-
}
|
|
58
106
|
}
|
|
59
107
|
|
|
60
108
|
handle(action: Action): void {
|
|
@@ -90,12 +138,7 @@ export class HelperLineManager implements IActionHandler, ISelectionListener, IH
|
|
|
90
138
|
}
|
|
91
139
|
|
|
92
140
|
protected createHelperLineFeedback(elementIds: string[]): DrawHelperLinesFeedbackAction {
|
|
93
|
-
return DrawHelperLinesFeedbackAction.create({
|
|
94
|
-
elementIds,
|
|
95
|
-
elementLines: this.elementLines,
|
|
96
|
-
viewportLines: this.viewportLines,
|
|
97
|
-
alignmentEpsilon: this.alignmentEpsilon
|
|
98
|
-
});
|
|
141
|
+
return DrawHelperLinesFeedbackAction.create({ elementIds, ...this.options });
|
|
99
142
|
}
|
|
100
143
|
|
|
101
144
|
protected handleSetBoundsAction(action: SetBoundsAction | SetBoundsFeedbackAction): void {
|
|
@@ -108,7 +151,12 @@ export class HelperLineManager implements IActionHandler, ISelectionListener, IH
|
|
|
108
151
|
this.feedback.dispose();
|
|
109
152
|
}
|
|
110
153
|
|
|
111
|
-
|
|
112
|
-
|
|
154
|
+
getMinimumMoveDelta(element: GModelElement, isSnap: boolean, direction: Direction): number {
|
|
155
|
+
if (!isSnap) {
|
|
156
|
+
return 0;
|
|
157
|
+
}
|
|
158
|
+
return direction === Direction.Left || direction === Direction.Right
|
|
159
|
+
? this.options.minimumMoveDelta.x
|
|
160
|
+
: this.options.minimumMoveDelta.y;
|
|
113
161
|
}
|
|
114
162
|
}
|
|
@@ -17,5 +17,12 @@ import { GModelElement } from '@eclipse-glsp/sprotty';
|
|
|
17
17
|
import { Direction } from './model';
|
|
18
18
|
|
|
19
19
|
export interface IHelperLineManager {
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Calculates the minimum move delta that is necessary to break through a helper line.
|
|
22
|
+
*
|
|
23
|
+
* @param element element that is being moved
|
|
24
|
+
* @param isSnap whether snapping is active or not
|
|
25
|
+
* @param direction direction in which the target element is moving
|
|
26
|
+
*/
|
|
27
|
+
getMinimumMoveDelta(element: GModelElement, isSnap: boolean, direction: Direction): number;
|
|
21
28
|
}
|
|
@@ -195,13 +195,13 @@ export class FeedbackMoveMouseListener extends DragAwareMouseListener implements
|
|
|
195
195
|
if (event.buttons === 0) {
|
|
196
196
|
this.mouseUp(target, event);
|
|
197
197
|
} else if (!this.positionUpdater.isLastDragPositionUndefined()) {
|
|
198
|
-
this.pendingMoveInitialized?.cancel();
|
|
199
198
|
if (this.elementId2startPos.size === 0) {
|
|
200
199
|
this.collectStartPositions(target.root);
|
|
201
200
|
}
|
|
202
201
|
this._isMouseDrag = true;
|
|
203
202
|
const moveAction = this.getElementMoves(target, event, false);
|
|
204
203
|
if (moveAction) {
|
|
204
|
+
this.pendingMoveInitialized?.cancel();
|
|
205
205
|
result.push(moveAction);
|
|
206
206
|
result.push(cursorFeedbackAction(CursorCSS.MOVE));
|
|
207
207
|
this.tool.registerFeedback(result, this);
|
package/src/utils/gmodel-util.ts
CHANGED
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
TypeGuard,
|
|
32
32
|
distinctAdd,
|
|
33
33
|
findParentByFeature,
|
|
34
|
+
getAbsoluteBounds,
|
|
34
35
|
isBoundsAware,
|
|
35
36
|
isMoveable,
|
|
36
37
|
isSelectable,
|
|
@@ -350,3 +351,14 @@ export function calculateDeltaBetweenPoints(target: Point, source: Point, elemen
|
|
|
350
351
|
const adaptedDelta = { x: delta.x / zoom, y: delta.y / zoom };
|
|
351
352
|
return adaptedDelta;
|
|
352
353
|
}
|
|
354
|
+
|
|
355
|
+
export function isVisibleOnCanvas(model: BoundsAwareModelElement): boolean {
|
|
356
|
+
const modelBounds = getAbsoluteBounds(model);
|
|
357
|
+
const canvasBounds = model.root.canvasBounds;
|
|
358
|
+
return (
|
|
359
|
+
modelBounds.x <= canvasBounds.width &&
|
|
360
|
+
modelBounds.x + modelBounds.width >= 0 &&
|
|
361
|
+
modelBounds.y <= canvasBounds.height &&
|
|
362
|
+
modelBounds.y + modelBounds.height >= 0
|
|
363
|
+
);
|
|
364
|
+
}
|