필터 지우기
필터 지우기

Zoom GUI callback delay with mouse roller

조회 수: 5 (최근 30일)
Jeff
Jeff 2019년 4월 8일
댓글: Rik 2019년 4월 8일
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