function peigui_vector_command ( action )

%  USAGE peigui_vector_command(action)
%  In this function there are some command used in hopsGui for contouring
%
% The comands (action) are basically:
% depth_vector,......Plot vectors for at depths contours
%
% Pedro Velez (UIB-IEO), July 1999


global peigui_obj


switch ( action )


case 'depth_vector'
peigui_obj{1}.vectoraction=action;


%Drawing vectors overimposed in the contour-depth plots        
    	peigui_obj{1}.drawvectors=1;
	
    	[u,x,y]=peigui_depthslicev(peigui_obj{1}.filein, ...
        peigui_obj{1}.depth, ....
        peigui_obj{1}.time,peigui_obj{1}.vectorvar);

    	[v,x,y]=peigui_depthsliceu(peigui_obj{1}.filein, ...
        peigui_obj{1}.depth, ....
        peigui_obj{1}.time,peigui_obj{1}.vectorvar);
	  
    
	%Resampling the data 
	[m,n]=size(u);
	u=u([1:peigui_obj{1}.isub:m],[1:peigui_obj{1}.isub:n]);
	v=v([1:peigui_obj{1}.isub:m],[1:peigui_obj{1}.isub:n]);
	x=x([1:peigui_obj{1}.isub:m],[1:peigui_obj{1}.isub:n]);
	y=y([1:peigui_obj{1}.isub:m],[1:peigui_obj{1}.isub:n]);

	ig=find(finite(u));
	hold on;
	peigui_obj{1}.hvectors1=quiver(x(ig),y(ig),u(ig)*peigui_obj{1}.fac, ...
		v(ig)*peigui_obj{1}.fac,0,peigui_obj{1}.vectorcolor);
	set(peigui_obj{1}.hvectors1,'linewidth',.1);
	hold off;	
		
	%Reference vector
	hold on;
  	xlim=get(peigui_obj{1}.haxes1,'xlim');
	ylim=get(peigui_obj{1}.haxes1,'ylim');
	posx=xlim(1)+(xlim(2)-xlim(1))*0.02;
	dx=(xlim(2)-xlim(1))*0.3;
	posy=ylim(2)-(ylim(2)-ylim(1))*0.02;
	dy=(ylim(2)-ylim(1))*0.015;
	peigui_obj{1}.hvectors2=patch([posx posx+peigui_obj{1}.refvector*peigui_obj{1}.fac posx+peigui_obj{1}.refvector*peigui_obj{1}.fac posx], ...
	      [posy-dy posy-dy posy+dy posy+dy],'w','edgecolor',[1 1 1]);
	peigui_obj{1}.hvectors3=quiver(posx,posy,...
		peigui_obj{1}.refvector*peigui_obj{1}.fac,0.,0, ...
		peigui_obj{1}.vectorcolor);
	set(peigui_obj{1}.hvectors3,'linewidth',.1);		
	hold off ;


case 'k_vector'
peigui_obj{1}.vectoraction=action;

%Drawing vectors overimposed in the contour-depth plots        
    	
    	[u,x,y,z]=peigui_kslice(peigui_obj{1}.filein, ...
        peigui_obj{1}.kindex, ....
        peigui_obj{1}.time,'ut');

    	[v,x,y,z]=peigui_kslice(peigui_obj{1}.filein, ...
        peigui_obj{1}.kindex, ....
        peigui_obj{1}.time,'vt');
	  
    	%Resampling the data 
	[m,n]=size(u);
	u=u([1:peigui_obj{1}.isub:m],[1:peigui_obj{1}.isub:n]);
	v=v([1:peigui_obj{1}.isub:m],[1:peigui_obj{1}.isub:n]);
	x=x([1:peigui_obj{1}.isub:m],[1:peigui_obj{1}.isub:n]);
	y=y([1:peigui_obj{1}.isub:m],[1:peigui_obj{1}.isub:n]);
	ig=find(finite(u));
	hold on;
	peigui_obj{1}.hvectors1=quiver(x(ig),y(ig),u(ig)*peigui_obj{1}.fac, ...
		v(ig)*peigui_obj{1}.fac,0,peigui_obj{1}.vectorcolor);
	set(peigui_obj{1}.hvectors1,'linewidth',.1);				
	%Reference vector
	hold on;
  	xlim=get(peigui_obj{1}.haxes1,'xlim');
	ylim=get(peigui_obj{1}.haxes1,'ylim');
	posx=xlim(1)+(xlim(2)-xlim(1))*0.02;
	dx=(xlim(2)-xlim(1))*0.3;
	posy=ylim(2)-(ylim(2)-ylim(1))*0.02;
	dy=(ylim(2)-ylim(1))*0.015;
	peigui_obj{1}.hvectors2=patch([posx posx+peigui_obj{1}.refvector*peigui_obj{1}.fac posx+peigui_obj{1}.refvector*peigui_obj{1}.fac posx], ...
	      [posy-dy posy-dy posy+dy posy+dy],'w','edgecolor',[1 1 1]);
	peigui_obj{1}.hvectors3=quiver(posx,posy,...
		peigui_obj{1}.refvector*peigui_obj{1}.fac,0.,0, ...
		peigui_obj{1}.vectorcolor);
	set(peigui_obj{1}.hvectors3,'linewidth',.1);				
	hold off;



	
end
return;

