In App Designer is it possible to plot lines on top of UI components?

14 ビュー (過去 30 日間)
Cecil
Cecil 2025 年 6 月 2 日
コメント済み: Adam Danz 2025 年 6 月 16 日
I'm working on an application that ties to a Simulink model. The intent is to click two check boxes, and then a button that connects them. The connection is made between associated nodes in Simulink, and then a line is plotted on a UIAxes to show the connection. The UIAxes spans the whole app window, and pulls the positions of the checkboxes, which are built into custom UI components.
Essentially, all of this is functional already. My problem is that when the lines are plotted on the UIAxes between two checkbox elements, the lines are drawn behind UI elements within the app. This could be the custom components, or any buttons I have built into the app. Can anyone help with a way to force the UIAxes to draw on top of all other UI components?
I can incorporate some images and code if needed to clarify how the app is set up.

採用された回答

Adam Danz
Adam Danz 2025 年 6 月 2 日
> In App Designer is it possible to plot lines on top of UI components?
Lines can cross over text layers but other UI components live on a different layer. In this demo, an annotation line crosses under the checkbox, button, and image, but on top of the checkbox label and the ui-label.
fig = uifigure;
cbx = uicheckbox(fig);
uibutton(fig,Position=[190 97 85 30])
uilabel(fig,Position=[285 96 60 30],Text='label')
uiimage(fig,ImageSource=rand(5,6,3),Position=[310 92 80 36])
A = annotation(fig,'line',units='pixels',Position=[1 111, 500 0])
Sharing an image of your app may be helpful to suggest workarounds.
  5 件のコメント
Cecil
Cecil 2025 年 6 月 3 日
Adam,
Some specifics: This is an attempt to update a series of virtual lab "experiments" from Guide to App Designer. They don't run well on newer matlab releases. For example, this first experiment is a simple application of ohms law.The buttons are tied to a simulink model, and current and voltage is provided as an output if the components are connected correctly:
The way these are designed, there is a lot of hard coded resizing of images, and when you "make" a connection this happens:
I have turned all of these components into custom UI elements, and as discussed, connection two buttons causes the plot line to go behind the elements. This is an example of random lines when I tested the plotting function in my redesign in App Designer:
I suspect at this point I am going to have to revert back to how the Guide version handles this, which is to plot the background image on the UIAxes, and then add the "connection" lines to the axes. I was hoping to use modular components because there are several different equipment setups that need to be updated. My best idea to modularize this would be to proceduraly generate and place the checkboxes based on which background image is loaded into the UIAxes.
Again, thanks for the assistance!
Adam Danz
Adam Danz 2025 年 6 月 16 日
Thanks for sharing these screenshots @Cecil.
I suspect that if your design was supported in GUIDE, then it should be supported using uicontrol objects.
This page from the MATLAB documentation shows a conversion table from uicontrol objects to ui components used in App Designer. You'd be converting in the other direction.
I'll share your use case internally.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeApp Building についてさらに検索

製品


リリース

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by