forked from automeris-io/WebPlotDigitizer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
combined-compiled.js
218 lines (218 loc) · 90.9 KB
/
combined-compiled.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
var wpd=wpd||{};wpd.initApp=function(){wpd.browserInfo.checkBrowser();wpd.layoutManager.initialLayout();wpd.graphicsWidget.loadImageFromURL("start.png");document.getElementById("loadingCurtain").style.display="none";wpd.messagePopup.show("Unstable Version Warning!","You are using a beta version of WebPlotDigitizer. There may be some issues with the software that are expected.");wpd.loadRemoteData()};
wpd.loadRemoteData=function(){"undefined"!==typeof wpdremote&&null!=wpdremote.imageData&&0<wpdremote.imageData.length&&wpd.messagePopup.show("Remote Data",wpdremote.imageData)};document.addEventListener("DOMContentLoaded",wpd.initApp,!0);wpd=wpd||{};wpd.detectionAlgoManager=function(){return{setActiveAlgo:function(c){},getActiveAlgo:function(){return null},getAllApplicableAlgorithms:function(){}}}();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(b){c().topColors=wpd.colorAnalyzer.getTopColors(b)}}}();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.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(b,a){return b.getPixelCount()>a.getPixelCount()?-1:b.getPixelCount()<a.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()/(0.25*c.data.length)};return k}}}();wpd=wpd||{};wpd.dataEventNames={axesAligned:"axesAligned",imageLoaded:"imageLoaded"};wpd.dataEventManager=function(){return{fireEvent:function(c,b){},subscribe:function(c,b){},unsubscribe:function(c,b){},removeAllSubscriptionsForEvent:function(c){}}}();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,p,m){var r=b.length,l=f.length;b[r]=c;a[r]=e;f[l]=k;f[l+1]=p;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,p){0>a||a>=b.length||(f[d*a]=c,f[d*a+1]=e,3===d&&(f[d*a+2]=p))};this.findNearestPoint=function(d,c,e){e=null==e?50:parseFloat(e);var f,m=-1,r,l;for(r=0;r<b.length;r++)if(l=Math.sqrt((d-b[r])*(d-b[r])+(c-a[r])*(c-a[r])),0>m&&l<=e||0<=m&&l<f)m=r,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.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,p=-1,m,r;for(m=0;m<b.length;m++)if(r=Math.sqrt((a-b[m].x)*(a-b[m].x)+(d-b[m].y)*(d-b[m].y)),0>p&&r<=c||0<=p&&r<f)p=m,f=r;return p};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)};this.getSelectedPixels=function(){return a}}}();
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.getDataFromActiveSeries=function(){var a=this.getActiveDataSeries();if(null==a||null==this.axes)return null;var b,f,e,g=[],h;b=a.hasMetadata();f=a.getMetadataKeys();var k=!0===b?f.length:0;for(b=0;b<a.getCount();b++){f=this.dataSeriesColl[c].getPixel(b);e=this.axes.pixelToData(f.x,f.y);g[b]=[];for(h=0;h<
e.length;h++)g[b][h]=e[h];for(h=0;h<k;h++)g[b][e.length+h]=f.metadata[h]}return g};this.reset=function(){this.distanceMeasurementData=this.angleMeasurementData=this.axes=null;this.dataSeriesColl=[];this.calibration=this.gridData=null;c=0;b=new wpd.AutoDetector}}}();
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,p,m,r;for(m=0;m<b.length;m++)for(r=0;r<2*c;r+=2)if(p=(b[m][r]-a)*(b[m][r]-a)+(b[m][r+1]-d)*(b[m][r+1]-d),-1===h||p<k)g=m,h=r/2,k=p;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.dateConverter=function(){function c(b,a){var d;d=a.replace("YYYY","yyyy");d=d.replace("YY","yy");d=d.replace("MMMM","mmmm");d=d.replace("MMM","mmm");d=d.replace("MM","mm");d=d.replace("DD","dd");d=d.replace("yyyy",b.getUTCFullYear());var c=b.getUTCFullYear()%100;d=d.replace("yy",10>c?"0"+c:c);d=d.replace("mmmm","January February March April May June July August September October November December".split(" ")[b.getUTCMonth()]);d=d.replace("mmm","Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" ")[b.getUTCMonth()]);
d=d.replace("mm",b.getUTCMonth()+1);return d=d.replace("dd",b.getUTCDate())}return{parse:function(b){if(null==b||0>b.indexOf("/"))b=null;else{var a=b.split("/"),d;0>=a.length||3<a.length?b=null:(b=parseInt(a[0],10),d=parseInt(void 0===a[1]?0:a[1],10),date=parseInt(void 0===a[2]?1:a[2],10),isNaN(b)||isNaN(d)||isNaN(date)||12<d||1>d||31<date||1>date?b=null:(a=new Date,a.setUTCFullYear(b),a.setUTCMonth(d-1),a.setUTCDate(date),b=parseFloat(Date.parse(a)),b=isNaN(b)?null:b))}return b},getFormatString:function(b){b=
b.split("/");var a="yyyy/mm/dd";1<=b.length&&(a="yyyy");2<=b.length&&(a+="/mm");3===b.length&&(a+="/dd");return a},formatDate:c,formatDateNumber:function(b,a){var d;d=parseFloat(b);d=parseInt(864E5*Math.round(d/864E5),10);return c(new Date(d),a)}}}();wpd=wpd||{};
wpd.gridDetectionCore=function(){var c,b,a,d;return{run:function(){var f=[],e,g,h,k=wpd.appData.getPlotData().getAutoDetector(),p=k.gridMask.xmin,m=k.gridMask.xmax,r=k.gridMask.ymin,l=k.gridMask.ymax,n,u=k.imageWidth,q,t,s;if(b)for(e=p;e<=m;e+=a){h=[];t=[];q=0;for(n=e-a;n<=e+a;n++)for(g=r;g<=l;g++)s=g*u+parseInt(n,10),!0===k.gridBinaryData[s]&&(h[h.length]=s,!0!==t[g]&&(q++,t[g]=!0));if(q>0.3*(l-r))for(q=0;q<h.length;q++)f[h[q]]=!0}if(c)for(g=r;g<=l;g+=d){h=[];t=[];q=0;for(r=g-d;r<=g+d;r++)for(e=
p;e<=m;e++)s=parseInt(r,10)*u+e,!0===k.gridBinaryData[s]&&(h[h.length]=s,!0!==t[e]&&(q++,t[e]=!0));if(q>0.3*(m-p))for(q=0;q<h.length;q++)f[h[q]]=!0}wpd.appData.getPlotData().gridData=f},setHorizontalParameters:function(a,b,g){c=a;d=b},setVerticalParameters:function(d,c,g){b=d;a=c}}}();wpd=wpd||{};
wpd.InputParser=function(){return function(){this.parse=function(c){this.isDate=this.isValid=!1;this.formatting=null;if(null==c)return null;c=c.trim();if(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.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.AveragingWindowCore=function(){return function(c,b,a,d,f,e){this.run=function(){var g=[],h=0,k=[],p,m,r,l,n,u,q,t,s;e.clearAll();for(p=0;p<a;p++){n=-1;r=-2*f;for(m=l=0;m<b;m++)!0===c[m*a+p]&&(m>r+f?(n+=1,l=1,r=k[n]=m):(l+=1,k[n]=parseFloat((k[n]*(l-1)+m)/parseFloat(l))));if(0<=n)for(r=p,m=0;m<=n;m++)l=k[m],g[h]=[],g[h][0]=parseFloat(r),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]){p=!0;n=k+1;m=g[k][0];r=g[k][1];l=m;u=r;for(s=1;!0===p&&n<h;)q=g[n][0],t=g[n][1],
Math.abs(q-m)<=d&&Math.abs(t-r)<=f&&!0===g[n][2]&&(l=(l*s+q)/(s+1),u=(u*s+t)/(s+1),s+=1,g[n][2]=!1),q>m+2*d&&(p=!1),n+=1;g[k][2]=!1;e.addPixel(parseFloat(l),parseFloat(u))}return e}}}}();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",0.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",0.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 p=h.imageWidth,m=h.imageHeight,r,l,n,u,q,t,s,v,w;k.clearAll();for(r=c;r<=a;r+=b)for(w=g.dataToPixel(r,f),l=w.x,u=w.y,w=g.dataToPixel(r,e),n=w.x,q=w.y,l=Math.sqrt((q-u)*(q-u)+(n-l)*(n-l)),n=(e-f)/l,u=!1,t=q=0,s=!1,v=0;v<=l;v++)w=1*-v*n+e,w=g.dataToPixel(r,w),xi_pix=w.x,yi_pix=w.y,0<=xi_pix&&xi_pix<p&&0<=yi_pix&&yi_pix<m&&(!0===
h.binaryData[parseInt(yi_pix,10)*p+parseInt(xi_pix,10)]?(!1===u&&(t=q=v,u=!0,s=!1),!0===s&&(t=v,s=!1)):!1===s&&(t=v,s=!0),!0===u&&(v>q+d||v==l-1)&&(u=!1,q>t&&(t=v),w=(q+t)/2,w=1*-w*n+e,w=g.dataToPixel(r,w),k.addPixel(parseFloat(w.x),parseFloat(w.y))))}}}();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=[],p,m,r,l,n,u,q,t,
s;if(!(0>=e||0>=g||null==d.binaryData||0===d.binaryData.length)){f.clearAll();f.setMetadataKeys(["area","moment"]);for(p=0;p<e;p++)for(m=0;m<g;m++)if(!0===d.binaryData[m*e+p]&&!0!==h[m*e+p])for(h[m*e+p]=!0,l=k.length,k[l]={pixels:[{x:p,y:m}],centroid:{x:p,y:m},area:1,moment:0},r=0;r<k[l].pixels.length;){q=k[l].pixels[r].x;t=k[l].pixels[r].y;for(n=q-1;n<=q+1;n++)for(u=t-1;u<=t+1;u++)0<=n&&0<=u&&n<e&&u<g&&!0!==h[u*e+n]&&!0===d.binaryData[u*e+n]&&(h[u*e+n]=!0,s=k[l].pixels.length,k[l].pixels[s]={x:n,
y:u},k[l].centroid.x=(k[l].centroid.x*s+n)/(s+1),k[l].centroid.y=(k[l].centroid.y*s+u)/(s+1),k[l].area+=1);r+=1}for(l=0;l<k.length;l++){for(r=k[l].moment=0;r<k[l].pixels.length;r++)k[l].moment=k[l].moment+(k[l].pixels[r].x-k[l].centroid.x)*(k[l].pixels[r].x-k[l].centroid.x)+(k[l].pixels[r].y-k[l].centroid.y)*(k[l].pixels[r].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","Units",0]]):[["X_min","Units",0],["\u0394X Step","Units",0.1],["X_max","Units",0],["Y_min","Units",0],["Y_max","Units",0],["Smoothing",
"Units",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 p=0,m=h.imageWidth,r=h.imageHeight,l,n,u,q,t,s,v=[],w=[];s=[];var y=[];k.clearAll();l=g.dataToPixel(c,f);n=g.dataToPixel(c,e);n=Math.sqrt((l.x-n.x)*(l.x-n.x)+(l.y-n.y)*(l.y-n.y));y=(e-f)/n;n=g.dataToPixel(a,f);l=Math.sqrt((l.x-n.x)*(l.x-n.x)+(l.y-n.y)*(l.y-n.y));n=(a-c)/l;for(l=c;0<n&&l<=a||0>n&&l>=a;){t=q=0;
for(u=f;0<y&&u<=e||0>y&&u>=e;)s=g.dataToPixel(l,u),0<s.x&&0<s.y&&s.x<m&&s.y<r&&!0===h.binaryData[parseInt(s.y,10)*m+parseInt(s.x,10)]&&(q=(q*t+u)/parseFloat(t+1),t++),u+=y;0<t&&(v[p]=parseFloat(l),w[p]=parseFloat(q),p+=1);l+=n}if(!(0>=v.length||0>=w.length)){if(0<d)for(s=[],y=[],l=v[0];0<n&&l<=v[v.length-1]||0>n&&l>=v[v.length-1];){for(h=t=m=p=0;h<v.length;h++)v[h]<l+d&&v[h]>l-d&&(p=(p*t+v[h])/parseFloat(t+1),m=(m*t+w[h])/parseFloat(t+1),t++);0<t&&(s[s.length]=p,y[y.length]=m);l=0<n?l+d:l-d}else s=
v,y=w;if(!(0>=s.length||0>=y.length||(v=[],h=0,l=c,0>n&&0<b||0<n&&0>b))){for(;0<n&&l<=a||0>n&&l>=a;)v[h]=l,h++,l+=b;w=numeric.spline(s,y).at(v);for(h=0;h<w.length;h++)isNaN(v[h])||isNaN(w[h])||(s=g.dataToPixel(v[h],w[h]),k.addPixel(s.x,s.y))}}}}}();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 d=this.pixelToData(b,a);return d[0].toFixed(2)+", "+d[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,d,c;this.isCalibrated=function(){return b};this.calibrate=function(e,g,h){var k=e.getPoint(0);e=e.getPoint(1);c=Math.sqrt((k.px-e.px)*(k.px-e.px)+(k.py-e.py)*(k.py-e.py));a=parseFloat(g);d=h;return b=!0};this.pixelToData=function(b,d){var h=[];h[0]=b*a/c;h[1]=d*a/c;return h};this.pixelToDataDistance=function(b){return b*a/c};this.pixelToDataArea=function(b){return b*a*a/(c*c)};this.dataToPixel=function(a,b,d){return{x:0,y:0}};this.pixelToLiveString=
function(a,b){var d=this.pixelToData(a,b);return d[0].toExponential(4)+", "+d[1].toExponential(4)};this.getScaleLength=function(){return a};this.getUnits=function(){return d};this.getTransformationEquations=function(){return{pixelToData:["x_data = "+a/c+"*x_pixel","y_data = "+a/c+"*y_pixel"],dataToPixel:["x_pixel = "+c/a+"*x_data","y_pixel = "+c/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,d=!1,c,e,g,h,k,p,m,r,l,n,u,q,t,s;processCalibration=function(b,w,y){var z=b.getPoint(0),G=b.getPoint(1);b=b.getPoint(2);c=z.px;e=z.py;g=G.px;h=G.py;k=b.px;p=b.py;m=G.dx;r=G.dy;l=b.dx;a=w;d=y;!0===a&&(r*=Math.PI/180);n=Math.sqrt((g-c)*(g-c)+(h-e)*(h-e));u=Math.sqrt((k-c)*(k-c)+(p-e)*(p-e));q=u-n;t=wpd.taninverse(-(h-e),g-c);s=t-r;return!0};this.isCalibrated=function(){return b};this.calibrate=function(a,d,c){return b=processCalibration(a,d,c)};
this.isThetaDegrees=function(){return a};this.isThetaClockwise=function(){return d};this.pixelToData=function(b,d){var g=[],h,k;xp=parseFloat(b);yp=parseFloat(d);h=(l-m)/q*(Math.sqrt((xp-c)*(xp-c)+(yp-e)*(yp-e))-n)+m;k=wpd.taninverse(-(yp-e),xp-c)-s;!0==a&&(k=180*k/Math.PI);g[0]=h;g[1]=k;return g};this.dataToPixel=function(a,b){return{x:0,y:0}};this.pixelToLiveString=function(a,b){var d=this.pixelToData(a,b);return d[0].toExponential(4)+", "+d[1].toExponential(4)};this.getTransformationEquations=
function(){var b="r = ("+(l-m)/q+")*sqrt((x_pixel - "+c+")^2 + (y_pixel - "+e+")^2) + ("+(m-n*(l-m)/q)+")",d="atan2(("+e+" - y_pixel), (x_pixel - "+c+")) - ("+s+")",d=a?"theta = (180/PI)*("+d+"), theta = theta + 360 if theta < 0":"theta = "+d+" theta = theta + 2*PI if theta < 0";return{pixelToData:[b,d]}}};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,d,c,e,g,h,k,p,m;this.isCalibrated=function(){return b};this.calibrate=function(r,l,n){var u=r.getPoint(0),q=r.getPoint(1);r.getPoint(2);a=u.px;d=u.py;c=q.px;e=q.py;g=Math.sqrt((a-c)*(a-c)+(d-e)*(d-e));h=wpd.taninverse(-(e-d),c-a);k=Math.sqrt(3);p=l;m=n;return b=!0};this.isRange100=function(){return p};this.isNormalOrientation=function(){return m};this.pixelToData=function(b,c){var e=[],f,q,t,s;xp=parseFloat(b);yp=parseFloat(c);f=Math.sqrt((xp-
a)*(xp-a)+(yp-d)*(yp-d));q=wpd.taninverse(-(yp-d),xp-a)-h;t=f*Math.cos(q)/g;q=f*Math.sin(q)/g;f=1-t-q/k;t-=q/k;q=2*q/k;!1==m&&(s=t,t=f,f=q,q=s);!0==p&&(f*=100,t*=100,q*=100);e[0]=f;e[1]=t;e[2]=q;return e};this.dataToPixel=function(a,b,d){return{x:0,y:0}};this.pixelToLiveString=function(a,b){var d=this.pixelToData(a,b);return d[0].toExponential(4)+", "+d[1].toExponential(4)+", "+d[2].toExponential(4)};this.getTransformationEquations=function(){var b="rp = sqrt((x_pixel - "+a+")^2 + (y_pixel - "+d+
")^2)/("+g+")",h="thetap = atan2(("+d+" - y_pixel), (x_pixel - "+a+")) - ("+Math.atan2(-(e-d),c-a)+")",k="1 - rp*(cos(thetap) - sin(thetap)/sqrt(3))",u="rp*(cos(thetap) - sin(thetap)/sqrt(3))",q="2*rp*sin(thetap)/sqrt(3)",t;p&&(k="100*("+k+")",u="100*("+u+")",q="100*("+q+")");k="a_data = "+k;u="b_data = "+u;q="c_data = "+q;m||(t=u,u=k,k=q,q=t);return{pixelToData:[b,h,k,u,q]}}};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,d=!1,c=!1,e=!1,g,h,k,p,m,r,l,n,u,q,t,s,v,w,y=[0,0,0,0],z=[0,0,0,0];c_vec=[0,0];processCalibration=function(b,K,F){if(4>b.getCount())return!1;var D=b.getPoint(0),I=b.getPoint(1),H=b.getPoint(2);b=b.getPoint(3);var E=new wpd.InputParser;k=D.px;l=D.py;p=I.px;n=I.py;m=H.px;u=H.py;r=b.px;q=b.py;t=D.dx;s=I.dx;v=H.dy;w=b.dy;t=E.parse(t);if(!E.isValid)return!1;c=E.isDate;s=E.parse(s);if(!E.isValid||E.isDate!=c)return!1;g=E.formatting;v=E.parse(v);if(!E.isValid)return!1;
e=E.isDate;w=E.parse(w);if(!E.isValid||E.isDate!=e)return!1;h=E.formatting;a=K;d=F;!0===a&&(t=Math.log(t)/Math.log(10),s=Math.log(s)/Math.log(10));!0===d&&(v=Math.log(v)/Math.log(10),w=Math.log(w)/Math.log(10));y=wpd.mat.mult2x2([t-s,0,0,v-w],wpd.mat.inv2x2([k-p,m-r,l-n,u-q]));z=wpd.mat.inv2x2(y);c_vec[0]=t-y[0]*k-y[1]*l;c_vec[1]=v-y[2]*m-y[3]*u;return!0};this.getBounds=function(){return{x1:t,x2:s,y3:v,y4:w}};this.isCalibrated=function(){return b};this.calibrate=function(a,d,c){return b=processCalibration(a,
d,c)};this.pixelToData=function(b,c){var e=[],f,g;f=parseFloat(b);g=parseFloat(c);g=wpd.mat.mult2x2Vec(y,[f,g]);g[0]+=c_vec[0];g[1]+=c_vec[1];f=g[0];g=g[1];!0===a&&(f=Math.pow(10,f));!0===d&&(g=Math.pow(10,g));e[0]=f;e[1]=g;return e};this.dataToPixel=function(a,b){var d;d=wpd.mat.mult2x2Vec(z,[a-c_vec[0],b-c_vec[1]]);return{x:d[0],y:d[1]}};this.pixelToLiveString=function(a,b){var d="",k=this.pixelToData(a,b),d=c?d+wpd.dateConverter.formatDateNumber(k[0],g):d+k[0].toExponential(4),d=d+", ";return d=
e?d+wpd.dateConverter.formatDateNumber(k[1],h):d+k[1].toExponential(4)};this.isDate=function(a){return 0===a?c:e};this.getInitialDateFormat=function(a){return 0===a?g:h};this.isLogX=function(){return a};this.isLogY=function(){return d};this.getTransformationEquations=function(){var b="("+y[0]+")*x_pixel + ("+y[1]+")*y_pixel + ("+c_vec[0]+")",c="("+y[2]+")*x_pixel + ("+y[3]+")*y_pixel + ("+c_vec[1]+")",e="x_pixel = ("+z[0]+")*x_data + ("+z[1]+")*y_data + ("+(-z[0]*c_vec[0]-z[1]*c_vec[1])+")",g="y_pixel = ("+
z[2]+")*x_data + ("+z[3]+")*y_data + ("+(-z[2]*c_vec[0]-z[3]*c_vec[1])+")",b=a?"x_data = pow(10, "+b+")":"x_data = "+b,c=d?"y_data = pow(10, "+c+")":"y_data = "+c;return a||d?{pixelToData:[b,c]}:{pixelToData:[b,c],dataToPixel:[e,g]}}};c.prototype.numCalibrationPointsRequired=function(){return 4};c.prototype.getDimensions=function(){return 2};c.prototype.getAxesLabels=function(){return["X","Y"]};return c}();wpd=wpd||{};
wpd.dataTable=function(){function c(){e=wpd.appData.getPlotData().getDataFromActiveSeries()}function b(){g=e.slice(0);var a=document.getElementById("data-sort-variables").value,b="ascending"===document.getElementById("data-sort-order").value,d="raw"===a,c="NearestNeighbor"===a,f,h=wpd.appData.getPlotData().axes.getDimensions();if(!d)if(!c)f=parseInt(a,10),g.sort(function(a,d){return a[f]>d[f]?b?1:-1:a[f]<d[f]?b?-1:1:0});else if(c){var u,c=[1,1,1],q,t,s=e.length;for(q=0;q<s-1;q++){d=-1;for(t=q+1;t<
s;t++)if(a=(g[q][0]-g[t][0])*(g[q][0]-g[t][0])+(g[q][1]-g[t][1])*(g[q][1]-g[t][1]),3===h&&(a+=(g[q][2]-g[t][2])*(g[q][2]-g[t][2])),a<u||-1===d)u=a,d=t;c[0]=g[d][0];g[d][0]=g[q+1][0];g[q+1][0]=c[0];c[1]=g[d][1];g[d][1]=g[q+1][1];g[q+1][1]=c[1];3===h&&(c[2]=g[d][2],g[d][2]=g[q+1][2],g[q+1][2]=c[2])}}}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!=e){var a=wpd.appData.getPlotData().axes,b=wpd.appData.getPlotData().getActiveDataSeries(),d=a.getDimensions(),b=b.getMetadataKeys().length,c=e.length,f,n,u,q=document.getElementById("digitizedDataTable"),t=[],s=parseInt(document.getElementById("data-number-format-digits").value,10),v=document.getElementById("data-number-format-style").value;h="";for(f=0;f<c;f++){u=[];for(n=0;n<d+b;n++)n<d&&null!=a.isDate&&a.isDate(n)?(void 0===t[n]&&(t[n]=document.getElementById("data-format-string-"+
n).value),u[n]=wpd.dateConverter.formatDateNumber(g[f][n],t[n])):u[n]="fixed"===v&&0<=s?g[f][n].toFixed(s):"precision"===v&&0<=s?g[f][n].toPrecision(s):"exponential"===v&&0<=s?g[f][n].toExponential(s):g[f][n];h+=u.join(", ");h+="\n"}q.value=h}}function f(){if(wpd.appData.isAligned()){wpd.popup.show("csvWindow");c();var e=document.getElementById("data-sort-variables"),f=document.getElementById("dataVariables"),g=document.getElementById("data-date-formatting-container"),h=document.getElementById("data-date-formatting"),
l=wpd.appData.getPlotData().axes,n=wpd.appData.getPlotData().getActiveDataSeries(),u=l.getAxesLabels(),q="",t=u.join(", "),s="";isAnyVariableDate=!1;tableVariables=u;dimCount=l.getDimensions();n.hasMetadata()&&(tableVariables=u.concat(n.getMetadataKeys()),t=tableVariables.join(", "));g.style.display="none";q+='<option value="raw">Raw</option>';for(n=0;n<tableVariables.length;n++)q+='<option value="'+n+'">'+tableVariables[n]+"</option>",n<dimCount&&null!=l.isDate&&null!=l.getInitialDateFormat&&l.isDate(n)&&
(s+="<p>"+u[n]+' <input type="text" length="15" value="'+l.getInitialDateFormat(n)+'" id="data-format-string-'+n+'"/></p>',isAnyVariableDate=!0);e.innerHTML=q+'<option value="NearestNeighbor">Nearest Neighbor</option>';f.innerHTML=t;isAnyVariableDate&&(g.style.display="inline-block",h.innerHTML=s);b();d();a();for(var e=document.getElementById("data-table-dataset-list"),f=wpd.appData.getPlotData(),g=f.getActiveDataSeriesIndex(),v,h=0;h<f.dataSeriesColl.length;h++)v+="<option>"+f.dataSeriesColl[h].name+
"</option>";e.innerHTML=v;e.selectedIndex=g}}var e,g,h;return{getSeriesData:c,showTable:f,updateSortingControls:a,reSort:function(){a();b();d()},selectAll:function(){var a=document.getElementById("digitizedDataTable");a.focus();a.select()},generateCSV:function(){wpd.download.csv(JSON.stringify(h))},exportToPlotly:function(){if(null!=e&&0!==e.length){var a=document.createElement("div"),b=document.createElement("form"),d=document.createElement("textarea");b.setAttribute("method","post");b.setAttribute("action",
"https://plot.ly/external");b.setAttribute("target","_blank");d.setAttribute("name","data");d.setAttribute("id","data");b.appendChild(d);a.appendChild(b);document.body.appendChild(a);a.style.display="none";var c={data:[]},f=wpd.appData.getPlotData().axes,h=wpd.appData.getPlotData().getActiveDataSeries().getMetadataKeys(),u=h.length,q=f.getDimensions(),t=e.length,s,v,w=["x","y","z"];c.data[0]={};for(s=0;s<t;s++)for(rowValues=[],v=0;v<q+u;v++)0===s&&(v<q?c.data[0][w[v]]=[]:c.data[0][h[v-q]]=[]),v<q&&
null!=f.isDate&&f.isDate(v)?c.data[0][w[v]][s]=wpd.dateConverter.formatDateNumber(g[s][v],"yyyy-mm-dd"):v<q?c.data[0][w[v]][s]=g[s][v]:c.data[0][h[v-q]][s]=g[s][v];d.innerHTML=JSON.stringify(c);b.submit();document.body.removeChild(a)}},changeDataset:function(){var a=document.getElementById("data-table-dataset-list");wpd.appData.getPlotData().setActiveDataSeriesIndex(a.selectedIndex);wpd.graphicsWidget.forceHandlerRepaint();wpd.dataPointCounter.setCount();wpd.popup.close("csvWindow");f()}}}();
wpd=wpd||{};
wpd.graphicsWidget=function(){function c(a){var b=z.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/J,y:b/J}}function a(a,b){a=parseInt(a,10);b=parseInt(b,10);E.style.width=a+"px";E.style.height=b+"px";z.width=a;G.width=a;K.width=a;F.width=a;D.width=a;z.height=b;G.height=b;K.height=b;F.height=b;D.height=b;V=a/(1*b);L=a;M=b;if(null!=O){Q.fillStyle="rgb(255, 255, 255)";Q.fillRect(0,0,L,M);
Q.drawImage(I,0,0,L,M);if(null!=A&&void 0!=A.onRedraw)A.onRedraw();if(null!=x&&void 0!=x.onRedraw)x.onRedraw()}}function d(){z.width=z.width;G.width=G.width;K.width=K.width;F.width=F.width;D.width=D.width;H.width=H.width}function f(){if(null!=A&&void 0!=A.onRemove)A.onRemove();A=null}function e(){var b=wpd.layoutManager.getGraphicsViewportSize();a(b.width,b.height);V>R?(J=M/(1*B),a(M*R,M)):(J=L/(1*C),a(L,L/R))}function g(b){J=b;a(C*J,B*J)}function h(a){220===a.keyCode&&(a.preventDefault(),T=!T,F.width=
F.width)}function k(a,b){var d=wpd.zoomView.getSize(),c=wpd.zoomView.getZoomRatio(),e,f,g,h,k,m,l,r=0,p=0,n=d.width,q=d.height;g=d.width/c;h=d.height/c;e=a-g/2;f=b-h/2;m=e;d=f;k=e+g;l=f+h;0>e&&(m=0,r=-e*c);0>f&&(d=0,p=-f*c);e+g>=C&&(k=C,n-=c*(C-(e+g)));f+h>=B&&(l=B,q-=c*(B-(f+h)));g=P.getImageData(parseInt(m,10),parseInt(d,10),parseInt(k-m,10),parseInt(l-d,10));k=S.getImageData(parseInt(m,10),parseInt(d,10),parseInt(k-m,10),parseInt(l-d,10));for(l=0;l<k.data.length;l+=4)if(0!=k.data[l]||0!=k.data[l+
1]||0!=k.data[l+2])g.data[l]=k.data[l],g.data[l+1]=k.data[l+1],g.data[l+2]=k.data[l+2];m=c*(parseInt(m,10)-m);c*=parseInt(d,10)-d;wpd.zoomView.setZoomImage(g,parseInt(r+m,10),parseInt(p+c,10),parseInt(n-r,10),parseInt(q-p,10))}function p(a){clearTimeout(W);var d=setTimeout,e=c(a);a=e.x;var e=e.y,f=b(a,e);T&&(F.width=F.width,N.strokeStyle="rgba(0,0,0, 0.5)",N.beginPath(),N.moveTo(a,0),N.lineTo(a,M),N.moveTo(0,e),N.lineTo(L,e),N.stroke());k(f.x,f.y);wpd.zoomView.setCoords(f.x,f.y);W=d(void 0,10)}function m(){z=
document.getElementById("mainCanvas");G=document.getElementById("dataCanvas");K=document.getElementById("drawCanvas");F=document.getElementById("hoverCanvas");D=document.getElementById("topCanvas");I=document.createElement("canvas");H=document.createElement("canvas");Q=z.getContext("2d");U=G.getContext("2d");N=F.getContext("2d");X=D.getContext("2d");Y=K.getContext("2d");P=I.getContext("2d");S=H.getContext("2d");E=document.getElementById("canvasDiv");document.body.addEventListener("keydown",h,!1);
D.addEventListener("mousemove",p,!1);D.addEventListener("dragover",function(a){a.preventDefault()},!0);D.addEventListener("drop",function(a){a.preventDefault();wpd.busyNote.show();a=a.dataTransfer.files;1===a.length&&l(a[0])},!0);D.addEventListener("mousemove",q,!1);D.addEventListener("click",t,!1);D.addEventListener("mouseup",v,!1);D.addEventListener("mousedown",w,!1);D.addEventListener("mouseout",y,!0);document.addEventListener("mouseup",s,!1);document.addEventListener("mousedown",function(a){Z=
a.target===D?!0:!1},!1);document.addEventListener("keydown",function(a){if(Z&&null!=x&&void 0!=x.onKeyDown)x.onKeyDown(a)},!0);wpd.zoomView.initZoom();document.getElementById("fileLoadBox").addEventListener("change",n);window.addEventListener("paste",function(a){wpd.busyNote.show();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")){var d=a[b].getAsFile();(window.URL||window.webkitURL).createObjectURL(d);l(d)}},!1)}function r(a){var b=
document.createElement("img");b.onload=function(){null==z&&m();wpd.appData.reset();wpd.sidebar.clear();u();f();C=b.width;B=b.height;R=C/(1*B);I.width=C;I.height=B;H.width=C;H.height=B;P.drawImage(b,0,0,C,B);O=P.getImageData(0,0,C,B);d();e();wpd.appData.plotLoaded(O);wpd.busyNote.close();!1===$&&wpd.popup.show("axesList");$=!1};b.src=a}function l(a){if(a.type.match("image.*")){var b=new FileReader;b.onload=function(){r(b.result)};b.readAsDataURL(a)}}function n(){wpd.busyNote.show();var a=document.getElementById("fileLoadBox");
1==a.files.length&&l(a.files[0]);wpd.popup.close("loadNewImage")}function u(){if(null!=x&&void 0!=x.onRemove)x.onRemove();x=null}function q(a){if(null!=x&&void 0!=x.onMouseMove){var d=c(a),e=b(d.x,d.y);x.onMouseMove(a,d,e)}}function t(a){if(null!=x&&void 0!=x.onMouseClick){var d=c(a),e=b(d.x,d.y);x.onMouseClick(a,d,e)}}function s(a){if(null!=x&&void 0!=x.onDocumentMouseUp){var d=c(a),e=b(d.x,d.y);x.onDocumentMouseUp(a,d,e)}}function v(a){if(null!=x&&void 0!=x.onMouseUp){var d=c(a),e=b(d.x,d.y);x.onMouseUp(a,
d,e)}}function w(a){if(null!=x&&void 0!=x.onMouseDown){var d=c(a),e=b(d.x,d.y);x.onMouseDown(a,d,e)}}function y(a){if(null!=x&&void 0!=x.onMouseOut){var d=c(a),e=b(d.x,d.y);x.onMouseOut(a,d,e)}}var z,G,K,F,D,I,H,E,Q,U,Y,N,X,P,S,L,M,C,B,R,V,O,J,T=!1,W,x,A,Z=!1,$=!0;return{zoomIn:function(){g(1.2*J)},zoomOut:function(){g(J/1.2)},zoomFit:e,zoom100perc:function(){g(1)},setZoomRatio:g,getZoomRatio:function(){return J},loadImageFromURL:r,load:n,runImageOp:function(a){var b=a(O,C,B);a=b.imageData;var c=
b.width,b=b.height;wpd.appData.reset();u();f();C=c;B=b;R=C/(1*B);I.width=C;I.height=B;H.width=C;H.height=B;P.putImageData(a,0,0);O=a;d();e();wpd.appData.plotLoaded(O)},setTool:function(a){if(null!=x&&void 0!=x.onRemove)x.onRemove();x=a;if(null!=x&&void 0!=x.onAttach)x.onAttach()},removeTool:u,getAllContexts:function(){return{mainCtx:Q,dataCtx:U,drawCtx:Y,hoverCtx:N,topCtx:X,oriImageCtx:P,oriDataCtx:S}},resetData:function(){H.width=H.width;G.width=G.width},resetHover:function(){F.width=F.width},imagePx:b,
screenPx:function(a,b){return{x:a*J,y:b*J}},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:L,height:M}},getImageSize:function(){return{width:C,height:B}},copyImageDataLayerToScreen:function(){U.drawImage(H,0,0,L,M)},setRepainter:function(a){if(null==A||void 0==A.painterName||null==a||void 0==a.painterName||A.painterName!=a.painterName){if(null!=
A&&void 0!=A.onRemove)A.onRemove();A=a;if(null!=A&&void 0!=A.onAttach)A.onAttach()}},removeRepainter:f,forceHandlerRepaint:function(){if(null!=A&&void 0!=A.onForcedRedraw)A.onForcedRedraw()},getRepainter:function(){return A},saveImage:function(){var a=document.createElement("canvas"),b=a.getContext("2d"),d,c,e;a.width=C;a.height=B;b.drawImage(I,0,0,C,B);d=b.getImageData(0,0,C,B);e=S.getImageData(0,0,C,B);for(c=0;c<d.data.length;c+=4)if(0!=e.data[c]||0!=e.data[c+1]||0!=e.data[c+2])d.data[c]=e.data[c],
d.data[c+1]=e.data[c+1],d.data[c+2]=e.data[c+2];b.putImageData(d,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(){return{show:function(c){document.getElementById("shadow").style.visibility="visible";c=document.getElementById(c);var b=parseInt(window.innerWidth),a=parseInt(window.innerHeight),d=parseInt(c.offsetWidth),f=parseInt(c.offsetHeight),a=(a-f)/2;c.style.left=(b-d)/2+"px";c.style.top=(60<a?60:a)+"px";c.style.visibility="visible"},close:function(c){document.getElementById("shadow").style.visibility="hidden";document.getElementById(c).style.visibility="hidden"}}}();
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> </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(d){b=d;a.src=window.URL.createObjectURL(d)},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"===p?"rgba(0,0,0,1)":"red"===p?"rgba(255,0,0,1)":"yellow"===p?"rgba(255,255,0,1)":"rgba(0,0,0,1)";b.beginPath();b.moveTo(e/2,0);b.lineTo(e/2,g);b.moveTo(0,g/2);b.lineTo(e,g/2);b.stroke()}var b,a,d,f,e=250,g=250,h,k,p="black";return{initZoom:function(){b=document.getElementById("zoomCanvas");a=b.getContext("2d");d=document.createElement("canvas");f=d.getContext("2d");
h=document.getElementById("mousePosition");k=5;c()},setZoomImage:function(c,e,g,h,p){d.width=h/k;d.height=p/k;f.putImageData(c,0,0);b.width=b.width;a.drawImage(d,e,g,h,p)},setCoords:function(a,b){if(wpd.appData.isAligned()){var d=wpd.appData.getPlotData();h.innerHTML=d.axes.pixelToLiveString(a,b)}else h.innerHTML=a.toFixed(2)+", "+b.toFixed(2)},setZoomRatio:function(a){k=a},getZoomRatio:function(){return k},getSize:function(){return{width:e,height:g}},showSettingsWindow:function(){document.getElementById("zoom-magnification-value").value=
k;document.getElementById("zoom-crosshair-color-value").value=p;wpd.popup.show("zoom-settings-popup")},applySettings:function(){k=document.getElementById("zoom-magnification-value").value;p=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.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,d=new wpd.MapAxes,c=wpd.alignAxes.getActiveCalib();d.calibrate(c,b,a);b=wpd.appData.getPlotData();
b.axes=d;b.calibration=c;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 d=b.getPoint(b.getSelectedPoints()[0]),c=d.px,d=d.py,f=!0===a.shiftKey?5/wpd.graphicsWidget.getZoomRatio():0.5/wpd.graphicsWidget.getZoomRatio();if(wpd.keyCodes.isUp(a.keyCode))d-=f;else if(wpd.keyCodes.isDown(a.keyCode))d+=f;else if(wpd.keyCodes.isLeft(a.keyCode))c-=f;else if(wpd.keyCodes.isRight(a.keyCode))c+=f;else return;b.changePointPx(b.getSelectedPoints()[0],
c,d);wpd.graphicsWidget.forceHandlerRepaint();wpd.graphicsWidget.updateZoomToImagePosn(c,d);a.preventDefault();a.stopPropagation()}}}}();
wpd.AlignmentCornersRepainter=function(){return function(){var c=wpd.graphicsWidget.getAllContexts();this.painterName="AlignmentCornersReptainer";this.onForcedRedraw=function(){wpd.graphicsWidget.resetData();this.onRedraw()};this.onRedraw=function(){var b=wpd.alignAxes.getActiveCalib();if(null!=b){var a,d,f;for(a=0;a<b.getCount();a++)f=b.getPoint(a),d=wpd.graphicsWidget.screenPx(f.px,f.py),c.dataCtx.fillStyle="rgba(255,255,255,0.7)",c.dataCtx.fillRect(d.x-10,d.y-10,20,40),c.dataCtx.beginPath(),b.isPointSelected(a)?
c.dataCtx.fillStyle="rgba(0,200,0,1)":c.dataCtx.fillStyle="rgba(200,0,0,1)",c.dataCtx.arc(d.x,d.y,3,0,2*Math.PI,!0),c.dataCtx.fill(),c.dataCtx.font="14px sans-serif",c.dataCtx.fillText(b.labels[a],d.x-10,d.y+18),c.oriDataCtx.beginPath(),b.isPointSelected(a)?c.oriDataCtx.fillStyle="rgb(0,200,0)":c.oriDataCtx.fillStyle="rgb(200,0,0)",c.oriDataCtx.arc(f.px,f.py,3,0,2*Math.PI,!0),c.oriDataCtx.fill(),c.oriDataCtx.font="14px sans-serif",c.oriDataCtx.fillText(b.labels[a],parseInt(f.px-10,10),parseInt(f.py+
18,10))}}}}();
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");wpd.popup.close("axesList");if(!0===xyEl.checked)b=wpd.xyCalibration;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 a=wpd.appData.getPlotData();a.getActiveDataSeries();var b=a.getActiveDataSeriesIndex(),c=document.getElementById("automatic-sidebar-dataset-list"),e="",g;for(g=0;g<a.dataSeriesColl.length;g++)e+="<option>"+a.dataSeriesColl[g].name+"</option>";c.innerHTML=e;c.selectedIndex=b}function b(){var a=wpd.appData.getPlotData().getAutoDetector(),b=document.getElementById("auto-extract-algo-name").value;if("averagingWindow"===b)a.algorithm=new wpd.AveragingWindowAlgo;
else if("XStep"===b||"XStepWithInterpolation"===b){var c=wpd.appData.getPlotData().axes;c instanceof wpd.XYAxes&&!1===c.isLogX()&&!1===c.isLogY()?"XStep"===b?a.algorithm=new wpd.AveragingWindowWithStepSizeAlgo:"XStepWithInterpolation"===b&&(a.algorithm=new wpd.XStepWithInterpolationAlgo):(wpd.messagePopup.show("Not supported!","This algorithm is only supported for non log scale XY plots."),document.getElementById("auto-extract-algo-name").value="averagingWindow",a.algorithm=new wpd.AveragingWindowAlgo)}else"blobDetector"===
b&&(a.algorithm=new wpd.BlobDetectorAlgo);for(var b=a.algorithm,a=document.getElementById("algo-parameter-container"),b=b.getParamList(),e="<table>",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>"}return{start:function(){wpd.sidebar.show("auto-extraction-sidebar");c();wpd.colorPicker.init();b()},changeAlgorithm:b,runAlgo: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(),p=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,p.width,p.height);a.generateBinaryData();wpd.graphicsWidget.setRepainter(c);
b.run(wpd.appData.getPlotData());wpd.graphicsWidget.forceHandlerRepaint();wpd.dataPointCounter.setCount();wpd.busyNote.close();return!0},10)},updateDatasetControl:c,changeDataset:function(){var a=document.getElementById("automatic-sidebar-dataset-list").selectedIndex;wpd.appData.getPlotData().setActiveDataSeriesIndex(a);wpd.graphicsWidget.forceHandlerRepaint();wpd.dataPointCounter.setCount()}}}();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,p="",m,r;for(f=0;f<d;f++)r="rgb("+
c[f].r+","+c[f].g+","+c[f].b+");",m=c[f].percentage.toFixed(3)+"%",p+='<div class="colorOptionBox" style="background-color: '+r+'" title="'+m+'" onclick="wpd.colorSelectionWidget.selectTopColor('+f+');"></div>';a.innerHTML=p;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,r;r=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),r.data[4*m]=255,r.data[4*m+1]=255,r.data[4*m+2]=0,r.data[4*m+3]=
255):(r.data[4*m]=0,r.data[4*m+1]=0,r.data[4*m+2]=0,r.data[4*m+3]=150);c.oriDataCtx.putImageData(r,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.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(),p=d.getDataSeriesNames(),d=d.getActiveDataSeriesIndex(),m="";a.value=k.name;b.innerHTML=k.getCount();for(a=0;a<p.length;a++)m+='<option value="'+a+'">'+p[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.graphicsHelper=function(){return{}}();
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,g,h){!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,g.x-a.x,g.y-a.y),d.oriDataCtx.fillStyle="rgba(255,255,0,0.8)",d.oriDataCtx.fillRect(b.x,b.y,h.x-b.x,h.y-b.y))},k=null,p=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,p=d)};this.onDocumentMouseUp=function(a,b,c){null!=k&&null!=p?h(a,k,p):
h(a,b,c);p=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,p,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++)p=a.data[h+m],a.data[h+m]=a.data[k+m],a.data[k+m]=p;return{imageData:a,width:b,height:c}}function b(a,b,c){var e,g,h,k,p,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++)p=a.data[h+m],a.data[h+m]=a.data[k+m],a.data[k+m]=p;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},isAlphabet:function(c,b){return 90<c||65>c?!1:String.fromCharCode(c).toLowerCase()===b}}}();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.sidebar.show("acquireDataSidebar");d();wpd.dataPointCounter.setCount()}function d(){var a=wpd.appData.getPlotData();a.getActiveDataSeries();var b=a.getActiveDataSeriesIndex(),c=document.getElementById("manual-sidebar-dataset-list"),d="",f;for(f=0;f<a.dataSeriesColl.length;f++)d+="<option>"+a.dataSeriesColl[f].name+
"</option>";c.innerHTML=d;c.selectedIndex=b}function f(){wpd.graphicsWidget.setTool(new wpd.AdjustDataPointTool)}return{load:function(){wpd.appData.isAligned()?(a(),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:f,deletePoint:b,clearAll:function(){wpd.appData.getPlotData().getActiveDataSeries().clearAll();
wpd.graphicsWidget.removeTool();wpd.graphicsWidget.resetData();wpd.dataPointCounter.setCount();wpd.graphicsWidget.removeRepainter()},undo:function(){wpd.appData.getPlotData().getActiveDataSeries().removeLastPixel();wpd.graphicsWidget.resetData();wpd.graphicsWidget.forceHandlerRepaint();wpd.dataPointCounter.setCount()},showSidebar:a,switchToolOnKeyPress:function(a){switch(a){case "d":b();break;case "a":c();break;case "s":f()}},updateDatasetControl:d,changeDataset:function(a){a=a.selectedIndex;wpd.appData.getPlotData().setActiveDataSeriesIndex(a);
wpd.graphicsWidget.forceHandlerRepaint();wpd.dataPointCounter.setCount()}}}();
wpd.ManualSelectionTool=function(){return function(){var c=wpd.graphicsWidget.getAllContexts(),b=wpd.appData.getPlotData();this.onAttach=function(){document.getElementById("manual-select-button").classList.add("pressed-button");wpd.graphicsWidget.setRepainter(new wpd.DataPointsRepainter)};this.onMouseClick=function(a,d,f){b.getActiveDataSeries().addPixel(f.x,f.y);c.dataCtx.beginPath();c.dataCtx.fillStyle="rgb(200,0,0)";c.dataCtx.arc(d.x,d.y,3,0,2*Math.PI,!0);c.dataCtx.fill();c.oriDataCtx.beginPath();
c.oriDataCtx.fillStyle="rgb(200,0,0)";c.oriDataCtx.arc(f.x,f.y,3,0,2*Math.PI,!0);c.oriDataCtx.fill();wpd.graphicsWidget.updateZoomOnEvent(a);wpd.dataPointCounter.setCount()};this.onRemove=function(){document.getElementById("manual-select-button").classList.remove("pressed-button")};this.onKeyDown=function(a){var c=b.getActiveDataSeries(),f=c.getCount()-1,e=c.getPixel(f),g=0.5/wpd.graphicsWidget.getZoomRatio();if(wpd.keyCodes.isUp(a.keyCode))e.y-=g;else if(wpd.keyCodes.isDown(a.keyCode))e.y+=g;else if(wpd.keyCodes.isLeft(a.keyCode))e.x-=
g;else if(wpd.keyCodes.isRight(a.keyCode))e.x+=g;else{(wpd.keyCodes.isAlphabet(a.keyCode,"a")||wpd.keyCodes.isAlphabet(a.keyCode,"s")||wpd.keyCodes.isAlphabet(a.keyCode,"d"))&&wpd.acquireData.switchToolOnKeyPress(String.fromCharCode(a.keyCode).toLowerCase());return}c.setPixelAt(f,e.x,e.y);wpd.graphicsWidget.resetData();wpd.graphicsWidget.forceHandlerRepaint();wpd.graphicsWidget.updateZoomToImagePosn(e.x,e.y);a.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.keyCodes.isAlphabet(b.keyCode,"a")||wpd.keyCodes.isAlphabet(b.keyCode,"s")||wpd.keyCodes.isAlphabet(b.keyCode,"d"))&&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.graphicsWidget.getAllContexts(),a=wpd.appData.getPlotData().getActiveDataSeries(),c,f,e,g;for(c=0;c<a.getCount();c++)f=a.getPixel(c),g=0<=a.getSelectedPixels().indexOf(c),e=wpd.graphicsWidget.screenPx(f.x,f.y),b.dataCtx.beginPath(),b.dataCtx.fillStyle=g?"rgb(0,200,0)":"rgb(200,0,0)",b.dataCtx.arc(e.x,e.y,3,0,2*Math.PI,!0),b.dataCtx.fill(),b.oriDataCtx.beginPath(),b.oriDataCtx.fillStyle=g?"rgb(0,200,0)":"rgb(200,0,0)",
b.oriDataCtx.arc(f.x,f.y,3,0,2*Math.PI,!0),b.oriDataCtx.fill()};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)};this.onRemove=function(){wpd.appData.getPlotData().getActiveDataSeries().unselectAll();wpd.graphicsWidget.forceHandlerRepaint();document.getElementById("manual-adjust-button").classList.remove("pressed-button")};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.keyCodes.isAlphabet(c.keyCode,"a")||wpd.keyCodes.isAlphabet(c.keyCode,"s")||wpd.keyCodes.isAlphabet(c.keyCode,"d"))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():0.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 return;b.setPixelAt(a,f,d);wpd.graphicsWidget.forceHandlerRepaint();wpd.graphicsWidget.updateZoomToImagePosn(f,d);c.preventDefault();c.stopPropagation()}}}}}();
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,g,h){!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,g.x-a.x,g.y-a.y),d.oriDataCtx.fillStyle="rgba(255,255,0,0.8)",d.oriDataCtx.fillRect(b.x,b.y,h.x-b.x,h.y-b.y))},k=null,p=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,p=d)};this.onDocumentMouseUp=function(a,b,c){null!=k&&null!=p?h(a,k,p):h(a,b,c);p=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,0.8)";c.dataCtx.lineTo(d.x,d.y);c.dataCtx.stroke();c.oriDataCtx.strokeStyle="rgba(255,255,0,0.8)";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,0.8)",c.dataCtx.lineWidth=a*wpd.graphicsWidget.getZoomRatio(),c.dataCtx.beginPath(),c.dataCtx.moveTo(d.x,d.y),c.oriDataCtx.strokeStyle="rgba(255,255,0,0.8)",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]=200;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.measurementData=function(){var c;return{showAngleData:function(){wpd.popup.show("measurement-data-window");var b=wpd.appData.getPlotData().angleMeasurementData,a=b.connectionCount(),d,f=document.getElementById("measurement-data-table");c="";for(d=0;d<a;d++)c+=d.toString()+", "+b.getAngle(d)+"\n";f.value=c},showDistanceData:function(){wpd.popup.show("measurement-data-window");var b=wpd.appData.getPlotData().distanceMeasurementData,a=b.connectionCount(),d,f=document.getElementById("measurement-data-table"),
e=wpd.appData.getPlotData().axes;c="";for(d=0;d<a;d++)c=!0===wpd.appData.isAligned()&&e instanceof wpd.MapAxes?c+(d.toString()+", "+e.pixelToDataDistance(b.getDistance(d))+"\n"):c+(d.toString()+", "+b.getDistance(d)+"\n");f.value=c},selectAll:function(){var b=document.getElementById("measurement-data-table");b.focus();b.select()},generateCSV:function(){wpd.download.csv(JSON.stringify(c))},close:function(){c="";wpd.popup.close("measurement-data-window")}}}();
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.onMouseClick=
function(k,p,m){if(e){wpd.graphicsWidget.resetHover();g[2*f]=m.x;g[2*f+1]=m.y;f+=1;f===h&&(e=!1,b?d.distanceMeasurementData.addConnection(g):d.angleMeasurementData.addConnection(g),wpd.graphicsWidget.forceHandlerRepaint(),wpd.graphicsWidget.setTool(new wpd.AdjustMeasurementTool(c)));if(1<f){var r=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(r.x,r.y);a.dataCtx.lineTo(p.x,p.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(p.x,p.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())};this.onKeyDown=function(a){}}}();
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.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():0.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,n,u){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(n,u);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){d.dataCtx.font="14px sans-serif";d.dataCtx.fillText(f,parseInt(a,10),parseInt(b,10));d.oriDataCtx.font="14px sans-serif";d.oriDataCtx.fillText(f,parseInt(c,10),parseInt(e,10))};this.painterName="measurementRepainter-"+c;this.onAttach=function(){wpd.graphicsWidget.resetData()};this.onRedraw=
function(){if(b){var c=wpd.appData.getPlotData().distanceMeasurementData,k=c.connectionCount(),p,m,r,l,n,u,q,t,s,v,w=wpd.appData.getPlotData().axes;for(p=0;p<k;p++)m=c.getConnectionAt(p),r=m[0],l=m[1],n=m[2],m=m[3],s=c.isPointSelected(p,0),v=c.isPointSelected(p,1),t=!0===wpd.appData.isAligned()&&w instanceof wpd.MapAxes?"["+p.toString()+"]: "+w.pixelToDataDistance(c.getDistance(p)).toFixed(2)+" "+w.getUnits():"["+p.toString()+"]: "+c.getDistance(p).toFixed(2)+" px",u=wpd.graphicsWidget.screenPx(r,
l),q=wpd.graphicsWidget.screenPx(n,m),f(u.x,u.y,q.x,q.y,r,l,n,m),e(u.x,u.y,r,l,s),e(q.x,q.y,n,m,v),g(0.5*(u.x+q.x),0.5*(u.y+q.y),0.5*(r+n),0.5*(l+m),t)}if(a){var c=wpd.appData.getPlotData().angleMeasurementData,k=c.connectionCount(),y,z,G,K,F;for(p=0;p<k;p++)n=c.getConnectionAt(p),q=n[0],t=n[1],r=n[2],l=n[3],s=n[4],v=n[5],G=c.isPointSelected(p,0),K=c.isPointSelected(p,1),F=c.isPointSelected(p,2),w="["+p.toString()+"]: "+c.getAngle(p).toFixed(2)+"\u00b0",u=Math.atan2(t-l,q-r),m=Math.atan2(v-l,s-r),
y=wpd.graphicsWidget.screenPx(q,t),n=wpd.graphicsWidget.screenPx(r,l),z=wpd.graphicsWidget.screenPx(s,v),f(y.x,y.y,n.x,n.y,q,t,r,l),f(n.x,n.y,z.x,z.y,r,l,s,v),e(y.x,y.y,q,t,G),e(n.x,n.y,r,l,K),e(z.x,z.y,s,v,F),q=n.x,t=n.y,s=r,v=l,d.dataCtx.beginPath(),d.dataCtx.strokeStyle="rgb(0,0,10)",d.dataCtx.arc(q,t,15,u,m,!0),d.dataCtx.stroke(),d.oriDataCtx.beginPath(),d.oriDataCtx.strokeStyle="rgb(0,0,10)",d.oriDataCtx.arc(s,v,15,u,m,!0),d.oriDataCtx.stroke(),g(n.x+10,n.y+15,r+10,l+15,w)}};this.onForcedRedraw=
function(){wpd.graphicsWidget.resetData();this.onRedraw()}}}();wpd=wpd||{};
wpd.download=function(){function c(b,a){var c,f,e;c=document.createElement("div");f=document.createElement("form");e=document.createElement("textarea");f.setAttribute("method","post");"json"===a?f.setAttribute("action","php/json.php"):"csv"===a&&f.setAttribute("action","php/csvexport.php");e.setAttribute("name","data");e.setAttribute("id","data");f.appendChild(e);c.appendChild(f);document.body.appendChild(c);c.style.display="none";e.innerHTML=b;f.submit();document.body.removeChild(c)}return{json:function(b){c(b,
"json")},csv:function(b){c(b,"csv")}}}();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("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,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,5],axesType:null,axesParameters:null,calibration:null,dataSeries:[],distanceMeasurementData:null,angleMeasurementData:null}},
e="",g;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.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(g=a.dataSeriesColl[e],c.wpd.dataSeries[e]={name:g.name,data:[]},b=0;b<g.getCount();b++)c.wpd.dataSeries[e].data[b]=g.getPixel(b);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.")}}}();