dicom-microscopy-viewer 0.36.4 → 0.36.5
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/package.json
CHANGED
package/src/viewer.js
CHANGED
|
@@ -797,6 +797,7 @@ class VolumeImageViewer {
|
|
|
797
797
|
* @param {metadata.VLWholeSlideMicroscopyImage[]} options.metadata -
|
|
798
798
|
* Metadata of DICOM VL Whole Slide Microscopy Image instances that should be
|
|
799
799
|
* diplayed.
|
|
800
|
+
* @param {Object} options.preload - Whether data should be preloaded
|
|
800
801
|
* @param {string[]} [options.controls=[]] - Names of viewer control elements
|
|
801
802
|
* that should be included in the viewport
|
|
802
803
|
* @param {boolean} [options.debug=false] - Whether debug features should be
|
|
@@ -809,6 +810,14 @@ class VolumeImageViewer {
|
|
|
809
810
|
|
|
810
811
|
if (this[_options].debug == null) {
|
|
811
812
|
this[_options].debug = false
|
|
813
|
+
} else {
|
|
814
|
+
this[_options].debug = true
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
if (this[_options].preload == null) {
|
|
818
|
+
this[_options].preload = false
|
|
819
|
+
} else {
|
|
820
|
+
this[_options].preload = true
|
|
812
821
|
}
|
|
813
822
|
|
|
814
823
|
if (this[_options].tilesCacheSize == null) {
|
|
@@ -1145,7 +1154,7 @@ class VolumeImageViewer {
|
|
|
1145
1154
|
opticalPath.layer = new TileLayer({
|
|
1146
1155
|
source,
|
|
1147
1156
|
extent: pyramid.extent,
|
|
1148
|
-
preload: 1,
|
|
1157
|
+
preload: this[_options].preload ? 1 : 0,
|
|
1149
1158
|
style: style,
|
|
1150
1159
|
visible: false,
|
|
1151
1160
|
useInterimTilesOnError: false,
|
|
@@ -1227,7 +1236,6 @@ class VolumeImageViewer {
|
|
|
1227
1236
|
projection: this[_projection],
|
|
1228
1237
|
wrapX: false,
|
|
1229
1238
|
transition: 0,
|
|
1230
|
-
preload: 1,
|
|
1231
1239
|
bandCount: 3
|
|
1232
1240
|
})
|
|
1233
1241
|
source.on('tileloaderror', (event) => {
|
|
@@ -1248,7 +1256,7 @@ class VolumeImageViewer {
|
|
|
1248
1256
|
opticalPath.layer = new TileLayer({
|
|
1249
1257
|
source,
|
|
1250
1258
|
extent: this[_tileGrid].extent,
|
|
1251
|
-
preload: 1,
|
|
1259
|
+
preload: this[_options].preload ? 1 : 0,
|
|
1252
1260
|
useInterimTilesOnError: false,
|
|
1253
1261
|
cacheSize: this[_options].tilesCacheSize
|
|
1254
1262
|
})
|
|
@@ -1288,24 +1296,28 @@ class VolumeImageViewer {
|
|
|
1288
1296
|
layers.push(tileDebugLayer)
|
|
1289
1297
|
}
|
|
1290
1298
|
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1299
|
+
if (Math.max(...this[_pyramid].gridSizes[0]) <= 10) {
|
|
1300
|
+
const overviewView = new View({
|
|
1301
|
+
projection: this[_projection],
|
|
1302
|
+
rotation: this[_rotation],
|
|
1303
|
+
constrainOnlyCenter: false,
|
|
1304
|
+
smoothExtentConstraint: true,
|
|
1305
|
+
smoothResolutionConstraint: true,
|
|
1306
|
+
minZoom: 0,
|
|
1307
|
+
maxZoom: 0,
|
|
1308
|
+
extent: this[_pyramid].extent
|
|
1309
|
+
})
|
|
1301
1310
|
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1311
|
+
this[_overviewMap] = new OverviewMap({
|
|
1312
|
+
view: overviewView,
|
|
1313
|
+
layers: overviewLayers,
|
|
1314
|
+
collapsed: false,
|
|
1315
|
+
collapsible: true,
|
|
1316
|
+
rotateWithView: true
|
|
1317
|
+
})
|
|
1318
|
+
} else {
|
|
1319
|
+
this[_overviewMap] = null
|
|
1320
|
+
}
|
|
1309
1321
|
|
|
1310
1322
|
this[_drawingSource] = new VectorSource({
|
|
1311
1323
|
tileGrid: this[_tileGrid],
|
|
@@ -1376,7 +1388,9 @@ class VolumeImageViewer {
|
|
|
1376
1388
|
}
|
|
1377
1389
|
|
|
1378
1390
|
if (this[_options].controls.has('overview')) {
|
|
1379
|
-
|
|
1391
|
+
if (this[_overviewMap]) {
|
|
1392
|
+
this[_controls].overview = this[_overviewMap]
|
|
1393
|
+
}
|
|
1380
1394
|
}
|
|
1381
1395
|
|
|
1382
1396
|
for (const control in this[_controls]) {
|
|
@@ -1578,10 +1592,12 @@ class VolumeImageViewer {
|
|
|
1578
1592
|
0,
|
|
1579
1593
|
opticalPath.layer
|
|
1580
1594
|
)
|
|
1581
|
-
this[_overviewMap]
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1595
|
+
if (this[_overviewMap]) {
|
|
1596
|
+
this[_overviewMap].getOverviewMap().getLayers().insertAt(
|
|
1597
|
+
0,
|
|
1598
|
+
opticalPath.overviewTileLayer
|
|
1599
|
+
)
|
|
1600
|
+
}
|
|
1585
1601
|
}
|
|
1586
1602
|
|
|
1587
1603
|
/**
|
|
@@ -1601,9 +1617,11 @@ class VolumeImageViewer {
|
|
|
1601
1617
|
return
|
|
1602
1618
|
}
|
|
1603
1619
|
this[_map].removeLayer(opticalPath.layer)
|
|
1604
|
-
this[_overviewMap]
|
|
1605
|
-
|
|
1606
|
-
|
|
1620
|
+
if (this[_overviewMap]) {
|
|
1621
|
+
this[_overviewMap].getOverviewMap().removeLayer(
|
|
1622
|
+
opticalPath.overviewTileLayer
|
|
1623
|
+
)
|
|
1624
|
+
}
|
|
1607
1625
|
}
|
|
1608
1626
|
|
|
1609
1627
|
/**
|
|
@@ -1843,43 +1861,53 @@ class VolumeImageViewer {
|
|
|
1843
1861
|
scaleInnerElement.style.margin = '1px'
|
|
1844
1862
|
scaleInnerElement.style.willChange = 'contents,width'
|
|
1845
1863
|
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
let resizeFactor
|
|
1858
|
-
let targetWidth
|
|
1859
|
-
if (Math.abs(rotation - 180) < 0.01 || Math.abs(rotation - 0) < 0.01) {
|
|
1860
|
-
if (windowSize[1] > windowSize[0]) {
|
|
1861
|
-
targetHeight = Math.ceil(windowSize[1] * 0.2)
|
|
1862
|
-
resizeFactor = targetHeight / height
|
|
1863
|
-
targetWidth = width * resizeFactor
|
|
1864
|
-
} else {
|
|
1865
|
-
targetWidth = Math.ceil(windowSize[0] * 0.15)
|
|
1866
|
-
resizeFactor = targetWidth / width
|
|
1867
|
-
targetHeight = height * resizeFactor
|
|
1864
|
+
if (this[_overviewMap]) {
|
|
1865
|
+
const overviewElement = this[_overviewMap].element
|
|
1866
|
+
const overviewmapElement = Object.values(overviewElement.children).find(
|
|
1867
|
+
c => c.className === 'ol-overviewmap-map'
|
|
1868
|
+
)
|
|
1869
|
+
const buttonElement = Object.values(overviewElement.children).find(
|
|
1870
|
+
c => c.type === 'button'
|
|
1871
|
+
)
|
|
1872
|
+
if (buttonElement) {
|
|
1873
|
+
buttonElement.style.border = '0.25px solid black'
|
|
1874
|
+
buttonElement.style.backgroundColor = 'white'
|
|
1868
1875
|
}
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1876
|
+
overviewmapElement.style.border = '1px solid black'
|
|
1877
|
+
overviewmapElement.style.color = 'black'
|
|
1878
|
+
// Try to fit the overview map into the target control overlay container
|
|
1879
|
+
const height = Math.abs(this[_pyramid].extent[1])
|
|
1880
|
+
const width = Math.abs(this[_pyramid].extent[2])
|
|
1881
|
+
const rotation = this[_rotation] / Math.PI * 180
|
|
1882
|
+
const windowSize = _getWindowSize()
|
|
1883
|
+
let targetHeight
|
|
1884
|
+
let resizeFactor
|
|
1885
|
+
let targetWidth
|
|
1886
|
+
if (Math.abs(rotation - 180) < 0.01 || Math.abs(rotation - 0) < 0.01) {
|
|
1887
|
+
if (windowSize[1] > windowSize[0]) {
|
|
1888
|
+
targetHeight = Math.ceil(windowSize[1] * 0.2)
|
|
1889
|
+
resizeFactor = targetHeight / height
|
|
1890
|
+
targetWidth = width * resizeFactor
|
|
1891
|
+
} else {
|
|
1892
|
+
targetWidth = Math.ceil(windowSize[0] * 0.15)
|
|
1893
|
+
resizeFactor = targetWidth / width
|
|
1894
|
+
targetHeight = height * resizeFactor
|
|
1895
|
+
}
|
|
1874
1896
|
} else {
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1897
|
+
if (windowSize[1] > windowSize[0]) {
|
|
1898
|
+
targetHeight = Math.ceil(windowSize[1] * 0.2)
|
|
1899
|
+
resizeFactor = targetHeight / width
|
|
1900
|
+
targetWidth = height * resizeFactor
|
|
1901
|
+
} else {
|
|
1902
|
+
targetWidth = Math.ceil(windowSize[0] * 0.15)
|
|
1903
|
+
resizeFactor = targetWidth / height
|
|
1904
|
+
targetHeight = width * resizeFactor
|
|
1905
|
+
}
|
|
1878
1906
|
}
|
|
1907
|
+
overviewmapElement.style.width = `${targetWidth}px`
|
|
1908
|
+
overviewmapElement.style.height = `${targetHeight}px`
|
|
1909
|
+
this[_overviewMap].getOverviewMap().updateSize()
|
|
1879
1910
|
}
|
|
1880
|
-
overviewmapElement.style.width = `${targetWidth}px`
|
|
1881
|
-
overviewmapElement.style.height = `${targetHeight}px`
|
|
1882
|
-
this[_overviewMap].getOverviewMap().updateSize()
|
|
1883
1911
|
})
|
|
1884
1912
|
}
|
|
1885
1913
|
|
|
@@ -2128,17 +2156,19 @@ class VolumeImageViewer {
|
|
|
2128
2156
|
* @returns {void}
|
|
2129
2157
|
*/
|
|
2130
2158
|
toggleOverviewMap () {
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2159
|
+
if (this[_overviewMap]) {
|
|
2160
|
+
const controls = this[_map].getControls()
|
|
2161
|
+
const overview = controls.getArray().find((c) => c === this[_overviewMap])
|
|
2162
|
+
if (overview) {
|
|
2163
|
+
this[_map].removeControl(this[_overviewMap])
|
|
2164
|
+
return
|
|
2165
|
+
}
|
|
2166
|
+
this[_map].addControl(this[_overviewMap])
|
|
2167
|
+
const map = this[_overviewMap].getOverviewMap()
|
|
2168
|
+
const view = map.getView()
|
|
2169
|
+
const projection = view.getProjection()
|
|
2170
|
+
view.fit(projection.getExtent(), { size: map.getSize() })
|
|
2136
2171
|
}
|
|
2137
|
-
this[_map].addControl(this[_overviewMap])
|
|
2138
|
-
const map = this[_overviewMap].getOverviewMap()
|
|
2139
|
-
const view = map.getView()
|
|
2140
|
-
const projection = view.getProjection()
|
|
2141
|
-
view.fit(projection.getExtent(), { size: map.getSize() })
|
|
2142
2172
|
}
|
|
2143
2173
|
|
|
2144
2174
|
/**
|
|
@@ -2392,11 +2422,15 @@ class VolumeImageViewer {
|
|
|
2392
2422
|
}
|
|
2393
2423
|
|
|
2394
2424
|
collapseOverviewMap () {
|
|
2395
|
-
this[_overviewMap]
|
|
2425
|
+
if (this[_overviewMap]) {
|
|
2426
|
+
this[_overviewMap].setCollapsed(true)
|
|
2427
|
+
}
|
|
2396
2428
|
}
|
|
2397
2429
|
|
|
2398
2430
|
expandOverviewMap () {
|
|
2399
|
-
this[_overviewMap]
|
|
2431
|
+
if (this[_overviewMap]) {
|
|
2432
|
+
this[_overviewMap].setCollapsed(true)
|
|
2433
|
+
}
|
|
2400
2434
|
}
|
|
2401
2435
|
|
|
2402
2436
|
/**
|
|
@@ -2830,7 +2864,7 @@ class VolumeImageViewer {
|
|
|
2830
2864
|
const container = this[_map].getTargetElement()
|
|
2831
2865
|
publish(container, EVENT.LOADING_ENDED)
|
|
2832
2866
|
})
|
|
2833
|
-
source.on('
|
|
2867
|
+
source.on('featuresloaderror', (event) => {
|
|
2834
2868
|
const container = this[_map].getTargetElement()
|
|
2835
2869
|
publish(container, EVENT.LOADING_ENDED)
|
|
2836
2870
|
})
|
|
@@ -3352,7 +3386,7 @@ class VolumeImageViewer {
|
|
|
3352
3386
|
extent: this[_pyramid].extent,
|
|
3353
3387
|
visible: false,
|
|
3354
3388
|
opacity: 0.9,
|
|
3355
|
-
preload: 0,
|
|
3389
|
+
preload: this[_options].preload ? 1 : 0,
|
|
3356
3390
|
transition: 0,
|
|
3357
3391
|
style: _getColorPaletteStyleForTileLayer({
|
|
3358
3392
|
windowCenter,
|
|
@@ -3783,7 +3817,7 @@ class VolumeImageViewer {
|
|
|
3783
3817
|
projection: this[_projection],
|
|
3784
3818
|
visible: false,
|
|
3785
3819
|
opacity: 1,
|
|
3786
|
-
preload: 1,
|
|
3820
|
+
preload: this[_options].preload ? 1 : 0,
|
|
3787
3821
|
transition: 0,
|
|
3788
3822
|
style: _getColorPaletteStyleForTileLayer({
|
|
3789
3823
|
windowCenter,
|