med-viewer-sdk 0.1.11 → 0.1.13
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/README.md +139 -137
- package/dist/core/Engine.d.ts +21 -9
- package/dist/core/Magnification.d.ts +1 -0
- package/dist/core/SelectionPlugin.d.ts +2 -2
- package/dist/med-viewer-sdk.d.ts +8 -8
- package/dist/med-viewer-sdk.mjs +12602 -12576
- package/dist/med-viewer-sdk.umd.js +2 -2
- package/package.json +1 -1
- package/src/core/Engine.ts +190 -198
- package/src/core/Magnification.ts +43 -17
- package/src/core/SelectionPlugin.ts +112 -118
- package/src/i18n/i18n.ts +32 -34
- package/src/index.ts +23 -30
package/README.md
CHANGED
|
@@ -6,41 +6,41 @@ MedViewer SDK 是一个强大且灵活的医学图像查看 SDK,它基于 Open
|
|
|
6
6
|
|
|
7
7
|
- **高性能图像查看:** 利用 OpenSeadragon 实现高分辨率医学图像的无缝查看,支持深度缩放和平移功能。
|
|
8
8
|
- **可定制工具栏:**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
- 动态且可配置的工具栏,可集成各种工具和插件。
|
|
10
|
+
- 支持文本和图标按钮。
|
|
11
|
+
- 按钮可以触发设置下拉菜单或直接执行操作。
|
|
12
|
+
- 用户定义的按钮配置可以覆盖默认设置(图标、标签、功能)。
|
|
13
|
+
- 响应式布局,侧边工具栏(MIDDLE_LEFT, MIDDLE_RIGHT)支持垂直方向。
|
|
14
14
|
- **选择插件:**
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
- 提供交互式选择功能(例如,绘制矩形)。
|
|
16
|
+
- 可配置的选择外观和行为。
|
|
17
|
+
- 与工具栏集成,方便访问和控制。
|
|
18
18
|
- **比例尺插件:**
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
- 在查看器上显示动态比例尺。
|
|
20
|
+
- 支持不同类型的比例尺(例如,显微镜、地图)。
|
|
21
|
+
- 可配置位置、颜色、字体和大小。
|
|
22
|
+
- 自动初始化并与查看器的缩放级别同步。
|
|
23
23
|
- **标注工具:**
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
24
|
+
- **Annotorious 集成 (AnnoAnnotator):**
|
|
25
|
+
- 集成 Annotorious 库以提供高级标注功能。
|
|
26
|
+
- 支持各种标注工具(例如,徒手绘制、多边形)。
|
|
27
|
+
- 提供启用/禁用、设置工具、获取/设置标注和清除标注的方法。
|
|
28
|
+
- 动态注入自定义标注样式。
|
|
29
|
+
- **Konva.js 集成 (KonvaAnnotator):**
|
|
30
|
+
- 利用 Konva.js 实现自定义绘图覆盖。
|
|
31
|
+
- 当前支持绘制矩形和可能的箭头(注释掉的同步逻辑表明可能计划了更复杂的交互)。
|
|
32
|
+
- 允许拖动形状。
|
|
33
|
+
- 无论缩放级别如何,都保持恒定的描边宽度 (`strokeScaleEnabled: false`)。
|
|
34
|
+
- 提供启用/禁用、设置工具、获取/设置标注和清除标注的方法。
|
|
35
35
|
- **颜色调整插件:**
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
- 启用对图像属性(如亮度、对比度、饱和度、伽马、锐化、边缘增强、伪彩色和反色)的实时调整。
|
|
37
|
+
- **利用 WebGL 着色器:** 直接在 GPU 上实现调整以提高性能。
|
|
38
|
+
- 尝试强制 OpenSeadragon 使用其 WebGL 渲染器以获得最佳功能。
|
|
39
|
+
- 提供自定义 WebGL 着色器用于高级颜色操作。
|
|
40
40
|
- **基于插件的架构:**
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
- SDK 采用模块化、基于插件的架构设计,以 `MedViewerEngine` 作为核心协调器。
|
|
42
|
+
- 易于扩展以添加新功能。
|
|
43
|
+
- 管理各种插件的生命周期(初始化、销毁)。
|
|
44
44
|
|
|
45
45
|
## 安装
|
|
46
46
|
|
|
@@ -54,7 +54,7 @@ yarn add openseadragon
|
|
|
54
54
|
然后,在您的项目中引入 SDK:
|
|
55
55
|
|
|
56
56
|
```typescript
|
|
57
|
-
import { MedViewerEngine } from 'med-viewer-sdk'
|
|
57
|
+
import { MedViewerEngine } from 'med-viewer-sdk' // 根据需要调整路径
|
|
58
58
|
// 如果有任何 CSS,请导入
|
|
59
59
|
```
|
|
60
60
|
|
|
@@ -63,10 +63,10 @@ import { MedViewerEngine } from 'med-viewer-sdk'; // 根据需要调整路径
|
|
|
63
63
|
### 基本初始化
|
|
64
64
|
|
|
65
65
|
```typescript
|
|
66
|
-
import { MedViewerEngine } from './core/Engine'
|
|
67
|
-
import OpenSeadragon from 'openseadragon'
|
|
66
|
+
import { MedViewerEngine } from './core/Engine' // 以本地路径为例
|
|
67
|
+
import OpenSeadragon from 'openseadragon'
|
|
68
68
|
|
|
69
|
-
const viewerElement = document.getElementById('med-viewer-container')
|
|
69
|
+
const viewerElement = document.getElementById('med-viewer-container')
|
|
70
70
|
|
|
71
71
|
if (viewerElement) {
|
|
72
72
|
const engine = new MedViewerEngine({
|
|
@@ -78,49 +78,51 @@ if (viewerElement) {
|
|
|
78
78
|
tileSources: {
|
|
79
79
|
type: 'image',
|
|
80
80
|
url: 'https://openseadragon.github.io/example-images/duomo/duomo.dzi'
|
|
81
|
-
}
|
|
81
|
+
}
|
|
82
82
|
// ... 其他 OSD 选项
|
|
83
83
|
},
|
|
84
84
|
plugins: {
|
|
85
85
|
toolbar: true, // 启用默认工具栏
|
|
86
86
|
selection: true, // 启用选择插件
|
|
87
|
-
scalebar: {
|
|
87
|
+
scalebar: {
|
|
88
|
+
// 启用比例尺插件并带自定义选项
|
|
88
89
|
type: 'MICROSCOPY',
|
|
89
90
|
location: 'BOTTOM_LEFT',
|
|
90
91
|
color: 'rgb(255, 255, 255)',
|
|
91
92
|
fontColor: 'rgb(255, 255, 255)',
|
|
92
|
-
backgroundColor: 'rgba(0, 0, 0, 0.5)'
|
|
93
|
+
backgroundColor: 'rgba(0, 0, 0, 0.5)'
|
|
93
94
|
},
|
|
94
95
|
anno: true, // 启用 Annotorious
|
|
95
96
|
konva: true, // 启用 Konva.js 绘图
|
|
96
|
-
colorAdjust: {
|
|
97
|
+
colorAdjust: {
|
|
98
|
+
// 启用颜色调整并带初始设置
|
|
97
99
|
initial: {
|
|
98
100
|
brightness: 1.2,
|
|
99
101
|
contrast: 0.8,
|
|
100
|
-
invert: true
|
|
102
|
+
invert: true
|
|
101
103
|
}
|
|
102
104
|
}
|
|
103
105
|
}
|
|
104
|
-
})
|
|
106
|
+
})
|
|
105
107
|
|
|
106
108
|
// 访问插件
|
|
107
109
|
if (engine.toolbar) {
|
|
108
|
-
console.log('工具栏已激活')
|
|
110
|
+
console.log('工具栏已激活')
|
|
109
111
|
}
|
|
110
112
|
if (engine.selection) {
|
|
111
|
-
engine.selection.enable()
|
|
112
|
-
engine.selection.setSelectionMode('RECTANGLE')
|
|
113
|
+
engine.selection.enable()
|
|
114
|
+
engine.selection.setSelectionMode('RECTANGLE')
|
|
113
115
|
}
|
|
114
116
|
if (engine.anno) {
|
|
115
|
-
engine.anno.setEnabled(true)
|
|
116
|
-
engine.anno.setTool('rect')
|
|
117
|
+
engine.anno.setEnabled(true)
|
|
118
|
+
engine.anno.setTool('rect')
|
|
117
119
|
}
|
|
118
120
|
if (engine.konva) {
|
|
119
|
-
engine.konva.setEnabled(true)
|
|
120
|
-
engine.konva.setTool('rect')
|
|
121
|
+
engine.konva.setEnabled(true)
|
|
122
|
+
engine.konva.setTool('rect')
|
|
121
123
|
}
|
|
122
124
|
if (engine.colorAdjust) {
|
|
123
|
-
engine.colorAdjust.setAdjustments({ brightness: 1.5 })
|
|
125
|
+
engine.colorAdjust.setAdjustments({ brightness: 1.5 })
|
|
124
126
|
}
|
|
125
127
|
|
|
126
128
|
// 不再需要时进行清理
|
|
@@ -133,36 +135,36 @@ if (viewerElement) {
|
|
|
133
135
|
您可以通过将 `ToolbarButton` 配置数组传递给 `toolbar` 插件选项来定制工具栏。可以通过匹配其 `id` 来覆盖现有默认按钮。
|
|
134
136
|
|
|
135
137
|
```typescript
|
|
136
|
-
import { MedViewerEngine, ToolbarButton } from './core/Engine'
|
|
137
|
-
import myCustomIcon from './assets/my-icon.png'
|
|
138
|
+
import { MedViewerEngine, ToolbarButton } from './core/Engine' // 以本地路径为例
|
|
139
|
+
import myCustomIcon from './assets/my-icon.png'
|
|
138
140
|
|
|
139
141
|
const customToolbarButtons: ToolbarButton[] = [
|
|
140
142
|
{
|
|
141
143
|
id: 'anno', // 覆盖默认的 'anno' 按钮
|
|
142
144
|
label: '我的标注',
|
|
143
|
-
icon: myCustomIcon
|
|
145
|
+
icon: myCustomIcon // 使用自定义图标
|
|
144
146
|
// 保留原始的 dropdownContent 或定义新的
|
|
145
147
|
},
|
|
146
148
|
{
|
|
147
149
|
id: 'customTool', // 添加新的自定义按钮
|
|
148
150
|
label: '新工具',
|
|
149
151
|
onClick: (engine) => {
|
|
150
|
-
alert('自定义工具已点击!')
|
|
152
|
+
alert('自定义工具已点击!')
|
|
151
153
|
// 在此处实现自定义逻辑
|
|
152
154
|
}
|
|
153
155
|
}
|
|
154
|
-
]
|
|
156
|
+
]
|
|
155
157
|
|
|
156
158
|
const engine = new MedViewerEngine({
|
|
157
159
|
// ...
|
|
158
160
|
plugins: {
|
|
159
161
|
toolbar: {
|
|
160
|
-
buttons: customToolbarButtons
|
|
162
|
+
buttons: customToolbarButtons
|
|
161
163
|
// ... 其他工具栏选项
|
|
162
|
-
}
|
|
164
|
+
}
|
|
163
165
|
// ... 其他插件
|
|
164
166
|
}
|
|
165
|
-
})
|
|
167
|
+
})
|
|
166
168
|
```
|
|
167
169
|
|
|
168
170
|
### 在 Vue 项目中使用
|
|
@@ -191,12 +193,12 @@ yarn add med-viewer-sdk openseadragon vue
|
|
|
191
193
|
</template>
|
|
192
194
|
|
|
193
195
|
<script setup lang="ts">
|
|
194
|
-
import { ref, onMounted, onBeforeUnmount } from 'vue'
|
|
195
|
-
import { MedViewerEngine } from 'med-viewer-sdk'
|
|
196
|
-
import OpenSeadragon from 'openseadragon'
|
|
196
|
+
import { ref, onMounted, onBeforeUnmount } from 'vue'
|
|
197
|
+
import { MedViewerEngine } from 'med-viewer-sdk'
|
|
198
|
+
import OpenSeadragon from 'openseadragon' // 如果需要 OpenSeadragon 类型
|
|
197
199
|
|
|
198
|
-
const viewerContainer = ref<HTMLElement | null>(null)
|
|
199
|
-
let medViewer: MedViewerEngine | null = null
|
|
200
|
+
const viewerContainer = ref<HTMLElement | null>(null)
|
|
201
|
+
let medViewer: MedViewerEngine | null = null
|
|
200
202
|
|
|
201
203
|
onMounted(() => {
|
|
202
204
|
if (viewerContainer.value) {
|
|
@@ -208,7 +210,7 @@ onMounted(() => {
|
|
|
208
210
|
tileSources: {
|
|
209
211
|
type: 'image',
|
|
210
212
|
url: 'https://openseadragon.github.io/example-images/duomo/duomo.dzi'
|
|
211
|
-
}
|
|
213
|
+
}
|
|
212
214
|
},
|
|
213
215
|
plugins: {
|
|
214
216
|
toolbar: true,
|
|
@@ -218,7 +220,7 @@ onMounted(() => {
|
|
|
218
220
|
location: 'BOTTOM_LEFT',
|
|
219
221
|
color: 'rgb(255, 255, 255)',
|
|
220
222
|
fontColor: 'rgb(255, 255, 255)',
|
|
221
|
-
backgroundColor: 'rgba(0, 0, 0, 0.5)'
|
|
223
|
+
backgroundColor: 'rgba(0, 0, 0, 0.5)'
|
|
222
224
|
},
|
|
223
225
|
anno: true,
|
|
224
226
|
konva: true,
|
|
@@ -226,26 +228,26 @@ onMounted(() => {
|
|
|
226
228
|
initial: {
|
|
227
229
|
brightness: 1.2,
|
|
228
230
|
contrast: 0.8,
|
|
229
|
-
invert: true
|
|
231
|
+
invert: true
|
|
230
232
|
}
|
|
231
233
|
}
|
|
232
234
|
}
|
|
233
|
-
})
|
|
235
|
+
})
|
|
234
236
|
|
|
235
237
|
// 可以访问插件并进行操作
|
|
236
238
|
if (medViewer.selection) {
|
|
237
|
-
medViewer.selection.enable()
|
|
238
|
-
medViewer.selection.setSelectionMode('RECTANGLE')
|
|
239
|
+
medViewer.selection.enable()
|
|
240
|
+
medViewer.selection.setSelectionMode('RECTANGLE')
|
|
239
241
|
}
|
|
240
242
|
}
|
|
241
|
-
})
|
|
243
|
+
})
|
|
242
244
|
|
|
243
245
|
onBeforeUnmount(() => {
|
|
244
246
|
if (medViewer) {
|
|
245
|
-
medViewer.destroy()
|
|
246
|
-
medViewer = null
|
|
247
|
+
medViewer.destroy()
|
|
248
|
+
medViewer = null
|
|
247
249
|
}
|
|
248
|
-
})
|
|
250
|
+
})
|
|
249
251
|
</script>
|
|
250
252
|
|
|
251
253
|
<style scoped>
|
|
@@ -265,15 +267,15 @@ onBeforeUnmount(() => {
|
|
|
265
267
|
</template>
|
|
266
268
|
|
|
267
269
|
<script lang="ts">
|
|
268
|
-
import Vue from 'vue'
|
|
269
|
-
import { MedViewerEngine } from 'med-viewer-sdk'
|
|
270
|
-
import OpenSeadragon from 'openseadragon'
|
|
270
|
+
import Vue from 'vue'
|
|
271
|
+
import { MedViewerEngine } from 'med-viewer-sdk'
|
|
272
|
+
import OpenSeadragon from 'openseadragon' // 如果需要 OpenSeadragon 类型
|
|
271
273
|
|
|
272
274
|
export default Vue.extend({
|
|
273
275
|
data() {
|
|
274
276
|
return {
|
|
275
|
-
medViewer: null as MedViewerEngine | null
|
|
276
|
-
}
|
|
277
|
+
medViewer: null as MedViewerEngine | null
|
|
278
|
+
}
|
|
277
279
|
},
|
|
278
280
|
mounted() {
|
|
279
281
|
if (this.$refs.viewerContainer) {
|
|
@@ -285,7 +287,7 @@ export default Vue.extend({
|
|
|
285
287
|
tileSources: {
|
|
286
288
|
type: 'image',
|
|
287
289
|
url: 'https://openseadragon.github.io/example-images/duomo/duomo.dzi'
|
|
288
|
-
}
|
|
290
|
+
}
|
|
289
291
|
},
|
|
290
292
|
plugins: {
|
|
291
293
|
toolbar: true,
|
|
@@ -295,7 +297,7 @@ export default Vue.extend({
|
|
|
295
297
|
location: 'BOTTOM_LEFT',
|
|
296
298
|
color: 'rgb(255, 255, 255)',
|
|
297
299
|
fontColor: 'rgb(255, 255, 255)',
|
|
298
|
-
backgroundColor: 'rgba(0, 0, 0, 0.5)'
|
|
300
|
+
backgroundColor: 'rgba(0, 0, 0, 0.5)'
|
|
299
301
|
},
|
|
300
302
|
anno: true,
|
|
301
303
|
konva: true,
|
|
@@ -303,25 +305,26 @@ export default Vue.extend({
|
|
|
303
305
|
initial: {
|
|
304
306
|
brightness: 1.2,
|
|
305
307
|
contrast: 0.8,
|
|
306
|
-
invert: true
|
|
308
|
+
invert: true
|
|
307
309
|
}
|
|
308
310
|
}
|
|
309
311
|
}
|
|
310
|
-
})
|
|
312
|
+
})
|
|
311
313
|
|
|
312
314
|
if (this.medViewer.selection) {
|
|
313
|
-
this.medViewer.selection.enable()
|
|
314
|
-
this.medViewer.selection.setSelectionMode('RECTANGLE')
|
|
315
|
+
this.medViewer.selection.enable()
|
|
316
|
+
this.medViewer.selection.setSelectionMode('RECTANGLE')
|
|
315
317
|
}
|
|
316
318
|
}
|
|
317
319
|
},
|
|
318
|
-
beforeDestroy() {
|
|
320
|
+
beforeDestroy() {
|
|
321
|
+
// Vue 2 使用 beforeDestroy
|
|
319
322
|
if (this.medViewer) {
|
|
320
|
-
this.medViewer.destroy()
|
|
321
|
-
this.medViewer = null
|
|
323
|
+
this.medViewer.destroy()
|
|
324
|
+
this.medViewer = null
|
|
322
325
|
}
|
|
323
|
-
}
|
|
324
|
-
})
|
|
326
|
+
}
|
|
327
|
+
})
|
|
325
328
|
</script>
|
|
326
329
|
|
|
327
330
|
<style scoped>
|
|
@@ -335,10 +338,9 @@ export default Vue.extend({
|
|
|
335
338
|
|
|
336
339
|
#### 3. 注意事项
|
|
337
340
|
|
|
338
|
-
-
|
|
339
|
-
-
|
|
340
|
-
-
|
|
341
|
-
|
|
341
|
+
- **CSS 导入**:如果 `med-viewer-sdk` 包含任何 CSS 样式,您可能需要在您的 Vue 项目的入口文件或相关组件中导入它。例如:`import 'med-viewer-sdk/dist/style.css';`
|
|
342
|
+
- **全局样式**:确保 `med-viewer-sdk` 的容器元素有足够的宽高,以便查看器能够正确渲染。
|
|
343
|
+
- **响应式数据**:`MedViewerEngine` 实例本身不是响应式的。如果您需要其内部状态在 Vue 中响应式,您可能需要手动将其属性或方法包装在 Vue 的响应式系统中。
|
|
342
344
|
|
|
343
345
|
## 引用方式
|
|
344
346
|
|
|
@@ -348,67 +350,67 @@ export default Vue.extend({
|
|
|
348
350
|
|
|
349
351
|
如果您在本地同时开发 `med-viewer-sdk` 和另一个项目,`npm link` 是一个便捷的选择。
|
|
350
352
|
|
|
351
|
-
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
353
|
+
- **在 `med-viewer-sdk` 项目目录中执行:**
|
|
354
|
+
```bash
|
|
355
|
+
npm link
|
|
356
|
+
```
|
|
357
|
+
- **在您的其他项目目录中执行:**
|
|
358
|
+
```bash
|
|
359
|
+
npm link med-viewer-sdk
|
|
360
|
+
```
|
|
361
|
+
现在,您就可以像从 npm 安装一样导入 `med-viewer-sdk` 了。
|
|
360
362
|
|
|
361
363
|
### 2. 从本地路径安装
|
|
362
364
|
|
|
363
365
|
您可以直接从文件系统的本地路径安装打包后的 SDK。
|
|
364
366
|
|
|
365
|
-
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
-
|
|
367
|
+
- **在您的其他项目的 `package.json` 中添加:**
|
|
368
|
+
```json
|
|
369
|
+
"dependencies": {
|
|
370
|
+
"med-viewer-sdk": "file:../path/to/your/med-viewer-sdk", // 根据实际路径调整
|
|
371
|
+
// ... 其他依赖
|
|
372
|
+
}
|
|
373
|
+
```
|
|
374
|
+
- **然后在您的其他项目目录中运行 `npm install`。**
|
|
373
375
|
|
|
374
376
|
### 3. 发布到包注册表 (例如 npm)
|
|
375
377
|
|
|
376
378
|
如果这是一个可重用的库,您通常会将其发布到包注册表。
|
|
377
379
|
|
|
378
|
-
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
380
|
+
- **确保您的 `package.json` 已准备好发布:**
|
|
381
|
+
- `name`、`version`、`main`、`module`、`types`、`files` 字段应正确配置。
|
|
382
|
+
- `files` 数组应包含 `dist` 目录和任何其他必要文件。
|
|
383
|
+
- **登录 npm (如果尚未登录):**
|
|
384
|
+
```bash
|
|
385
|
+
npm login
|
|
386
|
+
```
|
|
387
|
+
- **发布:**
|
|
388
|
+
```bash
|
|
389
|
+
npm publish --access public // 如果是私有包,则无需 --access public
|
|
390
|
+
```
|
|
389
391
|
|
|
390
392
|
### 4. 在您的代码中导入
|
|
391
393
|
|
|
392
394
|
安装/链接后,您可以在应用程序中导入它:
|
|
393
395
|
|
|
394
|
-
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
396
|
+
- **对于 ES 模块 (推荐用于现代 JS/TS 项目):**
|
|
397
|
+
```typescript
|
|
398
|
+
import { MedViewerEngine } from 'med-viewer-sdk'
|
|
399
|
+
// 或者如果您在脚本标签中需要全局名称:
|
|
400
|
+
// const MedViewerSDK = window.MedViewerSDK;
|
|
401
|
+
```
|
|
402
|
+
- **对于 CommonJS (如果使用 Node.js 或旧版打包工具):**
|
|
403
|
+
```javascript
|
|
404
|
+
const { MedViewerEngine } = require('med-viewer-sdk')
|
|
405
|
+
```
|
|
406
|
+
- **直接在 HTML 中 (UMD 构建):**
|
|
407
|
+
```html
|
|
408
|
+
<script src="path/to/your/node_modules/med-viewer-sdk/dist/med-viewer-sdk.umd.js"></script>
|
|
409
|
+
<script>
|
|
410
|
+
const MedViewerSDK = window.MedViewerSDK
|
|
411
|
+
// 使用 MedViewerSDK.MedViewerEngine 等
|
|
412
|
+
</script>
|
|
413
|
+
```
|
|
412
414
|
|
|
413
415
|
## API 参考
|
|
414
416
|
|
package/dist/core/Engine.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { AnnoAnnotator } from
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { Locale } from
|
|
1
|
+
import type OpenSeadragonType from 'openseadragon';
|
|
2
|
+
import OpenSeadragon from 'openseadragon';
|
|
3
|
+
import { AnnoAnnotator } from './AnnoAnnotator';
|
|
4
|
+
import { ColorAdjustPlugin, type ColorAdjustOptions } from './ColorAdjustPlugin';
|
|
5
|
+
import { MagnificationPlugin, type MagnificationOptions } from './Magnification';
|
|
6
|
+
import { ScalebarPlugin, type ScalebarOptions } from './Scalebar';
|
|
7
|
+
import { SelectionPlugin, type SelectionOptions } from './SelectionPlugin';
|
|
8
|
+
import { MedToolbar, type ToolbarOptions } from './Toolbar';
|
|
9
|
+
import { Locale } from '../i18n/i18n';
|
|
10
10
|
/**
|
|
11
11
|
* 引擎配置接口
|
|
12
12
|
*/
|
|
@@ -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;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import OpenSeadragon from
|
|
2
|
-
import
|
|
1
|
+
import OpenSeadragon from 'openseadragon';
|
|
2
|
+
import '../plugins/openseadragon-selection.js';
|
|
3
3
|
export interface SelectionOptions {
|
|
4
4
|
element?: HTMLElement | null;
|
|
5
5
|
showSelectionControl?: boolean;
|
package/dist/med-viewer-sdk.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
export {
|
|
1
|
+
import { AnnoAnnotator } from './core/AnnoAnnotator';
|
|
2
|
+
import { ColorAdjustPlugin, type ColorAdjustOptions } from './core/ColorAdjustPlugin';
|
|
3
|
+
import { MedViewerEngine, type MedEngineOptions } from './core/Engine';
|
|
4
|
+
import { MagnificationPlugin, MagnificationPosition, MagnificationType, type MagnificationOptions } from './core/Magnification';
|
|
5
|
+
import { ScalebarLocation, ScalebarType, type ScalebarOptions } from './core/Scalebar';
|
|
6
|
+
import { SelectionPlugin, type SelectionOptions } from './core/SelectionPlugin';
|
|
7
|
+
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 };
|