Index: /issm/trunk-jpl/src/m/plot/applyoptions.js
===================================================================
--- /issm/trunk-jpl/src/m/plot/applyoptions.js	(revision 19964)
+++ /issm/trunk-jpl/src/m/plot/applyoptions.js	(revision 19965)
@@ -6,136 +6,9 @@
 	//
 	//   See also: PLOTMODEL, PARSE_OPTIONS
-	/* //{{{
-	//fontsize
-	fontsize=options.getfieldvalue('fontsize',14);
-
-	//fontweight
-	fontweight=options.getfieldvalue('fontweight','normal');
-
-	//title
-	if exist(options,'title')
-		titlevalue=options.getfieldvalue('title');
-		if iscell(titlevalue),
-			title(titlevalue,'FontSize',fontsize,'FontWeight',fontweight);
-		else
-			if ~isnan(titlevalue),
-				title(titlevalue,'FontSize',fontsize,'FontWeight',fontweight);
-			end
-		end
-	end
-
-	//xlabel, ylabel and zlabel
-	if exist(options,'xlabel');
-		xlabel(options.getfieldvalue('xlabel'),'FontSize',fontsize,'FontWeight',fontweight);
-	end
-	if exist(options,'ylabel');
-		ylabel(options.getfieldvalue('ylabel'),'FontSize',fontsize,'FontWeight',fontweight);
-	end
-	if exist(options,'zlabel');
-		zlabel(options.getfieldvalue('zlabel'),'FontSize',fontsize,'FontWeight',fontweight);
-	end
-
-	//xticks, yticks and zticks
-	if exist(options,'xtick'), set(gca,'XTick',options.getfieldvalue('xtick')); end
-	if exist(options,'ytick'), set(gca,'YTick',options.getfieldvalue('ytick')); end
-	if exist(options,'ztick'), set(gca,'ZTick',options.getfieldvalue('ztick')); end
-
-	//view 
-	if dimension(md.mesh)==3 & ~exist(options,'layer'),
-		view(options.getfieldvalue('view',3));
-	else
-		view(options.getfieldvalue('view',2));
-	end
-
-	//axis
-	set(gca,'FontSize',options.getfieldvalue('axisfontsize',fontsize));;
-	if exist(options,'axis')
-		eval(['axis ' options.getfieldvalue('axis')]);
-	else
-		if strcmp(domaintype(md.mesh),'3D'),
-			if ~exist(options,'layer'),
-				axis auto tight
-			else
-				axis tight equal
-			end
-		elseif strcmp(domaintype(md.mesh),'2Dvertical'),
-			axis auto tight
-		elseif strcmp(domaintype(md.mesh),'3Dsurface'),
-			axis auto tight
-
-		elseif strcmp(domaintype(md.mesh),'2Dhorizontal'),
-			axis tight equal;
-		else
-			error('type of domain not supported');
-		end
-	end
-
-	//box
-	if exist(options,'box')
-		eval(['box ' options.getfieldvalue('box')]);
-	end
-
-	//xlim, ylim and zlim
-	if exist(options,'xlim');
-		xlim(options.getfieldvalue('xlim'));
-	end
-	if exist(options,'ylim');
-		ylim(options.getfieldvalue('ylim'));
-	end
-	if exist(options,'zlim');
-		zlim(options.getfieldvalue('zlim'));
-	end
-
-	//latlon
-	//Must be done here (before xlim and ylim??) so that it uses the same xlim and ylim as plot_overlay
-	//these are changed by axis that follows
-	if ~strcmpi(options.getfieldvalue('latlon','off'),'off')
-		latlonoverlay(md,options);
-	end
-
-	//Basinzoom
-	if exist(options,'basin');
-		basinzoom(options);
-	end
-
-	//ShowBasins
-	if strcmpi(options.getfieldvalue('showbasins','off'),'on')
-		showbasins(options);
-	end
-	*/ //}}}
-	/* ///{{{
-	//shading
-	if exist(options,'shading'),
-		shading(options.getfieldvalue('shading'));
-	end
-
-	//grid
-	if exist(options,'grid'),
-		if strcmpi(options.getfieldvalue('grid'),'on'),
-			grid on;
-		end
-	end
-
-	//colormap
-	c = getcolormap(options);
-	h = colormap(c);
-
-	//wrapping
-	if exist(options,'wrapping'),
-		if ~exist(options,'colormap'),
-			h=jet;
-		end
-		colormap(repmat(h,options.getfieldvalue('wrapping',1),1));
-	end
-	*/ //}}}
-	//colorbar
+	
+	//colorbar {{{
 	if (options.exist('colorbar')) {
 		if (options.getfieldvalue('colorbar')==1) {
-			if (options.exist('colorbarcornerposition')) {
-				//c=colorbar(options.getfieldvalue('colorbarcornerposition'),'peer',gca);
-			} else { 
-			}
-			
-			//Handle movie data
+			//Handle movie data {{{
 			var	dataresults = processdata(md,data,options);
 			var	data2 = dataresults[0]; 
@@ -150,6 +23,6 @@
 				data = data[node["movieFrame"]].slice(0,-1);
 				console.log(data);
-			}
-			
+			} //}}}
+			//Variable options initialization {{{
 			var caxis = options.getfieldvalue('caxis',[ArrayMin(data),ArrayMax(data)]);
 			var canvassize = options.getfieldvalue('canvassize',480);
@@ -160,9 +33,10 @@
 			var ccontext,ccanvas,ccanvasid,ccanvashtml;
 			var colorbarorientiation = options.getfieldvalue('colorbarorientation','vertical');
-			//define offsets for correct font drawing on canvas
 			var cheightoffset = options.getfieldvalue('colorbarfontsize',16);
 			var cwidthoffset = options.getfieldvalue('colorbarfontsize',16)*3;
-			
-			//Set colorbar lables
+			var y;
+			var x;
+			//}}}
+			//Set colorbar lables {{{
 			var labels = [];
 			var cdivisions = options.getfieldvalue('colorbarnticks',6);
@@ -183,9 +57,7 @@
 					labels[i] = (caxisdelta*(cdivisions-i)/cdivisions+caxis[0]).toPrecision(precision);
 				}
-			}
-			var y;
-			var x;
-			
-			if (colorbarorientiation=='vertical') {
+			} //}}}
+			//Handle orientation {{{
+			if (colorbarorientiation=='vertical') { //{{{
 				cheight = options.getfieldvalue('colorbarheight',0.95)*canvassize;
 				cwidth = options.getfieldvalue('colorbarwidth',canvassize/20);
@@ -259,6 +131,6 @@
 					ccontext.fillText(options.getfieldvalue('colorbartitle'),0,cheightoffset);
 				}
-			}
-			else { //colorbarorientiation=='horizontal'
+			} //}}}
+			else { //colorbarorientiation=='horizontal' {{{
 				cheight = options.getfieldvalue('colorbarheight',canvassize/20);
 				cwidth = options.getfieldvalue('colorbarwidth',0.95)*canvassize;
@@ -332,78 +204,10 @@
 					ccontext.fillText(options.getfieldvalue('colorbartitle'),cwidth/2+cwidthoffset,cheightoffset);
 				}
-			}
-			/* //{{{
-			if exist(options,'wrapping')
-				lim=get(c,'Ylim');
-				lim=[lim(1) lim(1)+(lim(2)-lim(1))/options.getfieldvalue('wrapping')];
-				set(c,'Ylim',lim);
-			}
-			if exist(options,'colorbarpos'),
-				set(c,'Position',options.getfieldvalue('colorbarpos'));
-			}
-			if exist(options,'log'),
-				nlab=length(get(c,'YTick'));
-				logvalue=options.getfieldvalue('log');
-
-				scaleminmax=caxis;
-				Min=min(scaleminmax);
-				Max=max(scaleminmax);
-				set(c,'YLim',[Min Max]); // set colorbar limits
-				set(c,'YTick',linspace(Min,Max,nlab));     // set tick mark locations
-
-				labels = cell(1,nlab);
-				tick_vals = linspace(Min,Max,nlab);
-				tick_vals = exp(log(logvalue)*tick_vals);
-				warning off MATLAB:log:logOfZero;
-				for i = 1:nlab
-					labels{i} = sprintf('//-3.4g',round_ice(tick_vals(i),2));
-					//labels{i} = sprintf('//-.4g',round_ice(tick_vals(i),2));
-				}
-				warning on MATLAB:log:logOfZero;
-				set(c,'YTickLabel',labels);
-			} 
-			if exist(options,'cbYLim'); 
-				set(c,'YLim',options.getfieldvalue('cbYLim'));
-			}
-			if exist(options,'colorbartitle'),
-				set(get(c,'title'),'FontSize',options.getfieldvalue('colorbarfontsize',fontsize),'String',options.getfieldvalue('colorbartitle'),...
-					'Color',options.getfieldvalue('FontColor','k'));
-			}
-			if exist(options,'colorbarYLabel'),
-				set(get(c,'Ylabel'),'FontSize',options.getfieldvalue('colorbarfontsize',fontsize),'String',options.getfieldvalue('colorbarYLabel'),...
-					'Color',options.getfieldvalue('FontColor','k'));
-			}
-			if exist(options,'colorbarwidth'),
-				posaxes=get(gca,'Position');
-				alpha=options.getfieldvalue('colorbarwidth',1);
-				position=get(c,'Position');
-				dx=position(3);
-				newdx=dx*alpha;
-				position(1)=position(1)+(dx-newdx)/2;
-				position(3)=newdx;
-				set(c,'Position',position);
-				set(gca,'Position',posaxes);
-			}
-			if exist(options,'colorbarheight'),
-				posaxes=get(gca,'Position');
-				alpha=options.getfieldvalue('colorbarheight',1);
-				position=get(c,'Position');
-				dy=position(4);
-				newdy=dy*alpha;
-				position(2)=position(2)+(dy-newdy)/2;
-				position(4)=newdy;
-				set(c,'Position',position);
-				set(gca,'Position',posaxes);
-			}
-			if (options.exist('cbYTickLabel')) {
-			}
-			*/ //}}}
-		}
-	} else {
-		//do nothing
-
-	}
-	//Make texture canvas
-	
+			} //}}}
+			//}}}
+		} 
+	}
+	//}}}
+	//Make texture canvas //{{{
 	var tcontext,tcanvas,tcanvasid,tcanvashtml,tURL,tgradient;
 	tcanvasid = 'texturecanvas';
@@ -432,266 +236,80 @@
 	tURL = tcanvashtml.toDataURL();
 	node["texture"] = initTexture(gl,tURL);
-	/* //{{{
-	//area
-	if exist(options,'area'),
-		antzoom(options.getfieldvalue('area'));
-	end
-
-	//expdisp
-	if exist(options,'expdisp'),
-		filename=(options.getfieldvalue('expdisp'));
-		style=(options.getfieldvalue('expstyle'));
-		linewidth=(options.getfieldvalue('linewidth',1));
-		for i=1:length(options.getfieldvalue('expdisp')),
-			filenamei=filename{i};
-			stylei=style{i};
-			if length(linewidth)==1,
-				linewidthi=linewidth;
-			else
-				linewidthi=linewidth{i};
-			end
-			expdisp(filenamei,'linestyle',stylei,'linewidthi',linewidthi,'multiplier',options.getfieldvalue('unit',1));
-		end
-	end
-
-	//text (default value is empty, not NaN...)
-	if exist(options,'text');
-		textstring=options.getfieldvalue('text');
-		textweight=options.getfieldvalue('textweight','b');
-		textsize=options.getfieldvalue('textsize');
-		textcolor=options.getfieldvalue('textcolor');
-		textposition=options.getfieldvalue('textposition');
-		textrotation=options.getfieldvalue('textrotation');
-		for i=1:length(options.getfieldvalue('text'));
-			textstringi=textstring{i};
-			textweighti=textweight{i};
-			textsizei=textsize{i};
-			textcolori=textcolor{i};
-			textpositioni=textposition{i};
-			textrotationi=textrotation{i};
-			h=text(textpositioni(1),textpositioni(2),10,textstringi,'FontSize',textsizei,'FontWeight',textweighti,'Color',textcolori,'Rotation',textrotationi);
-			set(h,'Clipping','on'); //prevent text from appearing outside of the box
-		end
-	end
-
-	//north arrow
-	if exist(options,'northarrow'),
-		northarrow(options.getfieldvalue('northarrow'));
-	end
-
-	//curved arrow
-	if exist(options,'curvedarrow'),
-		curvedoptions=options.getfieldvalue('curvedarrow');
-		curvedarrow(curvedoptions{:});
-	end
-
-	//Scale ruler
-	if exist(options,'scaleruler'),
-		scaleruler(options);
-	end
-
-	//streamliness
-	if exist(options,'streamlines'),
-		plot_streamlines(md,options);
-	end
-
-	//contours
-	if exist(options,'contourlevels'),
-		plot_contour(md,data,options);
-	end
-
-	//YTickLabel
-	if exist(options,'yticklabel'),
-		set(gca,'YTickLabel',options.getfieldvalue('YTickLabel'));
-	end
-
-	//XTickLabel
-	if exist(options,'xticklabel'),
-		set(gca,'XTickLabel',options.getfieldvalue('XTickLabel'));
-	end
-
-	//xtick
-	if exist(options,'xtick'),
-		set(gca,'xtick',options.getfieldvalue('xtick'));
-	end
-
-	//ytick
-	if exist(options,'ytick'),
-		set(gca,'ytick',options.getfieldvalue('ytick'));
-	end
-
-	//Axis positions
-	if exist(options,'offsetaxispos'),
-		offset=options.getfieldvalue('offsetaxispos');
-		P=get(gca,'pos');
-		P(1)=P(1)+offset(1);
-		P(2)=P(2)+offset(2);
-		P(3)=P(3)+offset(3);
-		P(3)=P(4)+offset(4);
-		set(gca,'pos',P);
-	end
-	if exist(options,'axispos'),
-		Axis=options.getfieldvalue('axispos');
-		hold on
-		set(gca,'pos',Axis);
-	end
-
-	//axes position
-	if exist(options,'axesPosition')
-		set(gca,'Position',options.getfieldvalue('axesPosition'));
-	end
-
-	//showregion
-	if strcmpi(options.getfieldvalue('showregion','off'),'on'),
-		//Keep pointer of main axis
-		maingca=gca;
-		//get inset relative position (x,y,width,height)
-		insetpos=options.getfieldvalue('insetpos',[0.02 0.70 0.18 0.18]);
-		//get current plos position
-		cplotpos=get(maingca,'pos');
-		//compute inset position
-		PosInset=[cplotpos(1)+insetpos(1)*cplotpos(3),cplotpos(2)+insetpos(2)*cplotpos(4), insetpos(3)*cplotpos(3), insetpos(4)*cplotpos(4)];
-		axes('pos',PosInset);
-		axis equal off
-		//box off
-		if md.mesh.epsg==3413,
-			A=expread('/u/astrid-r1b/ModelData/Exp/GreenlandBoxFront.exp');
-			[A.x A.y]=ll2xy(A.x,A.y,+1,45,70);
-			A.x = A.x(1:30:end);
-			A.y = A.y(1:30:end);
-		elseif md.mesh.epsg==3031,
-			A=expread('/u/astrid-r1b/ModelData/Exp/Antarctica.exp');
-		else
-			error('applyoptions error message: md.mesh.epsg not defined');
-		end
-		offset=3*10^4;
-		Ax=[min(A.x)-offset max(A.x)+offset];
-		Ay=[min(A.y)-offset max(A.y)+offset];
-		//if we are zooming on a basin, don't take the mesh for the boundaries!
-		if exist(options,'basin'),
-			[mdx mdy]=basinzoom(options);
-		else
-			mdx=[min(md.mesh.x)-offset max(md.mesh.x)+offset];
-			mdy=[min(md.mesh.y)-offset max(md.mesh.y)+offset];
-		end
-		line(A.x,A.y,ones(size(A.x)),'color','b');
-		patch([Ax(1)  Ax(2)  Ax(2)  Ax(1) Ax(1)],[Ay(1)  Ay(1)  Ay(2)  Ay(2) Ay(1)],[1 1 1],'EdgeColor',[0 0 0],'LineWidth',1,'FaceLighting','none')
-		patch([mdx(1) mdx(2) mdx(2) mdx(1)],[mdy(1) mdy(1) mdy(2) mdy(2)],ones(4,1),'EdgeColor',[0 0 0],'FaceColor','r','FaceAlpha',0.5)
-		colorbar('off');
-		//back to main gca
-		set(gcf,'CurrentAxes',maingca)
-	end
-
-	//flag edges of a partition
-	if exist(options,'partitionedges')
-		[xsegments ysegments]=flagedges(md.mesh.elements,md.mesh.x,md.mesh.y,md.qmu.partition);
-		xsegments=xsegments*options.getfieldvalue('unit',1);
-		ysegments=ysegments*options.getfieldvalue('unit',1);
-		color=options.getfieldvalue('partitionedgescolor','r-');
-		linewidth=options.getfieldvalue('linewidth',1);
-		hold on;
-		for i=1:length(xsegments),
-			plot(xsegments(i,:),ysegments(i,:),color,'LineWidth',linewidth);
-		end
-	end
-
-	//Scatter
-	if exist(options,'scatter')
-		data=options.getfieldvalue('scatter');
-		hold on
-		plot_scatter(data(:,1),data(:,2),data(:,3),options);
-	end
-
-	//backgroundcolor
-	set(gca,'color',options.getfieldvalue('backgroundcolor','none'));
-
-	//lighting
-	if strcmpi(options.getfieldvalue('light','off'),'on'),
-		set(gca,'FaceLighting','gouraud','FaceColor','interp','AmbientStrength',0.5);
-		light('Position',[0 0.1 0.1],'Style','infinite');
-	end
-
-	//cloud of points: 
-	if exist(options,'cloud'),
-		field=options.getfieldvalue('cloud');
-		x=field(:,1);
-		y=field(:,2);
-		//unit multiplier:
-		if exist(options,'unit'),
-			unit=options.getfieldvalue('unit');
-			x=x*unit;
-			y=y*unit;
-		end
-		hold on,p=plot(x,y,'k.');
-		markersize=options.getfieldvalue('markersize',12);
-		color=options.getfieldvalue('cloudcolor','k');
-		set(p,'Color',color);
-		set(p,'MarkerSize',markersize);
-	end
-
-	//========================//
-	//OK VERY LAST STEP: INSET|
-	//========================//
-	if exist(options,'inset'),
-
-		//Keep pointer of main axis
-		maingca=gca;
-		//get inset relative position (x,y,width,height)
-		insetpos=options.getfieldvalue('insetpos',[0.56 0.55 0.35 0.35]);
-		//get current plot position
-		cplotpos=get(gca,'pos');
-
-		X1=options.getfieldvalue('insetx',xlim);
-		Y1=options.getfieldvalue('insety',ylim);
-
-		for i=1:length(options.getfieldvalue('insetx')),
-			if length(insetpos)==4,
-				insetposi=insetpos;
-			else
-				insetposi=insetpos{i};
-			end
-			PosInseti=[cplotpos(1)+insetposi(1)*cplotpos(3),cplotpos(2)+insetposi(2)*cplotpos(4), insetposi(3)*cplotpos(3), insetposi(4)*cplotpos(4)];
-			//show pos
-			if iscell(X1),
-				X1i=X1{i};
-			else
-				X1i=X1;
-			end
-			if iscell(Y1),
-				Y1i=Y1{i};
-			else
-				Y1i=Y1;
-			end
-			if strcmpi(options.getfieldvalue('showinset','off'),'on')
-				line(X1i([1 2 2 1 1]),Y1i([1 1 2 2 1]),zeros(1,5),'Color','k','LineWidth',2);
-			end
-
-			//Get current figure
-			ax1=gca;
-
-			//plot inset
-			axes('pos',PosInseti);
-			copyobj(get(ax1,'children'),gca);
-			patch('Faces',[1 2 3 4 1],'Vertices',[X1i([1 2 2 1])' Y1i([1 1 2 2])'],'FaceColor','None','EdgeColor','k','LineWidth',2);
-
-			//apply options
-			options=removefield(options,'text',0);
-			options=removefield(options,'title',0);
-			options=removefield(options,'xlabel',0);
-			options=removefield(options,'ylabel',0);
-			options=removefield(options,'inset',0);
-			options=removefield(options,'offsetaxispos',0);
-			options=removefield(options,'showregion',0);
-			options=changefieldvalue(options,'colorbar',0);
-			options=changefieldvalue(options,'latlon','off');
-			options=changefieldvalue(options,'axis','equal off');
-			options=changefieldvalue(options,'xlim',X1i);
-			options=changefieldvalue(options,'ylim',Y1i);
-			applyoptions(md,data,options);
-
-			//back to main gca
-			set(gcf,'CurrentAxes',maingca)
-		end
-	end
-	*/ //}}}
+	//}}}
+	//expdisp contours
+	if (options.exist('expdisp')) {
+		canvas.nodes["expdisp"] = Node(gl,options);
+		var node = canvas.nodes["expdisp"];
+		
+		//declare variables:  {{{
+		var vertices = [];
+		var indices = [];
+		var colors = [];
+		var rgbcolor = [];
+		var xmin,xmax;
+		var ymin,ymax;
+		var zmin,zmax;
+		var scale;
+		
+		//Process data and model
+		var x = options.getfieldvalue('expdisp')['x'];
+		var y = options.getfieldvalue('expdisp')['y'];
+		var z = Array.apply(null, Array(x.length)).map(Number.prototype.valueOf,0);
+		
+		if (options.getfieldvalue('expdisp')['z']) {
+			z = options.getfieldvalue('expdisp')['z'];
+		}
+		//}}}
+
+		//Compute coordinates and data range:
+		var modelxlim = [ArrayMin(x),ArrayMax(x)];
+		var modelylim = [ArrayMin(y),ArrayMax(y)];
+		var modelzlim = [ArrayMin(z),ArrayMax(z)];
+		var xlim = options.getfieldvalue('xlim',modelxlim);
+		var ylim = options.getfieldvalue('ylim',modelylim);
+		var zlim = options.getfieldvalue('zlim',modelzlim);
+		xmin = xlim[0];
+		xmax = xlim[1];
+		ymin = ylim[0];
+		ymax = ylim[1];
+		zmin = zlim[0];
+		zmax = zlim[1];
+
+		//Compute scaling: 
+		var scale = 1 / (xmax - xmin);
+		node["shaderName"] = "colored";
+		node["shader"] = gl["shaders"][node["shaderName"]]["program"];
+		node["scale"] = [scale, scale, scale*options.getfieldvalue('heightscale',1)];
+		node["translation"] = [(xmin + xmax) / (-2 / scale), (ymin + ymax) / (-2 / scale), (zmin + zmax) / (-2 / scale)];
+		node["modelMatrix"] = recalculateModelMatrix(node);
+		node["drawMode"] = gl.LINE_LOOP;
+		node["drawOrder"] = 0;
+		node["useIndexBuffer"] = false;
+		node["disableDepthTest"] = true;
+					
+		//some defaults:
+		colors.itemSize = 4;
+
+		//retrieve some options
+		var linewidth=options.getfieldvalue('linewidth',1);
+		var edgecolor=options.getfieldvalue('edgecolor','black'); //RGBCOLOR?
+
+		vertices.itemSize = 3;
+		for(var i = 0; i < x.length; i++){
+			vertices[vertices.length] = x[i];
+			vertices[vertices.length] = y[i];
+			vertices[vertices.length] = z[i];
+
+			//edgecolor
+			rgbcolor = [0.0, 0.0, 0.0];
+			colors[colors.length] = rgbcolor[0];
+			colors[colors.length] = rgbcolor[1];
+			colors[colors.length] = rgbcolor[2];
+			colors[colors.length] = 1.0;
+		}
+
+		/*Initalize buffers: */
+		node["arrays"] = [vertices, colors];
+		node["buffers"] = initBuffers(gl, node["arrays"]);
+	}
 }
Index: /issm/trunk-jpl/src/m/plot/webgl.js
===================================================================
--- /issm/trunk-jpl/src/m/plot/webgl.js	(revision 19964)
+++ /issm/trunk-jpl/src/m/plot/webgl.js	(revision 19965)
@@ -427,4 +427,7 @@
 		gl.uniform1i(node["shader"]["uColorSampler"], 0);	
 	}
+	if (node["disableDepthTest"]) {
+		gl.disable(gl.DEPTH_TEST);
+	}
 	gl.blendFunc (gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
 	if  (node["useIndexBuffer"] == true) {
@@ -435,4 +438,5 @@
 		gl.drawArrays(node["drawMode"], 0, node["buffers"][0].numItems);
 	}	
+	gl.enable(gl.DEPTH_TEST);
 } //}}}
 function bindAttributes(gl,shaderProgram,bufferArray) { //{{{
