moveline.m

来自「Univ. of Calgary CREWS的免费地震研究软件」· M 代码 · 共 2 行

M
2
字号
function moveline(action)
 if(nargin<1) %set the button down function
		set(gcf,'windowbuttondownfcn','moveline(''init'')');
		return;
	end
	if(strcmp(action,'init'))
		hline=gco;
		if(~strcmp(get(hline,'type'),'line'))
			return;
		end
		pt=get(gca,'currentpoint');
		set(hline,'userdata',pt(1,1:2));
		set(hline,'erasemode','xor','linestyle','.');
		
		set(gcf,'windowbuttonmotionfcn','moveline(''move'')');
		set(gcf,'windowbuttonupfcn','moveline(''fini'')');
		return;
	end
	if(strcmp(action,'move'))
		hline=gco;
		
		pt1=get(hline,'userdata');
		pt2=get(gca,'currentpoint');
		pt2=pt2(1,1:2);
		
		del=pt2-pt1;
		
		x=get(hline,'xdata');
		y=get(hline,'ydata');
		
		set(hline,'xdata',x+del(1));
		set(hline,'ydata',y+del(2));
		set(hline,'userdata',pt2);
		
		return;
	end
	
	if(strcmp(action,'fini'))
		hline=gco;
		set(hline,'erasemode','normal','linestyle','-');
		
		set(gcf,'windowbuttonmotionfcn','');
		set(gcf,'windowbuttonupfcn','');
		return;
	end
end
		
		

⌨️ 快捷键说明

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