Mercurial > hg > digilib
changeset 1245:29c97a4e266e
small fixes.
author | robcast |
---|---|
date | Thu, 16 Jan 2014 14:00:33 +0100 |
parents | 8cb0faad875a |
children | 778c099c6b4c |
files | webapp/src/main/webapp/jquery/jquery.digilib.js webapp/src/main/webapp/jquery/jquery.digilib.measure.js webapp/src/main/webapp/jquery/jquery.digilib.vector.js |
diffstat | 3 files changed, 39 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/webapp/src/main/webapp/jquery/jquery.digilib.js Wed Jan 15 22:32:42 2014 +0100 +++ b/webapp/src/main/webapp/jquery/jquery.digilib.js Thu Jan 16 14:00:33 2014 +0100 @@ -1579,6 +1579,39 @@ } }; + /** + * calculates the distance between two points (in relative cooordinates). + * + * Returns the distance in (current) screen pixels, original pixels and + * original size (in meter) (if available). + * + * @param data + * @param p1 point in relative coordinates + * @param p2 point in relative coordinates + * @returns { pixel: X, o_pixel: Y, o_size: Z} + * + */ + var getDistance = function (data, p1, p2) { + var dist = {}; + if (data.imgTrafo != null) { + var pt1 = data.imgTrafo.transform(p1); + var pt2 = data.imgTrafo.transform(p2); + dist['pixel'] = pt1.distance(pt2); + if (data.imgInfo != null && data.imgInfo.width != null) { + // use original pixel size + var odx = (p2.x - p1.x) * data.imgInfo.width; + var ody = (p2.y - p1.y) * data.imgInfo.height; + var opd = Math.sqrt(odx * odx + ody * ody); + dist['o_pixel'] = opd; + if (data.imgInfo.dpi_x != null) { + // use original dpi + dist['o_size'] = opd / data.imgInfo.dpi_x * 0.0254; + } + } + } + return dist; + }; + /** sets a key to a value (relative values with +/- if relative=true). * */ @@ -1756,6 +1789,7 @@ isFullArea : isFullArea, isNumber : isNumber, getFullscreenRect : getFullscreenRect, + getDistance : getDistance, getBorderWidth : getBorderWidth, cropFloat : cropFloat, cropFloatStr : cropFloatStr,
--- a/webapp/src/main/webapp/jquery/jquery.digilib.measure.js Wed Jan 15 22:32:42 2014 +0100 +++ b/webapp/src/main/webapp/jquery/jquery.digilib.measure.js Thu Jan 16 14:00:33 2014 +0100 @@ -748,7 +748,7 @@ var actions = { toolbar : function(data) { - var $toolbar = data.settings.$toolbar; + var $toolbar = data.$toolbar; if (!$toolbar) { $toolbar = setupToolbar(data); }; @@ -763,7 +763,7 @@ // load shapes into select element var loadShapes = function(data) { - var $t = data.settings.$toolbar; + var $t = data.$toolbar; var $shape = $t.find('#measure-shapes'); $.each(data.settings.shapes, function(index, name) { var $opt = $('<option value="'+index+'">'+name+'</option>'); @@ -773,7 +773,7 @@ // load units into select elements var loadSections = function(data) { - var $t = data.settings.$toolbar; + var $t = data.$toolbar; var $unit1 = $t.find('#measure-unit1'); var $unit2 = $t.find('#measure-unit2'); var sections = data.settings.units.sections; @@ -817,7 +817,7 @@ </div>'; var $toolbar = $(html); data.$elem.append($toolbar); - data.settings.$toolbar = $toolbar; + data.$toolbar = $toolbar; loadShapes(data); loadSections(data); return $toolbar;
--- a/webapp/src/main/webapp/jquery/jquery.digilib.vector.js Wed Jan 15 22:32:42 2014 +0100 +++ b/webapp/src/main/webapp/jquery/jquery.digilib.vector.js Thu Jan 16 14:00:33 2014 +0100 @@ -204,7 +204,7 @@ var handleUpdate = function (evt) { console.debug("vector: handleUpdate"); var data = this; - if (data.imgRect != null) { + if (data.imgRect != null && data.$svg != null) { // adjust svg element size and position (doesn't work with .adjustDiv()) data.$svg.css(data.imgRect.getAsCss()); // adjust zoom statue (use DOM setAttribute because jQuery lowercases attributes)