Quellcode durchsuchen

添加提示方法

bill vor 2 Jahren
Ursprung
Commit
ac8a4df09a

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

@@ -16,6 +16,7 @@ import { addRoad } from "../Controls/AddRoad";
 import { addLine } from "./AddLine.js";
 import VectorCategory from "../enum/VectorCategory.js";
 // import { floorplanData } from "../VectorData.js";
+import Message from "@/components/base/components/message/message.vue";
 
 export default class UIControl {
   constructor(layer, newsletter, graphicStateUI) {
@@ -232,4 +233,9 @@ export default class UIControl {
   }
 
   /******************************************************************************************************************************************************************/
+
+
+  prompt(msg) {
+    return Message.success({ msg })
+  }
 }

+ 16 - 2
src/graphic/Renderer/Draw.js

@@ -578,8 +578,22 @@ export default class Draw {
     this.context.font = oldFont;
   }
 
+  drawLineText(vector) {
+    const startReal = dataService.getPoint(vector.startId);
+    const start = coordinate.getScreenXY(startReal);
+    const endReal = dataService.getPoint(vector.endId);
+    const end = coordinate.getScreenXY(endReal);
+
+    const angle = Math.atan2(end.y - start.y, end.x - start.x) * 180 / Math.PI;
+    this.context.translate(start.x, start.y);
+    this.context.rotate(angle * Math.PI / 180);
+
+// 在路径上绘制文本
+    context.fillText('Hello World!', 0, 0);
+  }
+
   drawLine(vector) {
-    if ([UIEvents.Arrow, UIEvents.MeasureLine].includes(vector.category)) {
+    if ([UIEvents.Arrow, UIEvents.MeasureFree].includes(vector.category)) {
       return this.drawArrow(vector);
     }
     const startReal = dataService.getPoint(vector.startId);
@@ -596,7 +610,7 @@ export default class Draw {
     if (style.dash) {
       this.context.setLineDash(style.dash);
     }
-    
+
     this.context.beginPath();
     this.context.moveTo(start.x, start.y);
     this.context.lineTo(end.x, end.y);

+ 1 - 1
src/graphic/enum/UIEvents.js

@@ -14,7 +14,7 @@ const UIEvents = {
 
   // 测量
   // 自由测量
-  MeasureFree: "MeasureFree",
+  MeasureFree: "MeasureLine",
   // 直角定位法
   AngleLocationMode: "AngleLocationMode",
   // 综合定位法

+ 2 - 1
src/hook/useGraphic.ts

@@ -33,7 +33,8 @@ export const graphicState = ref({
   canRecovery: false,
   showBackImage: true,
   canAngleLocationMode: false,
-  canAllLocationMode: false
+  canAllLocationMode: false,
+  existsBaseLine: false,
 })
 
 export const setCanvas = async (canvas: HTMLCanvasElement, data: Ref<AccidentPhoto | RoadPhoto>) => {