"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SGraphPointListInsert = void 0; const lib_1 = require("@persagy-web/draw/lib"); const index_1 = require("../index"); class SGraphPointListInsert extends index_1.SGraphCommand { constructor(scene, item, pointList, pos, index = null) { super(scene); this.item = item; this.pos = pos; this.index = index; this.pointList = pointList; this.command = "SGraphPointListInsert"; this.desc = `添加折点=${item.id}`; } redo() { const point = new lib_1.SPoint(this.pos.x, this.pos.y); if (this.index == null) { this.pointList.push(point); } else { this.pointList.splice(this.index, 0, point); } this.item.update(); } undo() { if (this.index == null) { this.pointList.pop(); } else { this.pointList.splice(this.index, 1); } this.item.update(); } toString() { const pointList = `pointList=${JSON.stringify(this.pointList)}`; const pos = `pos=${JSON.stringify(this.pos)}`; const index = `index=${this.index}`; return `${index};\n${pos};\n${pointList}`; } } exports.SGraphPointListInsert = SGraphPointListInsert;