Zoom GUI callback delay with mouse roller
5 次查看(过去 30 天)
显示 更早的评论
I have a GPS map plotting tool which uses a web based satellite image, where I've included the basic Matlab zoom and pan functions. While the zoom function works fine for zooming IN with a left mouse click rectangular selection, I'm having difficulties getting the mouse roller to allow zooming out. It seems that the callback is being executed with every click of the roller, which forces reacquisition of the web image. The plot seems to reset after scrolling back to about its original size.
Is there a way to modify this behavior so the scroll callback delays, or measures time such that this can be trapped. Allowing the replot to only be called once, after scrolling has been completed?
I'm also compiling this tool into a stand alone exe, although I assume that doesn't matter, as I see the same behavior running either compiled, or from within Matlab.
zoomPlot is the GUI zoom button callback, where I'm setting an "ActionPostCallback". Is there a way to avoid repeated calls to this function while the mouse roller is being used, while also being depressed?
Thank You
%function - Set zoom
function zoomPlot(obj, src,~, mode)
obj.clearTools('cursor');
if isempty(obj.figZoom)
%create a zoom tool context menu with a single item, to reset the zoom
hCMZ = uicontextmenu;
hZMenu = uimenu('Parent',hCMZ,'Label','Reset to Original View',...
'Callback',@obj.zoomReset);
hZoom = zoom(obj.gui_h.figure1);
set(hZoom,'ActionPostCallback',@(src, event) zoomControl(obj, src, event));
hZoom.UIContextMenu = hCMZ;
hZoom.setAxesZoomMotion(obj.gui_h.plotaxis,'both');
hZoom.setAxesZoomMotion(obj.gui_h.dataaxis,'horizontal');
obj.figZoom = hZoom;
end
axes(obj.gui_h.dataaxis)
if strcmpi(mode,'zoom')
%turn off pan
obj.clearTools('pan');
if strcmpi(src.State,'on')
zoom on
else
zoom off
end
else
%turn off zoom
obj.clearTools('zoom');
if strcmpi(src.State,'on')
pan on
else
pan off
end
end
end
3 个评论
Rik
2019-4-8
I don't know if it is a good idea in the first place to be using the builtin zoom function. It may be a better idea to set the axis yourself. That way you keep control over what is happening (and you make it more robust to changes in the native UI of Matlab).
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!