|
@@ -20,6 +20,14 @@ export default class Change {
|
|
|
this.lastData.lines = JSON.parse(JSON.stringify(dataService.getLines()));
|
|
|
this.lastData.texts = JSON.parse(JSON.stringify(dataService.getTexts()));
|
|
|
this.lastData.points = JSON.parse(JSON.stringify(dataService.getPoints()));
|
|
|
+
|
|
|
+ this.lastData.curveLines = JSON.parse(
|
|
|
+ JSON.stringify(dataService.getCurveLines())
|
|
|
+ );
|
|
|
+ this.lastData.curvePoints = JSON.parse(
|
|
|
+ JSON.stringify(dataService.getCurvePoints())
|
|
|
+ );
|
|
|
+
|
|
|
this.lastData.circles = JSON.parse(
|
|
|
JSON.stringify(dataService.getCircles())
|
|
|
);
|
|
@@ -54,6 +62,8 @@ export default class Change {
|
|
|
// this.compareRoads();
|
|
|
this.comparePoints();
|
|
|
this.compareLines();
|
|
|
+ this.compareCurvePoints();
|
|
|
+ this.compareCurveLines();
|
|
|
this.compareCircles();
|
|
|
this.compareTexts();
|
|
|
this.compareMagnifiers();
|
|
@@ -68,6 +78,8 @@ export default class Change {
|
|
|
if (
|
|
|
this.currentData.points.length == 0 &&
|
|
|
this.currentData.lines.length == 0 &&
|
|
|
+ this.currentData.curvePoints.length == 0 &&
|
|
|
+ this.currentData.curveLines.length == 0 &&
|
|
|
this.currentData.circles.length == 0 &&
|
|
|
this.currentData.texts.length == 0 &&
|
|
|
this.currentData.magnifiers.length == 0 &&
|
|
@@ -126,44 +138,127 @@ export default class Change {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // compareRoads() {
|
|
|
- // this.currentData.roads = [];
|
|
|
- // const roads = dataService.getRoads();
|
|
|
- // for (const key in roads) {
|
|
|
- // const road = roads[key];
|
|
|
- // const lastRoad = this.lastData.roads[key];
|
|
|
-
|
|
|
- // // 不存在意味着增加
|
|
|
- // if (!lastRoad) {
|
|
|
- // const item = {
|
|
|
- // handle: HistoryEvents.AddRoad,
|
|
|
- // road: historyUtil.getDataForRoad(road),
|
|
|
- // };
|
|
|
- // this.currentData.roads.push(item);
|
|
|
- // } else {
|
|
|
- // if (!historyUtil.isDifferentForRoads(road, lastRoad)) {
|
|
|
- // delete this.lastData.roads[key];
|
|
|
- // continue;
|
|
|
- // } else {
|
|
|
- // const item = {
|
|
|
- // handle: HistoryEvents.ModifyRoad,
|
|
|
- // preRoad: historyUtil.getDataForRoad(lastRoad),
|
|
|
- // curRoad: historyUtil.getDataForRoad(road),
|
|
|
- // };
|
|
|
- // this.currentData.roads.push(item);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // delete this.lastData.roads[key];
|
|
|
- // }
|
|
|
-
|
|
|
- // for (const key in this.lastData.roads) {
|
|
|
- // const item = {
|
|
|
- // handle: HistoryEvents.DeleteRoad,
|
|
|
- // road: historyUtil.getDataForRoad(this.lastData.roads[key]),
|
|
|
- // };
|
|
|
- // this.currentData.roads.push(item);
|
|
|
- // }
|
|
|
- // }
|
|
|
+ compareLines() {
|
|
|
+ const lines = dataService.getLines();
|
|
|
+ this.currentData.lines = [];
|
|
|
+
|
|
|
+ for (const key in lines) {
|
|
|
+ const line = lines[key];
|
|
|
+ // 不存在意味着增加
|
|
|
+ if (!this.lastData.lines[key]) {
|
|
|
+ const item = {
|
|
|
+ handle: HistoryEvents.AddLine,
|
|
|
+ line: historyUtil.getDataForLine(line),
|
|
|
+ };
|
|
|
+ this.currentData.lines.push(item);
|
|
|
+ } else {
|
|
|
+ const lastLine = this.lastData.lines[key];
|
|
|
+ if (!historyUtil.isDifferentForLines(line, lastLine)) {
|
|
|
+ delete this.lastData.lines[key];
|
|
|
+ continue;
|
|
|
+ } else {
|
|
|
+ const item = {
|
|
|
+ handle: HistoryEvents.ModifyLine,
|
|
|
+ preLine: historyUtil.getDataForLine(lastLine),
|
|
|
+ curLine: historyUtil.getDataForLine(line),
|
|
|
+ };
|
|
|
+ this.currentData.lines.push(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ delete this.lastData.lines[key];
|
|
|
+ }
|
|
|
+
|
|
|
+ for (const key in this.lastData.lines) {
|
|
|
+ const item = {
|
|
|
+ handle: HistoryEvents.DeleteLine,
|
|
|
+ line: historyUtil.getDataForLine(this.lastData.lines[key]),
|
|
|
+ };
|
|
|
+ this.currentData.lines.push(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ compareCurvePoints() {
|
|
|
+ const curvePoints = dataService.getCurvePoints();
|
|
|
+ this.currentData.curvePoints = [];
|
|
|
+
|
|
|
+ for (const key in curvePoints) {
|
|
|
+ const curvePoint = curvePoints[key];
|
|
|
+ // 不存在意味着增加
|
|
|
+ if (!this.lastData.curvePoints[key]) {
|
|
|
+ const item = {
|
|
|
+ handle: HistoryEvents.AddCurvePoint,
|
|
|
+ curvePoint: historyUtil.getDataForCurvePoint(curvePoint),
|
|
|
+ };
|
|
|
+ this.currentData.curvePoints.push(item);
|
|
|
+ } else {
|
|
|
+ const lastCurvePoint = this.lastData.curvePoints[key];
|
|
|
+ if (
|
|
|
+ !historyUtil.isDifferentForCurvePoints(curvePoint, lastCurvePoint)
|
|
|
+ ) {
|
|
|
+ delete this.lastData.curvePoints[key];
|
|
|
+ continue;
|
|
|
+ } else {
|
|
|
+ const item = {
|
|
|
+ handle: HistoryEvents.ModifyCurvePoint,
|
|
|
+ preCurvePoint: historyUtil.getDataForCurvePoint(lastCurvePoint),
|
|
|
+ curCurvePoint: historyUtil.getDataForCurvePoint(curvePoint),
|
|
|
+ };
|
|
|
+ this.currentData.curvePoints.push(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ delete this.lastData.curvePoints[key];
|
|
|
+ }
|
|
|
+
|
|
|
+ for (const key in this.lastData.curvePoints) {
|
|
|
+ const item = {
|
|
|
+ handle: HistoryEvents.DeleteCurvePoint,
|
|
|
+ curvePoint: historyUtil.getDataForCurvePoint(
|
|
|
+ this.lastData.curvePoints[key]
|
|
|
+ ),
|
|
|
+ };
|
|
|
+ this.currentData.curvePoints.push(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ compareCurveLines() {
|
|
|
+ const curveLines = dataService.getCurveLines();
|
|
|
+ this.currentData.curveLines = [];
|
|
|
+
|
|
|
+ for (const key in curveLines) {
|
|
|
+ const curveLine = curveLines[key];
|
|
|
+ // 不存在意味着增加
|
|
|
+ if (!this.lastData.curveLines[key]) {
|
|
|
+ const item = {
|
|
|
+ handle: HistoryEvents.AddCurveLine,
|
|
|
+ curveLine: historyUtil.getDataForCurveLine(curveLine),
|
|
|
+ };
|
|
|
+ this.currentData.curveLines.push(item);
|
|
|
+ } else {
|
|
|
+ const lastCurveLine = this.lastData.curveLines[key];
|
|
|
+ if (!historyUtil.isDifferentForCurveLines(curveLine, lastCurveLine)) {
|
|
|
+ delete this.lastData.curveLines[key];
|
|
|
+ continue;
|
|
|
+ } else {
|
|
|
+ const item = {
|
|
|
+ handle: HistoryEvents.ModifyCurveLine,
|
|
|
+ preCurveLine: historyUtil.getDataForCurveLine(lastCurveLine),
|
|
|
+ curCurveLine: historyUtil.getDataForCurveLine(curveLine),
|
|
|
+ };
|
|
|
+ this.currentData.curveLines.push(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ delete this.lastData.curveLines[key];
|
|
|
+ }
|
|
|
+
|
|
|
+ for (const key in this.lastData.curveLines) {
|
|
|
+ const item = {
|
|
|
+ handle: HistoryEvents.DeleteCurveLine,
|
|
|
+ curveLine: historyUtil.getDataForCurveLine(
|
|
|
+ this.lastData.curveLines[key]
|
|
|
+ ),
|
|
|
+ };
|
|
|
+ this.currentData.curveLines.push(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
compareTexts() {
|
|
|
this.currentData.texts = [];
|
|
@@ -205,45 +300,6 @@ export default class Change {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- compareLines() {
|
|
|
- const lines = dataService.getLines();
|
|
|
- this.currentData.lines = [];
|
|
|
-
|
|
|
- for (const key in lines) {
|
|
|
- const line = lines[key];
|
|
|
- // 不存在意味着增加
|
|
|
- if (!this.lastData.lines[key]) {
|
|
|
- const item = {
|
|
|
- handle: HistoryEvents.AddLine,
|
|
|
- line: historyUtil.getDataForLine(line),
|
|
|
- };
|
|
|
- this.currentData.lines.push(item);
|
|
|
- } else {
|
|
|
- const lastLine = this.lastData.lines[key];
|
|
|
- if (!historyUtil.isDifferentForLines(line, lastLine)) {
|
|
|
- delete this.lastData.lines[key];
|
|
|
- continue;
|
|
|
- } else {
|
|
|
- const item = {
|
|
|
- handle: HistoryEvents.ModifyLine,
|
|
|
- preLine: historyUtil.getDataForLine(lastLine),
|
|
|
- curLine: historyUtil.getDataForLine(line),
|
|
|
- };
|
|
|
- this.currentData.lines.push(item);
|
|
|
- }
|
|
|
- }
|
|
|
- delete this.lastData.lines[key];
|
|
|
- }
|
|
|
-
|
|
|
- for (const key in this.lastData.lines) {
|
|
|
- const item = {
|
|
|
- handle: HistoryEvents.DeleteLine,
|
|
|
- line: historyUtil.getDataForLine(this.lastData.lines[key]),
|
|
|
- };
|
|
|
- this.currentData.lines.push(item);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
compareCircles() {
|
|
|
const circles = dataService.getCircles();
|
|
|
this.currentData.circles = [];
|