Browse Source

修正问题

bill 2 years ago
parent
commit
3889c2c937

+ 35 - 19
src/graphic/Renderer/Draw.js

@@ -228,6 +228,16 @@ export const help = {
       (ctx.lineWidth || 1) *
       (weight === VectorWeight.Bold ? 2 : 1);
 
+    const funStyle = [
+      VectorStyle.PointDrawLine,
+      VectorStyle.SingleDashedLine,
+      VectorStyle.SingleSolidLine,
+    ]
+    if (typeof line === "function" && !funStyle.includes(style)) {
+      style = VectorStyle.SingleSolidLine
+    }
+
+
     switch (style) {
       case VectorStyle.PointDrawLine:
       case VectorStyle.SingleDashedLine:
@@ -243,8 +253,12 @@ export const help = {
           ]);
         }
 
-        ctx.moveTo(line[0].x, line[0].y);
-        ctx.lineTo(line[1].x, line[1].y);
+        if (typeof line === 'function') {
+          line()
+        } else {
+          ctx.moveTo(line[0].x, line[0].y);
+          ctx.lineTo(line[1].x, line[1].y);
+        }
         break;
       // 单实线
       case VectorStyle.DoubleDashedLine:
@@ -677,13 +691,13 @@ export default class Draw {
       }
 
 
-      midCovesArray = help.transformCoves([
-        vector.curves,
-      ]);
-      ctx.strokeStyle = 'red'
-      for (let coves of midCovesArray) {
-        help.drawCoves(ctx, coves);
-      }
+      // midCovesArray = help.transformCoves([
+      //   vector.curves,
+      // ]);
+      // ctx.strokeStyle = 'red'
+      // for (let coves of midCovesArray) {
+      //   help.drawCoves(ctx, coves);
+      // }
 
     }
     ctx.restore();
@@ -758,8 +772,13 @@ export default class Draw {
     ctx.save();
     help.setVectorStyle(ctx, vector);
     select && help.setStyle(ctx, style);
-    ctx.lineWidth *= Settings.lineWidth;
-    help.drawCoves(ctx, coves);
+    // ctx.lineWidth *= Settings.lineWidth;
+
+    help.drawStyleLine(this.context, () => {
+      help.drawCoves(ctx, coves);
+    }, vector.style, vector.weight);
+
+    // help.drawCoves(ctx, coves);
     ctx.restore();
 
     if (import.meta.env.DEV) {
@@ -1211,14 +1230,11 @@ export default class Draw {
     ctx.save();
     help.setVectorStyle(ctx, vector);
 
-    const lineWidth =
-      Settings.lineWidth *
-      (ctx.lineWidth || 1) *
-      (vector.weight === VectorWeight.Bold ? 2 : 1);
-    ctx.lineWidth = lineWidth
-    help.transformCoves([vector.curves]).forEach((coves) => {
-      help.drawCoves(ctx, coves);
-    });
+    help.drawStyleLine(this.context, () => {
+      help.transformCoves([vector.curves]).forEach((coves) => {
+        help.drawCoves(ctx, coves);
+      });
+    }, vector.style, vector.weight);
     ctx.restore();
 
     // if (import.meta.env.DEV) {

+ 8 - 4
src/views/graphic/geos/normalLine.vue

@@ -23,6 +23,7 @@ const isCurve = props.geo.type === VectorType.CurveLine
 const clickHandlerFactory = (key) => {
   return () => drawRef.value.uiControl.updateVectorForSelectUI(key)
 }
+console.log(props)
 
 const lineTypeMenu = [
   {
@@ -38,18 +39,21 @@ const lineTypeMenu = [
     onClick: clickHandlerFactory(VectorStyle.SingleDashedLine)
   },
   {
+    hide: isCurve,
     key: VectorStyle.DoubleSolidLine,
     icon: "line_df",
     text: "双实线",
     onClick: clickHandlerFactory(VectorStyle.DoubleSolidLine)
   },
   {
+    hide: isCurve,
     key: VectorStyle.DoubleDashedLine,
     icon: "line_dd",
     text: "双虚线",
     onClick: clickHandlerFactory(VectorStyle.DoubleDashedLine)
   },
   {
+    hide: isCurve,
     key: VectorStyle.BrokenLine,
     icon: "line_broken",
     text: "折线",
@@ -70,7 +74,7 @@ const lineWidthMenu = [
     text: "宽度",
     onClick: () => {
       clickHandlerFactory(VectorWeight.Thinning)()
-      menus.value[isCurve ? 0 : 1] = lineWidthMenu[1]
+      menus.value[1] = lineWidthMenu[1]
     }
   },
   {
@@ -79,7 +83,7 @@ const lineWidthMenu = [
     text: "宽度",
     onClick: () => {
       clickHandlerFactory(VectorWeight.Bold)()
-      menus.value[isCurve ? 0 : 1] = lineWidthMenu[0]
+      menus.value[1] = lineWidthMenu[0]
     }
   },
 ]
@@ -102,14 +106,14 @@ const appendMenus = (props.geo.category === VectorCategory.Line.NormalLine || is
   : []
 const childMenus = ref<UnwrapRef<typeof menus>>()
 const menus = ref([
-    ...(props.geo.type !== VectorType.CurveLine ? [{
+   {
     key: UITypeExtend.lineType,
     text: "单实线",
     icon: "line",
     onClick() {
       childMenus.value = toRaw(childMenus.value) === lineTypeMenu ? null : lineTypeMenu
     }
-  }] : []),
+  },
   vector.value?.weight === VectorWeight.Bold ? lineWidthMenu[0] : lineWidthMenu[1],
   ...appendMenus,
   {

+ 9 - 2
src/views/graphic/geos/roadEdge.vue

@@ -37,18 +37,26 @@ const lineTypeMenu = [
     onClick: clickHandlerFactory(VectorStyle.SingleDashedLine)
   },
   {
+    hide: props.geo.type === VectorType.CurveRoadEdge,
     key: VectorStyle.DoubleSolidLine,
     icon: "line_df",
     text: "双实线",
     onClick: clickHandlerFactory(VectorStyle.DoubleSolidLine)
   },
   {
+    hide: props.geo.type === VectorType.CurveRoadEdge,
     key: VectorStyle.DoubleDashedLine,
     icon: "line_dd",
     text: "双虚线",
     onClick: clickHandlerFactory(VectorStyle.DoubleDashedLine)
   },
-  {key: VectorStyle.BrokenLine, icon: "line_broken", text: "折线", onClick: clickHandlerFactory(VectorStyle.BrokenLine)},
+  {
+    hide: props.geo.type === VectorType.CurveRoadEdge,
+    key: VectorStyle.BrokenLine,
+    icon: "line_broken",
+    text: "折线",
+    onClick: clickHandlerFactory(VectorStyle.BrokenLine)
+  },
   {
     key: VectorStyle.PointDrawLine,
     icon: "line_dot",
@@ -99,7 +107,6 @@ const childMenus = ref<UnwrapRef<typeof menus>>()
 // console.log(vector.value)
 const menus = ref([
   {
-    hide: props.geo.type === VectorType.CurveRoadEdge,
     key: UITypeExtend.lineType,
     text: "单实线",
     icon: "line",