SGraphPointListUpdate.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.SGraphPointListUpdate = void 0;
  4. const index_1 = require("../index");
  5. class SGraphPointListUpdate extends index_1.SGraphCommand {
  6. constructor(scene, item, pointList, old, pos, index) {
  7. super(scene);
  8. this.item = item;
  9. this.old = old;
  10. this.pos = pos;
  11. this.index = index;
  12. this.pointList = pointList;
  13. this.command = "SGraphPointListUpdate";
  14. this.desc = `更新折点=${item.id}`;
  15. }
  16. redo() {
  17. this.pointList[this.index].x = this.pos.x;
  18. this.pointList[this.index].y = this.pos.y;
  19. this.item.update();
  20. }
  21. undo() {
  22. this.pointList[this.index].x = this.old.x;
  23. this.pointList[this.index].y = this.old.y;
  24. this.item.update();
  25. }
  26. toString() {
  27. const pointList = `pointList=${JSON.stringify(this.pointList)}`;
  28. const old = `old=${JSON.stringify(this.old)}`;
  29. const pos = `pos=${JSON.stringify(this.pos)}`;
  30. const index = `index=${this.index}`;
  31. return `${index};\n${old};\n${pos};\n${pointList}`;
  32. }
  33. }
  34. exports.SGraphPointListUpdate = SGraphPointListUpdate;