Zoom GUI callback delay with mouse roller

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 Kommentare

Rik
Rik am 8 Apr. 2019
Start zoomControl by loading a lock variable. If the lock is active, increment the zoom count, if not, start the zoom. Then at the end of the zoom call you can load the counter and apply them in a group.
You can implement the lock either with a logical, or by comparing now to the time of the last call.
Jeff
Jeff am 8 Apr. 2019
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 am 8 Apr. 2019
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).

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Data Exploration finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2018b

Gefragt:

am 8 Apr. 2019

Kommentiert:

Rik
am 8 Apr. 2019

Community Treasure Hunt

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

Start Hunting!

Translated by