UNPKG

@wcardinal/wcardinal-geditor

Version:

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

1,379 lines (1,343 loc) 1.49 MB
/* WinterCardinal Graphic Editor v1.4.0 Copyright (C) TOSHIBA Coorporation SPDX-License-Identifier: Apache-2.0 Material Design icons by Google Apache license version 2.0. */ (function (wcardinalUi, pixi_js) { 'use strict'; /****************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ /* global Reflect, Promise, SuppressedError, Symbol */ var extendStatics = function(d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; function __extends(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); } typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { var e = new Error(message); return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; }; var ECommandComposition = /** @class */ (function (_super) { __extends(ECommandComposition, _super); function ECommandComposition(commands, selection) { var _this = _super.call(this) || this; _this._commands = commands; _this._selection = selection; return _this; } Object.defineProperty(ECommandComposition.prototype, "commands", { get: function () { return this._commands; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandComposition.prototype, "selection", { get: function () { return this._selection; }, enumerable: false, configurable: true }); ECommandComposition.prototype.execute = function () { return true; }; ECommandComposition.prototype.redo = function () { var selection = this._selection; var commands = this._commands; selection.lock(); for (var i = 0, imax = commands.length; i < imax; ++i) { commands[i].redo(); } selection.unlock(); return true; }; ECommandComposition.prototype.undo = function () { var selection = this._selection; selection.lock(); var commands = this._commands; for (var i = commands.length - 1; 0 <= i; --i) { commands[i].undo(); } selection.unlock(); return true; }; ECommandComposition.prototype.destroy = function () { var commands = this._commands; for (var i = 0, imax = commands.length; i < imax; ++i) { commands[i].destroy(); } }; return ECommandComposition; }(wcardinalUi.DCommandBase)); var ECommandDocumentAll = /** @class */ (function (_super) { __extends(ECommandDocumentAll, _super); function ECommandDocumentAll(diagram, canvas, name, label, width, height, category, summary, description, backgroundColor, backgroundAlpha) { var _this = _super.call(this) || this; _this._diagram = diagram; _this._canvas = canvas; _this._name = name; _this._label = label; _this._width = width; _this._height = height; _this._category = category; _this._summary = summary; _this._description = description; _this._backgroundColor = backgroundColor; _this._backgroundAlpha = backgroundAlpha; return _this; } Object.defineProperty(ECommandDocumentAll.prototype, "diagram", { get: function () { return this._diagram; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentAll.prototype, "canvas", { get: function () { return this._canvas; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentAll.prototype, "name", { get: function () { return this._name; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentAll.prototype, "label", { get: function () { return this._label; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentAll.prototype, "width", { get: function () { return this._width; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentAll.prototype, "height", { get: function () { return this._height; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentAll.prototype, "category", { get: function () { return this._category; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentAll.prototype, "summary", { get: function () { return this._summary; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentAll.prototype, "description", { get: function () { return this._description; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentAll.prototype, "backgroundColor", { get: function () { return this._backgroundColor; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentAll.prototype, "backgroundAlpha", { get: function () { return this._backgroundAlpha; }, enumerable: false, configurable: true }); ECommandDocumentAll.prototype.execute = function () { return this.redo(); }; ECommandDocumentAll.prototype.redo = function () { var canvas = this._canvas; var name = this._name; this._name = canvas.name; canvas.name = name; var label = this._label; this._label = canvas.label; canvas.label = label; var width = this._width; this._width = canvas.width; canvas.width = width; var height = this._height; this._height = canvas.height; canvas.height = height; var category = this._category; this._category = canvas.category; canvas.category = category; var summary = this._summary; this._summary = canvas.summary; canvas.summary = summary; var description = this._description; this._description = canvas.description; canvas.description = description; var backgroundColor = this._backgroundColor; var backgroundAlpha = this._backgroundAlpha; var state = new wcardinalUi.DBaseStateSetImpl(); var background = canvas.background; this._backgroundColor = background.getColor(state); this._backgroundAlpha = background.getAlpha(state); background.color = backgroundColor; background.alpha = backgroundAlpha; this._diagram.emit("change", this._diagram); return true; }; ECommandDocumentAll.prototype.undo = function () { return this.redo(); }; return ECommandDocumentAll; }(wcardinalUi.DCommandBase)); var ECommandDocumentBackground = /** @class */ (function (_super) { __extends(ECommandDocumentBackground, _super); function ECommandDocumentBackground(diagram, color, alpha) { var _this = _super.call(this) || this; _this._diagram = diagram; _this._color = color; _this._alpha = alpha; return _this; } Object.defineProperty(ECommandDocumentBackground.prototype, "diagram", { get: function () { return this._diagram; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentBackground.prototype, "color", { get: function () { return this._color; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentBackground.prototype, "alpha", { get: function () { return this._alpha; }, enumerable: false, configurable: true }); ECommandDocumentBackground.prototype.execute = function () { return this.redo(); }; ECommandDocumentBackground.prototype.redo = function () { var canvas = this._diagram.canvas; if (canvas != null) { var background = canvas.background; var color = this._color; var alpha = this._alpha; var state = new wcardinalUi.DBaseStateSetImpl(); this._color = background.getColor(state); this._alpha = background.getAlpha(state); background.color = color; background.alpha = alpha; this._diagram.emit("change", this._diagram); } return true; }; ECommandDocumentBackground.prototype.undo = function () { return this.redo(); }; return ECommandDocumentBackground; }(wcardinalUi.DCommandBase)); var ECommandDocumentCategory = /** @class */ (function (_super) { __extends(ECommandDocumentCategory, _super); function ECommandDocumentCategory(diagram, canvas, category) { var _this = _super.call(this) || this; _this._diagram = diagram; _this._canvas = canvas; _this._category = category; return _this; } Object.defineProperty(ECommandDocumentCategory.prototype, "diagram", { get: function () { return this._diagram; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentCategory.prototype, "canvas", { get: function () { return this._canvas; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentCategory.prototype, "category", { get: function () { return this._category; }, enumerable: false, configurable: true }); ECommandDocumentCategory.prototype.execute = function () { return this.redo(); }; ECommandDocumentCategory.prototype.redo = function () { var canvas = this._canvas; var category = this._category; this._category = canvas.category; canvas.category = category; this._diagram.emit("change", this._diagram); return true; }; ECommandDocumentCategory.prototype.undo = function () { return this.redo(); }; return ECommandDocumentCategory; }(wcardinalUi.DCommandBase)); var ECommandDocumentCreate = /** @class */ (function (_super) { __extends(ECommandDocumentCreate, _super); function ECommandDocumentCreate(diagram, canvas) { var _this = _super.call(this) || this; _this._diagram = diagram; _this._canvas = canvas; return _this; } Object.defineProperty(ECommandDocumentCreate.prototype, "diagram", { get: function () { return this._diagram; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentCreate.prototype, "canvas", { get: function () { return this._canvas; }, enumerable: false, configurable: true }); ECommandDocumentCreate.prototype.execute = function () { return true; }; return ECommandDocumentCreate; }(wcardinalUi.DCommandCreate)); var ECommandDocumentDescription = /** @class */ (function (_super) { __extends(ECommandDocumentDescription, _super); function ECommandDocumentDescription(diagram, canvas, description) { var _this = _super.call(this) || this; _this._diagram = diagram; _this._canvas = canvas; _this._description = description; return _this; } Object.defineProperty(ECommandDocumentDescription.prototype, "diagram", { get: function () { return this._diagram; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentDescription.prototype, "canvas", { get: function () { return this._canvas; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentDescription.prototype, "description", { get: function () { return this._description; }, enumerable: false, configurable: true }); ECommandDocumentDescription.prototype.execute = function () { return this.redo(); }; ECommandDocumentDescription.prototype.redo = function () { var canvas = this._canvas; var description = this._description; this._description = canvas.description; canvas.description = description; this._diagram.emit("change", this._diagram); return true; }; ECommandDocumentDescription.prototype.undo = function () { return this.redo(); }; return ECommandDocumentDescription; }(wcardinalUi.DCommandBase)); var ECommandDocumentHeight = /** @class */ (function (_super) { __extends(ECommandDocumentHeight, _super); function ECommandDocumentHeight(diagram, canvas, height) { var _this = _super.call(this) || this; _this._diagram = diagram; _this._canvas = canvas; _this._height = height; return _this; } Object.defineProperty(ECommandDocumentHeight.prototype, "diagram", { get: function () { return this._diagram; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentHeight.prototype, "canvas", { get: function () { return this._canvas; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentHeight.prototype, "height", { get: function () { return this._height; }, enumerable: false, configurable: true }); ECommandDocumentHeight.prototype.execute = function () { return this.redo(); }; ECommandDocumentHeight.prototype.redo = function () { var canvas = this._canvas; var height = this._height; this._height = canvas.height; canvas.y = canvas.y + (canvas.height - height) * 0.5; canvas.height = height; this._diagram.emit("change", this._diagram); return true; }; ECommandDocumentHeight.prototype.undo = function () { return this.redo(); }; return ECommandDocumentHeight; }(wcardinalUi.DCommandBase)); var ECommandDocumentLabel = /** @class */ (function (_super) { __extends(ECommandDocumentLabel, _super); function ECommandDocumentLabel(diagram, canvas, label) { var _this = _super.call(this) || this; _this._diagram = diagram; _this._canvas = canvas; _this._label = label; return _this; } Object.defineProperty(ECommandDocumentLabel.prototype, "diagram", { get: function () { return this._diagram; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentLabel.prototype, "canvas", { get: function () { return this._canvas; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentLabel.prototype, "label", { get: function () { return this._label; }, enumerable: false, configurable: true }); ECommandDocumentLabel.prototype.execute = function () { return this.redo(); }; ECommandDocumentLabel.prototype.redo = function () { var canvas = this._canvas; var label = this._label; this._label = canvas.label; canvas.label = label; this._diagram.emit("change", this._diagram); return true; }; ECommandDocumentLabel.prototype.undo = function () { return this.redo(); }; return ECommandDocumentLabel; }(wcardinalUi.DCommandBase)); var ECommandDocumentName = /** @class */ (function (_super) { __extends(ECommandDocumentName, _super); function ECommandDocumentName(diagram, canvas, name) { var _this = _super.call(this) || this; _this._diagram = diagram; _this._canvas = canvas; _this._name = name; return _this; } Object.defineProperty(ECommandDocumentName.prototype, "diagram", { get: function () { return this._diagram; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentName.prototype, "canvas", { get: function () { return this._canvas; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentName.prototype, "name", { get: function () { return this._name; }, enumerable: false, configurable: true }); ECommandDocumentName.prototype.execute = function () { return this.redo(); }; ECommandDocumentName.prototype.redo = function () { var canvas = this._canvas; var name = this._name; this._name = canvas.name; canvas.name = name; this._diagram.emit("change", this._diagram); return true; }; ECommandDocumentName.prototype.undo = function () { return this.redo(); }; return ECommandDocumentName; }(wcardinalUi.DCommandBase)); var ECommandDocumentOpen = /** @class */ (function (_super) { __extends(ECommandDocumentOpen, _super); function ECommandDocumentOpen(diagram, canvas) { var _this = _super.call(this) || this; _this._diagram = diagram; _this._canvas = canvas; return _this; } Object.defineProperty(ECommandDocumentOpen.prototype, "diagram", { get: function () { return this._diagram; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentOpen.prototype, "canvas", { get: function () { return this._canvas; }, enumerable: false, configurable: true }); ECommandDocumentOpen.prototype.execute = function () { return true; }; return ECommandDocumentOpen; }(wcardinalUi.DCommandCreate)); var ECommandDocumentSnapBringForward = /** @class */ (function (_super) { __extends(ECommandDocumentSnapBringForward, _super); function ECommandDocumentSnapBringForward(snapper, index) { var _this = _super.call(this) || this; _this._snapper = snapper; _this._index = index; return _this; } Object.defineProperty(ECommandDocumentSnapBringForward.prototype, "snapper", { get: function () { return this._snapper; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentSnapBringForward.prototype, "index", { get: function () { return this._index; }, enumerable: false, configurable: true }); ECommandDocumentSnapBringForward.prototype.execute = function () { return this.redo(); }; ECommandDocumentSnapBringForward.prototype.redo = function () { var index = this._index; this._snapper.target.swap(index - 1, index); return true; }; ECommandDocumentSnapBringForward.prototype.undo = function () { return this.redo(); }; return ECommandDocumentSnapBringForward; }(wcardinalUi.DCommandBase)); var ECommandDocumentSnapCreate = /** @class */ (function (_super) { __extends(ECommandDocumentSnapCreate, _super); function ECommandDocumentSnapCreate(snapper, target) { var _this = _super.call(this) || this; _this._snapper = snapper; _this._target = target; return _this; } Object.defineProperty(ECommandDocumentSnapCreate.prototype, "snapper", { get: function () { return this._snapper; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentSnapCreate.prototype, "target", { get: function () { return this._target; }, enumerable: false, configurable: true }); ECommandDocumentSnapCreate.prototype.execute = function () { return this.redo(); }; ECommandDocumentSnapCreate.prototype.redo = function () { this._snapper.target.add(this._target); return true; }; ECommandDocumentSnapCreate.prototype.undo = function () { var target = this._snapper.target; target.remove(target.size - 1); return true; }; return ECommandDocumentSnapCreate; }(wcardinalUi.DCommandBase)); var ECommandDocumentSnapDelete = /** @class */ (function (_super) { __extends(ECommandDocumentSnapDelete, _super); function ECommandDocumentSnapDelete(snapper, index, target) { var _this = _super.call(this) || this; _this._snapper = snapper; _this._index = index; _this._target = target; return _this; } Object.defineProperty(ECommandDocumentSnapDelete.prototype, "snapper", { get: function () { return this._snapper; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentSnapDelete.prototype, "index", { get: function () { return this._index; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentSnapDelete.prototype, "target", { get: function () { return this._target; }, enumerable: false, configurable: true }); ECommandDocumentSnapDelete.prototype.execute = function () { return this.redo(); }; ECommandDocumentSnapDelete.prototype.redo = function () { this._snapper.target.remove(this._index); return true; }; ECommandDocumentSnapDelete.prototype.undo = function () { this._snapper.target.add(this._target, this._index); return true; }; return ECommandDocumentSnapDelete; }(wcardinalUi.DCommandBase)); var ECommandDocumentSnapGridSize = /** @class */ (function (_super) { __extends(ECommandDocumentSnapGridSize, _super); function ECommandDocumentSnapGridSize(snapper, size) { var _this = _super.call(this) || this; _this._snapper = snapper; _this._size = size; return _this; } Object.defineProperty(ECommandDocumentSnapGridSize.prototype, "snapper", { get: function () { return this._snapper; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentSnapGridSize.prototype, "size", { get: function () { return this._size; }, enumerable: false, configurable: true }); ECommandDocumentSnapGridSize.prototype.execute = function () { return this.redo(); }; ECommandDocumentSnapGridSize.prototype.redo = function () { var snapper = this._snapper; var size = this._size; this._size = snapper.grid.size; snapper.grid.size = size; return true; }; ECommandDocumentSnapGridSize.prototype.undo = function () { return this.redo(); }; return ECommandDocumentSnapGridSize; }(wcardinalUi.DCommandBase)); var ECommandDocumentSnapGridToggleVisibility = /** @class */ (function (_super) { __extends(ECommandDocumentSnapGridToggleVisibility, _super); function ECommandDocumentSnapGridToggleVisibility(snapper) { var _this = _super.call(this) || this; _this._snapper = snapper; return _this; } Object.defineProperty(ECommandDocumentSnapGridToggleVisibility.prototype, "snapper", { get: function () { return this._snapper; }, enumerable: false, configurable: true }); ECommandDocumentSnapGridToggleVisibility.prototype.execute = function () { return this.redo(); }; ECommandDocumentSnapGridToggleVisibility.prototype.redo = function () { var grid = this._snapper.grid; grid.visible = !grid.visible; return true; }; ECommandDocumentSnapGridToggleVisibility.prototype.undo = function () { return this.redo(); }; return ECommandDocumentSnapGridToggleVisibility; }(wcardinalUi.DCommandBase)); var ECommandDocumentSnapGridToggle = /** @class */ (function (_super) { __extends(ECommandDocumentSnapGridToggle, _super); function ECommandDocumentSnapGridToggle(snapper) { var _this = _super.call(this) || this; _this._snapper = snapper; return _this; } Object.defineProperty(ECommandDocumentSnapGridToggle.prototype, "snapper", { get: function () { return this._snapper; }, enumerable: false, configurable: true }); ECommandDocumentSnapGridToggle.prototype.execute = function () { return this.redo(); }; ECommandDocumentSnapGridToggle.prototype.redo = function () { var grid = this._snapper.grid; grid.enable = !grid.enable; return true; }; ECommandDocumentSnapGridToggle.prototype.undo = function () { return this.redo(); }; return ECommandDocumentSnapGridToggle; }(wcardinalUi.DCommandBase)); var ECommandDocumentSnapReplace = /** @class */ (function (_super) { __extends(ECommandDocumentSnapReplace, _super); function ECommandDocumentSnapReplace(snapper, oldValue, newValue, list) { var _this = _super.call(this) || this; _this._snapper = snapper; _this._oldValue = oldValue; _this._newValue = newValue; _this._index = snapper.target.values.indexOf(_this._oldValue); _this._list = list; return _this; } Object.defineProperty(ECommandDocumentSnapReplace.prototype, "snapper", { get: function () { return this._snapper; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentSnapReplace.prototype, "index", { get: function () { return this._index; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentSnapReplace.prototype, "oldValue", { get: function () { return this._oldValue; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentSnapReplace.prototype, "newValue", { get: function () { return this._newValue; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentSnapReplace.prototype, "list", { get: function () { return this._list; }, enumerable: false, configurable: true }); ECommandDocumentSnapReplace.prototype.execute = function () { return this.redo(); }; ECommandDocumentSnapReplace.prototype.redo = function () { var index = this._index; if (0 <= index) { var list = this._list; var newValue = this._newValue; var snapper = this._snapper; if (list.data.selection.contains(this._oldValue)) { snapper.target.replace(index, newValue); list.data.selection.clearAndAdd(newValue); } else { snapper.target.replace(index, newValue); } } return true; }; ECommandDocumentSnapReplace.prototype.undo = function () { var index = this._index; if (0 <= index) { var list = this._list; var oldValue = this._oldValue; var snapper = this._snapper; if (list.data.selection.contains(this._newValue)) { snapper.target.replace(index, oldValue); list.data.selection.clearAndAdd(oldValue); } else { snapper.target.replace(index, oldValue); } } return true; }; return ECommandDocumentSnapReplace; }(wcardinalUi.DCommandBase)); var ECommandDocumentSnapSendBackward = /** @class */ (function (_super) { __extends(ECommandDocumentSnapSendBackward, _super); function ECommandDocumentSnapSendBackward(snapper, index) { var _this = _super.call(this) || this; _this._snapper = snapper; _this._index = index; return _this; } Object.defineProperty(ECommandDocumentSnapSendBackward.prototype, "snapper", { get: function () { return this._snapper; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentSnapSendBackward.prototype, "index", { get: function () { return this._index; }, enumerable: false, configurable: true }); ECommandDocumentSnapSendBackward.prototype.execute = function () { return this.redo(); }; ECommandDocumentSnapSendBackward.prototype.redo = function () { var index = this._index; this._snapper.target.swap(index, index + 1); return true; }; ECommandDocumentSnapSendBackward.prototype.undo = function () { return this.redo(); }; return ECommandDocumentSnapSendBackward; }(wcardinalUi.DCommandBase)); var ECommandDocumentSnapTargetToggleVisibility = /** @class */ (function (_super) { __extends(ECommandDocumentSnapTargetToggleVisibility, _super); function ECommandDocumentSnapTargetToggleVisibility(snapper) { var _this = _super.call(this) || this; _this._snapper = snapper; return _this; } Object.defineProperty(ECommandDocumentSnapTargetToggleVisibility.prototype, "snapper", { get: function () { return this._snapper; }, enumerable: false, configurable: true }); ECommandDocumentSnapTargetToggleVisibility.prototype.execute = function () { return this.redo(); }; ECommandDocumentSnapTargetToggleVisibility.prototype.redo = function () { var target = this._snapper.target; target.visible = !target.visible; return true; }; ECommandDocumentSnapTargetToggleVisibility.prototype.undo = function () { return this.redo(); }; return ECommandDocumentSnapTargetToggleVisibility; }(wcardinalUi.DCommandBase)); var ECommandDocumentSnapTargetToggle = /** @class */ (function (_super) { __extends(ECommandDocumentSnapTargetToggle, _super); function ECommandDocumentSnapTargetToggle(snapper) { var _this = _super.call(this) || this; _this._snapper = snapper; return _this; } Object.defineProperty(ECommandDocumentSnapTargetToggle.prototype, "snapper", { get: function () { return this._snapper; }, enumerable: false, configurable: true }); ECommandDocumentSnapTargetToggle.prototype.execute = function () { return this.redo(); }; ECommandDocumentSnapTargetToggle.prototype.redo = function () { var target = this._snapper.target; target.enable = !target.enable; return true; }; ECommandDocumentSnapTargetToggle.prototype.undo = function () { return this.redo(); }; return ECommandDocumentSnapTargetToggle; }(wcardinalUi.DCommandBase)); var ECommandDocumentSnapToggle = /** @class */ (function (_super) { __extends(ECommandDocumentSnapToggle, _super); function ECommandDocumentSnapToggle(snapper) { var _this = _super.call(this) || this; _this._snapper = snapper; return _this; } Object.defineProperty(ECommandDocumentSnapToggle.prototype, "snapper", { get: function () { return this._snapper; }, enumerable: false, configurable: true }); ECommandDocumentSnapToggle.prototype.execute = function () { return this.redo(); }; ECommandDocumentSnapToggle.prototype.redo = function () { var snapper = this._snapper; snapper.enable = !snapper.enable; return true; }; ECommandDocumentSnapToggle.prototype.undo = function () { return this.redo(); }; return ECommandDocumentSnapToggle; }(wcardinalUi.DCommandBase)); var ECommandDocumentSummary = /** @class */ (function (_super) { __extends(ECommandDocumentSummary, _super); function ECommandDocumentSummary(diagram, canvas, summary) { var _this = _super.call(this) || this; _this._diagram = diagram; _this._canvas = canvas; _this._summary = summary; return _this; } Object.defineProperty(ECommandDocumentSummary.prototype, "diagram", { get: function () { return this._diagram; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentSummary.prototype, "canvas", { get: function () { return this._canvas; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentSummary.prototype, "summary", { get: function () { return this._summary; }, enumerable: false, configurable: true }); ECommandDocumentSummary.prototype.execute = function () { return this.redo(); }; ECommandDocumentSummary.prototype.redo = function () { var canvas = this._canvas; var summary = this._summary; this._summary = canvas.summary; canvas.summary = summary; this._diagram.emit("change", this._diagram); return true; }; ECommandDocumentSummary.prototype.undo = function () { return this.redo(); }; return ECommandDocumentSummary; }(wcardinalUi.DCommandBase)); var ECommandDocumentWidth = /** @class */ (function (_super) { __extends(ECommandDocumentWidth, _super); function ECommandDocumentWidth(diagram, canvas, width) { var _this = _super.call(this) || this; _this._diagram = diagram; _this._canvas = canvas; _this._width = width; return _this; } Object.defineProperty(ECommandDocumentWidth.prototype, "diagram", { get: function () { return this._diagram; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentWidth.prototype, "canvas", { get: function () { return this._canvas; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentWidth.prototype, "width", { get: function () { return this._width; }, enumerable: false, configurable: true }); ECommandDocumentWidth.prototype.execute = function () { return this.redo(); }; ECommandDocumentWidth.prototype.redo = function () { var canvas = this._canvas; var width = this._width; this._width = canvas.width; canvas.x = canvas.x + (canvas.width - width) * 0.5; canvas.width = width; this._diagram.emit("change", this._diagram); return true; }; ECommandDocumentWidth.prototype.undo = function () { return this.redo(); }; return ECommandDocumentWidth; }(wcardinalUi.DCommandBase)); var ECommandLayerBringForward = /** @class */ (function (_super) { __extends(ECommandLayerBringForward, _super); function ECommandLayerBringForward(index, layerContainer) { var _this = _super.call(this) || this; _this._index = index; _this._layerContainer = layerContainer; return _this; } Object.defineProperty(ECommandLayerBringForward.prototype, "index", { get: function () { return this._index; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandLayerBringForward.prototype, "layerContainer", { get: function () { return this._layerContainer; }, enumerable: false, configurable: true }); ECommandLayerBringForward.prototype.execute = function () { return this.redo(); }; ECommandLayerBringForward.prototype.redo = function () { var index = this._index; var layerContainer = this._layerContainer; var children = layerContainer.children; var tmp = children[index]; children[index] = children[index + 1]; children[index + 1] = tmp; layerContainer.onChildrenChange(index); layerContainer.emit("change", layerContainer); wcardinalUi.DApplications.update(layerContainer); return true; }; ECommandLayerBringForward.prototype.undo = function () { this.redo(); return true; }; return ECommandLayerBringForward; }(wcardinalUi.DCommandBase)); var EDialogLayerValueBackground = /** @class */ (function () { function EDialogLayerValueBackground(enable, color, alpha) { this.enable = enable; this.color = color; this.alpha = alpha; } EDialogLayerValueBackground.prototype.isEqual = function (target) { return (this.enable === target.enable && this.color === target.color && this.alpha === target.alpha); }; EDialogLayerValueBackground.from = function (layer) { return new EDialogLayerValueBackground(layer.background.enable, layer.background.color, layer.background.alpha); }; return EDialogLayerValueBackground; }()); var EDialogLayerValue = /** @class */ (function () { function EDialogLayerValue(name, x, y, width, height, background, visible, interactive, gesture) { this.name = name; this.x = x; this.y = y; this.width = width; this.height = height; this.background = background; this.visible = visible; this.interactive = interactive; this.gesture = gesture; } EDialogLayerValue.prototype.isEqual = function (target) { return (this.name === target.name && this.x === target.x && this.y === target.y && this.width === target.width && this.height === target.height && this.background.isEqual(target.background) && this.visible === target.visible && this.interactive === target.interactive && this.gesture === target.gesture); }; EDialogLayerValue.prototype.copyTo = function (layer) { layer.name = this.name; layer.position.set(this.x, this.y); layer.width = this.width; layer.height = this.height; layer.background.copy(this.background); var state = layer.state; state.lock(); state.set(wcardinalUi.EShapeLayerState.INVISIBLE, !this.visible); state.set(wcardinalUi.EShapeLayerState.INTERACTIVE, this.interactive); var gesture = this.gesture; state.set(wcardinalUi.EShapeLayerState.DRAGGABLE, !!(gesture & wcardinalUi.EShapeActionValueGestureOperationType.DRAG)); state.set(wcardinalUi.EShapeLayerState.PINCHABLE, !!(gesture & wcardinalUi.EShapeActionValueGestureOperationType.PINCH)); state.unlock(); return this; }; EDialogLayerValue.from = function (layer) { var drag = layer.state.is(wcardinalUi.EShapeLayerState.DRAGGABLE) ? wcardinalUi.EShapeActionValueGestureOperationType.DRAG : wcardinalUi.EShapeActionValueGestureOperationType.NONE; var pinch = layer.state.is(wcardinalUi.EShapeLayerState.PINCHABLE) ? wcardinalUi.EShapeActionValueGestureOperationType.PINCH : wcardinalUi.EShapeActionValueGestureOperationType.NONE; var gesture = drag | pinch; return new EDialogLayerValue(layer.name, layer.position.x, layer.position.y, layer.width, layer.height, EDialogLayerValueBackground.from(layer), !layer.state.is(wcardinalUi.EShapeLayerState.INVISIBLE), layer.state.is(wcardinalUi.EShapeLayerState.INTERACTIVE), gesture); }; return EDialogLayerValue; }()); var ECommandLayerChange = /** @class */ (function (_super) { __extends(ECommandLayerChange, _super); function ECommandLayerChange(layer, value, layerContainer) { var _this = _super.call(this) || this; _this._layer = layer; _this._layerContainer = layerContainer; _this._oldValue = EDialogLayerValue.from(layer); _this._newValue = value; return _this; } Object.defineProperty(ECommandLayerChange.prototype, "layer", { get: function () { return this._layer; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandLayerChange.prototype, "newValue", { get: function () { return this._newValue; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandLayerChange.prototype, "oldValue", { get: function () { return this._oldValue; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandLayerChange.prototype, "layerContainer", { get: function () { return this._layerContainer; }, enumerable: false, configurable: true }); ECommandLayerChange.prototype.execute = function () { return this.redo(); }; ECommandLayerChange.prototype.redo = function () { this._newValue.copyTo(this._layer); var layerContainer = this._layerContainer; layerContainer.emit("change", layerContainer); return true; }; ECommandLayerChange.prototype.undo = function () { this._oldValue.copyTo(this._layer); var layerContainer = this._layerContainer; layerContainer.emit("change", layerContainer); return true; }; return ECommandLayerChange; }(wcardinalUi.DCommandBase)); var ECommandLayerCreate = /** @class */ (function (_super) { __extends(ECommandLayerCreate, _super); function ECommandLayerCreate(value, layerContainer, selection) { var _this = _super.call(this) || this; _this._value = value; _this._layerContainer = layerContainer; _this._layerActive = layerContainer.active; _this._layerCreated = null; _this._selection = selection; _this._selectionStored = null; return _this; } ECommandLayerCreate.prototype.newLayer = function (value, layerContainer) { var result = layerContainer.create(value.name, true); value.copyTo(result); return result; }; Object.defineProperty(ECommandLayerCreate.prototype, "value", { get: function () { return this._value; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandLayerCreate.prototype, "layerContainer", { get: function () { return this._layerContainer; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandLayerCreate.prototype, "layerActive", { get: function () { return this._layerActive; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandLayerCreate.prototype, "layerCreated", { get: function () { return this._layerCreated; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandLayerCreate.prototype, "selection", { get: function () { return this._selection; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandLayerCreate.prototype, "selectionStored", { get: function () { return this._selectionStored; }, enumerable: false, configurable: true }); ECommandLayerCreate.prototype.execute = function () { var selection = this._selection; if (!selection.isEmpty()) { this._selectionStored = selection.store(); selection.clear(); } else { this._selectionStored = null; } this._layerCreated = this.newLayer(this._value, this._layerContainer); this._layerCreated.reference += 1; return true; }; ECommandLayerCreate.prototype.redo = function () { var selectionStored = this._selectionStored; if (selectionStored != null) { this._selection.clear(); } var layerCreated = this._layerCreated; if (layerCreated != null) { this._layerContainer.attach(layerCreated, true); } return true; }; ECommandLayerCreate.prototype.undo = function () { var layerCreated = this._layerCreated; if (layerCreated != null) { this._layerContainer.detach(layerCreated, this._layerActive); } var selectionStored = this._selectionStored; if (selectionStored != null) { this._selection.restore(selectionStored); } return true; }; ECommandLayerCreate.prototype.destroy = function () { var layerCreated = this._layerCreated; if (layerCreated != null) { layerCreated.reference -= 1; if (layerCreated.parent == null && layerCreated.reference <= 0) { layerCreated.destroy(); } } this._layerActive = null; }; return ECommandLayerCreate; }(wcardinalUi.DCommandBase)); var ECommandLayerDelete = /** @class */ (function (_super) { __extends(ECommandLayerDelete, _super); function ECommandLayerDelete(layer, layerContainer, selection) { var _this = _super.call(this) || this; _this._layerContainer = layerContainer; _this._layerActive = layerContainer.active; _this._layer = layer; layer.reference += 1; _this._layerIndex =