Appdesigner: Using axes toolbar to zoom and pan while using drawpolyline without getting new points

2 次查看(过去 30 天)
Currently I am building an App in AppDesigner where I want the user to be able to draw a line on an image in an UIAxes while being able to zoom in and out and pan on the image. For the interactivity with the image I am so far relying on the standard Matlab axes toolbar. Sadly after having started a drawpolyline, every click on the image to zoom in gets me a new point for the polyline and every click to do a movement of the image also gives me a new point for the polyline.
When I try the same in Matlab with a figure it works as intended. So while using the axes toolbar during drawing a polyline no new points get added. But in AppDesigner sadly the behaviour is different. Every click from the axis toolbar gives me a new point on the polyline.
Matlab code (intended behaviour):
image(peaks,'CDataMapping','scaled','Interpolation','bilinear');
b=drawpolyline;
AppDesigner code (unintended behaviour):
function Button_4Pushed(app, event)
image(app.UIAxes_2,peaks,'CDataMapping','scaled','Interpolation','bilinear');
end
function Button2Pushed(app, event)
b=drawpolyline(app.UIAxes_2);
end
How can I prevent in AppDesigner new points being added to a polyline while I use the axes toolbar?

回答(1 个)

Gayathri
Gayathri 2024-9-17
编辑:Gayathri 2024-9-17
I understand that when trying to zoom the image or use pan in between drawing a polyline in MATLAB R2020b version, you are getting extra points on the polyline which is not desired. I was able to reproduce the issue at my end.
To resolve it, consider upgrading to MATLAB R2022a or a later version, where this issue has been addressed. In these versions, you can zoom the image without inadvertently adding extra points to the polyline.
Hope you find this information helpful.

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by