Why does zoom unexpectedly invert sometimes? (App Designer, UIFigures)

3 次查看(过去 30 天)
Hello there!
Sometimes I find the plot zoom behaviour is inverted in my UIFigures. If "zoom in" is active (the "zoom in" symbol in the toolbar is active), it would actually zoom out when clicking in the plot and vice versa. Also, in this case, it is not possible to zoom into only one individual axis.
Unfortunately, this bug is not really reproducable, for it seems to happen out of the blue while using my app.
Similarly, the bug sometimes resolves itself and sometimes I am forced to reopen my app to solve it.
There are no Warnings or Errors.
I work with app designer but create the toolbar for the UIFigure myself, in order to define my own callbacks. Also I have 3 axes which have the xAxis linked:
toolbarButtons = {'export', 'datacursor', 'pan', 'zoomin', 'zoomout', 'restoreview'};
enableLegacyExplorationModes(app.MyUIFigure);
% Toolbar Axis 1
app.axesOne.Toolbar = axtoolbar(app.axesOne, toolbarButtons, 'Visible', 'off');
app.restoreViewBtn = findall(app.axesOne.Toolbar, 'Tooltip','Restore View');
app.restoreViewBtn.ButtonPushedFcn = @app.restoreView;
% Toolbar Axis 2
app.axesTwo.Toolbar = axtoolbar(app.axesTwo, toolbarButtons, 'Visible', 'off');
app.restoreViewBtn(2) = findall(app.axesTwo.Toolbar, 'Tooltip','Restore View');
app.restoreViewBtn(2).ButtonPushedFcn = @app.restoreView;
% Toolbar Axis 3
app.axesThree.Toolbar = axtoolbar(app.axesThree, toolbarButtons, 'Visible', 'off');
app.restoreViewBtn(3) = findall(app.axesThree.Toolbar, 'Tooltip','Restore View');
app.restoreViewBtn(3).ButtonPushedFcn = @app.restoreView;
% Pan Callback
app.panHandle = pan(app.MyUIFigure);
app.panHandle.ActionPreCallback = @app.panPreCallback;
app.panHandle.ActionPostCallback = @app.panPostCallback;
% Zoom Callback
app.zoomHandle = zoom(app.MyUIFigure);
app.zoomHandle.ActionPreCallback = @app.zoomPreCallback;
app.zoomHandle.ActionPostCallback = @app.zoomPostCallback;
% Linking
linkaxes([app.axesOne, app.axesTwo, app.axesThree], 'x');
I already verified, the active toolbar symbol alway reflects correctly in zoom.Direction. So the mess-up must be somewhere elese:
temp = zoom(app.MyUIFigure)
temp =
zoom with properties:
Motion: 'both'
Direction: 'in'
RightClickAction: 'PostContextMenu'
ContextMenu: []
ButtonDownFilter: []
ActionPreCallback: @(varargin)app.zoomPreCallback(varargin{:})
ActionPostCallback: @(varargin)app.zoomPostCallback(varargin{:})
Enable: 'off'
FigureHandle: [1×1 Figure]
UseLegacyExplorationModes: on
Hopefully somebody can point me in the right direction to resolve this mistery. Thanks a lot in advance for any help.

回答(1 个)

UDAYA PEDDIRAJU
UDAYA PEDDIRAJU 2024-5-14
编辑:UDAYA PEDDIRAJU 2024-5-14
Hi Tiberia,
  • Linked Axes: You have 3 linked axes. Consider if "linkaxes" is affecting zoom behavior and test by temporarily disabling it. Try temporarily unlinking them (unlinkaxes) to see if the inversion persists. If it does, the issue might not be related to linked axes.
  • Legacy Mode: You're using "enableLegacyExplorationModes". Try disabling it to see if it improves zoom behavior.
  • Check Custom Callbacks: You created custom callbacks for zoom actions. Make sure these callbacks aren't accidentally reversing the zoom direction. Ensure there's no logic in "app.zoomPreCallback" and "app.zoomPostCallback" that might invert zoom behavior.
  • Update MATLAB: Ensure you're using the latest version of MATLAB, as this might be a bug that has been fixed in a newer release. Try restarting your app or MATLAB to see if it resolves the issue temporarily.

类别

Help CenterFile Exchange 中查找有关 Visual Exploration 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by