med-viewer-sdk 0.1.21 → 0.1.22

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.
@@ -86,6 +86,10 @@ export declare class MedViewerEngine {
86
86
  private mountAnnotorious;
87
87
  loadAIMarks(aiBoxes?: AiBoxRect[], showLabel?: boolean): void;
88
88
  updateAIMarks(aiBoxes?: AiBoxRect[], showLabel?: boolean): void;
89
+ goToPosition(target: {
90
+ x: number;
91
+ y: number;
92
+ }, animate?: boolean, mag?: number | null): Promise<void>;
89
93
  clearAIMarks(): void;
90
94
  loadSelectionBox(selections?: SelectionBox[]): void;
91
95
  addHandler(event: string, handler: Function): void;
@@ -1,8 +1,10 @@
1
1
  import { AnnoAnnotator } from './core/AnnoAnnotator';
2
2
  import { ColorAdjustPlugin, type ColorAdjustOptions } from './core/ColorAdjustPlugin';
3
3
  import { MedViewerEngine, type MedEngineOptions } from './core/Engine';
4
+ import type OpenSeadragonType from 'openseadragon';
5
+ import OpenSeadragon from 'openseadragon';
4
6
  import { MagnificationPlugin, MagnificationPosition, MagnificationType, type MagnificationOptions } from './core/Magnification';
5
7
  import { ScalebarLocation, ScalebarType, type ScalebarOptions } from './core/Scalebar';
6
8
  import { SelectionPlugin, type SelectionOptions } from './core/SelectionPlugin';
7
9
  import { MedToolbar, ToolbarPosition, type ToolbarOptions } from './core/Toolbar';
8
- export { AnnoAnnotator, ColorAdjustPlugin, MagnificationPlugin, MagnificationPosition, MagnificationType, MedToolbar, MedViewerEngine, ScalebarLocation, ScalebarType, SelectionPlugin, ToolbarPosition, type ColorAdjustOptions, type MagnificationOptions, type MedEngineOptions, type ScalebarOptions, type SelectionOptions, type ToolbarOptions };
10
+ export { AnnoAnnotator, ColorAdjustPlugin, MagnificationPlugin, MagnificationPosition, MagnificationType, MedToolbar, MedViewerEngine, ScalebarLocation, ScalebarType, SelectionPlugin, ToolbarPosition, OpenSeadragon, type OpenSeadragonType, type ColorAdjustOptions, type MagnificationOptions, type MedEngineOptions, type ScalebarOptions, type SelectionOptions, type ToolbarOptions };
@@ -6,6 +6,7 @@ var __publicField = (obj, key, value) => {
6
6
  };
7
7
  var _a, _b, _c, _d, _e;
8
8
  import OpenSeadragon from "openseadragon";
9
+ import { default as default2 } from "openseadragon";
9
10
  function getDefaultExportFromCjs(x2) {
10
11
  return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
11
12
  }
@@ -15820,6 +15821,7 @@ const DEFAULT_BUTTONS = [
15820
15821
  label: t("toolbar.screenshot"),
15821
15822
  onClick: (engine, hide) => {
15822
15823
  var _a2;
15824
+ console.log("selection toggleState");
15823
15825
  (_a2 = engine.selection) == null ? void 0 : _a2.toggleState();
15824
15826
  if (engine.anno) {
15825
15827
  engine.anno.setEnabled(false);
@@ -16467,6 +16469,38 @@ class MedViewerEngine {
16467
16469
  updateAIMarks(aiBoxes = [], showLabel = false) {
16468
16470
  this.loadAIMarks(aiBoxes, showLabel);
16469
16471
  }
16472
+ async goToPosition(target, animate = true, mag = null) {
16473
+ var _a2, _b2, _c2, _d2;
16474
+ const point = this.viewer.viewport.imageToViewportCoordinates(target.x, target.y);
16475
+ if (!point)
16476
+ return;
16477
+ if (!mag) {
16478
+ this.viewer.viewport.panTo(point, animate);
16479
+ return;
16480
+ }
16481
+ const { plugins } = this.options;
16482
+ const config = typeof (plugins == null ? void 0 : plugins.magnification) === "object" ? plugins.magnification : {};
16483
+ if (config.type === "LD") {
16484
+ const tiledImage = this.viewer.world.getItemAt(0);
16485
+ if (!tiledImage)
16486
+ return;
16487
+ const source = this.viewer.source;
16488
+ const width = source.width;
16489
+ source.height;
16490
+ const pixelsPerMeter = typeof (plugins == null ? void 0 : plugins.scalebar) === "object" && ((_a2 = plugins == null ? void 0 : plugins.scalebar) == null ? void 0 : _a2.pixelsPerMeter) ? (_b2 = plugins == null ? void 0 : plugins.scalebar) == null ? void 0 : _b2.pixelsPerMeter : ((_c2 = this.viewer.scalebarInstance) == null ? void 0 : _c2.pixelsPerMeter) || 96;
16491
+ const conversionFactor = 20 * 11e-4 * pixelsPerMeter / width;
16492
+ const targetZoom = mag / conversionFactor;
16493
+ await this.viewer.viewport.zoomTo(targetZoom, point, false);
16494
+ } else {
16495
+ const tiledImage = this.viewer.world.getItemAt(0);
16496
+ if (!tiledImage)
16497
+ return;
16498
+ const baseMag = ((_d2 = this.viewer.source) == null ? void 0 : _d2.max_magnification) || 40;
16499
+ const targetImageZoom = mag / baseMag;
16500
+ const targetViewportZoom = this.viewer.viewport.imageToViewportZoom(targetImageZoom);
16501
+ await this.viewer.viewport.zoomTo(targetViewportZoom, point, false);
16502
+ }
16503
+ }
16470
16504
  clearAIMarks() {
16471
16505
  const aiBoxesList = Array.from(
16472
16506
  document.getElementsByClassName("ld-ai-box")
@@ -16569,6 +16603,7 @@ export {
16569
16603
  MagnificationType,
16570
16604
  MedToolbar,
16571
16605
  MedViewerEngine,
16606
+ default2 as OpenSeadragon,
16572
16607
  ScalebarLocation,
16573
16608
  ScalebarType,
16574
16609
  SelectionPlugin,