Skip to content

Commit 588d82a

Browse files
committed
Update to Openlayers 6
1 parent 48c2a19 commit 588d82a

File tree

4 files changed

+56
-58
lines changed

4 files changed

+56
-58
lines changed

package-lock.json

Lines changed: 26 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dicom-microscopy-viewer",
3-
"version": "0.8.1",
3+
"version": "0.9.0",
44
"description": "Interactive web-based viewer for DICOM Microscopy Images",
55
"main": "build/dicom-microscopy-viewer.js",
66
"scripts": {
@@ -40,6 +40,6 @@
4040
},
4141
"dependencies": {
4242
"dicomweb-client": "^0.5.2",
43-
"ol": "^5.3.3"
43+
"ol": "^6.2.1"
4444
}
4545
}

rollup.config.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,15 @@ export default {
2222
main: true,
2323
browser: true,
2424
}),
25-
]
25+
],
26+
onwarn: function(warning, superOnWarn) {
27+
/*
28+
* skip certain warnings
29+
* https://github.com/openlayers/openlayers/issues/10245
30+
*/
31+
if (warning.code === 'THIS_IS_UNDEFINED') {
32+
return;
33+
}
34+
superOnWarn(warning);
35+
}
2636
};

src/api.js

Lines changed: 17 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import WebGLMap from 'ol/WebGLMap';
21
import Map from 'ol/Map';
32
import View from 'ol/View';
43
import TileLayer from 'ol/layer/Tile';
@@ -360,16 +359,14 @@ class VLWholeSlideMicroscopyImageViewer {
360359
const totalSizes = [];
361360
const resolutions = [];
362361
const origins = [];
363-
const offset = [0, -1];
362+
const offset = [0, 0];
364363
const basePixelSpacing = _getPixelSpacing(this[_pyramidBaseMetadata]);
365364
const baseColumns = this[_pyramidBaseMetadata].Columns;
366365
const baseRows = this[_pyramidBaseMetadata].Rows;
367366
const baseTotalPixelMatrixColumns = this[_pyramidBaseMetadata].TotalPixelMatrixColumns;
368367
const baseTotalPixelMatrixRows = this[_pyramidBaseMetadata].TotalPixelMatrixRows;
369368
const baseColFactor = Math.ceil(baseTotalPixelMatrixColumns / baseColumns);
370369
const baseRowFactor = Math.ceil(baseTotalPixelMatrixRows / baseRows);
371-
const baseAdjustedTotalPixelMatrixColumns = baseColumns * baseColFactor;
372-
const baseAdjustedTotalPixelMatrixRows = baseRows * baseRowFactor;
373370
for (let j = (nLevels - 1); j >= 0; j--) {
374371
const columns = this[_pyramidMetadata][j].Columns;
375372
const rows = this[_pyramidMetadata][j].Rows;
@@ -378,15 +375,13 @@ class VLWholeSlideMicroscopyImageViewer {
378375
const pixelSpacing = _getPixelSpacing(this[_pyramidMetadata][j]);
379376
const colFactor = Math.ceil(totalPixelMatrixColumns / columns);
380377
const rowFactor = Math.ceil(totalPixelMatrixRows / rows);
381-
const adjustedTotalPixelMatrixColumns = columns * colFactor;
382-
const adjustedTotalPixelMatrixRows = rows * rowFactor;
383378
tileSizes.push([
384379
columns,
385380
rows
386381
]);
387382
totalSizes.push([
388-
adjustedTotalPixelMatrixColumns,
389-
adjustedTotalPixelMatrixRows
383+
totalPixelMatrixColumns,
384+
totalPixelMatrixRows
390385
]);
391386

392387
/*
@@ -404,7 +399,8 @@ class VLWholeSlideMicroscopyImageViewer {
404399
origins.push(offset);
405400
}
406401
resolutions.reverse();
407-
tileSizes.reverse();
402+
tileSizes.reverse(); // FIXME
403+
totalSizes.reverse(); // FIXME
408404
origins.reverse();
409405

410406
// Functions won't be able to access "this"
@@ -427,12 +423,7 @@ class VLWholeSlideMicroscopyImageViewer {
427423
*/
428424
let z = tileCoord[0];
429425
let y = tileCoord[1] + 1;
430-
/*
431-
* The vertical axis is inverted for the chosen tile source, i.e.
432-
* it starts at -1 at the top left corner and descreases along the
433-
* vertical axis to the lower left corner of the viewport.
434-
*/
435-
let x = -(tileCoord[2] + 1) + 1;
426+
let x = tileCoord[2] + 1;
436427
let index = x + "-" + y;
437428
let path = pyramidFrameMappings[z][index];
438429
if (path === undefined) {
@@ -662,6 +653,7 @@ class VLWholeSlideMicroscopyImageViewer {
662653
if (options.controls.has('overview')) {
663654
this[_controls].overview = new OverviewMap({
664655
view: overviewView,
656+
layers: [imageLayer, this[_drawingLayer]],
665657
collapsed: true,
666658
});
667659
}
@@ -670,26 +662,14 @@ class VLWholeSlideMicroscopyImageViewer {
670662
* Creates the map with the defined layers and view and renders it via
671663
* WebGL.
672664
*/
673-
if (this[_usewebgl]) {
674-
this[_map] = new WebGLMap({
675-
layers: [imageLayer, this[_drawingLayer]],
676-
view: view,
677-
controls: [],
678-
loadTilesWhileAnimating: true,
679-
loadTilesWhileInteracting: true,
680-
logo: false
681-
});
682-
} else {
683-
684-
this[_map] = new Map({
685-
layers: [imageLayer, this[_drawingLayer]],
686-
view: view,
687-
controls: [],
688-
loadTilesWhileAnimating: true,
689-
loadTilesWhileInteracting: true,
690-
logo: false
691-
});
692-
}
665+
this[_map] = new Map({
666+
layers: [imageLayer, this[_drawingLayer]],
667+
view: view,
668+
controls: [],
669+
loadTilesWhileAnimating: true,
670+
loadTilesWhileInteracting: true,
671+
logo: false
672+
});
693673

694674
for (let control in this[_controls]) {
695675
this[_map].addControl(this[_controls][control]);
@@ -701,7 +681,7 @@ class VLWholeSlideMicroscopyImageViewer {
701681
resize(){
702682
this[_map].updateSize();
703683
}
704-
684+
705685

706686
/* Renders the images.
707687
*/
@@ -710,6 +690,7 @@ class VLWholeSlideMicroscopyImageViewer {
710690
console.error('container must be provided for rendering images')
711691
}
712692
this[_map].setTarget(options.container);
693+
this[_map].updateSize();
713694

714695
// Style scale element (overriding default Openlayers CSS "ol-scale-line")
715696
let scaleElement = this[_controls]['scale'].element;

0 commit comments

Comments
 (0)