@wcardinal/wcardinal-geditor
Version:
WebGL-based graphic editor, tester and viewer for supervisory systems
63 lines • 2.81 kB
JavaScript
import { __extends } from "tslib";
import { EShapeCapabilities, EShapeCapability, EShapeConnectorLine } from "@wcardinal/wcardinal-ui";
import { ECommandShapeProperty } from "./e-command-shape-property";
var ECommandShapePropertyPositionAndRotate = /** @class */ (function (_super) {
__extends(ECommandShapePropertyPositionAndRotate, _super);
function ECommandShapePropertyPositionAndRotate(selection) {
return _super.call(this, selection, undefined) || this;
}
ECommandShapePropertyPositionAndRotate.prototype.toCapability = function (shape) {
if (shape instanceof EShapeConnectorLine) {
var edge = shape.edge;
if (edge.tail.acceptor.shape == null && edge.head.acceptor.shape == null) {
return EShapeCapability.ALL;
}
return EShapeCapability.NONE;
}
else {
var result = EShapeCapability.NONE;
if (EShapeCapabilities.contains(shape, EShapeCapability.POSITION)) {
result |= EShapeCapability.POSITION;
}
if (EShapeCapabilities.contains(shape, EShapeCapability.ROTATION)) {
result |= EShapeCapability.ROTATION;
}
return result;
}
};
ECommandShapePropertyPositionAndRotate.prototype.getProperty = function (shape, capability) {
if (shape instanceof EShapeConnectorLine) {
var edge = shape.edge;
var tailLocal = edge.tail.local;
var headLocal = edge.head.local;
return [tailLocal.x, tailLocal.y, headLocal.x, headLocal.y];
}
else {
var transform = shape.transform;
var position = transform.position;
return [position.x, position.y, transform.rotation, 0];
}
};
ECommandShapePropertyPositionAndRotate.prototype.setProperty = function (shape, capability, property) {
if (shape instanceof EShapeConnectorLine) {
var edge = shape.edge;
edge.tail.local.set(property[0], property[1]);
edge.head.local.set(property[2], property[3]);
}
else {
var transform = shape.transform;
if (capability & EShapeCapability.POSITION) {
transform.position.set(property[0], property[1]);
}
if (capability & EShapeCapability.ROTATION) {
transform.rotation = property[2];
}
}
};
ECommandShapePropertyPositionAndRotate.prototype.initProperty = function (shape, capability, property) {
// DO NOTHING
};
return ECommandShapePropertyPositionAndRotate;
}(ECommandShapeProperty));
export { ECommandShapePropertyPositionAndRotate };
//# sourceMappingURL=e-command-shape-property-position-and-rotation.js.map