⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 movecvp.m

📁 地震解释处理matlab工具箱
💻 M
字号:
function points = movecvp(action)

if(nargin<1) %set the button down function
		set(gcf,'windowbuttondownfcn','movecvp(''init'')');
		return;
end

% Get the data needed for this function
cvpi = refdata('get','cvpi');
cvpj = refdata('get','cvpj');
shotcoord = refdata('get', 'shotcoord');
fbcoord = refdata('get', 'fbcoord');
fbtime = refdata('get', 'fbtime');
[shots, currentshot, axeslist] = cvpinfo('get');
if(~isempty(currentshot))
   i = shots(currentshot,1);
   j = shots(currentshot,2);
else
   return;
end

validxi = find(~isnan(fbcoord(i,:)));
validxj = find(~isnan(fbcoord(j,:)));

startp1x = min(fbcoord(i,validxi));
startp2x = min(fbcoord(j,validxj));
minx1 = max(startp1x, startp2x);
maxx1 = shotcoord(i);

endp1x = max(fbcoord(i,validxi));
endp2x = max(fbcoord(j,validxj));
maxx2 = min(endp1x, endp2x);
minx2 = shotcoord(j);

pt=get(gca,'currentpoint');
userx = pt(1,1);

% Check to see if the user clicked in the 'i' shot side or the 'j' side.
iniside = 0;
if( userx < maxx1 & userx > minx1 )
   iniside = 1;
end
injside = 0;
if( userx < maxx2 & userx > minx2 )
   injside = 1;
end

if( iniside == 0 & injside == 0 )
   disp('Selected point not in valid range.');
end

xi = cvpi(i,j);
xj = cvpj(i,j);

% Interpolate to find the time of each CVP point
ti = 0;
if( xi ~= NaN )
   ti = interp1(fbcoord(i,:),fbtime(i,:),xi);
end
tj = 0;
if( xj ~= NaN )
   tj = interp1(fbcoord(j,:),fbtime(j,:),xj);
end
  
if(strcmp(action,'init'))
    set(gcf,'windowbuttonmotionfcn','');
    set(gcf,'windowbuttonupfcn','');

    % Selectiontype normal means button 1  - add CVP
    if(strcmp(get(gcf,'selectiontype'),'normal'))
        if( iniside )
           cvp = cvpi(i,j);
        else
           cvp = cvpj(i,j);
        end
        
        if( cvp == NaN )    % Then we can create a point here
           str = sprintf('Creating a CVP point at %f ',userx);
           disp(str);
           if( iniside )
              xi = userx;
	      ti = interp1(fbcoord(i,:),fbtime(i,:),userx);
           else
              xj = userx;
	      tj = interp1(fbcoord(j,:),fbtime(j,:),userx);
           end
           plotCVPlines( 'draw', axeslist, xi, xj, ti, tj ); 
        else
           str = sprintf('Initiating move ',userx);
           disp(str);
        end

        set(gcf,'windowbuttonmotionfcn','movecvp(''move'')');
        set(gcf,'windowbuttonupfcn','movecvp(''fini'')');

	return;

    % Selectiontype alt means button 3  - delete CVP
    elseif(strcmp(get(gcf,'selectiontype'),'alt'))
	hpoint=gco;
	if(strcmp(get(hpoint,'type'),'line')& get(hpoint,'color') == [1 0 0])
		delete(gco);
		return;
	else
		return;
	end
    else
	return;
    end
end

if(strcmp(action,'move'))
   if( iniside )
      xi = userx;
      ti = interp1(fbcoord(i,:),fbtime(i,:),userx);
   else
      xj = userx;
      tj = interp1(fbcoord(j,:),fbtime(j,:),userx);
   end
   plotCVPlines( 'move', axeslist, xi, xj, ti, tj );
   str = sprintf( 'Moving a CVP point at %f ', userx );
   disp(str);
end

if(strcmp(action,'fini'))
   if( iniside )
      xi = userx;
      ti = interp1(fbcoord(i,:),fbtime(i,:),userx);
      cvpi(i,j) = userx;
      refdata('set','cvpi',cvpi);
   elseif( injside )
      xj = userx;
      tj = interp1(fbcoord(j,:),fbtime(j,:),userx);
      cvpj(i,j) = userx;
      refdata('set','cvpj',cvpj);
   else
      disp('Point not in valid range.  Not set.');
   end
   plotCVPlines('draw',axeslist,xi,xj, ti, tj);

   set(gcf,'windowbuttonmotionfcn','');
   set(gcf,'windowbuttonupfcn','');

end

if(strcmp(action,'save'))
	objs = get(gca,'children');
	n = 1;   % Counter for the number of picked points
	[number x] = size(objs);
	for i=1:number    % i is the counter for the number of axes children
		if(strcmp(get(objs(i),'linestyle'),'*'))
			point(n) = objs(i);
			get(point(n),'xdata')   % This just prints X
			n = n+1;
		end
	end
	points = point;
end
		
		

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -