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!