ROI deleted event listener

조회 수: 14 (최근 30일)
John D
John D 2019년 11월 27일
댓글: Brian Derstine 2023년 1월 10일
Is there a listener event for when an ROI has been deleted from an axes? For example, like so:
addlistener(h,'ROIDeleted',@allevents);
But this doesn't seem to work.
If not, how could I check when a ROI shape has been deleted by the user through GUIDE?
Many thanks.
  댓글 수: 6
Adam Danz
Adam Danz 2023년 1월 10일
편집: Adam Danz 2023년 1월 10일
I know what you mean @Brian Derstine about the collapsed sections. Whenever I text search a doc page, I expand all components first to make sure I don't miss something. This option is at the top, right of doc pages that contain expansion fields.
About the callbacks, note that these are not callback function. They are events.
Brian Derstine
Brian Derstine 2023년 1월 10일
ah that's a helpful tip. thanks

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

답변 (2개)

Matthew Siefring
Matthew Siefring 2022년 1월 10일
As an alternative to Adam's answer, you can use 'DeletingROI' as the event name parameter for the addListener function.
addlistener(h,'DeletingROI',@allEvents);
This way, the allEvents function will only be triggered when the user deletes the ROI interactively, instead of whenever a cleanup is triggered on the ROI object.

Adam Danz
Adam Danz 2020년 11월 2일
편집: Adam Danz 2020년 11월 2일
Use onCleanup to define a function that is evoked when the ROI is deleted. Store the onCleanup handle within the object.
Demo: Displays "ROI deleted" when the ROI object is deleted.
I = imread('baby.jpg');
figure
imshow(I)
h = images.roi.Circle(gca,'Center',[1000 1000],'Radius',500);
h.UserData.OnCleanup = onCleanup(@()allevents);
% Show figure, pause
drawnow;
pause(1)
% delete ROI obj
delete(h)
function allevents
fprintf('ROI deleted\n')
end
  댓글 수: 3
Adam Danz
Adam Danz 2020년 11월 2일
Glad I could help!
Brian Derstine
Brian Derstine 2023년 1월 9일
편집: Brian Derstine 2023년 1월 9일
Is there an undocumented "ROIDeleted" function that gets called after "DeletingROI"? I am able to run code during the DeletingROI event but no matter what I do, the polyline always gets deleted after that function finishes. I want to prevent the polyline from being deleted all at once but allow individual vertices to be deleted. One way I tried to do this was by setting the "Deletable" property to 0/false, but after doing that I can no longer delete vertices on the polyline. I can add and move vertices no problem. Do I need to override the default context menu options and manually remove the Delete Polyline option somehow?

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

카테고리

Help CenterFile Exchange에서 Build Interactive Tools에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by