Browse Source

修改弯路实现

bill 2 years ago
parent
commit
be069c6d68

+ 4 - 3
src/graphic/CanvasStyle/default.js

@@ -23,11 +23,12 @@ const Lane = {
 
 const CurveRoad = {
   ...Road,
+  lineWidth: 1,
 }
 
 const CurveRoadEdge = {
   ...CurveRoad,
-  ...RoadEdge
+  ...RoadEdge,
 }
 
 const CurveLan = {
@@ -65,7 +66,7 @@ const RoadPoint = {
   ...Point
 }
 
-const CurvePoint = {
+const CurveRoadPoint = {
   ...Point
 }
 
@@ -130,7 +131,7 @@ export default {
   Point,
   Tag,
   ControlPoint,
-  CurvePoint,
+  CurveRoadPoint,
   Text,
   Font: CanvasFont,
   Measure,

+ 5 - 4
src/graphic/CanvasStyle/focus.js

@@ -8,7 +8,8 @@ const Road = {
 
 const CurveRoad = {
   ...def.CurveRoad,
-  ...Road
+  ...Road,
+  lineWidth: 2,
 }
 
 const Tag = {
@@ -26,8 +27,8 @@ const RoadPoint = {
   ...Point,
 }
 
-const CurvePoint = {
-  ...def.CurvePoint,
+const CurveRoadPoint = {
+  ...def.CurveRoadPoint,
   ...Point
 }
 
@@ -55,7 +56,7 @@ export default {
   Tag,
   Point,
   RoadPoint,
-  CurvePoint,
+  CurveRoadPoint,
   ControlPoint,
   CurveRoad,
   RoadEdge,

+ 5 - 4
src/graphic/CanvasStyle/select.js

@@ -8,7 +8,8 @@ const Road = {
 
 const CurveRoad = {
   ...def.CurveRoad,
-  ...Road
+  ...Road,
+  lineWidth: 2,
 }
 
 const Tag = {
@@ -38,8 +39,8 @@ const RoadPoint = {
   ...Point
 }
 
-const CurvePoint = {
-  ...def.CurvePoint,
+const CurveRoadPoint = {
+  ...def.CurveRoadPoint,
   ...Point
 }
 
@@ -53,7 +54,7 @@ export default {
   Tag,
   Point,
   RoadPoint,
-  CurvePoint,
+  CurveRoadPoint,
   ControlPoint,
   CurveRoad,
   RoadEdge,

+ 22 - 22
src/graphic/Renderer/Draw.js

@@ -138,17 +138,10 @@ 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);
@@ -167,6 +160,12 @@ export default class Draw {
     }
 
     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
@@ -293,18 +292,19 @@ export default class Draw {
   }
 
   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));

+ 1 - 1
src/graphic/enum/LayerEvents.js

@@ -21,7 +21,7 @@ const LayerEvents = {
   MoveCurveEdge: "moveCurveEdge",
 
   MoveCurveLine: "moveCurveLine",
-  MoveLine: "moveLine",
+  // MoveLine: "moveLine",
   AddTag: "addTag",
   MoveTag: "moveTag",