2014-08-07 00:38:56 +04:00
|
|
|
/*
|
2014-08-07 00:48:18 +04:00
|
|
|
* OpenSeadragon - TiledImage
|
2014-08-07 00:38:56 +04:00
|
|
|
*
|
|
|
|
* Copyright (C) 2009 CodePlex Foundation
|
|
|
|
* Copyright (C) 2010-2013 OpenSeadragon contributors
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are
|
|
|
|
* met:
|
|
|
|
*
|
|
|
|
* - Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* - Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* - Neither the name of CodePlex Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived from
|
|
|
|
* this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
|
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
|
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
(function( $ ){
|
|
|
|
|
|
|
|
/**
|
2014-11-06 01:48:37 +03:00
|
|
|
* You shouldn't have to create a TiledImage directly; use {@link OpenSeadragon.Viewer#open}
|
|
|
|
* or {@link OpenSeadragon.Viewer#addTiledImage} instead.
|
2014-08-07 00:48:18 +04:00
|
|
|
* @class TiledImage
|
2014-11-04 22:53:39 +03:00
|
|
|
* @memberof OpenSeadragon
|
2014-11-12 04:14:48 +03:00
|
|
|
* @extends OpenSeadragon.EventSource
|
2014-08-07 00:38:56 +04:00
|
|
|
* @classdesc Handles rendering of tiles for an {@link OpenSeadragon.Viewer}.
|
2014-08-07 00:48:18 +04:00
|
|
|
* A new instance is created for each TileSource opened.
|
2014-11-04 22:53:39 +03:00
|
|
|
* @param {Object} options - Configuration for this TiledImage.
|
|
|
|
* @param {OpenSeadragon.TileSource} options.source - The TileSource that defines this TiledImage.
|
|
|
|
* @param {OpenSeadragon.Viewer} options.viewer - The Viewer that owns this TiledImage.
|
|
|
|
* @param {OpenSeadragon.TileCache} options.tileCache - The TileCache for this TiledImage to use.
|
|
|
|
* @param {OpenSeadragon.Drawer} options.drawer - The Drawer for this TiledImage to draw onto.
|
|
|
|
* @param {OpenSeadragon.ImageLoader} options.imageLoader - The ImageLoader for this TiledImage to use.
|
2014-11-24 22:59:06 +03:00
|
|
|
* @param {Number} [options.x=0] - Left position, in viewport coordinates.
|
|
|
|
* @param {Number} [options.y=0] - Top position, in viewport coordinates.
|
|
|
|
* @param {Number} [options.width=1] - Width, in viewport coordinates.
|
|
|
|
* @param {Number} [options.height] - Height, in viewport coordinates.
|
2016-03-22 23:41:28 +03:00
|
|
|
* @param {OpenSeadragon.Rect} [options.fitBounds] The bounds in viewport coordinates
|
|
|
|
* to fit the image into. If specified, x, y, width and height get ignored.
|
|
|
|
* @param {OpenSeadragon.Placement} [options.fitBoundsPlacement=OpenSeadragon.Placement.CENTER]
|
|
|
|
* How to anchor the image in the bounds if options.fitBounds is set.
|
2015-03-20 02:38:52 +03:00
|
|
|
* @param {OpenSeadragon.Rect} [options.clip] - An area, in image pixels, to clip to
|
|
|
|
* (portions of the image outside of this area will not be visible). Only works on
|
|
|
|
* browsers that support the HTML5 canvas.
|
2014-12-02 22:44:02 +03:00
|
|
|
* @param {Number} [options.springStiffness] - See {@link OpenSeadragon.Options}.
|
|
|
|
* @param {Boolean} [options.animationTime] - See {@link OpenSeadragon.Options}.
|
2014-11-04 22:53:39 +03:00
|
|
|
* @param {Number} [options.minZoomImageRatio] - See {@link OpenSeadragon.Options}.
|
|
|
|
* @param {Boolean} [options.wrapHorizontal] - See {@link OpenSeadragon.Options}.
|
|
|
|
* @param {Boolean} [options.wrapVertical] - See {@link OpenSeadragon.Options}.
|
|
|
|
* @param {Boolean} [options.immediateRender] - See {@link OpenSeadragon.Options}.
|
|
|
|
* @param {Number} [options.blendTime] - See {@link OpenSeadragon.Options}.
|
|
|
|
* @param {Boolean} [options.alwaysBlend] - See {@link OpenSeadragon.Options}.
|
|
|
|
* @param {Number} [options.minPixelRatio] - See {@link OpenSeadragon.Options}.
|
2015-11-05 17:19:56 +03:00
|
|
|
* @param {Number} [options.smoothTileEdgesMinZoom] - See {@link OpenSeadragon.Options}.
|
2016-06-17 09:32:50 +03:00
|
|
|
* @param {Boolean} [options.iOSDevice] - See {@link OpenSeadragon.Options}.
|
2015-04-21 02:25:36 +03:00
|
|
|
* @param {Number} [options.opacity=1] - Opacity the tiled image should be drawn at.
|
2016-01-20 01:17:52 +03:00
|
|
|
* @param {String} [options.compositeOperation] - How the image is composited onto other images; see compositeOperation in {@link OpenSeadragon.Options} for possible values.
|
2014-11-04 22:53:39 +03:00
|
|
|
* @param {Boolean} [options.debugMode] - See {@link OpenSeadragon.Options}.
|
2015-04-10 15:31:08 +03:00
|
|
|
* @param {String|CanvasGradient|CanvasPattern|Function} [options.placeholderFillStyle] - See {@link OpenSeadragon.Options}.
|
2014-11-04 22:53:39 +03:00
|
|
|
* @param {String|Boolean} [options.crossOriginPolicy] - See {@link OpenSeadragon.Options}.
|
2014-08-07 00:38:56 +04:00
|
|
|
*/
|
2014-08-07 00:48:18 +04:00
|
|
|
$.TiledImage = function( options ) {
|
2014-11-25 00:25:20 +03:00
|
|
|
var _this = this;
|
|
|
|
|
2014-08-07 00:48:18 +04:00
|
|
|
$.console.assert( options.tileCache, "[TiledImage] options.tileCache is required" );
|
|
|
|
$.console.assert( options.drawer, "[TiledImage] options.drawer is required" );
|
2014-08-12 04:04:20 +04:00
|
|
|
$.console.assert( options.viewer, "[TiledImage] options.viewer is required" );
|
|
|
|
$.console.assert( options.imageLoader, "[TiledImage] options.imageLoader is required" );
|
2014-11-04 22:53:39 +03:00
|
|
|
$.console.assert( options.source, "[TiledImage] options.source is required" );
|
2015-03-18 20:03:44 +03:00
|
|
|
$.console.assert(!options.clip || options.clip instanceof $.Rect,
|
|
|
|
"[TiledImage] options.clip must be an OpenSeadragon.Rect if present");
|
2014-08-07 00:48:18 +04:00
|
|
|
|
2014-11-12 04:14:48 +03:00
|
|
|
$.EventSource.call( this );
|
|
|
|
|
2014-08-07 00:48:18 +04:00
|
|
|
this._tileCache = options.tileCache;
|
|
|
|
delete options.tileCache;
|
|
|
|
|
|
|
|
this._drawer = options.drawer;
|
|
|
|
delete options.drawer;
|
2014-08-07 00:38:56 +04:00
|
|
|
|
2014-08-12 04:04:20 +04:00
|
|
|
this._imageLoader = options.imageLoader;
|
|
|
|
delete options.imageLoader;
|
|
|
|
|
2015-03-20 02:38:52 +03:00
|
|
|
if (options.clip instanceof $.Rect) {
|
|
|
|
this._clip = options.clip.clone();
|
|
|
|
}
|
|
|
|
|
2015-03-18 20:03:44 +03:00
|
|
|
delete options.clip;
|
|
|
|
|
2014-11-25 04:47:16 +03:00
|
|
|
var x = options.x || 0;
|
2014-08-07 00:38:56 +04:00
|
|
|
delete options.x;
|
2014-11-25 04:47:16 +03:00
|
|
|
var y = options.y || 0;
|
2014-08-07 00:38:56 +04:00
|
|
|
delete options.y;
|
|
|
|
|
|
|
|
// Ratio of zoomable image height to width.
|
|
|
|
this.normHeight = options.source.dimensions.y / options.source.dimensions.x;
|
2014-11-22 03:32:04 +03:00
|
|
|
this.contentAspectX = options.source.dimensions.x / options.source.dimensions.y;
|
2014-08-07 00:38:56 +04:00
|
|
|
|
2014-11-25 04:47:16 +03:00
|
|
|
var scale = 1;
|
2014-08-07 00:38:56 +04:00
|
|
|
if ( options.width ) {
|
2014-11-25 04:47:16 +03:00
|
|
|
scale = options.width;
|
2014-08-07 00:38:56 +04:00
|
|
|
delete options.width;
|
|
|
|
|
|
|
|
if ( options.height ) {
|
2014-08-07 00:48:18 +04:00
|
|
|
$.console.error( "specifying both width and height to a tiledImage is not supported" );
|
2014-08-07 00:38:56 +04:00
|
|
|
delete options.height;
|
|
|
|
}
|
|
|
|
} else if ( options.height ) {
|
2014-11-25 04:47:16 +03:00
|
|
|
scale = options.height / this.normHeight;
|
2014-08-07 00:38:56 +04:00
|
|
|
delete options.height;
|
|
|
|
}
|
|
|
|
|
2016-03-22 23:41:28 +03:00
|
|
|
var fitBounds = options.fitBounds;
|
|
|
|
delete options.fitBounds;
|
|
|
|
var fitBoundsPlacement = options.fitBoundsPlacement || OpenSeadragon.Placement.CENTER;
|
|
|
|
delete options.fitBoundsPlacement;
|
|
|
|
|
2016-08-21 13:54:33 +03:00
|
|
|
this._degrees = $.positiveModulo(options.degrees || 0, 360);
|
|
|
|
delete options.degrees;
|
|
|
|
|
2014-08-07 00:38:56 +04:00
|
|
|
$.extend( true, this, {
|
|
|
|
|
|
|
|
//internal state properties
|
|
|
|
viewer: null,
|
|
|
|
tilesMatrix: {}, // A '3d' dictionary [level][x][y] --> Tile.
|
|
|
|
coverage: {}, // A '3d' dictionary [level][x][y] --> Boolean.
|
|
|
|
lastDrawn: [], // An unordered list of Tiles drawn last frame.
|
2014-08-07 00:48:18 +04:00
|
|
|
lastResetTime: 0, // Last time for which the tiledImage was reset.
|
2015-04-09 14:44:55 +03:00
|
|
|
_midDraw: false, // Is the tiledImage currently updating the viewport?
|
|
|
|
_needsDraw: true, // Does the tiledImage need to update the viewport again?
|
2015-10-29 23:42:45 +03:00
|
|
|
_hasOpaqueTile: false, // Do we have even one fully opaque tile?
|
2016-11-05 00:37:48 +03:00
|
|
|
_tilesLoading: 0, // The number of pending tile requests.
|
2014-08-07 00:38:56 +04:00
|
|
|
//configurable settings
|
2015-11-04 18:04:50 +03:00
|
|
|
springStiffness: $.DEFAULT_SETTINGS.springStiffness,
|
|
|
|
animationTime: $.DEFAULT_SETTINGS.animationTime,
|
|
|
|
minZoomImageRatio: $.DEFAULT_SETTINGS.minZoomImageRatio,
|
|
|
|
wrapHorizontal: $.DEFAULT_SETTINGS.wrapHorizontal,
|
|
|
|
wrapVertical: $.DEFAULT_SETTINGS.wrapVertical,
|
|
|
|
immediateRender: $.DEFAULT_SETTINGS.immediateRender,
|
|
|
|
blendTime: $.DEFAULT_SETTINGS.blendTime,
|
|
|
|
alwaysBlend: $.DEFAULT_SETTINGS.alwaysBlend,
|
|
|
|
minPixelRatio: $.DEFAULT_SETTINGS.minPixelRatio,
|
|
|
|
smoothTileEdgesMinZoom: $.DEFAULT_SETTINGS.smoothTileEdgesMinZoom,
|
2016-06-17 09:32:50 +03:00
|
|
|
iOSDevice: $.DEFAULT_SETTINGS.iOSDevice,
|
2015-11-04 18:04:50 +03:00
|
|
|
debugMode: $.DEFAULT_SETTINGS.debugMode,
|
|
|
|
crossOriginPolicy: $.DEFAULT_SETTINGS.crossOriginPolicy,
|
|
|
|
placeholderFillStyle: $.DEFAULT_SETTINGS.placeholderFillStyle,
|
2016-01-14 23:42:02 +03:00
|
|
|
opacity: $.DEFAULT_SETTINGS.opacity,
|
2016-01-14 23:32:54 +03:00
|
|
|
compositeOperation: $.DEFAULT_SETTINGS.compositeOperation
|
2014-08-07 00:38:56 +04:00
|
|
|
}, options );
|
2014-11-25 00:25:20 +03:00
|
|
|
|
2016-08-10 20:35:08 +03:00
|
|
|
this._fullyLoaded = false;
|
|
|
|
|
2014-11-25 04:47:16 +03:00
|
|
|
this._xSpring = new $.Spring({
|
|
|
|
initial: x,
|
|
|
|
springStiffness: this.springStiffness,
|
|
|
|
animationTime: this.animationTime
|
|
|
|
});
|
|
|
|
|
|
|
|
this._ySpring = new $.Spring({
|
|
|
|
initial: y,
|
|
|
|
springStiffness: this.springStiffness,
|
|
|
|
animationTime: this.animationTime
|
|
|
|
});
|
|
|
|
|
|
|
|
this._scaleSpring = new $.Spring({
|
|
|
|
initial: scale,
|
|
|
|
springStiffness: this.springStiffness,
|
|
|
|
animationTime: this.animationTime
|
|
|
|
});
|
|
|
|
|
|
|
|
this._updateForScale();
|
|
|
|
|
2016-03-22 23:41:28 +03:00
|
|
|
if (fitBounds) {
|
|
|
|
this.fitBounds(fitBounds, fitBoundsPlacement, true);
|
|
|
|
}
|
|
|
|
|
2014-11-25 00:25:20 +03:00
|
|
|
// We need a callback to give image manipulation a chance to happen
|
|
|
|
this._drawingHandler = function(args) {
|
|
|
|
/**
|
|
|
|
* This event is fired just before the tile is drawn giving the application a chance to alter the image.
|
|
|
|
*
|
2016-01-20 00:23:29 +03:00
|
|
|
* NOTE: This event is only fired when the drawer is using a <canvas>.
|
2014-11-25 00:25:20 +03:00
|
|
|
*
|
|
|
|
* @event tile-drawing
|
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised the event.
|
|
|
|
* @property {OpenSeadragon.Tile} tile - The Tile being drawn.
|
|
|
|
* @property {OpenSeadragon.TiledImage} tiledImage - Which TiledImage is being drawn.
|
|
|
|
* @property {OpenSeadragon.Tile} context - The HTML canvas context being drawn into.
|
|
|
|
* @property {OpenSeadragon.Tile} rendered - The HTML canvas context containing the tile imagery.
|
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
|
|
|
*/
|
|
|
|
_this.viewer.raiseEvent('tile-drawing', $.extend({
|
|
|
|
tiledImage: _this
|
|
|
|
}, args));
|
|
|
|
};
|
2014-08-07 00:38:56 +04:00
|
|
|
};
|
|
|
|
|
2014-11-12 04:14:48 +03:00
|
|
|
$.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadragon.TiledImage.prototype */{
|
2014-08-07 00:38:56 +04:00
|
|
|
/**
|
2014-12-02 22:44:02 +03:00
|
|
|
* @returns {Boolean} Whether the TiledImage needs to be drawn.
|
2014-08-07 00:38:56 +04:00
|
|
|
*/
|
2014-12-02 22:44:02 +03:00
|
|
|
needsDraw: function() {
|
|
|
|
return this._needsDraw;
|
2014-08-07 00:38:56 +04:00
|
|
|
},
|
|
|
|
|
2016-08-10 20:35:08 +03:00
|
|
|
/**
|
|
|
|
* @returns {Boolean} Whether all tiles necessary for this TiledImage to draw at the current view have been loaded.
|
|
|
|
*/
|
|
|
|
getFullyLoaded: function() {
|
|
|
|
return this._fullyLoaded;
|
|
|
|
},
|
|
|
|
|
|
|
|
// private
|
|
|
|
_setFullyLoaded: function(flag) {
|
|
|
|
if (flag === this._fullyLoaded) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this._fullyLoaded = flag;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fired when the TiledImage's "fully loaded" flag (whether all tiles necessary for this TiledImage
|
|
|
|
* to draw at the current view have been loaded) changes.
|
|
|
|
*
|
|
|
|
* @event fully-loaded-change
|
|
|
|
* @memberof OpenSeadragon.TiledImage
|
|
|
|
* @type {object}
|
|
|
|
* @property {Boolean} fullyLoaded - The new "fully loaded" value.
|
|
|
|
* @property {OpenSeadragon.TiledImage} eventSource - A reference to the TiledImage which raised the event.
|
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
|
|
|
*/
|
|
|
|
this.raiseEvent('fully-loaded-change', {
|
|
|
|
fullyLoaded: this._fullyLoaded
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2014-08-07 00:38:56 +04:00
|
|
|
/**
|
|
|
|
* Clears all tiles and triggers an update on the next call to
|
2014-11-04 22:53:39 +03:00
|
|
|
* {@link OpenSeadragon.TiledImage#update}.
|
2014-08-07 00:38:56 +04:00
|
|
|
*/
|
|
|
|
reset: function() {
|
2014-08-07 00:48:18 +04:00
|
|
|
this._tileCache.clearTilesFor(this);
|
2014-08-07 00:38:56 +04:00
|
|
|
this.lastResetTime = $.now();
|
2014-12-02 22:44:02 +03:00
|
|
|
this._needsDraw = true;
|
2014-08-07 00:38:56 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2014-12-02 22:44:02 +03:00
|
|
|
* Updates the TiledImage's bounds, animating if needed.
|
|
|
|
* @returns {Boolean} Whether the TiledImage animated.
|
2014-08-07 00:38:56 +04:00
|
|
|
*/
|
|
|
|
update: function() {
|
2014-12-02 22:44:02 +03:00
|
|
|
var oldX = this._xSpring.current.value;
|
|
|
|
var oldY = this._ySpring.current.value;
|
|
|
|
var oldScale = this._scaleSpring.current.value;
|
|
|
|
|
|
|
|
this._xSpring.update();
|
|
|
|
this._ySpring.update();
|
|
|
|
this._scaleSpring.update();
|
|
|
|
|
|
|
|
if (this._xSpring.current.value !== oldX || this._ySpring.current.value !== oldY ||
|
|
|
|
this._scaleSpring.current.value !== oldScale) {
|
2014-12-03 00:17:56 +03:00
|
|
|
this._updateForScale();
|
2014-12-02 22:44:02 +03:00
|
|
|
this._needsDraw = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Draws the TiledImage to its Drawer.
|
|
|
|
*/
|
|
|
|
draw: function() {
|
2016-02-23 20:42:21 +03:00
|
|
|
if (this.opacity !== 0) {
|
|
|
|
this._midDraw = true;
|
2016-08-21 20:24:40 +03:00
|
|
|
this._updateViewport();
|
2016-02-23 20:42:21 +03:00
|
|
|
this._midDraw = false;
|
|
|
|
}
|
2014-08-07 00:38:56 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2014-11-04 22:53:39 +03:00
|
|
|
* Destroy the TiledImage (unload current loaded tiles).
|
2014-08-07 00:38:56 +04:00
|
|
|
*/
|
|
|
|
destroy: function() {
|
2014-08-07 00:48:18 +04:00
|
|
|
this.reset();
|
2014-08-13 03:04:55 +04:00
|
|
|
},
|
|
|
|
|
2014-11-04 22:53:39 +03:00
|
|
|
/**
|
2016-08-28 13:10:35 +03:00
|
|
|
* Get this TiledImage's bounds in viewport coordinates.
|
|
|
|
* @param {Boolean} [current=false] - Pass true for the current location;
|
|
|
|
* false for target location.
|
2014-11-24 22:59:06 +03:00
|
|
|
* @returns {OpenSeadragon.Rect} This TiledImage's bounds in viewport coordinates.
|
2014-11-04 22:53:39 +03:00
|
|
|
*/
|
2014-11-25 04:47:16 +03:00
|
|
|
getBounds: function(current) {
|
2016-08-28 13:10:35 +03:00
|
|
|
return this.getBoundsNoRotate(current)
|
|
|
|
.rotate(this._degrees, this._getRotationPoint(current));
|
|
|
|
},
|
2014-11-25 04:47:16 +03:00
|
|
|
|
2016-08-28 13:10:35 +03:00
|
|
|
/**
|
|
|
|
* Get this TiledImage's bounds in viewport coordinates without taking
|
|
|
|
* rotation into account.
|
|
|
|
* @param {Boolean} [current=false] - Pass true for the current location;
|
|
|
|
* false for target location.
|
|
|
|
* @returns {OpenSeadragon.Rect} This TiledImage's bounds in viewport coordinates.
|
|
|
|
*/
|
|
|
|
getBoundsNoRotate: function(current) {
|
2016-08-17 16:43:08 +03:00
|
|
|
return current ?
|
|
|
|
new $.Rect(
|
|
|
|
this._xSpring.current.value,
|
|
|
|
this._ySpring.current.value,
|
|
|
|
this._worldWidthCurrent,
|
2016-08-28 13:10:35 +03:00
|
|
|
this._worldHeightCurrent) :
|
2016-08-17 16:43:08 +03:00
|
|
|
new $.Rect(
|
|
|
|
this._xSpring.target.value,
|
|
|
|
this._ySpring.target.value,
|
|
|
|
this._worldWidthTarget,
|
2016-08-28 13:10:35 +03:00
|
|
|
this._worldHeightTarget);
|
2014-08-19 03:04:49 +04:00
|
|
|
},
|
|
|
|
|
2014-11-13 03:31:46 +03:00
|
|
|
// deprecated
|
|
|
|
getWorldBounds: function() {
|
|
|
|
$.console.error('[TiledImage.getWorldBounds] is deprecated; use TiledImage.getBounds instead');
|
|
|
|
return this.getBounds();
|
|
|
|
},
|
|
|
|
|
2016-04-06 00:50:18 +03:00
|
|
|
/**
|
|
|
|
* Get the bounds of the displayed part of the tiled image.
|
|
|
|
* @param {Boolean} [current=false] Pass true for the current location,
|
|
|
|
* false for the target location.
|
|
|
|
* @returns {$.Rect} The clipped bounds in viewport coordinates.
|
|
|
|
*/
|
|
|
|
getClippedBounds: function(current) {
|
2016-08-28 13:10:35 +03:00
|
|
|
var bounds = this.getBoundsNoRotate(current);
|
2016-04-06 00:50:18 +03:00
|
|
|
if (this._clip) {
|
2016-08-28 13:10:35 +03:00
|
|
|
var worldWidth = current ?
|
|
|
|
this._worldWidthCurrent : this._worldWidthTarget;
|
|
|
|
var ratio = worldWidth / this.source.dimensions.x;
|
2016-04-06 00:50:18 +03:00
|
|
|
var clip = this._clip.times(ratio);
|
|
|
|
bounds = new $.Rect(
|
|
|
|
bounds.x + clip.x,
|
|
|
|
bounds.y + clip.y,
|
|
|
|
clip.width,
|
|
|
|
clip.height);
|
|
|
|
}
|
2016-08-28 13:10:35 +03:00
|
|
|
return bounds.rotate(this._degrees, this._getRotationPoint(current));
|
2016-04-06 00:50:18 +03:00
|
|
|
},
|
|
|
|
|
2014-11-04 22:53:39 +03:00
|
|
|
/**
|
|
|
|
* @returns {OpenSeadragon.Point} This TiledImage's content size, in original pixels.
|
|
|
|
*/
|
2014-08-19 03:04:49 +04:00
|
|
|
getContentSize: function() {
|
|
|
|
return new $.Point(this.source.dimensions.x, this.source.dimensions.y);
|
2014-11-12 04:14:48 +03:00
|
|
|
},
|
|
|
|
|
2014-11-24 22:46:33 +03:00
|
|
|
// private
|
2014-11-25 04:47:16 +03:00
|
|
|
_viewportToImageDelta: function( viewerX, viewerY, current ) {
|
2015-01-30 23:46:52 +03:00
|
|
|
var scale = (current ? this._scaleSpring.current.value : this._scaleSpring.target.value);
|
2014-11-25 04:47:16 +03:00
|
|
|
return new $.Point(viewerX * (this.source.dimensions.x / scale),
|
|
|
|
viewerY * ((this.source.dimensions.y * this.contentAspectX) / scale));
|
2014-11-24 22:46:33 +03:00
|
|
|
},
|
|
|
|
|
2014-11-22 03:32:04 +03:00
|
|
|
/**
|
|
|
|
* Translates from OpenSeadragon viewer coordinate system to image coordinate system.
|
2014-11-25 04:47:16 +03:00
|
|
|
* This method can be called either by passing X,Y coordinates or an {@link OpenSeadragon.Point}.
|
|
|
|
* @param {Number|OpenSeadragon.Point} viewerX - The X coordinate or point in viewport coordinate system.
|
|
|
|
* @param {Number} [viewerY] - The Y coordinate in viewport coordinate system.
|
|
|
|
* @param {Boolean} [current=false] - Pass true to use the current location; false for target location.
|
|
|
|
* @return {OpenSeadragon.Point} A point representing the coordinates in the image.
|
2014-11-22 03:32:04 +03:00
|
|
|
*/
|
2016-08-28 13:10:35 +03:00
|
|
|
viewportToImageCoordinates: function(viewerX, viewerY, current) {
|
|
|
|
var point;
|
2014-11-25 04:47:16 +03:00
|
|
|
if (viewerX instanceof $.Point) {
|
2014-11-22 03:32:04 +03:00
|
|
|
//they passed a point instead of individual components
|
2014-11-25 04:47:16 +03:00
|
|
|
current = viewerY;
|
2016-08-28 13:10:35 +03:00
|
|
|
point = viewerX;
|
|
|
|
} else {
|
|
|
|
point = new $.Point(viewerX, viewerY);
|
2014-11-25 04:47:16 +03:00
|
|
|
}
|
|
|
|
|
2016-08-28 13:10:35 +03:00
|
|
|
point = point.rotate(-this._degrees, this._getRotationPoint(current));
|
|
|
|
return current ?
|
|
|
|
this._viewportToImageDelta(
|
|
|
|
point.x - this._xSpring.current.value,
|
|
|
|
point.y - this._ySpring.current.value) :
|
|
|
|
this._viewportToImageDelta(
|
|
|
|
point.x - this._xSpring.target.value,
|
|
|
|
point.y - this._ySpring.target.value);
|
2014-11-24 22:46:33 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
// private
|
2014-11-25 04:47:16 +03:00
|
|
|
_imageToViewportDelta: function( imageX, imageY, current ) {
|
2015-01-30 23:46:52 +03:00
|
|
|
var scale = (current ? this._scaleSpring.current.value : this._scaleSpring.target.value);
|
2014-11-25 04:47:16 +03:00
|
|
|
return new $.Point((imageX / this.source.dimensions.x) * scale,
|
|
|
|
(imageY / this.source.dimensions.y / this.contentAspectX) * scale);
|
2014-11-22 03:32:04 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Translates from image coordinate system to OpenSeadragon viewer coordinate system
|
2014-11-25 04:47:16 +03:00
|
|
|
* This method can be called either by passing X,Y coordinates or an {@link OpenSeadragon.Point}.
|
|
|
|
* @param {Number|OpenSeadragon.Point} imageX - The X coordinate or point in image coordinate system.
|
|
|
|
* @param {Number} [imageY] - The Y coordinate in image coordinate system.
|
|
|
|
* @param {Boolean} [current=false] - Pass true to use the current location; false for target location.
|
|
|
|
* @return {OpenSeadragon.Point} A point representing the coordinates in the viewport.
|
2014-11-22 03:32:04 +03:00
|
|
|
*/
|
2016-08-28 13:10:35 +03:00
|
|
|
imageToViewportCoordinates: function(imageX, imageY, current) {
|
2014-11-25 04:47:16 +03:00
|
|
|
if (imageX instanceof $.Point) {
|
2014-11-22 03:32:04 +03:00
|
|
|
//they passed a point instead of individual components
|
2014-11-25 04:47:16 +03:00
|
|
|
current = imageY;
|
|
|
|
imageY = imageX.y;
|
|
|
|
imageX = imageX.x;
|
2014-11-22 03:32:04 +03:00
|
|
|
}
|
|
|
|
|
2014-11-24 22:46:33 +03:00
|
|
|
var point = this._imageToViewportDelta(imageX, imageY);
|
2014-11-25 04:47:16 +03:00
|
|
|
if (current) {
|
|
|
|
point.x += this._xSpring.current.value;
|
|
|
|
point.y += this._ySpring.current.value;
|
|
|
|
} else {
|
|
|
|
point.x += this._xSpring.target.value;
|
|
|
|
point.y += this._ySpring.target.value;
|
|
|
|
}
|
|
|
|
|
2016-08-28 13:10:35 +03:00
|
|
|
return point.rotate(this._degrees, this._getRotationPoint(current));
|
2014-11-22 03:32:04 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Translates from a rectangle which describes a portion of the image in
|
|
|
|
* pixel coordinates to OpenSeadragon viewport rectangle coordinates.
|
2014-11-25 04:47:16 +03:00
|
|
|
* This method can be called either by passing X,Y,width,height or an {@link OpenSeadragon.Rect}.
|
|
|
|
* @param {Number|OpenSeadragon.Rect} imageX - The left coordinate or rectangle in image coordinate system.
|
|
|
|
* @param {Number} [imageY] - The top coordinate in image coordinate system.
|
|
|
|
* @param {Number} [pixelWidth] - The width in pixel of the rectangle.
|
|
|
|
* @param {Number} [pixelHeight] - The height in pixel of the rectangle.
|
|
|
|
* @param {Boolean} [current=false] - Pass true to use the current location; false for target location.
|
|
|
|
* @return {OpenSeadragon.Rect} A rect representing the coordinates in the viewport.
|
2014-11-22 03:32:04 +03:00
|
|
|
*/
|
2014-11-25 04:47:16 +03:00
|
|
|
imageToViewportRectangle: function( imageX, imageY, pixelWidth, pixelHeight, current ) {
|
2015-12-12 03:07:23 +03:00
|
|
|
var rect = imageX;
|
|
|
|
if (rect instanceof $.Rect) {
|
2014-11-25 04:47:16 +03:00
|
|
|
//they passed a rect instead of individual components
|
|
|
|
current = imageY;
|
2015-12-12 03:07:23 +03:00
|
|
|
} else {
|
|
|
|
rect = new $.Rect(imageX, imageY, pixelWidth, pixelHeight);
|
2014-11-22 03:32:04 +03:00
|
|
|
}
|
2014-11-25 04:47:16 +03:00
|
|
|
|
2015-12-12 03:07:23 +03:00
|
|
|
var coordA = this.imageToViewportCoordinates(rect.getTopLeft(), current);
|
|
|
|
var coordB = this._imageToViewportDelta(rect.width, rect.height, current);
|
2014-11-25 04:47:16 +03:00
|
|
|
|
2014-11-22 03:32:04 +03:00
|
|
|
return new $.Rect(
|
|
|
|
coordA.x,
|
|
|
|
coordA.y,
|
2014-11-24 22:46:33 +03:00
|
|
|
coordB.x,
|
2015-12-12 03:07:23 +03:00
|
|
|
coordB.y,
|
2016-08-28 13:10:35 +03:00
|
|
|
rect.degrees + this._degrees
|
2014-11-22 03:32:04 +03:00
|
|
|
);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Translates from a rectangle which describes a portion of
|
|
|
|
* the viewport in point coordinates to image rectangle coordinates.
|
2014-11-25 04:47:16 +03:00
|
|
|
* This method can be called either by passing X,Y,width,height or an {@link OpenSeadragon.Rect}.
|
|
|
|
* @param {Number|OpenSeadragon.Rect} viewerX - The left coordinate or rectangle in viewport coordinate system.
|
|
|
|
* @param {Number} [viewerY] - The top coordinate in viewport coordinate system.
|
|
|
|
* @param {Number} [pointWidth] - The width in viewport coordinate system.
|
|
|
|
* @param {Number} [pointHeight] - The height in viewport coordinate system.
|
|
|
|
* @param {Boolean} [current=false] - Pass true to use the current location; false for target location.
|
|
|
|
* @return {OpenSeadragon.Rect} A rect representing the coordinates in the image.
|
2014-11-22 03:32:04 +03:00
|
|
|
*/
|
2014-11-25 04:47:16 +03:00
|
|
|
viewportToImageRectangle: function( viewerX, viewerY, pointWidth, pointHeight, current ) {
|
2015-12-12 03:07:23 +03:00
|
|
|
var rect = viewerX;
|
2014-11-25 04:47:16 +03:00
|
|
|
if (viewerX instanceof $.Rect) {
|
|
|
|
//they passed a rect instead of individual components
|
|
|
|
current = viewerY;
|
2015-12-12 03:07:23 +03:00
|
|
|
} else {
|
|
|
|
rect = new $.Rect(viewerX, viewerY, pointWidth, pointHeight);
|
2014-11-22 03:32:04 +03:00
|
|
|
}
|
2014-11-25 04:47:16 +03:00
|
|
|
|
2015-12-12 03:07:23 +03:00
|
|
|
var coordA = this.viewportToImageCoordinates(rect.getTopLeft(), current);
|
|
|
|
var coordB = this._viewportToImageDelta(rect.width, rect.height, current);
|
2014-11-25 04:47:16 +03:00
|
|
|
|
2014-11-22 03:32:04 +03:00
|
|
|
return new $.Rect(
|
|
|
|
coordA.x,
|
|
|
|
coordA.y,
|
2014-11-24 22:46:33 +03:00
|
|
|
coordB.x,
|
2015-12-12 03:07:23 +03:00
|
|
|
coordB.y,
|
2016-08-28 13:10:35 +03:00
|
|
|
rect.degrees - this._degrees
|
2014-11-22 03:32:04 +03:00
|
|
|
);
|
|
|
|
},
|
|
|
|
|
2015-06-02 23:41:37 +03:00
|
|
|
/**
|
|
|
|
* Convert pixel coordinates relative to the viewer element to image
|
|
|
|
* coordinates.
|
|
|
|
* @param {OpenSeadragon.Point} pixel
|
|
|
|
* @returns {OpenSeadragon.Point}
|
|
|
|
*/
|
|
|
|
viewerElementToImageCoordinates: function( pixel ) {
|
|
|
|
var point = this.viewport.pointFromPixel( pixel, true );
|
|
|
|
return this.viewportToImageCoordinates( point );
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert pixel coordinates relative to the image to
|
|
|
|
* viewer element coordinates.
|
|
|
|
* @param {OpenSeadragon.Point} pixel
|
|
|
|
* @returns {OpenSeadragon.Point}
|
|
|
|
*/
|
|
|
|
imageToViewerElementCoordinates: function( pixel ) {
|
|
|
|
var point = this.imageToViewportCoordinates( pixel );
|
|
|
|
return this.viewport.pixelFromPoint( point, true );
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert pixel coordinates relative to the window to image coordinates.
|
|
|
|
* @param {OpenSeadragon.Point} pixel
|
|
|
|
* @returns {OpenSeadragon.Point}
|
|
|
|
*/
|
|
|
|
windowToImageCoordinates: function( pixel ) {
|
|
|
|
var viewerCoordinates = pixel.minus(
|
|
|
|
OpenSeadragon.getElementPosition( this.viewer.element ));
|
|
|
|
return this.viewerElementToImageCoordinates( viewerCoordinates );
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert image coordinates to pixel coordinates relative to the window.
|
|
|
|
* @param {OpenSeadragon.Point} pixel
|
|
|
|
* @returns {OpenSeadragon.Point}
|
|
|
|
*/
|
|
|
|
imageToWindowCoordinates: function( pixel ) {
|
|
|
|
var viewerCoordinates = this.imageToViewerElementCoordinates( pixel );
|
|
|
|
return viewerCoordinates.plus(
|
|
|
|
OpenSeadragon.getElementPosition( this.viewer.element ));
|
|
|
|
},
|
|
|
|
|
2016-08-28 13:10:35 +03:00
|
|
|
// private
|
2016-10-25 22:41:42 +03:00
|
|
|
// Convert rectangle in viewport coordinates to this tiled image point
|
|
|
|
// coordinates (x in [0, 1] and y in [0, aspectRatio])
|
2016-08-28 13:10:35 +03:00
|
|
|
_viewportToTiledImageRectangle: function(rect) {
|
|
|
|
var scale = this._scaleSpring.current.value;
|
|
|
|
rect = rect.rotate(-this.getRotation(), this._getRotationPoint(true));
|
|
|
|
return new $.Rect(
|
|
|
|
(rect.x - this._xSpring.current.value) / scale,
|
|
|
|
(rect.y - this._ySpring.current.value) / scale,
|
|
|
|
rect.width / scale,
|
|
|
|
rect.height / scale,
|
|
|
|
rect.degrees);
|
|
|
|
},
|
|
|
|
|
2015-06-02 23:41:37 +03:00
|
|
|
/**
|
|
|
|
* Convert a viewport zoom to an image zoom.
|
|
|
|
* Image zoom: ratio of the original image size to displayed image size.
|
|
|
|
* 1 means original image size, 0.5 half size...
|
|
|
|
* Viewport zoom: ratio of the displayed image's width to viewport's width.
|
|
|
|
* 1 means identical width, 2 means image's width is twice the viewport's width...
|
|
|
|
* @function
|
|
|
|
* @param {Number} viewportZoom The viewport zoom
|
|
|
|
* @returns {Number} imageZoom The image zoom
|
|
|
|
*/
|
|
|
|
viewportToImageZoom: function( viewportZoom ) {
|
|
|
|
var ratio = this._scaleSpring.current.value *
|
|
|
|
this.viewport._containerInnerSize.x / this.source.dimensions.x;
|
2017-01-08 17:52:57 +03:00
|
|
|
return ratio * viewportZoom;
|
2015-06-02 23:41:37 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert an image zoom to a viewport zoom.
|
|
|
|
* Image zoom: ratio of the original image size to displayed image size.
|
|
|
|
* 1 means original image size, 0.5 half size...
|
|
|
|
* Viewport zoom: ratio of the displayed image's width to viewport's width.
|
|
|
|
* 1 means identical width, 2 means image's width is twice the viewport's width...
|
|
|
|
* Note: not accurate with multi-image.
|
|
|
|
* @function
|
|
|
|
* @param {Number} imageZoom The image zoom
|
|
|
|
* @returns {Number} viewportZoom The viewport zoom
|
|
|
|
*/
|
|
|
|
imageToViewportZoom: function( imageZoom ) {
|
|
|
|
var ratio = this._scaleSpring.current.value *
|
|
|
|
this.viewport._containerInnerSize.x / this.source.dimensions.x;
|
|
|
|
return imageZoom / ratio;
|
|
|
|
},
|
|
|
|
|
2014-11-12 04:14:48 +03:00
|
|
|
/**
|
2014-11-13 03:31:46 +03:00
|
|
|
* Sets the TiledImage's position in the world.
|
2014-11-24 22:59:06 +03:00
|
|
|
* @param {OpenSeadragon.Point} position - The new position, in viewport coordinates.
|
2014-11-25 04:47:16 +03:00
|
|
|
* @param {Boolean} [immediately=false] - Whether to animate to the new position or snap immediately.
|
2014-11-13 03:31:46 +03:00
|
|
|
* @fires OpenSeadragon.TiledImage.event:bounds-change
|
2014-11-12 04:14:48 +03:00
|
|
|
*/
|
2014-11-25 04:47:16 +03:00
|
|
|
setPosition: function(position, immediately) {
|
2014-12-02 22:44:02 +03:00
|
|
|
var sameTarget = (this._xSpring.target.value === position.x &&
|
|
|
|
this._ySpring.target.value === position.y);
|
|
|
|
|
2014-11-25 04:47:16 +03:00
|
|
|
if (immediately) {
|
2014-12-02 22:44:02 +03:00
|
|
|
if (sameTarget && this._xSpring.current.value === position.x &&
|
|
|
|
this._ySpring.current.value === position.y) {
|
2014-11-25 04:47:16 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this._xSpring.resetTo(position.x);
|
|
|
|
this._ySpring.resetTo(position.y);
|
2015-10-29 23:42:45 +03:00
|
|
|
this._needsDraw = true;
|
2014-11-25 04:47:16 +03:00
|
|
|
} else {
|
2014-12-02 22:44:02 +03:00
|
|
|
if (sameTarget) {
|
2014-11-25 04:47:16 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this._xSpring.springTo(position.x);
|
|
|
|
this._ySpring.springTo(position.y);
|
2015-10-29 23:42:45 +03:00
|
|
|
this._needsDraw = true;
|
2014-11-13 02:48:38 +03:00
|
|
|
}
|
|
|
|
|
2014-12-02 22:44:02 +03:00
|
|
|
if (!sameTarget) {
|
|
|
|
this._raiseBoundsChange();
|
|
|
|
}
|
2014-11-12 04:14:48 +03:00
|
|
|
},
|
|
|
|
|
2014-11-13 02:48:38 +03:00
|
|
|
/**
|
2014-11-13 03:31:46 +03:00
|
|
|
* Sets the TiledImage's width in the world, adjusting the height to match based on aspect ratio.
|
2014-11-24 22:59:06 +03:00
|
|
|
* @param {Number} width - The new width, in viewport coordinates.
|
2014-11-25 04:47:16 +03:00
|
|
|
* @param {Boolean} [immediately=false] - Whether to animate to the new size or snap immediately.
|
2014-11-13 03:31:46 +03:00
|
|
|
* @fires OpenSeadragon.TiledImage.event:bounds-change
|
2014-11-13 02:48:38 +03:00
|
|
|
*/
|
2014-11-25 04:47:16 +03:00
|
|
|
setWidth: function(width, immediately) {
|
2014-12-02 22:44:02 +03:00
|
|
|
this._setScale(width, immediately);
|
2014-11-13 02:48:38 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2014-11-13 03:31:46 +03:00
|
|
|
* Sets the TiledImage's height in the world, adjusting the width to match based on aspect ratio.
|
2014-11-24 22:59:06 +03:00
|
|
|
* @param {Number} height - The new height, in viewport coordinates.
|
2014-11-25 04:47:16 +03:00
|
|
|
* @param {Boolean} [immediately=false] - Whether to animate to the new size or snap immediately.
|
2014-11-13 03:31:46 +03:00
|
|
|
* @fires OpenSeadragon.TiledImage.event:bounds-change
|
2014-11-13 02:48:38 +03:00
|
|
|
*/
|
2014-11-25 04:47:16 +03:00
|
|
|
setHeight: function(height, immediately) {
|
2014-12-02 22:44:02 +03:00
|
|
|
this._setScale(height / this.normHeight, immediately);
|
|
|
|
},
|
|
|
|
|
2016-03-21 23:11:50 +03:00
|
|
|
/**
|
|
|
|
* Positions and scales the TiledImage to fit in the specified bounds.
|
|
|
|
* Note: this method fires OpenSeadragon.TiledImage.event:bounds-change
|
|
|
|
* twice
|
|
|
|
* @param {OpenSeadragon.Rect} bounds The bounds to fit the image into.
|
|
|
|
* @param {OpenSeadragon.Placement} [anchor=OpenSeadragon.Placement.CENTER]
|
|
|
|
* How to anchor the image in the bounds.
|
|
|
|
* @param {Boolean} [immediately=false] Whether to animate to the new size
|
|
|
|
* or snap immediately.
|
|
|
|
* @fires OpenSeadragon.TiledImage.event:bounds-change
|
|
|
|
*/
|
2016-03-22 23:41:28 +03:00
|
|
|
fitBounds: function(bounds, anchor, immediately) {
|
2016-03-21 23:11:50 +03:00
|
|
|
anchor = anchor || $.Placement.CENTER;
|
2016-03-22 22:50:48 +03:00
|
|
|
var anchorProperties = $.Placement.properties[anchor];
|
2016-03-24 18:48:29 +03:00
|
|
|
var aspectRatio = this.contentAspectX;
|
|
|
|
var xOffset = 0;
|
|
|
|
var yOffset = 0;
|
|
|
|
var displayedWidthRatio = 1;
|
|
|
|
var displayedHeightRatio = 1;
|
|
|
|
if (this._clip) {
|
|
|
|
aspectRatio = this._clip.getAspectRatio();
|
|
|
|
displayedWidthRatio = this._clip.width / this.source.dimensions.x;
|
|
|
|
displayedHeightRatio = this._clip.height / this.source.dimensions.y;
|
|
|
|
if (bounds.getAspectRatio() > aspectRatio) {
|
|
|
|
xOffset = this._clip.x / this._clip.height * bounds.height;
|
|
|
|
yOffset = this._clip.y / this._clip.height * bounds.height;
|
|
|
|
} else {
|
|
|
|
xOffset = this._clip.x / this._clip.width * bounds.width;
|
|
|
|
yOffset = this._clip.y / this._clip.width * bounds.width;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bounds.getAspectRatio() > aspectRatio) {
|
2016-03-21 23:11:50 +03:00
|
|
|
// We will have margins on the X axis
|
2016-03-24 18:48:29 +03:00
|
|
|
var height = bounds.height / displayedHeightRatio;
|
2016-03-21 23:11:50 +03:00
|
|
|
var marginLeft = 0;
|
2016-03-22 22:50:48 +03:00
|
|
|
if (anchorProperties.isHorizontallyCentered) {
|
2016-03-24 18:48:29 +03:00
|
|
|
marginLeft = (bounds.width - bounds.height * aspectRatio) / 2;
|
2016-03-22 22:50:48 +03:00
|
|
|
} else if (anchorProperties.isRight) {
|
2016-03-24 18:48:29 +03:00
|
|
|
marginLeft = bounds.width - bounds.height * aspectRatio;
|
2016-03-21 23:11:50 +03:00
|
|
|
}
|
|
|
|
this.setPosition(
|
2016-03-24 18:48:29 +03:00
|
|
|
new $.Point(bounds.x - xOffset + marginLeft, bounds.y - yOffset),
|
2016-03-21 23:11:50 +03:00
|
|
|
immediately);
|
2016-03-24 18:48:29 +03:00
|
|
|
this.setHeight(height, immediately);
|
2016-03-21 23:11:50 +03:00
|
|
|
} else {
|
|
|
|
// We will have margins on the Y axis
|
2016-03-24 18:48:29 +03:00
|
|
|
var width = bounds.width / displayedWidthRatio;
|
2016-03-21 23:11:50 +03:00
|
|
|
var marginTop = 0;
|
2016-03-22 22:50:48 +03:00
|
|
|
if (anchorProperties.isVerticallyCentered) {
|
2016-03-24 18:48:29 +03:00
|
|
|
marginTop = (bounds.height - bounds.width / aspectRatio) / 2;
|
2016-03-22 22:50:48 +03:00
|
|
|
} else if (anchorProperties.isBottom) {
|
2016-03-24 18:48:29 +03:00
|
|
|
marginTop = bounds.height - bounds.width / aspectRatio;
|
2016-03-21 23:11:50 +03:00
|
|
|
}
|
|
|
|
this.setPosition(
|
2016-03-24 18:48:29 +03:00
|
|
|
new $.Point(bounds.x - xOffset, bounds.y - yOffset + marginTop),
|
2016-03-21 23:11:50 +03:00
|
|
|
immediately);
|
2016-03-24 18:48:29 +03:00
|
|
|
this.setWidth(width, immediately);
|
2016-03-21 23:11:50 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-03-20 02:38:52 +03:00
|
|
|
/**
|
|
|
|
* @returns {OpenSeadragon.Rect|null} The TiledImage's current clip rectangle,
|
|
|
|
* in image pixels, or null if none.
|
|
|
|
*/
|
|
|
|
getClip: function() {
|
|
|
|
if (this._clip) {
|
|
|
|
return this._clip.clone();
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {OpenSeadragon.Rect|null} newClip - An area, in image pixels, to clip to
|
|
|
|
* (portions of the image outside of this area will not be visible). Only works on
|
|
|
|
* browsers that support the HTML5 canvas.
|
2016-08-28 15:39:14 +03:00
|
|
|
* @fires OpenSeadragon.TiledImage.event:clip-change
|
2015-03-20 02:38:52 +03:00
|
|
|
*/
|
|
|
|
setClip: function(newClip) {
|
|
|
|
$.console.assert(!newClip || newClip instanceof $.Rect,
|
|
|
|
"[TiledImage.setClip] newClip must be an OpenSeadragon.Rect or null");
|
|
|
|
|
|
|
|
if (newClip instanceof $.Rect) {
|
|
|
|
this._clip = newClip.clone();
|
|
|
|
} else {
|
|
|
|
this._clip = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
this._needsDraw = true;
|
2016-08-28 15:39:14 +03:00
|
|
|
/**
|
|
|
|
* Raised when the TiledImage's clip is changed.
|
|
|
|
* @event clip-change
|
|
|
|
* @memberOf OpenSeadragon.TiledImage
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.TiledImage} eventSource - A reference to the
|
|
|
|
* TiledImage which raised the event.
|
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
|
|
|
*/
|
|
|
|
this.raiseEvent('clip-change');
|
2015-03-20 02:38:52 +03:00
|
|
|
},
|
|
|
|
|
2015-04-21 02:25:36 +03:00
|
|
|
/**
|
|
|
|
* @returns {Number} The TiledImage's current opacity.
|
|
|
|
*/
|
|
|
|
getOpacity: function() {
|
|
|
|
return this.opacity;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {Number} opacity Opacity the tiled image should be drawn at.
|
|
|
|
*/
|
|
|
|
setOpacity: function(opacity) {
|
|
|
|
this.opacity = opacity;
|
|
|
|
this._needsDraw = true;
|
|
|
|
},
|
|
|
|
|
2016-08-17 16:43:08 +03:00
|
|
|
/**
|
|
|
|
* Get the current rotation of this tiled image in degrees.
|
|
|
|
* @returns {Number} the current rotation of this tiled image in degrees.
|
|
|
|
*/
|
|
|
|
getRotation: function() {
|
2016-08-21 13:54:33 +03:00
|
|
|
return this._degrees;
|
2016-08-17 16:43:08 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the current rotation of this tiled image in degrees.
|
2016-08-28 13:10:35 +03:00
|
|
|
* @param {Number} degrees the rotation in degrees.
|
2016-08-28 15:39:14 +03:00
|
|
|
* @fires OpenSeadragon.TiledImage.event:bounds-change
|
2016-08-17 16:43:08 +03:00
|
|
|
*/
|
|
|
|
setRotation: function(degrees) {
|
2016-08-21 13:54:33 +03:00
|
|
|
degrees = $.positiveModulo(degrees, 360);
|
|
|
|
if (this._degrees === degrees) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this._degrees = degrees;
|
2016-08-17 16:43:08 +03:00
|
|
|
this._needsDraw = true;
|
2016-08-21 13:54:33 +03:00
|
|
|
this._raiseBoundsChange();
|
2016-08-17 16:43:08 +03:00
|
|
|
},
|
|
|
|
|
2016-08-28 13:10:35 +03:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* Get the point around which this tiled image is rotated
|
|
|
|
* @param {Boolean} current True for current rotation point, false for target.
|
|
|
|
* @returns {OpenSeadragon.Point}
|
|
|
|
*/
|
|
|
|
_getRotationPoint: function(current) {
|
2016-08-28 14:39:26 +03:00
|
|
|
return this.getBoundsNoRotate(current).getCenter();
|
2016-08-28 13:10:35 +03:00
|
|
|
},
|
|
|
|
|
Update to allow setting of globalCompositeOperation when
html <canvas> is used to process multiple tiledImages to blend
is a specific way.
(special handling,
when compositeOperation is 'source-over' and opacity is 1,
useSketch is false, otherwise useSketch is true
)
Valid values are 'source-atop', 'source-in', 'source-out',
'destination-over', 'destination-atop', 'destination-in',
'destination-out', 'lighter', 'copy' or 'xor'
http://www.w3schools.com/tags/canvas_globalcompositeoperation.asp
2016-01-06 18:58:36 +03:00
|
|
|
/**
|
|
|
|
* @returns {String} The TiledImage's current compositeOperation.
|
|
|
|
*/
|
|
|
|
getCompositeOperation: function() {
|
|
|
|
return this.compositeOperation;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {String} compositeOperation the tiled image should be drawn with this globalCompositeOperation.
|
|
|
|
*/
|
|
|
|
setCompositeOperation: function(compositeOperation) {
|
|
|
|
this.compositeOperation = compositeOperation;
|
|
|
|
this._needsDraw = true;
|
|
|
|
},
|
|
|
|
|
2014-12-02 22:44:02 +03:00
|
|
|
// private
|
|
|
|
_setScale: function(scale, immediately) {
|
|
|
|
var sameTarget = (this._scaleSpring.target.value === scale);
|
2014-11-25 04:47:16 +03:00
|
|
|
if (immediately) {
|
2014-12-02 22:44:02 +03:00
|
|
|
if (sameTarget && this._scaleSpring.current.value === scale) {
|
2014-11-25 04:47:16 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this._scaleSpring.resetTo(scale);
|
|
|
|
this._updateForScale();
|
2015-10-29 23:42:45 +03:00
|
|
|
this._needsDraw = true;
|
2014-11-25 04:47:16 +03:00
|
|
|
} else {
|
2014-12-02 22:44:02 +03:00
|
|
|
if (sameTarget) {
|
2014-11-25 04:47:16 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this._scaleSpring.springTo(scale);
|
|
|
|
this._updateForScale();
|
2015-10-29 23:42:45 +03:00
|
|
|
this._needsDraw = true;
|
2014-11-13 02:48:38 +03:00
|
|
|
}
|
|
|
|
|
2014-12-02 22:44:02 +03:00
|
|
|
if (!sameTarget) {
|
|
|
|
this._raiseBoundsChange();
|
|
|
|
}
|
2014-11-13 02:48:38 +03:00
|
|
|
},
|
|
|
|
|
2014-11-25 04:47:16 +03:00
|
|
|
// private
|
|
|
|
_updateForScale: function() {
|
2014-12-02 22:44:02 +03:00
|
|
|
this._worldWidthTarget = this._scaleSpring.target.value;
|
|
|
|
this._worldHeightTarget = this.normHeight * this._scaleSpring.target.value;
|
|
|
|
this._worldWidthCurrent = this._scaleSpring.current.value;
|
|
|
|
this._worldHeightCurrent = this.normHeight * this._scaleSpring.current.value;
|
2014-11-25 04:47:16 +03:00
|
|
|
},
|
|
|
|
|
2014-11-13 03:31:46 +03:00
|
|
|
// private
|
|
|
|
_raiseBoundsChange: function() {
|
2014-11-12 04:14:48 +03:00
|
|
|
/**
|
|
|
|
* Raised when the TiledImage's bounds are changed.
|
2014-12-02 22:44:02 +03:00
|
|
|
* Note that this event is triggered only when the animation target is changed;
|
|
|
|
* not for every frame of animation.
|
2014-11-13 03:31:46 +03:00
|
|
|
* @event bounds-change
|
2014-11-12 04:14:48 +03:00
|
|
|
* @memberOf OpenSeadragon.TiledImage
|
|
|
|
* @type {object}
|
2016-08-28 15:39:14 +03:00
|
|
|
* @property {OpenSeadragon.TiledImage} eventSource - A reference to the
|
|
|
|
* TiledImage which raised the event.
|
2014-11-12 04:14:48 +03:00
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
|
|
|
*/
|
2014-11-13 03:31:46 +03:00
|
|
|
this.raiseEvent('bounds-change');
|
2016-02-24 03:37:41 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
// private
|
|
|
|
_isBottomItem: function() {
|
|
|
|
return this.viewer.world.getItemAt(0) === this;
|
2016-08-21 20:24:40 +03:00
|
|
|
},
|
2014-08-07 00:38:56 +04:00
|
|
|
|
2016-08-21 20:24:40 +03:00
|
|
|
// private
|
|
|
|
_getLevelsInterval: function() {
|
|
|
|
var lowestLevel = Math.max(
|
|
|
|
this.source.minLevel,
|
|
|
|
Math.floor(Math.log(this.minZoomImageRatio) / Math.log(2))
|
|
|
|
);
|
|
|
|
var currentZeroRatio = this.viewport.deltaPixelsFromPointsNoRotate(
|
|
|
|
this.source.getPixelRatio(0), true).x *
|
|
|
|
this._scaleSpring.current.value;
|
|
|
|
var highestLevel = Math.min(
|
|
|
|
Math.abs(this.source.maxLevel),
|
2014-08-07 00:38:56 +04:00
|
|
|
Math.abs(Math.floor(
|
2016-08-21 20:24:40 +03:00
|
|
|
Math.log(currentZeroRatio / this.minPixelRatio) / Math.log(2)
|
2014-08-07 00:38:56 +04:00
|
|
|
))
|
2016-08-21 20:24:40 +03:00
|
|
|
);
|
2014-11-06 03:39:35 +03:00
|
|
|
|
2016-08-21 20:24:40 +03:00
|
|
|
// Calculations for the interval of levels to draw
|
|
|
|
// can return invalid intervals; fix that here if necessary
|
|
|
|
lowestLevel = Math.min(lowestLevel, highestLevel);
|
|
|
|
return {
|
|
|
|
lowestLevel: lowestLevel,
|
|
|
|
highestLevel: highestLevel
|
|
|
|
};
|
|
|
|
},
|
2014-11-06 03:39:35 +03:00
|
|
|
|
2016-09-06 02:27:18 +03:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
* Pretty much every other line in this needs to be documented so it's clear
|
|
|
|
* how each piece of this routine contributes to the drawing process. That's
|
|
|
|
* why there are so many TODO's inside this function.
|
|
|
|
*/
|
2016-08-21 20:24:40 +03:00
|
|
|
_updateViewport: function() {
|
|
|
|
this._needsDraw = false;
|
2016-11-05 00:37:48 +03:00
|
|
|
this._tilesLoading = 0;
|
2014-08-07 00:38:56 +04:00
|
|
|
|
2016-08-21 20:24:40 +03:00
|
|
|
// Reset tile's internal drawn state
|
|
|
|
while (this.lastDrawn.length > 0) {
|
|
|
|
var tile = this.lastDrawn.pop();
|
|
|
|
tile.beingDrawn = false;
|
|
|
|
}
|
2014-11-06 03:39:35 +03:00
|
|
|
|
2016-08-28 13:10:35 +03:00
|
|
|
var viewport = this.viewport;
|
|
|
|
var drawArea = this._viewportToTiledImageRectangle(
|
|
|
|
viewport.getBoundsWithMargins(true));
|
2014-08-07 00:38:56 +04:00
|
|
|
|
2016-08-21 20:24:40 +03:00
|
|
|
if (!this.wrapHorizontal && !this.wrapVertical) {
|
2016-08-28 13:10:35 +03:00
|
|
|
var tiledImageBounds = this._viewportToTiledImageRectangle(
|
|
|
|
this.getClippedBounds(true));
|
|
|
|
drawArea = drawArea.intersection(tiledImageBounds);
|
|
|
|
if (drawArea === null) {
|
2016-08-21 20:24:40 +03:00
|
|
|
return;
|
|
|
|
}
|
2014-08-07 00:38:56 +04:00
|
|
|
}
|
|
|
|
|
2016-08-21 20:24:40 +03:00
|
|
|
var levelsInterval = this._getLevelsInterval();
|
|
|
|
var lowestLevel = levelsInterval.lowestLevel;
|
|
|
|
var highestLevel = levelsInterval.highestLevel;
|
|
|
|
var bestTile = null;
|
|
|
|
var haveDrawn = false;
|
|
|
|
var currentTime = $.now();
|
|
|
|
|
|
|
|
// Update any level that will be drawn
|
|
|
|
for (var level = highestLevel; level >= lowestLevel; level--) {
|
|
|
|
var drawLevel = false;
|
|
|
|
|
|
|
|
//Avoid calculations for draw if we have already drawn this
|
|
|
|
var currentRenderPixelRatio = viewport.deltaPixelsFromPointsNoRotate(
|
|
|
|
this.source.getPixelRatio(level),
|
|
|
|
true
|
|
|
|
).x * this._scaleSpring.current.value;
|
|
|
|
|
|
|
|
if (level === lowestLevel ||
|
|
|
|
(!haveDrawn && currentRenderPixelRatio >= this.minPixelRatio)) {
|
|
|
|
drawLevel = true;
|
|
|
|
haveDrawn = true;
|
|
|
|
} else if (!haveDrawn) {
|
|
|
|
continue;
|
|
|
|
}
|
2014-08-07 00:38:56 +04:00
|
|
|
|
2016-08-21 20:24:40 +03:00
|
|
|
//Perform calculations for draw if we haven't drawn this
|
|
|
|
var targetRenderPixelRatio = viewport.deltaPixelsFromPointsNoRotate(
|
|
|
|
this.source.getPixelRatio(level),
|
|
|
|
false
|
2016-10-23 19:25:14 +03:00
|
|
|
).x * this._scaleSpring.current.value;
|
2016-08-21 20:24:40 +03:00
|
|
|
|
|
|
|
var targetZeroRatio = viewport.deltaPixelsFromPointsNoRotate(
|
|
|
|
this.source.getPixelRatio(
|
|
|
|
Math.max(
|
|
|
|
this.source.getClosestLevel(viewport.containerSize) - 1,
|
|
|
|
0
|
|
|
|
)
|
|
|
|
),
|
|
|
|
false
|
2016-10-23 19:25:14 +03:00
|
|
|
).x * this._scaleSpring.current.value;
|
2016-08-21 20:24:40 +03:00
|
|
|
|
|
|
|
var optimalRatio = this.immediateRender ? 1 : targetZeroRatio;
|
|
|
|
var levelOpacity = Math.min(1, (currentRenderPixelRatio - 0.5) / 0.5);
|
|
|
|
var levelVisibility = optimalRatio / Math.abs(
|
|
|
|
optimalRatio - targetRenderPixelRatio
|
|
|
|
);
|
|
|
|
|
|
|
|
// Update the level and keep track of 'best' tile to load
|
|
|
|
bestTile = updateLevel(
|
|
|
|
this,
|
|
|
|
haveDrawn,
|
|
|
|
drawLevel,
|
|
|
|
level,
|
|
|
|
levelOpacity,
|
|
|
|
levelVisibility,
|
2016-08-28 13:10:35 +03:00
|
|
|
drawArea,
|
2016-08-21 20:24:40 +03:00
|
|
|
currentTime,
|
|
|
|
bestTile
|
|
|
|
);
|
2014-08-07 00:38:56 +04:00
|
|
|
|
2016-08-21 20:24:40 +03:00
|
|
|
// Stop the loop if lower-res tiles would all be covered by
|
|
|
|
// already drawn tiles
|
|
|
|
if (providesCoverage(this.coverage, level)) {
|
|
|
|
break;
|
|
|
|
}
|
2014-08-07 00:38:56 +04:00
|
|
|
}
|
|
|
|
|
2016-08-21 20:24:40 +03:00
|
|
|
// Perform the actual drawing
|
|
|
|
drawTiles(this, this.lastDrawn);
|
2014-08-07 00:38:56 +04:00
|
|
|
|
2016-08-21 20:24:40 +03:00
|
|
|
// Load the new 'best' tile
|
|
|
|
if (bestTile && !bestTile.context2D) {
|
|
|
|
loadTile(this, bestTile, currentTime);
|
2016-08-28 13:14:49 +03:00
|
|
|
this._needsDraw = true;
|
2016-08-21 20:24:40 +03:00
|
|
|
this._setFullyLoaded(false);
|
|
|
|
} else {
|
2016-11-05 00:37:48 +03:00
|
|
|
this._setFullyLoaded(this._tilesLoading === 0);
|
2016-08-21 20:24:40 +03:00
|
|
|
}
|
2016-11-01 23:43:00 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
// private
|
|
|
|
_getCornerTiles: function(level, topLeftBound, bottomRightBound) {
|
|
|
|
var leftX;
|
|
|
|
var rightX;
|
|
|
|
if (this.wrapHorizontal) {
|
|
|
|
leftX = $.positiveModulo(topLeftBound.x, 1);
|
|
|
|
rightX = $.positiveModulo(bottomRightBound.x, 1);
|
|
|
|
} else {
|
|
|
|
leftX = Math.max(0, topLeftBound.x);
|
|
|
|
rightX = Math.min(1, bottomRightBound.x);
|
|
|
|
}
|
|
|
|
var topY;
|
|
|
|
var bottomY;
|
|
|
|
var aspectRatio = 1 / this.source.aspectRatio;
|
|
|
|
if (this.wrapVertical) {
|
|
|
|
topY = $.positiveModulo(topLeftBound.y, aspectRatio);
|
|
|
|
bottomY = $.positiveModulo(bottomRightBound.y, aspectRatio);
|
|
|
|
} else {
|
|
|
|
topY = Math.max(0, topLeftBound.y);
|
|
|
|
bottomY = Math.min(aspectRatio, bottomRightBound.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
var topLeftTile = this.source.getTileAtPoint(level, new $.Point(leftX, topY));
|
|
|
|
var bottomRightTile = this.source.getTileAtPoint(level, new $.Point(rightX, bottomY));
|
|
|
|
var numTiles = this.source.getNumTiles(level);
|
|
|
|
|
|
|
|
if (this.wrapHorizontal) {
|
|
|
|
topLeftTile.x += numTiles.x * Math.floor(topLeftBound.x);
|
|
|
|
bottomRightTile.x += numTiles.x * Math.floor(bottomRightBound.x);
|
|
|
|
}
|
|
|
|
if (this.wrapVertical) {
|
|
|
|
topLeftTile.y += numTiles.y * Math.floor(topLeftBound.y / aspectRatio);
|
|
|
|
bottomRightTile.y += numTiles.y * Math.floor(bottomRightBound.y / aspectRatio);
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
topLeft: topLeftTile,
|
|
|
|
bottomRight: bottomRightTile,
|
|
|
|
};
|
2014-08-07 00:38:56 +04:00
|
|
|
}
|
2016-08-21 20:24:40 +03:00
|
|
|
});
|
2014-08-07 00:38:56 +04:00
|
|
|
|
2016-09-06 02:27:18 +03:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
* Updates all tiles at a given resolution level.
|
|
|
|
* @param {OpenSeadragon.TiledImage} tiledImage - Which TiledImage is being drawn.
|
|
|
|
* @param {Boolean} haveDrawn
|
|
|
|
* @param {Boolean} drawLevel
|
|
|
|
* @param {Number} level
|
|
|
|
* @param {Number} levelOpacity
|
|
|
|
* @param {Number} levelVisibility
|
|
|
|
* @param {OpenSeadragon.Point} viewportTL - The index of the most top-left visible tile.
|
|
|
|
* @param {OpenSeadragon.Point} viewportBR - The index of the most bottom-right visible tile.
|
|
|
|
* @param {Number} currentTime
|
|
|
|
* @param {OpenSeadragon.Tile} best - The current "best" tile to draw.
|
|
|
|
*/
|
2016-08-28 13:10:35 +03:00
|
|
|
function updateLevel(tiledImage, haveDrawn, drawLevel, level, levelOpacity,
|
|
|
|
levelVisibility, drawArea, currentTime, best) {
|
2014-08-07 00:38:56 +04:00
|
|
|
|
2016-08-28 13:10:35 +03:00
|
|
|
var topLeftBound = drawArea.getBoundingBox().getTopLeft();
|
|
|
|
var bottomRightBound = drawArea.getBoundingBox().getBottomRight();
|
2014-08-07 00:38:56 +04:00
|
|
|
|
2016-08-21 20:24:40 +03:00
|
|
|
if (tiledImage.viewer) {
|
2014-08-07 00:38:56 +04:00
|
|
|
/**
|
|
|
|
* <em>- Needs documentation -</em>
|
|
|
|
*
|
|
|
|
* @event update-level
|
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised the event.
|
2014-11-21 03:41:43 +03:00
|
|
|
* @property {OpenSeadragon.TiledImage} tiledImage - Which TiledImage is being drawn.
|
2014-08-07 00:38:56 +04:00
|
|
|
* @property {Object} havedrawn
|
|
|
|
* @property {Object} level
|
|
|
|
* @property {Object} opacity
|
|
|
|
* @property {Object} visibility
|
2016-08-28 13:10:35 +03:00
|
|
|
* @property {OpenSeadragon.Rect} drawArea
|
|
|
|
* @property {Object} topleft deprecated, use drawArea instead
|
|
|
|
* @property {Object} bottomright deprecated, use drawArea instead
|
2014-08-07 00:38:56 +04:00
|
|
|
* @property {Object} currenttime
|
|
|
|
* @property {Object} best
|
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
|
|
|
*/
|
2016-08-21 20:24:40 +03:00
|
|
|
tiledImage.viewer.raiseEvent('update-level', {
|
2014-11-21 03:41:43 +03:00
|
|
|
tiledImage: tiledImage,
|
2014-08-07 00:38:56 +04:00
|
|
|
havedrawn: haveDrawn,
|
|
|
|
level: level,
|
|
|
|
opacity: levelOpacity,
|
|
|
|
visibility: levelVisibility,
|
2016-08-28 13:10:35 +03:00
|
|
|
drawArea: drawArea,
|
|
|
|
topleft: topLeftBound,
|
|
|
|
bottomright: bottomRightBound,
|
2014-08-07 00:38:56 +04:00
|
|
|
currenttime: currentTime,
|
|
|
|
best: best
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-08-21 20:24:40 +03:00
|
|
|
resetCoverage(tiledImage.coverage, level);
|
2014-08-07 00:38:56 +04:00
|
|
|
|
2016-11-01 23:43:00 +03:00
|
|
|
//OK, a new drawing so do your calculations
|
|
|
|
var cornerTiles = tiledImage._getCornerTiles(level, topLeftBound, bottomRightBound);
|
|
|
|
var topLeftTile = cornerTiles.topLeft;
|
|
|
|
var bottomRightTile = cornerTiles.bottomRight;
|
|
|
|
var numberOfTiles = tiledImage.source.getNumTiles(level);
|
2014-08-07 00:38:56 +04:00
|
|
|
|
2016-08-21 20:24:40 +03:00
|
|
|
var viewportCenter = tiledImage.viewport.pixelFromPoint(
|
|
|
|
tiledImage.viewport.getCenter());
|
|
|
|
for (var x = topLeftTile.x; x <= bottomRightTile.x; x++) {
|
|
|
|
for (var y = topLeftTile.y; y <= bottomRightTile.y; y++) {
|
2014-08-07 00:38:56 +04:00
|
|
|
|
2016-10-23 23:25:16 +03:00
|
|
|
// Optimisation disabled with wrapping because getTileBounds does not
|
|
|
|
// work correctly with x and y outside of the number of tiles
|
|
|
|
if (!tiledImage.wrapHorizontal && !tiledImage.wrapVertical) {
|
|
|
|
var tileBounds = tiledImage.source.getTileBounds(level, x, y);
|
|
|
|
if (drawArea.intersection(tileBounds) === null) {
|
|
|
|
// This tile is outside of the viewport, no need to draw it
|
|
|
|
continue;
|
|
|
|
}
|
2016-08-28 13:10:35 +03:00
|
|
|
}
|
2014-08-07 00:38:56 +04:00
|
|
|
|
|
|
|
best = updateTile(
|
2014-08-07 00:48:18 +04:00
|
|
|
tiledImage,
|
2014-08-07 00:38:56 +04:00
|
|
|
drawLevel,
|
|
|
|
haveDrawn,
|
|
|
|
x, y,
|
|
|
|
level,
|
|
|
|
levelOpacity,
|
|
|
|
levelVisibility,
|
|
|
|
viewportCenter,
|
|
|
|
numberOfTiles,
|
|
|
|
currentTime,
|
|
|
|
best
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return best;
|
|
|
|
}
|
|
|
|
|
2016-09-06 02:27:18 +03:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
* Update a single tile at a particular resolution level.
|
|
|
|
* @param {OpenSeadragon.TiledImage} tiledImage - Which TiledImage is being drawn.
|
|
|
|
* @param {Boolean} haveDrawn
|
|
|
|
* @param {Boolean} drawLevel
|
|
|
|
* @param {Number} x
|
|
|
|
* @param {Number} y
|
|
|
|
* @param {Number} level
|
|
|
|
* @param {Number} levelOpacity
|
|
|
|
* @param {Number} levelVisibility
|
|
|
|
* @param {OpenSeadragon.Point} viewportCenter
|
|
|
|
* @param {Number} numberOfTiles
|
|
|
|
* @param {Number} currentTime
|
|
|
|
* @param {OpenSeadragon.Tile} best - The current "best" tile to draw.
|
|
|
|
*/
|
|
|
|
function updateTile( tiledImage, haveDrawn, drawLevel, x, y, level, levelOpacity, levelVisibility, viewportCenter, numberOfTiles, currentTime, best){
|
2014-08-07 00:38:56 +04:00
|
|
|
|
|
|
|
var tile = getTile(
|
|
|
|
x, y,
|
|
|
|
level,
|
2014-08-07 00:48:18 +04:00
|
|
|
tiledImage.source,
|
|
|
|
tiledImage.tilesMatrix,
|
2014-08-07 00:38:56 +04:00
|
|
|
currentTime,
|
|
|
|
numberOfTiles,
|
2014-12-02 22:44:02 +03:00
|
|
|
tiledImage._worldWidthCurrent,
|
|
|
|
tiledImage._worldHeightCurrent
|
2014-08-07 00:38:56 +04:00
|
|
|
),
|
|
|
|
drawTile = drawLevel;
|
|
|
|
|
2014-08-07 00:48:18 +04:00
|
|
|
if( tiledImage.viewer ){
|
2014-08-07 00:38:56 +04:00
|
|
|
/**
|
|
|
|
* <em>- Needs documentation -</em>
|
|
|
|
*
|
|
|
|
* @event update-tile
|
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised the event.
|
2014-11-21 03:41:43 +03:00
|
|
|
* @property {OpenSeadragon.TiledImage} tiledImage - Which TiledImage is being drawn.
|
2014-08-07 00:38:56 +04:00
|
|
|
* @property {OpenSeadragon.Tile} tile
|
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
|
|
|
*/
|
2014-08-07 00:48:18 +04:00
|
|
|
tiledImage.viewer.raiseEvent( 'update-tile', {
|
2014-11-21 03:41:43 +03:00
|
|
|
tiledImage: tiledImage,
|
2014-08-07 00:38:56 +04:00
|
|
|
tile: tile
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-08-07 00:48:18 +04:00
|
|
|
setCoverage( tiledImage.coverage, level, x, y, false );
|
2014-08-07 00:38:56 +04:00
|
|
|
|
|
|
|
if ( !tile.exists ) {
|
|
|
|
return best;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( haveDrawn && !drawTile ) {
|
2014-08-07 00:48:18 +04:00
|
|
|
if ( isCovered( tiledImage.coverage, level, x, y ) ) {
|
|
|
|
setCoverage( tiledImage.coverage, level, x, y, true );
|
2014-08-07 00:38:56 +04:00
|
|
|
} else {
|
|
|
|
drawTile = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !drawTile ) {
|
|
|
|
return best;
|
|
|
|
}
|
|
|
|
|
|
|
|
positionTile(
|
|
|
|
tile,
|
2014-08-07 00:48:18 +04:00
|
|
|
tiledImage.source.tileOverlap,
|
|
|
|
tiledImage.viewport,
|
2014-08-07 00:38:56 +04:00
|
|
|
viewportCenter,
|
|
|
|
levelVisibility,
|
2014-08-07 00:48:18 +04:00
|
|
|
tiledImage
|
2014-08-07 00:38:56 +04:00
|
|
|
);
|
|
|
|
|
2014-11-06 00:48:27 +03:00
|
|
|
if (!tile.loaded) {
|
2015-11-03 03:42:14 +03:00
|
|
|
if (tile.context2D) {
|
|
|
|
setTileLoaded(tiledImage, tile);
|
|
|
|
} else {
|
|
|
|
var imageRecord = tiledImage._tileCache.getImageRecord(tile.url);
|
|
|
|
if (imageRecord) {
|
|
|
|
var image = imageRecord.getImage();
|
|
|
|
setTileLoaded(tiledImage, tile, image);
|
|
|
|
}
|
2014-11-06 00:48:27 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-07 00:38:56 +04:00
|
|
|
if ( tile.loaded ) {
|
2014-12-02 22:44:02 +03:00
|
|
|
var needsDraw = blendTile(
|
2014-08-07 00:48:18 +04:00
|
|
|
tiledImage,
|
2014-08-07 00:38:56 +04:00
|
|
|
tile,
|
|
|
|
x, y,
|
|
|
|
level,
|
|
|
|
levelOpacity,
|
|
|
|
currentTime
|
|
|
|
);
|
|
|
|
|
2014-12-02 22:44:02 +03:00
|
|
|
if ( needsDraw ) {
|
|
|
|
tiledImage._needsDraw = true;
|
2014-08-07 00:38:56 +04:00
|
|
|
}
|
|
|
|
} else if ( tile.loading ) {
|
|
|
|
// the tile is already in the download queue
|
2016-11-05 00:37:48 +03:00
|
|
|
tiledImage._tilesLoading++;
|
2014-08-07 00:38:56 +04:00
|
|
|
} else {
|
|
|
|
best = compareTiles( best, tile );
|
|
|
|
}
|
|
|
|
|
|
|
|
return best;
|
|
|
|
}
|
|
|
|
|
2016-09-06 02:27:18 +03:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
* Obtains a tile at the given location.
|
|
|
|
* @param {Number} x
|
|
|
|
* @param {Number} y
|
|
|
|
* @param {Number} level
|
|
|
|
* @param {OpenSeadragon.TileSource} tileSource
|
|
|
|
* @param {Object} tilesMatrix - A '3d' dictionary [level][x][y] --> Tile.
|
|
|
|
* @param {Number} time
|
|
|
|
* @param {Number} numTiles
|
|
|
|
* @param {Number} worldWidth
|
|
|
|
* @param {Number} worldHeight
|
|
|
|
* @returns {OpenSeadragon.Tile}
|
|
|
|
*/
|
2014-08-07 00:38:56 +04:00
|
|
|
function getTile( x, y, level, tileSource, tilesMatrix, time, numTiles, worldWidth, worldHeight ) {
|
|
|
|
var xMod,
|
|
|
|
yMod,
|
|
|
|
bounds,
|
|
|
|
exists,
|
|
|
|
url,
|
2015-11-03 03:42:14 +03:00
|
|
|
context2D,
|
2014-08-07 00:38:56 +04:00
|
|
|
tile;
|
|
|
|
|
|
|
|
if ( !tilesMatrix[ level ] ) {
|
|
|
|
tilesMatrix[ level ] = {};
|
|
|
|
}
|
|
|
|
if ( !tilesMatrix[ level ][ x ] ) {
|
|
|
|
tilesMatrix[ level ][ x ] = {};
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !tilesMatrix[ level ][ x ][ y ] ) {
|
|
|
|
xMod = ( numTiles.x + ( x % numTiles.x ) ) % numTiles.x;
|
|
|
|
yMod = ( numTiles.y + ( y % numTiles.y ) ) % numTiles.y;
|
|
|
|
bounds = tileSource.getTileBounds( level, xMod, yMod );
|
|
|
|
exists = tileSource.tileExists( level, xMod, yMod );
|
|
|
|
url = tileSource.getTileUrl( level, xMod, yMod );
|
2015-11-03 03:42:14 +03:00
|
|
|
context2D = tileSource.getContext2D ?
|
|
|
|
tileSource.getContext2D(level, xMod, yMod) : undefined;
|
2014-08-07 00:38:56 +04:00
|
|
|
|
2014-11-06 02:24:31 +03:00
|
|
|
bounds.x += ( x - xMod ) / numTiles.x;
|
|
|
|
bounds.y += (worldHeight / worldWidth) * (( y - yMod ) / numTiles.y);
|
2014-08-07 00:38:56 +04:00
|
|
|
|
|
|
|
tilesMatrix[ level ][ x ][ y ] = new $.Tile(
|
|
|
|
level,
|
|
|
|
x,
|
|
|
|
y,
|
|
|
|
bounds,
|
|
|
|
exists,
|
2015-11-03 03:42:14 +03:00
|
|
|
url,
|
|
|
|
context2D
|
2014-08-07 00:38:56 +04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
tile = tilesMatrix[ level ][ x ][ y ];
|
|
|
|
tile.lastTouchTime = time;
|
|
|
|
|
|
|
|
return tile;
|
|
|
|
}
|
|
|
|
|
2016-09-06 02:27:18 +03:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
* Dispatch a job to the ImageLoader to load the Image for a Tile.
|
|
|
|
* @param {OpenSeadragon.TiledImage} tiledImage
|
|
|
|
* @param {OpenSeadragon.Tile} tile
|
|
|
|
* @param {Number} time
|
|
|
|
*/
|
2014-08-07 00:48:18 +04:00
|
|
|
function loadTile( tiledImage, tile, time ) {
|
|
|
|
tile.loading = true;
|
2014-08-12 04:04:20 +04:00
|
|
|
tiledImage._imageLoader.addJob({
|
2014-08-07 00:48:18 +04:00
|
|
|
src: tile.url,
|
|
|
|
crossOriginPolicy: tiledImage.crossOriginPolicy,
|
2015-07-06 23:56:41 +03:00
|
|
|
callback: function( image, errorMsg ){
|
|
|
|
onTileLoad( tiledImage, tile, time, image, errorMsg );
|
2015-03-03 11:29:31 +03:00
|
|
|
},
|
|
|
|
abort: function() {
|
|
|
|
tile.loading = false;
|
2014-08-07 00:48:18 +04:00
|
|
|
}
|
|
|
|
});
|
2014-08-07 00:38:56 +04:00
|
|
|
}
|
|
|
|
|
2016-09-06 02:27:18 +03:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
* Callback fired when a Tile's Image finished downloading.
|
|
|
|
* @param {OpenSeadragon.TiledImage} tiledImage
|
|
|
|
* @param {OpenSeadragon.Tile} tile
|
|
|
|
* @param {Number} time
|
|
|
|
* @param {Image} image
|
|
|
|
* @param {String} errorMsg
|
|
|
|
*/
|
2015-07-06 23:56:41 +03:00
|
|
|
function onTileLoad( tiledImage, tile, time, image, errorMsg ) {
|
2014-11-08 04:13:48 +03:00
|
|
|
if ( !image ) {
|
2015-07-07 00:07:00 +03:00
|
|
|
$.console.log( "Tile %s failed to load: %s - error: %s", tile, tile.url, errorMsg );
|
2015-09-11 23:24:22 +03:00
|
|
|
/**
|
|
|
|
* Triggered when a tile fails to load.
|
|
|
|
*
|
2015-09-15 20:31:43 +03:00
|
|
|
* @event tile-load-failed
|
2015-09-11 23:24:22 +03:00
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
2015-09-15 00:25:30 +03:00
|
|
|
* @property {OpenSeadragon.Tile} tile - The tile that failed to load.
|
2015-09-15 20:31:43 +03:00
|
|
|
* @property {OpenSeadragon.TiledImage} tiledImage - The tiled image the tile belongs to.
|
2015-09-15 00:25:30 +03:00
|
|
|
* @property {number} time - The time in milliseconds when the tile load began.
|
2015-09-11 23:24:22 +03:00
|
|
|
* @property {string} message - The error message.
|
|
|
|
*/
|
2015-09-15 00:25:30 +03:00
|
|
|
tiledImage.viewer.raiseEvent("tile-load-failed", {tile: tile, tiledImage: tiledImage, time: time, message: errorMsg});
|
2015-12-17 01:40:28 +03:00
|
|
|
tile.loading = false;
|
|
|
|
tile.exists = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( time < tiledImage.lastResetTime ) {
|
2014-08-07 00:38:56 +04:00
|
|
|
$.console.log( "Ignoring tile %s loaded before reset: %s", tile, tile.url );
|
2014-11-08 04:13:48 +03:00
|
|
|
tile.loading = false;
|
2014-08-07 00:38:56 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-11-08 04:13:48 +03:00
|
|
|
var finish = function() {
|
2015-05-29 18:49:58 +03:00
|
|
|
var cutoff = Math.ceil( Math.log(
|
2015-06-29 20:42:09 +03:00
|
|
|
tiledImage.source.getTileWidth(tile.level) ) / Math.log( 2 ) );
|
2015-05-29 22:10:47 +03:00
|
|
|
setTileLoaded(tiledImage, tile, image, cutoff);
|
2014-11-08 04:13:48 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
// Check if we're mid-update; this can happen on IE8 because image load events for
|
|
|
|
// cached images happen immediately there
|
2014-12-02 22:44:02 +03:00
|
|
|
if ( !tiledImage._midDraw ) {
|
2014-11-08 04:13:48 +03:00
|
|
|
finish();
|
|
|
|
} else {
|
|
|
|
// Wait until after the update, in case caching unloads any tiles
|
|
|
|
window.setTimeout( finish, 1);
|
|
|
|
}
|
2014-08-07 00:38:56 +04:00
|
|
|
}
|
|
|
|
|
2016-09-06 02:27:18 +03:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
* @param {OpenSeadragon.TiledImage} tiledImage
|
|
|
|
* @param {OpenSeadragon.Tile} tile
|
|
|
|
* @param {Image} image
|
|
|
|
* @param {Number} cutoff
|
|
|
|
*/
|
2015-05-29 22:10:47 +03:00
|
|
|
function setTileLoaded(tiledImage, tile, image, cutoff) {
|
2015-06-02 19:59:38 +03:00
|
|
|
var increment = 0;
|
|
|
|
|
|
|
|
function getCompletionCallback() {
|
|
|
|
increment++;
|
|
|
|
return completionCallback;
|
|
|
|
}
|
|
|
|
|
|
|
|
function completionCallback() {
|
|
|
|
increment--;
|
|
|
|
if (increment === 0) {
|
|
|
|
tile.loading = false;
|
|
|
|
tile.loaded = true;
|
2015-11-03 03:42:14 +03:00
|
|
|
if (!tile.context2D) {
|
|
|
|
tiledImage._tileCache.cacheTile({
|
|
|
|
image: image,
|
|
|
|
tile: tile,
|
|
|
|
cutoff: cutoff,
|
|
|
|
tiledImage: tiledImage
|
|
|
|
});
|
|
|
|
}
|
2015-06-03 21:40:20 +03:00
|
|
|
tiledImage._needsDraw = true;
|
2015-06-02 19:59:38 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Triggered when a tile has just been loaded in memory. That means that the
|
2015-06-03 21:40:20 +03:00
|
|
|
* image has been downloaded and can be modified before being drawn to the canvas.
|
2015-06-02 19:59:38 +03:00
|
|
|
*
|
|
|
|
* @event tile-loaded
|
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {Image} image - The image of the tile.
|
|
|
|
* @property {OpenSeadragon.TiledImage} tiledImage - The tiled image of the loaded tile.
|
|
|
|
* @property {OpenSeadragon.Tile} tile - The tile which has been loaded.
|
|
|
|
* @property {function} getCompletionCallback - A function giving a callback to call
|
|
|
|
* when the asynchronous processing of the image is done. The image will be
|
2015-06-11 17:59:32 +03:00
|
|
|
* marked as entirely loaded when the callback has been called once for each
|
2015-06-03 21:40:20 +03:00
|
|
|
* call to getCompletionCallback.
|
2015-06-02 19:59:38 +03:00
|
|
|
*/
|
2015-05-29 22:10:47 +03:00
|
|
|
tiledImage.viewer.raiseEvent("tile-loaded", {
|
|
|
|
tile: tile,
|
|
|
|
tiledImage: tiledImage,
|
|
|
|
image: image,
|
2015-06-02 19:59:38 +03:00
|
|
|
getCompletionCallback: getCompletionCallback
|
2015-05-29 22:10:47 +03:00
|
|
|
});
|
2015-06-02 19:59:38 +03:00
|
|
|
// In case the completion callback is never called, we at least force it once.
|
|
|
|
getCompletionCallback()();
|
2015-05-29 22:10:47 +03:00
|
|
|
}
|
2014-08-07 00:38:56 +04:00
|
|
|
|
2016-09-06 02:27:18 +03:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
* @param {OpenSeadragon.Tile} tile
|
|
|
|
* @param {Boolean} overlap
|
|
|
|
* @param {OpenSeadragon.Viewport} viewport
|
|
|
|
* @param {OpenSeadragon.Point} viewportCenter
|
|
|
|
* @param {Number} levelVisibility
|
|
|
|
* @param {OpenSeadragon.TiledImage} tiledImage
|
|
|
|
*/
|
2014-08-07 00:48:18 +04:00
|
|
|
function positionTile( tile, overlap, viewport, viewportCenter, levelVisibility, tiledImage ){
|
2014-08-07 00:38:56 +04:00
|
|
|
var boundsTL = tile.bounds.getTopLeft();
|
|
|
|
|
2014-12-02 22:44:02 +03:00
|
|
|
boundsTL.x *= tiledImage._scaleSpring.current.value;
|
|
|
|
boundsTL.y *= tiledImage._scaleSpring.current.value;
|
2014-11-25 04:47:16 +03:00
|
|
|
boundsTL.x += tiledImage._xSpring.current.value;
|
|
|
|
boundsTL.y += tiledImage._ySpring.current.value;
|
2014-08-07 00:38:56 +04:00
|
|
|
|
|
|
|
var boundsSize = tile.bounds.getSize();
|
|
|
|
|
2014-12-02 22:44:02 +03:00
|
|
|
boundsSize.x *= tiledImage._scaleSpring.current.value;
|
|
|
|
boundsSize.y *= tiledImage._scaleSpring.current.value;
|
2014-08-07 00:38:56 +04:00
|
|
|
|
2016-09-02 17:31:36 +03:00
|
|
|
var positionC = viewport.pixelFromPointNoRotate(boundsTL, true),
|
|
|
|
positionT = viewport.pixelFromPointNoRotate(boundsTL, false),
|
|
|
|
sizeC = viewport.deltaPixelsFromPointsNoRotate(boundsSize, true),
|
|
|
|
sizeT = viewport.deltaPixelsFromPointsNoRotate(boundsSize, false),
|
|
|
|
tileCenter = positionT.plus( sizeT.divide( 2 ) ),
|
|
|
|
tileSquaredDistance = viewportCenter.squaredDistanceTo( tileCenter );
|
2014-08-07 00:38:56 +04:00
|
|
|
|
|
|
|
if ( !overlap ) {
|
|
|
|
sizeC = sizeC.plus( new $.Point( 1, 1 ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
tile.position = positionC;
|
|
|
|
tile.size = sizeC;
|
2016-09-02 17:31:36 +03:00
|
|
|
tile.squaredDistance = tileSquaredDistance;
|
2014-08-07 00:38:56 +04:00
|
|
|
tile.visibility = levelVisibility;
|
|
|
|
}
|
|
|
|
|
2016-09-06 02:27:18 +03:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
* Updates the opacity of a tile according to the time it has been on screen
|
|
|
|
* to perform a fade-in.
|
|
|
|
* Updates coverage once a tile is fully opaque.
|
|
|
|
* Returns whether the fade-in has completed.
|
|
|
|
*
|
|
|
|
* @param {OpenSeadragon.TiledImage} tiledImage
|
|
|
|
* @param {OpenSeadragon.Tile} tile
|
|
|
|
* @param {Number} x
|
|
|
|
* @param {Number} y
|
|
|
|
* @param {Number} level
|
|
|
|
* @param {Number} levelOpacity
|
|
|
|
* @param {Number} currentTime
|
|
|
|
* @returns {Boolean}
|
|
|
|
*/
|
2014-08-07 00:48:18 +04:00
|
|
|
function blendTile( tiledImage, tile, x, y, level, levelOpacity, currentTime ){
|
|
|
|
var blendTimeMillis = 1000 * tiledImage.blendTime,
|
2014-08-07 00:38:56 +04:00
|
|
|
deltaTime,
|
|
|
|
opacity;
|
|
|
|
|
|
|
|
if ( !tile.blendStart ) {
|
|
|
|
tile.blendStart = currentTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
deltaTime = currentTime - tile.blendStart;
|
|
|
|
opacity = blendTimeMillis ? Math.min( 1, deltaTime / ( blendTimeMillis ) ) : 1;
|
|
|
|
|
2014-08-07 00:48:18 +04:00
|
|
|
if ( tiledImage.alwaysBlend ) {
|
2014-08-07 00:38:56 +04:00
|
|
|
opacity *= levelOpacity;
|
|
|
|
}
|
|
|
|
|
|
|
|
tile.opacity = opacity;
|
|
|
|
|
2014-08-07 00:48:18 +04:00
|
|
|
tiledImage.lastDrawn.push( tile );
|
2014-08-07 00:38:56 +04:00
|
|
|
|
|
|
|
if ( opacity == 1 ) {
|
2014-08-07 00:48:18 +04:00
|
|
|
setCoverage( tiledImage.coverage, level, x, y, true );
|
2015-09-16 06:52:44 +03:00
|
|
|
tiledImage._hasOpaqueTile = true;
|
2014-08-07 00:38:56 +04:00
|
|
|
} else if ( deltaTime < blendTimeMillis ) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
* Returns true if the given tile provides coverage to lower-level tiles of
|
|
|
|
* lower resolution representing the same content. If neither x nor y is
|
|
|
|
* given, returns true if the entire visible level provides coverage.
|
|
|
|
*
|
|
|
|
* Note that out-of-bounds tiles provide coverage in this sense, since
|
|
|
|
* there's no content that they would need to cover. Tiles at non-existent
|
|
|
|
* levels that are within the image bounds, however, do not.
|
2016-09-06 02:27:18 +03:00
|
|
|
*
|
|
|
|
* @param {Object} coverage - A '3d' dictionary [level][x][y] --> Boolean.
|
|
|
|
* @param {Number} level - The resolution level of the tile.
|
|
|
|
* @param {Number} x - The X position of the tile.
|
|
|
|
* @param {Number} y - The Y position of the tile.
|
|
|
|
* @returns {Boolean}
|
2014-08-07 00:38:56 +04:00
|
|
|
*/
|
|
|
|
function providesCoverage( coverage, level, x, y ) {
|
|
|
|
var rows,
|
|
|
|
cols,
|
|
|
|
i, j;
|
|
|
|
|
|
|
|
if ( !coverage[ level ] ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( x === undefined || y === undefined ) {
|
|
|
|
rows = coverage[ level ];
|
|
|
|
for ( i in rows ) {
|
|
|
|
if ( rows.hasOwnProperty( i ) ) {
|
|
|
|
cols = rows[ i ];
|
|
|
|
for ( j in cols ) {
|
|
|
|
if ( cols.hasOwnProperty( j ) && !cols[ j ] ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
coverage[ level ][ x] === undefined ||
|
|
|
|
coverage[ level ][ x ][ y ] === undefined ||
|
|
|
|
coverage[ level ][ x ][ y ] === true
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
* Returns true if the given tile is completely covered by higher-level
|
|
|
|
* tiles of higher resolution representing the same content. If neither x
|
|
|
|
* nor y is given, returns true if the entire visible level is covered.
|
2016-09-06 02:27:18 +03:00
|
|
|
*
|
|
|
|
* @param {Object} coverage - A '3d' dictionary [level][x][y] --> Boolean.
|
|
|
|
* @param {Number} level - The resolution level of the tile.
|
|
|
|
* @param {Number} x - The X position of the tile.
|
|
|
|
* @param {Number} y - The Y position of the tile.
|
|
|
|
* @returns {Boolean}
|
2014-08-07 00:38:56 +04:00
|
|
|
*/
|
|
|
|
function isCovered( coverage, level, x, y ) {
|
|
|
|
if ( x === undefined || y === undefined ) {
|
|
|
|
return providesCoverage( coverage, level + 1 );
|
|
|
|
} else {
|
|
|
|
return (
|
|
|
|
providesCoverage( coverage, level + 1, 2 * x, 2 * y ) &&
|
|
|
|
providesCoverage( coverage, level + 1, 2 * x, 2 * y + 1 ) &&
|
|
|
|
providesCoverage( coverage, level + 1, 2 * x + 1, 2 * y ) &&
|
|
|
|
providesCoverage( coverage, level + 1, 2 * x + 1, 2 * y + 1 )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
* Sets whether the given tile provides coverage or not.
|
2016-09-06 02:27:18 +03:00
|
|
|
*
|
|
|
|
* @param {Object} coverage - A '3d' dictionary [level][x][y] --> Boolean.
|
|
|
|
* @param {Number} level - The resolution level of the tile.
|
|
|
|
* @param {Number} x - The X position of the tile.
|
|
|
|
* @param {Number} y - The Y position of the tile.
|
|
|
|
* @param {Boolean} covers - Whether the tile provides coverage.
|
2014-08-07 00:38:56 +04:00
|
|
|
*/
|
|
|
|
function setCoverage( coverage, level, x, y, covers ) {
|
|
|
|
if ( !coverage[ level ] ) {
|
|
|
|
$.console.warn(
|
|
|
|
"Setting coverage for a tile before its level's coverage has been reset: %s",
|
|
|
|
level
|
|
|
|
);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !coverage[ level ][ x ] ) {
|
|
|
|
coverage[ level ][ x ] = {};
|
|
|
|
}
|
|
|
|
|
|
|
|
coverage[ level ][ x ][ y ] = covers;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
* Resets coverage information for the given level. This should be called
|
|
|
|
* after every draw routine. Note that at the beginning of the next draw
|
|
|
|
* routine, coverage for every visible tile should be explicitly set.
|
2016-09-06 02:27:18 +03:00
|
|
|
*
|
|
|
|
* @param {Object} coverage - A '3d' dictionary [level][x][y] --> Boolean.
|
|
|
|
* @param {Number} level - The resolution level of tiles to completely reset.
|
2014-08-07 00:38:56 +04:00
|
|
|
*/
|
|
|
|
function resetCoverage( coverage, level ) {
|
|
|
|
coverage[ level ] = {};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
* Determines whether the 'last best' tile for the area is better than the
|
|
|
|
* tile in question.
|
2016-09-06 02:27:18 +03:00
|
|
|
*
|
|
|
|
* @param {OpenSeadragon.Tile} previousBest
|
|
|
|
* @param {OpenSeadragon.Tile} tile
|
|
|
|
* @returns {OpenSeadragon.Tile} The new best tile.
|
2014-08-07 00:38:56 +04:00
|
|
|
*/
|
|
|
|
function compareTiles( previousBest, tile ) {
|
|
|
|
if ( !previousBest ) {
|
|
|
|
return tile;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( tile.visibility > previousBest.visibility ) {
|
|
|
|
return tile;
|
|
|
|
} else if ( tile.visibility == previousBest.visibility ) {
|
2016-09-02 17:31:36 +03:00
|
|
|
if ( tile.squaredDistance < previousBest.squaredDistance ) {
|
2014-08-07 00:38:56 +04:00
|
|
|
return tile;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return previousBest;
|
|
|
|
}
|
|
|
|
|
2016-09-06 02:27:18 +03:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
* Draws a TiledImage.
|
|
|
|
* @param {OpenSeadragon.TiledImage} tiledImage
|
|
|
|
* @param {OpenSeadragon.Tile[]} lastDrawn - An unordered list of Tiles drawn last frame.
|
|
|
|
*/
|
2015-04-09 14:44:55 +03:00
|
|
|
function drawTiles( tiledImage, lastDrawn ) {
|
2016-02-25 03:48:11 +03:00
|
|
|
if (lastDrawn.length === 0) {
|
2015-04-19 23:10:37 +03:00
|
|
|
return;
|
|
|
|
}
|
2016-02-25 03:48:11 +03:00
|
|
|
var tile = lastDrawn[0];
|
|
|
|
|
2016-01-20 20:14:10 +03:00
|
|
|
var useSketch = tiledImage.opacity < 1 ||
|
2016-02-24 03:37:41 +03:00
|
|
|
(tiledImage.compositeOperation &&
|
|
|
|
tiledImage.compositeOperation !== 'source-over') ||
|
2016-02-25 03:53:35 +03:00
|
|
|
(!tiledImage._isBottomItem() && tile._hasTransparencyChannel());
|
2016-01-20 20:14:10 +03:00
|
|
|
|
2015-11-05 17:19:56 +03:00
|
|
|
var sketchScale;
|
|
|
|
var sketchTranslate;
|
2015-11-04 18:04:50 +03:00
|
|
|
|
2015-11-05 17:19:56 +03:00
|
|
|
var zoom = tiledImage.viewport.getZoom(true);
|
2015-11-04 18:04:50 +03:00
|
|
|
var imageZoom = tiledImage.viewportToImageZoom(zoom);
|
2016-10-23 18:45:39 +03:00
|
|
|
// TODO: support tile edge smoothing with tiled image rotation.
|
2017-01-07 21:56:37 +03:00
|
|
|
if (lastDrawn.length > 1 &&
|
|
|
|
imageZoom > tiledImage.smoothTileEdgesMinZoom &&
|
|
|
|
!tiledImage.iOSDevice &&
|
|
|
|
tiledImage.getRotation() === 0 &&
|
|
|
|
$.supportsCanvas) {
|
2015-11-04 18:04:50 +03:00
|
|
|
// When zoomed in a lot (>100%) the tile edges are visible.
|
|
|
|
// So we have to composite them at ~100% and scale them up together.
|
2016-06-17 09:32:50 +03:00
|
|
|
// Note: Disabled on iOS devices per default as it causes a native crash
|
2015-11-04 18:04:50 +03:00
|
|
|
useSketch = true;
|
2015-11-05 17:19:56 +03:00
|
|
|
sketchScale = tile.getScaleForEdgeSmoothing();
|
2016-01-24 02:40:53 +03:00
|
|
|
sketchTranslate = tile.getTranslationForEdgeSmoothing(sketchScale,
|
|
|
|
tiledImage._drawer.getCanvasSize(false),
|
|
|
|
tiledImage._drawer.getCanvasSize(true));
|
2015-11-04 18:04:50 +03:00
|
|
|
}
|
|
|
|
|
2016-04-27 18:08:44 +03:00
|
|
|
var bounds;
|
|
|
|
if (useSketch) {
|
|
|
|
if (!sketchScale) {
|
|
|
|
// Except when edge smoothing, we only clean the part of the
|
|
|
|
// sketch canvas we are going to use for performance reasons.
|
|
|
|
bounds = tiledImage.viewport.viewportToViewerElementRectangle(
|
2016-04-28 18:26:09 +03:00
|
|
|
tiledImage.getClippedBounds(true))
|
|
|
|
.getIntegerBoundingBox()
|
|
|
|
.times($.pixelDensityRatio);
|
2016-04-27 18:08:44 +03:00
|
|
|
}
|
|
|
|
tiledImage._drawer._clear(true, bounds);
|
2015-04-23 01:30:49 +03:00
|
|
|
}
|
2015-04-08 22:45:38 +03:00
|
|
|
|
2016-08-17 16:43:08 +03:00
|
|
|
// When scaling, we must rotate only when blending the sketch canvas to
|
|
|
|
// avoid interpolation
|
|
|
|
if (!sketchScale) {
|
|
|
|
if (tiledImage.viewport.degrees !== 0) {
|
2016-10-24 23:03:31 +03:00
|
|
|
tiledImage._drawer._offsetForRotation({
|
|
|
|
degrees: tiledImage.viewport.degrees,
|
|
|
|
useSketch: useSketch
|
|
|
|
});
|
2016-08-17 16:43:08 +03:00
|
|
|
}
|
2016-08-21 13:54:33 +03:00
|
|
|
if (tiledImage._degrees !== 0) {
|
2016-10-24 23:03:31 +03:00
|
|
|
tiledImage._drawer._offsetForRotation({
|
|
|
|
degrees: tiledImage._degrees,
|
|
|
|
point: tiledImage.viewport.pixelFromPointNoRotate(
|
2016-08-28 13:10:35 +03:00
|
|
|
tiledImage._getRotationPoint(true), true),
|
2016-10-24 23:03:31 +03:00
|
|
|
useSketch: useSketch
|
|
|
|
});
|
2016-08-17 16:43:08 +03:00
|
|
|
}
|
2015-12-12 03:07:23 +03:00
|
|
|
}
|
|
|
|
|
2015-04-13 20:02:04 +03:00
|
|
|
var usedClip = false;
|
2015-04-08 22:45:38 +03:00
|
|
|
if ( tiledImage._clip ) {
|
2015-04-19 23:10:37 +03:00
|
|
|
tiledImage._drawer.saveContext(useSketch);
|
2015-04-08 22:45:38 +03:00
|
|
|
|
2015-04-09 20:57:55 +03:00
|
|
|
var box = tiledImage.imageToViewportRectangle(tiledImage._clip, true);
|
2016-08-28 13:10:35 +03:00
|
|
|
box = box.rotate(-tiledImage._degrees, tiledImage._getRotationPoint());
|
2015-04-09 20:57:55 +03:00
|
|
|
var clipRect = tiledImage._drawer.viewportToDrawerRectangle(box);
|
2015-11-05 17:31:13 +03:00
|
|
|
if (sketchScale) {
|
|
|
|
clipRect = clipRect.times(sketchScale);
|
|
|
|
}
|
|
|
|
if (sketchTranslate) {
|
|
|
|
clipRect = clipRect.translate(sketchTranslate);
|
|
|
|
}
|
2015-04-19 23:10:37 +03:00
|
|
|
tiledImage._drawer.setClip(clipRect, useSketch);
|
2015-04-13 20:02:04 +03:00
|
|
|
|
|
|
|
usedClip = true;
|
2015-04-08 21:14:13 +03:00
|
|
|
}
|
|
|
|
|
2015-09-16 06:52:44 +03:00
|
|
|
if ( tiledImage.placeholderFillStyle && tiledImage._hasOpaqueTile === false ) {
|
2015-04-09 20:57:55 +03:00
|
|
|
var placeholderRect = tiledImage._drawer.viewportToDrawerRectangle(tiledImage.getBounds(true));
|
2015-11-05 17:31:13 +03:00
|
|
|
if (sketchScale) {
|
|
|
|
placeholderRect = placeholderRect.times(sketchScale);
|
|
|
|
}
|
|
|
|
if (sketchTranslate) {
|
|
|
|
placeholderRect = placeholderRect.translate(sketchTranslate);
|
|
|
|
}
|
2015-04-15 14:32:41 +03:00
|
|
|
|
|
|
|
var fillStyle = null;
|
|
|
|
if ( typeof tiledImage.placeholderFillStyle === "function" ) {
|
|
|
|
fillStyle = tiledImage.placeholderFillStyle(tiledImage, tiledImage._drawer.context);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fillStyle = tiledImage.placeholderFillStyle;
|
|
|
|
}
|
|
|
|
|
2015-04-19 23:10:37 +03:00
|
|
|
tiledImage._drawer.drawRectangle(placeholderRect, fillStyle, useSketch);
|
2015-03-18 20:03:44 +03:00
|
|
|
}
|
|
|
|
|
2016-02-25 03:48:11 +03:00
|
|
|
for (var i = lastDrawn.length - 1; i >= 0; i--) {
|
2014-08-07 00:38:56 +04:00
|
|
|
tile = lastDrawn[ i ];
|
2015-11-05 17:19:56 +03:00
|
|
|
tiledImage._drawer.drawTile( tile, tiledImage._drawingHandler, useSketch, sketchScale, sketchTranslate );
|
2014-08-07 00:48:18 +04:00
|
|
|
tile.beingDrawn = true;
|
2014-08-07 00:38:56 +04:00
|
|
|
|
2014-08-07 00:48:18 +04:00
|
|
|
if( tiledImage.viewer ){
|
2014-08-07 00:38:56 +04:00
|
|
|
/**
|
|
|
|
* <em>- Needs documentation -</em>
|
|
|
|
*
|
|
|
|
* @event tile-drawn
|
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised the event.
|
2014-11-21 03:41:43 +03:00
|
|
|
* @property {OpenSeadragon.TiledImage} tiledImage - Which TiledImage is being drawn.
|
2014-08-07 00:38:56 +04:00
|
|
|
* @property {OpenSeadragon.Tile} tile
|
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
|
|
|
*/
|
2014-08-07 00:48:18 +04:00
|
|
|
tiledImage.viewer.raiseEvent( 'tile-drawn', {
|
2014-11-21 03:41:43 +03:00
|
|
|
tiledImage: tiledImage,
|
2014-08-07 00:38:56 +04:00
|
|
|
tile: tile
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2015-03-18 20:03:44 +03:00
|
|
|
|
2015-04-13 20:02:04 +03:00
|
|
|
if ( usedClip ) {
|
2015-04-19 23:10:37 +03:00
|
|
|
tiledImage._drawer.restoreContext( useSketch );
|
|
|
|
}
|
|
|
|
|
2016-08-17 16:43:08 +03:00
|
|
|
if (!sketchScale) {
|
2016-08-21 13:54:33 +03:00
|
|
|
if (tiledImage._degrees !== 0) {
|
2016-08-17 16:43:08 +03:00
|
|
|
tiledImage._drawer._restoreRotationChanges(useSketch);
|
|
|
|
}
|
|
|
|
if (tiledImage.viewport.degrees !== 0) {
|
|
|
|
tiledImage._drawer._restoreRotationChanges(useSketch);
|
|
|
|
}
|
2015-12-12 03:07:23 +03:00
|
|
|
}
|
|
|
|
|
2016-01-24 02:40:53 +03:00
|
|
|
if (useSketch) {
|
2016-08-17 16:43:08 +03:00
|
|
|
if (sketchScale) {
|
|
|
|
if (tiledImage.viewport.degrees !== 0) {
|
2016-10-24 23:03:31 +03:00
|
|
|
tiledImage._drawer._offsetForRotation({
|
|
|
|
degrees: tiledImage.viewport.degrees,
|
|
|
|
useSketch: false
|
|
|
|
});
|
2016-08-17 16:43:08 +03:00
|
|
|
}
|
2016-08-21 13:54:33 +03:00
|
|
|
if (tiledImage._degrees !== 0) {
|
2016-10-24 23:03:31 +03:00
|
|
|
tiledImage._drawer._offsetForRotation({
|
|
|
|
degrees: tiledImage._degrees,
|
|
|
|
point: tiledImage.viewport.pixelFromPointNoRotate(
|
2016-08-28 13:10:35 +03:00
|
|
|
tiledImage._getRotationPoint(true), true),
|
2016-10-24 23:03:31 +03:00
|
|
|
useSketch: false
|
|
|
|
});
|
2016-08-17 16:43:08 +03:00
|
|
|
}
|
2016-01-24 02:40:53 +03:00
|
|
|
}
|
2016-04-27 18:08:44 +03:00
|
|
|
tiledImage._drawer.blendSketch({
|
|
|
|
opacity: tiledImage.opacity,
|
|
|
|
scale: sketchScale,
|
|
|
|
translate: sketchTranslate,
|
|
|
|
compositeOperation: tiledImage.compositeOperation,
|
|
|
|
bounds: bounds
|
|
|
|
});
|
2016-08-17 16:43:08 +03:00
|
|
|
if (sketchScale) {
|
2016-08-21 13:54:33 +03:00
|
|
|
if (tiledImage._degrees !== 0) {
|
2016-08-17 16:43:08 +03:00
|
|
|
tiledImage._drawer._restoreRotationChanges(false);
|
|
|
|
}
|
|
|
|
if (tiledImage.viewport.degrees !== 0) {
|
|
|
|
tiledImage._drawer._restoreRotationChanges(false);
|
|
|
|
}
|
2016-01-24 02:40:53 +03:00
|
|
|
}
|
2015-04-21 02:25:36 +03:00
|
|
|
}
|
|
|
|
drawDebugInfo( tiledImage, lastDrawn );
|
|
|
|
}
|
|
|
|
|
2016-09-06 02:27:18 +03:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
* Draws special debug information for a TiledImage if in debug mode.
|
|
|
|
* @param {OpenSeadragon.TiledImage} tiledImage
|
|
|
|
* @param {OpenSeadragon.Tile[]} lastDrawn - An unordered list of Tiles drawn last frame.
|
|
|
|
*/
|
2015-04-21 02:25:36 +03:00
|
|
|
function drawDebugInfo( tiledImage, lastDrawn ) {
|
|
|
|
if( tiledImage.debugMode ) {
|
|
|
|
for ( var i = lastDrawn.length - 1; i >= 0; i-- ) {
|
|
|
|
var tile = lastDrawn[ i ];
|
|
|
|
try {
|
2016-08-17 16:43:08 +03:00
|
|
|
tiledImage._drawer.drawDebugInfo(
|
|
|
|
tile, lastDrawn.length, i, tiledImage);
|
2015-04-21 02:25:36 +03:00
|
|
|
} catch(e) {
|
|
|
|
$.console.error(e);
|
|
|
|
}
|
|
|
|
}
|
2015-03-18 20:03:44 +03:00
|
|
|
}
|
2014-08-07 00:38:56 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
}( OpenSeadragon ));
|