diff --git a/cvat-core/package.json b/cvat-core/package.json index 5467bfc2899..63ef4136909 100644 --- a/cvat-core/package.json +++ b/cvat-core/package.json @@ -1,6 +1,6 @@ { "name": "cvat-core", - "version": "3.1.1", + "version": "3.1.2", "description": "Part of Computer Vision Tool which presents an interface for client-side integration", "main": "babel.config.js", "scripts": { diff --git a/cvat-core/src/annotations-objects.js b/cvat-core/src/annotations-objects.js index de02f8de6a6..752670fee1c 100644 --- a/cvat-core/src/annotations-objects.js +++ b/cvat-core/src/annotations-objects.js @@ -15,6 +15,7 @@ } = require('./common'); const { colors, + Source, ObjectShape, ObjectType, AttributeType, @@ -296,21 +297,6 @@ }, [this.clientID], frame); } - _saveSource(source, frame) { - const undoSource = this.source; - const redoSource = source; - - this.history.do(HistoryActions.CHANGED_SOURCE, () => { - this.source = undoSource; - this.updated = Date.now(); - }, () => { - this.source = redoSource; - this.updated = Date.now(); - }, [this.clientID], frame); - - this.source = source; - } - _validateStateBeforeSave(frame, data, updated) { let fittedPoints = []; @@ -397,10 +383,6 @@ } } - if (updated.source) { - checkObjectType('source', data.source, 'string', null); - } - return fittedPoints; } @@ -416,8 +398,7 @@ updateTimestamp(updated) { const anyChanges = updated.label || updated.attributes || updated.points || updated.outside || updated.occluded || updated.keyframe - || updated.zOrder || updated.hidden || updated.lock || updated.pinned - || updated.source; + || updated.zOrder || updated.hidden || updated.lock || updated.pinned; if (anyChanges) { this.updated = Date.now(); @@ -549,45 +530,60 @@ _savePoints(points, frame) { const undoPoints = this.points; const redoPoints = points; + const undoSource = this.source; + const redoSource = Source.MANUAL; this.history.do(HistoryActions.CHANGED_POINTS, () => { this.points = undoPoints; + this.source = undoSource; this.updated = Date.now(); }, () => { this.points = redoPoints; + this.source = redoSource; this.updated = Date.now(); }, [this.clientID], frame); + this.source = Source.MANUAL; this.points = points; } _saveOccluded(occluded, frame) { const undoOccluded = this.occluded; const redoOccluded = occluded; + const undoSource = this.source; + const redoSource = Source.MANUAL; this.history.do(HistoryActions.CHANGED_OCCLUDED, () => { this.occluded = undoOccluded; + this.source = undoSource; this.updated = Date.now(); }, () => { this.occluded = redoOccluded; + this.source = redoSource; this.updated = Date.now(); }, [this.clientID], frame); + this.source = Source.MANUAL; this.occluded = occluded; } _saveZOrder(zOrder, frame) { const undoZOrder = this.zOrder; const redoZOrder = zOrder; + const undoSource = this.source; + const redoSource = Source.MANUAL; this.history.do(HistoryActions.CHANGED_ZORDER, () => { this.zOrder = undoZOrder; + this.source = undoSource; this.updated = Date.now(); }, () => { this.zOrder = redoZOrder; + this.source = redoSource; this.updated = Date.now(); }, [this.clientID], frame); + this.source = Source.MANUAL; this.zOrder = zOrder; } @@ -642,10 +638,6 @@ this._saveHidden(data.hidden, frame); } - if (updated.source) { - this._saveSource(data.source, frame); - } - this.updateTimestamp(updated); updated.reset(); @@ -940,13 +932,14 @@ }, [this.clientID], frame); } - _appendShapeActionToHistory(actionType, frame, undoShape, redoShape) { + _appendShapeActionToHistory(actionType, frame, undoShape, redoShape, undoSource, redoSource) { this.history.do(actionType, () => { if (!undoShape) { delete this.shapes[frame]; } else { this.shapes[frame] = undoShape; } + this.source = undoSource; this.updated = Date.now(); }, () => { if (!redoShape) { @@ -954,6 +947,7 @@ } else { this.shapes[frame] = redoShape; } + this.source = redoSource; this.updated = Date.now(); }, [this.clientID], frame); } @@ -961,6 +955,8 @@ _savePoints(points, frame) { const current = this.get(frame); const wasKeyframe = frame in this.shapes; + const undoSource = this.source; + const redoSource = Source.MANUAL; const undoShape = wasKeyframe ? this.shapes[frame] : undefined; const redoShape = wasKeyframe ? { ...this.shapes[frame], points } : { frame, @@ -972,17 +968,22 @@ }; this.shapes[frame] = redoShape; + this.source = Source.MANUAL; this._appendShapeActionToHistory( HistoryActions.CHANGED_POINTS, frame, undoShape, redoShape, + undoSource, + redoSource, ); } _saveOutside(frame, outside) { const current = this.get(frame); const wasKeyframe = frame in this.shapes; + const undoSource = this.source; + const redoSource = Source.MANUAL; const undoShape = wasKeyframe ? this.shapes[frame] : undefined; const redoShape = wasKeyframe ? { ...this.shapes[frame], outside } : { frame, @@ -994,17 +995,22 @@ }; this.shapes[frame] = redoShape; + this.source = Source.MANUAL; this._appendShapeActionToHistory( HistoryActions.CHANGED_OUTSIDE, frame, undoShape, redoShape, + undoSource, + redoSource, ); } _saveOccluded(occluded, frame) { const current = this.get(frame); const wasKeyframe = frame in this.shapes; + const undoSource = this.source; + const redoSource = Source.MANUAL; const undoShape = wasKeyframe ? this.shapes[frame] : undefined; const redoShape = wasKeyframe ? { ...this.shapes[frame], occluded } : { frame, @@ -1016,17 +1022,22 @@ }; this.shapes[frame] = redoShape; + this.source = Source.MANUAL; this._appendShapeActionToHistory( HistoryActions.CHANGED_OCCLUDED, frame, undoShape, redoShape, + undoSource, + redoSource, ); } _saveZOrder(zOrder, frame) { const current = this.get(frame); const wasKeyframe = frame in this.shapes; + const undoSource = this.source; + const redoSource = Source.MANUAL; const undoShape = wasKeyframe ? this.shapes[frame] : undefined; const redoShape = wasKeyframe ? { ...this.shapes[frame], zOrder } : { frame, @@ -1038,11 +1049,14 @@ }; this.shapes[frame] = redoShape; + this.source = Source.MANUAL; this._appendShapeActionToHistory( HistoryActions.CHANGED_ZORDER, frame, undoShape, redoShape, + undoSource, + redoSource, ); } @@ -1055,6 +1069,8 @@ return; } + const undoSource = this.source; + const redoSource = Source.MANUAL; const undoShape = wasKeyframe ? this.shapes[frame] : undefined; const redoShape = keyframe ? { frame, @@ -1066,6 +1082,7 @@ source: current.source, } : undefined; + this.source = Source.MANUAL; if (redoShape) { this.shapes[frame] = redoShape; } else { @@ -1077,6 +1094,8 @@ frame, undoShape, redoShape, + undoSource, + redoSource, ); } @@ -1128,10 +1147,6 @@ this._saveAttributes(data.attributes, frame); } - if (updated.source) { - this._saveSource(data.source, frame); - } - if (updated.keyframe) { this._saveKeyframe(frame, data.keyframe); } @@ -1264,10 +1279,6 @@ this._saveColor(data.color, frame); } - if (updated.source) { - this._saveSource(data.source, frame); - } - this.updateTimestamp(updated); updated.reset(); diff --git a/cvat-core/src/api.js b/cvat-core/src/api.js index df6622f5761..41a7007ad62 100644 --- a/cvat-core/src/api.js +++ b/cvat-core/src/api.js @@ -31,7 +31,7 @@ function build() { LogType, HistoryActions, colors, - source, + Source, } = require('./enums'); const { @@ -532,7 +532,7 @@ function build() { LogType, HistoryActions, colors, - source, + Source, }, /** * Namespace is used for access to exceptions diff --git a/cvat-core/src/enums.js b/cvat-core/src/enums.js index 894760cfee3..a1a5918fd59 100644 --- a/cvat-core/src/enums.js +++ b/cvat-core/src/enums.js @@ -107,16 +107,16 @@ /** * Annotation type * @enum {string} - * @name source + * @name Source * @memberof module:API.cvat.enums * @property {string} MANUAL 'manual' * @property {string} AUTO 'auto' * @readonly */ - const source = Object.freeze({ - MANUAL:'manual', - AUTO:'auto', -}); + const Source = Object.freeze({ + MANUAL:'manual', + AUTO:'auto', + }); /** * Logger event types @@ -257,6 +257,6 @@ LogType, HistoryActions, colors, - source, + Source, }; })(); diff --git a/cvat-core/src/object-state.js b/cvat-core/src/object-state.js index 1b3e4c483a0..64cad384acd 100644 --- a/cvat-core/src/object-state.js +++ b/cvat-core/src/object-state.js @@ -3,6 +3,8 @@ * SPDX-License-Identifier: MIT */ +const { Source } = require('./enums'); + /* global require:false */ @@ -39,7 +41,7 @@ color: null, hidden: null, pinned: null, - source: null, + source: Source.MANUAL, keyframes: serialized.keyframes, group: serialized.group, updated: serialized.updated, @@ -69,7 +71,6 @@ this.lock = false; this.color = false; this.hidden = false; - this.source = false; return reset; }, @@ -114,16 +115,12 @@ source: { /** * @name source - * @type {module:API.cvat.enums.source} + * @type {module:API.cvat.enums.Source} * @memberof module:API.cvat.classes.ObjectState * @readonly * @instance */ get: () => data.source, - set: (source) => { - data.updateFlags.source = true; - data.source = source; - }, }, clientID: { /** @@ -359,8 +356,10 @@ this.label = serialized.label; this.lock = serialized.lock; - this.source = serialized.source; + if ([Source.MANUAL, Source.AUTO].includes(serialized.source)) { + data.source = serialized.source; + } if (typeof (serialized.zOrder) === 'number') { this.zOrder = serialized.zOrder; } diff --git a/cvat-ui/package-lock.json b/cvat-ui/package-lock.json index f90e4e9fe5a..26e0217c3ae 100644 --- a/cvat-ui/package-lock.json +++ b/cvat-ui/package-lock.json @@ -1,6 +1,6 @@ { "name": "cvat-ui", - "version": "1.6.3", + "version": "1.6.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/cvat-ui/package.json b/cvat-ui/package.json index 6c4281dd973..add2deab7ed 100644 --- a/cvat-ui/package.json +++ b/cvat-ui/package.json @@ -1,6 +1,6 @@ { "name": "cvat-ui", - "version": "1.6.3", + "version": "1.6.4", "description": "CVAT single-page application", "main": "src/index.tsx", "scripts": { diff --git a/cvat-ui/src/components/annotation-page/standard-workspace/canvas-wrapper.tsx b/cvat-ui/src/components/annotation-page/standard-workspace/canvas-wrapper.tsx index 4824a442811..b10cd3d6bfe 100644 --- a/cvat-ui/src/components/annotation-page/standard-workspace/canvas-wrapper.tsx +++ b/cvat-ui/src/components/annotation-page/standard-workspace/canvas-wrapper.tsx @@ -324,7 +324,6 @@ export default class CanvasWrapperComponent extends React.PureComponent { .filter((label: any) => label.id === activeLabelID)[0]; state.occluded = state.occluded || false; state.frame = frame; - state.source = 'manual'; const objectState = new cvat.classes.ObjectState(state); onCreateAnnotations(jobInstance, frame, [objectState]); }; @@ -501,7 +500,6 @@ export default class CanvasWrapperComponent extends React.PureComponent { points, } = event.detail; state.points = points; - state.source = 'manual'; onUpdateAnnotations([state]); };