Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions cvat-core/src/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,7 @@
use_cache: undefined,
copy_data: undefined,
dimension: undefined,
allowed_annotation_mode: undefined,
};

const updatedFields = new FieldUpdateTrigger({
Expand Down Expand Up @@ -1049,6 +1050,16 @@
description: {
get: () => data.description,
},
/**
* @name allowedAnnotationMode
* @type {string}
* @memberof module:API.cvat.classes.Task
* @instance
* @throws {module:API.cvat.exceptions.ArgumentError}
*/
allowedAnnotationMode: {
get: () => data.allowed_annotation_mode,
},
/**
* @name projectId
* @type {integer|null}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import React from 'react';
import Layout from 'antd/lib/layout';

import { ActiveControl, Rotation } from 'reducers/interfaces';
import { ActiveControl, Rotation, AllowedInstruments } from 'reducers/interfaces';
import GlobalHotKeys, { KeyMap } from 'utils/mousetrap-react';
import { Canvas } from 'cvat-canvas-wrapper';

Expand Down Expand Up @@ -33,6 +33,7 @@ interface Props {
keyMap: KeyMap;
normalizedKeyMap: Record<string, string>;
labels: any[];
allowedAnnotationMode: string;

mergeObjects(enabled: boolean): void;
groupObjects(enabled: boolean): void;
Expand Down Expand Up @@ -70,6 +71,7 @@ export default function ControlsSideBarComponent(props: Props): JSX.Element {
normalizedKeyMap,
keyMap,
labels,
allowedAnnotationMode,
mergeObjects,
groupObjects,
splitTrack,
Expand Down Expand Up @@ -224,29 +226,33 @@ export default function ControlsSideBarComponent(props: Props): JSX.Element {
<ObservedDrawRectangleControl
canvasInstance={canvasInstance}
isDrawing={activeControl === ActiveControl.DRAW_RECTANGLE}
disabled={!labels.length}
disabled={!labels.length || allowedAnnotationMode !== AllowedInstruments.RECTANGLE}
/>
<ObservedDrawPolygonControl
canvasInstance={canvasInstance}
isDrawing={activeControl === ActiveControl.DRAW_POLYGON}
disabled={!labels.length}
disabled={!labels.length || allowedAnnotationMode !== AllowedInstruments.POLYSHAPE}
/>
<ObservedDrawPolylineControl
canvasInstance={canvasInstance}
isDrawing={activeControl === ActiveControl.DRAW_POLYLINE}
disabled={!labels.length}
disabled={!labels.length || allowedAnnotationMode !== AllowedInstruments.POLYSHAPE}
/>
<ObservedDrawPointsControl
canvasInstance={canvasInstance}
isDrawing={activeControl === ActiveControl.DRAW_POINTS}
disabled={!labels.length}
disabled={!labels.length || allowedAnnotationMode !== AllowedInstruments.POLYSHAPE}
/>
<ObservedDrawCuboidControl
canvasInstance={canvasInstance}
isDrawing={activeControl === ActiveControl.DRAW_CUBOID}
disabled={!labels.length}
disabled={!labels.length || allowedAnnotationMode !== AllowedInstruments.POLYSHAPE}
/>
<ObservedSetupTagControl
canvasInstance={canvasInstance}
isDrawing={false}
disabled={!labels.length || allowedAnnotationMode !== AllowedInstruments.TAG}
/>
<ObservedSetupTagControl canvasInstance={canvasInstance} isDrawing={false} disabled={!labels.length} />

<hr />

Expand All @@ -255,22 +261,22 @@ export default function ControlsSideBarComponent(props: Props): JSX.Element {
canvasInstance={canvasInstance}
activeControl={activeControl}
mergeObjects={mergeObjects}
disabled={!labels.length}
disabled={!labels.length || allowedAnnotationMode !== AllowedInstruments.POLYSHAPE}
/>
<ObservedGroupControl
switchGroupShortcut={normalizedKeyMap.SWITCH_GROUP_MODE}
resetGroupShortcut={normalizedKeyMap.RESET_GROUP}
canvasInstance={canvasInstance}
activeControl={activeControl}
groupObjects={groupObjects}
disabled={!labels.length}
disabled={!labels.length || allowedAnnotationMode !== AllowedInstruments.POLYSHAPE}
/>
<ObservedSplitControl
canvasInstance={canvasInstance}
switchSplitShortcut={normalizedKeyMap.SWITCH_SPLIT_MODE}
activeControl={activeControl}
splitTrack={splitTrack}
disabled={!labels.length}
disabled={!labels.length || allowedAnnotationMode !== AllowedInstruments.POLYSHAPE}
/>

<ExtraControlsControl />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import getCore from 'cvat-core-wrapper';
import openCVWrapper from 'utils/opencv-wrapper/opencv-wrapper';
import { IntelligentScissors } from 'utils/opencv-wrapper/intelligent-scissors';
import {
CombinedState, ActiveControl, OpenCVTool, ObjectType,
CombinedState, ActiveControl, OpenCVTool, ObjectType, AllowedInstruments,
} from 'reducers/interfaces';
import {
interactWithCanvas,
Expand Down Expand Up @@ -383,7 +383,9 @@ class OpenCVControlComponent extends React.PureComponent<Props & DispatchToProps
}

public render(): JSX.Element {
const { isActivated, canvasInstance, labels } = this.props;
const {
isActivated, canvasInstance, labels, jobInstance,
} = this.props;
const dynamcPopoverPros = isActivated ?
{
overlayStyle: {
Expand All @@ -403,7 +405,7 @@ class OpenCVControlComponent extends React.PureComponent<Props & DispatchToProps
className: 'cvat-tools-control',
};

return !labels.length ? (
return !labels.length || jobInstance.task.allowedAnnotationMode !== AllowedInstruments.POLYSHAPE ? (
<Icon className='cvat-opencv-control cvat-disabled-canvas-control' component={OpenCVIcon} />
) : (
<CustomPopover
Expand Down
14 changes: 12 additions & 2 deletions cvat-ui/src/components/annotation-page/top-bar/right-group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
FilterIcon, FullscreenIcon, InfoIcon, BrainIcon,
} from 'icons';
import {
CombinedState, DimensionType, Workspace, PredictorState,
CombinedState, DimensionType, Workspace, PredictorState, AllowedInstruments,
} from 'reducers/interfaces';

interface Props {
Expand Down Expand Up @@ -185,9 +185,19 @@ function RightGroup(props: Props): JSX.Element {
</Select.Option>
);
}
if (jobInstance.task.allowedAnnotationMode === AllowedInstruments.TAG) {
if (ws === Workspace.STANDARD3D) {
return null;
}
return (
<Select.Option disabled={ws === Workspace.ATTRIBUTE_ANNOTATION} key={ws} value={ws}>
{ws}
</Select.Option>
);
}
if (ws !== Workspace.STANDARD3D) {
return (
<Select.Option key={ws} value={ws}>
<Select.Option disabled={ws !== Workspace.STANDARD} key={ws} value={ws}>
Comment thread
vkomodey marked this conversation as resolved.
{ws}
</Select.Option>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ interface StateToProps {
keyMap: KeyMap;
normalizedKeyMap: Record<string, string>;
labels: any[];
type: string;
}

interface DispatchToProps {
Expand All @@ -43,7 +44,12 @@ function mapStateToProps(state: CombinedState): StateToProps {
const {
annotation: {
canvas: { instance: canvasInstance, activeControl },
job: { labels },
job: {
labels,
instance: {
task: { allowedAnnotationMode },
},
},
},
settings: {
player: { rotateAll },
Expand All @@ -58,6 +64,7 @@ function mapStateToProps(state: CombinedState): StateToProps {
labels,
normalizedKeyMap,
keyMap,
allowedAnnotationMode,
};
}

Expand Down
6 changes: 6 additions & 0 deletions cvat-ui/src/reducers/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,12 @@ export enum Workspace {
TAG_ANNOTATION = 'Tag annotation',
}

export enum AllowedInstruments {
RECTANGLE = 'Rectangle',
POLYSHAPE = 'Polyshape',
TAG = 'Tag',
}

export enum GridColor {
White = 'White',
Black = 'Black',
Expand Down
18 changes: 18 additions & 0 deletions cvat/apps/engine/migrations/0045_task_allowed_annotation_mode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.1.13 on 2021-10-25 15:28

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('engine', '0044_task_description'),
]

operations = [
migrations.AddField(
model_name='task',
name='allowed_annotation_mode',
field=models.CharField(blank=True, default='', max_length=64),
),
]
1 change: 1 addition & 0 deletions cvat/apps/engine/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ class Task(models.Model):
dimension = models.CharField(max_length=2, choices=DimensionType.choices(), default=DimensionType.DIM_2D)
subset = models.CharField(max_length=64, blank=True, default="")
is_exchange_notified = models.BooleanField(default=False)
allowed_annotation_mode = models.CharField(max_length=64, blank=True, default="")

# Extend default permission model
class Meta:
Expand Down
2 changes: 1 addition & 1 deletion cvat/apps/engine/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ class Meta:
'bug_tracker', 'created_date', 'updated_date', 'overlap',
'segment_size', 'status', 'labels', 'segments',
'data_chunk_size', 'data_compressed_chunk_type', 'data_original_chunk_type', 'size', 'image_quality',
'data', 'dimension', 'subset')
'data', 'dimension', 'subset', 'allowed_annotation_mode')
Comment thread
vkomodey marked this conversation as resolved.
read_only_fields = ('mode', 'created_date', 'updated_date', 'status', 'data_chunk_size', 'owner', 'assignee',
'data_compressed_chunk_type', 'data_original_chunk_type', 'size', 'image_quality', 'data')
write_once_fields = ('overlap', 'segment_size', 'project_id')
Expand Down