Skip to content

Commit 0b2fef1

Browse files
authored
Extract resize anchor component (#1131)
1 parent 0f7eded commit 0b2fef1

File tree

12 files changed

+20
-13
lines changed

12 files changed

+20
-13
lines changed

web_ui/packages/smart-tools/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ export { type GrabcutData } from './src/grabcut/interfaces';
1515
export { buildIntelligentScissorsInstance, IntelligentScissors } from './src/intelligent-scissors/intelligent-scissors';
1616

1717
export { Anchor } from './src/edit-bounding-box/anchor.component';
18+
export { ANCHOR_SIZE, ResizeAnchor } from './src/edit-bounding-box/resize-anchor.component';

web_ui/src/pages/annotator/tools/edit-tool/resize-anchor.component.tsx renamed to web_ui/packages/smart-tools/src/edit-bounding-box/resize-anchor.component.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33

44
import { CSSProperties, ReactNode } from 'react';
55

6-
import { Anchor as InternalAnchor } from '@geti/smart-tools';
7-
8-
import { ResizeAnchorType } from './resize-anchor.enum';
6+
import { Anchor as InternalAnchor } from './anchor.component';
97

108
export const ANCHOR_SIZE = 8;
119

10+
enum ResizeAnchorType {
11+
SQUARE,
12+
CIRCLE,
13+
CUSTOM,
14+
}
15+
1216
interface ResizeAnchorProps {
1317
zoom: number;
1418
x: number;

web_ui/src/pages/annotator/tools/edit-tool/edit-bounding-box/edit-bounding-box.component.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33

44
import { useEffect, useState } from 'react';
55

6+
import { ANCHOR_SIZE, ResizeAnchor } from '@geti/smart-tools';
7+
68
import { Annotation } from '../../../../../core/annotations/annotation.interface';
79
import { Point } from '../../../../../core/annotations/shapes.interface';
810
import { ShapeType } from '../../../../../core/annotations/shapetype.enum';
911
import { Labels } from '../../../annotation/labels/labels.component';
1012
import { AnnotationToolContext } from '../../../core/annotation-tool-context.interface';
1113
import { useROI } from '../../../providers/region-of-interest-provider/region-of-interest-provider.component';
1214
import { useZoom } from '../../../zoom/zoom-provider.component';
13-
import { ANCHOR_SIZE, ResizeAnchor } from '../resize-anchor.component';
1415
import { TranslateShape } from '../translate-shape.component';
1516
import { getBoundingBoxInRoi, getBoundingBoxResizePoints, getClampedBoundingBox } from '../utils';
1617

web_ui/src/pages/annotator/tools/edit-tool/edit-bounding-box/edit-bounding-box.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import '@wessberg/pointer-events';
55

6+
import { ANCHOR_SIZE } from '@geti/smart-tools';
67
import { fireEvent, screen } from '@testing-library/react';
78

89
import { Annotation } from '../../../../../core/annotations/annotation.interface';
@@ -15,7 +16,6 @@ import { ProjectProvider } from '../../../../project-details/providers/project-p
1516
import { AnnotationToolContext } from '../../../core/annotation-tool-context.interface';
1617
import { useROI } from '../../../providers/region-of-interest-provider/region-of-interest-provider.component';
1718
import { TaskProvider } from '../../../providers/task-provider/task-provider.component';
18-
import { ANCHOR_SIZE } from '../resize-anchor.component';
1919
import { EditBoundingBox as EditBoundingBoxTool } from './edit-bounding-box.component';
2020

2121
const mockROI = getMockedROI({ x: 0, y: 0, width: 1000, height: 1000 });

web_ui/src/pages/annotator/tools/edit-tool/edit-circle/edit-circle.component.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import { useEffect, useState } from 'react';
55

6+
import { ANCHOR_SIZE, ResizeAnchor } from '@geti/smart-tools';
67
import { Vec2 } from '@geti/smart-tools/utils';
78

89
import { Annotation, RegionOfInterest } from '../../../../../core/annotations/annotation.interface';
@@ -14,7 +15,6 @@ import { useROI } from '../../../providers/region-of-interest-provider/region-of
1415
import { useZoom } from '../../../zoom/zoom-provider.component';
1516
import { getMaxCircleRadius, MIN_RADIUS } from '../../circle-tool/utils';
1617
import { isShapeWithinRoi } from '../../utils';
17-
import { ANCHOR_SIZE, ResizeAnchor } from '../resize-anchor.component';
1818
import { ResizeAnchorType } from '../resize-anchor.enum';
1919
import { TranslateShape } from '../translate-shape.component';
2020

web_ui/src/pages/annotator/tools/edit-tool/edit-keypoint/edit-keypoint-tool.component.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import { useEffect, useRef, useState } from 'react';
55

6+
import { ANCHOR_SIZE, ResizeAnchor } from '@geti/smart-tools';
67
import { getBoundingBox } from '@geti/smart-tools/utils';
78

89
import { KeypointAnnotation } from '../../../../../core/annotations/annotation.interface';
@@ -20,7 +21,6 @@ import {
2021
MIN_BOUNDING_BOX_SIZE,
2122
rotatePointsAroundPivot,
2223
} from '../../keypoint-tool/utils';
23-
import { ANCHOR_SIZE, ResizeAnchor } from '../resize-anchor.component';
2424
import { TranslateShape } from '../translate-shape.component';
2525
import { getBoundingBoxInRoi, getBoundingBoxResizePoints, getClampedBoundingBox } from '../utils';
2626
import { ClosestKeypoint } from './closest-keypoint.component';

web_ui/src/pages/annotator/tools/edit-tool/edit-keypoint/edit-pose-point.component.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import { useRef } from 'react';
55

6+
import { ResizeAnchor } from '@geti/smart-tools';
67
import { Invisible, Visible } from '@geti/ui/icons';
78

89
import { RegionOfInterest } from '../../../../../core/annotations/annotation.interface';
@@ -15,7 +16,6 @@ import { PoseKeypointVisibility } from '../../../annotation/shapes/pose-keypoint
1516
import { useAnnotatorCanvasSettings } from '../../../providers/annotator-canvas-settings-provider/annotator-canvas-settings-provider.component';
1617
import { useAnnotatorContextMenu } from '../../../providers/annotator-context-menu-provider/annotator-context-menu-provider.component';
1718
import { useZoom } from '../../../zoom/zoom-provider.component';
18-
import { ResizeAnchor } from '../resize-anchor.component';
1919
import { ResizeAnchorType } from '../resize-anchor.enum';
2020

2121
export interface EditPosePointToolProps {

web_ui/src/pages/annotator/tools/edit-tool/edit-polygon/edit-points.component.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import { PointerEvent, RefObject, useEffect, useRef, useState } from 'react';
55

6+
import { ANCHOR_SIZE, ResizeAnchor } from '@geti/smart-tools';
67
import { Delete } from '@geti/ui/icons';
78
import { isEmpty, noop } from 'lodash-es';
89

@@ -15,7 +16,6 @@ import { isKeyboardDelete } from '../../../../media/utils';
1516
import { getRelativePoint, projectPointOnLine } from '../../../../utils';
1617
import { useAnnotationScene } from '../../../providers/annotation-scene-provider/annotation-scene-provider.component';
1718
import { useAnnotatorContextMenu } from '../../../providers/annotator-context-menu-provider/annotator-context-menu-provider.component';
18-
import { ANCHOR_SIZE, ResizeAnchor } from '../resize-anchor.component';
1919
import { selectAnchorPointLabel } from './utils';
2020

2121
interface EditPointsProps {

web_ui/src/pages/annotator/tools/edit-tool/edit-rotated-bounding-box/edit-rotated-bounding-box.component.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import { useEffect, useState } from 'react';
55

6+
import { ANCHOR_SIZE, ResizeAnchor } from '@geti/smart-tools';
67
import {
78
calculateSizeAndPositionBasedOfCornerAnchor,
89
calculateSizeAndPositionOfSideAnchor,
@@ -18,7 +19,6 @@ import { AnnotationToolContext } from '../../../core/annotation-tool-context.int
1819
import { useROI } from '../../../providers/region-of-interest-provider/region-of-interest-provider.component';
1920
import { useZoom } from '../../../zoom/zoom-provider.component';
2021
import { isShapeWithinRoi } from '../../utils';
21-
import { ANCHOR_SIZE, ResizeAnchor } from '../resize-anchor.component';
2222
import { ResizeAnchorType } from '../resize-anchor.enum';
2323
import { TranslateShape } from '../translate-shape.component';
2424
import { getSideAnchorLocations } from './location';

web_ui/src/pages/annotator/tools/edit-tool/edit-rotated-bounding-box/edit-rotated-bounding-box.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33

44
import '@wessberg/pointer-events';
55

6+
import { ANCHOR_SIZE } from '@geti/smart-tools';
67
import { fireEvent, render, screen } from '@testing-library/react';
78

89
import { ShapeType } from '../../../../../core/annotations/shapetype.enum';
910
import { fakeAnnotationToolContext } from '../../../../../test-utils/fake-annotator-context';
1011
import { getMockedImage, getMockedROI } from '../../../../../test-utils/utils';
11-
import { ANCHOR_SIZE } from '../resize-anchor.component';
1212
import { EditRotatedBoundingBox as EditRotatedBoundingBoxTool } from './edit-rotated-bounding-box.component';
1313

1414
const mockROI = getMockedROI({ x: 0, y: 0, width: 1000, height: 1000 });

0 commit comments

Comments
 (0)