Allow silencing multi-image warnings

This commit is contained in:
Clay Coleman 2022-02-25 12:11:06 -06:00
parent 2b6c8dd622
commit 322a22cb68
3 changed files with 64 additions and 43 deletions

View File

@ -163,6 +163,10 @@
* The colors of grids in debug mode. Each tiled image's grid uses a consecutive color.
* If there are more tiled images than provided colors, the color vector is recycled.
*
* @property {Boolean} [silenceMultiImageWarnings=false]
* Silences warnings when calling viewport coordinate functions with multi-image.
* Useful when you're overlaying multiple images on top of one another.
*
* @property {Number} [blendTime=0]
* Specifies the duration of animation as higher or lower level tiles are
* replacing the existing tile.
@ -1370,7 +1374,9 @@ function OpenSeadragon( options ){
//DEVELOPER SETTINGS
debugMode: false,
debugGridColor: ['#437AB2', '#1B9E77', '#D95F02', '#7570B3', '#E7298A', '#66A61E', '#E6AB02', '#A6761D', '#666666']
debugGridColor: ['#437AB2', '#1B9E77', '#D95F02', '#7570B3', '#E7298A', '#66A61E', '#E6AB02', '#A6761D', '#666666'],
silenceMultiImageWarnings: false
},

View File

@ -382,7 +382,8 @@ $.Viewer = function( options ) {
flipped: this.flipped,
navigatorRotate: this.navigatorRotate,
homeFillsViewer: this.homeFillsViewer,
margins: this.viewportMargins
margins: this.viewportMargins,
silenceMultiImageWarnings: this.silenceMultiImageWarnings
});
this.viewport._setContentBounds(this.world.getHomeBounds(), this.world.getContentFactor());

View File

@ -54,6 +54,7 @@
* @param {Number} [options.maxZoomLevel] - See maxZoomLevel in {@link OpenSeadragon.Options}.
* @param {Number} [options.degrees] - See degrees in {@link OpenSeadragon.Options}.
* @param {Boolean} [options.homeFillsViewer] - See homeFillsViewer in {@link OpenSeadragon.Options}.
* @param {Boolean} [options.silenceMultiImageWarnings] - See silenceMultiImageWarnings in {@link OpenSeadragon.Options}.
*/
$.Viewport = function( options ) {
@ -108,7 +109,8 @@ $.Viewport = function( options ) {
maxZoomLevel: $.DEFAULT_SETTINGS.maxZoomLevel,
degrees: $.DEFAULT_SETTINGS.degrees,
flipped: $.DEFAULT_SETTINGS.flipped,
homeFillsViewer: $.DEFAULT_SETTINGS.homeFillsViewer
homeFillsViewer: $.DEFAULT_SETTINGS.homeFillsViewer,
silenceMultiImageWarnings: $.DEFAULT_SETTINGS.silenceMultiImageWarnings
}, options );
@ -1170,8 +1172,10 @@ $.Viewport.prototype = {
if (this.viewer) {
var count = this.viewer.world.getItemCount();
if (count > 1) {
if (!this.silenceMultiImageWarnings) {
$.console.error('[Viewport.viewportToImageCoordinates] is not accurate ' +
'with multi-image; use TiledImage.viewportToImageCoordinates instead.');
}
} else if (count === 1) {
// It is better to use TiledImage.viewportToImageCoordinates
// because this._contentBoundsNoRotate can not be relied on
@ -1214,8 +1218,10 @@ $.Viewport.prototype = {
if (this.viewer) {
var count = this.viewer.world.getItemCount();
if (count > 1) {
if (!this.silenceMultiImageWarnings) {
$.console.error('[Viewport.imageToViewportCoordinates] is not accurate ' +
'with multi-image; use TiledImage.imageToViewportCoordinates instead.');
}
} else if (count === 1) {
// It is better to use TiledImage.viewportToImageCoordinates
// because this._contentBoundsNoRotate can not be relied on
@ -1256,8 +1262,10 @@ $.Viewport.prototype = {
if (this.viewer) {
var count = this.viewer.world.getItemCount();
if (count > 1) {
if (!this.silenceMultiImageWarnings) {
$.console.error('[Viewport.imageToViewportRectangle] is not accurate ' +
'with multi-image; use TiledImage.imageToViewportRectangle instead.');
}
} else if (count === 1) {
// It is better to use TiledImage.imageToViewportRectangle
// because this._contentBoundsNoRotate can not be relied on
@ -1304,8 +1312,10 @@ $.Viewport.prototype = {
if (this.viewer) {
var count = this.viewer.world.getItemCount();
if (count > 1) {
if (!this.silenceMultiImageWarnings) {
$.console.error('[Viewport.viewportToImageRectangle] is not accurate ' +
'with multi-image; use TiledImage.viewportToImageRectangle instead.');
}
} else if (count === 1) {
// It is better to use TiledImage.viewportToImageCoordinates
// because this._contentBoundsNoRotate can not be relied on
@ -1469,8 +1479,10 @@ $.Viewport.prototype = {
if (this.viewer) {
var count = this.viewer.world.getItemCount();
if (count > 1) {
if (!this.silenceMultiImageWarnings) {
$.console.error('[Viewport.viewportToImageZoom] is not ' +
'accurate with multi-image.');
}
} else if (count === 1) {
// It is better to use TiledImage.viewportToImageZoom
// because this._contentBoundsNoRotate can not be relied on
@ -1503,8 +1515,10 @@ $.Viewport.prototype = {
if (this.viewer) {
var count = this.viewer.world.getItemCount();
if (count > 1) {
if (!this.silenceMultiImageWarnings) {
$.console.error('[Viewport.imageToViewportZoom] is not accurate ' +
'with multi-image.');
}
} else if (count === 1) {
// It is better to use TiledImage.imageToViewportZoom
// because this._contentBoundsNoRotate can not be relied on