Feat: 세그멘테이션 레이블 수정 결과 반영하도록 수정

This commit is contained in:
jhynsoo 2024-09-23 22:15:52 +09:00
parent 6b542b5b0f
commit 02602a0dd1
2 changed files with 9 additions and 5 deletions

View File

@ -1,6 +1,5 @@
import { Label } from '@/types';
import Konva from 'konva';
import { useState } from 'react';
import { Line } from 'react-konva';
import PolygonTransformer from './PolygonTransformer';
@ -8,21 +7,25 @@ export default function LabelPolygon({
isSelected,
onSelect,
info,
setLabel,
stage,
dragLayer,
}: {
isSelected: boolean;
onSelect: () => void;
info: Label;
setLabel: (coordinate: [number, number][]) => void;
stage: Konva.Stage;
dragLayer: Konva.Layer;
}) {
const [coordinates, setCoordinates] = useState<Array<[number, number]>>(info.coordinates);
const handleChange = (coordinates: [number, number][]) => {
setLabel(coordinates);
};
return (
<>
<Line
points={coordinates.flat()}
points={info.coordinates.flat()}
stroke={info.color}
strokeWidth={1}
onMouseDown={onSelect}
@ -33,8 +36,8 @@ export default function LabelPolygon({
/>
{isSelected && (
<PolygonTransformer
coordinates={coordinates}
setCoordinates={setCoordinates}
coordinates={info.coordinates}
setCoordinates={handleChange}
stage={stage}
dragLayer={dragLayer}
/>

View File

@ -289,6 +289,7 @@ export default function ImageCanvas() {
isSelected={label.id === selectedLabelId}
onSelect={() => setSelectedLabelId(label.id)}
info={label}
setLabel={setLabel(label.id)}
stage={stageRef.current as Konva.Stage}
dragLayer={dragLayerRef.current as Konva.Layer}
/>