Fixed default undefined, fixed double change (#1935)

* Fixed default undefined, fixed double change

* Fixed for shapes
main
Boris Sekachev 6 years ago committed by GitHub
parent 3e12bbb43e
commit 1d17647658
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,6 +1,6 @@
{ {
"name": "cvat-core", "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", "description": "Part of Computer Vision Tool which presents an interface for client-side integration",
"main": "babel.config.js", "main": "babel.config.js",
"scripts": { "scripts": {

@ -15,6 +15,7 @@
} = require('./common'); } = require('./common');
const { const {
colors, colors,
Source,
ObjectShape, ObjectShape,
ObjectType, ObjectType,
AttributeType, AttributeType,
@ -296,21 +297,6 @@
}, [this.clientID], frame); }, [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) { _validateStateBeforeSave(frame, data, updated) {
let fittedPoints = []; let fittedPoints = [];
@ -397,10 +383,6 @@
} }
} }
if (updated.source) {
checkObjectType('source', data.source, 'string', null);
}
return fittedPoints; return fittedPoints;
} }
@ -416,8 +398,7 @@
updateTimestamp(updated) { updateTimestamp(updated) {
const anyChanges = updated.label || updated.attributes || updated.points const anyChanges = updated.label || updated.attributes || updated.points
|| updated.outside || updated.occluded || updated.keyframe || updated.outside || updated.occluded || updated.keyframe
|| updated.zOrder || updated.hidden || updated.lock || updated.pinned || updated.zOrder || updated.hidden || updated.lock || updated.pinned;
|| updated.source;
if (anyChanges) { if (anyChanges) {
this.updated = Date.now(); this.updated = Date.now();
@ -549,45 +530,60 @@
_savePoints(points, frame) { _savePoints(points, frame) {
const undoPoints = this.points; const undoPoints = this.points;
const redoPoints = points; const redoPoints = points;
const undoSource = this.source;
const redoSource = Source.MANUAL;
this.history.do(HistoryActions.CHANGED_POINTS, () => { this.history.do(HistoryActions.CHANGED_POINTS, () => {
this.points = undoPoints; this.points = undoPoints;
this.source = undoSource;
this.updated = Date.now(); this.updated = Date.now();
}, () => { }, () => {
this.points = redoPoints; this.points = redoPoints;
this.source = redoSource;
this.updated = Date.now(); this.updated = Date.now();
}, [this.clientID], frame); }, [this.clientID], frame);
this.source = Source.MANUAL;
this.points = points; this.points = points;
} }
_saveOccluded(occluded, frame) { _saveOccluded(occluded, frame) {
const undoOccluded = this.occluded; const undoOccluded = this.occluded;
const redoOccluded = occluded; const redoOccluded = occluded;
const undoSource = this.source;
const redoSource = Source.MANUAL;
this.history.do(HistoryActions.CHANGED_OCCLUDED, () => { this.history.do(HistoryActions.CHANGED_OCCLUDED, () => {
this.occluded = undoOccluded; this.occluded = undoOccluded;
this.source = undoSource;
this.updated = Date.now(); this.updated = Date.now();
}, () => { }, () => {
this.occluded = redoOccluded; this.occluded = redoOccluded;
this.source = redoSource;
this.updated = Date.now(); this.updated = Date.now();
}, [this.clientID], frame); }, [this.clientID], frame);
this.source = Source.MANUAL;
this.occluded = occluded; this.occluded = occluded;
} }
_saveZOrder(zOrder, frame) { _saveZOrder(zOrder, frame) {
const undoZOrder = this.zOrder; const undoZOrder = this.zOrder;
const redoZOrder = zOrder; const redoZOrder = zOrder;
const undoSource = this.source;
const redoSource = Source.MANUAL;
this.history.do(HistoryActions.CHANGED_ZORDER, () => { this.history.do(HistoryActions.CHANGED_ZORDER, () => {
this.zOrder = undoZOrder; this.zOrder = undoZOrder;
this.source = undoSource;
this.updated = Date.now(); this.updated = Date.now();
}, () => { }, () => {
this.zOrder = redoZOrder; this.zOrder = redoZOrder;
this.source = redoSource;
this.updated = Date.now(); this.updated = Date.now();
}, [this.clientID], frame); }, [this.clientID], frame);
this.source = Source.MANUAL;
this.zOrder = zOrder; this.zOrder = zOrder;
} }
@ -642,10 +638,6 @@
this._saveHidden(data.hidden, frame); this._saveHidden(data.hidden, frame);
} }
if (updated.source) {
this._saveSource(data.source, frame);
}
this.updateTimestamp(updated); this.updateTimestamp(updated);
updated.reset(); updated.reset();
@ -940,13 +932,14 @@
}, [this.clientID], frame); }, [this.clientID], frame);
} }
_appendShapeActionToHistory(actionType, frame, undoShape, redoShape) { _appendShapeActionToHistory(actionType, frame, undoShape, redoShape, undoSource, redoSource) {
this.history.do(actionType, () => { this.history.do(actionType, () => {
if (!undoShape) { if (!undoShape) {
delete this.shapes[frame]; delete this.shapes[frame];
} else { } else {
this.shapes[frame] = undoShape; this.shapes[frame] = undoShape;
} }
this.source = undoSource;
this.updated = Date.now(); this.updated = Date.now();
}, () => { }, () => {
if (!redoShape) { if (!redoShape) {
@ -954,6 +947,7 @@
} else { } else {
this.shapes[frame] = redoShape; this.shapes[frame] = redoShape;
} }
this.source = redoSource;
this.updated = Date.now(); this.updated = Date.now();
}, [this.clientID], frame); }, [this.clientID], frame);
} }
@ -961,6 +955,8 @@
_savePoints(points, frame) { _savePoints(points, frame) {
const current = this.get(frame); const current = this.get(frame);
const wasKeyframe = frame in this.shapes; const wasKeyframe = frame in this.shapes;
const undoSource = this.source;
const redoSource = Source.MANUAL;
const undoShape = wasKeyframe ? this.shapes[frame] : undefined; const undoShape = wasKeyframe ? this.shapes[frame] : undefined;
const redoShape = wasKeyframe ? { ...this.shapes[frame], points } : { const redoShape = wasKeyframe ? { ...this.shapes[frame], points } : {
frame, frame,
@ -972,17 +968,22 @@
}; };
this.shapes[frame] = redoShape; this.shapes[frame] = redoShape;
this.source = Source.MANUAL;
this._appendShapeActionToHistory( this._appendShapeActionToHistory(
HistoryActions.CHANGED_POINTS, HistoryActions.CHANGED_POINTS,
frame, frame,
undoShape, undoShape,
redoShape, redoShape,
undoSource,
redoSource,
); );
} }
_saveOutside(frame, outside) { _saveOutside(frame, outside) {
const current = this.get(frame); const current = this.get(frame);
const wasKeyframe = frame in this.shapes; const wasKeyframe = frame in this.shapes;
const undoSource = this.source;
const redoSource = Source.MANUAL;
const undoShape = wasKeyframe ? this.shapes[frame] : undefined; const undoShape = wasKeyframe ? this.shapes[frame] : undefined;
const redoShape = wasKeyframe ? { ...this.shapes[frame], outside } : { const redoShape = wasKeyframe ? { ...this.shapes[frame], outside } : {
frame, frame,
@ -994,17 +995,22 @@
}; };
this.shapes[frame] = redoShape; this.shapes[frame] = redoShape;
this.source = Source.MANUAL;
this._appendShapeActionToHistory( this._appendShapeActionToHistory(
HistoryActions.CHANGED_OUTSIDE, HistoryActions.CHANGED_OUTSIDE,
frame, frame,
undoShape, undoShape,
redoShape, redoShape,
undoSource,
redoSource,
); );
} }
_saveOccluded(occluded, frame) { _saveOccluded(occluded, frame) {
const current = this.get(frame); const current = this.get(frame);
const wasKeyframe = frame in this.shapes; const wasKeyframe = frame in this.shapes;
const undoSource = this.source;
const redoSource = Source.MANUAL;
const undoShape = wasKeyframe ? this.shapes[frame] : undefined; const undoShape = wasKeyframe ? this.shapes[frame] : undefined;
const redoShape = wasKeyframe ? { ...this.shapes[frame], occluded } : { const redoShape = wasKeyframe ? { ...this.shapes[frame], occluded } : {
frame, frame,
@ -1016,17 +1022,22 @@
}; };
this.shapes[frame] = redoShape; this.shapes[frame] = redoShape;
this.source = Source.MANUAL;
this._appendShapeActionToHistory( this._appendShapeActionToHistory(
HistoryActions.CHANGED_OCCLUDED, HistoryActions.CHANGED_OCCLUDED,
frame, frame,
undoShape, undoShape,
redoShape, redoShape,
undoSource,
redoSource,
); );
} }
_saveZOrder(zOrder, frame) { _saveZOrder(zOrder, frame) {
const current = this.get(frame); const current = this.get(frame);
const wasKeyframe = frame in this.shapes; const wasKeyframe = frame in this.shapes;
const undoSource = this.source;
const redoSource = Source.MANUAL;
const undoShape = wasKeyframe ? this.shapes[frame] : undefined; const undoShape = wasKeyframe ? this.shapes[frame] : undefined;
const redoShape = wasKeyframe ? { ...this.shapes[frame], zOrder } : { const redoShape = wasKeyframe ? { ...this.shapes[frame], zOrder } : {
frame, frame,
@ -1038,11 +1049,14 @@
}; };
this.shapes[frame] = redoShape; this.shapes[frame] = redoShape;
this.source = Source.MANUAL;
this._appendShapeActionToHistory( this._appendShapeActionToHistory(
HistoryActions.CHANGED_ZORDER, HistoryActions.CHANGED_ZORDER,
frame, frame,
undoShape, undoShape,
redoShape, redoShape,
undoSource,
redoSource,
); );
} }
@ -1055,6 +1069,8 @@
return; return;
} }
const undoSource = this.source;
const redoSource = Source.MANUAL;
const undoShape = wasKeyframe ? this.shapes[frame] : undefined; const undoShape = wasKeyframe ? this.shapes[frame] : undefined;
const redoShape = keyframe ? { const redoShape = keyframe ? {
frame, frame,
@ -1066,6 +1082,7 @@
source: current.source, source: current.source,
} : undefined; } : undefined;
this.source = Source.MANUAL;
if (redoShape) { if (redoShape) {
this.shapes[frame] = redoShape; this.shapes[frame] = redoShape;
} else { } else {
@ -1077,6 +1094,8 @@
frame, frame,
undoShape, undoShape,
redoShape, redoShape,
undoSource,
redoSource,
); );
} }
@ -1128,10 +1147,6 @@
this._saveAttributes(data.attributes, frame); this._saveAttributes(data.attributes, frame);
} }
if (updated.source) {
this._saveSource(data.source, frame);
}
if (updated.keyframe) { if (updated.keyframe) {
this._saveKeyframe(frame, data.keyframe); this._saveKeyframe(frame, data.keyframe);
} }
@ -1264,10 +1279,6 @@
this._saveColor(data.color, frame); this._saveColor(data.color, frame);
} }
if (updated.source) {
this._saveSource(data.source, frame);
}
this.updateTimestamp(updated); this.updateTimestamp(updated);
updated.reset(); updated.reset();

@ -31,7 +31,7 @@ function build() {
LogType, LogType,
HistoryActions, HistoryActions,
colors, colors,
source, Source,
} = require('./enums'); } = require('./enums');
const { const {
@ -532,7 +532,7 @@ function build() {
LogType, LogType,
HistoryActions, HistoryActions,
colors, colors,
source, Source,
}, },
/** /**
* Namespace is used for access to exceptions * Namespace is used for access to exceptions

@ -107,16 +107,16 @@
/** /**
* Annotation type * Annotation type
* @enum {string} * @enum {string}
* @name source * @name Source
* @memberof module:API.cvat.enums * @memberof module:API.cvat.enums
* @property {string} MANUAL 'manual' * @property {string} MANUAL 'manual'
* @property {string} AUTO 'auto' * @property {string} AUTO 'auto'
* @readonly * @readonly
*/ */
const source = Object.freeze({ const Source = Object.freeze({
MANUAL:'manual', MANUAL:'manual',
AUTO:'auto', AUTO:'auto',
}); });
/** /**
* Logger event types * Logger event types
@ -257,6 +257,6 @@
LogType, LogType,
HistoryActions, HistoryActions,
colors, colors,
source, Source,
}; };
})(); })();

@ -3,6 +3,8 @@
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */
const { Source } = require('./enums');
/* global /* global
require:false require:false
*/ */
@ -39,7 +41,7 @@
color: null, color: null,
hidden: null, hidden: null,
pinned: null, pinned: null,
source: null, source: Source.MANUAL,
keyframes: serialized.keyframes, keyframes: serialized.keyframes,
group: serialized.group, group: serialized.group,
updated: serialized.updated, updated: serialized.updated,
@ -69,7 +71,6 @@
this.lock = false; this.lock = false;
this.color = false; this.color = false;
this.hidden = false; this.hidden = false;
this.source = false;
return reset; return reset;
}, },
@ -114,16 +115,12 @@
source: { source: {
/** /**
* @name source * @name source
* @type {module:API.cvat.enums.source} * @type {module:API.cvat.enums.Source}
* @memberof module:API.cvat.classes.ObjectState * @memberof module:API.cvat.classes.ObjectState
* @readonly * @readonly
* @instance * @instance
*/ */
get: () => data.source, get: () => data.source,
set: (source) => {
data.updateFlags.source = true;
data.source = source;
},
}, },
clientID: { clientID: {
/** /**
@ -359,8 +356,10 @@
this.label = serialized.label; this.label = serialized.label;
this.lock = serialized.lock; 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') { if (typeof (serialized.zOrder) === 'number') {
this.zOrder = serialized.zOrder; this.zOrder = serialized.zOrder;
} }

@ -1,6 +1,6 @@
{ {
"name": "cvat-ui", "name": "cvat-ui",
"version": "1.6.3", "version": "1.6.4",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

@ -1,6 +1,6 @@
{ {
"name": "cvat-ui", "name": "cvat-ui",
"version": "1.6.3", "version": "1.6.4",
"description": "CVAT single-page application", "description": "CVAT single-page application",
"main": "src/index.tsx", "main": "src/index.tsx",
"scripts": { "scripts": {

@ -324,7 +324,6 @@ export default class CanvasWrapperComponent extends React.PureComponent<Props> {
.filter((label: any) => label.id === activeLabelID)[0]; .filter((label: any) => label.id === activeLabelID)[0];
state.occluded = state.occluded || false; state.occluded = state.occluded || false;
state.frame = frame; state.frame = frame;
state.source = 'manual';
const objectState = new cvat.classes.ObjectState(state); const objectState = new cvat.classes.ObjectState(state);
onCreateAnnotations(jobInstance, frame, [objectState]); onCreateAnnotations(jobInstance, frame, [objectState]);
}; };
@ -501,7 +500,6 @@ export default class CanvasWrapperComponent extends React.PureComponent<Props> {
points, points,
} = event.detail; } = event.detail;
state.points = points; state.points = points;
state.source = 'manual';
onUpdateAnnotations([state]); onUpdateAnnotations([state]);
}; };

Loading…
Cancel
Save