Zoom GUI callback delay with mouse roller

9 次查看(过去 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 个评论
Jeff
Jeff 2019-4-8
Thank You for the reply.
I want to handle both button and wheel inputs in the same callback, but am unable to see any information in either the src or event data available to determine which mouse input generated the call.
The built in zoom function overrides the figure the WindowScrollWheelFunction callback and won't allow it to be changed.
It seems there should be a way to determine which mouse function generated the callback?
Rik
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 CenterFile Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

标签

产品


版本

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by