2019-11-29 12:51:58 +08:00
|
|
|
import Path from 'zrender/src/graphic/Path';
|
|
|
|
|
|
|
|
/** 指向箭头坐标*/
|
|
|
|
export function arrow(modelX, modelY, length, radius) {
|
2021-01-07 15:15:54 +08:00
|
|
|
return [
|
|
|
|
[modelX - length, modelY],
|
|
|
|
[modelX - length + radius / 1.5, modelY - radius / 1.2],
|
|
|
|
[modelX - length + radius / 1.5, modelY - radius / 3],
|
|
|
|
[modelX + length, modelY - radius / 3],
|
|
|
|
[modelX + length, modelY + radius / 3],
|
|
|
|
[modelX - length + radius / 1.5, modelY + radius / 3],
|
|
|
|
[modelX - length + radius / 1.5, modelY + radius / 1.2]
|
|
|
|
];
|
2019-11-29 12:51:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/** 指向三角形坐标*/
|
|
|
|
export function triangular(modelX, modelY, drict, radius) {
|
2021-01-07 15:15:54 +08:00
|
|
|
return [
|
|
|
|
[modelX, modelY],
|
|
|
|
[modelX - drict * (radius + 2), modelY - radius],
|
|
|
|
[modelX - drict * (radius + 2), modelY + radius]
|
|
|
|
];
|
2019-11-29 12:51:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/** 屏蔽门手电筒*/
|
|
|
|
export function flashlight(modelX, modelY, drict, width, height, offsetx, offsety, beyond) {
|
2021-01-07 15:15:54 +08:00
|
|
|
return [
|
|
|
|
[modelX + drict * (offsetx), modelY + drict * offsety - (height + beyond) / 2],
|
|
|
|
[modelX + drict * (offsetx + beyond), modelY + drict * offsety - height / 2],
|
|
|
|
[modelX + drict * (offsetx + beyond + width), modelY + drict * offsety - height / 2],
|
|
|
|
[modelX + drict * (offsetx + beyond + width), modelY + drict * offsety + height / 2],
|
|
|
|
[modelX + drict * (offsetx + beyond), modelY + drict * offsety + height / 2],
|
|
|
|
[modelX + drict * (offsetx), modelY + drict * offsety + (height + beyond) / 2]
|
|
|
|
];
|
2019-11-29 12:51:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/** 区段限速体带方向*/
|
|
|
|
export function limitArrows(modelX, modelY, drict, radius) {
|
2021-01-07 15:15:54 +08:00
|
|
|
return [
|
|
|
|
[modelX + drict * radius, modelY - radius],
|
|
|
|
[modelX + drict * radius, modelY + radius],
|
|
|
|
[modelX - drict * radius, modelY + radius],
|
|
|
|
[modelX - drict * radius * 1.8, modelY],
|
|
|
|
[modelX - drict * radius, modelY - radius]
|
|
|
|
];
|
2019-11-29 12:51:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/** 区段折返标记*/
|
|
|
|
export function turnbackArrows(modelX, modelY, drict, width, height) {
|
2021-01-07 15:15:54 +08:00
|
|
|
return [
|
|
|
|
[modelX - drict * (width - 1), modelY + height],
|
|
|
|
[modelX + drict * width / 2, modelY + height],
|
|
|
|
[modelX + drict * width / 2, modelY - height],
|
|
|
|
[modelX - drict * (width - 3), modelY - height]
|
|
|
|
];
|
2019-11-29 12:51:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export const Ugraph = Path.extend({
|
2021-01-07 15:15:54 +08:00
|
|
|
type: 'ugraph',
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2021-01-07 15:15:54 +08:00
|
|
|
shape: {
|
|
|
|
points: null,
|
|
|
|
counterclockwise: true
|
|
|
|
},
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2021-01-07 15:15:54 +08:00
|
|
|
style: {
|
|
|
|
stroke: '#000',
|
|
|
|
fill: null
|
|
|
|
},
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2021-01-07 15:15:54 +08:00
|
|
|
buildPath: function (ctx, shape) {
|
|
|
|
var points = shape.points;
|
|
|
|
var r = Math.abs(points[1][1] - points[2][1]) / 2;
|
|
|
|
var x = Math.abs(points[1][0] + points[2][0]) / 2;
|
|
|
|
var y = Math.abs(points[1][1] + points[2][1]) / 2;
|
|
|
|
ctx.moveTo(points[0][0], points[0][1]);
|
|
|
|
ctx.lineTo(points[1][0], points[1][1]);
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2021-01-07 15:15:54 +08:00
|
|
|
shape.counterclockwise && ctx.arc(x, y, r, Math.PI / 2, Math.PI * 3 / 2, false);
|
|
|
|
shape.counterclockwise || ctx.arc(x, y, r, Math.PI / 2, -Math.PI / 2, true);
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2021-01-07 15:15:54 +08:00
|
|
|
ctx.moveTo(points[2][0], points[2][1]);
|
|
|
|
ctx.lineTo(points[3][0], points[3][1]);
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2021-01-07 15:15:54 +08:00
|
|
|
ctx.closePath();
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2021-01-07 15:15:54 +08:00
|
|
|
points = shape.points;
|
|
|
|
r = Math.abs(points[1][1] - points[2][1]) / 2;
|
|
|
|
x = Math.abs(points[1][0] + points[2][0]) / 2;
|
|
|
|
y = Math.abs(points[1][1] + points[2][1]) / 2;
|
|
|
|
ctx.moveTo(points[0][0], points[0][1]);
|
|
|
|
ctx.lineTo(points[1][0], points[1][1]);
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2021-01-07 15:15:54 +08:00
|
|
|
shape.counterclockwise && ctx.arc(x, y, r, Math.PI / 2, Math.PI * 3 / 2, false);
|
|
|
|
shape.counterclockwise || ctx.arc(x, y, r, Math.PI / 2, -Math.PI / 2, true);
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2021-01-07 15:15:54 +08:00
|
|
|
ctx.moveTo(points[2][0], points[2][1]);
|
|
|
|
ctx.lineTo(points[3][0], points[3][1]);
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2021-01-07 15:15:54 +08:00
|
|
|
ctx.closePath();
|
|
|
|
}
|
2019-11-29 12:51:58 +08:00
|
|
|
});
|