|
@@ -138,35 +138,34 @@ export default class Draw {
|
|
|
}
|
|
|
|
|
|
drawRoad(vector, isTemp) {
|
|
|
- const startReal = isTemp
|
|
|
- ? vector.start
|
|
|
- : dataService.getRoadPoint(vector.startId);
|
|
|
- const endReal = isTemp
|
|
|
- ? vector.end
|
|
|
- : dataService.getRoadPoint(vector.endId);
|
|
|
-
|
|
|
- if (vector?.midDivide?.display && vector?.midDivideWidth) {
|
|
|
+ if (vector.display && vector.midDivide && vector?.midDivideWidth) {
|
|
|
const ctx = this.context;
|
|
|
- const startScreen = coordinate.getScreenXY(startReal);
|
|
|
- const endScreen = coordinate.getScreenXY(endReal);
|
|
|
+ const startScreen = coordinate.getScreenXY(vector.midDivide.start);
|
|
|
+ const endScreen = coordinate.getScreenXY(vector.midDivide.end);
|
|
|
const draw = () => {
|
|
|
ctx.beginPath();
|
|
|
ctx.moveTo(startScreen.x, startScreen.y);
|
|
|
ctx.lineTo(endScreen.x, endScreen.y);
|
|
|
ctx.stroke();
|
|
|
- };
|
|
|
+ }
|
|
|
|
|
|
ctx.save();
|
|
|
const vectorStyle = help.setVectorStyle(ctx, vector);
|
|
|
- ctx.lineWidth = vector.midDivideWidth;
|
|
|
- draw();
|
|
|
- ctx.strokeStyle = Style.bgColor;
|
|
|
- ctx.lineWidth = vector.midDivideWidth - vectorStyle.realLineWidth;
|
|
|
- draw();
|
|
|
+ ctx.lineWidth = vector.midDivideWidth
|
|
|
+ draw()
|
|
|
+ ctx.strokeStyle = Style.bgColor
|
|
|
+ ctx.lineWidth = vector.midDivideWidth - vectorStyle.realLineWidth
|
|
|
+ draw()
|
|
|
ctx.restore();
|
|
|
}
|
|
|
|
|
|
if (import.meta.env.DEV && !isTemp) {
|
|
|
+ const startReal = isTemp
|
|
|
+ ? vector.start
|
|
|
+ : dataService.getRoadPoint(vector.startId);
|
|
|
+ const endReal = isTemp
|
|
|
+ ? vector.end
|
|
|
+ : dataService.getRoadPoint(vector.endId);
|
|
|
this.drawText(
|
|
|
{ x: (startReal.x + endReal.x) / 2, y: (startReal.y + endReal.y) / 2 },
|
|
|
vector.vectorId
|
|
@@ -253,14 +252,10 @@ export default class Draw {
|
|
|
|
|
|
drawControlPoint(vector) {
|
|
|
const start = coordinate.getScreenXY(
|
|
|
- dataService
|
|
|
- .getRoadEdge(vector.edgeInfo1.id)
|
|
|
- .getPosition(vector.edgeInfo1.dir)
|
|
|
+ dataService.getRoadEdge(vector.edgeInfo1.id).getPosition(vector.edgeInfo1.dir)
|
|
|
);
|
|
|
const end = coordinate.getScreenXY(
|
|
|
- dataService
|
|
|
- .getRoadEdge(vector.edgeInfo2.id)
|
|
|
- .getPosition(vector.edgeInfo2.dir)
|
|
|
+ dataService.getRoadEdge(vector.edgeInfo2.id).getPosition(vector.edgeInfo2.dir)
|
|
|
);
|
|
|
const pt2 = this.twoOrderBezier(
|
|
|
0.5,
|
|
@@ -293,21 +288,23 @@ export default class Draw {
|
|
|
ctx.quadraticCurveTo(pt.x, pt.y, end.x, end.y);
|
|
|
ctx.stroke();
|
|
|
ctx.restore();
|
|
|
+
|
|
|
}
|
|
|
|
|
|
drawCurveRoad(vector) {
|
|
|
- console.log(vector);
|
|
|
- const [coves] = help.transformCoves([vector.curves]);
|
|
|
- const ctx = this.context;
|
|
|
-
|
|
|
- ctx.save();
|
|
|
- const vectorStyle = help.setVectorStyle(ctx, vector);
|
|
|
- ctx.lineWidth = vector?.midDivideWidth || vectorStyle.lineWidth;
|
|
|
- help.drawCoves(ctx, coves);
|
|
|
- ctx.lineWidth = ctx.lineWidth - vectorStyle.realLineWidth;
|
|
|
- ctx.strokeStyle = Style.bgColor;
|
|
|
- help.drawCoves(ctx, coves);
|
|
|
- ctx.restore();
|
|
|
+ if (vector.display && vector.midDivide) {
|
|
|
+ const covesArray = help.transformCoves([
|
|
|
+ vector.midDivide.leftMidDivideCurves,
|
|
|
+ vector.midDivide.rightMidDivideCurves
|
|
|
+ ]);
|
|
|
+ const ctx = this.context;
|
|
|
+ ctx.save();
|
|
|
+ help.setVectorStyle(ctx, vector);
|
|
|
+ for (let coves of covesArray) {
|
|
|
+ help.drawCoves(ctx, coves);
|
|
|
+ }
|
|
|
+ ctx.restore();
|
|
|
+ }
|
|
|
|
|
|
this.drawCurveRoadEdge(dataService.getCurveRoadEdge(vector.rightEdgeId));
|
|
|
this.drawCurveRoadEdge(dataService.getCurveRoadEdge(vector.leftEdgeId));
|
|
@@ -353,12 +350,14 @@ export default class Draw {
|
|
|
}
|
|
|
|
|
|
drawRoadPoint(vector) {
|
|
|
- this.drawPoint(vector);
|
|
|
+ this.drawPoint(vector)
|
|
|
}
|
|
|
drawPoint(vector) {
|
|
|
const pt = coordinate.getScreenXY({ x: vector.x, y: vector.y });
|
|
|
const ctx = this.context;
|
|
|
- const draw = () => {};
|
|
|
+ const draw = () => {
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
help.setVectorStyle(ctx, vector, vector.geoType || "Point");
|
|
|
ctx.beginPath();
|
|
@@ -422,7 +421,7 @@ export default class Draw {
|
|
|
drawText(position, txt, angle) {
|
|
|
const ctx = this.context;
|
|
|
ctx.save();
|
|
|
- help.setVectorStyle(ctx, null, "Text");
|
|
|
+ help.setVectorStyle(ctx, null,"Text");
|
|
|
|
|
|
const pt = coordinate.getScreenXY(position);
|
|
|
if (angle) {
|
|
@@ -435,56 +434,56 @@ export default class Draw {
|
|
|
ctx.restore();
|
|
|
}
|
|
|
|
|
|
- drawText(geometry, styleType, hide) {
|
|
|
+ drawTag(geometry, styleType, hide) {
|
|
|
this.context.save();
|
|
|
|
|
|
- this.context.lineWidth = Style.Text.lineWidth * coordinate.ratio;
|
|
|
- this.context.strokeStyle = Style.Text.strokeStyle;
|
|
|
- this.context.fillStyle = Style.Text.fillStyle;
|
|
|
+ this.context.lineWidth = Style.Tag.lineWidth * coordinate.ratio;
|
|
|
+ this.context.strokeStyle = Style.Tag.strokeStyle;
|
|
|
+ this.context.fillStyle = Style.Tag.fillStyle;
|
|
|
|
|
|
if (styleType) {
|
|
|
if (styleType == "style-1") {
|
|
|
this.context.lineWidth =
|
|
|
- Style.DownLoad.style1.Text.lineWidth * coordinate.ratio;
|
|
|
- this.context.strokeStyle = Style.DownLoad.style1.Text.strokeStyle;
|
|
|
- this.context.fillStyle = Style.DownLoad.style1.Text.fillStyle;
|
|
|
+ Style.DownLoad.style1.Tag.lineWidth * coordinate.ratio;
|
|
|
+ this.context.strokeStyle = Style.DownLoad.style1.Tag.strokeStyle;
|
|
|
+ this.context.fillStyle = Style.DownLoad.style1.Tag.fillStyle;
|
|
|
} else if (styleType == "style-2") {
|
|
|
this.context.lineWidth =
|
|
|
- Style.DownLoad.style2.Text.lineWidth * coordinate.ratio;
|
|
|
- this.context.strokeStyle = Style.DownLoad.style2.Text.strokeStyle;
|
|
|
- this.context.fillStyle = Style.DownLoad.style2.Text.fillStyle;
|
|
|
+ Style.DownLoad.style2.Tag.lineWidth * coordinate.ratio;
|
|
|
+ this.context.strokeStyle = Style.DownLoad.style2.Tag.strokeStyle;
|
|
|
+ this.context.fillStyle = Style.DownLoad.style2.Tag.fillStyle;
|
|
|
} else if (styleType == "style-3") {
|
|
|
this.context.lineWidth =
|
|
|
- Style.DownLoad.style3.Text.lineWidth * coordinate.ratio;
|
|
|
- this.context.strokeStyle = Style.DownLoad.style3.Text.strokeStyle;
|
|
|
- this.context.fillStyle = Style.DownLoad.style3.Text.fillStyle;
|
|
|
+ Style.DownLoad.style3.Tag.lineWidth * coordinate.ratio;
|
|
|
+ this.context.strokeStyle = Style.DownLoad.style3.Tag.strokeStyle;
|
|
|
+ this.context.fillStyle = Style.DownLoad.style3.Tag.fillStyle;
|
|
|
} else if (styleType == "style-4") {
|
|
|
this.context.lineWidth =
|
|
|
- Style.DownLoad.style4.Text.lineWidth * coordinate.ratio;
|
|
|
- this.context.strokeStyle = Style.DownLoad.style4.Text.strokeStyle;
|
|
|
- this.context.fillStyle = Style.DownLoad.style4.Text.fillStyle;
|
|
|
+ Style.DownLoad.style4.Tag.lineWidth * coordinate.ratio;
|
|
|
+ this.context.strokeStyle = Style.DownLoad.style4.Tag.strokeStyle;
|
|
|
+ this.context.fillStyle = Style.DownLoad.style4.Tag.fillStyle;
|
|
|
}
|
|
|
} else {
|
|
|
const selectItem = stateService.getSelectItem();
|
|
|
const draggingItem = stateService.getDraggingItem();
|
|
|
const focusItem = stateService.getFocusItem();
|
|
|
|
|
|
- if (selectItem && selectItem.type == VectorType.Text) {
|
|
|
+ if (selectItem && selectItem.type == VectorType.Tag) {
|
|
|
if (geometry.vectorId == selectItem.vectorId) {
|
|
|
- this.context.strokeStyle = Style.Select.Text.strokeStyle;
|
|
|
- this.context.fillStyle = Style.Select.Text.fillStyle;
|
|
|
+ this.context.strokeStyle = Style.Select.Tag.strokeStyle;
|
|
|
+ this.context.fillStyle = Style.Select.Tag.fillStyle;
|
|
|
}
|
|
|
- } else if (draggingItem && draggingItem.type == VectorType.Text) {
|
|
|
+ } else if (draggingItem && draggingItem.type == VectorType.Tag) {
|
|
|
if (geometry.vectorId == draggingItem.vectorId) {
|
|
|
- this.context.strokeStyle = Style.Select.Text.strokeStyle;
|
|
|
- this.context.fillStyle = Style.Select.Text.fillStyle;
|
|
|
+ this.context.strokeStyle = Style.Select.Tag.strokeStyle;
|
|
|
+ this.context.fillStyle = Style.Select.Tag.fillStyle;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (focusItem && focusItem.type == VectorType.Text) {
|
|
|
+ if (focusItem && focusItem.type == VectorType.Tag) {
|
|
|
if (geometry.vectorId == focusItem.vectorId) {
|
|
|
- this.context.strokeStyle = Style.Focus.Text.strokeStyle;
|
|
|
- this.context.fillStyle = Style.Focus.Text.fillStyle;
|
|
|
+ this.context.strokeStyle = Style.Focus.Tag.strokeStyle;
|
|
|
+ this.context.fillStyle = Style.Focus.Tag.fillStyle;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -500,8 +499,8 @@ export default class Draw {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- this.context.strokeStyle = Style.Text.strokeStyle_adding;
|
|
|
- this.context.fillStyle = Style.Text.fillStyle_adding;
|
|
|
+ this.context.strokeStyle = Style.Tag.strokeStyle_adding;
|
|
|
+ this.context.fillStyle = Style.Tag.fillStyle_adding;
|
|
|
this.context.beginPath();
|
|
|
this.context.moveTo(points[0].x, points[0].y);
|
|
|
this.context.lineTo(points[1].x, points[1].y);
|