Browse Source

添加完图例

xushiting 2 years ago
parent
commit
87091ca611
3 changed files with 28 additions and 19 deletions
  1. 14 13
      src/graphic/Controls/MoveSVG.js
  2. 13 5
      src/graphic/Geometry/SVG.js
  3. 1 1
      src/graphic/Renderer/Draw.js

+ 14 - 13
src/graphic/Controls/MoveSVG.js

@@ -10,19 +10,6 @@ export default class MoveSVG {
     svg.setBoundingVertexs();
   }
 
-  movePoint(position, svgId, pointIndex) {
-    let svg = dataService.getSVG(svgId);
-    const rec = svg.getLengthWidth();
-    const scale = svg.getScale();
-    const side1 = Math.sqrt(
-      Math.pow((rec.width / 2) * scale, 2) +
-        Math.pow((rec.length / 2) * scale, 2)
-    );
-    const side2 = mathUtil.getDistance(position, svg.center);
-    svg.scale = (side2 / side1) * scale;
-    svg.setBoundingVertexs();
-  }
-
   // movePoint(position, svgId, pointIndex) {
   //   let svg = dataService.getSVG(svgId);
   //   const rec = svg.getLengthWidth();
@@ -35,6 +22,20 @@ export default class MoveSVG {
   //   svg.scale = (side2 / side1) * scale;
   //   svg.setBoundingVertexs();
   // }
+
+  movePoint(position, svgId, pointIndex) {
+    let svg = dataService.getSVG(svgId);
+    const rec = svg.getLengthWidth();
+    const scale = svg.getScale();
+    const side1 = Math.sqrt(
+      Math.pow((rec.width / 2) * scale, 2) +
+        Math.pow((rec.length / 2) * scale, 2)
+    );
+
+    svg.setBoundingVertexs2(position, pointIndex);
+    const side2 = mathUtil.getDistance(position, svg.center);
+    svg.scale = (side2 / side1) * scale;
+  }
 }
 
 const moveSVG = new MoveSVG();

+ 13 - 5
src/graphic/Geometry/SVG.js

@@ -91,11 +91,19 @@ export default class SVG extends Geometry {
     this.points.push(point4);
   }
 
-  // setBoundingVertexs2(position, pointIndex) {
-  //   mathUtil.clonePoint(this.points[pointIndex], position);
-  //   // 【注意】angle 逆时针为正,顺时针为负
-  //   this.points[pointIndex] = this.rotatePoint(position, this.center, 90);
-  // }
+  setBoundingVertexs2(position, pointIndex) {
+    if (mathUtil.getDistance(position, this.center) < Constant.minAdsorbPix) {
+      return;
+    }
+    mathUtil.clonePoint(this.points[pointIndex], position);
+    // 【注意】angle 逆时针为正,顺时针为负
+    let nextIndex = this.getNextIndex(pointIndex);
+    this.points[nextIndex] = this.rotatePoint(position, this.center, 90);
+    nextIndex = this.getNextIndex(nextIndex);
+    this.points[nextIndex] = this.rotatePoint(position, this.center, 180);
+    nextIndex = this.getNextIndex(nextIndex);
+    this.points[nextIndex] = this.rotatePoint(position, this.center, 270);
+  }
 
   getNextIndex(index) {
     let nextIndex = index + 1;

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

@@ -614,7 +614,7 @@ export default class Draw {
       ...element,
       // radius: help.getReal(element.radius),
       radius: (element.radius * coordinate.zoom) / coordinate.defaultZoom,
-      geoType: "Circle",
+      geoType: VectorType.Circle,
       ...element.center,
     });