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",
"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": {

@ -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();

@ -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

@ -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,
};
})();

@ -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;
}

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

@ -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": {

@ -324,7 +324,6 @@ export default class CanvasWrapperComponent extends React.PureComponent<Props> {
.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<Props> {
points,
} = event.detail;
state.points = points;
state.source = 'manual';
onUpdateAnnotations([state]);
};

Loading…
Cancel
Save