UNPKG

@wcardinal/wcardinal-geditor

Version:

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

130 lines 4.99 kB
import { __extends } from "tslib"; import { EShapeGroup } from "@wcardinal/wcardinal-ui"; import { EShapeCapabilities } from "@wcardinal/wcardinal-ui"; import { EShapeCapability } from "@wcardinal/wcardinal-ui"; import { DCommandBase } from "@wcardinal/wcardinal-ui"; import { EToolSelectSelectionUpdatedPart } from "../tool/e-tool-select-selection-updated-part"; var ECommandShapeProperty = /** @class */ (function (_super) { __extends(ECommandShapeProperty, _super); function ECommandShapeProperty(selection, property, targets) { if (targets === void 0) { targets = selection.get(); } var _this = _super.call(this) || this; _this._selection = selection; _this._shapes = []; _this._capabilities = []; _this._data = []; _this._property = property; _this._targets = targets; _this._isMerged = false; return _this; } Object.defineProperty(ECommandShapeProperty.prototype, "selection", { get: function () { return this._selection; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandShapeProperty.prototype, "shapes", { get: function () { return this._shapes; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandShapeProperty.prototype, "capabilities", { get: function () { return this._capabilities; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandShapeProperty.prototype, "data", { get: function () { return this._data; }, enumerable: false, configurable: true }); ECommandShapeProperty.prototype.toCapability = function (shape) { return EShapeCapability.ALL; }; ECommandShapeProperty.prototype.isRecursive = function () { return false; }; ECommandShapeProperty.prototype.isMergeable = function () { return false; }; ECommandShapeProperty.prototype.isClassMergeable = function (target) { return target.constructor === this.constructor; }; ECommandShapeProperty.prototype.execute = function () { var shapes = this._shapes; var capabilities = this._capabilities; var property = this._property; for (var i = 0, imax = shapes.length; i < imax; ++i) { this.initProperty(shapes[i], capabilities[i], property); } this._selection.update(this.getParts()); return true; }; ECommandShapeProperty.prototype.init = function (targets, shapes, capabilities, data, recursive) { for (var i = 0, imax = targets.length; i < imax; ++i) { var target = targets[i]; if (recursive && target instanceof EShapeGroup) { if (EShapeCapabilities.contains(target, EShapeCapability.CHILDREN)) { this.init(target.children, shapes, capabilities, data, recursive); } } else { var capability = this.toCapability(target); if (capability !== EShapeCapability.NONE) { shapes.push(target); data.push(this.getProperty(target, capability)); capabilities.push(capability); } } } }; ECommandShapeProperty.prototype.merge = function (target) { if (this.isMergeable() && this.isClassMergeable(target)) { this._isMerged = true; this._shapes = target.shapes; this._capabilities = target.capabilities; this._data = target.data; return true; } this.init(this._targets, this._shapes, this._capabilities, this._data, this.isRecursive()); return false; }; ECommandShapeProperty.prototype.isMerged = function () { return this._isMerged; }; ECommandShapeProperty.prototype.redo = function () { var shapes = this._shapes; var data = this._data; var capabilities = this._capabilities; for (var i = 0, imax = shapes.length; i < imax; ++i) { var shape = shapes[i]; var datum = data[i]; var capability = capabilities[i]; data[i] = this.getProperty(shape, capability); this.setProperty(shape, capability, datum); } this._selection.update(this.getParts()); return true; }; ECommandShapeProperty.prototype.undo = function () { return this.redo(); }; ECommandShapeProperty.prototype.destroy = function () { this._shapes.length = 0; this._data.length = 0; }; ECommandShapeProperty.prototype.getParts = function () { return EToolSelectSelectionUpdatedPart.PROPERTY; }; return ECommandShapeProperty; }(DCommandBase)); export { ECommandShapeProperty }; //# sourceMappingURL=e-command-shape-property.js.map