|
@@ -69,22 +69,37 @@ export const extendLinesOverlap = (
|
|
type ResultJoin = ReturnType<typeof getExtendPolygons>;
|
|
type ResultJoin = ReturnType<typeof getExtendPolygons>;
|
|
const joins = ref<ResultJoin[]>([]);
|
|
const joins = ref<ResultJoin[]>([]);
|
|
|
|
|
|
- const updateJoins = (points: LineData["points"]) => {
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- watch(getJoinLine(data, line1, points[1].id), (joinLines, _, onCleanup) => {
|
|
|
|
- for (let j = 0; j < joinLines.length; j++) {
|
|
|
|
- const key = [points[0].id, points[1].id, joinLines[j].points[1].id];
|
|
|
|
- if (has(key)) continue;
|
|
|
|
- set(key);
|
|
|
|
- const polygons = getExtendPolygons({ ...line1, points }, joinLines[j]);
|
|
|
|
- joins.value.push(polygons);
|
|
|
|
- onCleanup(() => {
|
|
|
|
- const ndx = joins.value.indexOf(polygons);
|
|
|
|
- ~ndx && joins.value.splice(ndx, 1);
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
|
|
+ const updateJoins = (rev = false) => {
|
|
|
|
+ const points = computed(() => {
|
|
|
|
+ const pointIds = rev ? [line1.b, line1.a] : [line1.a, line1.b]
|
|
|
|
+ return pointIds.map(
|
|
|
|
+ (id) => data.points.find((item) => item.id === id)!
|
|
|
|
+ )
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+ watch(
|
|
|
|
+ () => getJoinLine(data, line1, points.value[1].id),
|
|
|
|
+ (joinLines) => {
|
|
|
|
+ for (let j = 0; j < joinLines.length; j++) {
|
|
|
|
+ const key = [points.value[0].id, points.value[1].id, joinLines[j].points[1].id];
|
|
|
|
+ if (has(key)) continue;
|
|
|
|
+ set(key);
|
|
|
|
+ watchEffect((onCleanup) => {
|
|
|
|
+ console.log(points.value)
|
|
|
|
+ const polygons = getExtendPolygons(
|
|
|
|
+ { ...line1, points: points.value },
|
|
|
|
+ joinLines[j]
|
|
|
|
+ );
|
|
|
|
+ joins.value.push(polygons);
|
|
|
|
+ onCleanup(() => {
|
|
|
|
+ const ndx = joins.value.indexOf(polygons);
|
|
|
|
+ ~ndx && joins.value.splice(ndx, 1);
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ { immediate: true }
|
|
|
|
+ );
|
|
};
|
|
};
|
|
|
|
|
|
const stopWatch = watch(
|
|
const stopWatch = watch(
|
|
@@ -93,13 +108,8 @@ export const extendLinesOverlap = (
|
|
if (!data.lines.includes(line1)) {
|
|
if (!data.lines.includes(line1)) {
|
|
return stopWatch();
|
|
return stopWatch();
|
|
}
|
|
}
|
|
-
|
|
|
|
- const points = [line1.a, line1.b].map(
|
|
|
|
- (id) => data.points.find((item) => item.id === id)!
|
|
|
|
- );
|
|
|
|
- const groupPoints = [[...points], [...points].reverse()];
|
|
|
|
- updateJoins(groupPoints[0]);
|
|
|
|
- updateJoins(groupPoints[1]);
|
|
|
|
|
|
+ updateJoins(false);
|
|
|
|
+ updateJoins(true);
|
|
},
|
|
},
|
|
{ immediate: true }
|
|
{ immediate: true }
|
|
);
|
|
);
|