Changeset 19867


Ignore:
Timestamp:
12/08/15 20:31:56 (9 years ago)
Author:
dlcheng
Message:

CHG (JAVASCRIPT): Implementing xlim, ylim options for js plot display.

File:
1 edited

Legend:

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

    r19864 r19867  
    1717       
    1818        //Process data and model
    19         var x = md.mesh.x;
    20         var y = md.mesh.y;
    21         var z = [0.0];
    22         var elements = md.mesh.elements;
     19        var meshresults = processmesh(md,data,options);
     20        var x = meshresults[0];
     21        var y = meshresults[1];
     22        var z = meshresults[2];
     23        var elements = meshresults[3];
     24        var is2d = meshresults[4];
     25        var isplanet = meshresults[5];
    2326        //}}}
    2427
    2528        //Compute coordinates and data range:
    26         xlim=options.getfieldvalue('xlim',[ArrayMin(x),ArrayMax(x)]);
    27         ylim=options.getfieldvalue('ylim',[ArrayMin(y),ArrayMax(y)]);
     29        var modelxlim = [ArrayMin(x),ArrayMax(x)];
     30        var modelylim = [ArrayMin(y),ArrayMax(y)];
     31        var modelzlim = [ArrayMin(z),ArrayMax(z)];
     32        var xlim = options.getfieldvalue('xlim',modelxlim);
     33        var ylim = options.getfieldvalue('ylim',modelylim);
     34        var zlim = options.getfieldvalue('zlim',modelzlim);
    2835        xmin = xlim[0];
    2936        xmax = xlim[1];
    3037        ymin = ylim[0];
    3138        ymax = ylim[1];
    32         zmin = ArrayMin(z);
    33         zmax = ArrayMax(z);
     39        zmin = zlim[0];
     40        zmax = zlim[1];
    3441       
    3542        //Compute scaling:
     
    3744        node["scale"] = [scale, scale, scale];
    3845        node["rotation"] = options.getfieldvalue('view',[0,0,0]);
    39         node["translation"] = [(xmin + xmax) / (-2 / scale), (ymin + ymax) / (-2 / scale), (zmin + zmax) / (-2 / scale)];
     46        node["translation"] = [(modelxlim[0] + modelxlim[1]) / (-2 / scale), (modelylim[0] + modelylim[1]) / (-2 / scale), (modelzlim[0] + modelzlim[1]) / (-2 / scale)];
    4047        node["modelMatrix"] = recalculateModelMatrix(node);
    41         node["texture"] = initTexture(gl,options.getfieldvalue('image','images/checker.gif'));
     48        node["texture"] = initTexture(gl,options.getfieldvalue('image','images/penguin.png'));
    4249        node["alpha"] = options.getfieldvalue('alpha',1.0);
    4350        node["overlay"] = true;
     
    4956        var xrange = xmax - xmin;
    5057        var yrange = ymax - ymin;
     58
     59        //redefine overlay as square plane
     60        x = [xmin, xmax, xmin, xmax];
     61        y = [ymin, ymin, ymax, ymax];
     62        z = [zmin, zmin, zmin, zmin];
     63        elements = [[1,2,3],[2,4,3]];
    5164       
    5265        //generate mesh:
     
    5467                vertices[vertices.length] = x[i];
    5568                vertices[vertices.length] = y[i];
    56                 vertices[vertices.length] = 0.0;
     69                vertices[vertices.length] = z[i];
    5770
    5871                texcoords[texcoords.length] = (x[i] - xmin) / xrange;
Note: See TracChangeset for help on using the changeset viewer.