bill 1 天之前
父节点
当前提交
5201656a8b

+ 28 - 9
src/core/components/icon/temp-path.vue

@@ -19,16 +19,35 @@ const config = computed(() => {
   if (!props.config.fix) {
     return props.config;
   }
-  // return props.config;
+
   const dec = props.mat.decompose();
-  // console.log(props.svg.width, props.svg.height, props.config.box);
-  const config = {
+  const invScaleX = dec.scaleX ? 1 / dec.scaleX : 1;
+  const invScaleY = dec.scaleY ? 1 / dec.scaleY : 1;
+
+  // When canceling parent scaling for a sub-path, we must also scale around a
+  // stable anchor point; otherwise the path shrinks towards (0,0) and drifts.
+  const box = props.config.box;
+  const fixCenter = props.config.fixCenter || "";
+  const ax = fixCenter.includes("L")
+    ? box.x
+    : fixCenter.includes("R")
+      ? box.x + box.width
+      : box.x + box.width / 2;
+  const ay = fixCenter.includes("T")
+    ? box.y
+    : fixCenter.includes("B")
+      ? box.y + box.height
+      : box.y + box.height / 2;
+
+  return {
     ...props.config,
-    scaleX: 1 / dec.scaleX,
-    scaleY: 1 / dec.scaleY,
-    // x: props.config.box.x - props.svg.width / 2,
-    // y: props.config.box.y - props.svg.height / 2,
-  };
-  return config;
+    scaleX: invScaleX,
+    scaleY: invScaleY,
+    // Keep the original svg offset (temp-icon uses svg.x/svg.y as an offset),
+    // but use (ax, ay) as the scaling origin for this path.
+    offset: { x: ax, y: ay },
+    x: ax - props.svg.x,
+    y: ay - props.svg.y,
+  } as any;
 });
 </script>

+ 6 - 2
src/core/components/line/renderer/wall/index.vue

@@ -19,7 +19,7 @@
         <SizeLine
           :points="line"
           :fixed="props.line.fixed"
-          v-for="(line) in [...gd.steps.value, ...gd.subSteps.value]"
+          v-for="line in [...gd.steps.value, ...gd.subSteps.value]"
         />
       </template>
       <SizeLine :points="points" :fixed="props.line.fixed" v-else />
@@ -49,7 +49,11 @@ const props = defineProps<{
 const polygon = computed(() => props.getShapeAttrib(props.line));
 const points = computed(() => getLinePoints(props.data, props.line));
 const gd = useGetDiffLineIconPolygons(props.line, points);
-const polygons = computed(() => gd.diff(polygon.value));
+const polygons = computed(() => {
+  const result = gd.diff(polygon.value);
+  // console.log(result, polygon.value);
+  return result;
+});
 const scale = useFixedScale();
 const strokeWidth = computed(() => (props.line.fixed ? scale.value * 1 : 1));
 </script>

+ 1 - 1
src/core/viewer.ts

@@ -105,7 +105,7 @@ export class Viewer {
     const isMin = base * scale < min
     const isMax = base * scale > max
     if (isMax || isMin) {
-      console.error(`缩放范围${min}~${max} 将自动调整缩放值`);
+      // console.error(`缩放范围${min}~${max} 将自动调整缩放值`);
       if (scale > 1 && isMin) {
         scale = min / base
       } else if (scale < 1 && isMax) {

+ 9 - 4
src/example/fuse/views/tabulation/overview-viewport.vue

@@ -195,7 +195,7 @@ const updateOrigin = async () => {
       const isIcon = type === "icon" || type === "lineIcon";
       if (!("fixed" in item) && !isIcon) return;
 
-      if (isIcon) return;
+      // if (isIcon) return;
 
       item.fixed = false;
       item.fix = true;
@@ -206,8 +206,9 @@ const updateOrigin = async () => {
         item.strokeWidth = (item.__strokeWidth * pixelPaperToDrawPixel.value!) / 2;
       }
       if (isIcon) {
-        item.strokeWidth =
-          ((item.__strokeWidth || iconDefaultStyle.strokeWidth) * viewScale.value!) / 10;
+        item.strokeWidth = (item.__strokeWidth || 1) * (viewScale.value! / 2);
+        // console.log(item.strokeWidth, item.__strokeWidth);
+        //     ((item.__strokeWidth || iconDefaultStyle.strokeWidth) * viewScale.value!) / 10;
       }
     };
     if (d?.store) {
@@ -266,11 +267,15 @@ watch([coverScale, () => props.showLabelLine], () => {
   left: -100vw;
   top: -100vh;
   visibility: hidden;
+  pointer-events: none;
 
+  // visibility: visible;
   // left: 0;
   // top: 0;
+  // pointer-events: all;
+  // background: #ccc;
+
   width: 100vw;
   height: 100vh;
-  pointer-events: none;
 }
 </style>

+ 3 - 0
src/utils/resource.ts

@@ -69,6 +69,7 @@ export type SVGPath = {
   strokeWidth?: number;
   data: string;
   fix: boolean;
+  fixCenter?: string | null;
   box: DOMRect
 };
 export type SVGParseResult = Size & Pos & {
@@ -112,6 +113,7 @@ export let parseSvgContent = (svgContent: string): SVGParseResult => {
       const data = path.getAttribute("d")!;
       const stroke = path.getAttribute("stroke")!;
       const fix = path.getAttribute("fix") === "true";
+      const fixCenter = path.getAttribute("fix-center");
       const strokeWidth = path.getAttribute("stroke-width")!;
       return {
         fill,
@@ -119,6 +121,7 @@ export let parseSvgContent = (svgContent: string): SVGParseResult => {
         stroke,
         box,
         fix,
+        fixCenter,
         strokeWidth: (strokeWidth && Number(strokeWidth)) || 1,
       };
     });

文件差异内容过多而无法显示
+ 1 - 1
tsconfig.app.tsbuildinfo