Pan object support for uiaxes for callback functionality following that of "Zoom" (ActionPreCallback / ActionPostCallback)
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am working on an app component that requires ActionPreCallback and ActionPostCallback functions for both zoom and pan.
Since this project is based on an old GUIDE application, I need at least similar functionality that Axes provides with uiaxes.
In the original implementation using Axes, the callbacks can be assigned using zoom and pan objects following (Enable pan mode - MATLAB (mathworks.com), Enable zoom mode - MATLAB (mathworks.com)). However, according to the documentation under the 2023a version history notes, when using uiaxes, a zoom or pan object is not returned.
Following this thread (Cannot get zoom post-callback to work on UIAxes - MATLAB Answers - MATLAB Central (mathworks.com)), I am able to set the callback for zoom because a zoom object is returned, contrary to the documentation. On the other hand, the equivalent approach with pan returns the following error when calling "hp = pan(app.UIAxes)":
"Error using uigetmodemanager
First argument must be a figure handle
Error in getuimode (line 12)
hManager = uigetmodemanager(hFig);
Error in pan>locGetMode (line 347)
hMode = getuimode(hFig,'Exploration.Pan');
Error in pan>locGetObj (line 277)
hMode = locGetMode(hFig);
Error in pan (line 229)
out = locGetObj(arg1);"
Attempted solutions:
- I have tried adding a value changed callback to app.UIAxes.XAxis.LimitsChangedFcn, but this does not provide the necessary pre and post action callbacks which I need for this project.
My question is: how can I get pre and post action callback functionality for panning using a uiaxes?
0 commentaires
Réponses (1)
Githin George
le 20 Déc 2023
Hello Josiah,
It is my understanding that you are trying to replicate the “ActionPreCallback” and “ActionPostCallback” functionality of “pan” action for a MATLAB “uiaxes” like that of a MATLAB “axis” object.
You can use the following workaround to add a listener to the “PreSet” and “PostSet” event for properties like “XLim” or “YLim” of the “uiaxes”. Since these properties are set during a “pan” action, you will be able to implement the logic within the listener functions. An example code is provided below.
function startupFcn(app)
addlistener(app.UIAxes, 'YLim', 'PostSet', @(src,evnt)postFun(src,evnt,app));
addlistener(app.UIAxes, 'YLim', 'PreSet', @(src,evnt)preFun(src,evnt,app));
end
Note that the above workaround requires the listener functions to be external to the application.
Please refer to the documentation link for “addlistener” function below.
I hope this helps.
0 commentaires
Voir également
Catégories
En savoir plus sur Specifying Target for Graphics Output dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!