Skip to content

Commit db868d8

Browse files
nick-skriabinrobot-ci-heartexhlomzik
authored andcommitted
fix: BROS-464: Vector region selection (#8636)
Co-authored-by: robot-ci-heartex <robot-ci-heartex@users.noreply.github.com> Co-authored-by: hlomzik <hlomzik@users.noreply.github.com> Co-authored-by: nick-skriabin <nick-skriabin@users.noreply.github.com>
1 parent 20e78bb commit db868d8

File tree

12 files changed

+996
-280
lines changed

12 files changed

+996
-280
lines changed

docs/source/includes/tags/vector.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
| [skeleton] | <code>boolean</code> | <code>false</code> | Enables skeleton mode to allow branch paths |
1919
| [minPoints] | <code>number</code> \| <code>none</code> | <code>none</code> | Minimum allowed number of points |
2020
| [maxPoints] | <code>number</code> \| <code>none</code> | <code>none</code> | Maximum allowed number of points |
21-
| [constrainToBounds] | <code>boolean</code> | <code>false</code> | Whether to keep shapes inside image bounds |
2221
| [pointSizeEnabled] | <code>number</code> | <code>5</code> | Size of a point in pixels when shape is selected |
2322
| [pointSizeDisabled] | <code>number</code> | <code>3</code> | Size of a point in pixels when shape is not selected |
2423

docs/source/includes/tags/vectorlabels.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
| [skeleton] | <code>boolean</code> | <code>false</code> | Enables skeleton mode to allow branch paths |
2020
| [minPoints] | <code>number</code> \| <code>none</code> | <code>none</code> | Minimum allowed number of points |
2121
| [maxPoints] | <code>number</code> \| <code>none</code> | <code>none</code> | Maximum allowed number of points |
22-
| [constrainToBounds] | <code>boolean</code> | <code>false</code> | Whether to keep shapes inside image bounds |
2322
| [pointsizeenabled] | <code>number</code> | <code>5</code> | Size of a point in pixels when shape is selected |
2423
| [pointsizedisabled] | <code>number</code> | <code>5</code> | Size of a point in pixels when shape is not selected |
2524

web/libs/core/src/lib/utils/schema/tags.json

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2738,13 +2738,6 @@
27382738
"required": false,
27392739
"default": "none"
27402740
},
2741-
"constrainToBounds": {
2742-
"name": "constrainToBounds",
2743-
"description": "Whether to keep shapes inside image bounds",
2744-
"type": ["true", "false"],
2745-
"required": false,
2746-
"default": false
2747-
},
27482741
"pointSizeEnabled": {
27492742
"name": "pointSizeEnabled",
27502743
"description": "Size of a point in pixels when shape is selected",
@@ -2763,7 +2756,7 @@
27632756
},
27642757
"VectorLabels": {
27652758
"name": "VectorLabels",
2766-
"description": "The `VectorLabels` tag is used to create labeled vectors. Use to apply labels to vectors in semantic segmentation tasks.\n\nUse with the following data types: image.\n\n## Key Features\n\n### Point Management\n- **Add Points**: Click on empty space, Shift+click on path segments\n- **Edit Points**: Drag to reposition, Shift+click to convert regular ↔ bezier\n- **Delete Points**: Alt+click on existing points\n- **Multi-Selection**: Select multiple points for batch transformations\n- **Break Closed Path**: Alt+click on any segment of a closed path to break it at that specific segment\n\n### Bezier Curves\n- **Create**: Drag while adding points or convert existing points\n- **Edit**: Drag control points, disconnect/reconnect control handles\n- **Control**: `curves` prop to enable/disable bezier functionality\n\n## Keyboard Shortcuts & Hotkeys\n\n### Point Creation & Editing\n- **Click**: Add new point in drawing mode\n- **Shift + Click** on a segment: Add point on path segment (insert between existing points)\n- **Shift + Drag**: Create bezier point with control handles\n- **Shift + Click** on a point: Convert point between regular ↔ bezier\n- **Alt + Click** on a segment: Break closed path at segment (when path is closed)\n\n### Point Selection\n- **Click**: Select single point\n- **Cmd/Ctrl + Click**: Add point to multi-selection\n- **Cmd/Ctrl + Click on shape**: Select all points in the path\n- **Cmd/Ctrl + Click on point**: Toggle point selection in multi-selection\n\n### Path Management\n- **Click on first/last point**: Close path bidirectionally (first→last or last→first)\n- **Shift + Click**: Add point on path segment without closing\n\n### Bezier Curve Control\n- **Drag control points**: Adjust curve shape\n- **Alt + Drag control point**: Disconnect control handles (make asymmetric)\n- **Shift + Drag**: Create new bezier point with control handles\n\n### Multi-Selection & Transformation\n- **Select multiple points**: Use Cmd/Ctrl + Click to build selection\n- **Transform selection**: Use transformer handles for rotation, scaling, and translation\n- **Clear selection**: Click on any point\n\n## Usage Examples\n\n### Basic Vector Path\n```jsx\n<View>\n <Image name=\"image\" value=\"$image\" />\n <VectorLabels name=\"labels\" toName=\"image\">\n <Label value=\"Road\" />\n <Label value=\"Boundary\" />\n </VectorLabels>\n</View>\n```\n\n### Polygon with Bezier Support\n```jsx\n<View>\n <Image name=\"image\" value=\"$image\" />\n <VectorLabels\n name=\"polygons\"\n toName=\"image\"\n closable={true}\n curves={true}\n minPoints=\"3\"\n maxPoints=\"20\"\n >\n <Label value=\"Building\" />\n <Label value=\"Park\" />\n </VectorLabels>\n</View>\n```\n\n### Skeleton Mode for Branching Paths\n```jsx\n<View>\n <Image name=\"image\" value=\"$image\" />\n <VectorLabels\n name=\"skeleton\"\n toName=\"image\"\n skeleton={true}\n closable={false}\n curves={true}\n >\n <Label value=\"Tree\" />\n <Label value=\"Branch\" />\n </VectorLabels>\n</View>\n```\n\n### Keypoint Annotation Tool\n```jsx\n<View>\n <Image name=\"image\" value=\"$image\" />\n <VectorLabels\n name=\"keypoints\"\n toName=\"image\"\n closable={false}\n curves={false}\n minPoints=\"1\"\n maxPoints=\"1\"\n >\n <Label value=\"Eye\" />\n <Label value=\"Nose\" />\n <Label value=\"Mouth\" />\n </VectorLabels>\n</View>\n```\n\n### Constrained Drawing\n```jsx\n<View>\n <Image name=\"image\" value=\"$image\" />\n <VectorLabels\n name=\"constrained\"\n toName=\"image\"\n closable={true}\n curves={true}\n constraintoBounds={true}\n snap=\"pixel\"\n minPoints=\"4\"\n maxPoints=\"12\"\n >\n <Label value=\"Region\" />\n </VectorLabels>\n</View>\n```\n\n## Advanced Features\n\n### Path Breaking\nWhen a path is closed, you can break it at any segment:\n- **Alt + Click** on any segment of a closed path\n- The path breaks at that segment\n- The breaking point becomes the first element\n- The point before breaking becomes active\n\n### Skeleton Mode\n- **Purpose**: Create branching paths instead of linear sequences\n- **Behavior**: New points connect to the active point, not the last added point\n- **Use Case**: Tree structures, network diagrams, anatomical features\n\n### Bezier Curve Management\n- **Symmetric Control**: By default, control points move symmetrically\n- **Asymmetric Control**: Hold Alt while dragging to disconnect handles\n- **Control Point Visibility**: Control points are shown when editing bezier points\n\n### Multi-Selection Workflow\n1. **Build Selection**: Use Cmd/Ctrl + Click to add points\n2. **Transform**: Use transformer handles for rotation, scaling, translation\n3. **Batch Operations**: Apply transformations to all selected points\n4. **Clear**: Click outside or use programmatic methods\n\n## Props Reference",
2759+
"description": "The `VectorLabels` tag is used to create labeled vectors. Use to apply labels to vectors in semantic segmentation tasks.\n\nUse with the following data types: image.\n\n## Key Features\n\n### Point Management\n- **Add Points**: Click on empty space, Shift+click on path segments\n- **Edit Points**: Drag to reposition, Shift+click to convert regular ↔ bezier\n- **Delete Points**: Alt+click on existing points\n- **Multi-Selection**: Select multiple points for batch transformations\n- **Break Closed Path**: Alt+click on any segment of a closed path to break it at that specific segment\n\n### Bezier Curves\n- **Create**: Drag while adding points or convert existing points\n- **Edit**: Drag control points, disconnect/reconnect control handles\n- **Control**: `curves` prop to enable/disable bezier functionality\n\n## Keyboard Shortcuts & Hotkeys\n\n### Point Creation & Editing\n- **Click**: Add new point in drawing mode\n- **Shift + Click** on a segment: Add point on path segment (insert between existing points)\n- **Shift + Drag**: Create bezier point with control handles\n- **Shift + Click** on a point: Convert point between regular ↔ bezier\n- **Alt + Click** on a segment: Break closed path at segment (when path is closed)\n\n### Point Selection\n- **Click**: Select single point\n- **Cmd/Ctrl + Click**: Add point to multi-selection\n- **Cmd/Ctrl + Click on shape**: Select all points in the path\n- **Cmd/Ctrl + Click on point**: Toggle point selection in multi-selection\n\n### Path Management\n- **Click on first/last point**: Close path bidirectionally (first→last or last→first)\n- **Shift + Click**: Add point on path segment without closing\n\n### Bezier Curve Control\n- **Drag control points**: Adjust curve shape\n- **Alt + Drag control point**: Disconnect control handles (make asymmetric)\n- **Shift + Drag**: Create new bezier point with control handles\n\n### Multi-Selection & Transformation\n- **Select multiple points**: Use Cmd/Ctrl + Click to build selection\n- **Transform selection**: Use transformer handles for rotation, scaling, and translation\n- **Clear selection**: Click on any point\n\n## Usage Examples\n\n### Basic Vector Path\n```jsx\n<View>\n <Image name=\"image\" value=\"$image\" />\n <VectorLabels name=\"labels\" toName=\"image\">\n <Label value=\"Road\" />\n <Label value=\"Boundary\" />\n </VectorLabels>\n</View>\n```\n\n### Polygon with Bezier Support\n```jsx\n<View>\n <Image name=\"image\" value=\"$image\" />\n <VectorLabels\n name=\"polygons\"\n toName=\"image\"\n closable={true}\n curves={true}\n minPoints=\"3\"\n maxPoints=\"20\"\n >\n <Label value=\"Building\" />\n <Label value=\"Park\" />\n </VectorLabels>\n</View>\n```\n\n### Skeleton Mode for Branching Paths\n```jsx\n<View>\n <Image name=\"image\" value=\"$image\" />\n <VectorLabels\n name=\"skeleton\"\n toName=\"image\"\n skeleton={true}\n closable={false}\n curves={true}\n >\n <Label value=\"Tree\" />\n <Label value=\"Branch\" />\n </VectorLabels>\n</View>\n```\n\n### Keypoint Annotation Tool\n```jsx\n<View>\n <Image name=\"image\" value=\"$image\" />\n <VectorLabels\n name=\"keypoints\"\n toName=\"image\"\n closable={false}\n curves={false}\n minPoints=\"1\"\n maxPoints=\"1\"\n >\n <Label value=\"Eye\" />\n <Label value=\"Nose\" />\n <Label value=\"Mouth\" />\n </VectorLabels>\n</View>\n```\n\n## Advanced Features\n\n### Path Breaking\nWhen a path is closed, you can break it at any segment:\n- **Alt + Click** on any segment of a closed path\n- The path breaks at that segment\n- The breaking point becomes the first element\n- The point before breaking becomes active\n\n### Skeleton Mode\n- **Purpose**: Create branching paths instead of linear sequences\n- **Behavior**: New points connect to the active point, not the last added point\n- **Use Case**: Tree structures, network diagrams, anatomical features\n\n### Bezier Curve Management\n- **Symmetric Control**: By default, control points move symmetrically\n- **Asymmetric Control**: Hold Alt while dragging to disconnect handles\n- **Control Point Visibility**: Control points are shown when editing bezier points\n\n### Multi-Selection Workflow\n1. **Build Selection**: Use Cmd/Ctrl + Click to add points\n2. **Transform**: Use transformer handles for rotation, scaling, translation\n3. **Batch Operations**: Apply transformations to all selected points\n4. **Clear**: Click outside or use programmatic methods\n\n## Props Reference",
27672760
"attrs": {
27682761
"name": {
27692762
"name": "name",
@@ -2879,13 +2872,6 @@
28792872
"required": false,
28802873
"default": "none"
28812874
},
2882-
"constrainToBounds": {
2883-
"name": "constrainToBounds",
2884-
"description": "Whether to keep shapes inside image bounds",
2885-
"type": ["true", "false"],
2886-
"required": false,
2887-
"default": false
2888-
},
28892875
"pointsizeenabled": {
28902876
"name": "pointsizeenabled",
28912877
"description": "Size of a point in pixels when shape is selected",

web/libs/editor/src/components/ImageTransformer/ImageTransformer.jsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,17 @@ export default class TransformerComponent extends Component {
174174
});
175175
};
176176

177+
applyRegionsTransform = () => {
178+
if (!this.transformer) return;
179+
180+
const { item } = this.props;
181+
const { selectedRegions } = item;
182+
183+
selectedRegions.forEach((region) => {
184+
region.applyTransform?.({}, null);
185+
});
186+
};
187+
177188
renderLSTransformer() {
178189
return (
179190
<>
@@ -214,10 +225,14 @@ export default class TransformerComponent extends Component {
214225
}}
215226
dragBoundFunc={this.dragBoundFunc}
216227
onDragEnd={() => {
228+
// Call applyTransform for VectorRegion instances
229+
this.applyRegionsTransform();
217230
this.unfreeze();
218231
setTimeout(this.checkNode);
219232
}}
220233
onTransformEnd={() => {
234+
// Call applyTransform for VectorRegion instances
235+
this.applyRegionsTransform();
221236
setTimeout(this.checkNode);
222237
}}
223238
backSelector={this.props.draggableBackgroundSelector}
@@ -262,10 +277,14 @@ export default class TransformerComponent extends Component {
262277
}}
263278
dragBoundFunc={this.dragBoundFunc}
264279
onDragEnd={() => {
280+
// Call applyTransform for VectorRegion instances
281+
this.applyRegionsTransform();
265282
this.unfreeze();
266283
setTimeout(this.checkNode);
267284
}}
268285
onTransformEnd={() => {
286+
// Call applyTransform for VectorRegion instances
287+
this.applyRegionsTransform();
269288
setTimeout(this.checkNode);
270289
}}
271290
backSelector={this.props.draggableBackgroundSelector}

0 commit comments

Comments
 (0)