Changeset 20769


Ignore:
Timestamp:
06/17/16 21:43:07 (9 years ago)
Author:
dlcheng
Message:

CHG (javascript): js api standardidation and changes (initialzoom/zoom, cmap/colormap, image/overlay_image, colorbarcanvasid/colorbarid, azimuthbounds/azlim, elevationbounds/azlim, zoombounds/zoomlim) . Full js plot documentation. Implementing linewidth and scaling options for quiver plots.

Location:
issm/trunk-jpl/src/m/plot
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/plot/applyoptions.js

    r20748 r20769  
    4141                        //Handle orientation {{{
    4242                        if (colorbarorientiation=='vertical') { //{{{
    43                                 ccanvasid = options.getfieldvalue('colorbarcanvasid',options.getfieldvalue('canvasid')+'_colorbar');
     43                                ccanvasid = options.getfieldvalue('colorbarid',options.getfieldvalue('canvasid')+'_colorbar');
    4444                                ccanvashtml = document.getElementById(ccanvasid);
    4545                                cwidth = ccanvashtml.width*cwidthscale*options.getfieldvalue('colorbarwidth',1);
     
    5151
    5252                                var cgradient = ccontext.createLinearGradient(0,cheightoffset/2,0,cheight);
    53                                 var cmap = options.getfieldvalue('cmap','jet');
     53                                var cmap = options.getfieldvalue('colormap','jet');
    5454                                var colorbar = colorbars[cmap];
    5555                                for (var i=0; i < colorbar.length; i++) {
     
    9191                        } //}}}
    9292                        else { //colorbarorientiation=='horizontal' {{{
    93                                 ccanvasid = options.getfieldvalue('colorbarcanvasid',options.getfieldvalue('canvasid')+'_colorbar');
     93                                ccanvasid = options.getfieldvalue('colorbarid',options.getfieldvalue('canvasid')+'_colorbar');
    9494                                ccanvashtml = document.getElementById(ccanvasid);
    9595                                cwidth = ccanvashtml.width*0.7*options.getfieldvalue('colorbarwidth',1);
     
    101101
    102102                                var cgradient = ccontext.createLinearGradient(cwidth+cwidthoffset,0,cwidthoffset,0);           
    103                                 var cmap = options.getfieldvalue('cmap','jet');
     103                                var cmap = options.getfieldvalue('colormap','jet');
    104104                                var colorbar = colorbars[cmap];
    105105                                for (var i=0; i < colorbar.length; i++) {
     
    159159        tgradient = tcontext.createLinearGradient(0,0,0,256);
    160160               
    161         var cmap = options.getfieldvalue('cmap','jet');
     161        var cmap = options.getfieldvalue('colormap','jet');
    162162        var colorbar = colorbars[cmap];
    163163        for (var i=0; i < colorbar.length; i++) {
  • issm/trunk-jpl/src/m/plot/plot_mesh.js

    r20748 r20769  
    6464        node["shaderName"] = "colored";
    6565        node["shader"] = gl["shaders"][node["shaderName"]]["program"];
     66        node["lineWidth"] = options.getfieldvalue('linewidth',1);
    6667        node["scale"] = [scale, scale, scale * matrixscale];
    6768        node["translation"] = [(xmin + xmax) / (-2 / scale), (ymin + ymax) / (-2 / scale), (zmin + zmax) / (2 / scale)];
     
    7778
    7879        //retrieve some options
    79         var linewidth=options.getfieldvalue('linewidth',1);
    80         var edgecolor=new RGBColor(options.getfieldvalue('edgecolor','black'));
     80        var edgecolor = new RGBColor(options.getfieldvalue('edgecolor','black'));
    8181        if (edgecolor.ok) edgecolor = [edgecolor.r/255.0, edgecolor.g/255.0, edgecolor.b/255.0, 1.0];
    8282        else throw Error(sprintf("s%s%s\n","initWebGL error message: cound not find out edgecolor color for curent canvas ",canvas));
  • issm/trunk-jpl/src/m/plot/plot_overlay.js

    r20748 r20769  
    6767        node["translation"] = [(xmin + xmax) / (-2 / scale), (ymin + ymax) / (-2 / scale), (zmin + zmax) / (2 / scale)];
    6868        node["modelMatrix"] = recalculateModelMatrix(node);
    69         node["texture"] = initTexture(gl,options.getfieldvalue('image'));
     69        node["texture"] = initTexture(gl,options.getfieldvalue('overlay_image'));
    7070        node["alpha"] = options.getfieldvalue('outeralpha',1.0);
    7171        node["drawOrder"] = 1;
  • issm/trunk-jpl/src/m/plot/plot_quiver.js

    r20748 r20769  
    6666        node["shaderName"] = "colored";
    6767        node["shader"] = gl["shaders"][node["shaderName"]]["program"];
     68        node["lineWidth"] = options.getfieldvalue('linewidth',1);
    6869        node["scale"] = [scale, scale, scale * matrixscale];
    6970        node["translation"] = [(xmin + xmax) / (-2 / scale), (ymin + ymax) / (-2 / scale), (zmin + zmax) / (2 / scale)];
     
    8081
    8182        //retrieve some options
    82         var linewidth=options.getfieldvalue('linewidth',1);
    83        
    8483        var edgecolor=new RGBColor(options.getfieldvalue('edgecolor','black'));
    8584        if (edgecolor.ok) edgecolor = [edgecolor.r/255.0, edgecolor.g/255.0, edgecolor.b/255.0, 1.0];
     
    9897                var magnitude;
    9998                var color = edgecolor;
     99                var scaling = options.getfieldvalue('scaling',1);
    100100                for(var i = 0; i < x.length; i++){
    101101                        //Check for NaN values and remove from indices array as necessary, but preserve vertex array spacing
     
    111111                       
    112112                        xyz2 = vec3.fromValues(vx[i], vy[i], 0.0);
    113                         magnitude = 1000.0; //mesh resolution
     113                        magnitude = 1000.0*scaling; //mesh resolution
    114114                        vec3.normalize(direction, xyz2);
    115115                        vec3.scale(direction, direction, magnitude);
  • issm/trunk-jpl/src/m/plot/plotdoc.js

    r20766 r20769  
    77        //TODO: Standardize image to overlay_image, heightscale to scaling, colorbarfontsize/color, clarify innermask/outermask, edgecolor implementation, check colormap,
    88
    9         console.log(' WARNING: documentation may not reflect entire implementation as of June 16 2016');
     9        console.log(' WARNING: starred methods (*) are experimental and not guarenteed to be stable');
    1010        console.log('   Plot usage: plotmodel(model,varargin)');
    1111        console.log('   Options: ');
     
    1616        console.log('                  - "mesh": draw mesh using trisurf');
    1717        console.log('                  - "quiver": quiver plot');
    18         console.log('       "caxis": modify  colorbar range. (array of type [a b] where b>=a)');
    19         console.log('       "backgroundcolor": plot background color. (default is "w")');
    20         console.log('       "colorbar": add colorbar (string "on" or "off")');
    21         console.log('       "colorbartitle": colorbar title (string)');
     18        console.log('       "caxis": modify  colorbar range. (array of type [a, b] where b>=a)');
     19        console.log('       "backgroundcolor": plot background color. (default "lightcyan", ex: "green","blue")');
     20        console.log('       "colorbar": add colorbar (default "off", ex: "on", "off")');
     21        console.log('       "colorbarid": colorbar canvas id (string)');
     22        console.log('       "colorbartitle": colorbar title (string)');
     23        console.log('       "colorbarnticks": number of colorbar ticks (default 6, ex: 2, 10)');       
     24        console.log('       "colorbarprecision": colorbar label digit precision (default 3, ex: 1, 4)');       
     25        console.log('       "colorbarorientation": oreintation of colorbar (default "vertical", ex: "horizontal")');
     26        console.log('       "colorbarfontsize": specify colorbar font size (default 1, ex: 14, 22)');
     27        console.log('       "colorbarfontcolor": specify colorbar font color (default "black", ex: "green","blue")');
    2228        console.log('       "colorbarwidth": multiplier (default 1) to the default width colorbar');
    2329        console.log('       "colorbarheight": multiplier (default 1) to the default height colorbar');
    24         console.log('       "colormap": same as standard matlab option ("jet","hsv","cool","spring","gray","Ala","Rignot",...)');
    25         console.log('       "edgecolor": same as standard matlab option EdgeColor (color name: "black" or RGB array: [0.5 0.2 0.8])');
    26         console.log('       "view": same as standard matlab option (ex: 2, 3 or [90 180]');
    27         console.log('       "xlim": same as standard matlab option (ex: [0 500])');
    28         console.log('       "ylim": same as standard matlab option');
    29         console.log('       "zlim": same as standard matlab option');
    30         console.log('       "xlabel": same as standard matlab option (ex:"km")');
    31         console.log('       "overlay": yes or no. This will overlay a radar amplitude image behind');
    32         console.log('       "overlay_image": path to overlay image. provide overlay_xlim, overlay_ylim, overlay_xposting and overlay_yposting options also');
    33         console.log('       "alpha": transparency coefficient (the higher, the more transparent). Default is 1.5');
    34         console.log('       "scaling": scaling factor used by quiver plots. Default is 0.4');
    35         console.log('       "linewidth": line width for expconsole.log plot (use a cell of strings if more than one)');
     30        console.log('       "colormap": same as standard matlab option (default "jet", ex: "hsv","cool","spring","gray","Ala","Rignot",...)');
     31        console.log('       "edgecolor": same as standard matlab option EdgeColor (default "black", ex: color name: "blue" or RGB array: [0.5, 0.2, 0.8])');
     32        console.log('       "view": initial azimuth and elevation angles for camera (default [0,90], ex: [90, 180]');
     33        console.log('       "zoom": initial camera zoom as a percentage of default (default 1, ex: 1.5, 0.01)');
     34        console.log('       "centeroffset": initial camera offset from model center (default [0,0,0.0], ex: [-2, 1.5, 0.01])');
     35        console.log('       "xlim": x coordinates to fit inside camera (ex: [0, 500])');
     36        console.log('       "ylim": y coordinates to fit inside camera (ex: [0, 500])');
     37        console.log('       "zlim": z coordinates to fit inside camera (ex: [0, 500])');
     38        console.log('       "azlim": azimuth view limits (ex: [0, 180])');
     39        console.log('       "ellim": elevation view limits (ex: [-90, 90])');
     40        console.log('       "zoomlim": zoom view limits (ex: [0.05, 10])');
     41        console.log('       "displayview": print view value to console');
     42        console.log('       "displayzoom": print zoom value to console');
     43        console.log('       "controlsensitivity": sensitivty of view/zoom changes as a percentage of default (default 1, ex: 0.5, 2.75)');
     44        console.log('       "2d": renders orthographic camera with view set to [0, 90] (default "off", ex: "on", "off")');
     45        console.log('       "moviefps": frames per second when displaying transient runs (default 5, ex: 1, 10)');
     46        console.log('       "overlay": overlay a radar amplitude image behind (default "off", ex: "on", "off")');
     47        console.log('       "overlay_image": path to overlay image (default "off", ex: "on", "off")');
     48        console.log('       "alpha": transparency coefficient 0.0 to 1.0, the lower, the more transparent. (default 1.0, ex: 0.5, 0.25)');
     49        console.log('       "heightscale": scaling factor to accentuate height. (default 1, ex: 0.5, 100)');
     50        console.log('       "scaling*": scaling factor used by quiver plots. Default is 0.4');
     51        console.log('       "linewidth*": line width for mesh, quiver, and contour plots, currently limited by WebGL to 1. (default 1, ex: 2, 5)');
     52        console.log('       "cloud*": plot a cloud of points, given a flat array of 3d coordinates (ex: [0.0, 0.0, 0.0, 1.0, 1.0, 1.0])');
     53        console.log('       "expdisp*": plot exp file on top of a data plot. provide exp file as an argument (use a cell of strings if more than one)');
     54        console.log('       "textlabels*": plot text labels rendered in 3d space, using an array of text/coordinate pairs (ex: [{"pos":[0.0,0.0,0.0],"text":"origin"}])');
     55        console.log('       "outermask*": Special mask that colors all parts of a overlay mesh below a height a certain color. provide outermaskheight and outermaskcolor options also (default "off", ex: "on", "off")');
     56        console.log('       "innermask*": Special mask that colors all parts of a data mesh below a height a certain color. provide innermaskheight and innermaskcolor options also (default "off", ex: "on", "off")');
    3657        console.log('       "mask": list of flags of size numberofnodes or numberofelements. Only "true" values are plotted ');
    3758        console.log('       "log": value of log');
  • issm/trunk-jpl/src/m/plot/webgl.js

    r20586 r20769  
    44        //Initialize open Gl for each canvas, if needed:
    55        var canvas=document.getElementById(options.getfieldvalue('canvasid'));
    6         if (!canvas) {
    7                 canvas = $('<div><canvas id="'+options.getfieldvalue('canvasid')+'" width="'+options.getfieldvalue('canvassize',480)+'" height="'+options.getfieldvalue('canvassize',480)+'"></canvas></div>)')
    8                 canvas.css({'height':String(options.getfieldvalue('canvassize',480)+'px')});
    9                 canvas.appendTo('body');
    10         }
    116        if (!canvas.initialized) {
    127                canvas.gl = initWebGL(canvas,options);
     
    5146        //TODO:Group variables in objects for organization and naming
    5247        canvas.gl = gl;
    53         canvas.zoomBounds = options.getfieldvalue('zoombounds',[0.001,100.0]);
    54         canvas.zoomFactor = clamp(options.getfieldvalue('zoomfactor',1.0), canvas.zoomBounds[0], canvas.zoomBounds[1]);
     48        canvas.zoomBounds = options.getfieldvalue('zoomlim',[0.001,100.0]);
     49        canvas.zoomFactor = clamp(options.getfieldvalue('zoom',1.0), canvas.zoomBounds[0], canvas.zoomBounds[1]);
    5550        canvas.zoomLast = canvas.zoomFactor;
    5651        canvas.cameraMatrix = mat4.create();
    5752        canvas.translation = options.getfieldvalue('centeroffset',[0,0,0.0]);
    58         canvas.rotationAzimuthBounds = options.getfieldvalue('azimuthbounds',[0,360]);
    59         canvas.rotationElevationBounds = options.getfieldvalue('elevationbounds',[-180,180]);
     53        canvas.rotationAzimuthBounds = options.getfieldvalue('azlim',[0,360]);
     54        canvas.rotationElevationBounds = options.getfieldvalue('ellim',[-180,180]);
    6055        canvas.rotationDefault = options.getfieldvalue('view',[0,90]); //0 azimuth - up is north, 90 elevation - looking straight down
    6156        canvas.rotation = canvas.rotationDefault;
     
    141136                useIndexBuffer:true,
    142137                alpha:1.0,
     138                lineWidth:1.0,
    143139                disableDepthTest:false,
    144140                enableCullFace:false,
     
    454450                gl.disable(gl.DEPTH_TEST);
    455451        }
     452        gl.lineWidth(node["lineWidth"]);
    456453        gl.blendFunc (gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
    457454        if  (node["useIndexBuffer"] == true) {
Note: See TracChangeset for help on using the changeset viewer.