How to terminate drawline() with a buttonPushedCallback?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
zhehao.nkd
am 12 Jun. 2021
Kommentiert: zhehao.nkd
am 21 Jun. 2021
I would like to repeat the drawline command for selecting multiple ROIs in a figure axes, and I hope to stop the while-loop after I press a stop button in the mlapp GUI. For this purpose, I used a stopButtonPushed callback to change the app.stopstate. But the problem is that, the drawline command will have been excuted after I press the stop button, so I have to draw an extract ROI before it stops.
Is there any way to solve this problem, like killing the running process? Thank you for your help!
(1) The multple ROIs I selected by repeating drawline()
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/650400/image.png)
(2) Part of my code related to this question
app.stopstate = 0;
while true
if app.stopstate == 1
app.stopstate = 0;
break
end
app.en = app.en + 1;
app.element{app.en} = drawline(app.UIAxes,'Color',color,'Deletable',true);
drawnow;
end
function stopButtonPushed(app, event)
app.stopstate = 1;
end
0 Kommentare
Akzeptierte Antwort
Aghamarsh Varanasi
am 15 Jun. 2021
Hi
You can use the keyboard shortcut 'Esc' key to cancel the drawing of a line while using the 'drawline' function. In your case, you can click on the GUI button to break from the while loop and click 'Esc' to cancel the extra line that you need to draw. However, cancelling the 'drawline' function returns an ROI object with empty 'Position' field, which can be filtered out easily.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!