Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/master'

bill 2 gadi atpakaļ
vecāks
revīzija
89d82e6adc

+ 3 - 0
src/graphic/Controls/MoveMagnifier.js

@@ -6,6 +6,9 @@ export default class MoveMagnifier {
 
   moveFullMagnifier(position, magnifierId, index) {
     let magnifier = dataService.getMagnifier(magnifierId);
+    //移动放大镜清除图片信息
+    magnifier.setPhotoUrl(null)
+    magnifier.setPhotoImg(null)
     if (index == 0) {
       magnifier.setPosition(position);
     } else {

+ 2 - 2
src/graphic/Controls/MovePoint.js

@@ -17,7 +17,6 @@ export default class MovePoint {
     if (point.getCategory() == VectorCategory.Point.TestPoint) {
       this.updatePositionByTestPoint(pointId);
     } else if (point.getCategory() == VectorCategory.Point.BasePoint) {
-
       this.updateBasePoint(pointId);
     } else {
       let parent = point.getParent();
@@ -77,7 +76,6 @@ export default class MovePoint {
       ) {
         pointService.mergePoint(pointId, listenLayer.modifyPoint.linkedPointId);
         Settings.selectBasePointId = null;
-
       } else {
         let point = dataService.getPoint(pointId);
         const parent = point.getParent();
@@ -232,7 +230,9 @@ export default class MovePoint {
 
   moveCurvePoint(position, curvePointId) {
     let curvePoint = dataService.getCurvePoint(curvePointId);
+    let curveLine = dataService.getCurveLine(curvePoint.getParent());
     curvePoint.setPosition(position);
+    curveLine.curves = mathUtil.getCurvesByPoints(curveLine.points);
   }
 }
 

+ 2 - 0
src/graphic/Controls/UIControl.js

@@ -353,6 +353,7 @@ export default class UIControl {
         }
         break;
       case VectorType.CurveLine:
+        dataService.deleteCurveLine(vectorId);
         break;
       case VectorType.Circle:
         dataService.deleteCircle(vectorId);
@@ -387,6 +388,7 @@ export default class UIControl {
         lineService.copy(vectorId);
         break;
       case VectorType.CurveLine:
+        lineService.copyCurveLine(vectorId);
         break;
       case VectorType.Circle:
         circleService.copy(vectorId);

+ 6 - 1
src/graphic/Geometry/Geometry.js

@@ -110,7 +110,12 @@ export default class Geometry {
   setWeight(weight) {
     this.weight = weight;
   }
-
+  setPhotoUrl(src) {
+    this.photoUrl = src;
+  }
+  setPhotoImg(type) {
+    this.photoImage = type;
+  }
   getType() {
     return this.type;
   }

+ 36 - 7
src/graphic/Service/LineService.js

@@ -112,14 +112,15 @@ export default class LineService {
       vectorId
     );
 
-    startPoint.setPointParent(curveLine.vectorId, "start");
+    startPoint.setPointParent(curveLine.vectorId);
     startPoint.setIndex(0);
-    endPoint.setPointParent(curveLine.vectorId, "end");
+    endPoint.setPointParent(curveLine.vectorId);
     endPoint.setIndex(2);
     let midPoint = curvePointService.create({
       x: (startPoint.x + endPoint.x) / 2,
       y: (startPoint.y + endPoint.y) / 2,
     });
+    midPoint.setPointParent(curveLine.vectorId);
     midPoint.setIndex(1);
     curveLine.points = [];
     curveLine.points.push(startPoint);
@@ -134,6 +135,7 @@ export default class LineService {
     let curvePoints = [];
     for (let i = 0; i < points.length; ++i) {
       let curvePoint = curvePointService.create(points[i]);
+      curvePoint.setIndex(i);
       curvePoints.push(curvePoint);
     }
     let curveLine = new CurveLine(
@@ -141,12 +143,11 @@ export default class LineService {
       curvePoints[curvePoints.length - 1].vectorId,
       vectorId
     );
-    curvePoints[0].setPointParent(curveLine.vectorId, "start");
-    curvePoints[curvePoints.length - 1].setPointParent(
-      curveLine.vectorId,
-      "end"
-    );
     curveLine.points = JSON.parse(JSON.stringify(curvePoints));
+    for (let i = 0; i < curveLine.points.length; ++i) {
+      curveLine.points[i].setIndex(i);
+      curveLine.points[i].setPointParent(curveLine.vectorId);
+    }
     curveLine.curves = mathUtil.getCurvesByPoints(curveLine.points);
     dataService.addCurveLine(curveLine);
     return curveLine;
@@ -156,9 +157,37 @@ export default class LineService {
     let curveLine = dataService.getCurveLine(vectorId);
     let newPoint = curvePointService.create(position);
     newPoint.setIndex(index);
+    newPoint.setPointParent(vectorId);
     curveLine.points.splice(index + 1, 0, newPoint);
     curveLine.curves = mathUtil.getCurvesByPoints(curveLine.points);
   }
+
+  copyCurveLine(vectorId) {
+    let curveLine = dataService.getCurveLine(vectorId);
+    let startPoint = dataService.getCurvePoint(curveLine.startId);
+    let endPoint = dataService.getCurvePoint(curveLine.endId);
+    startPoint = uiService.getNewPositionForPop(startPoint);
+    endPoint = uiService.getNewPositionForPop(endPoint);
+
+    let newCurveLine = this.createCurveLine(startPoint, endPoint);
+    newCurveLine.setColor(curveLine.color);
+    if (curveLine.weight) {
+      newCurveLine.setWeight(curveLine.weight);
+    }
+    if (curveLine.style) {
+      newCurveLine.setStyle(curveLine.style);
+    }
+    mathUtil.clonePoint(newCurveLine.points[1], curveLine.points[1]);
+    for (let i = 2; i < curveLine.points.length - 1; ++i) {
+      let newPoint = uiService.getNewPositionForPop(curveLine.points[i]);
+      newPoint = curvePointService.create(newPoint);
+      newPoint.setPointParent(vectorId);
+      newPoint.setIndex(i);
+      newCurveLine.points.splice(i + 1, 0, newPoint);
+    }
+    newCurveLine.curves = mathUtil.getCurvesByPoints(newCurveLine.points);
+    return newCurveLine;
+  }
 }
 
 const lineService = new LineService();