我需要使用鼠标指针移动图形的楼梯模型。更具体地说,如果我使用鼠标指针移动水平箭头标记中显示的水平图......那么相邻层也应该随着相应的移动水平线移动。 ..对于垂直轴类似..我怎么能在matlab中做到这一点。请帮助我..
下面编写的代码完全移动了绘图,但我需要移动确切的线(楼梯图的垂直/水平)而不干扰其他线。请帮助我...
`
loglog(handles.axes1,a,b,'r')
hold on
% h=loglog(handles.axes1,x,y,'w')
h=stairs(handles.axes1,x,y,'w')
set(h,'ButtonDownFcn',@startmovit);
gui = get(gcf,'UserData');
drawnow
set(gcf,'windowbuttonmotionfcn','')
set(gcf,'windowbuttonupfcn','')
function startmovit(src,evnt)
% Unpack gui object
gui = get(gcf,'UserData');
% Remove mouse pointer
set(gcf,'PointerShapeCData',nan(16,16))
set(gcf,'Pointer','custom');
% Set callbacks
gui.currenthandle = src;
thisfig = gcbf();
set(thisfig,'WindowButtonMotionFcn',@movit)
set(thisfig,'WindowButtonUpFcn',@stopmovit);
% Store starting point of the object
gui.startpoint = get(gca,'CurrentPoint')
set(gui.currenthandle,'UserData',{get(gui.currenthandle,'XData') get(gui.currenthandle,'YData')});
% Store gui object
set(gcf,'UserData',gui);
function movit(src,evnt)
% Unpack gui object
gui = get(gcf,'UserData');
try
if isequal(gui.startpoint,[])
return
end
catch
end
% Do "smart" positioning of the object, relative to starting point...
pos = get(gca,'CurrentPoint')-gui.startpoint
XYData = get(gui.currenthandle,'UserData')
% set(gui.currenthandle,'XData',XYData{1} + pos(1,1))
% set(gui.currenthandle,'YData',XYData{2} + pos(1,2))
set(gui.currenthandle,'XData',XYData{1} + pos(1,1))
set(gui.currenthandle,'YData',XYData{2} + pos(1,2))
% dx=XYData
% dy=XYData
%
% h=findobj(allchild(gca),'selected','on')
% set(h,'Xdata',get(h,'Xdata')+dx,'Ydata',get(h,'Ydata')+dy)
outData1 = get(gui.currenthandle,'XData')'
outData2 = get(gui.currenthandle,'YData')
% newea=outData1
handles = guidata(gcf);
drawnow;
% Store gui object
set(gcf,'UserData',gui);
function stopmovit(src,evnt)
% Clean up the evidence ...
thisfig = gcbf();
gui = get(gcf,'UserData');
set(gcf,'Pointer','arrow');
set(thisfig,'WindowButtonUpFcn','');
set(thisfig,'WindowButtonMotionFcn','');
drawnow
set(gui.currenthandle,'UserData','')
set(gcf,'UserData',[])
`