浏览代码

添加绘制相关类

bill 2 年之前
父节点
当前提交
a39091ebc8
共有 3 个文件被更改,包括 28 次插入22 次删除
  1. 1 1
      server/test/SS-t-P1d6CwREny2/attach/sceneStore
  2. 9 3
      src/graphic/Renderer/Draw.js
  3. 18 18
      src/views/graphic/menus.ts

文件差异内容过多而无法显示
+ 1 - 1
server/test/SS-t-P1d6CwREny2/attach/sceneStore


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

@@ -6,6 +6,7 @@ import VectorType from "../enum/VectorType.js";
 import { mathUtil } from "../Util/MathUtil.js";
 import ElementEvents from "../enum/ElementEvents.js";
 import { elementService } from "../Service/ElementService.js";
+import UIEvents from "@/graphic/enum/UIEvents.js";
 
 const imgCache = {}
 const help = {
@@ -121,6 +122,7 @@ export default class Draw {
   }
 
   drawBackGroundImg(vector) {
+    console.log(vector)
     const img = vector.imageData
     const width = help.getReal(img.width)
     const height = help.getReal(img.height)
@@ -535,9 +537,9 @@ export default class Draw {
     setStyle && help.setVectorStyle(ctx, null, "Text");
 
     const pt = coordinate.getScreenXY(position);
-    const text = ctx.measureText("foo");
+    const text = ctx.measureText(txt);
     pt.x -= text.width / 2
-    pt.y -= (text.actualBoundingBoxAscent + text.actualBoundingBoxDescent) / 2
+    pt.y += (text.actualBoundingBoxAscent + text.actualBoundingBoxDescent) / 2
     if (angle) {
       ctx.translate(pt.x, pt.y);
       ctx.rotate(angle);
@@ -545,6 +547,7 @@ export default class Draw {
     } else {
       ctx.fillText(txt, pt.x, pt.y);
     }
+    this.drawPoint(position)
     ctx.restore();
   }
 
@@ -552,14 +555,17 @@ export default class Draw {
   drawText(vector) {
     help.setVectorStyle(this.context, vector);
     this.context.fillStyle = vector.color
+    const oldFont = this.context.font
     this.context.font = `${vector.fontSize}px Microsoft YaHei`
     this.drawTextByInfo(vector.center, vector.value, 0, false);
+    this.context.font = oldFont
   }
 
   drawLine(vector) {
-    if (vector.category === "ArrowLine") {
+    if ([UIEvents.Arrow, UIEvents.MeasureLine].includes(vector.category)) {
       return this.drawArrow(vector);
     }
+    console.log(vector)
     let start = dataService.getPoint(vector.startId);
     start = coordinate.getScreenXY(start);
     let end = dataService.getPoint(vector.endId);

+ 18 - 18
src/views/graphic/menus.ts

@@ -72,27 +72,27 @@ export const templateMenusRaw = [
 ]
 
 export const mainMenusRaw: MenusRaw = [
-  { key: UIType.CurveRoad, text: "弯路" },
-  { key: UIType.Road, text: "直路" },
+  // { key: UIType.CurveRoad, text: "弯路" },
+  // { key: UIType.Road, text: "直路" },
   { key: UIType.Line, text: "画线" },
-  {
-    key: UITypeExtend.road,
-    text: "道路",
-    children: [
-      { key: UIType.OneEdgeOneLanRoad, text: "单向单车道直路" },
-      { key: UIType.OneEdgeTwoLanRoad, text: "单向双车道直路" },
-      { key: UIType.OneEdgeThreeLanRoad, text: "单向三车道直路" },
-      { key: UIType.TwoEdgeOneLanRoad, text: "双向单车道直路" },
-      { key: UIType.TwoEdgeTwoLanRoad, text: "双向双车道直路" },
-      { key: UIType.TwoEdgeThreeLanRoad, text: "双向三车道直路" },
-      { key: UITypeExtend.structure, text: "道路结构", extend: structureMenusRaw },
-      { key: UITypeExtend.template, text: "道路模板", extend: templateMenusRaw },
-    ]
-  },
-  { key: UIType.Img, text: "图例" },
+  // {
+  //   key: UITypeExtend.road,
+  //   text: "道路",
+  //   children: [
+  //     { key: UIType.OneEdgeOneLanRoad, text: "单向单车道直路" },
+  //     { key: UIType.OneEdgeTwoLanRoad, text: "单向双车道直路" },
+  //     { key: UIType.OneEdgeThreeLanRoad, text: "单向三车道直路" },
+  //     { key: UIType.TwoEdgeOneLanRoad, text: "双向单车道直路" },
+  //     { key: UIType.TwoEdgeTwoLanRoad, text: "双向双车道直路" },
+  //     { key: UIType.TwoEdgeThreeLanRoad, text: "双向三车道直路" },
+  //     { key: UITypeExtend.structure, text: "道路结构", extend: structureMenusRaw },
+  //     { key: UITypeExtend.template, text: "道路模板", extend: templateMenusRaw },
+  //   ]
+  // },
+  // { key: UIType.Img, text: "图例" },
   { key: UIType.MeasureLine, text: "测量" },
   { key: UIType.Text, text: "文字" },
-  { key: UIType.magnifier, text: "放大镜" },
+  { key: UIType.Magnifier, text: "放大镜" },
   { key: UITypeExtend.photo, text: "照片库" },
   { key: UITypeExtend.setup, text: "设置" },
 ];