Mercurial > hg > digilib
changeset 1269:a08a513f711c
added measure button, renamed some vars and methods
author | hertzhaft |
---|---|
date | Fri, 24 Jan 2014 15:26:42 +0100 |
parents | 0b04336453cb |
children | 3ab98c1847b7 |
files | webapp/src/main/webapp/jquery/img/fullscreen/32/measure.png webapp/src/main/webapp/jquery/img/fullscreen3.svg webapp/src/main/webapp/jquery/img/make_icon.cmd webapp/src/main/webapp/jquery/jquery.digilib.measure.js |
diffstat | 4 files changed, 166 insertions(+), 81 deletions(-) [+] |
line wrap: on
line diff
--- a/webapp/src/main/webapp/jquery/img/fullscreen3.svg Wed Jan 22 21:04:57 2014 +0100 +++ b/webapp/src/main/webapp/jquery/img/fullscreen3.svg Fri Jan 24 15:26:42 2014 +0100 @@ -120,21 +120,21 @@ inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="16" - inkscape:cx="9.150834" - inkscape:cy="12.945999" - inkscape:current-layer="g3379" + inkscape:cx="4.0072005" + inkscape:cy="23.109701" + inkscape:current-layer="layer7" showgrid="true" inkscape:grid-bbox="true" inkscape:document-units="px" - inkscape:window-width="1315" - inkscape:window-height="837" - inkscape:window-x="1436" + inkscape:window-width="1440" + inkscape:window-height="881" + inkscape:window-x="-4" inkscape:window-y="-4" inkscape:window-maximized="1" showguides="true" inkscape:guide-bbox="true" inkscape:snap-object-midpoints="true" - inkscape:snap-bbox="false" + inkscape:snap-bbox="true" inkscape:snap-grids="false" inkscape:snap-global="true" inkscape:snap-nodes="true" @@ -194,7 +194,7 @@ sodipodi:insensitive="true"> <path transform="matrix(0.87955865,0,0,0.86576173,-2.7623298,1.2980787)" - d="m 48.142857,26.214285 c 0,10.059472 -8.026895,18.214285 -17.928572,18.214285 -9.901677,0 -17.928572,-8.154813 -17.928572,-18.214285 C 12.285713,16.154813 20.312608,8 30.214285,8 c 9.901677,0 17.928572,8.154813 17.928572,18.214285 z" + d="m 48.142857,26.214285 a 17.928572,18.214285 0 1 1 -35.857144,0 17.928572,18.214285 0 1 1 35.857144,0 z" sodipodi:ry="18.214285" sodipodi:rx="17.928572" sodipodi:cy="26.214285" @@ -846,7 +846,7 @@ sodipodi:cy="16.857143" sodipodi:rx="6" sodipodi:ry="5.5714288" - d="m 24.857143,16.857143 a 6,5.5714288 0 1 1 -12,0 6,5.5714288 0 1 1 12,0 z" + d="m 24.857143,16.857143 c 0,3.077016 -2.686291,5.571429 -6,5.571429 -3.313708,0 -6,-2.494413 -6,-5.571429 0,-3.077015 2.686292,-5.571428 6,-5.571428 3.313709,0 6,2.494413 6,5.571428 z" transform="matrix(1.088683,0,0,1.172638,-8.8022,17.946136)" /> </g> </g> @@ -1638,7 +1638,7 @@ sodipodi:cy="19.714285" sodipodi:rx="10.428572" sodipodi:ry="10.142858" - d="m 37.571428,19.714285 c 0,5.601745 -4.66903,10.142857 -10.428571,10.142857 -5.759542,0 -10.428572,-4.541112 -10.428572,-10.142857 0,-5.601746 4.66903,-10.1428577 10.428572,-10.1428577 5.759541,0 10.428571,4.5411117 10.428571,10.1428577 z" + d="m 37.571428,19.714285 a 10.428572,10.142858 0 1 1 -20.857143,0 10.428572,10.142858 0 1 1 20.857143,0 z" transform="matrix(0.86721436,0,0,0.90813654,0.46798366,6.0967375)" /> <path style="fill:none;stroke:#000000;stroke-width:4.10256433;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;display:inline" @@ -1658,4 +1658,98 @@ id="tspan7328" sodipodi:role="line">+</tspan></text> </g> + <g + inkscape:groupmode="layer" + id="layer7" + inkscape:label="measure" + style="display:none" + sodipodi:insensitive="true"> + <path + style="color:#000000;fill:#008000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.39999998;marker:none;visibility:visible;display:inline;overflow:visible" + d="M 4.065864,25.989592 C 16.010855,2.4340977 16.010855,2.3457094 16.010855,2.3457094 l 0,5.7010484 z" + id="path5922" + inkscape:connector-curvature="0" /> + <path + inkscape:connector-curvature="0" + id="path5924" + d="M 4.065864,25.989592 C 16.010855,2.4340977 16.010855,2.3457094 16.010855,2.3457094 l 0,5.7010484 z" + style="color:#000000;fill:#008000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.39999998;marker:none;visibility:visible;display:inline;overflow:visible" /> + <path + style="color:#000000;fill:#008000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.39999998;marker:none;visibility:visible;display:inline;overflow:visible" + d="M 27.955846,26.033786 C 16.010855,2.4782919 16.010855,2.3899036 16.010855,2.3899036 l 0,5.7010484 z" + id="path5926" + inkscape:connector-curvature="0" /> + <rect + style="color:#000000;fill:#008000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.39999998;marker:none;visibility:visible;display:inline;overflow:visible" + id="rect5932" + width="3.3587573" + height="2.1213202" + x="14.760854" + y="7.604816" /> + <rect + style="color:#000000;fill:#808080;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.39999998;marker:none;visibility:visible;display:inline;overflow:visible" + id="rect5944" + width="2.0108349" + height="1.0606601" + x="6.0104074" + y="25.017321" /> + <rect + y="25.017321" + x="9.0156116" + height="1.0606601" + width="2.0108349" + id="rect5946" + style="color:#000000;fill:#808080;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.39999998;marker:none;visibility:visible;display:inline;overflow:visible" /> + <rect + style="color:#000000;fill:#808080;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.39999998;marker:none;visibility:visible;display:inline;overflow:visible" + id="rect5948" + width="2.0108349" + height="1.0606601" + x="9.0156116" + y="25.017321" /> + <rect + y="24.995224" + x="12.000234" + height="1.0606601" + width="2.0108349" + id="rect5950" + style="color:#000000;fill:#808080;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.39999998;marker:none;visibility:visible;display:inline;overflow:visible" /> + <rect + y="24.995224" + x="15.005438" + height="1.0606601" + width="2.0108349" + id="rect5952" + style="color:#000000;fill:#808080;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.39999998;marker:none;visibility:visible;display:inline;overflow:visible" /> + <rect + style="color:#000000;fill:#808080;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.39999998;marker:none;visibility:visible;display:inline;overflow:visible" + id="rect5954" + width="2.0108349" + height="1.0606601" + x="18.010641" + y="24.973127" /> + <rect + style="color:#000000;fill:#808080;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.39999998;marker:none;visibility:visible;display:inline;overflow:visible" + id="rect5956" + width="2.0108349" + height="1.0606601" + x="21.015846" + y="24.973127" /> + <rect + y="24.973127" + x="23.998953" + height="1.0606601" + width="2.0108349" + id="rect5958" + style="color:#000000;fill:#808080;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.39999998;marker:none;visibility:visible;display:inline;overflow:visible" /> + <path + sodipodi:type="arc" + style="color:#000000;fill:#008000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.39999998;marker:none;visibility:visible;display:inline;overflow:visible" + id="path5962" + sodipodi:cx="16.010855" + sodipodi:cy="4" + sodipodi:rx="2.4375" + sodipodi:ry="2.4375" + d="m 18.448355,4 a 2.4375,2.4375 0 1 1 -4.875,0 2.4375,2.4375 0 1 1 4.875,0 z" /> + </g> </svg>
--- a/webapp/src/main/webapp/jquery/img/make_icon.cmd Wed Jan 22 21:04:57 2014 +0100 +++ b/webapp/src/main/webapp/jquery/img/make_icon.cmd Fri Jan 24 15:26:42 2014 +0100 @@ -3,9 +3,9 @@ rem saxon embedded.svg embedded_icons.xsl -set ink=C:\prog_mr\inkscape-0.48.1\inkscape.exe +set ink=U:\programme\inkscape\inkscape.exe -%ink% embedded\svg\%1.svg --export-png=embedded\16\%1.png -w16 -h16 -%ink% embedded\svg\%1.svg --export-png=embedded\32\%1.png -w32 -h32 +%ink% fullscreen\svg_gen\%1.svg --export-png=fullscreen\16\%1.png -w16 -h16 +%ink% fullscreen\svg_gen\%1.svg --export-png=fullscreen\32\%1.png -w32 -h32 endlocal \ No newline at end of file
--- a/webapp/src/main/webapp/jquery/jquery.digilib.measure.js Wed Jan 22 21:04:57 2014 +0100 +++ b/webapp/src/main/webapp/jquery/jquery.digilib.measure.js Fri Jan 24 15:26:42 2014 +0100 @@ -677,10 +677,10 @@ }] }; var buttons = { - showtoolbar : { - onclick : "showtoolbar", - tooltip : "show toolbar", - icon : "showregions.png" + measure : { + onclick : "measurebar", + tooltip : "show the measuring toolbar", + icon : "measure.png" }, drawshape : { onclick : "drawshape", @@ -690,10 +690,10 @@ var defaults = { // buttonset of this plugin - measureButtonSet : ['showtoolbar'], + measureButtonSet : ['measurebar'], // unit data units : UNITS, - // choice of colors offered by toolbar + // choice of colors offered by measure bar lineColors : ['white', 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'violet', 'black'], // default color lineColor : 'red', @@ -756,31 +756,33 @@ }; var actions = { - showtoolbar : function(data) { - var $toolbar = data.$toolbar; - if (!$toolbar) { - $toolbar = setupToolbar(data); + measurebar : function(data) { + var $measureBar = data.$measureBar; + if (!$measureBar) { + $measureBar = setupMeasureBar(data); }; - $toolbar.toggle(); - setScreenPosition(data, $toolbar); + $measureBar.toggle(); + setScreenPosition(data, $measureBar); return; }, drawshape : function(data) { var shape = currentShape(data); - data.tbWidgets.draw.addClass('dl-drawing') + data.measureWidgets.draw.addClass('dl-drawing') digilib.actions.addShape(data, shape, onCompleteShape); - console.debug('action: drawshape', shape); } + }; + // round to 4 decimal places after point + var mRound = function (num) { + return Math.round(num * 10000 + 0.00001) / 10000 }; - // callback for vector.drawshape var onCompleteShape = function(data, shape) { console.debug('onCompleteShape', shape); - data.tbWidgets.draw.removeClass('dl-drawing') + data.measureWidgets.draw.removeClass('dl-drawing') if (shape == null || shape.geometry.coordinates == null) { return false; // do nothing if no line was produced }; @@ -802,33 +804,33 @@ // recalculate units var updateUnits = function(data) { var val = data.lastMeasuredValue; - var $t = data.tbWidgets; - var u1 = parseFloat($t.unit1.val()); - var u2 = parseFloat($t.unit2.val()); + var $w = data.measureWidgets; + var u1 = parseFloat($w.unit1.val()); + var u2 = parseFloat($w.unit2.val()); var v2 = val * u1 / u2; - $t.val2.val(fn.cropFloatStr(v2)); + $w.value2.val(fn.cropFloatStr(mRound(v2))); } // recalculate after measuring var updateLength = function(data, dist) { - var $t = data.tbWidgets; + var $w = data.measureWidgets; var fac = data.lastMeasureFactor; var val = dist * fac; - $t.len.text(fn.cropFloatStr(dist)); - $t.val1.val(fn.cropFloatStr(val)); + $w.len.text(fn.cropFloatStr(dist)); + $w.value1.val(fn.cropFloatStr(mRound(val))); data.lastMeasuredValue = val; data.lastMeasuredDistance = dist; updateUnits(data); }; - // recalculate factor after entering a new value in val1 + // recalculate factor after entering a new value in input element "value1" var updateFactor = function(data) { - var $t = data.tbWidgets; - var val = parseFloat($t.val1.val()); + var $w = data.measureWidgets; + var val = parseFloat($w.value1.val()); var dist = data.lastMeasuredDistance; var fac = val / dist; data.lastMeasureFactor = fac; - $t.fac.text(fn.cropFloatStr(fac)); + $w.fac.text(fn.cropFloatStr(fac)); data.lastMeasuredValue = val; updateUnits(data); }; @@ -850,7 +852,7 @@ // return shape type selected by user (on the toolbar) var getSelectedShapeType = function(data) { - var val = data.tbWidgets.shape.val(); + var val = data.measureWidgets.shape.val(); return data.settings.shapeTypes[val]; }; @@ -862,7 +864,7 @@ // load shapes into select element var loadShapeTypes = function(data) { - var $shape = data.tbWidgets.shape; + var $shape = data.measureWidgets.shape; $.each(data.settings.shapeTypes, function(index, item) { var $opt = $('<option value="'+ index + '">' + item.name + '</option>'); $shape.append($opt); @@ -872,7 +874,7 @@ // load units into select elements var loadSections = function(data) { - var $t = data.tbWidgets; + var $t = data.measureWidgets; var $u1 = $t.unit1; var $u2 = $t.unit2; var sections = data.settings.units.sections; @@ -899,14 +901,14 @@ }; // setup a div for accessing the measure functionality - var setupToolbar = function(data) { - console.debug('measure: setupToolbar'); - var tbWidgets = { + var setupMeasureBar = function(data) { + console.debug('measure: setupMeasureBar'); + var measureWidgets = { names : [ 'draw', 'shape', 'lenlabel', 'len', - 'eq1', 'val1', 'unit1', - 'eq2', 'val2', 'unit2' + 'eq1', 'value1', 'unit1', + 'eq2', 'value2', 'unit2' ], draw : $('<button id="dl-measure-draw" title="click to draw a measuring shape on top of the image">M</button>'), shape : $('<select id="dl-measure-shape" title="select a shape to use for measuring" />'), @@ -916,30 +918,30 @@ eq2 : $('<span class="dl-measure-label">=</span>'), len : $('<span id="dl-measure-len" class="dl-measure-number">0.0</span>'), fac : $('<span id="dl-measure-factor" class="dl-measure-number" />'), - val1 : $('<input id="dl-measure-val1" class="dl-measure-input" title="value of the last measured distance - click to change the value" value="0.0" />'), - val2 : $('<input id="dl-measure-val2" class="dl-measure-input" title="value of the last measured distance, converted to the secondary unit" value="0.0"/>'), + value1 : $('<input id="dl-measure-value1" class="dl-measure-input" title="value of the last measured distance - click to change the value" value="0.0" />'), + value2 : $('<input id="dl-measure-value2" class="dl-measure-input" title="value of the last measured distance, converted to the secondary unit" value="0.0"/>'), unit1 : $('<select id="dl-measure-unit1" title="current measuring unit - click to change" />'), unit2 : $('<select id="dl-measure-unit2" title="secondary measuring unit - click to change" />'), angle : $('<span id="dl-measure-angle" class="dl-measure-number" title="last measured angle" />') }; - var $toolbar = $('<div id="dl-measure-toolbar" />'); - $.each(tbWidgets.names, function(index, item) { - $toolbar.append(tbWidgets[item]); + var $measureBar = $('<div id="dl-measure-toolbar" />'); + $.each(measureWidgets.names, function(index, item) { + $measureBar.append(measureWidgets[item]); }); - data.$elem.append($toolbar); - data.$toolbar = $toolbar; - data.tbWidgets = tbWidgets; - tbWidgets.fac.text(fn.cropFloatStr(data.lastMeasureFactor)); + data.$elem.append($measureBar); + data.$measureBar = $measureBar; + data.measureWidgets = measureWidgets; + measureWidgets.fac.text(fn.cropFloatStr(data.lastMeasureFactor)); loadShapeTypes(data); loadSections(data); - setupToolbarButtons(data); - return $toolbar; + setupMeasureWidgets(data); + return $measureBar; }; // wire the draw button - var setupToolbarButtons = function (data) { - console.debug('measure: setupToolbarButtons'); - var $t = data.tbWidgets; + var setupMeasureWidgets = function (data) { + console.debug('measure: setupMeasureWidgets'); + var $t = data.measureWidgets; var $draw = $t.draw; var buttonConfig = buttons['drawshape']; // not in data.settings.buttons // button properties @@ -953,7 +955,7 @@ $elem.digilib(action); return false; }); - $t.val1.on('change.digilib', function(evt) { + $t.value1.on('change.digilib', function(evt) { updateFactor(data); }); $t.unit1.on('change.digilib', function(evt) { @@ -972,8 +974,8 @@ data.lastMeasuredDistance = 0; data.lastMeasuredValue = 0; data.lastMeasuredAngle = 0; - data.lastMeasureFactor = 1.0, - setupToolbar(data); + data.lastMeasureFactor = 1.0, + setupMeasureBar(data); }; // event handler @@ -982,18 +984,6 @@ console.debug("measure: handleUpdate"); }; - // additional buttons - var installButtons = function (data) { - var settings = data.settings; - var mode = settings.interactionMode; - var buttonSettings = settings.buttonSettings[mode]; - var buttonSet = settings.measureButtonSet; - if (buttonSet.length && buttonSet.length > 0) { - buttonSettings.measureButtonSet = buttonSet; - buttonSettings.buttonSets.push('measureButtonSet'); - } - }; - // plugin installation called by digilib on plugin object. var install = function (plugin) { digilib = plugin; @@ -1009,6 +999,11 @@ $.extend(true, digilib.defaults, defaults); $.extend(digilib.actions, actions); $.extend(true, digilib.buttons, buttons); + // insert in button list -- not elegant + if (digilib.plugins.buttons != null) { + // if (digilib.defaults.buttonSettings != null) { + digilib.defaults.buttonSettings.fullscreen.standardSet.splice(10, 0, 'measure'); + } // export functions // fn.test = test; }; @@ -1023,10 +1018,6 @@ var $data = $(data); $data.on('setup', handleSetup); $data.on('update', handleUpdate); - // install region buttons if user defined regions are allowed - if (digilib.plugins.buttons != null) { - installButtons(data); - } }; // plugin object with name and init