UNPKG

medsurf-draw

Version:

Draw annotations on jpg/zoomify images, based on PIXI.js

103 lines 4.9 kB
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 PIXI from "pixi.js-legacy"; import * as MedsurfDraw from "../../public-api"; import { BaseContainer, BaseContainerModel } from "../../bases/elements/BaseContainer"; import { Design } from "../../config/design"; var VirtualPointerElementModel = (function (_super) { __extends(VirtualPointerElementModel, _super); function VirtualPointerElementModel() { return _super !== null && _super.apply(this, arguments) || this; } return VirtualPointerElementModel; }(BaseContainerModel)); export { VirtualPointerElementModel }; var VirtualPointerElement = (function (_super) { __extends(VirtualPointerElement, _super); function VirtualPointerElement(model) { var _this = _super.call(this, model) || this; _this.zIndex = Design.virtualPointerElement.zIndex; _this.rotation = 45 * Math.PI / 180; _this.moveInteraction = new MedsurfDraw.MoveInteraction(_this, true); _this.moveInteraction.on("onMove", _this.onMove, _this); _this.on("added", function (parent) { _this.on("pointerover", _this._moveInteraction.onMoveHover, _this._moveInteraction); _this.on("mousedown", _this._moveInteraction.startMove, _this._moveInteraction); _this.on("pointermove", _this._moveInteraction.onMove, _this._moveInteraction); _this.on("mouseup", _this._moveInteraction.endMove, _this._moveInteraction); _this.on("pointerupoutside", _this._moveInteraction.endMove, _this._moveInteraction); }); _this.on("removed", function (parent) { _this.off("pointerover", _this._moveInteraction.onMoveHover, _this._moveInteraction); _this.off("mousedown", _this._moveInteraction.startMove, _this._moveInteraction); _this.off("pointermove", _this._moveInteraction.onMove, _this._moveInteraction); _this.off("mouseup", _this._moveInteraction.endMove, _this._moveInteraction); _this.off("pointerupoutside", _this._moveInteraction.endMove, _this._moveInteraction); }); return _this; } VirtualPointerElement.prototype.init = function () { this.interactive = true; this.position.set(this.rectangle.x, this.rectangle.y); this._arrowElement = new MedsurfDraw.Arrow({ rectangle: new PIXI.Rectangle(0, 0, this.rectangle.width, this.rectangle.height), wedgePoint: undefined, options: { hasLine: true, lineColor: Design.virtualPointerElement.lineColor, lineAlpha: Design.virtualPointerElement.lineAlpha, hasFill: true, fillColor: Design.virtualPointerElement.fillColor, fillAlpha: Design.virtualPointerElement.fillAlpha }, lineWidth: Design.virtualPointerElement.lineWidth }); this.addChild(this._arrowElement); }; VirtualPointerElement.prototype.draw = function () { this._arrowElement.draw(); }; VirtualPointerElement.prototype.destroy = function (options) { if (this.moveInteraction) { this.moveInteraction.removeAllListeners(); } if (this._arrowElement) { this._arrowElement.destroy(options); } _super.prototype.destroy.call(this, options); }; VirtualPointerElement.prototype.onMove = function (event, dX, dY) { event.stopPropagation(); this.position.x += dX; this.position.y += dY; }; Object.defineProperty(VirtualPointerElement.prototype, "rectangle", { get: function () { return this.data.rectangle; }, set: function (value) { this.data.rectangle = value; }, enumerable: false, configurable: true }); Object.defineProperty(VirtualPointerElement.prototype, "moveInteraction", { get: function () { return this._moveInteraction; }, set: function (value) { this._moveInteraction = value; }, enumerable: false, configurable: true }); return VirtualPointerElement; }(BaseContainer)); export { VirtualPointerElement }; //# sourceMappingURL=VirtualPointerElement.js.map