|
@@ -1,18 +1,31 @@
|
|
|
<template>
|
|
|
<EditLine
|
|
|
:ref="(d: any) => shape = d?.shape"
|
|
|
- :data="{ ...line, ...style }"
|
|
|
+ :data="{ ...line, ...style, lineJoin: 'miter' }"
|
|
|
:opacity="isDrawIng ? 0.5 : 1"
|
|
|
:points="points"
|
|
|
:closed="false"
|
|
|
:id="line.id"
|
|
|
:disablePoint="!canEdit || mode.include(Mode.readonly)"
|
|
|
:ndx="0"
|
|
|
- @dragstart="dragstartLineHandler(points.map((item) => item.id))"
|
|
|
- @update:line="dragLineHandler"
|
|
|
- @dragend="dragendLineHandler"
|
|
|
+ @dragstart="emit('dragLineStart', props.line)"
|
|
|
+ @update:line="(ps) => emit('dragLine', props.line, ps)"
|
|
|
+ @dragend="emit('dragLineEnd', props.line)"
|
|
|
@add-point="addPoint"
|
|
|
/>
|
|
|
+ <template v-if="joinLines">
|
|
|
+ <v-line
|
|
|
+ v-for="line in joinLines"
|
|
|
+ ref="line"
|
|
|
+ :config="{
|
|
|
+ strokeWidth: 20,
|
|
|
+ opacity: isDrawIng ? 0.5 : 1,
|
|
|
+ stroke: 'red',
|
|
|
+ points: flatPositions(line),
|
|
|
+ listening: false,
|
|
|
+ }"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
|
|
|
<SizeLine
|
|
|
v-if="
|
|
@@ -31,7 +44,7 @@
|
|
|
<EditPoint
|
|
|
v-for="(point, ndx) in points"
|
|
|
:key="point.id"
|
|
|
- :opacity="1"
|
|
|
+ :opacity="0.1"
|
|
|
:size="line.strokeWidth"
|
|
|
:points="points"
|
|
|
:drawIng="ndx === 0 && isDrawIng"
|
|
@@ -68,7 +81,7 @@
|
|
|
<script lang="ts" setup>
|
|
|
import { computed, ref } from "vue";
|
|
|
import { getMouseStyle, getSnapInfos, LineData, shapeName } from "./index.ts";
|
|
|
-import { onlyId } from "@/utils/shared.ts";
|
|
|
+import { flatPositions, onlyId } from "@/utils/shared.ts";
|
|
|
import EditLine from "../share/edit-line.vue";
|
|
|
import { getVectorLine, lineCenter, lineLen, lineVector, Pos } from "@/utils/math.ts";
|
|
|
import EditPoint from "../share/edit-point.vue";
|
|
@@ -88,6 +101,7 @@ import {
|
|
|
} from "@/core/hook/use-mouse-status.ts";
|
|
|
import { themeColor } from "@/constant";
|
|
|
import { Vector2 } from "three";
|
|
|
+import { extendLinesOverlap } from "./use-draw.ts";
|
|
|
|
|
|
const mode = useMode();
|
|
|
|
|
@@ -99,6 +113,8 @@ const props = defineProps<{
|
|
|
dragPointIds?: string[];
|
|
|
}>();
|
|
|
|
|
|
+const joinLines = extendLinesOverlap(props.data, props.line);
|
|
|
+
|
|
|
const emit = defineEmits<{
|
|
|
(e: "updatePoint", value: LineData["points"][number]): void;
|
|
|
(e: "addPoint", value: LineData["points"][number]): void;
|
|
@@ -231,13 +247,7 @@ const dragendHandler = () => {
|
|
|
snapInfos.forEach((item) => infos.remove(item));
|
|
|
};
|
|
|
|
|
|
-const dragstartLineHandler = (eIds: string[]) => {
|
|
|
- emit("dragLineStart", props.line);
|
|
|
-};
|
|
|
-const dragLineHandler = (ps: Pos[]) => {
|
|
|
- emit("dragLine", props.line, ps);
|
|
|
-};
|
|
|
-const dragendLineHandler = () => {
|
|
|
- emit("dragLineEnd", props.line);
|
|
|
-};
|
|
|
+// const padstart = computed(() => {
|
|
|
+// props.line.
|
|
|
+// })
|
|
|
</script>
|