function df_editor
figure('WindowButtonDownFcn',@myBDCallback,'WindowButtonUpFcn',@myBUCallback)
axis([-200,200,-200,200]); axis square; hold on;
xlabel('x'), ylabel('y');
po=sspread('mi.ssp');
pos(:,1)=po(:,1);
pos(:,2)=po(:,2);
for i=1:length(pos)-1
hL(i)=plot(pos(i:i+1,1),pos(i:i+1,2),'k-');
end
for i=1:length(pos)
h(i)=plot(pos(i,1),pos(i,2),'bs');
end
for i=1:length(pos)
h(i)=plot(pos(i,1),pos(i,2),'bo');
end
function myBDCallback(src,eventdata)
set(src,'WindowButtonMotionFcn',@myBMCallback);
function myBMCallback(src,evnt)
Cp = get(gca,'CurrentPoint');
Xf = Cp(1,1);
Yf = Cp(1,2);
[dp,Ip] = min((pos(:,1)-Xf).^2+(pos(:,2)-Yf).^2)
set(h(Ip),'XData',Xf)
set(h(Ip),'YData',Yf)
if Ip==1
set(hL(Ip),'XData',[Xf,pos(Ip+1,1)])
set(hL(Ip),'YData',[Yf,pos(Ip+1,2)])
pos(Ip,:)=[Xf Yf];
elseif Ip==length(pos)
set(hL(Ip-1),'XData',[pos(Ip-1,1),Xf])
set(hL(Ip-1),'YData',[pos(Ip-1,2),Yf])
pos(Ip,:)=[Xf Yf];
else
set(hL(Ip),'XData',[Xf,pos(Ip+1,1)])
set(hL(Ip),'YData',[Yf,pos(Ip+1,2)])
set(hL(Ip-1),'XData',[pos(Ip-1,1),Xf])
set(hL(Ip-1),'YData',[pos(Ip-1,2),Yf])
pos(Ip,:)=[Xf Yf];
end
drawnow
end
end
function myBUCallback(src,evantdata)
set(src,'WindowButtonMotionFcn','');
end
end