|
|
|
|
@ -7,12 +7,7 @@ import copy from 'copy-to-clipboard';
|
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
|
|
|
|
|
import { LogType } from 'cvat-logger';
|
|
|
|
|
import {
|
|
|
|
|
ActiveControl,
|
|
|
|
|
CombinedState,
|
|
|
|
|
ColorBy,
|
|
|
|
|
ShapeType,
|
|
|
|
|
} from 'reducers/interfaces';
|
|
|
|
|
import { ActiveControl, CombinedState, ColorBy, ShapeType } from 'reducers/interfaces';
|
|
|
|
|
import {
|
|
|
|
|
collapseObjectItems,
|
|
|
|
|
updateAnnotationsAsync,
|
|
|
|
|
@ -31,6 +26,7 @@ import { shift } from 'utils/math';
|
|
|
|
|
|
|
|
|
|
interface OwnProps {
|
|
|
|
|
clientID: number;
|
|
|
|
|
objectStates: any[];
|
|
|
|
|
initialCollapsed: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -66,46 +62,30 @@ function mapStateToProps(state: CombinedState, own: OwnProps): StateToProps {
|
|
|
|
|
const {
|
|
|
|
|
annotation: {
|
|
|
|
|
annotations: {
|
|
|
|
|
states,
|
|
|
|
|
collapsed: statesCollapsed,
|
|
|
|
|
activatedStateID,
|
|
|
|
|
zLayer: {
|
|
|
|
|
min: minZLayer,
|
|
|
|
|
max: maxZLayer,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
job: {
|
|
|
|
|
attributes: jobAttributes,
|
|
|
|
|
instance: jobInstance,
|
|
|
|
|
labels,
|
|
|
|
|
zLayer: { min: minZLayer, max: maxZLayer },
|
|
|
|
|
},
|
|
|
|
|
job: { attributes: jobAttributes, instance: jobInstance, labels },
|
|
|
|
|
player: {
|
|
|
|
|
frame: {
|
|
|
|
|
number: frameNumber,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
canvas: {
|
|
|
|
|
ready,
|
|
|
|
|
activeControl,
|
|
|
|
|
frame: { number: frameNumber },
|
|
|
|
|
},
|
|
|
|
|
canvas: { ready, activeControl },
|
|
|
|
|
aiToolsRef,
|
|
|
|
|
},
|
|
|
|
|
settings: {
|
|
|
|
|
shapes: {
|
|
|
|
|
colorBy,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
shortcuts: {
|
|
|
|
|
normalizedKeyMap,
|
|
|
|
|
shapes: { colorBy },
|
|
|
|
|
},
|
|
|
|
|
shortcuts: { normalizedKeyMap },
|
|
|
|
|
} = state;
|
|
|
|
|
|
|
|
|
|
const { objectStates: states, initialCollapsed, clientID } = own;
|
|
|
|
|
const stateIDs = states.map((_state: any): number => _state.clientID);
|
|
|
|
|
const index = stateIDs.indexOf(own.clientID);
|
|
|
|
|
const index = stateIDs.indexOf(clientID);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const collapsedState = typeof (statesCollapsed[own.clientID]) === 'undefined'
|
|
|
|
|
? own.initialCollapsed : statesCollapsed[own.clientID];
|
|
|
|
|
const collapsedState =
|
|
|
|
|
typeof statesCollapsed[clientID] === 'undefined' ? initialCollapsed : statesCollapsed[clientID];
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
objectState: states[index],
|
|
|
|
|
@ -117,7 +97,7 @@ function mapStateToProps(state: CombinedState, own: OwnProps): StateToProps {
|
|
|
|
|
colorBy,
|
|
|
|
|
jobInstance,
|
|
|
|
|
frameNumber,
|
|
|
|
|
activated: activatedStateID === own.clientID,
|
|
|
|
|
activated: activatedStateID === clientID,
|
|
|
|
|
minZLayer,
|
|
|
|
|
maxZLayer,
|
|
|
|
|
normalizedKeyMap,
|
|
|
|
|
@ -133,7 +113,9 @@ function mapStateToProps(state: CombinedState, own: OwnProps): StateToProps {
|
|
|
|
|
clientID: own.clientID,
|
|
|
|
|
stateIDs,
|
|
|
|
|
};
|
|
|
|
|
throw new Error(`${exception.toString()} in mapStateToProps of ObjectItemContainer. Data are ${JSON.stringify(dataObject)}`);
|
|
|
|
|
throw new Error(
|
|
|
|
|
`${exception.toString()} in mapStateToProps of ObjectItemContainer. Data are ${JSON.stringify(dataObject)}`,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -180,25 +162,15 @@ class ObjectItemContainer extends React.PureComponent<Props> {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private remove = (): void => {
|
|
|
|
|
const {
|
|
|
|
|
objectState,
|
|
|
|
|
removeObject,
|
|
|
|
|
jobInstance,
|
|
|
|
|
} = this.props;
|
|
|
|
|
const { objectState, removeObject, jobInstance } = this.props;
|
|
|
|
|
|
|
|
|
|
removeObject(jobInstance, objectState);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private createURL = (): void => {
|
|
|
|
|
const {
|
|
|
|
|
objectState,
|
|
|
|
|
frameNumber,
|
|
|
|
|
} = this.props;
|
|
|
|
|
const { objectState, frameNumber } = this.props;
|
|
|
|
|
|
|
|
|
|
const {
|
|
|
|
|
origin,
|
|
|
|
|
pathname,
|
|
|
|
|
} = window.location;
|
|
|
|
|
const { origin, pathname } = window.location;
|
|
|
|
|
|
|
|
|
|
const search = `frame=${frameNumber}&type=${objectState.objectType}&serverID=${objectState.serverID}`;
|
|
|
|
|
const url = `${origin}${pathname}?${search}`;
|
|
|
|
|
@ -219,12 +191,12 @@ class ObjectItemContainer extends React.PureComponent<Props> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return acc;
|
|
|
|
|
}, [],
|
|
|
|
|
},
|
|
|
|
|
[],
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (objectState.shapeType === ShapeType.POLYGON) {
|
|
|
|
|
objectState.points = reducedPoints.slice(0, 1)
|
|
|
|
|
.concat(reducedPoints.reverse().slice(0, -1)).flat();
|
|
|
|
|
objectState.points = reducedPoints.slice(0, 1).concat(reducedPoints.reverse().slice(0, -1)).flat();
|
|
|
|
|
updateState(objectState);
|
|
|
|
|
} else if (objectState.shapeType === ShapeType.POLYLINE) {
|
|
|
|
|
objectState.points = reducedPoints.reverse().flat();
|
|
|
|
|
@ -233,32 +205,21 @@ class ObjectItemContainer extends React.PureComponent<Props> {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private toBackground = (): void => {
|
|
|
|
|
const {
|
|
|
|
|
objectState,
|
|
|
|
|
minZLayer,
|
|
|
|
|
} = this.props;
|
|
|
|
|
const { objectState, minZLayer } = this.props;
|
|
|
|
|
|
|
|
|
|
objectState.zOrder = minZLayer - 1;
|
|
|
|
|
this.commit();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private toForeground = (): void => {
|
|
|
|
|
const {
|
|
|
|
|
objectState,
|
|
|
|
|
maxZLayer,
|
|
|
|
|
} = this.props;
|
|
|
|
|
const { objectState, maxZLayer } = this.props;
|
|
|
|
|
|
|
|
|
|
objectState.zOrder = maxZLayer + 1;
|
|
|
|
|
this.commit();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private activate = (): void => {
|
|
|
|
|
const {
|
|
|
|
|
activateObject,
|
|
|
|
|
objectState,
|
|
|
|
|
ready,
|
|
|
|
|
activeControl,
|
|
|
|
|
} = this.props;
|
|
|
|
|
const { activateObject, objectState, ready, activeControl } = this.props;
|
|
|
|
|
|
|
|
|
|
if (ready && activeControl === ActiveControl.CURSOR) {
|
|
|
|
|
activateObject(objectState.clientID);
|
|
|
|
|
@ -266,11 +227,7 @@ class ObjectItemContainer extends React.PureComponent<Props> {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private collapse = (): void => {
|
|
|
|
|
const {
|
|
|
|
|
collapseOrExpand,
|
|
|
|
|
objectState,
|
|
|
|
|
collapsed,
|
|
|
|
|
} = this.props;
|
|
|
|
|
const { collapseOrExpand, objectState, collapsed } = this.props;
|
|
|
|
|
|
|
|
|
|
collapseOrExpand([objectState], !collapsed);
|
|
|
|
|
};
|
|
|
|
|
@ -283,11 +240,7 @@ class ObjectItemContainer extends React.PureComponent<Props> {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private changeColor = (color: string): void => {
|
|
|
|
|
const {
|
|
|
|
|
objectState,
|
|
|
|
|
colorBy,
|
|
|
|
|
changeGroupColor,
|
|
|
|
|
} = this.props;
|
|
|
|
|
const { objectState, colorBy, changeGroupColor } = this.props;
|
|
|
|
|
|
|
|
|
|
if (colorBy === ColorBy.INSTANCE) {
|
|
|
|
|
objectState.color = color;
|
|
|
|
|
@ -298,10 +251,7 @@ class ObjectItemContainer extends React.PureComponent<Props> {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private changeLabel = (labelID: string): void => {
|
|
|
|
|
const {
|
|
|
|
|
objectState,
|
|
|
|
|
labels,
|
|
|
|
|
} = this.props;
|
|
|
|
|
const { objectState, labels } = this.props;
|
|
|
|
|
|
|
|
|
|
const [label] = labels.filter((_label: any): boolean => _label.id === +labelID);
|
|
|
|
|
objectState.label = label;
|
|
|
|
|
@ -330,8 +280,7 @@ class ObjectItemContainer extends React.PureComponent<Props> {
|
|
|
|
|
|
|
|
|
|
this.resetCuboidPerspective(false);
|
|
|
|
|
|
|
|
|
|
objectState.points = shift(objectState.points,
|
|
|
|
|
cuboidOrientationIsLeft(objectState.points) ? 4 : -4);
|
|
|
|
|
objectState.points = shift(objectState.points, cuboidOrientationIsLeft(objectState.points) ? 4 : -4);
|
|
|
|
|
|
|
|
|
|
this.commit();
|
|
|
|
|
};
|
|
|
|
|
@ -369,24 +318,13 @@ class ObjectItemContainer extends React.PureComponent<Props> {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private commit(): void {
|
|
|
|
|
const {
|
|
|
|
|
objectState,
|
|
|
|
|
updateState,
|
|
|
|
|
} = this.props;
|
|
|
|
|
const { objectState, updateState } = this.props;
|
|
|
|
|
|
|
|
|
|
updateState(objectState);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public render(): JSX.Element {
|
|
|
|
|
const {
|
|
|
|
|
objectState,
|
|
|
|
|
collapsed,
|
|
|
|
|
labels,
|
|
|
|
|
attributes,
|
|
|
|
|
activated,
|
|
|
|
|
colorBy,
|
|
|
|
|
normalizedKeyMap,
|
|
|
|
|
} = this.props;
|
|
|
|
|
const { objectState, collapsed, labels, attributes, activated, colorBy, normalizedKeyMap } = this.props;
|
|
|
|
|
|
|
|
|
|
let stateColor = '';
|
|
|
|
|
if (colorBy === ColorBy.INSTANCE) {
|
|
|
|
|
|