// Copyright (C) 2020 Intel Corporation // // SPDX-License-Identifier: MIT import React from 'react'; import { Row, Col } from 'antd/lib/grid'; import Button from 'antd/lib/button'; import InputNumber from 'antd/lib/input-number'; import Radio, { RadioChangeEvent } from 'antd/lib/radio'; import Tooltip from 'antd/lib/tooltip'; import Text from 'antd/lib/typography/Text'; import { RectDrawingMethod, CuboidDrawingMethod } from 'cvat-canvas-wrapper'; import { ShapeType } from 'reducers/interfaces'; import { clamp } from 'utils/math'; import LabelSelector from 'components/label-selector/label-selector'; interface Props { shapeType: ShapeType; labels: any[]; minimumPoints: number; rectDrawingMethod?: RectDrawingMethod; cuboidDrawingMethod?: CuboidDrawingMethod; numberOfPoints?: number; selectedLabelID: number; repeatShapeShortcut: string; onChangeLabel(value: string): void; onChangePoints(value: number | undefined): void; onChangeRectDrawingMethod(event: RadioChangeEvent): void; onChangeCuboidDrawingMethod(event: RadioChangeEvent): void; onDrawTrack(): void; onDrawShape(): void; } function DrawShapePopoverComponent(props: Props): JSX.Element { const { labels, shapeType, minimumPoints, selectedLabelID, numberOfPoints, rectDrawingMethod, cuboidDrawingMethod, repeatShapeShortcut, onDrawTrack, onDrawShape, onChangeLabel, onChangePoints, onChangeRectDrawingMethod, onChangeCuboidDrawingMethod, } = props; return (
{`Draw new ${shapeType}`} Label {shapeType === ShapeType.RECTANGLE && ( <> Drawing method By 2 Points By 4 Points )} {shapeType === ShapeType.CUBOID && ( <> Drawing method From rectangle By 4 Points )} {shapeType !== ShapeType.RECTANGLE && shapeType !== ShapeType.CUBOID && ( Number of points: { if (typeof value === 'number') { onChangePoints(Math.floor(clamp(value, minimumPoints, Number.MAX_SAFE_INTEGER))); } else if (!value) { onChangePoints(undefined); } }} className='cvat-draw-shape-popover-points-selector' min={minimumPoints} value={numberOfPoints} step={1} /> )}
); } export default React.memo(DrawShapePopoverComponent);