var wpd=wpd||{};wpd.initApp=function(){wpd.browserInfo.checkBrowser();wpd.layoutManager.initialLayout();wpd.loadRemoteData()||wpd.graphicsWidget.loadImageFromURL("start.png");document.getElementById("loadingCurtain").style.display="none"};
wpd.loadRemoteData=function(){return"undefined"===typeof wpdremote?!1:null!=wpdremote.status&&"fail"===wpdremote.status?(wpd.messagePopup.show("Remote Upload Failed!","Remote Upload Failed!"),!1):"success"===wpdremote.status&&null!=wpdremote.localUrl?(wpd.graphicsWidget.loadImageFromURL(wpdremote.localUrl),wpd.popup.show("axesList"),!0):!1};document.addEventListener("DOMContentLoaded",wpd.initApp,!0);wpd=wpd||{};
wpd.appData=function(){function c(){null==a&&(a=new wpd.PlotData);return a}var b=!1,a;return{isAligned:function(a){null!=a&&(b=a);return b},getPlotData:c,reset:function(){b=!1;a=null},plotLoaded:function(a){c().topColors=wpd.colorAnalyzer.getTopColors(a)}}}();wpd=wpd||{};
wpd.AutoDetector=function(){return function(){this.fgColor=[0,0,200];this.bgColor=[255,255,255];this.mask=null;this.gridMask={xmin:null,xmax:null,ymin:null,ymax:null,pixels:[]};this.gridLineColor=[150,150,150];this.gridColorDistance=150;this.gridData=null;this.colorDetectionMode="fg";this.colorDistance=120;this.imageData=this.gridBinaryData=this.binaryData=this.algorithm=null;this.imageHeight=this.imageWidth=0;this.reset=function(){this.gridData=this.imageData=this.binaryData=this.mask=null;this.gridMask=
{xmin:null,xmax:null,ymin:null,ymax:null,pixels:[]}};this.generateBinaryDataFromMask=function(){var c,b,a,d="fg"===this.colorDetectionMode?this.fgColor:this.bgColor;for(c=0;c<this.mask.length;c++)b=this.mask[c],a=Math.sqrt((this.imageData.data[4*b]-d[0])*(this.imageData.data[4*b]-d[0])+(this.imageData.data[4*b+1]-d[1])*(this.imageData.data[4*b+1]-d[1])+(this.imageData.data[4*b+2]-d[2])*(this.imageData.data[4*b+2]-d[2])),"fg"===this.colorDetectionMode?a<=this.colorDistance&&(this.binaryData[b]=!0):
a>=this.colorDistance&&(this.binaryData[b]=!0)};this.generateBinaryDataUsingFullImage=function(){var c,b,a="fg"===this.colorDetectionMode?this.fgColor:this.bgColor;for(b=0;b<this.imageData.data.length/4;b++)c=Math.sqrt((this.imageData.data[4*b]-a[0])*(this.imageData.data[4*b]-a[0])+(this.imageData.data[4*b+1]-a[1])*(this.imageData.data[4*b+1]-a[1])+(this.imageData.data[4*b+2]-a[2])*(this.imageData.data[4*b+2]-a[2])),"fg"===this.colorDetectionMode?c<=this.colorDistance&&(this.binaryData[b]=!0):c>=
this.colorDistance&&(this.binaryData[b]=!0)};this.generateBinaryData=function(){this.binaryData=[];null==this.imageData?this.imageWidth=this.imageHeight=0:(this.imageHeight=this.imageData.height,this.imageWidth=this.imageData.width,null==this.mask||0===this.mask.length?this.generateBinaryDataUsingFullImage():this.generateBinaryDataFromMask())};this.generateGridBinaryData=function(){this.gridBinaryData=[];if(null!=this.gridMask.pixels&&0!==this.gridMask.pixels.length)if(null==this.imageData)this.imageHeight=
this.imageWidth=0;else{this.imageWidth=this.imageData.width;this.imageHeight=this.imageData.height;var c,b,a;for(c=0;c<this.gridMask.pixels.length;c++)b=this.gridMask.pixels[c],a=wpd.dist3d(this.gridLineColor[0],this.gridLineColor[1],this.gridLineColor[2],this.imageData.data[4*b],this.imageData.data[4*b+1],this.imageData.data[4*b+2]),a<this.gridColorDistance&&(this.gridBinaryData[b]=!0)}}}}();wpd=wpd||{};
wpd.Calibration=function(){return function(c){var b=[],a=[],d=null==c?2:c,f=[],e=[];this.labels=[];this.getCount=function(){return b.length};this.getDimensions=function(){return d};this.addPoint=function(c,e,k,q,m){var n=b.length,l=f.length;b[n]=c;a[n]=e;f[l]=k;f[l+1]=q;3===d&&(f[l+2]=m)};this.getPoint=function(c){return 0>c||c>=b.length?null:{px:b[c],py:a[c],dx:f[d*c],dy:f[d*c+1],dz:2===d?null:f[d*c+2]}};this.changePointPx=function(d,c,e){0>d||d>=b.length||(b[d]=c,a[d]=e)};this.setDataAt=function(a,
c,e,q){0>a||a>=b.length||(f[d*a]=c,f[d*a+1]=e,3===d&&(f[d*a+2]=q))};this.findNearestPoint=function(d,c,e){e=null==e?50:parseFloat(e);var f,m=-1,n,l;for(n=0;n<b.length;n++)if(l=Math.sqrt((d-b[n])*(d-b[n])+(c-a[n])*(c-a[n])),0>m&&l<=e||0<=m&&l<f)m=n,f=l;return m};this.selectPoint=function(a){0>e.indexOf(a)&&(e[e.length]=a)};this.selectNearestPoint=function(a,b,d){a=this.findNearestPoint(a,b,d);0<=a&&this.selectPoint(a)};this.getSelectedPoints=function(){return e};this.unselectAll=function(){e=[]};this.isPointSelected=
function(a){return 0<=e.indexOf(a)};this.dump=function(){console.log(b);console.log(a);console.log(f)}}}();wpd=wpd||{};wpd.ColorGroup=function(){return function(c){var b=0,a={r:0,g:0,b:0};c=null==c?100:c;this.getPixelCount=function(){return b};this.getAverageColor=function(){return a};this.isColorInGroup=function(d,f,e){return 0===b?!0:(a.r-d)*(a.r-d)+(a.g-f)*(a.g-f)+(a.b-e)*(a.b-e)<=c*c};this.addPixel=function(d,c,e){a.r=(a.r*b+d)/(b+1);a.g=(a.g*b+c)/(b+1);a.b=(a.b*b+e)/(b+1);b+=1}}}();
wpd.colorAnalyzer=function(){return{getTopColors:function(c){var b=[],a,d,f,e,g,h,k=[];b[0]=new wpd.ColorGroup(120);for(a=0;a<c.data.length;a+=4){d=c.data[a];f=c.data[a+1];e=c.data[a+2];h=!1;for(g=0;g<b.length;g++)if(b[g].isColorInGroup(d,f,e)){b[g].addPixel(d,f,e);h=!0;break}h||(b[b.length]=new wpd.ColorGroup(120),b[b.length-1].addPixel(d,f,e))}b.sort(function(a,b){return a.getPixelCount()>b.getPixelCount()?-1:a.getPixelCount()<b.getPixelCount()?1:0});for(g=0;g<b.length;g++)a=b[g].getAverageColor(),
k[g]={r:parseInt(a.r,10),g:parseInt(a.g,10),b:parseInt(a.b,10),pixels:b[g].getPixelCount(),percentage:100*b[g].getPixelCount()/(.25*c.data.length)};return k}}}();wpd=wpd||{};
wpd.ConnectedPoints=function(){return function(c){var b=[],a=-1,d=-1;this.addConnection=function(a){b[b.length]=a};this.clearAll=function(){b=[]};this.getConnectionAt=function(a){if(a<b.length)return b[a]};this.replaceConnectionAt=function(a,d){a<b.length&&(b[a]=d)};this.deleteConnectionAt=function(a){a<b.length&&b.splice(a,1)};this.connectionCount=function(){return b.length};this.getDistance=function(a){if(a<b.length&&2===c)return Math.sqrt((b[a][0]-b[a][2])*(b[a][0]-b[a][2])+(b[a][1]-b[a][3])*(b[a][1]-
b[a][3]))};this.getAngle=function(a){if(a<b.length&&3===c){var d=wpd.taninverse(-(b[a][5]-b[a][3]),b[a][4]-b[a][2]);a=wpd.taninverse(-(b[a][1]-b[a][3]),b[a][0]-b[a][2]);d=180*(d-a)/Math.PI;return d=0>d?d+360:d}};this.findNearestPointAndConnection=function(a,d){var g=-1,h=-1,k,q,m,n;for(m=0;m<b.length;m++)for(n=0;n<2*c;n+=2)if(q=(b[m][n]-a)*(b[m][n]-a)+(b[m][n+1]-d)*(b[m][n+1]-d),-1===h||q<k)g=m,h=n/2,k=q;return{connectionIndex:g,pointIndex:h}};this.selectNearestPoint=function(b,c){var g=this.findNearestPointAndConnection(b,
c);0<=g.connectionIndex&&(a=g.connectionIndex,d=g.pointIndex)};this.deleteNearestConnection=function(a,b){var d=this.findNearestPointAndConnection(a,b);0<=d.connectionIndex&&this.deleteConnectionAt(d.connectionIndex)};this.isPointSelected=function(b,c){return d===c&&a===b?!0:!1};this.getSelectedConnectionAndPoint=function(){return{connectionIndex:a,pointIndex:d}};this.unselectConnectionAndPoint=function(){d=a=-1};this.setPointAt=function(a,d,c,h){b[a][2*d]=c;b[a][2*d+1]=h};this.getPointAt=function(a,
d){return{x:b[a][2*d],y:b[a][2*d+1]}}}}();wpd=wpd||{};
wpd.DataSeries=function(){return function(c){var b=[],a=[],d=!1,f=[];this.name="Default Dataset";this.variableNames=["x","y"];this.hasMetadata=function(){return d};this.setMetadataKeys=function(a){f=a};this.getMetadataKeys=function(){return f};this.addPixel=function(a,c,f){b[b.length]={x:a,y:c,metadata:f};null!=f&&(d=!0)};this.getPixel=function(a){return b[a]};this.setPixelAt=function(a,d,c){a<b.length&&(b[a].x=d,b[a].y=c)};this.setMetadataAt=function(a,d){a<b.length&&(b[a].metadata=d)};this.insertPixel=
function(a,d,c,f){b.splice(a,0,{x:d,y:c,metadata:f})};this.removePixelAtIndex=function(a){a<b.length&&b.splice(a,1)};this.removeLastPixel=function(){this.removePixelAtIndex(b.length-1)};this.findNearestPixel=function(a,d,c){c=null==c?50:parseFloat(c);var f,q=-1,m,n;for(m=0;m<b.length;m++)if(n=Math.sqrt((a-b[m].x)*(a-b[m].x)+(d-b[m].y)*(d-b[m].y)),0>q&&n<=c||0<=q&&n<f)q=m,f=n;return q};this.removeNearestPixel=function(a,b,d){a=this.findNearestPixel(a,b,d);0<=a&&this.removePixelAtIndex(a)};this.clearAll=
function(){b=[];d=!1;f=[]};this.getCount=function(){return b.length};this.selectPixel=function(b){0<=a.indexOf(b)||(a[a.length]=b)};this.unselectAll=function(){a=[]};this.selectNearestPixel=function(a,b,d){a=this.findNearestPixel(a,b,d);0<=a&&this.selectPixel(a);return a};this.selectNextPixel=function(){for(var d=0;d<a.length;d++)a[d]=(a[d]+1)%b.length};this.selectPreviousPixel=function(){var d,c;for(d=0;d<a.length;d++)c=a[d],c=0===c?b.length-1:c-1,a[d]=c};this.getSelectedPixels=function(){return a}}}();
wpd=wpd||{};
wpd.dateConverter=function(){function c(a){a=a.toString();var b=a.split("/"),c;if(0>=b.length||3<b.length)return null;a=parseInt(b[0],10);c=parseInt(void 0===b[1]?0:b[1],10);date=parseInt(void 0===b[2]?1:b[2],10);if(isNaN(a)||isNaN(c)||isNaN(date)||12<c||1>c||31<date||1>date)return null;b=new Date;b.setUTCFullYear(a);b.setUTCMonth(c-1);b.setUTCDate(date);a=parseFloat(Date.parse(b));return isNaN(a)?null:a}function b(a,b){var c;c=b.replace("YYYY","yyyy");c=c.replace("YY","yy");c=c.replace("MMMM","mmmm");
c=c.replace("MMM","mmm");c=c.replace("MM","mm");c=c.replace("DD","dd");c=c.replace("yyyy",a.getUTCFullYear());var e=a.getUTCFullYear()%100;c=c.replace("yy",10>e?"0"+e:e);c=c.replace("mmmm","January February March April May June July August September October November December".split(" ")[a.getUTCMonth()]);c=c.replace("mmm","Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" ")[a.getUTCMonth()]);c=c.replace("mm",a.getUTCMonth()+1);return c=c.replace("dd",a.getUTCDate())}return{parse:function(a){return null==
a||"string"===typeof a&&0>a.indexOf("/")?null:c(a)},getFormatString:function(a){a=a.split("/");var b="yyyy/mm/dd";1<=a.length&&(b="yyyy");2<=a.length&&(b+="/mm");3===a.length&&(b+="/dd");return b},formatDate:b,formatDateNumber:function(a,d){var c;c=parseFloat(a);c=parseInt(864E5*Math.round(c/864E5),10);return b(new Date(c),d)}}}();wpd=wpd||{};
wpd.gridDetectionCore=function(){var c,b,a,d;return{run:function(){var f=[],e,g,h,k=wpd.appData.getPlotData().getAutoDetector(),q=k.gridMask.xmin,m=k.gridMask.xmax,n=k.gridMask.ymin,l=k.gridMask.ymax,p,t=k.imageWidth,r,v,u;if(b)for(e=q;e<=m;e+=a){h=[];v=[];r=0;for(p=e-a;p<=e+a;p++)for(g=n;g<=l;g++)u=g*t+parseInt(p,10),!0===k.gridBinaryData[u]&&(h[h.length]=u,!0!==v[g]&&(r++,v[g]=!0));if(r>.3*(l-n))for(r=0;r<h.length;r++)f[h[r]]=!0}if(c)for(g=n;g<=l;g+=d){h=[];v=[];r=0;for(n=g-d;n<=g+d;n++)for(e=q;e<=
m;e++)u=parseInt(n,10)*t+e,!0===k.gridBinaryData[u]&&(h[h.length]=u,!0!==v[e]&&(r++,v[e]=!0));if(r>.3*(m-q))for(r=0;r<h.length;r++)f[h[r]]=!0}wpd.appData.getPlotData().gridData=f},setHorizontalParameters:function(a,b,g){c=a;d=b},setVerticalParameters:function(c,d,g){b=c;a=d}}}();wpd=wpd||{};
wpd.InputParser=function(){return function(){this.parse=function(c){this.isDate=this.isValid=!1;this.formatting=null;if(null==c||"string"===typeof c&&(c=c.trim(),0<=c.indexOf("^")))return null;var b=wpd.dateConverter.parse(c);if(null!=b)return this.isDate=this.isValid=!0,this.formatting=wpd.dateConverter.getFormatString(c),b;c=parseFloat(c);return isNaN(c)?null:(this.isValid=!0,c)};this.isDate=this.isValid=!1;this.formatting=null}}();wpd=wpd||{};
wpd.taninverse=function(c,b){var a;0<c?a=Math.atan2(c,b):0>=c&&(a=Math.atan2(c,b)+2*Math.PI);a>=2*Math.PI&&(a=0);return a};wpd.sqDist2d=function(c,b,a,d){return(c-a)*(c-a)+(b-d)*(b-d)};wpd.sqDist3d=function(c,b,a,d,f,e){return(c-d)*(c-d)+(b-f)*(b-f)+(a-e)*(a-e)};wpd.dist2d=function(c,b,a,d){return Math.sqrt(wpd.sqDist2d(c,b,a,d))};wpd.dist3d=function(c,b,a,d,f,e){return Math.sqrt(wpd.sqDist3d(c,b,a,d,f,e))};
wpd.mat=function(){function c(b){return b[0]*b[3]-b[1]*b[2]}return{det2x2:c,inv2x2:function(b){var a=c(b);return[b[3]/a,-b[1]/a,-b[2]/a,b[0]/a]},mult2x2:function(b,a){return[b[0]*a[0]+b[1]*a[2],b[0]*a[1]+b[1]*a[3],b[2]*a[0]+b[3]*a[2],b[2]*a[1]+b[3]*a[3]]},mult2x2Vec:function(b,a){return[b[0]*a[0]+b[1]*a[1],b[2]*a[0]+b[3]*a[1]]},multVec2x2:function(b,a){return[a[0]*b[0]+a[2]*b[1],a[1]*b[0]+a[3]*b[1]]}}}();wpd=wpd||{};
wpd.PlotData=function(){return function(){var c=0,b=new wpd.AutoDetector;this.axes=this.topColors=null;this.dataSeriesColl=[];this.distanceMeasurementData=this.angleMeasurementData=this.calibration=this.gridData=null;this.getActiveDataSeries=function(){null==this.dataSeriesColl[c]&&(this.dataSeriesColl[c]=new wpd.DataSeries);return this.dataSeriesColl[c]};this.getDataSeriesCount=function(){return this.dataSeriesColl.length};this.setActiveDataSeriesIndex=function(a){c=a};this.getActiveDataSeriesIndex=
function(){return c};this.getAutoDetector=function(){return b};this.getDataSeriesNames=function(){for(var a=[],b=0;b<this.dataSeriesColl.length;b++)a[b]=this.dataSeriesColl[b].name;return a};this.reset=function(){this.distanceMeasurementData=this.angleMeasurementData=this.axes=null;this.dataSeriesColl=[];this.calibration=this.gridData=null;c=0;b=new wpd.AutoDetector}}}();wpd=wpd||{};
wpd.AveragingWindowCore=function(){return function(c,b,a,d,f,e){this.run=function(){var g=[],h=0,k=[],q,m,n,l,p,t,r,v,u;e.clearAll();for(q=0;q<a;q++){p=-1;n=-2*f;for(m=l=0;m<b;m++)!0===c[m*a+q]&&(m>n+f?(p+=1,l=1,n=k[p]=m):(l+=1,k[p]=parseFloat((k[p]*(l-1)+m)/parseFloat(l))));if(0<=p)for(n=q,m=0;m<=p;m++)l=k[m],g[h]=[],g[h][0]=parseFloat(n),g[h][1]=parseFloat(l),g[h][2]=!0,h+=1}if(0!==h){for(k=0;k<h;k++)if(!0===g[k][2]){q=!0;p=k+1;m=g[k][0];n=g[k][1];l=m;t=n;for(u=1;!0===q&&p<h;)r=g[p][0],v=g[p][1],
Math.abs(r-m)<=d&&Math.abs(v-n)<=f&&!0===g[p][2]&&(l=(l*u+r)/(u+1),t=(t*u+v)/(u+1),u+=1,g[p][2]=!1),r>m+2*d&&(q=!1),p+=1;g[k][2]=!1;e.addPixel(parseFloat(l),parseFloat(t))}return e}}}}();wpd=wpd||{};
wpd.AveragingWindowAlgo=function(){return function(){var c=5,b=5;this.getParamList=function(){return[["\u0394X","Px",10],["\u0394Y","Px",10]]};this.setParam=function(a,d){0===a?c=d:1===a&&(b=d)};this.run=function(a){var d=a.getAutoDetector();a=a.getActiveDataSeries();(new wpd.AveragingWindowCore(d.binaryData,d.imageHeight,d.imageWidth,c,b,a)).run()}}}();wpd=wpd||{};
wpd.AveragingWindowWithStepSizeAlgo=function(){return function(){var c,b,a,d,f,e;this.getParamList=function(){var a=wpd.appData.isAligned(),b=wpd.appData.getPlotData().axes;return a&&b instanceof wpd.XYAxes?(a=b.getBounds(),[["X_min","Units",a.x1],["\u0394X Step","Units",.1],["X_max","Units",a.x2],["Y_min","Units",a.y3],["Y_max","Units",a.y4],["Line width","Px",30]]):[["X_min","Units",0],["\u0394X Step","Units",.1],["X_max","Units",0],["Y_min","Units",0],["Y_max","Units",0],["Line width","Px",30]]};
this.setParam=function(g,h){0===g?c=h:1===g?b=h:2===g?a=h:3===g?f=h:4===g?e=h:5===g&&(d=h)};this.run=function(g){var h=g.getAutoDetector(),k=g.getActiveDataSeries();g=g.axes;var q=h.imageWidth,m=h.imageHeight,n,l,p,t,r,v,u,w,x;k.clearAll();for(n=c;n<=a;n+=b)for(x=g.dataToPixel(n,f),l=x.x,t=x.y,x=g.dataToPixel(n,e),p=x.x,r=x.y,l=Math.sqrt((r-t)*(r-t)+(p-l)*(p-l)),p=(e-f)/l,t=!1,v=r=0,u=!1,w=0;w<=l;w++)x=1*-w*p+e,x=g.dataToPixel(n,x),xi_pix=x.x,yi_pix=x.y,0<=xi_pix&&xi_pix<q&&0<=yi_pix&&yi_pix<m&&(!0===
h.binaryData[parseInt(yi_pix,10)*q+parseInt(xi_pix,10)]?(!1===t&&(v=r=w,t=!0,u=!1),!0===u&&(v=w,u=!1)):!1===u&&(v=w,u=!0),!0===t&&(w>r+d||w==l-1)&&(t=!1,r>v&&(v=w),x=(r+v)/2,x=1*-x*p+e,x=g.dataToPixel(n,x),k.addPixel(parseFloat(x.x),parseFloat(x.y))))}}}();wpd=wpd||{};
wpd.BarValue=function(){this.avgX=this.avgVal=this.npoints=0;this.append=function(c,b){this.avgX=(this.npoints*this.avgX+c)/(this.npoints+1);this.avgVal=(this.npoints*this.avgVal+b)/(this.npoints+1);this.npoints++};this.isPointInGroup=function(c,b,a,d){return 0===this.npoints||Math.abs(this.avgX-c)<=a&&Math.abs(this.avgVal-b)<=d?!0:!1}};
wpd.BarExtractionAlgo=function(){var c,b;this.getParamList=function(){return"Y"===wpd.appData.getPlotData().axes.getOrientation().axes?[["\u0394X","Px",30],["\u0394Val","Px",10]]:[["\u0394Y","Px",30],["\u0394Val","Px",10]]};this.setParam=function(a,d){0===a?c=parseFloat(d):1===a&&(b=parseFloat(d))};this.run=function(a){var d=a.getAutoDetector(),f=a.getActiveDataSeries(),e=a.axes.getOrientation(),g=[],h,k,q=d.imageWidth,m=d.imageHeight,n,l,p,t,r=function(a,e,f){if(d.binaryData[e*q+a]){n=!1;l=0;t=[a,
e];for(l=0;l<g.length;l++)if(p=g[l],"Y"===f){if(p.isPointInGroup(t[0],t[1],c,b)){p.append(t[0],t[1]);n=!0;break}}else if(p.isPointInGroup(t[1],t[0],c,b)){p.append(t[1],t[0]);n=!0;break}n||(g.push(new wpd.BarValue),"Y"===f?g[g.length-1].append(t[0],t[1]):g[g.length-1].append(t[1],t[0]),n=!0);return!0}return!1};f.clearAll();if("Y"===e.axes)for(h=0;h<q;h++)if("increasing"===e.direction)for(k=0;k<m&&!r(h,k,e.axes);k++);else for(k=m-1;0<=k&&!r(h,k,e.axes);k--);else for(k=0;k<m;k++)if("increasing"===e.direction)for(h=
q-1;0<=h&&!r(h,k,e.axes);h--);else for(h=0;h<q&&!r(h,k,e.axes);h++);a.axes.dataPointsHaveLabels&&(h=f.getMetadataKeys(),null!=h&&"Label"===h[0]||f.setMetadataKeys(["Label"]));for(l=0;l<g.length;l++)p=g[l],a.axes.dataPointsHaveLabels?"Y"===e.axes?f.addPixel(p.avgX,p.avgVal,["Bar"+l]):f.addPixel(p.avgVal,p.avgX,["Bar"+l]):"Y"===e.axes?f.addPixel(p.avgX,p.avgVal):f.addPixel(p.avgVal,p.avgX)}};wpd=wpd||{};
wpd.BlobDetectorAlgo=function(){return function(){var c,b;this.getParamList=function(){var a=wpd.appData.isAligned(),b=wpd.appData.getPlotData().axes;return a&&b instanceof wpd.MapAxes?[["Min Diameter","Units",0],["Max Diameter","Units",5E3]]:[["Min Diameter","Px",0],["Max Diameter","Px",5E3]]};this.setParam=function(a,d){0===a?c=parseFloat(d):1===a&&(b=parseFloat(d))};this.run=function(a){var d=a.getAutoDetector(),f=a.getActiveDataSeries(),e=d.imageWidth,g=d.imageHeight,h=[],k=[],q,m,n,l,p,t,r,v,
u;if(!(0>=e||0>=g||null==d.binaryData||0===d.binaryData.length)){f.clearAll();f.setMetadataKeys(["area","moment"]);for(q=0;q<e;q++)for(m=0;m<g;m++)if(!0===d.binaryData[m*e+q]&&!0!==h[m*e+q])for(h[m*e+q]=!0,l=k.length,k[l]={pixels:[{x:q,y:m}],centroid:{x:q,y:m},area:1,moment:0},n=0;n<k[l].pixels.length;){r=k[l].pixels[n].x;v=k[l].pixels[n].y;for(p=r-1;p<=r+1;p++)for(t=v-1;t<=v+1;t++)0<=p&&0<=t&&p<e&&t<g&&!0!==h[t*e+p]&&!0===d.binaryData[t*e+p]&&(h[t*e+p]=!0,u=k[l].pixels.length,k[l].pixels[u]={x:p,
y:t},k[l].centroid.x=(k[l].centroid.x*u+p)/(u+1),k[l].centroid.y=(k[l].centroid.y*u+t)/(u+1),k[l].area+=1);n+=1}for(l=0;l<k.length;l++){for(n=k[l].moment=0;n<k[l].pixels.length;n++)k[l].moment=k[l].moment+(k[l].pixels[n].x-k[l].centroid.x)*(k[l].pixels[n].x-k[l].centroid.x)+(k[l].pixels[n].y-k[l].centroid.y)*(k[l].pixels[n].y-k[l].centroid.y);a.axes instanceof wpd.MapAxes&&(k[l].area=a.axes.pixelToDataArea(k[l].area));d=2*Math.sqrt(k[l].area/Math.PI);d<=b&&d>=c&&f.addPixel(k[l].centroid.x,k[l].centroid.y,
[k[l].area,k[l].moment])}}}}}();wpd=wpd||{};
wpd.XStepWithInterpolationAlgo=function(){return function(){var c,b,a,d,f,e;this.getParamList=function(){var a=wpd.appData.isAligned(),b=wpd.appData.getPlotData().axes;return a&&b instanceof wpd.XYAxes?(a=b.getBounds(),[["X_min","Units",a.x1],["\u0394X Step","Units",(a.x2-a.x1)/50],["X_max","Units",a.x2],["Y_min","Units",a.y3],["Y_max","Units",a.y4],["Smoothing","% of \u0394X",0]]):[["X_min","Units",0],["\u0394X Step","Units",.1],["X_max","Units",0],["Y_min","Units",0],["Y_max","Units",0],["Smoothing",
"% of \u0394X",0]]};this.setParam=function(g,h){0===g?c=h:1===g?b=h:2===g?a=h:3===g?f=h:4===g?e=h:5===g&&(d=h)};this.run=function(g){var h=g.getAutoDetector(),k=g.getActiveDataSeries();g=g.axes;var q=0,m=h.imageWidth,n=h.imageHeight,l,p,t,r,v,u,w=[],x=[];u=[];var A=[],y=Math.abs(d/100*b);k.clearAll();l=g.dataToPixel(c,f);p=g.dataToPixel(c,e);p=Math.sqrt((l.x-p.x)*(l.x-p.x)+(l.y-p.y)*(l.y-p.y));A=(e-f)/p;p=g.dataToPixel(a,f);l=Math.sqrt((l.x-p.x)*(l.x-p.x)+(l.y-p.y)*(l.y-p.y));p=(a-c)/l;0<Math.abs(y/
p)&&1>Math.abs(y/p)&&(y=p);for(l=c;0<p&&l<=a||0>p&&l>=a;){v=r=0;for(t=f;0<A&&t<=e||0>A&&t>=e;)u=g.dataToPixel(l,t),0<u.x&&0<u.y&&u.x<m&&u.y<n&&!0===h.binaryData[parseInt(u.y,10)*m+parseInt(u.x,10)]&&(r=(r*v+t)/parseFloat(v+1),v++),t+=A;0<v&&(w[q]=parseFloat(l),x[q]=parseFloat(r),q+=1);l+=p}if(!(0>=w.length||0>=x.length)){if(0<y)for(u=[],A=[],l=w[0];0<p&&l<=w[w.length-1]||0>p&&l>=w[w.length-1];){for(h=v=m=q=0;h<w.length;h++)w[h]<=l+y&&w[h]>=l-y&&(q=(q*v+w[h])/parseFloat(v+1),m=(m*v+x[h])/parseFloat(v+
1),v++);0<v&&(u[u.length]=q,A[A.length]=m);l=0<p?l+y:l-y}else u=w,A=x;if(!(0>=u.length||0>=A.length||(w=[],h=0,l=c,0>p&&0<b||0<p&&0>b))){for(;0<p&&l<=a||0>p&&l>=a;)w[h]=l,h++,l+=b;0>p&&(u=u.reverse(),A=A.reverse());x=numeric.spline(u,A).at(w);for(h=0;h<x.length;h++)isNaN(w[h])||isNaN(x[h])||(u=g.dataToPixel(w[h],x[h]),k.addPixel(u.x,u.y))}}}}}();wpd=wpd||{};
wpd.BarAxes=function(){var c=function(){var b=!1,a=!1,c,f,e,g,h,k,q;this.isCalibrated=function(){return b};this.calibrate=function(m,n){b=!1;var l=m.getPoint(0),p=m.getPoint(1);c=l.px;f=l.py;e=p.px;g=p.py;h=parseFloat(l.dy);k=parseFloat(p.dy);n?(a=!0,h=Math.log(h)/Math.log(10),k=Math.log(k)/Math.log(10)):a=!1;q=this.calculateOrientation();return b=!0};this.pixelToData=function(b,n){var l=[];l[0]=((n-f)*(g-f)+(e-c)*(b-c))/((g-f)*(g-f)+(e-c)*(e-c))*(k-h)+h;a&&(l[0]=Math.pow(10,l[0]));return l};this.dataToPixel=
function(a,b){return{x:0,y:0}};this.pixelToLiveString=function(a,b){return this.pixelToData(a,b)[0].toExponential(4)};this.isLog=function(){return a};this.getTransformationEquations=function(){return{pixelToData:["This will be available in a future release."]}};this.dataPointsHaveLabels=!0;this.dataPointsLabelPrefix="Bar";this.calculateOrientation=function(){var a=180*wpd.taninverse(-(g-f),e-c)/Math.PI,b={axes:"Y",direction:"increasing",angle:a};30>Math.abs(a-90)?(b.axes="Y",b.direction="increasing"):
30>Math.abs(a-270)?(b.axes="Y",b.direction="decreasing"):30>Math.abs(a-0)||30>Math.abs(a-360)?(b.axes="X",b.direction="increasing"):30>Math.abs(a-180)&&(b.axes="X",b.direction="decreasing");return b};this.getOrientation=function(){return q}};c.prototype.numCalibrationPointsRequired=function(){return 2};c.prototype.getDimensions=function(){return 2};c.prototype.getAxesLabels=function(){return["Label","Y"]};return c}();wpd=wpd||{};
wpd.ImageAxes=function(){var c=function(){this.isCalibrated=function(){return!0};this.calibrate=function(){return!0};this.pixelToData=function(b,a){return[b,a]};this.dataToPixel=function(b,a){return{x:b,y:a}};this.pixelToLiveString=function(b,a){var c=this.pixelToData(b,a);return c[0].toFixed(2)+", "+c[1].toFixed(2)};this.getTransformationEquations=function(){return{pixelToData:["x_data = x_pixel","y_data = y_pixel"],dataToPixel:["x_pixel = x_data","y_pixel = y_data"]}}};c.prototype.numCalibrationPointsRequired=
function(){return 0};c.prototype.getDimensions=function(){return 2};c.prototype.getAxesLabels=function(){return["X","Y"]};return c}();wpd=wpd||{};
wpd.MapAxes=function(){var c=function(){var b=!1,a,c,f;this.isCalibrated=function(){return b};this.calibrate=function(e,g,h){var k=e.getPoint(0);e=e.getPoint(1);f=Math.sqrt((k.px-e.px)*(k.px-e.px)+(k.py-e.py)*(k.py-e.py));a=parseFloat(g);c=h;return b=!0};this.pixelToData=function(b,c){var d=[];d[0]=b*a/f;d[1]=c*a/f;return d};this.pixelToDataDistance=function(b){return b*a/f};this.pixelToDataArea=function(b){return b*a*a/(f*f)};this.dataToPixel=function(a,b,c){return{x:0,y:0}};this.pixelToLiveString=
function(a,b){var c=this.pixelToData(a,b);return c[0].toExponential(4)+", "+c[1].toExponential(4)};this.getScaleLength=function(){return a};this.getUnits=function(){return c};this.getTransformationEquations=function(){return{pixelToData:["x_data = "+a/f+"*x_pixel","y_data = "+a/f+"*y_pixel"],dataToPixel:["x_pixel = "+f/a+"*x_data","y_pixel = "+f/a+"*y_data"]}}};c.prototype.numCalibrationPointsRequired=function(){return 2};c.prototype.getDimensions=function(){return 2};c.prototype.getAxesLabels=function(){return["X",
"Y"]};return c}();wpd=wpd||{};
wpd.PolarAxes=function(){var c=function(){var b=!1,a=!1,c=!1,f,e,g,h,k,q,m,n,l,p,t,r,v,u;processCalibration=function(b,x,A){var y=b.getPoint(0),B=b.getPoint(1);b=b.getPoint(2);f=y.px;e=y.py;g=B.px;h=B.py;k=b.px;q=b.py;m=B.dx;n=B.dy;l=b.dx;a=x;c=A;!0===a&&(n*=Math.PI/180);p=Math.sqrt((g-f)*(g-f)+(h-e)*(h-e));t=Math.sqrt((k-f)*(k-f)+(q-e)*(q-e));r=t-p;v=wpd.taninverse(-(h-e),g-f);u=c?v+n:v-n;return!0};this.isCalibrated=function(){return b};this.calibrate=function(a,c,d){return b=processCalibration(a,
c,d)};this.isThetaDegrees=function(){return a};this.isThetaClockwise=function(){return c};this.pixelToData=function(b,h){var g=[],k,n;xp=parseFloat(b);yp=parseFloat(h);k=(l-m)/r*(Math.sqrt((xp-f)*(xp-f)+(yp-e)*(yp-e))-p)+m;n=c?u-wpd.taninverse(-(yp-e),xp-f):wpd.taninverse(-(yp-e),xp-f)-u;0>n&&(n+=2*Math.PI);!0===a&&(n=180*n/Math.PI);g[0]=k;g[1]=n;return g};this.dataToPixel=function(a,b){return{x:0,y:0}};this.pixelToLiveString=function(a,b){var c=this.pixelToData(a,b);return c[0].toExponential(4)+
", "+c[1].toExponential(4)};this.getTransformationEquations=function(){var b="r = ("+(l-m)/r+")*sqrt((x_pixel - "+f+")^2 + (y_pixel - "+e+")^2) + ("+(m-p*(l-m)/r)+")",h;h=c?u-NaN+e+" - y_pixel), (x_pixel - "+f+"))":"atan2(("+e+" - y_pixel), (x_pixel - "+f+")) - ("+u+")";h=a?"theta = (180/PI)*("+h+"), theta = theta + 360 if theta < 0":"theta = "+h+" theta = theta + 2*PI if theta < 0";return{pixelToData:[b,h]}}};c.prototype.numCalibrationPointsRequired=function(){return 3};c.prototype.getDimensions=
function(){return 2};c.prototype.getAxesLabels=function(){return["r","\u03b8"]};return c}();wpd=wpd||{};
wpd.TernaryAxes=function(){var c=function(){var b=!1,a,c,f,e,g,h,k,q,m;this.isCalibrated=function(){return b};this.calibrate=function(n,l,p){var t=n.getPoint(0),r=n.getPoint(1);n.getPoint(2);a=t.px;c=t.py;f=r.px;e=r.py;g=Math.sqrt((a-f)*(a-f)+(c-e)*(c-e));h=wpd.taninverse(-(e-c),f-a);k=Math.sqrt(3);q=l;m=p;return b=!0};this.isRange100=function(){return q};this.isNormalOrientation=function(){return m};this.pixelToData=function(b,e){var f=[],t,r,v,u;xp=parseFloat(b);yp=parseFloat(e);t=Math.sqrt((xp-
a)*(xp-a)+(yp-c)*(yp-c));r=wpd.taninverse(-(yp-c),xp-a)-h;v=t*Math.cos(r)/g;r=t*Math.sin(r)/g;t=1-v-r/k;v-=r/k;r=2*r/k;0==m&&(u=v,v=t,t=r,r=u);1==q&&(t*=100,v*=100,r*=100);f[0]=t;f[1]=v;f[2]=r;return f};this.dataToPixel=function(a,b,c){return{x:0,y:0}};this.pixelToLiveString=function(a,b){var c=this.pixelToData(a,b);return c[0].toExponential(4)+", "+c[1].toExponential(4)+", "+c[2].toExponential(4)};this.getTransformationEquations=function(){var b="rp = sqrt((x_pixel - "+a+")^2 + (y_pixel - "+c+")^2)/("+
g+")",h="thetap = atan2(("+c+" -  y_pixel), (x_pixel - "+a+")) - ("+Math.atan2(-(e-c),f-a)+")",k="1 - rp*(cos(thetap) - sin(thetap)/sqrt(3))",t="rp*(cos(thetap) - sin(thetap)/sqrt(3))",r="2*rp*sin(thetap)/sqrt(3)",v;q&&(k="100*("+k+")",t="100*("+t+")",r="100*("+r+")");k="a_data = "+k;t="b_data = "+t;r="c_data = "+r;m||(v=t,t=k,k=r,r=v);return{pixelToData:[b,h,k,t,r]}}};c.prototype.numCalibrationPointsRequired=function(){return 3};c.prototype.getDimensions=function(){return 3};c.prototype.getAxesLabels=
function(){return["a","b","c"]};return c}();wpd=wpd||{};
wpd.XYAxes=function(){var c=function(){var b=!1,a=!1,c=!1,f=!1,e=!1,g,h,k,q,m,n,l,p,t,r,v,u,w,x,A=[0,0,0,0],y=[0,0,0,0],B=[0,0],J=function(b,G,L){if(4>b.getCount())return!1;var I=b.getPoint(0),P=b.getPoint(1),J=b.getPoint(2);b=b.getPoint(3);var F=new wpd.InputParser;k=I.px;l=I.py;q=P.px;p=P.py;m=J.px;t=J.py;n=b.px;r=b.py;v=I.dx;u=P.dx;w=J.dy;x=b.dy;v=F.parse(v);if(!F.isValid)return!1;f=F.isDate;u=F.parse(u);if(!F.isValid||F.isDate!=f)return!1;g=F.formatting;w=F.parse(w);if(!F.isValid)return!1;e=F.isDate;
x=F.parse(x);if(!F.isValid||F.isDate!=e)return!1;h=F.formatting;a=G;c=L;!0===a&&(v=Math.log(v)/Math.log(10),u=Math.log(u)/Math.log(10));!0===c&&(w=Math.log(w)/Math.log(10),x=Math.log(x)/Math.log(10));A=wpd.mat.mult2x2([v-u,0,0,w-x],wpd.mat.inv2x2([k-q,m-n,l-p,t-r]));y=wpd.mat.inv2x2(A);B[0]=v-A[0]*k-A[1]*l;B[1]=w-A[2]*m-A[3]*t;return!0};this.getBounds=function(){return{x1:v,x2:u,y3:w,y4:x}};this.isCalibrated=function(){return b};this.calibrate=function(a,c,d){return b=J(a,c,d)};this.pixelToData=function(b,
e){var f=[],h,g;h=parseFloat(b);g=parseFloat(e);g=wpd.mat.mult2x2Vec(A,[h,g]);g[0]+=B[0];g[1]+=B[1];h=g[0];g=g[1];!0===a&&(h=Math.pow(10,h));!0===c&&(g=Math.pow(10,g));f[0]=h;f[1]=g;return f};this.dataToPixel=function(a,b){var c;c=wpd.mat.mult2x2Vec(y,[a-B[0],b-B[1]]);return{x:c[0],y:c[1]}};this.pixelToLiveString=function(a,b){var c="",d=this.pixelToData(a,b),c=f?c+wpd.dateConverter.formatDateNumber(d[0],g):c+d[0].toExponential(4),c=c+", ";return c=e?c+wpd.dateConverter.formatDateNumber(d[1],h):c+
d[1].toExponential(4)};this.isDate=function(a){return 0===a?f:e};this.getInitialDateFormat=function(a){return 0===a?g:h};this.isLogX=function(){return a};this.isLogY=function(){return c};this.getTransformationEquations=function(){var b="("+A[0]+")*x_pixel + ("+A[1]+")*y_pixel + ("+B[0]+")",e="("+A[2]+")*x_pixel + ("+A[3]+")*y_pixel + ("+B[1]+")",f="x_pixel = ("+y[0]+")*x_data + ("+y[1]+")*y_data + ("+(-y[0]*B[0]-y[1]*B[1])+")",h="y_pixel = ("+y[2]+")*x_data + ("+y[3]+")*y_data + ("+(-y[2]*B[0]-y[3]*
B[1])+")",b=a?"x_data = pow(10, "+b+")":"x_data = "+b,e=c?"y_data = pow(10, "+e+")":"y_data = "+e;return a||c?{pixelToData:[b,e]}:{pixelToData:[b,e],dataToPixel:[f,h]}};this.getOrientation=function(){return{axes:"Y",direction:"increasing",angle:90}}};c.prototype.numCalibrationPointsRequired=function(){return 4};c.prototype.getDimensions=function(){return 2};c.prototype.getAxesLabels=function(){return["X","Y"]};return c}();wpd=wpd||{};
wpd.dataSeriesManagement=function(){function c(){if(wpd.appData.isAligned()){var a=document.getElementById("manage-data-series-name"),b=document.getElementById("manage-data-series-point-count"),c=document.getElementById("manage-data-series-list"),d=wpd.appData.getPlotData(),k=d.getActiveDataSeries(),q=d.getDataSeriesNames(),d=d.getActiveDataSeriesIndex(),m="";a.value=k.name;b.innerHTML=k.getCount();for(a=0;a<q.length;a++)m+='<option value="'+a+'">'+q[a]+"</option>";c.innerHTML=m;c.selectedIndex=d;
wpd.popup.show("manage-data-series-window")}else wpd.messagePopup.show("Manage Datasets","Please calibrate the axes before managing datasets.")}function b(){wpd.graphicsWidget.forceHandlerRepaint();wpd.autoExtraction.updateDatasetControl();wpd.acquireData.updateDatasetControl();wpd.dataPointCounter.setCount()}function a(){wpd.popup.close("manage-data-series-window")}var d=1;return{manage:c,addSeries:function(){var f=wpd.appData.getPlotData(),e="Dataset "+d,g=f.dataSeriesColl.length;a();f.dataSeriesColl[g]=
new wpd.DataSeries;f.dataSeriesColl[g].name=e;f.setActiveDataSeriesIndex(g);b();d++;c()},deleteSeries:function(){a();1===wpd.appData.getPlotData().dataSeriesColl.length?wpd.messagePopup.show("Can Not Delete!","You can not delete this dataset as at least one dataset is required.",c):wpd.okCancelPopup.show("Delete Dataset","Are you sure that you want to delete the dataset and all containing data points?",function(){var a=wpd.appData.getPlotData(),b=a.getActiveDataSeriesIndex();a.dataSeriesColl.splice(b,
1);a.setActiveDataSeriesIndex(0);c()},function(){c()})},viewData:function(){a();wpd.dataTable.showTable()},changeSelectedSeries:function(){var d=document.getElementById("manage-data-series-list"),e=wpd.appData.getPlotData();a();e.setActiveDataSeriesIndex(d.selectedIndex);b();c()},editSeriesName:function(){var d=wpd.appData.getPlotData().getActiveDataSeries(),e=document.getElementById("manage-data-series-name");a();d.name=e.value;b();c()}}}();wpd=wpd||{};
wpd.dataTable=function(){function c(){wpd.graphicsWidget.removeTool();wpd.popup.show("csvWindow");b()}function b(){g=e.getData();document.getElementById("data-table-dataset-control");var b=document.getElementById("data-table-dataset-list"),c=e.getDatasetNames(),h=document.getElementById("data-sort-variables"),k=document.getElementById("dataVariables"),p=document.getElementById("data-date-formatting-container"),t=document.getElementById("data-date-formatting"),r,v="",u="",w="",x=!1;for(r=0;r<c.length;r++)v+=
"<option>"+c[r]+"</option>";b.innerHTML=v;b.selectedIndex=e.getDatasetIndex();k.innerHTML=g.fields.join(", ");p.style.display="none";u+='<option value="raw">Raw</option>';for(r=0;r<g.fields.length;r++)g.isFieldSortable[r]&&(u+='<option value="'+g.fields[r]+'">'+g.fields[r]+"</option>"),null!=g.fieldDateFormat[r]&&(w+="<p>"+g.fields[r]+' <input type="text" length="15" value="'+g.fieldDateFormat[r]+'" id="data-format-string-'+r+'"/></p>',x=!0);g.allowConnectivity&&(u+='<option value="NearestNeighbor">Nearest Neighbor</option>');
h.innerHTML=u;a();x?(p.style.display="inline-block",t.innerHTML=w):p.style.display="hidden";d();f()}function a(){var a=document.getElementById("data-sort-variables").value,b=document.getElementById("data-sort-order");"NearestNeighbor"===a||"raw"===a?b.setAttribute("disabled",!0):b.removeAttribute("disabled")}function d(){if(null!=g&&null!=g.rawData){h=g.rawData.slice(0);var a=document.getElementById("data-sort-variables").value,b="ascending"===document.getElementById("data-sort-order").value,c="NearestNeighbor"===
a,d;if("raw"!==a)if(!c)d=g.fields.indexOf(a),0>d||h.sort(function(a,c){return a[d]>c[d]?b?1:-1:a[d]<c[d]?b?-1:1:0});else if(c)for(var e,f,k,v=h.length,u=g.connectivityFieldIndices,w,x,c=0;c<v-1;c++){a=-1;for(k=c+1;k<v;k++){for(w=f=0;w<u.length;w++)x=u[w],f+=(h[c][x]-h[k][x])*(h[c][x]-h[k][x]);if(f<e||-1===a)e=f,a=k}for(w=0;w<g.fields.length;w++)f=h[a][w],h[a][w]=h[c+1][w],h[c+1][w]=f}}}function f(){if(null!=h){var a=document.getElementById("digitizedDataTable"),b=parseInt(document.getElementById("data-number-format-digits").value,
10),c=document.getElementById("data-number-format-style").value,d=document.getElementById("data-number-format-separator").value,e,f,r,v=[],d=d.replace(/[^\\]\\t/,"\t").replace(/^\\t/,"\t");k="";for(e=0;e<h.length;e++){r=[];for(f=0;f<g.fields.length;f++)null!=g.fieldDateFormat[f]?(void 0===v[f]&&(v[f]=document.getElementById("data-format-string-"+f).value),r[f]=wpd.dateConverter.formatDateNumber(h[e][f],v[f])):r[f]="string"===typeof h[e][f]?h[e][f]:"fixed"===c&&0<=b?h[e][f].toFixed(b):"precision"===
c&&0<=b?h[e][f].toPrecision(b):"exponential"===c&&0<=b?h[e][f].toExponential(b):h[e][f];k+=r.join(d);k+="\n"}a.value=k}}var e,g,h,k;return{showTable:function(){e=wpd.plotDataProvider;c()},showAngleData:function(){e=wpd.measurementDataProvider;e.setDataSource("angle");c()},showDistanceData:function(){e=wpd.measurementDataProvider;e.setDataSource("distance");c()},updateSortingControls:a,reSort:function(){a();d();f()},selectAll:function(){var a=document.getElementById("digitizedDataTable");a.focus();
a.select()},generateCSV:function(){var a=e.getDatasetNames()[e.getDatasetIndex()];wpd.download.csv(JSON.stringify(k),a)},exportToPlotly:function(){if(null!=h){var a={data:[]},b,c,d;a.data[0]={};for(b=0;b<h.length;b++)for(c=0;c<g.fields.length;c++)d=g.fields[c],0===c?d="x":1===c&&(d="y"),0===b&&(a.data[0][d]=[]),a.data[0][d][b]=null!=g.fieldDateFormat[c]?wpd.dateConverter.formatDateNumber(h[b][c],"yyyy-mm-dd"):h[b][c];wpd.plotly.send(a)}},changeDataset:function(){var a=document.getElementById("data-table-dataset-list");
e.setDatasetIndex(a.selectedIndex);b()}}}();wpd=wpd||{};
wpd.graphicsWidget=function(){function c(a){var b=y.getBoundingClientRect();return{x:parseInt(a.pageX-(b.left+window.pageXOffset),10),y:parseInt(a.pageY-(b.top+window.pageYOffset),10)}}function b(a,b){return{x:a/K,y:b/K}}function a(a,b){a=parseInt(a,10);b=parseInt(b,10);P.style.width=a+"px";P.style.height=b+"px";y.width=a;B.width=a;J.width=a;H.width=a;G.width=a;y.height=b;B.height=b;J.height=b;H.height=b;G.height=b;X=a/(1*b);M=a;N=b;if(null!=Q){S.fillStyle="rgb(255, 255, 255)";S.fillRect(0,0,M,N);
S.drawImage(L,0,0,M,N);if(null!=C&&void 0!=C.onRedraw)C.onRedraw();if(null!=z&&void 0!=z.onRedraw)z.onRedraw()}}function d(){B.width=B.width;J.width=J.width;H.width=H.width;G.width=G.width;I.width=I.width}function f(){if(null!=C&&void 0!=C.onRemove)C.onRemove();C=null}function e(){var b=wpd.layoutManager.getGraphicsViewportSize();a(b.width,b.height);X>T?(K=N/(1*D),a(N*T,N)):(K=M/(1*E),a(M,M/T))}function g(b){K=b;a(E*K,D*K)}function h(){U=!U;var a=document.getElementById("extended-crosshair-btn");
U?a.classList.add("pressed-button"):a.classList.remove("pressed-button");H.width=H.width}function k(a,b){var c=wpd.zoomView.getSize(),d=wpd.zoomView.getZoomRatio(),e,f,h,g,k,l,m,n=0,q=0,p=c.width,r=c.height;h=c.width/d;g=c.height/d;e=a-h/2;f=b-g/2;l=e;c=f;k=e+h;m=f+g;0>e&&(l=0,n=-e*d);0>f&&(c=0,q=-f*d);e+h>=E&&(k=E,p-=d*(E-(e+h)));f+g>=D&&(m=D,r-=d*(D-(f+g)));h=R.getImageData(parseInt(l,10),parseInt(c,10),parseInt(k-l,10),parseInt(m-c,10));k=V.getImageData(parseInt(l,10),parseInt(c,10),parseInt(k-
l,10),parseInt(m-c,10));for(e=0;e<k.data.length;e+=4)if(0!=k.data[e]||0!=k.data[e+1]||0!=k.data[e+2])m=k.data[e+3]/255,h.data[e]=(1-m)*h.data[e]+m*k.data[e],h.data[e+1]=(1-m)*h.data[e+1]+m*k.data[e+1],h.data[e+2]=(1-m)*h.data[e+2]+m*k.data[e+2];l=d*(parseInt(l,10)-l);d*=parseInt(c,10)-c;wpd.zoomView.setZoomImage(h,parseInt(n+l,10),parseInt(q+d,10),parseInt(p-n,10),parseInt(r-q,10))}function q(a){clearTimeout(Y);var d=setTimeout,e=c(a);a=e.x;var e=e.y,f=b(a,e);U&&(H.width=H.width,O.strokeStyle="rgba(0,0,0, 0.5)",
O.beginPath(),O.moveTo(a,0),O.lineTo(a,N),O.moveTo(0,e),O.lineTo(M,e),O.stroke());k(f.x,f.y);wpd.zoomView.setCoords(f.x,f.y);Y=d(void 0,10)}function m(){y=document.getElementById("mainCanvas");B=document.getElementById("dataCanvas");J=document.getElementById("drawCanvas");H=document.getElementById("hoverCanvas");G=document.getElementById("topCanvas");L=document.createElement("canvas");I=document.createElement("canvas");S=y.getContext("2d");F=B.getContext("2d");O=H.getContext("2d");Z=G.getContext("2d");
aa=J.getContext("2d");R=L.getContext("2d");V=I.getContext("2d");P=document.getElementById("canvasDiv");document.addEventListener("keydown",function(a){W&&220===a.keyCode&&(a.preventDefault(),h())},!1);G.addEventListener("mousemove",q,!1);G.addEventListener("dragover",function(a){a.preventDefault()},!0);G.addEventListener("drop",function(a){a.preventDefault();wpd.busyNote.show();a=a.dataTransfer.files;1===a.length&&l(a[0])},!0);G.addEventListener("mousemove",r,!1);G.addEventListener("click",v,!1);
G.addEventListener("mouseup",w,!1);G.addEventListener("mousedown",x,!1);G.addEventListener("mouseout",A,!0);document.addEventListener("mouseup",u,!1);document.addEventListener("mousedown",function(a){W=a.target===G?!0:!1},!1);document.addEventListener("keydown",function(a){if(W&&null!=z&&void 0!=z.onKeyDown)z.onKeyDown(a)},!0);wpd.zoomView.initZoom();document.getElementById("fileLoadBox").addEventListener("change",p);window.addEventListener("paste",function(a){if(void 0!==a.clipboardData&&(a=a.clipboardData.items,
void 0!==a))for(var b=0;b<a.length;b++)if(-1!==a[b].type.indexOf("image")){wpd.busyNote.show();var c=a[b].getAsFile();(window.URL||window.webkitURL).createObjectURL(c);l(c)}},!1)}function n(a){var b=document.createElement("img");b.onload=function(){null==y&&m();wpd.appData.reset();wpd.sidebar.clear();t();f();E=b.width;D=b.height;T=E/(1*D);L.width=E;L.height=D;I.width=E;I.height=D;R.drawImage(b,0,0,E,D);Q=R.getImageData(0,0,E,D);y.width=y.width;d();e();wpd.appData.plotLoaded(Q);wpd.busyNote.close();
!1===ba&&wpd.popup.show("axesList");ba=!1};b.src=a}function l(a){if(a.type.match("image.*")){var b=new FileReader;b.onload=function(){n(b.result)};b.readAsDataURL(a)}}function p(){var a=document.getElementById("fileLoadBox");1==a.files.length&&(a=a.files[0],wpd.busyNote.show(),l(a));wpd.popup.close("loadNewImage")}function t(){if(null!=z&&void 0!=z.onRemove)z.onRemove();z=null}function r(a){if(null!=z&&void 0!=z.onMouseMove){var d=c(a),e=b(d.x,d.y);z.onMouseMove(a,d,e)}}function v(a){if(null!=z&&
void 0!=z.onMouseClick){var d=c(a),e=b(d.x,d.y);z.onMouseClick(a,d,e)}}function u(a){if(null!=z&&void 0!=z.onDocumentMouseUp){var d=c(a),e=b(d.x,d.y);z.onDocumentMouseUp(a,d,e)}}function w(a){if(null!=z&&void 0!=z.onMouseUp){var d=c(a),e=b(d.x,d.y);z.onMouseUp(a,d,e)}}function x(a){if(null!=z&&void 0!=z.onMouseDown){var d=c(a),e=b(d.x,d.y);z.onMouseDown(a,d,e)}}function A(a){if(null!=z&&void 0!=z.onMouseOut){var d=c(a),e=b(d.x,d.y);z.onMouseOut(a,d,e)}}var y,B,J,H,G,L,I,P,S,F,aa,O,Z,R,V,M,N,E,D,T,
X,Q,K,U=!1,Y,z,C,W=!1,ba=!0;return{zoomIn:function(){g(1.2*K)},zoomOut:function(){g(K/1.2)},zoomFit:e,zoom100perc:function(){g(1)},toggleExtendedCrosshairBtn:h,setZoomRatio:g,getZoomRatio:function(){return K},loadImageFromURL:n,load:p,runImageOp:function(a){var b=a(Q,E,D);a=b.imageData;var c=b.width,b=b.height;wpd.appData.reset();t();f();E=c;D=b;T=E/(1*D);L.width=E;L.height=D;I.width=E;I.height=D;R.putImageData(a,0,0);Q=a;y.width=y.width;d();e();wpd.appData.plotLoaded(Q)},setTool:function(a){if(null!=
z&&void 0!=z.onRemove)z.onRemove();z=a;if(null!=z&&void 0!=z.onAttach)z.onAttach()},removeTool:t,getAllContexts:function(){return{mainCtx:S,dataCtx:F,drawCtx:aa,hoverCtx:O,topCtx:Z,oriImageCtx:R,oriDataCtx:V}},resetData:function(){I.width=I.width;B.width=B.width},resetHover:function(){H.width=H.width},imagePx:b,screenPx:function(a,b){return{x:a*K,y:b*K}},updateZoomOnEvent:function(a){a=c(a);a=b(a.x,a.y);k(a.x,a.y);wpd.zoomView.setCoords(a.x,a.y)},updateZoomToImagePosn:function(a,b){k(a,b);wpd.zoomView.setCoords(a,
b)},getDisplaySize:function(){return{width:M,height:N}},getImageSize:function(){return{width:E,height:D}},copyImageDataLayerToScreen:function(){F.drawImage(I,0,0,M,N)},setRepainter:function(a){if(null==C||void 0==C.painterName||null==a||void 0==a.painterName||C.painterName!=a.painterName){if(null!=C&&void 0!=C.onRemove)C.onRemove();C=a;if(null!=C&&void 0!=C.onAttach)C.onAttach()}},removeRepainter:f,forceHandlerRepaint:function(){if(null!=C&&void 0!=C.onForcedRedraw)C.onForcedRedraw()},getRepainter:function(){return C},
saveImage:function(){var a=document.createElement("canvas"),b=a.getContext("2d"),c,d,e,f;a.width=E;a.height=D;b.drawImage(L,0,0,E,D);c=b.getImageData(0,0,E,D);e=V.getImageData(0,0,E,D);for(d=0;d<c.data.length;d+=4)if(0!=e.data[d]||0!=e.data[d+1]||0!=e.data[d+2])f=e.data[d+3]/255,c.data[d]=(1-f)*c.data[d]+f*e.data[d],c.data[d+1]=(1-f)*c.data[d+1]+f*e.data[d+1],c.data[d+2]=(1-f)*c.data[d+2]+f*e.data[d+2];b.putImageData(c,0,0);window.open(a.toDataURL(),"_blank")}}}();wpd=wpd||{};
wpd.layoutManager=function(){function c(){var a=parseInt(document.body.offsetWidth,10),b=parseInt(document.body.offsetHeight,10);f.style.height=b+"px";e.style.height=b-280+"px";g.style.width=a-f.offsetWidth-5+"px";g.style.height=b+"px";d.style.height=b-44+"px";wpd.sidebar.resize()}function b(b){clearTimeout(a);a=setTimeout(c,80)}var a,d,f,e,g;return{initialLayout:function(){d=document.getElementById("graphicsContainer");f=document.getElementById("sidebarContainer");e=document.getElementById("sidebarControlsContainer");
g=document.getElementById("mainContainer");c();window.addEventListener("resize",b,!1)},getGraphicsViewportSize:function(){return{width:d.offsetWidth,height:d.offsetHeight}}}}();wpd=wpd||{};
wpd.popup=function(){function c(c){var d=document.createElement("div");d.className="popup-drag-mask";d.style.display="inline-block";d.addEventListener("mousemove",b,!1);d.addEventListener("mouseup",a,!1);d.addEventListener("mouseout",f,!1);document.body.appendChild(d);g={dragMaskDiv:d,initialMouseX:c.pageX,initialMouseY:c.pageY,initialWindowX:h.offsetLeft,initialWindowY:h.offsetTop};c.preventDefault();c.stopPropagation()}function b(a){d(a);a.stopPropagation();a.preventDefault()}function a(a){d(a);
e();a.stopPropagation();a.preventDefault()}function d(a){var b=g.initialWindowX+a.pageX-g.initialMouseX;a=g.initialWindowY+a.pageY-g.initialMouseY;var c=parseInt(document.body.offsetWidth,10),d=parseInt(document.body.offsetHeight,10),e=parseInt(h.offsetWidth,10),f=parseInt(h.offsetHeight,10);b+.7*e<c&&0<b&&0<a&&a+.5*f<d&&(h.style.top=a+"px",h.style.left=b+"px")}function f(a){e()}function e(){null!=g&&null!=g.dragMaskDiv&&(g.dragMaskDiv.removeEventListener("mouseout",f,!1),g.dragMaskDiv.removeEventListener("mouseup",
a,!1),g.dragMaskDiv.removeEventListener("mousemove",b,!1),g.dragMaskDiv.style.display="none",document.body.removeChild(g.dragMaskDiv),g=null)}var g=null,h=null;return{show:function(a){document.getElementById("shadow").style.visibility="visible";a=document.getElementById(a);var b=parseInt(window.innerWidth,10),d=parseInt(window.innerHeight,10),e=parseInt(a.offsetWidth,10),f=parseInt(a.offsetHeight,10),d=(d-f)/2;a.style.left=(b-e)/2+"px";a.style.top=(60<d?60:d)+"px";a.style.visibility="visible";for(b=
0;b<a.childNodes.length;b++)if("popupheading"===a.childNodes[b].className){a.childNodes[b].addEventListener("mousedown",c,!1);break}h=a},close:function(a){document.getElementById("shadow").style.visibility="hidden";document.getElementById(a).style.visibility="hidden";e();h=null}}}();
wpd.busyNote=function(){var c,b=!1;return{show:function(){b||(null==c&&(c=document.createElement("div"),c.id="wait",c.innerHTML='<p align="center">Processing...</p>'),document.body.appendChild(c),b=!0)},close:function(){null!=c&&!0===b&&(document.body.removeChild(c),b=!1)}}}();
wpd.messagePopup=function(){var c;return{show:function(b,a,d){wpd.popup.show("messagePopup");document.getElementById("message-popup-heading").innerHTML=b;document.getElementById("message-popup-text").innerHTML=a;c=d},close:function(){wpd.popup.close("messagePopup");null!=c&&c()}}}();
wpd.okCancelPopup=function(){var c,b;return{show:function(a,d,f,e){wpd.popup.show("okCancelPopup");document.getElementById("ok-cancel-popup-heading").innerHTML=a;document.getElementById("ok-cancel-popup-text").innerHTML=d;c=f;b=e},ok:function(){wpd.popup.close("okCancelPopup");c()},cancel:function(){wpd.popup.close("okCancelPopup");b()}}}();wpd.unsupported=function(){wpd.messagePopup.show("Unsupported Feature!","This feature has not been implemented in the current version. This may be available in a future release.")};
wpd=wpd||{};
wpd.sidebar=function(){function c(){var b=document.getElementsByClassName("sidebar"),a;for(a=0;a<b.length;a++)b[a].style.display="none"}return{show:function(b){c();b=document.getElementById(b);b.style.display="inline-block";b.style.height=parseInt(document.body.offsetHeight,10)-280+"px"},clear:c,resize:function(){var b=document.getElementsByClassName("sidebar"),a;for(a=0;a<b.length;a++)"inline-block"===b[a].style.display&&(b[a].style.height=parseInt(document.body.offsetHeight,10)-280+"px")}}}();
wpd=wpd||{};wpd.toolbar=function(){function c(){var b=document.getElementsByClassName("toolbar"),a;for(a=0;a<b.length;a++)b[a].style.visibility="hidden"}return{show:function(b){c();document.getElementById(b).style.visibility="visible"},clear:c}}();wpd=wpd||{};
wpd.transformationEquations=function(){return{show:function(){if(!1===wpd.appData.isAligned())wpd.messagePopup.show("Transformation Equations","Transformation equations are available only after axes have been calibrated.");else{wpd.popup.show("axes-transformation-equations-window");var c=document.getElementById("axes-transformation-equation-list"),b="",a=wpd.appData.getPlotData().axes,d=a.getTransformationEquations(),b=b+"<p><b>Axes Type</b>: ";a instanceof wpd.XYAxes?b+="XY</p>":a instanceof wpd.PolarAxes?
b+="Polar</p>":a instanceof wpd.TernaryAxes?b+="Ternary</p>":a instanceof wpd.MapAxes?b+="Map</p>":a instanceof wpd.ImageAxes&&(b+="Image</p>");if(null!=d.pixelToData){b+="<p><b>Pixel to Data</b></p><ol>";for(a=0;a<d.pixelToData.length;a++)b+='<li><p class="footnote">'+d.pixelToData[a]+"</p></li>";b+="</ol>"}b+="<p>&nbsp;</p>";if(null!=d.dataToPixel){b+="<p><b>Data to Pixel</b></p><ol>";for(a=0;a<d.dataToPixel.length;a++)b+='<li><p class="footnote">'+d.dataToPixel[a]+"</p></li>";b+="</ol>"}c.innerHTML=
b}}}}();wpd=wpd||{};
wpd.webcamCapture=function(){function c(){void 0!=b&&b.stop();wpd.popup.close("webcamCapture")}var b;return{start:function(){if(null==(navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia))wpd.messagePopup.show("Webcam Capture","Your browser does not support webcam capture using HTML5 APIs. A recent version of Google Chrome is recommended.");else{wpd.popup.show("webcamCapture");var a=document.getElementById("webcamVideo");navigator.getUserMedia=navigator.getUserMedia||
navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia;navigator.getUserMedia({video:!0},function(c){b=c;a.src=window.URL.createObjectURL(c)},function(){})}},cancel:function(){c()},capture:function(){var a=document.createElement("canvas"),b=document.getElementById("webcamVideo"),f=a.getContext("2d"),e;a.width=b.videoWidth;a.height=b.videoHeight;f.drawImage(b,0,0);e=f.getImageData(0,0,a.width,a.height);c();wpd.graphicsWidget.runImageOp(function(){return{imageData:e,width:a.width,
height:a.height}})}}}();wpd=wpd||{};
wpd.zoomView=function(){function c(){var a=document.getElementById("zoomCrossHair"),b=a.getContext("2d");a.width=a.width;b.strokeStyle="black"===h?"rgba(0,0,0,1)":"red"===h?"rgba(255,0,0,1)":"yellow"===h?"rgba(255,255,0,1)":"rgba(0,0,0,1)";b.beginPath();b.moveTo(125,0);b.lineTo(125,250);b.moveTo(0,125);b.lineTo(250,125);b.stroke()}var b,a,d,f,e,g,h="black";return{initZoom:function(){b=document.getElementById("zoomCanvas");a=b.getContext("2d");d=document.createElement("canvas");f=d.getContext("2d");
e=document.getElementById("mousePosition");g=5;c()},setZoomImage:function(c,e,h,n,l){d.width=n/g;d.height=l/g;f.putImageData(c,0,0);b.width=b.width;a.drawImage(d,e,h,n,l)},setCoords:function(a,b){if(wpd.appData.isAligned()){var c=wpd.appData.getPlotData();e.innerHTML=c.axes.pixelToLiveString(a,b)}else e.innerHTML=a.toFixed(2)+", "+b.toFixed(2)},setZoomRatio:function(a){g=a},getZoomRatio:function(){return g},getSize:function(){return{width:250,height:250}},showSettingsWindow:function(){document.getElementById("zoom-magnification-value").value=
g;document.getElementById("zoom-crosshair-color-value").value=h;wpd.popup.show("zoom-settings-popup")},applySettings:function(){g=document.getElementById("zoom-magnification-value").value;h=document.getElementById("zoom-crosshair-color-value").value;c();wpd.popup.close("zoom-settings-popup")}}}();wpd=wpd||{};
wpd.xyCalibration=function(){function c(){wpd.popup.show("xyAlignment")}return{start:function(){wpd.popup.show("xyAxesInfo")},pickCorners:function(){wpd.popup.close("xyAxesInfo");var b=new wpd.AxesCornersTool(4,2,["X1","X2","Y1","Y2"]);wpd.graphicsWidget.setTool(b)},getCornerValues:c,align:function(){var b=document.getElementById("xmin").value,a=document.getElementById("xmax").value,d=document.getElementById("ymin").value,f=document.getElementById("ymax").value,e=document.getElementById("xlog").checked,
g=document.getElementById("ylog").checked,h=new wpd.XYAxes,k=wpd.alignAxes.getActiveCalib();k.setDataAt(0,b,d);k.setDataAt(1,a,d);k.setDataAt(2,b,d);k.setDataAt(3,a,f);if(!h.calibrate(k,e,g))return wpd.popup.close("xyAlignment"),wpd.messagePopup.show("Invalid Inputs","Please enter valid values for calibration.",c),!1;b=wpd.appData.getPlotData();b.axes=h;b.calibration=k;wpd.popup.close("xyAlignment");return!0}}}();
wpd.barCalibration=function(){function c(){wpd.popup.show("barAlignment")}return{start:function(){wpd.popup.show("barAxesInfo")},pickCorners:function(){wpd.popup.close("barAxesInfo");var b=new wpd.AxesCornersTool(2,2,["P1","P2"]);wpd.graphicsWidget.setTool(b)},getCornerValues:c,align:function(){var b=document.getElementById("bar-axes-p1").value,a=document.getElementById("bar-axes-p2").value,d=document.getElementById("bar-axes-log-scale").checked,f=new wpd.BarAxes,e=wpd.alignAxes.getActiveCalib();
e.setDataAt(0,0,b);e.setDataAt(1,0,a);if(!f.calibrate(e,d))return wpd.popup.close("barAlignment"),wpd.messagePopup.show("Invalid Inputs","Please enter valid values for calibration.",c),!1;b=wpd.appData.getPlotData();b.axes=f;b.calibration=e;wpd.popup.close("barAlignment");return!0}}}();
wpd.polarCalibration=function(){return{start:function(){wpd.popup.show("polarAxesInfo")},pickCorners:function(){wpd.popup.close("polarAxesInfo");var c=new wpd.AxesCornersTool(3,2,["Origin","P1","P2"]);wpd.graphicsWidget.setTool(c)},getCornerValues:function(){wpd.popup.show("polarAlignment")},align:function(){var c=parseFloat(document.getElementById("rpoint1").value),b=parseFloat(document.getElementById("thetapoint1").value),a=parseFloat(document.getElementById("rpoint2").value),d=parseFloat(document.getElementById("thetapoint2").value),
f=document.getElementById("degrees").checked;document.getElementById("radians");var e=document.getElementById("clockwise").checked,g=new wpd.PolarAxes,h=wpd.alignAxes.getActiveCalib();h.setDataAt(1,c,b);h.setDataAt(2,a,d);g.calibrate(h,f,e);c=wpd.appData.getPlotData();c.axes=g;c.calibration=h;wpd.popup.close("polarAlignment");return!0}}}();
wpd.ternaryCalibration=function(){return{start:function(){wpd.popup.show("ternaryAxesInfo")},pickCorners:function(){wpd.popup.close("ternaryAxesInfo");var c=new wpd.AxesCornersTool(3,3,["A","B","C"]);wpd.graphicsWidget.setTool(c)},getCornerValues:function(){wpd.popup.show("ternaryAlignment")},align:function(){document.getElementById("range0to1");var c=document.getElementById("range0to100").checked,b=document.getElementById("ternarynormal").checked,a=new wpd.TernaryAxes,d=wpd.alignAxes.getActiveCalib();
a.calibrate(d,c,b);c=wpd.appData.getPlotData();c.axes=a;c.calibration=d;wpd.popup.close("ternaryAlignment");return!0}}}();
wpd.mapCalibration=function(){function c(){wpd.popup.show("mapAlignment")}return{start:function(){wpd.popup.show("mapAxesInfo")},pickCorners:function(){wpd.popup.close("mapAxesInfo");var b=new wpd.AxesCornersTool(2,2,["P1","P2"]);wpd.graphicsWidget.setTool(b);b.onComplete=c},getCornerValues:c,align:function(){var b=parseFloat(document.getElementById("scaleLength").value),a=document.getElementById("scaleUnits").value,c=new wpd.MapAxes,f=wpd.alignAxes.getActiveCalib();c.calibrate(f,b,a);b=wpd.appData.getPlotData();
b.axes=c;b.calibration=f;wpd.popup.close("mapAlignment");return!0}}}();
wpd.AxesCornersTool=function(){return function(c,b,a){var d=0;b=new wpd.Calibration(b);var f=!0;b.labels=a;wpd.alignAxes.setActiveCalib(b);wpd.graphicsWidget.resetData();this.onMouseClick=function(a,b,h){f?(d+=1,b=wpd.alignAxes.getActiveCalib(),b.addPoint(h.x,h.y,0,0),b.unselectAll(),b.selectPoint(d-1),wpd.graphicsWidget.forceHandlerRepaint(),d===c&&(f=!1,wpd.alignAxes.calibrationCompleted())):(b=wpd.alignAxes.getActiveCalib(),b.unselectAll(),b.selectNearestPoint(h.x,h.y),wpd.graphicsWidget.forceHandlerRepaint());
wpd.graphicsWidget.updateZoomOnEvent(a)};this.onKeyDown=function(a){var b=wpd.alignAxes.getActiveCalib();if(0!==b.getSelectedPoints().length){var c=b.getPoint(b.getSelectedPoints()[0]),d=c.px,c=c.py,f=!0===a.shiftKey?5/wpd.graphicsWidget.getZoomRatio():.5/wpd.graphicsWidget.getZoomRatio();if(wpd.keyCodes.isUp(a.keyCode))c-=f;else if(wpd.keyCodes.isDown(a.keyCode))c+=f;else if(wpd.keyCodes.isLeft(a.keyCode))d-=f;else if(wpd.keyCodes.isRight(a.keyCode))d+=f;else return;b.changePointPx(b.getSelectedPoints()[0],
d,c);wpd.graphicsWidget.forceHandlerRepaint();wpd.graphicsWidget.updateZoomToImagePosn(d,c);a.preventDefault();a.stopPropagation()}}}}();
wpd.AlignmentCornersRepainter=function(){return function(){this.painterName="AlignmentCornersReptainer";this.onForcedRedraw=function(){wpd.graphicsWidget.resetData();this.onRedraw()};this.onRedraw=function(){var c=wpd.alignAxes.getActiveCalib();if(null!=c){var b,a,d;for(b=0;b<c.getCount();b++)a=c.getPoint(b),a={x:a.px,y:a.py},d=c.isPointSelected(b)?"rgba(0,200,0,1)":"rgba(200,0,0,1)",wpd.graphicsHelper.drawPoint(a,d,c.labels[b])}}}}();
wpd.alignAxes=function(){var c,b;return{start:function(){xyEl=document.getElementById("r_xy");polarEl=document.getElementById("r_polar");ternaryEl=document.getElementById("r_ternary");mapEl=document.getElementById("r_map");imageEl=document.getElementById("r_image");barEl=document.getElementById("r_bar");wpd.popup.close("axesList");if(!0===xyEl.checked)b=wpd.xyCalibration;else if(!0===barEl.checked)b=wpd.barCalibration;else if(!0===polarEl.checked)b=wpd.polarCalibration;else if(!0===ternaryEl.checked)b=
wpd.ternaryCalibration;else if(!0===mapEl.checked)b=wpd.mapCalibration;else if(!0===imageEl.checked){b=null;var a=new wpd.ImageAxes;a.calibrate();wpd.appData.getPlotData().axes=a;wpd.appData.isAligned(!0);wpd.acquireData.load()}null!=b&&(b.start(),wpd.graphicsWidget.setRepainter(new wpd.AlignmentCornersRepainter))},calibrationCompleted:function(){wpd.sidebar.show("axes-calibration-sidebar")},getCornerValues:function(){b.getCornerValues()},align:function(){wpd.graphicsWidget.removeTool();wpd.graphicsWidget.removeRepainter();
wpd.graphicsWidget.resetData();b.align()&&(wpd.appData.isAligned(!0),wpd.acquireData.load())},getActiveCalib:function(){return c},setActiveCalib:function(a){c=a}}}();wpd=wpd||{};
wpd.autoExtraction=function(){function c(){var b=wpd.appData.getPlotData();b.getActiveDataSeries();var a=b.getActiveDataSeriesIndex(),c=document.getElementById("automatic-sidebar-dataset-list"),f="",e;for(e=0;e<b.dataSeriesColl.length;e++)f+="<option>"+b.dataSeriesColl[e].name+"</option>";c.innerHTML=f;c.selectedIndex=a}return{start:function(){wpd.sidebar.show("auto-extraction-sidebar");c();wpd.colorPicker.init();wpd.algoManager.updateAlgoList()},updateDatasetControl:c,changeDataset:function(){var b=
document.getElementById("automatic-sidebar-dataset-list").selectedIndex;wpd.appData.getPlotData().setActiveDataSeriesIndex(b);wpd.graphicsWidget.forceHandlerRepaint();wpd.dataPointCounter.setCount()}}}();
wpd.algoManager=function(){function c(){var a=document.getElementById("auto-extract-algo-name").value,b=wpd.appData.getPlotData().getAutoDetector();b.algorithm="averagingWindow"===a?new wpd.AveragingWindowAlgo:"XStepWithInterpolation"===a?new wpd.XStepWithInterpolationAlgo:"XStep"===a?new wpd.AveragingWindowWithStepSizeAlgo:"blobDetector"===a?new wpd.BlobDetectorAlgo:"barExtraction"===a||"histogram"===a?new wpd.BarExtractionAlgo:new wpd.AveragingWindowAlgo;var b=b.algorithm,a=document.getElementById("algo-parameter-container"),
b=b.getParamList(),c,e="<table>";for(c=0;c<b.length;c++)e+="<tr><td>"+b[c][0]+'</td><td><input type="text" size=3 id="algo-param-'+c+'" class="algo-params" value="'+b[c][2]+'"/></td><td>'+b[c][1]+"</td></tr>";a.innerHTML=e+"</table>"}var b;return{updateAlgoList:function(){var a="",d=wpd.appData.getPlotData().axes,f=document.getElementById("auto-extract-algo-name");d!==b&&(b=d,d instanceof wpd.BarAxes||(a+='<option value="averagingWindow">Averaging Window</option>'),d instanceof wpd.XYAxes&&!d.isLogX()&&
!d.isLogY()&&(a+='<option value="XStepWithInterpolation">X Step w/ Interpolation</option><option value="XStep">X Step</option>'),d instanceof wpd.BarAxes||(a+='<option value="blobDetector">Blob Detector</option>'),d instanceof wpd.BarAxes&&(a+='<option value="barExtraction">Bar Extraction</option>'),d instanceof wpd.XYAxes&&(a+='<option value="histogram">Histogram</option>'),f.innerHTML=a,c())},applyAlgoSelection:c,run:function(){wpd.busyNote.show();setTimeout(function(){var a=wpd.appData.getPlotData().getAutoDetector(),
b=a.algorithm,c=new wpd.DataPointsRepainter,e=document.getElementsByClassName("algo-params"),g,h,k=wpd.graphicsWidget.getAllContexts(),q=wpd.graphicsWidget.getImageSize();for(g=0;g<e.length;g++)h=e[g].id,h=parseInt(h.replace("algo-param-",""),10),b.setParam(h,parseFloat(e[g].value));wpd.graphicsWidget.removeTool();a.imageData=k.oriImageCtx.getImageData(0,0,q.width,q.height);a.generateBinaryData();wpd.graphicsWidget.setRepainter(c);b.run(wpd.appData.getPlotData());wpd.graphicsWidget.forceHandlerRepaint();
wpd.dataPointCounter.setCount();wpd.busyNote.close();return!0},10)}}}();wpd=wpd||{};
wpd.colorSelectionWidget=function(){function c(){document.getElementById("color-selection-selected-color-box").style.backgroundColor="rgb("+b[0]+","+b[1]+","+b[2]+")";document.getElementById("color-selection-red").value=b[0];document.getElementById("color-selection-green").value=b[1];document.getElementById("color-selection-blue").value=b[2];var a=document.getElementById("color-selection-options"),c=wpd.appData.getPlotData().topColors,d=10<c.length?10:c.length,f,q="",m,n;for(f=0;f<d;f++)n="rgb("+
c[f].r+","+c[f].g+","+c[f].b+");",m=c[f].percentage.toFixed(3)+"%",q+='<div class="colorOptionBox" style="background-color: '+n+'" title="'+m+'" onclick="wpd.colorSelectionWidget.selectTopColor('+f+');"></div>';a.innerHTML=q;wpd.popup.show("color-selection-widget")}var b,a,d,f;return{setParams:function(c){b=c.color;a=c.triggerElementId;d=c.title;f=c.setColorDelegate;document.getElementById("color-selection-title").innerHTML=d},startPicker:c,pickColor:function(){wpd.popup.close("color-selection-widget");
var a=new wpd.ColorPickerTool;a.onComplete=function(a){b=a;f(a);wpd.graphicsWidget.removeTool();c()};wpd.graphicsWidget.setTool(a)},setColor:function(){var c=[];c[0]=parseInt(document.getElementById("color-selection-red").value,10);c[1]=parseInt(document.getElementById("color-selection-green").value,10);c[2]=parseInt(document.getElementById("color-selection-blue").value,10);b=c;f(c);wpd.popup.close("color-selection-widget");document.getElementById(a).style.backgroundColor="rgb("+b[0]+","+b[1]+","+
b[2]+")"},selectTopColor:function(a){var d=[],h=wpd.appData.getPlotData().topColors;d[0]=h[a].r;d[1]=h[a].g;d[2]=h[a].b;b=d;f(d);c()},paintFilteredColor:function(a,b){var c=wpd.graphicsWidget.getAllContexts();wpd.appData.getPlotData().getAutoDetector();var d=wpd.graphicsWidget.getImageSize(),f,m,n;n=c.oriDataCtx.getImageData(0,0,d.width,d.height);if(null!=b&&0!==b.length){for(f=0;f<b.length;f++)m=b[f],!0===a[m]?(parseInt(m/d.width,10),n.data[4*m]=255,n.data[4*m+1]=255,n.data[4*m+2]=0,n.data[4*m+3]=
255):(n.data[4*m]=0,n.data[4*m+1]=0,n.data[4*m+2]=0,n.data[4*m+3]=150);c.oriDataCtx.putImageData(n,0,0);wpd.graphicsWidget.copyImageDataLayerToScreen()}}}}();
wpd.colorPicker=function(){function c(){return{color:wpd.appData.getPlotData().getAutoDetector().fgColor,triggerElementId:"color-button",title:"Specify Plot (Foreground) Color",setColorDelegate:function(a){wpd.appData.getPlotData().getAutoDetector().fgColor=a}}}function b(){return{color:wpd.appData.getPlotData().getAutoDetector().bgColor,triggerElementId:"color-button",title:"Specify Background Color",setColorDelegate:function(a){wpd.appData.getPlotData().getAutoDetector().bgColor=a}}}function a(){var a=
document.getElementById("color-button"),b=document.getElementById("color-distance-value"),c=wpd.appData.getPlotData().getAutoDetector(),g=document.getElementById("color-detection-mode-select"),h;h="fg"===c.colorDetectionMode?c.fgColor:c.bgColor;color_distance=c.colorDistance;a.style.backgroundColor="rgb("+h[0]+","+h[1]+","+h[2]+")";b.value=color_distance;g.value=c.colorDetectionMode}return{startPicker:function(){wpd.graphicsWidget.removeTool();wpd.graphicsWidget.removeRepainter();wpd.graphicsWidget.resetData();
"fg"===wpd.appData.getPlotData().getAutoDetector().colorDetectionMode?wpd.colorSelectionWidget.setParams(c()):wpd.colorSelectionWidget.setParams(b());wpd.colorSelectionWidget.startPicker()},changeDetectionMode:function(){var b=document.getElementById("color-detection-mode-select");wpd.appData.getPlotData().getAutoDetector().colorDetectionMode=b.value;a()},changeColorDistance:function(){var a=parseFloat(document.getElementById("color-distance-value").value);wpd.appData.getPlotData().getAutoDetector().colorDistance=
a},init:a,testColorDetection:function(){wpd.graphicsWidget.removeTool();wpd.graphicsWidget.resetData();wpd.graphicsWidget.setRepainter(new wpd.ColorFilterRepainter);var a=wpd.graphicsWidget.getAllContexts(),b=wpd.appData.getPlotData().getAutoDetector(),c=wpd.graphicsWidget.getImageSize();b.imageData=a.oriImageCtx.getImageData(0,0,c.width,c.height);b.generateBinaryData();wpd.colorSelectionWidget.paintFilteredColor(b.binaryData,b.mask)}}}();
wpd.ColorPickerTool=function(){return function(){var c=wpd.graphicsWidget.getAllContexts();this.onMouseClick=function(b,a,d){b=c.oriImageCtx.getImageData(d.x,d.y,1,1);this.onComplete([b.data[0],b.data[1],b.data[2]])};this.onComplete=function(b){}}}();wpd.ColorFilterRepainter=function(){return function(){this.painterName="colorFilterRepainter";this.onRedraw=function(){var c=wpd.appData.getPlotData().getAutoDetector();wpd.colorSelectionWidget.paintFilteredColor(c.binaryData,c.mask)}}}();wpd=wpd||{};
wpd.plotDataProvider=function(){return{getDatasetNames:function(){var c=wpd.appData.getPlotData(),b=[],a;for(a=0;a<c.dataSeriesColl.length;a++)b[a]=c.dataSeriesColl[a].name;return b},getDatasetIndex:function(){return wpd.appData.getPlotData().getActiveDataSeriesIndex()},setDatasetIndex:function(c){wpd.appData.getPlotData().setActiveDataSeriesIndex(c);wpd.graphicsWidget.forceHandlerRepaint();wpd.dataPointCounter.setCount()},getData:function(){if(wpd.appData.getPlotData().axes instanceof wpd.BarAxes){var c=
[],b=[],a=[],a=wpd.appData.getPlotData(),c=a.getActiveDataSeries(),a=a.axes,d,f,e;for(d=0;d<c.getCount();d++)f=c.getPixel(d),e=a.pixelToData(f.x,f.y),b[d]=[],f=null==f.metadata?"Bar"+d:f.metadata[0],b[d][0]=f,b[d][1]=e[0];c=["Label","Value"];a=[!1,!0];return{fields:c,fieldDateFormat:[],rawData:b,allowConnectivity:!1,connectivityFieldIndices:[],isFieldSortable:a}}var c=wpd.appData.getPlotData(),b=c.getActiveDataSeries(),c=c.axes,g=[],a=[];d=[];e=[];f=[];for(var h,k,q,m=b.hasMetadata(),n=b.getMetadataKeys(),
l=!0===m?n.length:0,p,g=0;g<b.getCount();g++){k=b.getPixel(g);q=c.pixelToData(k.x,k.y);e[g]=[];for(h=0;h<q.length;h++)e[g][h]=q[h];for(h=0;h<l;h++)p=null==k.metadata||null==k.metadata[h]?0:k.metadata[h],e[g][q.length+h]=p}g=c.getAxesLabels();m&&(g=g.concat(n));for(h=0;h<g.length;h++)h<c.getDimensions()&&(d[h]=h,null!=c.isDate&&c.isDate(h)&&(a[h]=c.getInitialDateFormat(h))),f[h]=!0;return{fields:g,fieldDateFormat:a,rawData:e,allowConnectivity:!0,connectivityFieldIndices:d,isFieldSortable:f}}}}();
wpd.measurementDataProvider=function(){var c="distance";return{getDatasetNames:function(){if("angle"===c)return["Angle Measurements"];if("distance"===c)return["Distance Measurements"]},getDatasetIndex:function(){return 0},setDatasetIndex:function(b){},setDataSource:function(b){c=b},getData:function(){var b=[],a=[],d=[],f=wpd.appData.getPlotData(),e=f.axes,g=wpd.appData.isAligned()&&e instanceof wpd.MapAxes;if("distance"===c){d=f.distanceMeasurementData;for(b=0;b<d.connectionCount();b++)a[b]=[],a[b][0]=
"Dist"+b,a[b][1]=g?e.pixelToDataDistance(d.getDistance(b)):d.getDistance(b);b=["Label","Distance"];d=[!1,!0]}else if("angle"===c){d=f.angleMeasurementData;for(b=0;b<d.connectionCount();b++)a[b]=[],a[b][0]="Theta"+b,a[b][1]=d.getAngle(b);b=["Label","Angle"];d=[!1,!0]}return{fields:b,fieldDateFormat:[],rawData:a,allowConnectivity:!1,connectivityFieldIndices:[],isFieldSortable:d}}}}();wpd=wpd||{};
wpd.graphicsHelper=function(){return{drawPoint:function(c,b,a){var d=wpd.graphicsWidget.screenPx(c.x,c.y),f=wpd.graphicsWidget.getAllContexts(),e;null!=a&&(f.dataCtx.font="15px sans-serif",e=f.dataCtx.measureText(a).width,f.dataCtx.fillStyle="rgba(255, 255, 255, 0.7)",f.dataCtx.fillRect(d.x-13,d.y-8,e+5,35),f.dataCtx.fillStyle=b,f.dataCtx.fillText(a,d.x-10,d.y+18));f.dataCtx.beginPath();f.dataCtx.fillStyle=b;f.dataCtx.arc(d.x,d.y,3,0,2*Math.PI,!0);f.dataCtx.fill();null!=a&&(f.oriDataCtx.font="15px sans-serif",
f.oriDataCtx.fillStyle=b,f.oriDataCtx.fillText(a,c.x-10,c.y+18));f.oriDataCtx.beginPath();f.oriDataCtx.fillStyle=b;f.oriDataCtx.arc(c.x,c.y,3,0,2*Math.PI,!0);f.oriDataCtx.fill()}}}();wpd=wpd||{};
wpd.gridDetection=function(){return{start:function(){wpd.graphicsWidget.removeTool();wpd.graphicsWidget.removeRepainter();wpd.graphicsWidget.resetData();wpd.sidebar.show("grid-detection-sidebar")},markBox:function(){var c=new wpd.GridBoxTool;wpd.graphicsWidget.setTool(c)},clearMask:function(){wpd.graphicsWidget.removeTool();wpd.graphicsWidget.removeRepainter();wpd.appData.getPlotData().getAutoDetector().gridMask={xmin:null,xmax:null,ymin:null,ymax:null,pixels:[]};wpd.graphicsWidget.resetData()},viewMask:function(){var c=
new wpd.GridViewMaskTool;wpd.graphicsWidget.setTool(c)},grabMask:function(){var c=wpd.graphicsWidget.getAllContexts(),b=wpd.graphicsWidget.getImageSize(),c=c.oriDataCtx.getImageData(0,0,b.width,b.height),a=[],d,f=0,e=wpd.appData.getPlotData().getAutoDetector(),g,h;for(d=0;d<c.data.length;d+=4)255===c.data[d]&&255===c.data[d+1]&&0===c.data[d+2]&&(a[f]=d/4,f++,g=parseInt(d/4%b.width,10),h=parseInt(d/4/b.width,10),1===f?(e.gridMask.xmin=g,e.gridMask.xmax=g,e.gridMask.ymin=h,e.gridMask.ymax=h):(g<e.gridMask.xmin&&
(e.gridMask.xmin=g),g>e.gridMask.xmax&&(e.gridMask.xmax=g),h<e.gridMask.ymin&&(e.gridMask.ymin=h),h>e.gridMask.ymax&&(e.gridMask.ymax=h)));e.gridMask.pixels=a},startColorPicker:function(){wpd.colorSelectionWidget.setParams({color:wpd.appData.getPlotData().getAutoDetector().gridLineColor,triggerElementId:"grid-color-picker-button",title:"Specify Grid Line Color",setColorDelegate:function(c){wpd.appData.getPlotData().getAutoDetector().gridLineColor=c}});wpd.colorSelectionWidget.startPicker()},changeColorDistance:function(){var c=
parseFloat(document.getElementById("grid-color-distance").value);wpd.appData.getPlotData().getAutoDetector().gridColorDistance=c},testColor:function(){wpd.graphicsWidget.removeTool();wpd.graphicsWidget.resetData();wpd.graphicsWidget.setRepainter(new wpd.GridColorFilterRepainter);var c=wpd.graphicsWidget.getAllContexts(),b=wpd.appData.getPlotData().getAutoDetector(),a=wpd.graphicsWidget.getImageSize();b.imageData=c.oriImageCtx.getImageData(0,0,a.width,a.height);b.generateGridBinaryData();wpd.colorSelectionWidget.paintFilteredColor(b.gridBinaryData,
b.gridMask.pixels)},run:function(){wpd.graphicsWidget.removeTool();wpd.graphicsWidget.removeRepainter();var c=wpd.appData.getPlotData().getAutoDetector(),b=wpd.graphicsWidget.getAllContexts(),a=wpd.graphicsWidget.getImageSize();c.imageData=b.oriImageCtx.getImageData(0,0,a.width,a.height);c.generateGridBinaryData();wpd.gridDetectionCore.setHorizontalParameters(!0,5,5);wpd.gridDetectionCore.setVerticalParameters(!0,5,5);wpd.gridDetectionCore.run()},clear:function(){wpd.graphicsWidget.removeTool();wpd.appData.getPlotData().gridData=
null;wpd.graphicsWidget.removeRepainter();wpd.graphicsWidget.resetData()}}}();wpd.GridColorFilterRepainter=function(){return function(){this.painterName="gridColorFilterRepainter";this.onRedraw=function(){var c=wpd.appData.getPlotData().getAutoDetector();wpd.colorSelectionWidget.paintFilteredColor(c.gridBinaryData,c.gridMask.pixels)}}}();
wpd.GridBoxTool=function(){return function(){var c=!1,b,a,d=wpd.graphicsWidget.getAllContexts(),f,e,g=function(){wpd.graphicsWidget.resetHover();d.hoverCtx.strokeStyle="rgb(0,0,0)";d.hoverCtx.strokeRect(a.x,a.y,e.x-a.x,e.y-a.y)},h=function(e,h,g){!1!==c&&(clearTimeout(f),c=!1,wpd.graphicsWidget.resetHover(),d.dataCtx.fillStyle="rgba(255,255,0,0.8)",d.dataCtx.fillRect(a.x,a.y,h.x-a.x,h.y-a.y),d.oriDataCtx.fillStyle="rgba(255,255,0,0.8)",d.oriDataCtx.fillRect(b.x,b.y,g.x-b.x,g.y-b.y))},k=null,q=null;
this.onAttach=function(){wpd.graphicsWidget.setRepainter(new wpd.GridMaskPainter);document.getElementById("grid-mask-box").classList.add("pressed-button");document.getElementById("grid-mask-view").classList.add("pressed-button")};this.onMouseDown=function(d,e,f){!0!==c&&(c=!0,b=f,a=e)};this.onMouseMove=function(a,b,d){!1!==c&&(e=b,clearTimeout(f),f=setTimeout(g,2))};this.onMouseOut=function(a,b,d){!0===c&&(clearTimeout(f),k=b,q=d)};this.onDocumentMouseUp=function(a,b,c){null!=k&&null!=q?h(a,k,q):
h(a,b,c);q=k=null};this.onMouseUp=function(a,b,c){h(a,b,c)};this.onRemove=function(){document.getElementById("grid-mask-box").classList.remove("pressed-button");document.getElementById("grid-mask-view").classList.remove("pressed-button");wpd.gridDetection.grabMask()}}}();
wpd.GridViewMaskTool=function(){return function(){this.onAttach=function(){wpd.graphicsWidget.setRepainter(new wpd.GridMaskPainter);document.getElementById("grid-mask-view").classList.add("pressed-button")};this.onRemove=function(){document.getElementById("grid-mask-view").classList.remove("pressed-button");wpd.gridDetection.grabMask()}}}();
wpd.GridMaskPainter=function(){return function(){var c=wpd.graphicsWidget.getAllContexts(),b=wpd.appData.getPlotData().getAutoDetector(),a=function(){if(null!=b.gridMask.pixels&&0!==b.gridMask.pixels.length){var a,f;a=wpd.graphicsWidget.getImageSize();imgData=c.oriDataCtx.getImageData(0,0,a.width,a.height);for(a=0;a<b.gridMask.pixels.length;a++)f=b.gridMask.pixels[a],imgData.data[4*f]=255,imgData.data[4*f+1]=255,imgData.data[4*f+2]=0,imgData.data[4*f+3]=200;c.oriDataCtx.putImageData(imgData,0,0);
wpd.graphicsWidget.copyImageDataLayerToScreen()}};this.painterName="gridMaskPainter";this.onRedraw=function(){wpd.gridDetection.grabMask();a()};this.onAttach=function(){wpd.graphicsWidget.resetData();a()}}}();wpd=wpd||{};
wpd.imageOps=function(){function c(a,b,c){var e,g,h,k,q,m;for(e=0;e<c;e++)for(g=0;g<b/2;g++)for(h=4*(e*b+g),k=4*((e+1)*b-(g+1)),m=0;4>m;m++)q=a.data[h+m],a.data[h+m]=a.data[k+m],a.data[k+m]=q;return{imageData:a,width:b,height:c}}function b(a,b,c){var e,g,h,k,q,m;for(e=0;e<c/2;e++)for(g=0;g<b;g++)for(h=4*(e*b+g),k=4*((c-(e+2))*b+g),m=0;4>m;m++)q=a.data[h+m],a.data[h+m]=a.data[k+m],a.data[k+m]=q;return{imageData:a,width:b,height:c}}return{hflip:function(){wpd.graphicsWidget.runImageOp(c)},vflip:function(){wpd.graphicsWidget.runImageOp(b)}}}();
wpd=wpd||{};wpd.keyCodes=function(){return{isUp:function(c){return 38===c},isDown:function(c){return 40===c},isLeft:function(c){return 37===c},isRight:function(c){return 39===c},isTab:function(c){return 9===c},isDel:function(c){return 46===c},isBackspace:function(c){return 8===c},isAlphabet:function(c,b){return 90<c||65>c?!1:String.fromCharCode(c).toLowerCase()===b},isEnter:function(c){return 13===c},isEsc:function(c){return 27===c}}}();wpd=wpd||{};
wpd.acquireData=function(){function c(){var a=new wpd.ManualSelectionTool;wpd.graphicsWidget.setTool(a)}function b(){var a=new wpd.DeleteDataPointTool;wpd.graphicsWidget.setTool(a)}function a(){wpd.appData.getPlotData().getActiveDataSeries().clearAll();wpd.graphicsWidget.removeTool();wpd.graphicsWidget.resetData();wpd.dataPointCounter.setCount();wpd.graphicsWidget.removeRepainter()}function d(){wpd.sidebar.show("acquireDataSidebar");f();var a=wpd.appData.getPlotData().axes;document.getElementById("edit-data-labels").style.display=
a instanceof wpd.BarAxes?"inline-block":"none";wpd.dataPointCounter.setCount()}function f(){var a=wpd.appData.getPlotData();a.getActiveDataSeries();var b=a.getActiveDataSeriesIndex(),c=document.getElementById("manual-sidebar-dataset-list"),d="",e;for(e=0;e<a.dataSeriesColl.length;e++)d+="<option>"+a.dataSeriesColl[e].name+"</option>";c.innerHTML=d;c.selectedIndex=b}function e(){wpd.graphicsWidget.setTool(new wpd.AdjustDataPointTool)}function g(){wpd.graphicsWidget.setTool(new wpd.EditLabelsTool)}
return{load:function(){wpd.appData.isAligned()?(d(),wpd.dataPointCounter.setCount(),wpd.graphicsWidget.removeTool(),wpd.graphicsWidget.setRepainter(new wpd.DataPointsRepainter),c()):wpd.messagePopup.show("Acquire Data","Please calibrate the axes before acquiring data.")},manualSelection:c,adjustPoints:e,deletePoint:b,clearAll:function(){0>=wpd.appData.getPlotData().getActiveDataSeries().getCount()||wpd.okCancelPopup.show("Clear data points?","This will delete all data points from this dataset",a,
function(){})},undo:function(){wpd.appData.getPlotData().getActiveDataSeries().removeLastPixel();wpd.graphicsWidget.resetData();wpd.graphicsWidget.forceHandlerRepaint();wpd.dataPointCounter.setCount()},showSidebar:d,switchToolOnKeyPress:function(a){switch(a){case "d":b();break;case "a":c();break;case "s":e();break;case "e":g()}},isToolSwitchKey:function(a){return wpd.keyCodes.isAlphabet(a,"a")||wpd.keyCodes.isAlphabet(a,"s")||wpd.keyCodes.isAlphabet(a,"d")||wpd.keyCodes.isAlphabet(a,"e")?!0:!1},updateDatasetControl:f,
changeDataset:function(a){a=a.selectedIndex;wpd.appData.getPlotData().setActiveDataSeriesIndex(a);wpd.graphicsWidget.forceHandlerRepaint();wpd.dataPointCounter.setCount()},editLabels:g}}();
wpd.dataPointLabelEditor=function(){function c(){var b=document.getElementById("data-point-label-field").value;null!=b&&0<b.length&&(a.setMetadataAt(d,[b]),wpd.graphicsWidget.resetData(),wpd.graphicsWidget.forceHandlerRepaint());wpd.popup.close("data-point-label-editor");wpd.graphicsWidget.setTool(f)}function b(){wpd.popup.close("data-point-label-editor");wpd.graphicsWidget.setTool(f)}var a,d,f;return{show:function(b,c,h){var k=b.getPixel(c).metadata[0];a=b;d=c;f=h;wpd.graphicsWidget.removeTool();
wpd.popup.show("data-point-label-editor");b=document.getElementById("data-point-label-field");b.value=k;b.focus()},ok:c,cancel:b,keydown:function(a){wpd.keyCodes.isEnter(a.keyCode)?c():wpd.keyCodes.isEsc(a.keyCode)&&b();a.stopPropagation()}}}();
wpd.ManualSelectionTool=function(){return function(){var c=wpd.appData.getPlotData();this.onAttach=function(){document.getElementById("manual-select-button").classList.add("pressed-button");wpd.graphicsWidget.setRepainter(new wpd.DataPointsRepainter)};this.onMouseClick=function(b,a,d){a=c.getActiveDataSeries();var f;c.axes.dataPointsHaveLabels?(f=a.getMetadataKeys(),null!=f&&"Label"===f[0]||a.setMetadataKeys(["Label"]),f=c.axes.dataPointsLabelPrefix+a.getCount(),a.addPixel(d.x,d.y,[f]),wpd.graphicsHelper.drawPoint(d,
"rgb(200,0,0)",f)):(a.addPixel(d.x,d.y),wpd.graphicsHelper.drawPoint(d,"rgb(200,0,0)"));wpd.graphicsWidget.updateZoomOnEvent(b);wpd.dataPointCounter.setCount();c.axes.dataPointsHaveLabels&&b.shiftKey&&wpd.dataPointLabelEditor.show(a,a.getCount()-1,this)};this.onRemove=function(){document.getElementById("manual-select-button").classList.remove("pressed-button")};this.onKeyDown=function(b){var a=c.getActiveDataSeries(),d=a.getCount()-1,f=a.getPixel(d),e=.5/wpd.graphicsWidget.getZoomRatio();if(wpd.keyCodes.isUp(b.keyCode))f.y-=
e;else if(wpd.keyCodes.isDown(b.keyCode))f.y+=e;else if(wpd.keyCodes.isLeft(b.keyCode))f.x-=e;else if(wpd.keyCodes.isRight(b.keyCode))f.x+=e;else{wpd.acquireData.isToolSwitchKey(b.keyCode)&&wpd.acquireData.switchToolOnKeyPress(String.fromCharCode(b.keyCode).toLowerCase());return}a.setPixelAt(d,f.x,f.y);wpd.graphicsWidget.resetData();wpd.graphicsWidget.forceHandlerRepaint();wpd.graphicsWidget.updateZoomToImagePosn(f.x,f.y);b.preventDefault()}}}();
wpd.DeleteDataPointTool=function(){return function(){wpd.graphicsWidget.getAllContexts();var c=wpd.appData.getPlotData();this.onAttach=function(){document.getElementById("delete-point-button").classList.add("pressed-button");wpd.graphicsWidget.setRepainter(new wpd.DataPointsRepainter)};this.onMouseClick=function(b,a,d){c.getActiveDataSeries().removeNearestPixel(d.x,d.y);wpd.graphicsWidget.resetData();wpd.graphicsWidget.forceHandlerRepaint();wpd.graphicsWidget.updateZoomOnEvent(b);wpd.dataPointCounter.setCount()};
this.onKeyDown=function(b){wpd.acquireData.isToolSwitchKey(b.keyCode)&&wpd.acquireData.switchToolOnKeyPress(String.fromCharCode(b.keyCode).toLowerCase())};this.onRemove=function(){document.getElementById("delete-point-button").classList.remove("pressed-button")}}}();
wpd.DataPointsRepainter=function(){return function(){var c=function(){var b=wpd.appData.getPlotData(),a=b.getActiveDataSeries(),c,f,e;c=a.getMetadataKeys();var g=!1,h;b.axes.dataPointsHaveLabels&&null!=c&&"Label"===c[0]&&(g=!0);for(c=0;c<a.getCount();c++)f=a.getPixel(c),e=(e=0<=a.getSelectedPixels().indexOf(c))?"rgb(0,200,0)":"rgb(200,0,0)",g?(h=f.metadata[0],null==h&&(h=b.axes.dataPointsLabelPrefix+c),wpd.graphicsHelper.drawPoint(f,e,h)):wpd.graphicsHelper.drawPoint(f,e)};this.painterName="dataPointsRepainter";
this.onAttach=function(){wpd.graphicsWidget.resetData();c()};this.onRedraw=function(){c()};this.onForcedRedraw=function(){wpd.graphicsWidget.resetData();c()}}}();
wpd.AdjustDataPointTool=function(){return function(){this.onAttach=function(){document.getElementById("manual-adjust-button").classList.add("pressed-button");wpd.graphicsWidget.setRepainter(new wpd.DataPointsRepainter);wpd.toolbar.show("adjustDataPointsToolbar")};this.onRemove=function(){wpd.appData.getPlotData().getActiveDataSeries().unselectAll();wpd.graphicsWidget.forceHandlerRepaint();document.getElementById("manual-adjust-button").classList.remove("pressed-button");wpd.toolbar.clear()};this.onMouseClick=
function(c,b,a){b=wpd.appData.getPlotData().getActiveDataSeries();b.unselectAll();b.selectNearestPixel(a.x,a.y);wpd.graphicsWidget.forceHandlerRepaint();wpd.graphicsWidget.updateZoomOnEvent(c)};this.onKeyDown=function(c){if(wpd.acquireData.isToolSwitchKey(c.keyCode))wpd.acquireData.switchToolOnKeyPress(String.fromCharCode(c.keyCode).toLowerCase());else{var b=wpd.appData.getPlotData().getActiveDataSeries(),a=b.getSelectedPixels()[0];if(null!=a){var d=b.getPixel(a),f=d.x,d=d.y,e=!0===c.shiftKey?5/wpd.graphicsWidget.getZoomRatio():
.5/wpd.graphicsWidget.getZoomRatio();if(wpd.keyCodes.isUp(c.keyCode))d-=e;else if(wpd.keyCodes.isDown(c.keyCode))d+=e;else if(wpd.keyCodes.isLeft(c.keyCode))f-=e;else if(wpd.keyCodes.isRight(c.keyCode))f+=e;else if(wpd.keyCodes.isAlphabet(c.keyCode,"q"))b.selectPreviousPixel(),a=b.getSelectedPixels()[0],d=b.getPixel(a),f=d.x,d=d.y;else if(wpd.keyCodes.isAlphabet(c.keyCode,"w"))b.selectNextPixel(),a=b.getSelectedPixels()[0],d=b.getPixel(a),f=d.x,d=d.y;else if(wpd.keyCodes.isAlphabet(c.keyCode,"e")){if(wpd.appData.getPlotData().axes.dataPointsHaveLabels){a=
b.getSelectedPixels()[0];c.preventDefault();c.stopPropagation();wpd.dataPointLabelEditor.show(b,a,this);return}}else{if(wpd.keyCodes.isDel(c.keyCode)||wpd.keyCodes.isBackspace(c.keyCode))b.removePixelAtIndex(a),b.unselectAll(),0<=b.findNearestPixel(f,d)&&(b.selectNearestPixel(f,d),a=b.getSelectedPixels()[0],d=b.getPixel(a),f=d.x,d=d.y),wpd.graphicsWidget.resetData(),wpd.graphicsWidget.forceHandlerRepaint(),wpd.graphicsWidget.updateZoomToImagePosn(f,d),wpd.dataPointCounter.setCount(),c.preventDefault(),
c.stopPropagation();return}b.setPixelAt(a,f,d);wpd.graphicsWidget.forceHandlerRepaint();wpd.graphicsWidget.updateZoomToImagePosn(f,d);c.preventDefault();c.stopPropagation()}}}}}();
wpd.EditLabelsTool=function(){this.onAttach=function(){document.getElementById("edit-data-labels").classList.add("pressed-button");wpd.graphicsWidget.setRepainter(new wpd.DataPointsRepainter)};this.onRemove=function(){document.getElementById("edit-data-labels").classList.remove("pressed-button");wpd.appData.getPlotData().getActiveDataSeries().unselectAll()};this.onMouseClick=function(c,b,a){b=wpd.appData.getPlotData().getActiveDataSeries();b.unselectAll();a=b.selectNearestPixel(a.x,a.y);0<=a&&(wpd.graphicsWidget.forceHandlerRepaint(),
wpd.graphicsWidget.updateZoomOnEvent(c),wpd.dataPointLabelEditor.show(b,a,this))};this.onKeyDown=function(c){wpd.acquireData.isToolSwitchKey(c.keyCode)&&wpd.acquireData.switchToolOnKeyPress(String.fromCharCode(c.keyCode).toLowerCase())}};wpd.dataPointCounter=function(){return{setCount:function(){var c=document.getElementsByClassName("data-point-counter"),b;for(b=0;b<c.length;b++)c[b].innerHTML=wpd.appData.getPlotData().getActiveDataSeries().getCount()}}}();wpd=wpd||{};
wpd.dataMask=function(){function c(){var b=wpd.graphicsWidget.getAllContexts(),a=wpd.graphicsWidget.getImageSize(),b=b.oriDataCtx.getImageData(0,0,a.width,a.height),a=[],c,f=0,e=wpd.appData.getPlotData().getAutoDetector();for(c=0;c<b.data.length;c+=4)255===b.data[c]&&255===b.data[c+1]&&0===b.data[c+2]&&(a[f]=c/4,f++);e.mask=a}return{grabMask:c,markBox:function(){var b=new wpd.BoxMaskTool;wpd.graphicsWidget.setTool(b)},markPen:function(){var b=new wpd.PenMaskTool;wpd.graphicsWidget.setTool(b)},eraseMarks:function(){var b=
new wpd.EraseMaskTool;wpd.graphicsWidget.setTool(b)},viewMask:function(){var b=new wpd.ViewMaskTool;wpd.graphicsWidget.setTool(b)},clearMask:function(){wpd.graphicsWidget.resetData();c()}}}();
wpd.BoxMaskTool=function(){return function(){var c=!1,b,a,d=wpd.graphicsWidget.getAllContexts(),f,e,g=function(){wpd.graphicsWidget.resetHover();d.hoverCtx.strokeStyle="rgb(0,0,0)";d.hoverCtx.strokeRect(a.x,a.y,e.x-a.x,e.y-a.y)},h=function(e,h,g){!1!==c&&(clearTimeout(f),c=!1,wpd.graphicsWidget.resetHover(),d.dataCtx.fillStyle="rgba(255,255,0,1)",d.dataCtx.fillRect(a.x,a.y,h.x-a.x,h.y-a.y),d.oriDataCtx.fillStyle="rgba(255,255,0,1)",d.oriDataCtx.fillRect(b.x,b.y,g.x-b.x,g.y-b.y))},k=null,q=null;this.onAttach=
function(){wpd.graphicsWidget.setRepainter(new wpd.MaskPainter);document.getElementById("box-mask").classList.add("pressed-button");document.getElementById("view-mask").classList.add("pressed-button")};this.onMouseDown=function(d,e,f){!0!==c&&(c=!0,b=f,a=e)};this.onMouseMove=function(a,b,d){!1!==c&&(e=b,clearTimeout(f),f=setTimeout(g,2))};this.onMouseOut=function(a,b,d){!0===c&&(clearTimeout(f),k=b,q=d)};this.onDocumentMouseUp=function(a,b,c){null!=k&&null!=q?h(a,k,q):h(a,b,c);q=k=null};this.onMouseUp=
function(a,b,c){h(a,b,c)};this.onRemove=function(){document.getElementById("box-mask").classList.remove("pressed-button");document.getElementById("view-mask").classList.remove("pressed-button");wpd.dataMask.grabMask()}}}();
wpd.PenMaskTool=function(){return function(){var c=wpd.graphicsWidget.getAllContexts(),b=!1,a,d,f,e=function(){c.dataCtx.strokeStyle="rgba(255,255,0,1)";c.dataCtx.lineTo(d.x,d.y);c.dataCtx.stroke();c.oriDataCtx.strokeStyle="rgba(255,255,0,1)";c.oriDataCtx.lineTo(f.x,f.y);c.oriDataCtx.stroke()};this.onAttach=function(){wpd.graphicsWidget.setRepainter(new wpd.MaskPainter);document.getElementById("pen-mask").classList.add("pressed-button");document.getElementById("view-mask").classList.add("pressed-button");
wpd.toolbar.show("paintToolbar")};this.onMouseDown=function(a,d,e){!0!==b&&(a=parseInt(document.getElementById("paintThickness").value,10),b=!0,c.dataCtx.strokeStyle="rgba(255,255,0,1)",c.dataCtx.lineWidth=a*wpd.graphicsWidget.getZoomRatio(),c.dataCtx.beginPath(),c.dataCtx.moveTo(d.x,d.y),c.oriDataCtx.strokeStyle="rgba(255,255,0,1)",c.oriDataCtx.lineWidth=a,c.oriDataCtx.beginPath(),c.oriDataCtx.moveTo(e.x,e.y))};this.onMouseMove=function(c,h,k){!1!==b&&(d=h,f=k,clearTimeout(a),a=setTimeout(e,2))};
this.onMouseUp=function(d,e,f){clearTimeout(a);c.dataCtx.closePath();c.dataCtx.lineWidth=1;c.oriDataCtx.closePath();c.oriDataCtx.lineWidth=1;b=!1};this.onMouseOut=function(a,b,c){this.onMouseUp(a,b,c)};this.onRemove=function(){document.getElementById("pen-mask").classList.remove("pressed-button");document.getElementById("view-mask").classList.remove("pressed-button");wpd.dataMask.grabMask();wpd.toolbar.clear()}}}();
wpd.EraseMaskTool=function(){return function(){var c=wpd.graphicsWidget.getAllContexts(),b=!1,a,d,f,e=function(){c.dataCtx.globalCompositeOperation="destination-out";c.oriDataCtx.globalCompositeOperation="destination-out";c.dataCtx.strokeStyle="rgba(255,255,0,1)";c.dataCtx.lineTo(d.x,d.y);c.dataCtx.stroke();c.oriDataCtx.strokeStyle="rgba(255,255,0,1)";c.oriDataCtx.lineTo(f.x,f.y);c.oriDataCtx.stroke()};this.onAttach=function(){wpd.graphicsWidget.setRepainter(new wpd.MaskPainter);document.getElementById("erase-mask").classList.add("pressed-button");
document.getElementById("view-mask").classList.add("pressed-button");wpd.toolbar.show("eraseToolbar")};this.onMouseDown=function(a,d,e){!0!==b&&(a=parseInt(document.getElementById("eraseThickness").value,10),b=!0,c.dataCtx.globalCompositeOperation="destination-out",c.oriDataCtx.globalCompositeOperation="destination-out",c.dataCtx.strokeStyle="rgba(0,0,0,1)",c.dataCtx.lineWidth=a*wpd.graphicsWidget.getZoomRatio(),c.dataCtx.beginPath(),c.dataCtx.moveTo(d.x,d.y),c.oriDataCtx.strokeStyle="rgba(0,0,0,1)",
c.oriDataCtx.lineWidth=a,c.oriDataCtx.beginPath(),c.oriDataCtx.moveTo(e.x,e.y))};this.onMouseMove=function(c,h,k){!1!==b&&(d=h,f=k,clearTimeout(a),a=setTimeout(e,2))};this.onMouseOut=function(a,b,c){this.onMouseUp(a,b,c)};this.onMouseUp=function(d,e,f){clearTimeout(a);c.dataCtx.closePath();c.dataCtx.lineWidth=1;c.oriDataCtx.closePath();c.oriDataCtx.lineWidth=1;c.dataCtx.globalCompositeOperation="source-over";c.oriDataCtx.globalCompositeOperation="source-over";b=!1};this.onRemove=function(){document.getElementById("erase-mask").classList.remove("pressed-button");
document.getElementById("view-mask").classList.remove("pressed-button");wpd.dataMask.grabMask();wpd.toolbar.clear()}}}();wpd.ViewMaskTool=function(){return function(){this.onAttach=function(){wpd.graphicsWidget.setRepainter(new wpd.MaskPainter);document.getElementById("view-mask").classList.add("pressed-button")};this.onRemove=function(){document.getElementById("view-mask").classList.remove("pressed-button");wpd.dataMask.grabMask()}}}();
wpd.MaskPainter=function(){return function(){var c=wpd.graphicsWidget.getAllContexts(),b=wpd.appData.getPlotData().getAutoDetector(),a=function(){if(null!=b.mask&&0!==b.mask.length){var a,f;a=wpd.graphicsWidget.getImageSize();imgData=c.oriDataCtx.getImageData(0,0,a.width,a.height);for(a=0;a<b.mask.length;a++)f=b.mask[a],imgData.data[4*f]=255,imgData.data[4*f+1]=255,imgData.data[4*f+2]=0,imgData.data[4*f+3]=255;c.oriDataCtx.putImageData(imgData,0,0);wpd.graphicsWidget.copyImageDataLayerToScreen()}};
this.painterName="dataMaskPainter";this.onRedraw=function(){wpd.dataMask.grabMask();a()};this.onAttach=function(){wpd.graphicsWidget.resetData();a()}}}();wpd=wpd||{};
wpd.distanceMeasurement=function(){return{start:function(){wpd.graphicsWidget.removeTool();wpd.graphicsWidget.resetData();var c=wpd.appData.getPlotData();null==c.distanceMeasurementData&&(c.distanceMeasurementData=new wpd.ConnectedPoints(2));wpd.sidebar.show("measure-distances-sidebar");wpd.graphicsWidget.setTool(new wpd.AddMeasurementTool("distance"));wpd.graphicsWidget.forceHandlerRepaint()},addPair:function(){wpd.graphicsWidget.setTool(new wpd.AddMeasurementTool("distance"))},deletePair:function(){wpd.graphicsWidget.setTool(new wpd.DeleteMeasurementTool("distance"))},
clearAll:function(){wpd.graphicsWidget.removeTool();wpd.graphicsWidget.resetData();wpd.appData.getPlotData().distanceMeasurementData=new wpd.ConnectedPoints(2)}}}();
wpd.angleMeasurement=function(){return{start:function(){wpd.graphicsWidget.removeTool();wpd.graphicsWidget.resetData();var c=wpd.appData.getPlotData();null==c.angleMeasurementData&&(c.angleMeasurementData=new wpd.ConnectedPoints(3));wpd.sidebar.show("measure-angles-sidebar");wpd.graphicsWidget.setTool(new wpd.AddMeasurementTool("angle"));wpd.graphicsWidget.forceHandlerRepaint()},addAngle:function(){wpd.graphicsWidget.setTool(new wpd.AddMeasurementTool("angle"))},deleteAngle:function(){wpd.graphicsWidget.setTool(new wpd.DeleteMeasurementTool("angle"))},
clearAll:function(){wpd.graphicsWidget.removeTool();wpd.graphicsWidget.resetData();wpd.appData.getPlotData().angleMeasurementData=new wpd.ConnectedPoints(3)}}}();
wpd.AddMeasurementTool=function(){return function(c){var b="distance"===c,a=wpd.graphicsWidget.getAllContexts(),d=wpd.appData.getPlotData(),f=0,e=!0,g=[],h=b?2:3;this.onAttach=function(){document.getElementById(!0===b?"add-pair-button":"add-angle-button").classList.add("pressed-button");wpd.graphicsWidget.setRepainter(new wpd.MeasurementRepainter(c))};this.onRemove=function(){document.getElementById(!0===b?"add-pair-button":"add-angle-button").classList.remove("pressed-button")};this.onKeyDown=function(a){wpd.keyCodes.isAlphabet(a.keyCode,
"a")?(wpd.graphicsWidget.resetHover(),wpd.graphicsWidget.setTool(new wpd.AddMeasurementTool(c))):wpd.keyCodes.isAlphabet(a.keyCode,"d")&&(wpd.graphicsWidget.resetHover(),wpd.graphicsWidget.setTool(new wpd.DeleteMeasurementTool(c)))};this.onMouseClick=function(k,q,m){if(e){wpd.graphicsWidget.resetHover();g[2*f]=m.x;g[2*f+1]=m.y;f+=1;if(f===h){e=!1;b?d.distanceMeasurementData.addConnection(g):d.angleMeasurementData.addConnection(g);wpd.graphicsWidget.forceHandlerRepaint();wpd.graphicsWidget.setTool(new wpd.AdjustMeasurementTool(c));
return}if(1<f){var n=wpd.graphicsWidget.screenPx(g[2*(f-2)],g[2*(f-2)+1]);a.dataCtx.beginPath();a.dataCtx.strokeStyle="rgb(0,0,10)";a.dataCtx.moveTo(n.x,n.y);a.dataCtx.lineTo(q.x,q.y);a.dataCtx.stroke();a.oriDataCtx.beginPath();a.oriDataCtx.strokeStyle="rgb(0,0,10)";a.oriDataCtx.moveTo(g[2*(f-2)],g[2*(f-2)+1]);a.oriDataCtx.lineTo(m.x,m.y);a.oriDataCtx.stroke()}a.dataCtx.beginPath();a.dataCtx.fillStyle="rgb(200, 0, 0)";a.dataCtx.arc(q.x,q.y,3,0,2*Math.PI,!0);a.dataCtx.fill();a.oriDataCtx.beginPath();
a.oriDataCtx.fillStyle="rgb(200,0,0)";a.oriDataCtx.arc(m.x,m.y,3,0,2*Math.PI,!0);a.oriDataCtx.fill()}wpd.graphicsWidget.updateZoomOnEvent(k)};this.onMouseMove=function(b,c,d){e&&1<=f&&(wpd.graphicsWidget.resetHover(),b=wpd.graphicsWidget.screenPx(g[2*(f-1)],g[2*(f-1)+1]),a.hoverCtx.beginPath(),a.hoverCtx.strokeStyle="rgb(0,0,0)",a.hoverCtx.moveTo(b.x,b.y),a.hoverCtx.lineTo(c.x,c.y),a.hoverCtx.stroke())}}}();
wpd.DeleteMeasurementTool=function(){return function(c){var b="distance"===c;wpd.graphicsWidget.getAllContexts();var a=wpd.appData.getPlotData();this.onAttach=function(){document.getElementById(!0===b?"delete-pair-button":"delete-angle-button").classList.add("pressed-button");wpd.graphicsWidget.setRepainter(new wpd.MeasurementRepainter(c))};this.onRemove=function(){document.getElementById(!0===b?"delete-pair-button":"delete-angle-button").classList.remove("pressed-button")};this.onKeyDown=function(a){wpd.keyCodes.isAlphabet(a.keyCode,
"a")?wpd.graphicsWidget.setTool(new wpd.AddMeasurementTool(c)):wpd.keyCodes.isAlphabet(a.keyCode,"d")&&wpd.graphicsWidget.setTool(new wpd.DeleteMeasurementTool(c))};this.onMouseClick=function(d,f,e){b?a.distanceMeasurementData.deleteNearestConnection(e.x,e.y):a.angleMeasurementData.deleteNearestConnection(e.x,e.y);wpd.graphicsWidget.setTool(new wpd.AdjustMeasurementTool(c));wpd.graphicsWidget.resetData();wpd.graphicsWidget.forceHandlerRepaint();wpd.graphicsWidget.updateZoomOnEvent(d)}}}();
wpd.AdjustMeasurementTool=function(){return function(c){this.onAttach=function(){wpd.graphicsWidget.setRepainter(new wpd.MeasurementRepainter(c))};this.onMouseClick=function(b,a,d){a=wpd.appData.getPlotData();"distance"===c?a.distanceMeasurementData.selectNearestPoint(d.x,d.y):"angle"===c&&a.angleMeasurementData.selectNearestPoint(d.x,d.y);wpd.graphicsWidget.forceHandlerRepaint();wpd.graphicsWidget.updateZoomOnEvent(b)};this.onKeyDown=function(b){if(wpd.keyCodes.isAlphabet(b.keyCode,"a"))wpd.graphicsWidget.setTool(new wpd.AddMeasurementTool(c));
else if(wpd.keyCodes.isAlphabet(b.keyCode,"d"))wpd.graphicsWidget.setTool(new wpd.DeleteMeasurementTool(c));else{var a=wpd.appData.getPlotData(),a="distance"===c?a.distanceMeasurementData:a.angleMeasurementData,d=a.getSelectedConnectionAndPoint();if(0<=d.connectionIndex&&0<=d.pointIndex){var f=!0===b.shiftKey?5/wpd.graphicsWidget.getZoomRatio():.5/wpd.graphicsWidget.getZoomRatio(),e=a.getPointAt(d.connectionIndex,d.pointIndex);if(wpd.keyCodes.isUp(b.keyCode))e.y-=f;else if(wpd.keyCodes.isDown(b.keyCode))e.y+=
f;else if(wpd.keyCodes.isLeft(b.keyCode))e.x-=f;else if(wpd.keyCodes.isRight(b.keyCode))e.x+=f;else return;a.setPointAt(d.connectionIndex,d.pointIndex,e.x,e.y);wpd.graphicsWidget.forceHandlerRepaint();wpd.graphicsWidget.updateZoomToImagePosn(e.x,e.y);b.preventDefault();b.stopPropagation()}}}}}();
wpd.MeasurementRepainter=function(){return function(c){var b="distance"===c,a="angle"===c,d=wpd.graphicsWidget.getAllContexts(),f=function(a,b,c,e,f,g,p,t){d.dataCtx.beginPath();d.dataCtx.strokeStyle="rgb(0,0,10)";d.dataCtx.moveTo(a,b);d.dataCtx.lineTo(c,e);d.dataCtx.stroke();d.oriDataCtx.beginPath();d.oriDataCtx.strokeStyle="rgb(0,0,10)";d.oriDataCtx.moveTo(f,g);d.oriDataCtx.lineTo(p,t);d.oriDataCtx.stroke()},e=function(a,b,c,e,f){d.dataCtx.beginPath();d.dataCtx.fillStyle=f?"rgb(0, 200, 0)":"rgb(200, 0, 0)";
d.dataCtx.arc(a,b,3,0,2*Math.PI,!0);d.dataCtx.fill();d.oriDataCtx.beginPath();d.oriDataCtx.fillStyle=f?"rgb(0,200,0)":"rgb(200,0,0)";d.oriDataCtx.arc(c,e,3,0,2*Math.PI,!0);d.oriDataCtx.fill()},g=function(a,b,c,e,f){var g;a=parseInt(a,10);b=parseInt(b,10);c=parseInt(c,10);e=parseInt(e,10);d.dataCtx.font="14px sans-serif";g=d.dataCtx.measureText(f).width;d.dataCtx.fillStyle="rgba(255, 255, 255, 0.7)";d.dataCtx.fillRect(a-5,b-15,g+10,25);d.dataCtx.fillStyle="rgb(200, 0, 0)";d.dataCtx.fillText(f,a,b);
d.oriDataCtx.font="14px sans-serif";g=d.oriDataCtx.measureText(f).width;d.oriDataCtx.fillStyle="rgba(255, 255, 255, 0.7)";d.oriDataCtx.fillRect(c-5,e-15,g+10,25);d.oriDataCtx.fillStyle="rgb(200, 0, 0)";d.oriDataCtx.fillText(f,c,e)};this.painterName="measurementRepainter-"+c;this.onAttach=function(){wpd.graphicsWidget.resetData()};this.onRedraw=function(){if(b){var c=wpd.appData.getPlotData().distanceMeasurementData,k=c.connectionCount(),q,m,n,l,p,t,r,v,u,w,x=wpd.appData.getPlotData().axes;for(q=0;q<
k;q++)m=c.getConnectionAt(q),n=m[0],l=m[1],p=m[2],m=m[3],u=c.isPointSelected(q,0),w=c.isPointSelected(q,1),v=!0===wpd.appData.isAligned()&&x instanceof wpd.MapAxes?"Dist"+q.toString()+": "+x.pixelToDataDistance(c.getDistance(q)).toFixed(2)+" "+x.getUnits():"Dist"+q.toString()+": "+c.getDistance(q).toFixed(2)+" px",t=wpd.graphicsWidget.screenPx(n,l),r=wpd.graphicsWidget.screenPx(p,m),f(t.x,t.y,r.x,r.y,n,l,p,m),e(t.x,t.y,n,l,u),e(r.x,r.y,p,m,w),g(.5*(t.x+r.x),.5*(t.y+r.y),.5*(n+p),.5*(l+m),v)}if(a){var c=
wpd.appData.getPlotData().angleMeasurementData,k=c.connectionCount(),A,y,B,J,H;for(q=0;q<k;q++)p=c.getConnectionAt(q),r=p[0],v=p[1],n=p[2],l=p[3],u=p[4],w=p[5],B=c.isPointSelected(q,0),J=c.isPointSelected(q,1),H=c.isPointSelected(q,2),x="Theta"+q.toString()+": "+c.getAngle(q).toFixed(2)+"\u00b0",t=Math.atan2(v-l,r-n),m=Math.atan2(w-l,u-n),A=wpd.graphicsWidget.screenPx(r,v),p=wpd.graphicsWidget.screenPx(n,l),y=wpd.graphicsWidget.screenPx(u,w),f(A.x,A.y,p.x,p.y,r,v,n,l),f(p.x,p.y,y.x,y.y,n,l,u,w),e(A.x,
A.y,r,v,B),e(p.x,p.y,n,l,J),e(y.x,y.y,u,w,H),r=p.x,v=p.y,u=n,w=l,d.dataCtx.beginPath(),d.dataCtx.strokeStyle="rgb(0,0,10)",d.dataCtx.arc(r,v,15,t,m,!0),d.dataCtx.stroke(),d.oriDataCtx.beginPath(),d.oriDataCtx.strokeStyle="rgb(0,0,10)",d.oriDataCtx.arc(u,w,15,t,m,!0),d.oriDataCtx.stroke(),g(p.x+10,p.y+15,n+10,l+15,x)}};this.onForcedRedraw=function(){wpd.graphicsWidget.resetData();this.onRedraw()}}}();wpd=wpd||{};
wpd.download=function(){function c(b,a,c){var f,e,g,h;f=document.createElement("div");e=document.createElement("form");g=document.createElement("textarea");h=document.createElement("input");h.type="hidden";e.setAttribute("method","post");"json"===c?e.setAttribute("action","php/json.php"):"csv"===c&&e.setAttribute("action","php/csvexport.php");g.setAttribute("name","data");g.setAttribute("id","data");h.setAttribute("name","filename");h.setAttribute("id","filename");h.value=a.replace(/[^a-zA-Z\d+\.\-_\s]/g,
"_");e.appendChild(g);e.appendChild(h);f.appendChild(e);document.body.appendChild(f);f.style.display="none";g.innerHTML=b;e.submit();document.body.removeChild(f)}return{json:function(b,a){null==a&&(a="wpd_plot_data");c(b,a,"json")},csv:function(b,a){null==a&&(a="data");c(b,a,"csv")}}}();wpd=wpd||{};
wpd.plotly=function(){return{send:function(c){var b=document.createElement("div"),a=document.createElement("form"),d=document.createElement("textarea");a.setAttribute("method","post");a.setAttribute("action","https://plot.ly/external");a.setAttribute("target","_blank");d.setAttribute("name","data");d.setAttribute("id","data");a.appendChild(d);b.appendChild(a);document.body.appendChild(b);b.style.display="none";c=JSON.stringify(c);d.innerHTML=c;a.submit();document.body.removeChild(b)}}}();
wpd=wpd||{};
wpd.saveResume=function(){function c(a){var b=wpd.appData.getPlotData();a=a.wpd;var c,e,g,h;b.reset();wpd.appData.isAligned(!1);if(null!=a.axesType&&("ImageAxes"===a.axesType||null!=a.calibration&&null!=a.axesParameters)){if("ImageAxes"!==a.axesType){c="TernaryAxes"===a.axesType?new wpd.Calibration(3):new wpd.Calibration(2);for(e=0;e<a.calibration.length;e++)c.addPoint(a.calibration[e].px,a.calibration[e].py,a.calibration[e].dx,a.calibration[e].dy,a.calibration[e].dz);b.calibration=c}if("XYAxes"===a.axesType){if(b.axes=
new wpd.XYAxes,!b.axes.calibrate(b.calibration,a.axesParameters.isLogX,a.axesParameters.isLogY))return}else if("BarAxes"===a.axesType){if(b.axes=new wpd.BarAxes,!b.axes.calibrate(b.calibration,a.axesParameters.isLog))return}else if("PolarAxes"===a.axesType){if(b.axes=new wpd.PolarAxes,!b.axes.calibrate(b.calibration,a.axesParameters.isDegrees,a.axesParameters.isClockwise))return}else if("TernaryAxes"===a.axesType){if(b.axes=new wpd.TernaryAxes,!b.axes.calibrate(b.calibration,a.axesParameters.isRange100,
a.axesParameters.isNormalOrientation))return}else if("MapAxes"===a.axesType){if(b.axes=new wpd.MapAxes,!b.axes.calibrate(b.calibration,a.axesParameters.scaleLength,a.axesParameters.unitString))return}else"ImageAxes"===a.axesType&&(b.axes=new wpd.ImageAxes);wpd.appData.isAligned(!0);if(null!=a.dataSeries){for(e=0;e<a.dataSeries.length;e++)for(g=a.dataSeries[e],b.dataSeriesColl[e]=new wpd.DataSeries,h=b.dataSeriesColl[e],h.name=g.name,null!=g.metadataKeys&&h.setMetadataKeys(g.metadataKeys),c=0;c<g.data.length;c++)h.addPixel(g.data[c].x,
g.data[c].y,g.data[c].metadata);if(null!=a.distanceMeasurementData)for(b.distanceMeasurementData=new wpd.ConnectedPoints(2),e=0;e<a.distanceMeasurementData.length;e++)b.distanceMeasurementData.addConnection(a.distanceMeasurementData[e]);if(null!=a.angleMeasurementData)for(b.angleMeasurementData=new wpd.ConnectedPoints(3),e=0;e<a.angleMeasurementData.length;e++)b.angleMeasurementData.addConnection(a.angleMeasurementData[e])}}}function b(){var a=wpd.appData.getPlotData(),b=a.calibration,c={wpd:{version:[3,
8],axesType:null,axesParameters:null,calibration:null,dataSeries:[],distanceMeasurementData:null,angleMeasurementData:null}},e="",g,h;if(null!=b)for(c.wpd.calibration=[],e=0;e<b.getCount();e++)c.wpd.calibration[e]=b.getPoint(e);null!=a.axes&&(a.axes instanceof wpd.XYAxes?(c.wpd.axesType="XYAxes",c.wpd.axesParameters={isLogX:a.axes.isLogX(),isLogY:a.axes.isLogY()}):a.axes instanceof wpd.BarAxes?(c.wpd.axesType="BarAxes",c.wpd.axesParameters={isLog:a.axes.isLog()}):a.axes instanceof wpd.PolarAxes?(c.wpd.axesType=
"PolarAxes",c.wpd.axesParameters={isDegrees:a.axes.isThetaDegrees(),isClockwise:a.axes.isThetaClockwise()}):a.axes instanceof wpd.TernaryAxes?(c.wpd.axesType="TernaryAxes",c.wpd.axesParameters={isRange100:a.axes.isRange100(),isNormalOrientation:a.axes.isNormalOrientation()}):a.axes instanceof wpd.MapAxes?(c.wpd.axesType="MapAxes",c.wpd.axesParameters={scaleLength:a.axes.getScaleLength(),unitString:a.axes.getUnits()}):a.axes instanceof wpd.ImageAxes&&(c.wpd.axesType="ImageAxes"));for(e=0;e<a.dataSeriesColl.length;e++)for(b=
a.dataSeriesColl[e],c.wpd.dataSeries[e]={name:b.name,data:[]},g=b.getMetadataKeys(),null!=g&&(c.wpd.dataSeries[e].metadataKeys=g),g=0;g<b.getCount();g++)h=b.getPixel(g),c.wpd.dataSeries[e].data[g]=h,c.wpd.dataSeries[e].data[g].value=a.axes.pixelToData(h.x,h.y);if(null!=a.distanceMeasurementData)for(c.wpd.distanceMeasurementData=[],e=0;e<a.distanceMeasurementData.connectionCount();e++)c.wpd.distanceMeasurementData[e]=a.distanceMeasurementData.getConnectionAt(e);if(null!=a.angleMeasurementData)for(c.wpd.angleMeasurementData=
[],e=0;e<a.angleMeasurementData.connectionCount();e++)c.wpd.angleMeasurementData[e]=a.angleMeasurementData.getConnectionAt(e);return e=JSON.stringify(c)}return{save:function(){wpd.popup.show("export-json-window")},load:function(){wpd.popup.show("import-json-window")},download:function(){wpd.download.json(b());wpd.popup.close("export-json-window")},read:function(){var a=document.getElementById("import-json-file");wpd.popup.close("import-json-window");if(1===a.files.length){var b=new FileReader;b.onload=
function(){var a=JSON.parse(b.result);c(a);wpd.graphicsWidget.resetData();wpd.graphicsWidget.removeTool();wpd.graphicsWidget.removeRepainter();wpd.appData.isAligned()&&wpd.acquireData.load();wpd.messagePopup.show("Import JSON","JSON data has been loaded!")};b.readAsText(a.files[0])}}}}();wpd=wpd||{};
wpd.scriptInjector=function(){return{start:function(){wpd.popup.show("runScriptPopup")},cancel:function(){wpd.popup.close("runScriptPopup")},load:function(){var c=document.getElementById("runScriptFileInput");wpd.popup.close("runScriptPopup");if(1==c.files.length){var b=new FileReader;b.onload=function(){"undefined"!==typeof wpdscript&&delete wpdscript;eval(b.result);"wpdscript"!==typeof wpdscript&&(window.wpdscript=wpdscript,wpdscript.run())};b.readAsText(c.files[0])}}}}();wpd=wpd||{};
wpd.browserInfo=function(){return{checkBrowser:function(){window.FileReader||alert("\tWARNING!\nYour web browser is not supported. This program might not behave as intended. Please use a recent version of Google Chrome, Firefox or Safari browser.")}}}();
