I am trying to design an app using Matlab 2017b with appdesigner
. I want to attach a movable line to an image using the imline
function. However, appdesigner
appear to use a new type of object, uiaxes
, whereas the imline
function will only use the object axes
.
Example of command that does work:
figure; taxes = axes; imline(taxes, [0 0], [0 1]);
Example of a command that does not work:
figure; tuiaxes = uiaxes; imline(tuiaxes, [0 0], [0 1]);
Questions
Is there a workaround for using imline
with appdesigner? Is it still possible to use the old axes
object? Is there some other way to have interactive lines on GUIs using the appdesigner
?
To access the underlying "old axes
object" of a uiaxes
, all we need to do is struct(tuiaxes).Axes
. Moving on - I tried playing around with this in R2018b, and I have some good and some bad news.
imline
to a MATLAB figure by modifying the imline
function (<MATLAB>\R2018b\toolbox\images\imuitools\imline.m
) function a bit.Here are the very basic steps:
imline.m
, let's call it ui_imline.m
.cmenu
), and line 317 (updateAncestorListeners(...)
).Modify your code as follows:
uifigure; tuiaxes = uiaxes; ui_imline(struct(tuiaxes).Axes, [0 0], [0 1]);
This will result in:
If you want any other functionality besides dragging, you'll likely have to rewrite all uifigure-incompatible bits of imline
yourself, or wait for an unknown future release that would do it for you.