# HG changeset patch # User robcast # Date 1389877233 -3600 # Node ID 29c97a4e266e86800675512e0df8c201beb7e6b3 # Parent 8cb0faad875a933c473f7677b8e543855ffa4c4e small fixes. diff -r 8cb0faad875a -r 29c97a4e266e webapp/src/main/webapp/jquery/jquery.digilib.js --- 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, diff -r 8cb0faad875a -r 29c97a4e266e webapp/src/main/webapp/jquery/jquery.digilib.measure.js --- 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 = $(''); @@ -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 @@ '; var $toolbar = $(html); data.$elem.append($toolbar); - data.settings.$toolbar = $toolbar; + data.$toolbar = $toolbar; loadShapes(data); loadSections(data); return $toolbar; diff -r 8cb0faad875a -r 29c97a4e266e webapp/src/main/webapp/jquery/jquery.digilib.vector.js --- 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)