medsurf-draw
Version:
Draw annotations on jpg/zoomify images, based on PIXI.js
156 lines • 5.77 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 PIXI from "pixi.js-legacy";
import * as MedsurfDraw from "../../public-api";
import { debounce } from 'debounce';
var BaseGraphicsModel = (function () {
function BaseGraphicsModel() {
}
return BaseGraphicsModel;
}());
export { BaseGraphicsModel };
var BaseGraphicsImageModel = (function (_super) {
__extends(BaseGraphicsImageModel, _super);
function BaseGraphicsImageModel() {
return _super !== null && _super.apply(this, arguments) || this;
}
return BaseGraphicsImageModel;
}(BaseGraphicsModel));
export { BaseGraphicsImageModel };
var BaseGraphics = (function (_super) {
__extends(BaseGraphics, _super);
function BaseGraphics(data) {
var _this = _super.call(this) || this;
_this.data = data;
_this.modeInteraction = new MedsurfDraw.ModeInteraction(_this);
_this.modeInteraction.on("init", _this.init, _this);
_this._debounceDrawMethod = debounce(_this.draw.bind(_this), 20).bind(_this);
_this.on("added", function (parent) {
_this.on("debounceDraw", _this._debounceDrawMethod);
parent.modeInteraction.on("setDefaultMode", _this.modeInteraction.setDefaultMode, _this.modeInteraction);
parent.modeInteraction.on("setMode", _this.modeInteraction.setMode, _this.modeInteraction);
});
_this.on("removed", function (parent) {
_this.off("debounceDraw", _this._debounceDrawMethod);
parent.modeInteraction.off("setDefaultMode", _this.modeInteraction.setDefaultMode, _this.modeInteraction);
parent.modeInteraction.off("setMode", _this.modeInteraction.setMode, _this.modeInteraction);
});
return _this;
}
BaseGraphics.prototype.init = function (parent) {
return;
};
BaseGraphics.prototype.draw = function () {
return;
};
BaseGraphics.prototype.destroy = function (options) {
if (this.modeInteraction) {
this.modeInteraction.removeAllListeners();
}
this.removeAllListeners();
_super.prototype.destroy.call(this, options);
};
BaseGraphics.prototype.getRectangle = function () {
var position = this.position;
var bounds = this.getLocalBounds();
return new PIXI.Rectangle(position.x + bounds.x, position.y + bounds.y, bounds.width, bounds.height);
};
BaseGraphics.prototype.getElementRectangle = function () {
return this.getRectangle();
};
BaseGraphics.prototype.getRotation = function () {
return this.rotation;
};
BaseGraphics.prototype.showItem = function () {
this.visible = true;
this.emit("debounceDraw");
};
BaseGraphics.prototype.hideItem = function () {
this.visible = false;
};
BaseGraphics.prototype.toggleItem = function (override) {
this.visible = override || !this.visible;
};
BaseGraphics.prototype.onImageZoom = function (scaleX, scaleY) {
};
Object.defineProperty(BaseGraphics.prototype, "data", {
get: function () {
return this._data;
},
set: function (value) {
this._data = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(BaseGraphics.prototype, "image", {
get: function () {
if (this.data.hasOwnProperty("image")) {
return this.data.image;
}
debugger;
throw 'Not implemented';
},
enumerable: false,
configurable: true
});
Object.defineProperty(BaseGraphics.prototype, "imageCanvas", {
get: function () {
if (this.data.hasOwnProperty("image")) {
return this.data.image.canvas;
}
debugger;
throw 'Not implemented';
},
enumerable: false,
configurable: true
});
Object.defineProperty(BaseGraphics.prototype, "imageScale", {
get: function () {
if (this.data.hasOwnProperty("image")) {
return this.data.image.imageScale;
}
debugger;
throw 'Not implemented';
},
enumerable: false,
configurable: true
});
Object.defineProperty(BaseGraphics.prototype, "imageDimensions", {
get: function () {
if (this.data.hasOwnProperty("image")) {
return this.data.image.imageDimensions;
}
debugger;
throw 'Not implemented';
},
enumerable: false,
configurable: true
});
Object.defineProperty(BaseGraphics.prototype, "modeInteraction", {
get: function () {
return this._modeInteraction;
},
set: function (value) {
this._modeInteraction = value;
},
enumerable: false,
configurable: true
});
return BaseGraphics;
}(PIXI.Graphics));
export { BaseGraphics };
//# sourceMappingURL=BaseGraphics.js.map