UNPKG

@wcardinal/wcardinal-geditor

Version:

WebGL-based graphic editor, tester and viewer for supervisory systems

101 lines 3.33 kB
import { __extends } from "tslib"; import { DCommandBase } from "@wcardinal/wcardinal-ui"; import { UtilShapeDeleter } from "../util/util-shape-deleter"; var ECommandShapeDelete = /** @class */ (function (_super) { __extends(ECommandShapeDelete, _super); function ECommandShapeDelete(shapes, indices, parent, selection, select) { var _this = _super.call(this) || this; _this._shapes = shapes; for (var i = 0, imax = shapes.length; i < imax; ++i) { shapes[i].reference += 1; } _this._indices = indices; _this._parent = parent; _this._selection = selection; _this._select = select; return _this; } Object.defineProperty(ECommandShapeDelete.prototype, "parent", { get: function () { return this._parent; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandShapeDelete.prototype, "shapes", { get: function () { return this._shapes; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandShapeDelete.prototype, "indices", { get: function () { return this._indices; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandShapeDelete.prototype, "selection", { get: function () { return this._selection; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandShapeDelete.prototype, "select", { get: function () { return this._select; }, enumerable: false, configurable: true }); ECommandShapeDelete.prototype.execute = function () { return true; }; ECommandShapeDelete.prototype.redo = function () { var selection = this._selection; if (this._select) { selection.delete(false); } else { var shapes = this._shapes; for (var i = 0, imax = shapes.length; i < imax; ++i) { shapes[i].selected = true; } UtilShapeDeleter.delete(this._parent, undefined, false); selection.update("TREE"); } return true; }; ECommandShapeDelete.prototype.undo = function () { var shapes = this._shapes; var indices = this._indices; var parent = this._parent; for (var i = 0, imax = shapes.length; i < imax; ++i) { shapes[i].attach(parent, indices[i]); } var selection = this._selection; selection.lock(); if (this._select) { selection.clearAndAddAll(shapes); } selection.update("TREE"); selection.unlock(); return true; }; ECommandShapeDelete.prototype.destroy = function () { var shapes = this._shapes; for (var i = 0, imax = shapes.length; i < imax; ++i) { var shape = shapes[i]; shape.reference -= 1; if (shape.parent == null && shape.reference <= 0) { shape.destroy(); } } shapes.length = 0; }; return ECommandShapeDelete; }(DCommandBase)); export { ECommandShapeDelete }; //# sourceMappingURL=e-command-shape-delete.js.map