Merge pull request #2120 from claycoleman/allow-silencing-multi-image-warnings

Allow silencing multi-image warnings
This commit is contained in:
Ian Gilman 2022-03-04 14:13:51 -08:00 committed by GitHub
commit d175de1496
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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. * 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. * 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] * @property {Number} [blendTime=0]
* Specifies the duration of animation as higher or lower level tiles are * Specifies the duration of animation as higher or lower level tiles are
* replacing the existing tile. * replacing the existing tile.
@ -1370,7 +1374,9 @@ function OpenSeadragon( options ){
//DEVELOPER SETTINGS //DEVELOPER SETTINGS
debugMode: false, 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, flipped: this.flipped,
navigatorRotate: this.navigatorRotate, navigatorRotate: this.navigatorRotate,
homeFillsViewer: this.homeFillsViewer, homeFillsViewer: this.homeFillsViewer,
margins: this.viewportMargins margins: this.viewportMargins,
silenceMultiImageWarnings: this.silenceMultiImageWarnings
}); });
this.viewport._setContentBounds(this.world.getHomeBounds(), this.world.getContentFactor()); 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.maxZoomLevel] - See maxZoomLevel in {@link OpenSeadragon.Options}.
* @param {Number} [options.degrees] - See degrees 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.homeFillsViewer] - See homeFillsViewer in {@link OpenSeadragon.Options}.
* @param {Boolean} [options.silenceMultiImageWarnings] - See silenceMultiImageWarnings in {@link OpenSeadragon.Options}.
*/ */
$.Viewport = function( options ) { $.Viewport = function( options ) {
@ -108,7 +109,8 @@ $.Viewport = function( options ) {
maxZoomLevel: $.DEFAULT_SETTINGS.maxZoomLevel, maxZoomLevel: $.DEFAULT_SETTINGS.maxZoomLevel,
degrees: $.DEFAULT_SETTINGS.degrees, degrees: $.DEFAULT_SETTINGS.degrees,
flipped: $.DEFAULT_SETTINGS.flipped, flipped: $.DEFAULT_SETTINGS.flipped,
homeFillsViewer: $.DEFAULT_SETTINGS.homeFillsViewer homeFillsViewer: $.DEFAULT_SETTINGS.homeFillsViewer,
silenceMultiImageWarnings: $.DEFAULT_SETTINGS.silenceMultiImageWarnings
}, options ); }, options );
@ -1170,8 +1172,10 @@ $.Viewport.prototype = {
if (this.viewer) { if (this.viewer) {
var count = this.viewer.world.getItemCount(); var count = this.viewer.world.getItemCount();
if (count > 1) { if (count > 1) {
if (!this.silenceMultiImageWarnings) {
$.console.error('[Viewport.viewportToImageCoordinates] is not accurate ' + $.console.error('[Viewport.viewportToImageCoordinates] is not accurate ' +
'with multi-image; use TiledImage.viewportToImageCoordinates instead.'); 'with multi-image; use TiledImage.viewportToImageCoordinates instead.');
}
} else if (count === 1) { } else if (count === 1) {
// It is better to use TiledImage.viewportToImageCoordinates // It is better to use TiledImage.viewportToImageCoordinates
// because this._contentBoundsNoRotate can not be relied on // because this._contentBoundsNoRotate can not be relied on
@ -1214,8 +1218,10 @@ $.Viewport.prototype = {
if (this.viewer) { if (this.viewer) {
var count = this.viewer.world.getItemCount(); var count = this.viewer.world.getItemCount();
if (count > 1) { if (count > 1) {
if (!this.silenceMultiImageWarnings) {
$.console.error('[Viewport.imageToViewportCoordinates] is not accurate ' + $.console.error('[Viewport.imageToViewportCoordinates] is not accurate ' +
'with multi-image; use TiledImage.imageToViewportCoordinates instead.'); 'with multi-image; use TiledImage.imageToViewportCoordinates instead.');
}
} else if (count === 1) { } else if (count === 1) {
// It is better to use TiledImage.viewportToImageCoordinates // It is better to use TiledImage.viewportToImageCoordinates
// because this._contentBoundsNoRotate can not be relied on // because this._contentBoundsNoRotate can not be relied on
@ -1256,8 +1262,10 @@ $.Viewport.prototype = {
if (this.viewer) { if (this.viewer) {
var count = this.viewer.world.getItemCount(); var count = this.viewer.world.getItemCount();
if (count > 1) { if (count > 1) {
if (!this.silenceMultiImageWarnings) {
$.console.error('[Viewport.imageToViewportRectangle] is not accurate ' + $.console.error('[Viewport.imageToViewportRectangle] is not accurate ' +
'with multi-image; use TiledImage.imageToViewportRectangle instead.'); 'with multi-image; use TiledImage.imageToViewportRectangle instead.');
}
} else if (count === 1) { } else if (count === 1) {
// It is better to use TiledImage.imageToViewportRectangle // It is better to use TiledImage.imageToViewportRectangle
// because this._contentBoundsNoRotate can not be relied on // because this._contentBoundsNoRotate can not be relied on
@ -1304,8 +1312,10 @@ $.Viewport.prototype = {
if (this.viewer) { if (this.viewer) {
var count = this.viewer.world.getItemCount(); var count = this.viewer.world.getItemCount();
if (count > 1) { if (count > 1) {
if (!this.silenceMultiImageWarnings) {
$.console.error('[Viewport.viewportToImageRectangle] is not accurate ' + $.console.error('[Viewport.viewportToImageRectangle] is not accurate ' +
'with multi-image; use TiledImage.viewportToImageRectangle instead.'); 'with multi-image; use TiledImage.viewportToImageRectangle instead.');
}
} else if (count === 1) { } else if (count === 1) {
// It is better to use TiledImage.viewportToImageCoordinates // It is better to use TiledImage.viewportToImageCoordinates
// because this._contentBoundsNoRotate can not be relied on // because this._contentBoundsNoRotate can not be relied on
@ -1469,8 +1479,10 @@ $.Viewport.prototype = {
if (this.viewer) { if (this.viewer) {
var count = this.viewer.world.getItemCount(); var count = this.viewer.world.getItemCount();
if (count > 1) { if (count > 1) {
if (!this.silenceMultiImageWarnings) {
$.console.error('[Viewport.viewportToImageZoom] is not ' + $.console.error('[Viewport.viewportToImageZoom] is not ' +
'accurate with multi-image.'); 'accurate with multi-image.');
}
} else if (count === 1) { } else if (count === 1) {
// It is better to use TiledImage.viewportToImageZoom // It is better to use TiledImage.viewportToImageZoom
// because this._contentBoundsNoRotate can not be relied on // because this._contentBoundsNoRotate can not be relied on
@ -1503,8 +1515,10 @@ $.Viewport.prototype = {
if (this.viewer) { if (this.viewer) {
var count = this.viewer.world.getItemCount(); var count = this.viewer.world.getItemCount();
if (count > 1) { if (count > 1) {
if (!this.silenceMultiImageWarnings) {
$.console.error('[Viewport.imageToViewportZoom] is not accurate ' + $.console.error('[Viewport.imageToViewportZoom] is not accurate ' +
'with multi-image.'); 'with multi-image.');
}
} else if (count === 1) { } else if (count === 1) {
// It is better to use TiledImage.imageToViewportZoom // It is better to use TiledImage.imageToViewportZoom
// because this._contentBoundsNoRotate can not be relied on // because this._contentBoundsNoRotate can not be relied on