Skip to content

Commit

Permalink
Added errored shape
Browse files Browse the repository at this point in the history
  • Loading branch information
Boris Sekachev committed Jul 26, 2021
1 parent ca42cb5 commit 1117bf8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
8 changes: 5 additions & 3 deletions cvat-canvas/src/typescript/interactionHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,24 +278,26 @@ export class InteractionHandlerImpl implements InteractionHandler {
if (!intermediateShape) return;
const { shapeType, points } = intermediateShape;
if (shapeType === 'polygon') {
const erroredShape = shapeType === 'polygon' && points.length < 3 * 2;
this.drawnIntermediateShape = this.canvas
.polygon(stringifyPoints(translateToCanvas(geometry.offset, points)))
.attr({
'color-rendering': 'optimizeQuality',
'shape-rendering': 'geometricprecision',
'stroke-width': consts.BASE_STROKE_WIDTH / this.geometry.scale,
stroke: erroredShape ? 'red' : 'black',
fill: 'none',
})
.addClass('cvat_canvas_interact_intermediate_shape');
this.selectize(true, this.drawnIntermediateShape);
this.selectize(true, this.drawnIntermediateShape, erroredShape);
} else {
throw new Error(
`Shape type "${shapeType}" was not implemented at interactionHandler::updateIntermediateShape`,
);
}
}

private selectize(value: boolean, shape: SVG.Element): void {
private selectize(value: boolean, shape: SVG.Element, erroredShape = false): void {
const self = this;

if (value) {
Expand All @@ -307,7 +309,7 @@ export class InteractionHandlerImpl implements InteractionHandler {
pointType(cx: number, cy: number): SVG.Circle {
return this.nested
.circle(this.options.pointSize)
.stroke('black')
.stroke(erroredShape ? 'red' : 'black')
.fill('black')
.center(cx, cy)
.attr({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface Props {
onChange(value: number): void;
}

const MAX_ACCURACY = 13;
export const MAX_ACCURACY = 13;

export function thresholdFromAccuracy(approxPolyAccuracy: number): number {
const approxPolyMaxDistance = MAX_ACCURACY - approxPolyAccuracy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import InputNumber from 'antd/lib/input-number';
import Text from 'antd/lib/typography/Text';
import Slider from 'antd/lib/slider';

import { MAX_ACCURACY } from 'components/annotation-page/standard-workspace/controls-side-bar/approximation-accuracy';
import { clamp } from 'utils/math';

interface Props {
Expand Down Expand Up @@ -180,7 +181,7 @@ function WorkspaceSettingsComponent(props: Props): JSX.Element {
<Col span={5} offset={1}>
<Slider
min={0}
max={7}
max={MAX_ACCURACY}
step={1}
value={defaultApproxPolyAccuracy}
dots
Expand Down

0 comments on commit 1117bf8

Please sign in to comment.