@wcardinal/wcardinal-geditor
Version:
WebGL-based graphic editor, tester and viewer for supervisory systems
105 lines • 3.46 kB
JavaScript
import { __extends } from "tslib";
import { DCommandBase } from "@wcardinal/wcardinal-ui";
var ECommandShapeCreate = /** @class */ (function (_super) {
__extends(ECommandShapeCreate, _super);
function ECommandShapeCreate(shapes, 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._parent = parent;
_this._selection = selection;
_this._select = select;
return _this;
}
Object.defineProperty(ECommandShapeCreate.prototype, "parent", {
get: function () {
return this._parent;
},
enumerable: false,
configurable: true
});
Object.defineProperty(ECommandShapeCreate.prototype, "shapes", {
get: function () {
return this._shapes;
},
enumerable: false,
configurable: true
});
Object.defineProperty(ECommandShapeCreate.prototype, "selection", {
get: function () {
return this._selection;
},
enumerable: false,
configurable: true
});
Object.defineProperty(ECommandShapeCreate.prototype, "selectionStored", {
get: function () {
return this._selectionStored;
},
enumerable: false,
configurable: true
});
Object.defineProperty(ECommandShapeCreate.prototype, "select", {
get: function () {
return this._select;
},
enumerable: false,
configurable: true
});
ECommandShapeCreate.prototype.execute = function () {
var selection = this._selection;
selection.lock();
if (this._select) {
this._selectionStored = selection.store();
selection.clearAndAddAll(this._shapes);
}
selection.update("TREE");
selection.unlock();
return true;
};
ECommandShapeCreate.prototype.redo = function () {
var shapes = this._shapes;
var parent = this._parent;
for (var i = 0, imax = shapes.length; i < imax; ++i) {
shapes[i].attach(parent);
}
var selection = this._selection;
selection.lock();
if (this._select) {
selection.clearAndAddAll(shapes);
}
selection.update("TREE");
selection.unlock();
return true;
};
ECommandShapeCreate.prototype.undo = function () {
var shapes = this._shapes;
for (var i = 0, imax = shapes.length; i < imax; ++i) {
shapes[i].detach();
}
var selection = this._selection;
var selectionStored = this._selectionStored;
selection.lock();
if (this._select && selectionStored != null) {
selection.restore(selectionStored);
}
selection.update("TREE");
selection.unlock();
return true;
};
ECommandShapeCreate.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();
}
}
};
return ECommandShapeCreate;
}(DCommandBase));
export { ECommandShapeCreate };
//# sourceMappingURL=e-command-shape-create.js.map