Przeglądaj źródła

添加绘制相关类

bill 2 lat temu
rodzic
commit
4c58f52209

+ 5 - 1
src/graphic/Controls/UIControl.js

@@ -96,7 +96,7 @@ export default class UIControl {
     }
   }
 
-  handleGeo() {}
+  handleGeo(action) {}
 
   /****************************************************************************针对菜单*******************************************************************************/
 
@@ -124,6 +124,10 @@ export default class UIControl {
     this.layer.renderer.autoRedraw();
   }
 
+  menu_view_reset() {
+
+  }
+
   // value 为true则开 false则关
   menu_backgroundImg(value) {
     //

+ 6 - 3
src/graphic/Renderer/Draw.js

@@ -411,11 +411,14 @@ export default class Draw {
       ctx.strokeStyle = vector.arrowColor
     }
     ctx.beginPath();
+
     ctx.moveTo(start.x, start.y);
     ctx.lineTo(end.x, end.y);
-    ctx.moveTo(xC, yC);
-    ctx.lineTo(end.x, end.y);
-    ctx.lineTo(xD, yD);
+
+    const lines = mathUtil.getArrow(start, end)
+    ctx.moveTo(lines[0].x, lines[0].y);
+    ctx.lineTo(lines[1].x, lines[1].y);
+    ctx.lineTo(lines[2].x, lines[2].y);
     ctx.stroke();
     ctx.restore();
 

+ 14 - 0
src/graphic/Util/MathUtil.js

@@ -349,6 +349,20 @@ export default class MathUtil {
     }
   }
 
+  getArrow(start, end, ange = 30, L = 20) {
+    let a = Math.atan2((end.y - start.y), (end.x - start.x));
+    let xC = end.x - L * Math.cos(a + ange * Math.PI/180); // θ=30
+    let yC = end.y - L * Math.sin(a + ange * Math.PI/180);
+    let xD = end.x - L * Math.cos(a - ange * Math.PI/180);
+    let yD = end.y - L * Math.sin(a - ange * Math.PI/180);
+
+    return [
+      {x: xC, y: yC},
+      end,
+      {x: xD, y: yD}
+    ]
+  }
+
   //经过point且与line垂直的线
   getLineForPoint(line, point) {
     let parameter = {};

+ 6 - 1
src/graphic/enum/Action.js

@@ -1 +1,6 @@
-**
+const GeoActions = {
+  DeleteAction: "DeleteAction",
+  CopyAction: "CopyAction"
+}
+
+export default GeoActions

+ 3 - 0
src/views/graphic/geos/arrow.vue

@@ -19,6 +19,7 @@ import UiIcon from "@/components/base/components/icon/index.vue";
 import {drawRef, FocusVector, uiType, UIType} from '@/hook/useGraphic'
 import {computed, ref, watch, watchEffect} from "vue";
 import {dataService} from "@/graphic/Service/DataService";
+import GeoActions from "@/graphic/enum/Action"
 import {debounce} from "@/utils";
 
 const props = defineProps<{geo: FocusVector}>()
@@ -44,6 +45,7 @@ const menus = [
     key: 'copy',
     text: "复制",
     onClick: () => {
+      drawRef.value.uiControl.handleGeo(GeoActions.CopyAction)
       uiType.change(UIType.Copy)
     }
   },
@@ -51,6 +53,7 @@ const menus = [
     key: 'del',
     text: "删除",
     onClick: () => {
+      drawRef.value.uiControl.handleGeo(GeoActions.DeleteAction)
       uiType.change(UIType.Delete)
     }
   }

+ 2 - 1
src/views/graphic/geos/circle.vue

@@ -19,6 +19,7 @@ import {drawRef, FocusVector, uiType, UIType} from '@/hook/useGraphic'
 import {computed, ref, watch, watchEffect} from "vue";
 import {dataService} from "@/graphic/Service/DataService";
 import {debounce} from "@/utils";
+import GeoActions from "@/graphic/enum/Action";
 
 
 const props = defineProps<{geo: FocusVector}>()
@@ -43,7 +44,7 @@ const menus = [
     key: 'del',
     text: "删除",
     onClick: () => {
-      uiType.change(UIType.Delete)
+      drawRef.value.uiControl.handleGeo(GeoActions.CopyAction)
     }
   }
 ]

+ 2 - 1
src/views/graphic/geos/magnifier.vue

@@ -20,6 +20,7 @@ import {drawRef, FocusVector, uiType, UIType} from '@/hook/useGraphic'
 import {computed, ref, watch} from "vue";
 import {dataService} from "@/graphic/Service/DataService";
 import {getStaticFile} from "@/dbo/main";
+import GeoActions from "@/graphic/enum/Action";
 
 const props = defineProps<{geo: FocusVector}>()
 const vector = computed(() => dataService.getMagnifier(props.geo.vectorId))
@@ -33,7 +34,7 @@ const menus = [
     key: 'del',
     text: "删除",
     onClick: () => {
-      uiType.change(UIType.Delete)
+      drawRef.value.uiControl.handleGeo(GeoActions.CopyAction)
     }
   }
 ]

+ 2 - 1
src/views/graphic/geos/text.vue

@@ -31,6 +31,7 @@ import {uiType, UIType, FocusVector, drawRef} from '@/hook/useGraphic'
 import {computed, ref, watch, watchEffect} from "vue";
 import {dataService} from "@/graphic/Service/DataService";
 import {debounce} from '@/utils/index'
+import GeoActions from "@/graphic/enum/Action";
 
 const props = defineProps<{geo: FocusVector}>()
 const vector = computed(() => dataService.getText(props.geo.vectorId))
@@ -70,7 +71,7 @@ const menus = [
     key: 'del',
     text: "删除",
     onClick: () => {
-      uiType.change(UIType.Delete)
+      drawRef.value.uiControl.handleGeo(GeoActions.CopyAction)
     }
   }
 ]

+ 4 - 0
src/views/graphic/header.vue

@@ -67,6 +67,10 @@ const menus = computed<{disable?: boolean, text: string, onClick: () => void}[]>
     {
       text: "清除",
       onClick: () => drawRef.value.uiControl.menu_clear()
+    },
+    {
+      text: "恢复",
+      onClick: () => drawRef.value.uiControl.menu_view_reset()
     }
   ]