Procházet zdrojové kódy

feat: 放大镜问题修复

jinx před 2 roky
rodič
revize
155ee90726

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 1
server/test/a0k4xu045_202305311600080410/attach/sceneStore


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

@@ -14,6 +14,7 @@ export default class MoveMagnifier {
         x: popPosition.x,
         y: popPosition.y,
       };
+      magnifier.setPopPosition(position);
     }
   }
 }

+ 26 - 22
src/graphic/Geometry/Magnifier.js

@@ -1,10 +1,10 @@
 //放大镜
 
-import { coordinate } from "../Coordinate.js";
-import { mathUtil } from "../Util/MathUtil.js";
-import VectorType from "../enum/VectorType.js";
-import Geometry from "./Geometry";
-import {api} from '@/store/sync.ts'
+import { coordinate } from '../Coordinate.js';
+import { mathUtil } from '../Util/MathUtil.js';
+import VectorType from '../enum/VectorType.js';
+import Geometry from './Geometry';
+import { api } from '@/store/sync.ts';
 
 const distance = 500;
 export default class Magnifier extends Geometry {
@@ -26,8 +26,8 @@ export default class Magnifier extends Geometry {
     this.position.x = positionRaw.x;
     this.position.y = positionRaw.y;
     let position = {
-      x: this.position.x,
-      y: this.position.y,
+      // x: this.position.x,
+      // y: this.position.y,
     };
     //let position = coordinate.getScreenXY(this.position);
     // let center = {
@@ -111,7 +111,7 @@ export default class Magnifier extends Geometry {
   //     };
   //   }
   // }
-  setPopPosition() {
+  setPopPosition(positionRaw) {
     const position = coordinate.getScreenXY(this.position);
     const center = coordinate.getScreenXY(coordinate.center);
     let line = mathUtil.createLine1(position, center);
@@ -120,20 +120,24 @@ export default class Magnifier extends Geometry {
     let join1 = mathUtil.getIntersectionPoint(line, parallelLines.line1);
     let join2 = mathUtil.getIntersectionPoint(line, parallelLines.line2);
 
-    if (
-      mathUtil.getDistance(join1, center) < mathUtil.getDistance(join2, center)
-    ) {
-      this.popPosition = {
-        x: join1.x,
-        y: join1.y,
-      };
-    } else if (
-      mathUtil.getDistance(join2, center) < mathUtil.getDistance(join1, center)
-    ) {
-      this.popPosition = {
-        x: join2.x,
-        y: join2.y,
-      };
+    if (mathUtil.getDistance(join1, center) < mathUtil.getDistance(join2, center)) {
+      if (positionRaw) {
+        this.popPosition =  coordinate.getScreenXY(positionRaw);
+      } else {
+        this.popPosition = {
+          x: join1.x,
+          y: join1.y,
+        };
+      }
+    } else if (mathUtil.getDistance(join2, center) < mathUtil.getDistance(join1, center)) {
+      if (positionRaw) {
+        this.popPosition = coordinate.getScreenXY(positionRaw);
+      } else {
+        this.popPosition = {
+          x: join2.x,
+          y: join2.y,
+        };
+      }
     }
   }
 

+ 0 - 1
src/graphic/Layer.js

@@ -348,7 +348,6 @@ export default class Layer {
     if (Math.abs(X - this.startX) > minDragDis || Math.abs(Y - this.startY) > minDragDis) {
       // 是否拖拽了
       if (eventName != null) {
-        // console.log(stateService.getFocusItem(),stateService.getSelectItem());
         if (eventName == LayerEvents.MoveMagnifier && stateService.getSelectItem().state != 0) {
         } else {
           stateService.clearFocusItem();

+ 6 - 2
src/graphic/ListenLayer.js

@@ -1285,14 +1285,18 @@ export default class ListenLayer {
         this.modifyPoint.index
       );
     } else if (this.modifyPoint.magnifierId) {  
-      // if(this.modifyPoint.index==0){
+      if(this.modifyPoint.index==0){
         //点击隐藏的放大镜不显示
         stateService.setSelectItem(
           this.modifyPoint.magnifierId,
           VectorType.Magnifier,
           this.modifyPoint.index
         );
-      // }
+      }else{
+        stateService.setSelectState(
+          this.modifyPoint.index
+        );
+      }
     
     } else if (this.modifyPoint.linkedEdgeId) {
       stateService.setSelectItem(

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

@@ -546,7 +546,7 @@ export default class Draw {
       radius,
     });
     const pt = coordinate.getScreenXY(vector.position);
-    vector.setPopPosition();
+    // vector.setPopPosition();
     const target = {
       x: vector.popPosition.x,
       y: vector.popPosition.y,

+ 11 - 5
src/graphic/Service/StateService.js

@@ -1,7 +1,7 @@
-import VectorType from "../enum/VectorType.js";
-import SelectState from "../enum/SelectState.js";
-import VectorCategory from "../enum/VectorCategory.js";
-import { dataService } from "./DataService.js";
+import VectorType from '../enum/VectorType.js';
+import SelectState from '../enum/SelectState.js';
+import VectorCategory from '../enum/VectorCategory.js';
+import { dataService } from './DataService.js';
 
 export default class StateService {
   constructor() {
@@ -38,9 +38,15 @@ export default class StateService {
       const point = dataService.getPoint(vectorId);
       this.selectItem.category = point.getCategory();
     }
-    console.log("选中的元素:" + JSON.stringify(this.selectItem));
+    console.log('选中的元素:' + JSON.stringify(this.selectItem));
   }
+  setSelectState(state) {
+    if (!state || !this.selectItem) {
+      return;
+    }
 
+    this.selectItem.state = state;
+  }
   getSelectItem() {
     return this.selectItem;
   }