med-viewer-sdk 0.1.11 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/Engine.d.ts +12 -0
- package/dist/core/Magnification.d.ts +1 -0
- package/dist/med-viewer-sdk.mjs +58 -11
- package/dist/med-viewer-sdk.umd.js +1 -1
- package/package.json +1 -1
- package/src/core/Engine.ts +51 -26
- package/src/core/Magnification.ts +43 -17
package/dist/core/Engine.d.ts
CHANGED
|
@@ -43,6 +43,17 @@ export interface AiBoxRect {
|
|
|
43
43
|
};
|
|
44
44
|
labels: Array<AiBoxRectLabel>;
|
|
45
45
|
}
|
|
46
|
+
export interface SelectionBox {
|
|
47
|
+
x: number;
|
|
48
|
+
y: number;
|
|
49
|
+
width: number;
|
|
50
|
+
height: number;
|
|
51
|
+
style: {
|
|
52
|
+
border: string;
|
|
53
|
+
fontSize: number;
|
|
54
|
+
[key: string]: any;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
46
57
|
/**
|
|
47
58
|
* 医学影像核心引擎
|
|
48
59
|
* 职责:初始化 OpenSeadragon,管理插件生命周期
|
|
@@ -70,6 +81,7 @@ export declare class MedViewerEngine {
|
|
|
70
81
|
loadAIMarks(aiBoxes?: AiBoxRect[], showLabel?: boolean): void;
|
|
71
82
|
updateAIMarks(aiBoxes?: AiBoxRect[], showLabel?: boolean): void;
|
|
72
83
|
clearAIMarks(): void;
|
|
84
|
+
loadSelectionBox(selections?: SelectionBox[]): void;
|
|
73
85
|
addHandler(event: string, handler: Function): void;
|
|
74
86
|
addOnceHandler(event: string, handler: Function): void;
|
|
75
87
|
removeHandler(event: string, handler: Function): void;
|
package/dist/med-viewer-sdk.mjs
CHANGED
|
@@ -15893,7 +15893,7 @@ class MagnificationPlugin {
|
|
|
15893
15893
|
const source = this.viewer.source;
|
|
15894
15894
|
const width = source.width;
|
|
15895
15895
|
source.height;
|
|
15896
|
-
const pixelsPerMeter = this.options.pixelsPerMeter || ((
|
|
15896
|
+
const pixelsPerMeter = this.options.pixelsPerMeter || ((_a2 = this.viewer.scalebarInstance) == null ? void 0 : _a2.pixelsPerMeter) || 96;
|
|
15897
15897
|
const currentZoom = this.viewer.viewport.getZoom();
|
|
15898
15898
|
const conversionFactor = 20 * 11e-4 * pixelsPerMeter / width;
|
|
15899
15899
|
const magnification = conversionFactor * currentZoom;
|
|
@@ -15948,6 +15948,25 @@ class MagnificationPlugin {
|
|
|
15948
15948
|
button.onclick = onClick;
|
|
15949
15949
|
return button;
|
|
15950
15950
|
}
|
|
15951
|
+
getMagnification() {
|
|
15952
|
+
var _a2, _b2;
|
|
15953
|
+
const tiledImage = this.viewer.world.getItemAt(0);
|
|
15954
|
+
if (!tiledImage)
|
|
15955
|
+
return 0;
|
|
15956
|
+
if (this.options.type === "LD") {
|
|
15957
|
+
const source = this.viewer.source;
|
|
15958
|
+
const width = source == null ? void 0 : source.width;
|
|
15959
|
+
const pixelsPerMeter = this.options.pixelsPerMeter || ((_a2 = this.viewer.scalebarInstance) == null ? void 0 : _a2.pixelsPerMeter) || 96;
|
|
15960
|
+
const currentZoom2 = this.viewer.viewport.getZoom();
|
|
15961
|
+
const conversionFactor = 20 * 11e-4 * pixelsPerMeter / width;
|
|
15962
|
+
return conversionFactor * currentZoom2;
|
|
15963
|
+
}
|
|
15964
|
+
const currentZoom = this.viewer.viewport.viewportToImageZoom(
|
|
15965
|
+
this.viewer.viewport.getZoom()
|
|
15966
|
+
);
|
|
15967
|
+
const baseMag = ((_b2 = this.viewer.source) == null ? void 0 : _b2.max_magnification) || 40;
|
|
15968
|
+
return currentZoom * baseMag;
|
|
15969
|
+
}
|
|
15951
15970
|
// 修改 setMagnification 方法
|
|
15952
15971
|
setMagnification(mag) {
|
|
15953
15972
|
var _a2, _b2;
|
|
@@ -15958,11 +15977,15 @@ class MagnificationPlugin {
|
|
|
15958
15977
|
const source = this.viewer.source;
|
|
15959
15978
|
const width = source.width;
|
|
15960
15979
|
source.height;
|
|
15961
|
-
const pixelsPerMeter = this.options.pixelsPerMeter || ((
|
|
15980
|
+
const pixelsPerMeter = this.options.pixelsPerMeter || ((_a2 = this.viewer.scalebarInstance) == null ? void 0 : _a2.pixelsPerMeter) || 96;
|
|
15962
15981
|
this.viewer.viewport.getZoom();
|
|
15963
15982
|
const conversionFactor = 20 * 11e-4 * pixelsPerMeter / width;
|
|
15964
15983
|
const targetZoom = mag / conversionFactor;
|
|
15965
|
-
this.viewer.viewport.zoomTo(
|
|
15984
|
+
this.viewer.viewport.zoomTo(
|
|
15985
|
+
targetZoom,
|
|
15986
|
+
this.viewer.viewport.getCenter(),
|
|
15987
|
+
false
|
|
15988
|
+
);
|
|
15966
15989
|
this.updateMagnificationDisplay();
|
|
15967
15990
|
} else {
|
|
15968
15991
|
const tiledImage = this.viewer.world.getItemAt(0);
|
|
@@ -16241,7 +16264,7 @@ class MedViewerEngine {
|
|
|
16241
16264
|
this.clearAIMarks();
|
|
16242
16265
|
aiBoxes.forEach((box) => {
|
|
16243
16266
|
var elt = document.createElement("div");
|
|
16244
|
-
elt.classList.add("
|
|
16267
|
+
elt.classList.add("ld-ai-box");
|
|
16245
16268
|
if (box.style) {
|
|
16246
16269
|
Object.assign(elt.style, box.style);
|
|
16247
16270
|
}
|
|
@@ -16271,12 +16294,7 @@ class MedViewerEngine {
|
|
|
16271
16294
|
const h2 = box.height / size.y;
|
|
16272
16295
|
this.viewer.addOverlay({
|
|
16273
16296
|
element: elt,
|
|
16274
|
-
location: new OpenSeadragon.Rect(
|
|
16275
|
-
x2,
|
|
16276
|
-
y2,
|
|
16277
|
-
w2,
|
|
16278
|
-
h2
|
|
16279
|
-
)
|
|
16297
|
+
location: new OpenSeadragon.Rect(x2, y2, w2, h2)
|
|
16280
16298
|
});
|
|
16281
16299
|
});
|
|
16282
16300
|
}
|
|
@@ -16285,11 +16303,40 @@ class MedViewerEngine {
|
|
|
16285
16303
|
}
|
|
16286
16304
|
clearAIMarks() {
|
|
16287
16305
|
const aiBoxesList = Array.from(
|
|
16288
|
-
document.getElementsByClassName(
|
|
16306
|
+
document.getElementsByClassName(
|
|
16307
|
+
"ld-ai-box"
|
|
16308
|
+
)
|
|
16309
|
+
);
|
|
16310
|
+
aiBoxesList.forEach((box) => {
|
|
16311
|
+
this.viewer.removeOverlay(box);
|
|
16312
|
+
});
|
|
16313
|
+
}
|
|
16314
|
+
loadSelectionBox(selections = []) {
|
|
16315
|
+
const aiBoxesList = Array.from(
|
|
16316
|
+
document.getElementsByClassName(
|
|
16317
|
+
"ld-selection-box"
|
|
16318
|
+
)
|
|
16289
16319
|
);
|
|
16290
16320
|
aiBoxesList.forEach((box) => {
|
|
16291
16321
|
this.viewer.removeOverlay(box);
|
|
16292
16322
|
});
|
|
16323
|
+
selections.forEach((selection) => {
|
|
16324
|
+
let elt = document.createElement("div");
|
|
16325
|
+
elt.classList.add("ld-selection-box");
|
|
16326
|
+
if (selection.style) {
|
|
16327
|
+
Object.assign(elt.style, selection.style);
|
|
16328
|
+
}
|
|
16329
|
+
const img = this.viewer.world.getItemAt(0);
|
|
16330
|
+
const size = img.getContentSize();
|
|
16331
|
+
const x2 = selection.x / size.x;
|
|
16332
|
+
const y2 = selection.y / size.y;
|
|
16333
|
+
const w2 = selection.width / size.x;
|
|
16334
|
+
const h2 = selection.height / size.y;
|
|
16335
|
+
this.viewer.addOverlay({
|
|
16336
|
+
element: elt,
|
|
16337
|
+
location: new OpenSeadragon.Rect(x2, y2, w2, h2)
|
|
16338
|
+
});
|
|
16339
|
+
});
|
|
16293
16340
|
}
|
|
16294
16341
|
addHandler(event2, handler) {
|
|
16295
16342
|
if (!this.events.has(event2)) {
|