Browse Source

图例新增复制

jinx 2 years ago
parent
commit
255a37c92a
2 changed files with 12 additions and 1 deletions
  1. 4 0
      src/graphic/Controls/UIControl.js
  2. 8 1
      src/graphic/Service/SVGService.js

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

@@ -17,6 +17,7 @@ import { elementService } from '../Service/ElementService';
 import { lineService } from '../Service/LineService.js';
 import { circleService } from '../Service/CircleService.js';
 import { textService } from '../Service/TextService.js';
+import { svgService } from '../Service/SVGService.js';
 import { magnifierService } from '../Service/MagnifierService.js';
 import { mathUtil } from '../Util/MathUtil';
 import Constant from '../Constant';
@@ -405,6 +406,9 @@ export default class UIControl {
       case VectorType.Magnifier:
         await magnifierService.copy(vectorId);
         break;
+      case VectorType.SVG:
+        svgService.copy(vectorId);
+        break;
     }
   }
 

+ 8 - 1
src/graphic/Service/SVGService.js

@@ -1,7 +1,7 @@
 import SVG from "../Geometry/SVG.js";
 import { dataService } from "./DataService.js";
 import { mathUtil } from "../Util/MathUtil.js";
-
+import { uiService } from "./UIService.js";
 export default class SVGService {
   constructor() {}
 
@@ -10,6 +10,13 @@ export default class SVGService {
     dataService.addSVG(svg);
     return svg;
   }
+
+  copy(vectorId) {
+    let SVG = dataService.getSVG(vectorId);
+    let center = uiService.getNewPositionForPop(SVG.center);
+    let newSVG = this.create(center,SVG.type);
+    return newSVG;
+  }
 }
 
 const svgService = new SVGService();