Feat: 프로젝트 타입에 따라 캔버스에 사각형, 다각형 중 하나만 그릴 수 있도록 변경
This commit is contained in:
parent
0de67e7f94
commit
807bf970ae
@ -2,16 +2,22 @@ import useCanvasStore from '@/stores/useCanvasStore';
|
|||||||
import { LucideIcon, MousePointer2, PenTool, Save, Square } from 'lucide-react';
|
import { LucideIcon, MousePointer2, PenTool, Save, Square } from 'lucide-react';
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
|
|
||||||
export default function CanvasControlBar({ saveJson }: { saveJson: () => void }) {
|
export default function CanvasControlBar({
|
||||||
|
saveJson,
|
||||||
|
projectType,
|
||||||
|
}: {
|
||||||
|
saveJson: () => void;
|
||||||
|
projectType: 'classification' | 'detection' | 'segmentation';
|
||||||
|
}) {
|
||||||
const drawState = useCanvasStore((state) => state.drawState);
|
const drawState = useCanvasStore((state) => state.drawState);
|
||||||
const setDrawState = useCanvasStore((state) => state.setDrawState);
|
const setDrawState = useCanvasStore((state) => state.setDrawState);
|
||||||
const buttonBaseClassName = 'rounded-lg p-2 transition-colors ';
|
const buttonBaseClassName = 'rounded-lg p-2 transition-colors ';
|
||||||
const buttonClassName = 'hover:bg-gray-100';
|
const buttonClassName = 'hover:bg-gray-100';
|
||||||
const activeButtonClassName = 'bg-primary stroke-white';
|
const activeButtonClassName = 'bg-primary stroke-white';
|
||||||
|
|
||||||
const controls: { [key: string]: LucideIcon } = {
|
const controls: { [key: string]: LucideIcon } = {
|
||||||
pointer: MousePointer2,
|
pointer: MousePointer2,
|
||||||
rect: Square,
|
...(projectType === 'segmentation' ? { pen: PenTool } : { rect: Square }),
|
||||||
pen: PenTool,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -31,7 +37,7 @@ export default function CanvasControlBar({ saveJson }: { saveJson: () => void })
|
|||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
<div className="h-5 w-0.5 rounded bg-gray-400" />
|
||||||
<button
|
<button
|
||||||
className={cn(buttonClassName, buttonBaseClassName)}
|
className={cn(buttonClassName, buttonBaseClassName)}
|
||||||
onClick={saveJson}
|
onClick={saveJson}
|
||||||
|
@ -345,7 +345,10 @@ export default function ImageCanvas() {
|
|||||||
|
|
||||||
<Layer ref={dragLayerRef} />
|
<Layer ref={dragLayerRef} />
|
||||||
</Stage>
|
</Stage>
|
||||||
<CanvasControlBar saveJson={saveJson} />
|
<CanvasControlBar
|
||||||
|
saveJson={saveJson}
|
||||||
|
projectType={project.type}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div></div>
|
<div></div>
|
||||||
|
Loading…
Reference in New Issue
Block a user