bill недель назад: 2
Родитель
Сommit
dfa8db7fd1

+ 6 - 3
src/core/components/group/group.vue

@@ -150,11 +150,14 @@ const { shape, tData, data } = useComponentStatus<Rect, GroupData>({
       openSnap: false,
       getRepShape($shape) {
         const repShape = new Rect({ fill: themeColor, opacity: 0.3 });
-        const syncShape = () =>
+        const syncShape = () => {
           autoUpdate.value && (prevMat = $shape.getTransform().copy());
-        $shape.on("bound-change", syncShape);
+          console.log("sync");
+        };
+        // $shape.on("bound-change", syncShape);
         syncShape();
         const update = () => {
+          console.log("update");
           repShape.x($shape.x());
           repShape.y($shape.y());
           repShape.width($shape.width());
@@ -165,7 +168,7 @@ const { shape, tData, data } = useComponentStatus<Rect, GroupData>({
         update();
         return {
           shape: repShape,
-          update,
+          update() {},
           destory() {
             $shape.off("bound-change", syncShape);
           },

+ 4 - 3
src/core/components/group/temp-group.vue

@@ -1,5 +1,8 @@
 <template>
-  <v-rect :config="{ ...data, zIndex: undefined, strokeScaleEnable: true }" ref="shape" />
+  <v-rect
+    :config="{ ...data, opacity: 0, zIndex: undefined, strokeScaleEnable: true }"
+    ref="shape"
+  />
 </template>
 
 <script lang="ts" setup>
@@ -8,7 +11,6 @@ import { computed, nextTick, onUnmounted, ref, watch } from "vue";
 import { DC, EntityShape } from "@/deconstruction.js";
 import { Rect, RectConfig } from "konva/lib/shapes/Rect";
 import { useViewerInvertTransform } from "@/core/hook/use-viewer.ts";
-import { useDashAnimation } from "@/core/hook/use-animation.ts";
 import { useStage } from "@/core/hook/use-global-vars.ts";
 import { useOnComponentBoundChange } from "@/core/hook/use-component.ts";
 import { debounce } from "@/utils/shared.ts";
@@ -19,7 +21,6 @@ const props = defineProps<{
   autoUpdate?: boolean;
 }>();
 const shape = ref<DC<Rect>>();
-useDashAnimation(shape);
 const data = computed(() => ({ ...defaultStyle, ...props.data }));
 
 const stage = useStage();

+ 38 - 23
src/core/components/line-icon/icon.vue

@@ -20,6 +20,7 @@ import {
   getLineIconMat,
   getSnapLine,
   getLineIconEndpoints,
+  isRangInner,
 } from "./index.ts";
 import { useComponentStatus } from "@/core/hook/use-component.ts";
 import { PropertyUpdate, Operate } from "../../html-mount/propertys/index.ts";
@@ -43,6 +44,7 @@ import {
   lineLen,
   lineVector,
   Pos,
+  zeroEq,
 } from "@/utils/math.ts";
 import { copy } from "@/utils/shared.ts";
 import { useTestPoints } from "@/core/hook/use-debugger.ts";
@@ -179,30 +181,43 @@ watch(
       const eq0 = eqPoint(oldLine[0], line[0]);
       const eq1 = eqPoint(oldLine[1], line[1]);
       if (!eq0 || !eq1) {
-        // 联动
-        const startNdx = eq0 ? 0 : 1;
-        const endNdx = eq0 ? 1 : 0;
-        const rotate = line2IncludedAngle(
-          [oldLine[startNdx], oldLine[endNdx]],
-          [line[startNdx], line[endNdx]]
-        );
-        const mat = new Transform()
-          .translate(line[startNdx].x, line[startNdx].y)
-          .rotate(rotate)
-          .translate(-line[startNdx].x, -line[startNdx].y);
-        const endPoints = getLineIconEndpoints(oldLine, data.value).map((p) =>
-          mat.point(p)
-        );
-
-        if (lineInner(line, endPoints[0]) && lineInner(line, endPoints[1])) {
-          emit("updateShape", {
-            ...data.value,
-            startLen: lineLen(line[0], endPoints[0]),
-            endLen: lineLen(line[0], endPoints[1]),
-          });
+        if (eq0 === eq1) {
+          let newLen = lineLen(line[0], line[1]);
+          if (zeroEq(newLen - lineLen(oldLine[0], oldLine[1]))) {
+            shape.value?.getNode().fire("bound-change");
+            return;
+          }
+          if (!isRangInner(line, data.value)) {
+            emit("delShape");
+            return;
+          }
         } else {
-          emit("delShape");
-          return;
+          // 联动
+          const startNdx = eq0 ? 0 : 1;
+          const endNdx = eq0 ? 1 : 0;
+          const rotate = line2IncludedAngle(
+            [oldLine[startNdx], oldLine[endNdx]],
+            [line[startNdx], line[endNdx]]
+          );
+          const mat = new Transform()
+            .translate(line[startNdx].x, line[startNdx].y)
+            .rotate(rotate)
+            .translate(-line[startNdx].x, -line[startNdx].y);
+
+          const endPoints = getLineIconEndpoints(oldLine, data.value).map((p) =>
+            mat.point(p)
+          );
+
+          if (lineInner(line, endPoints[0]) && lineInner(line, endPoints[1])) {
+            emit("updateShape", {
+              ...data.value,
+              startLen: lineLen(line[0], endPoints[0]),
+              endLen: lineLen(line[0], endPoints[1]),
+            });
+          } else {
+            emit("delShape");
+            return;
+          }
         }
       } else if (newv.width !== oldv.width && newv.width && props.data.type === "full") {
         emit("updateShape", { ...data.value, height: newv.width });

+ 1 - 0
src/core/components/line/attach-server.ts

@@ -610,6 +610,7 @@ export const useLineDescribes = (line: Ref<LineDataLine>) => {
       return lineLen(points.value[0], points.value[1]);
     },
     set value(val) {
+      console.log(val, d.length.isChange);
       if (!d.isChange) {
         setLineVector = lineVector(points.value);
       }

+ 2 - 0
src/core/components/line/renderer/wall/view.ts

@@ -6,6 +6,7 @@ import {
   getLineEdges,
   LEJInfo,
   LEJLine,
+  lineLen,
   lineVector,
   Pos,
   verticalVector,
@@ -251,6 +252,7 @@ export const useGetExtendPolygon = (lineData: Ref<LineData | undefined>) => {
   );
 
   return (line: LineDataLine) => {
+    // console.error(lineLen(...getLinePoints(lineData.value!, line!)))
     const polygon = lineData.value ? getLEJPolygon(lineData.value, line) : [];
     return polygon
   };

+ 41 - 35
src/core/hook/use-selection.ts

@@ -189,35 +189,37 @@ export const useShapesIcon = (
   const unMountMap = new WeakMap<EntityShape, () => void>();
 
   const pause = usePause();
-  const stop = watch([shapes, () => pause.isPause], ([shapes], [oldShapes]) => {
-    if (pause.isPause) {
-      shapes = [];
-    }
-
-    const { added, deleted } = diffArrayChange(shapes || [], oldShapes || []);
-    for (const addShape of added) {
-      const mat = ref(getShapeMat(addShape));
-      const data = reactive({ ...iconProps, mat: mat });
-      const update = frameEebounce(() => {
-        data.width = invConfig.value.scaleX * iconProps.width;
-        data.height = invConfig.value.scaleY * iconProps.height;
-        mat.value = getShapeMat(addShape);
-      });
-      const unHooks = [
-        on(addShape, update),
-        watch(invConfig, update, { immediate: true, flush: "post" }),
-        mParts.add({
-          comp: markRaw(Icon),
-          props: { data },
-        }),
-      ];
-      unMountMap.set(addShape, mergeFuns(unHooks));
-    }
-    for (const delShape of deleted) {
-      const fn = unMountMap.get(delShape);
-      fn && fn();
+  const stop = watch(
+    [() => [...(shapes.value || [])], () => pause.isPause],
+    ([shapes], [oldShapes]) => {
+      if (pause.isPause) {
+        shapes = [];
+      }
+      const { added, deleted } = diffArrayChange(shapes || [], oldShapes || []);
+      for (const addShape of added) {
+        const mat = ref(getShapeMat(addShape));
+        const data = reactive({ ...iconProps, mat: mat });
+        const update = frameEebounce(() => {
+          data.width = invConfig.value.scaleX * iconProps.width;
+          data.height = invConfig.value.scaleY * iconProps.height;
+          mat.value = getShapeMat(addShape);
+        });
+        const unHooks = [
+          on(addShape, update),
+          watch(invConfig, update, { immediate: true, flush: "post" }),
+          mParts.add({
+            comp: markRaw(Icon),
+            props: { data },
+          }),
+        ];
+        unMountMap.set(addShape, mergeFuns(unHooks));
+      }
+      for (const delShape of deleted) {
+        const fn = unMountMap.get(delShape);
+        fn && fn();
+      }
     }
-  });
+  );
   return [stop, pause];
 };
 
@@ -238,9 +240,9 @@ export const useStoreSelectionManage = installGlobalVar((): SelectionManage => {
   const canSelect = (shape: EntityShape) => {
     const id = shape.id();
     if (!id) {
-      return false
+      return false;
     }
-    const item = store.items.find((item) => item.id === id)
+    const item = store.items.find((item) => item.id === id);
     return !!(item && !item.lock);
   };
   const listener = (shape: EntityShape) => {
@@ -347,11 +349,15 @@ export const useSelectionRevise = () => {
   };
   const operMode = useOperMode();
   const layer = useFormalLayer();
-  watch(() => operMode.value.mulSelection, (muls, olv) => {
-    if (muls) {
-      status.selects = [...status.selects, ...status.actives]
-    }
-  }, {flush: 'pre'})
+  watch(
+    () => operMode.value.mulSelection,
+    (muls, olv) => {
+      if (muls) {
+        status.selects = [...status.selects, ...status.actives];
+      }
+    },
+    { flush: "pre" }
+  );
   watch(
     () => [!!ids.value.length, operMode.value.mulSelection],
     (_a, _b) => {

+ 0 - 1
src/core/store/store.ts

@@ -130,7 +130,6 @@ export const useStoreRaw = defineStore("draw-data", {
           const old = typeItems[type]![ndx]
           Object.assign(typeItems[type]![ndx], playData.value);
           const newv = typeItems[type]![ndx]
-          console.log(old === newv)
         });
       }
     },