浏览代码

添加开发环境测试信息

bill 2 年之前
父节点
当前提交
009dcfc0ec
共有 1 个文件被更改,包括 34 次插入10 次删除
  1. 34 10
      src/graphic/Renderer/Draw.js

+ 34 - 10
src/graphic/Renderer/Draw.js

@@ -41,7 +41,7 @@ const help = {
       ctx[style] = styles[style];
     }
   },
-  getLinesCoves(lines) {
+  transformCoves(lines) {
     return lines
       .map(line => line.map(line => ({
         start: coordinate.getScreenXY(line.start),
@@ -124,7 +124,7 @@ export default class Draw {
       ctx.restore();
     }
 
-    if (!isTemp) {
+    if (import.meta.env.DEV && !isTemp) {
       this.drawText(
         { x: (startReal.x + endReal.x) / 2, y: (startReal.y + endReal.y) / 2 },
         vector.vectorId
@@ -147,6 +147,11 @@ export default class Draw {
     ctx.lineTo(end.x, end.y)
     ctx.stroke();
     ctx.restore();
+
+    if (import.meta.env.DEV) {
+      this.drawPoint(lan.start)
+      this.drawPoint(lan.end)
+    }
   }
 
   drawEdge(vector, isTemp) {
@@ -188,6 +193,13 @@ export default class Draw {
     drawEdgeChild(leftEdge)
     drawEdgeChild(rightEdge)
     ctx.restore()
+
+    if (import.meta.env.DEV) {
+      this.drawPoint(leftEdge.start)
+      this.drawPoint(leftEdge.end)
+      this.drawPoint(rightEdge.start)
+      this.drawPoint(rightEdge.end)
+    }
   }
 
   drawControlPoint(vector) {
@@ -234,7 +246,7 @@ export default class Draw {
   }
 
   drawCurveRoad(vector) {
-    const [coves] = help.getLinesCoves([vector.curves])
+    const [coves] = help.transformCoves([vector.curves])
     const ctx = this.context;
     ctx.save();
 
@@ -247,29 +259,39 @@ export default class Draw {
     vector.leftLanesCurves && vector.leftLanesCurves.forEach(this.drawCurveLan.bind(this))
     vector.rightLanesCurves && vector.rightLanesCurves.forEach(this.drawCurveLan.bind(this))
 
-    vector.points.forEach(this.drawPoint.bind(this))
+    if (import.meta.env.DEV) {
+      vector.points.forEach(this.drawPoint.bind(this))
+    }
   }
 
   drawCurveEdge(vector, isTemp) {
-    const [coves] = help.getLinesCoves([vector.curves])
-
+    const [coves] = help.transformCoves([vector.curves])
     const ctx = this.context;
     ctx.save();
     help.setVectorStyle(ctx, vector)
     help.drawCoves(ctx, coves);
     this.context.restore();
 
-    vector.points.forEach(this.drawPoint.bind(this))
+    if (import.meta.env.DEV) {
+      vector.points.forEach(this.drawPoint.bind(this))
+    }
   }
 
   drawCurveLan(lines) {
-    const [coves] = help.getLinesCoves([lines])
+    const [coves] = help.transformCoves([lines])
     const ctx = this.context;
     ctx.save();
     help.setVectorStyle(ctx, null, "CurveLan")
     ctx.setLineDash(Style.Lane.dash);
     help.drawCoves(ctx, coves);
     this.context.restore();
+
+    if (import.meta.env.DEV) {
+      lines.map(line => {
+        this.drawPoint(line.start)
+        this.drawPoint(line.end)
+      })
+    }
   }
 
 
@@ -291,8 +313,10 @@ export default class Draw {
     ctx.fill();
     ctx.restore();
 
-    if (vector.vectorId) {
-      this.drawText(vector, vector.vectorId);
+    if (import.meta.env.DEV) {
+      if (vector.vectorId) {
+        this.drawText(vector, vector.vectorId);
+      }
     }
   }