|
@@ -90,23 +90,20 @@ export default class Draw {
|
|
|
drawCurveRoad(vector, isTemp) {
|
|
|
const getStyleLines = () => {
|
|
|
const styleLines = {
|
|
|
- dotted: [
|
|
|
- ...vector.leftLanes,
|
|
|
- ...vector.rightLanes
|
|
|
- ],
|
|
|
+ dotted: [...vector.leftLanes, ...vector.rightLanes],
|
|
|
solid: [
|
|
|
vector.points,
|
|
|
dataService.getCurveEdge(vector.rightEdgeId).points,
|
|
|
- dataService.getCurveEdge(vector.leftEdgeId).points
|
|
|
- ]
|
|
|
- }
|
|
|
+ dataService.getCurveEdge(vector.leftEdgeId).points,
|
|
|
+ ],
|
|
|
+ };
|
|
|
return Object.entries(styleLines).reduce((t, [key, lines]) => {
|
|
|
- t[key] = lines.map(
|
|
|
- line => line.map(point => coordinate.getScreenXY(point))
|
|
|
- )
|
|
|
+ t[key] = lines.map((line) =>
|
|
|
+ line.map((point) => coordinate.getScreenXY(point))
|
|
|
+ );
|
|
|
return t;
|
|
|
- }, {})
|
|
|
- }
|
|
|
+ }, {});
|
|
|
+ };
|
|
|
|
|
|
const draw = (points, drawPoints = false) => {
|
|
|
if (drawPoints) {
|
|
@@ -114,7 +111,7 @@ export default class Draw {
|
|
|
for (const point of points) {
|
|
|
ctx.beginPath();
|
|
|
ctx.arc(point.x, point.y, radius, 0, 2 * Math.PI);
|
|
|
- ctx.fill()
|
|
|
+ ctx.fill();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -127,42 +124,45 @@ export default class Draw {
|
|
|
curve.end.x,
|
|
|
curve.end.y,
|
|
|
curve.control.x,
|
|
|
- curve.control.y,
|
|
|
- )
|
|
|
+ curve.control.y
|
|
|
+ );
|
|
|
}
|
|
|
ctx.stroke();
|
|
|
- }
|
|
|
-
|
|
|
+ };
|
|
|
|
|
|
const ctx = this.context;
|
|
|
ctx.save();
|
|
|
|
|
|
const itemsEntry = [
|
|
|
- [stateService.getSelectItem(), 'Select'],
|
|
|
- [stateService.getDraggingItem(), 'Select'],
|
|
|
- [stateService.getFocusItem(), 'Focus']
|
|
|
- ]
|
|
|
+ [stateService.getSelectItem(), "Select"],
|
|
|
+ [stateService.getDraggingItem(), "Select"],
|
|
|
+ [stateService.getFocusItem(), "Focus"],
|
|
|
+ ];
|
|
|
const strokeStyle = itemsEntry.reduce((prev, [item, attr]) => {
|
|
|
- if (item && item.type === VectorType.Road && vector.vectorId === item.vectorId) {
|
|
|
+ if (
|
|
|
+ item &&
|
|
|
+ item.type === VectorType.Road &&
|
|
|
+ vector.vectorId === item.vectorId
|
|
|
+ ) {
|
|
|
return Style[attr].Road.strokeStyle;
|
|
|
}
|
|
|
- }, Style.Road.strokeStyle || "rgba(0,0,0,0.1)")
|
|
|
+ }, Style.Road.strokeStyle || "rgba(0,0,0,0.1)");
|
|
|
|
|
|
ctx.lineWidth = 2;
|
|
|
- ctx.lineCap = 'butt'
|
|
|
- ctx.strokeStyle = strokeStyle
|
|
|
+ ctx.lineCap = "butt";
|
|
|
+ ctx.strokeStyle = strokeStyle;
|
|
|
|
|
|
const styleLines = getStyleLines();
|
|
|
for (const style in styleLines) {
|
|
|
- const isSolid = style === 'solid';
|
|
|
+ const isSolid = style === "solid";
|
|
|
ctx.setLineDash(isSolid ? [] : [15, 15]);
|
|
|
|
|
|
- const lines = styleLines[style]
|
|
|
+ const lines = styleLines[style];
|
|
|
for (const points of lines) {
|
|
|
if (points.length < 2) {
|
|
|
break;
|
|
|
}
|
|
|
- draw(points, true)
|
|
|
+ draw(points, true);
|
|
|
}
|
|
|
}
|
|
|
ctx.restore();
|
|
@@ -963,6 +963,27 @@ export default class Draw {
|
|
|
// this.context.restore();
|
|
|
}
|
|
|
|
|
|
+ drawTestLine(start, end, hit) {
|
|
|
+ this.context.save();
|
|
|
+
|
|
|
+ this.context.strokeStyle = "blue";
|
|
|
+ this.context.beginPath();
|
|
|
+ this.context.moveTo(start.x, start.y);
|
|
|
+ this.context.lineTo(end.x, end.y);
|
|
|
+ this.context.stroke();
|
|
|
+
|
|
|
+ this.context.beginPath();
|
|
|
+ this.context.arc(start.x, start.y, Constant.minAdsorbPix, 0, 2 * Math.PI);
|
|
|
+ if (!hit) {
|
|
|
+ this.context.fillStyle = "black";
|
|
|
+ } else {
|
|
|
+ this.context.fillStyle = "red";
|
|
|
+ }
|
|
|
+ this.context.fill();
|
|
|
+
|
|
|
+ this.context.restore();
|
|
|
+ }
|
|
|
+
|
|
|
//由多个点构成,里面的坐标都已经是屏幕坐标
|
|
|
drawMeasure(points, dir, styleType) {
|
|
|
this.context.save();
|