Changeset 20586
- Timestamp:
- 04/30/16 23:09:24 (9 years ago)
- Location:
- issm/trunk-jpl/src/m/plot
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified issm/trunk-jpl/src/m/plot/applyoptions.js ¶
r20579 r20586 35 35 var precision=options.getfieldvalue('colorbarprecision',3); 36 36 37 if (options.getfieldvalue('log', 10)!='off') {37 if (options.getfieldvalue('log','off')!='off') { 38 38 for (var i = cdivisions; i >= 0; i--) { 39 var scale = Math.log(caxis[1])-Math.log(caxis[0]);40 labels[i] = (Math. exp(Math.log(caxis[0])+scale*(cdivisions-i)/cdivisions)).toPrecision(precision);39 var scale = (Math.log10(caxis[1])-Math.log10(caxis[0]))/Math.log10(options.getfieldvalue('log',10)); 40 labels[i] = (Math.pow(options.getfieldvalue('log',10),Math.log10(caxis[0])/Math.log10(options.getfieldvalue('log',10))+scale*(cdivisions-i)/cdivisions)).toPrecision(precision); 41 41 } 42 42 } else { … … 212 212 var cmap = options.getfieldvalue('cmap','jet'); 213 213 var colorbar = colorbars[cmap]; 214 if (options.getfieldvalue('log',10)!='off') { 215 for (var i = 0; i < colorbar.length; i++) { 216 color = colorbar[colorbar.length-i-1]; 217 color = [Math.round(color[0]*255),Math.round(color[1]*255),Math.round(color[2]*255)]; 218 tgradient.addColorStop(1.0-Math.exp(Math.log((colorbar.length-i)/colorbar.length)/Math.log(options.getfieldvalue('log',10))*i/colorbar.length),'rgba('+color.toString()+',1.0)'); 219 } 220 } else { 221 for (var i = 0; i < colorbar.length; i++) { 222 color = colorbar[colorbar.length-i-1]; 223 color = [Math.round(color[0]*255),Math.round(color[1]*255),Math.round(color[2]*255)]; 224 tgradient.addColorStop(i/colorbar.length,'rgba('+color.toString()+',1.0)'); 225 } 214 for (var i = 0; i < colorbar.length; i++) { 215 color = colorbar[colorbar.length-i-1]; 216 color = [Math.round(color[0]*255),Math.round(color[1]*255),Math.round(color[2]*255)]; 217 tgradient.addColorStop(i/colorbar.length,'rgba('+color.toString()+',1.0)'); 226 218 } 227 219 -
TabularUnified issm/trunk-jpl/src/m/plot/plot_manager.js ¶
r20584 r20586 78 78 return; 79 79 case 'mesh': 80 plot_mesh(md,options,canvas ,gl,canvas.nodes["data"+String(canvas.datalength)]);80 plot_mesh(md,options,canvas); 81 81 return; 82 82 case 'none': … … 125 125 return; 126 126 case 'quiver': 127 plot_quiver(md,options,canvas ,gl,canvas.nodes["data"+String(canvas.datalength)]);127 plot_quiver(md,options,canvas); 128 128 return; 129 129 case 'strainrate_tensor': … … 171 171 //Figure out if this is a semi-transparent plot. 172 172 if (options.getfieldvalue('overlay','off')=='on'){ 173 canvas.nodes["overlay"] = Node(gl,options); 174 plot_overlay(md,data,options,canvas,gl,canvas.nodes["overlay"]); 173 plot_overlay(md,data,options,canvas); 175 174 } 176 175 … … 204 203 205 204 //plot unit 206 plot_unit(md,data2,datatype,options,canvas ,gl,canvas.nodes["data"+String(canvas.datalength)]);207 208 applyoptions(md,data2,datatype,options,canvas,gl,canvas.nodes[ "data"+String(canvas.datalength)]);205 plot_unit(md,data2,datatype,options,canvas); 206 207 applyoptions(md,data2,datatype,options,canvas,gl,canvas.nodes[canvas.nodes.length-1]); 209 208 } -
TabularUnified issm/trunk-jpl/src/m/plot/plot_mesh.js ¶
r20585 r20586 1 function plot_mesh(md,options,canvas ,gl,node) {1 function plot_mesh(md,options,canvas) { 2 2 // Usage: 3 // plot_mesh(md,options,canvas ,gl);3 // plot_mesh(md,options,canvas); 4 4 // 5 5 // See also: PLOTMODEL … … 56 56 57 57 //Compute gl variables: 58 var scale = 1 / (xmax - xmin); 58 var gl = canvas.gl; 59 var node = Node(gl,options); 60 canvas.nodes[canvas.nodes.length] = node; 61 scale = 1 / (xmax - xmin); 59 62 node["shaderName"] = "colored"; 60 63 node["shader"] = gl["shaders"][node["shaderName"]]["program"]; -
TabularUnified issm/trunk-jpl/src/m/plot/plot_overlay.js ¶
r20584 r20586 1 function plot_overlay(md,data,options,canvas ,gl,node){1 function plot_overlay(md,data,options,canvas){ 2 2 //PLOT_OVERLAY - Function for plotting a georeferenced image. 3 3 //This function is called from within the plotmodel code. 4 4 // 5 5 // Usage: 6 // plot_overlay(md,data,options,canvas ,gl,node);6 // plot_overlay(md,data,options,canvas); 7 7 // 8 8 // See also: PLOTMODEL, PLOT_MANAGER … … 59 59 60 60 //Compute gl variables: 61 var gl = canvas.gl; 62 var node = Node(gl,options); 63 canvas.nodes[canvas.nodes.length] = node; 61 64 scale = 1 / (xmax - xmin); 62 65 node["shaderName"] = "unlit_textured"; -
TabularUnified issm/trunk-jpl/src/m/plot/plot_quiver.js ¶
r20585 r20586 1 function plot_quiver(md,options,canvas ,gl,node) {1 function plot_quiver(md,options,canvas) { 2 2 //PLOT_QUIVER - quiver plot with colors 3 3 // 4 4 // Usage: 5 // plot_quiver(md,options,canvas ,gl,node)5 // plot_quiver(md,options,canvas) 6 6 // 7 7 … … 59 59 60 60 //Compute gl variables: 61 var scale = 1 / (xmax - xmin); 61 var gl = canvas.gl; 62 var node = Node(gl,options); 63 canvas.nodes[canvas.nodes.length] = node; 64 scale = 1 / (xmax - xmin); 62 65 node["shaderName"] = "colored"; 63 66 node["shader"] = gl["shaders"][node["shaderName"]]["program"]; -
TabularUnified issm/trunk-jpl/src/m/plot/plot_unit.js ¶
r20585 r20586 1 function plot_unit(md,data,datatype,options,canvas ,gl,node) {1 function plot_unit(md,data,datatype,options,canvas) { 2 2 //PLOT_UNIT - unit plot, display data 3 3 // 4 4 // Usage: 5 // plot_unit(md,data,options,canvas ,gl);5 // plot_unit(md,data,options,canvas); 6 6 // 7 7 // See also: PLOTMODEL, PLOT_MANAGER … … 60 60 61 61 //Compute gl variables: 62 var gl = canvas.gl; 63 var node = Node(gl,options); 64 canvas.nodes[canvas.nodes.length] = node; 62 65 scale = 1 / (xmax - xmin); 63 66 node["shaderName"] = "unlit_textured"; … … 235 238 236 239 //Initialize movie loop 237 node["movieInterval"] = 1000 / options.getfieldvalue('moviefps',5);240 node["movieInterval"] = 1000 / canvas.moviefps; 238 241 node["movieTimestamps"] = timestamps; 239 242 node["movieLength"] = timestamps.length; -
TabularUnified issm/trunk-jpl/src/m/plot/webgl.js ¶
r20585 r20586 11 11 if (!canvas.initialized) { 12 12 canvas.gl = initWebGL(canvas,options); 13 canvas.nodes = {}; 14 canvas.datalength = 0; 13 canvas.nodes = []; 15 14 if (canvas.drawHandler) window.cancelAnimationFrame(canvas.drawHandler); 16 15 draw(canvas,options); 17 16 canvas.initialized = true; 18 17 } 19 canvas.nodes["data"+String(++canvas.datalength)] = Node(canvas.gl,options);20 18 return canvas; 21 19 } … … 67 65 canvas.movieReverse = false; 68 66 canvas.movieIncrement = true; 67 canvas.moviefps = options.getfieldvalue('moviefps',5); 69 68 70 69 if (canvas.twod) { … … 76 75 77 76 // Add event listeners for canvas 78 canvas.addEventListener("mousewheel", function (ev) {onZoom(ev,canvas,options.getfieldvalue('displayzoom','off') == 'on')}, false); 79 canvas.addEventListener("DOMMouseScroll", function (ev) {onZoom(ev,canvas,options.getfieldvalue('displayzoom','off') == 'on')}, false); 80 77 var displayview = options.getfieldvalue('displayview','off') == 'on'; 78 var displayzoom = options.getfieldvalue('displayzoom','off') == 'on'; 81 79 var mc = new Hammer.Manager(canvas); 82 80 83 81 mc.add(new Hammer.Pan({threshold:0, pointers:0})); 84 82 mc.add(new Hammer.Pinch({threshold:0})).recognizeWith(mc.get('pan')); 85 86 mc.on("panstart panmove", function (ev) {onPan(ev,canvas,options.getfieldvalue('displayview','off') == 'on');}); 87 mc.on("pinchstart pinchmove", function (ev) {onPinch(ev,canvas,options.getfieldvalue('displayview','off') == 'on');}); 83 mc.on("panstart panmove", function (ev) {onPan(ev,canvas,displayview);}); 84 mc.on("pinchstart pinchmove", function (ev) {onPinch(ev,canvas,displayview);}); 88 85 //mc.on("mousewheel DOMMouseScroll", function (ev) {onZoom(ev,canvas,options);}); 86 87 canvas.addEventListener("mousewheel", function (ev) {onZoom(ev,canvas,displayzoom)}, false); 88 canvas.addEventListener("DOMMouseScroll", function (ev) {onZoom(ev,canvas,displayzoom)}, false); 89 89 90 90 return gl; … … 371 371 canvas.lastDeltaY = ev.deltaY; 372 372 373 if (displaylog) console.log(canvas. translation);373 if (displaylog) console.log(canvas.rotation); 374 374 } //}}} 375 375 function onPinch(ev,canvas,displaylog) { //{{{
Note:
See TracChangeset
for help on using the changeset viewer.