Changeset 19929


Ignore:
Timestamp:
01/06/16 12:37:02 (9 years ago)
Author:
dlcheng
Message:

CHG (javascript): Tentative implementation of multiplot rendering. Iproving transparency handling.

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

Legend:

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

    r19912 r19929  
    77//   See also: PLOTMODEL, PLOT_UNIT
    88                       
    9 
    109        //parse options and get a structure of options.
    1110        checkplotoptions(md,options);
    12 
    1311        //get data to be displayed
    1412        data=options.getfieldvalue('data');
    15 
    16         //standard plot: initialize open Gl for each canvas:
     13       
     14        //standard plot: initialize open Gl for each canvas, if needed:
    1715        var canvas = $('<div><canvas id="'+options.getfieldvalue('canvasid')+'" width="'+options.getfieldvalue('canvassize',480)+'" height="'+options.getfieldvalue('canvassize',480)+'"></canvas></div>)')
    1816        canvas.css({'height':String(options.getfieldvalue('canvassize',480)+'px')});
     
    2119        }
    2220        canvas=document.getElementById(options.getfieldvalue('canvasid'));
    23 
    24         // Initialize the GL context:
    25         var gl=initWebGL(canvas,options);
    26         if(!gl){
    27                 throw Error("plotmodel error message: could not initialize open Gl!");
    28         }
    29        
    30         //Initialize the buffer structure:
    31         var nodes = {};
    32         nodes["main"] = Node(gl,options);
    33        
     21        //Initialize the buffer structure when first data is drawn to mesh:
     22        var requestDrawing = false;
     23        var gl = canvas.gl;
     24        if (!canvas.hasOwnProperty("nodes")) {
     25                canvas.nodes = {};
     26                canvas.datalength = 0;
     27                requestDrawing = true;
     28                //Initialize the GL context:
     29                gl = initWebGL(canvas,options);
     30                if (!gl) {
     31                        throw Error("plotmodel error message: could not initialize open Gl!");
     32                }
     33                canvas.gl = gl;
     34        }
     35        canvas.nodes["data"+String(++canvas.datalength)] = Node(gl,options);
     36
    3437        //figure out if this is a special plot
    3538        if (typeof data === 'string'){
     
    189192        //Figure out if this is a semi-transparent plot.
    190193        if (options.getfieldvalue('overlay','off')=='on'){
    191                 nodes["overlay"] = Node(gl,options);
    192                 plot_overlay(md,data,options,canvas,gl,nodes["overlay"]);
     194                canvas.nodes["overlay"] = Node(gl,options);
     195                plot_overlay(md,data,options,canvas,gl,canvas.nodes["overlay"]);
    193196        }
    194197
     
    219222        if (typeof data !== 'string'){
    220223                //plot unit
    221                 plot_unit(md,data,options,canvas,gl,nodes["main"]);
    222         }
    223 
    224         //applyoptions(md,data2,options);
    225         applyoptions(md,data,options,canvas,gl,nodes["main"]);
     224                plot_unit(md,data,options,canvas,gl,canvas.nodes["data"+String(canvas.datalength)]);
     225        }
     226
     227        applyoptions(md,data,options,canvas,gl,canvas.nodes["data"+String(canvas.datalength)]);
    226228       
    227         /*Draw into the canvas:*/
    228         draw(gl,options,canvas,nodes);
     229        //Draw into the canvas if needed:
     230        if (requestDrawing)     draw(gl,options,canvas,canvas.nodes);
     231        console.log(canvas.nodes);
    229232}
  • issm/trunk-jpl/src/m/plot/plot_overlay.js

    r19927 r19929  
    5252        node["modelMatrix"] = recalculateModelMatrix(node);
    5353        node["texture"] = initTexture(gl,options.getfieldvalue('image'));
    54         node["alpha"] = options.getfieldvalue('alpha',.5);
     54        node["alpha"] = options.getfieldvalue('outeralpha',.9);
    5555        node["overlay"] = false;
    5656        node["drawOrder"] = 1;
  • issm/trunk-jpl/src/m/plot/plot_unit.js

    r19927 r19929  
    5858        node["translation"] = [(xmin + xmax) / (-2 / scale), (ymin + ymax) / (-2 / scale), (zmax) / (-1 / scale)];
    5959        node["modelMatrix"] = recalculateModelMatrix(node);
    60         node["alpha"] = options.getfieldvalue('alpha',1.0);
     60        node["alpha"] = options.getfieldvalue('alpha',.6);
    6161        node["overlay"] = options.getfieldvalue('overlay','off') == 'on';
    6262        node["drawOrder"] = 0;
  • issm/trunk-jpl/src/m/plot/plotmodel.js

    r19741 r19929  
    3434        //go through subplots
    3535        if (numberofplots){
    36 
     36                //Clear all canvas nodes
     37                for (var i=0;i<numberofplots;i++){
     38                        var canvas=document.getElementById(options.list[i].getfieldvalue('canvasid'));
     39                        if (canvas && canvas.nodes) {
     40                                delete canvas.nodes;
     41                        }
     42                }
    3743                //Go through all data plottable and close window if an error occurs
    3844                for (var i=0;i<numberofplots;i++){
    39 
    4045                        plot_manager(options.list[i].getfieldvalue('model',md),options.list[i],subplotwidth,nlines,ncols,i);
    4146
  • issm/trunk-jpl/src/m/plot/webgl.js

    r19923 r19929  
    423423                gl.uniform1i(node["shader"]["uColorSampler"], 0);       
    424424        }
    425         if (node["overlay"] == true) {
    426                 gl.blendFunc(gl.SRC_ALPHA, gl.ONE);
    427         }
    428         else {
    429                 gl.blendFunc (gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
    430         }
     425        //if (node["overlay"] == true) {
     426        //      gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
     427        //}
     428        //else {
     429        //      gl.blendFunc (gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
     430        //}
     431        gl.blendFunc (gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
    431432        if  (node["useIndexBuffer"] == true) {
    432433                gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, node["buffers"][node["buffers"].length - 1]);
Note: See TracChangeset for help on using the changeset viewer.