Skip to content

Commit af9d042

Browse files
fix: Address regressions introduced by recent new features & refactoring (#202)
* Address frac seg issue, remove logs * Add fallback case for resolution * Add fallback case for resolution * Bump version
1 parent 6129842 commit af9d042

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dicom-microscopy-viewer",
3-
"version": "0.48.8",
3+
"version": "0.48.9",
44
"license": "MIT",
55
"author": "ImagingDataCommons",
66
"homepage": "https://github.com/imagingdatacommons/dicom-microscopy-viewer#readme",

src/viewer.js

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,7 @@ const _pointsSources = Symbol('pointsSources')
788788
const _clustersSources = Symbol('clustersSources')
789789
const _segmentationInterpolate = Symbol('segmentationInterpolate')
790790
const _segmentationTileGrid = Symbol('segmentationTileGrid')
791+
const _mapViewResolutions = Symbol('mapViewResolutions')
791792

792793
/**
793794
* Interactive viewer for DICOM VL Whole Slide Microscopy Image instances
@@ -847,7 +848,7 @@ class VolumeImageViewer {
847848
this[_highResSources] = {}
848849
this[_pointsSources] = {}
849850
this[_clustersSources] = {}
850-
this[_segmentationInterpolate] = false
851+
this[_segmentationInterpolate] = true
851852

852853
this._onBulkAnnotationsFeaturesLoadStart = this._onBulkAnnotationsFeaturesLoadStart.bind(this)
853854
this._onBulkAnnotationsFeaturesLoadEnd = this._onBulkAnnotationsFeaturesLoadEnd.bind(this)
@@ -1171,7 +1172,7 @@ class VolumeImageViewer {
11711172
tileSizes: this[_pyramid].tileSizes
11721173
})
11731174

1174-
let mapViewResolutions =
1175+
this[_mapViewResolutions] =
11751176
this[_options].useTileGridResolutions === false ||
11761177
this[_options].skipThumbnails === true
11771178
? undefined
@@ -1184,19 +1185,19 @@ class VolumeImageViewer {
11841185
* not what we want for a thumbnail image.
11851186
*/
11861187
if (!this[_metadata].find((image) => image.ImageType[2] === ImageFlavors.THUMBNAIL) && this[_metadata].length > 1) {
1187-
mapViewResolutions = undefined
1188+
this[_mapViewResolutions] = undefined
11881189
}
11891190

11901191
if (has(this[_options], 'mapViewResolutions')) {
1191-
mapViewResolutions = this[_options].mapViewResolutions
1192+
this[_mapViewResolutions] = this[_options].mapViewResolutions
11921193
}
11931194

11941195
const view = new View({
11951196
center: getCenter(this[_pyramid].extent),
11961197
projection: this[_projection],
11971198
rotation: this[_rotation],
11981199
constrainOnlyCenter: false,
1199-
resolutions: mapViewResolutions,
1200+
resolutions: this[_mapViewResolutions],
12001201
smoothResolutionConstraint: true,
12011202
showFullExtent: true,
12021203
extent: this[_pyramid].extent
@@ -3350,7 +3351,6 @@ class VolumeImageViewer {
33503351
* @returns {roi.ROI[]} Array of regions of interest.
33513352
*/
33523353
getAllROIs () {
3353-
console.info('get all ROIs')
33543354
const rois = []
33553355
this[_features].forEach((item) => {
33563356
rois.push(this.getROI(item.getId()))
@@ -3386,7 +3386,6 @@ class VolumeImageViewer {
33863386
* @returns {roi.ROI} Region of interest.
33873387
*/
33883388
getROI (uid) {
3389-
console.info(`get ROI ${uid}`)
33903389
const feature = this[_drawingSource].getFeatureById(uid)
33913390
if (feature == null) {
33923391
console.warn(`Could not find a ROI with UID "${uid}".`)
@@ -3764,8 +3763,16 @@ class VolumeImageViewer {
37643763
const view = map.getView()
37653764
const maxZoom = view.getMaxZoom()
37663765
const isHighResolution = () => {
3767-
const zoom = view.getZoom()
3768-
return zoom >= (this[_annotationOptions].maxZoom || maxZoom)
3766+
const isZoomUnlimited = this[_mapViewResolutions] === undefined
3767+
const highestResolution = this[_tileGrid].getResolutions()[0]
3768+
const updatedMaxZoom = isZoomUnlimited ? highestResolution : (this[_annotationOptions].maxZoom || maxZoom)
3769+
const zoom = isZoomUnlimited ? (view.getZoom() * this[_tileGrid].getResolutions().length) : view.getZoom()
3770+
console.debug('Zoom:', zoom)
3771+
console.debug('Max Zoom:', updatedMaxZoom)
3772+
console.debug('Original Max Zoom:', maxZoom)
3773+
console.debug('Highest Resolution:', highestResolution)
3774+
console.debug('Resolutions:', this[_tileGrid].getResolutions().length)
3775+
return zoom >= updatedMaxZoom
37693776
}
37703777

37713778
/**
@@ -4795,10 +4802,6 @@ class VolumeImageViewer {
47954802
maxStoredValue
47964803
)
47974804

4798-
/** Store window center and width in segment style for later use */
4799-
segment.style.windowCenter = windowCenter
4800-
segment.style.windowWidth = windowWidth
4801-
48024805
segment.layer = new TileLayer({
48034806
source,
48044807
extent: this[_pyramid].extent,
@@ -5043,15 +5046,21 @@ class VolumeImageViewer {
50435046
}
50445047

50455048
const segment = this[_segments][segmentUID]
5046-
5047-
/** Update opacity if provided */
50485049
if (styleOptions.opacity != null) {
50495050
segment.style.opacity = styleOptions.opacity
50505051
segment.layer.setOpacity(styleOptions.opacity)
50515052
}
50525053

50535054
/** Update palette color lookup table if provided */
5054-
if (styleOptions.paletteColorLookupTable != null) {
5055+
if (styleOptions.paletteColorLookupTable != null && segment.segmentationType !== 'FRACTIONAL') {
5056+
/** Calculate window center and width from segment's limit values or use defaults */
5057+
const windowCenter = segment.style.windowCenter || 128
5058+
const windowWidth = segment.style.windowWidth || 256
5059+
5060+
/** Store window center and width in segment style for later use */
5061+
segment.style.windowCenter = windowCenter
5062+
segment.style.windowWidth = windowWidth
5063+
50555064
let paletteColorLookupTable = styleOptions.paletteColorLookupTable
50565065

50575066
/** If the palette is a plain object (not a PaletteColorLookupTable instance),
@@ -5077,8 +5086,6 @@ class VolumeImageViewer {
50775086
}
50785087

50795088
/** Update the layer style with the new palette */
5080-
const windowCenter = segment.style.windowCenter || 128
5081-
const windowWidth = segment.style.windowWidth || 256
50825089
const defaultSegmentStyle = segment.defaultStyle
50835090

50845091
const newStyle = _getColorPaletteStyleForTileLayer({

0 commit comments

Comments
 (0)