|
@@ -28,12 +28,7 @@ import {
|
|
|
import { EntityShape } from "@/deconstruction";
|
|
|
import { Util } from "konva/lib/Util";
|
|
|
import { useViewerInvertTransform } from "./use-viewer";
|
|
|
-import {
|
|
|
- debounce,
|
|
|
- diffArrayChange,
|
|
|
- mergeFuns,
|
|
|
- onlyId,
|
|
|
-} from "@/utils/shared";
|
|
|
+import { debounce, diffArrayChange, mergeFuns, onlyId } from "@/utils/shared";
|
|
|
import { IRect } from "konva/lib/types";
|
|
|
import { useMouseShapesStatus } from "./use-mouse-status";
|
|
|
import Icon from "../components/icon/temp-icon.vue";
|
|
@@ -45,6 +40,7 @@ import { Stage } from "konva/lib/Stage";
|
|
|
import { useOnComponentBoundChange } from "./use-component";
|
|
|
import { useHistory } from "./use-history";
|
|
|
import { isRectContained } from "@/utils/math";
|
|
|
+import { useTransformer } from "./use-transformer";
|
|
|
|
|
|
const normalSelectIds = (
|
|
|
store: DrawStore,
|
|
@@ -121,6 +117,7 @@ export const useSelection = installGlobalVar(() => {
|
|
|
const stage = useStage();
|
|
|
const operMode = useOperMode();
|
|
|
const selections = ref<EntityShape[]>();
|
|
|
+ const transformer = useTransformer();
|
|
|
|
|
|
let shapeBoxs: IRect[] = [];
|
|
|
let shapes: EntityShape[] = [];
|
|
@@ -130,8 +127,15 @@ export const useSelection = installGlobalVar(() => {
|
|
|
selections.value = [];
|
|
|
|
|
|
for (let i = 0; i < shapeBoxs.length; i++) {
|
|
|
- if (Util.haveIntersection(boxRect, shapeBoxs[i]) && !isRectContained(shapeBoxs[i], boxRect))
|
|
|
- selections.value.push(shapes[i]);
|
|
|
+ if (
|
|
|
+ Util.haveIntersection(boxRect, shapeBoxs[i]) &&
|
|
|
+ !isRectContained(shapeBoxs[i], boxRect) &&
|
|
|
+ shapes[i] !== toRaw(transformer)
|
|
|
+ ) {
|
|
|
+ if (!selections.value.includes(shapes[i])) {
|
|
|
+ selections.value.push(shapes[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -247,7 +251,7 @@ const useWatchSelection = () => {
|
|
|
watch(
|
|
|
() => status.selects,
|
|
|
(shapes) => {
|
|
|
- const fShapes = Array.from(new Set(shapes))
|
|
|
+ const fShapes = Array.from(new Set(shapes));
|
|
|
const { added, deleted } = diffArrayChange(shapes, fShapes);
|
|
|
if (added.length || deleted.length) {
|
|
|
status.selects = fShapes;
|
|
@@ -261,7 +265,7 @@ const useWatchSelection = () => {
|
|
|
delShapes,
|
|
|
watchSelection,
|
|
|
};
|
|
|
-}
|
|
|
+};
|
|
|
|
|
|
const useWatchSelectionGroup = () => {
|
|
|
const stage = useStage();
|
|
@@ -356,7 +360,7 @@ export const useSelectionRevise = () => {
|
|
|
}
|
|
|
);
|
|
|
|
|
|
- const ids = computed(() => status.selects.map((item) => item.id()));
|
|
|
+ const ids = computed(() => [...new Set(status.selects.map((item) => item.id()))]);
|
|
|
const groupConfig = {
|
|
|
id: onlyId(),
|
|
|
createTime: Date.now(),
|