ソースを参照

继续修复bug

xushiting 2 年 前
コミット
117fd4e782
3 ファイル変更35 行追加2 行削除
  1. 20 0
      src/graphic/Layer.js
  2. 5 0
      src/graphic/Renderer/Render.js
  3. 10 2
      src/graphic/Service/LineService.js

+ 20 - 0
src/graphic/Layer.js

@@ -319,6 +319,26 @@ export default class Layer {
             mathUtil.clonePoint(curveLine.points[1], position);
             curveLine.curves = mathUtil.getCurvesByPoints(curveLine.points);
           } else if (focusItem.type == VectorType.CurveLine) {
+            let curveLine = dataService.getCurveLine(focusItem.vectorId);
+            let index = mathUtil.getIndexForCurvesPoints(
+              position,
+              curveLine.points
+            );
+            if (index != -1) {
+              lineService.addCPoint(position, index, focusItem.vectorId);
+            } else {
+              const dis1 = mathUtil.getDistance(curveLine.points[0], position);
+              const dis2 = mathUtil.getDistance(
+                curveLine.points[curveLine.points.length - 1],
+                position
+              );
+              if (dis1 > dis2) {
+                index = curveLine.points.length - 2;
+              } else {
+                index = 1;
+              }
+              lineService.addCPoint(position, index, focusItem.vectorId);
+            }
           }
 
           stateService.clearEventName();

+ 5 - 0
src/graphic/Renderer/Render.js

@@ -157,6 +157,11 @@ export default class Render {
       this.drawGeometry(lines[key]);
     }
 
+    const curveLines = dataService.getCurveLines();
+    for (const key in curveLines) {
+      this.drawGeometry(curveLines[key]);
+    }
+
     const circles = dataService.getCircles();
     for (const key in circles) {
       this.drawGeometry(circles[key]);

+ 10 - 2
src/graphic/Service/LineService.js

@@ -72,10 +72,10 @@ export default class LineService {
     endPoint = uiService.getNewPositionForPop(endPoint);
     let newLine = this.create(startPoint, endPoint, line.category);
     newLine.setColor(line.color);
-    if(line.weight){
+    if (line.weight) {
       newLine.setWeight(line.weight);
     }
-    if(line.style){
+    if (line.style) {
       newLine.setStyle(line.style);
     }
     return newLine;
@@ -151,6 +151,14 @@ export default class LineService {
     dataService.addCurveLine(curveLine);
     return curveLine;
   }
+
+  addCPoint(position, index, vectorId) {
+    let curveLine = dataService.getCurveLine(vectorId);
+    let newPoint = curvePointService.create(position);
+    newPoint.setIndex(index);
+    curveLine.points.splice(index + 1, 0, newPoint);
+    curveLine.curves = mathUtil.getCurvesByPoints(curveLine.points);
+  }
 }
 
 const lineService = new LineService();