SGraphPointListDelete.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.SGraphPointListDelete = void 0;
  4. const index_1 = require("../index");
  5. class SGraphPointListDelete extends index_1.SGraphCommand {
  6. constructor(scene, item, pointList, pos, index = null) {
  7. super(scene);
  8. this.item = item;
  9. this.index = index;
  10. this.pointList = pointList;
  11. this.pos = pos;
  12. this.command = "SGraphPointListDelete";
  13. this.desc = `删除折点=${item.id}`;
  14. }
  15. redo() {
  16. if (this.index == null) {
  17. this.pointList.pop();
  18. }
  19. else {
  20. this.pointList.splice(this.index, 1);
  21. }
  22. this.item.update();
  23. }
  24. undo() {
  25. if (this.pos == null)
  26. return;
  27. if (this.index == null) {
  28. this.pointList.push(this.pos);
  29. }
  30. else {
  31. this.pointList.splice(this.index, 0, this.pos);
  32. }
  33. this.item.update();
  34. }
  35. toString() {
  36. const pointList = `pointList=${JSON.stringify(this.pointList)}`;
  37. const pos = `pos=${JSON.stringify(this.pos)}`;
  38. const index = `index=${this.index}`;
  39. return `${index};\n${pos};\n${pointList}`;
  40. }
  41. }
  42. exports.SGraphPointListDelete = SGraphPointListDelete;