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