creating a line cursor in app designer

조회 수: 13 (최근 30일)
David
David 2023년 4월 30일
편집: Adam Danz 2023년 5월 15일
Hi!
assume I create a signal and show it over an UIiAxes in matlab app designer.
is there a way to create a retangle cursor or line cursor using the imaged.roi.rectangle object / imaged.roi.rectangle object ?
something like the next function:
a full code is needed, if is possible.
thanks
  댓글 수: 2
Adam Danz
Adam Danz 2023년 5월 1일
Could you elaborate on what you mean by cursor? Would the line/rectangle follow the mouse cursor?
David
David 2023년 5월 1일
Yes, If we use rectangle, i want that only the vertical lines would be dragged after the mouse ). The same for 2 lines objects.

댓글을 달려면 로그인하십시오.

답변 (1개)

Sachin
Sachin 2023년 5월 12일
Hi
I understand that you want to create a line cursor for an app designer.
You can use the Callback function in MATLAB to achieve this. There are several callback functions in MATLAB uifigure that you can help you.
  1. WindorButtonMotionFcn – This callback function executes whenever the user moves the pointer within the UI figure.
  2. ButtonDownfcn - This callback executes whenever the user clicks on the mouse button
fig = uifigure();
gl = uigridlayout(fig,[2 2]);
ax = uiaxes(gl);
hline = line(ax, [5 5], ax.YLim, 'Color', 'r');
%
fig.WindowButtonMotionFcn = @(fig, eve) btnCb(fig, eve, ax, hline);
function btnCb(~, ~, ax_up, l_h)
x = ax_up.CurrentPoint(1, 1)
if (ax_up.XLim(1) < x) && (x < ax_up.XLim(2))
l_h.XData = [x,x];
end
end
Referring to this MATLAB Answer page might be helpful to you:
Hope this helps you

카테고리

Help CenterFile Exchange에서 Develop uifigure-Based Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by