function pasteimage(command) %PASTEIMAGE Copy the CutPaste global variable to the specified position % in the current image, using the mouse. % % Claudio 28 Sept. 1995 % % % Copyright (c) 1995 by Claudio Rivetti and Mark Young % claudio@alice.uoregon.edu, mark@alice.uoregon.edu % global H I CutPaste ax l w h x y oldz oldmf olddf oldpn ss px; if isempty(CutPaste) message('| Nothing to Paste.'); return; end if nargin>1 error('Too many input arguments.'); end if nargin==0 command='START'; end if strcmp(upper(command), 'START') if ~isimage setviewmode('TOPVIEW'); showimage; end oldpn=get(gcf, 'pointer'); oldmf=get(gcf, 'WindowButtonMotionFcn'); olddf=get(gcf, 'WindowButtonDownFcn'); oldz=getzoomstatus; setzoomstatus(0); ss=scansize(H); px=size(I,1); w=size(CutPaste,2); h=size(CutPaste,1); w=w*ss/px; h=h*ss/px; lx=[0 0 w w 0]; ly=[0 h h 0 0]; l=line(lx,ly,'erasemode','xor'); set(gcf, 'pointer', 'fleur'); set(gcf, 'WindowButtonMotionFcn', 'pasteimage(''MOVE'')'); set(gcf, 'WindowButtonDownFcn', 'pasteimage(''PASTE'')'); end if strcmp(upper(command), 'MOVE') p=pix2axes(get(gcf, 'currentpoint')); lx=[p(1)-w/2 p(1)-w/2 p(1)+w/2 p(1)+w/2 p(1)-w/2]; ly=[p(2)-h/2 p(2)+h/2 p(2)+h/2 p(2)-h/2 p(2)-h/2]; set(l,'xdata',lx);set(l,'ydata',ly); end if strcmp(upper(command), 'PASTE') set(gcf, 'WindowButtonMotionFcn', oldmf); set(gcf, 'WindowButtonDownFcn', olddf); set(gcf, 'pointer', oldpn); x=get(l, 'xdata'); y=get(l, 'ydata'); x=ceil((x(1)-xoffset(H)) * px/ss); y=ceil((y(1)-yoffset(H)) * px/ss); delete(l); setzoomstatus(oldz); setimage(CutPaste, [x y]); end return;