medsurf-draw
Version:
Draw annotations on jpg/zoomify images, based on PIXI.js
98 lines • 4.24 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
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);
};
return function (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 __());
};
})();
import * as MedsurfDraw from "../public-api";
import { BaseElementInteraction } from "../bases/interactions/BaseElementInteraction";
export var ChooseTypes;
(function (ChooseTypes) {
ChooseTypes[ChooseTypes["PositionPoint"] = 0] = "PositionPoint";
ChooseTypes[ChooseTypes["Lines"] = 1] = "Lines";
ChooseTypes[ChooseTypes["Primitives"] = 2] = "Primitives";
ChooseTypes[ChooseTypes["Collections"] = 3] = "Collections";
})(ChooseTypes || (ChooseTypes = {}));
var ChooseInteraction = (function (_super) {
__extends(ChooseInteraction, _super);
function ChooseInteraction(element, chooseType) {
var _this = _super.call(this, element) || this;
_this.chooseType = chooseType;
return _this;
}
ChooseInteraction.prototype.reset = function () {
return;
};
ChooseInteraction.prototype.startChoose = function (event) {
event.stopPropagation();
this.emit("startChooseStart", event);
if (this.element.moveInteraction.isMoving) {
return;
}
this.emit("startMove", event);
this.emit("startChoose", event);
};
ChooseInteraction.prototype.onChoose = function (event) {
this.emit("onChooseStart", event);
if (this.element.moveInteraction.isMoving) {
this.emit("onMove", event);
}
this.emit("onChoose", event);
};
ChooseInteraction.prototype.endChoose = function (event) {
event.stopPropagation();
this.emit("endChooseStart", event);
if (this.element.moveInteraction.isMoving) {
this.emit("endMove", event);
}
var image = this.element.image;
var renderer = image.renderer;
if (renderer) {
var globalPoint = renderer.plugins.interaction.mouse.global;
var element = renderer.plugins.interaction.hitTest(globalPoint, image);
if (element instanceof MedsurfDraw.PositionPoint) {
this.emit("chooseElement", event, element);
}
else if (this._chooseType >= ChooseTypes.Lines && element instanceof MedsurfDraw.Line) {
this.emit("chooseElement", event, element);
}
else if (this._chooseType >= ChooseTypes.Primitives && (element instanceof MedsurfDraw.ArrowPrimitive
|| element instanceof MedsurfDraw.EllipsePrimitive
|| element instanceof MedsurfDraw.RectanglePrimitive
|| element instanceof MedsurfDraw.TextPrimitive)) {
this.emit("chooseElement", event, element.parent);
}
else if (this._chooseType >= ChooseTypes.Collections && (element instanceof MedsurfDraw.LegendRow
|| element instanceof MedsurfDraw.FillCollection)) {
this.emit("chooseElement", event, element);
}
}
};
ChooseInteraction.prototype.abortChoose = function (event) {
event.stopPropagation();
this.emit("abortChooseStart", event);
this.emit("abortChoose", event);
};
Object.defineProperty(ChooseInteraction.prototype, "chooseType", {
get: function () {
return this._chooseType;
},
set: function (value) {
this._chooseType = value;
},
enumerable: false,
configurable: true
});
return ChooseInteraction;
}(BaseElementInteraction));
export { ChooseInteraction };
//# sourceMappingURL=ChooseInteraction.js.map