How do you implement 'AddingVertex' event callback
이전 댓글 표시
I have been using app designer to open an image and then use the drawpolyline function to create an roi. However, I want to add a callback function to prevent the user from trying to add a vertex outside of the drawing area (even though I specify drawing area, a click outside of the drawing area results in a vertex on the perimeter).
I tried adding the code as shown below but it never goes into the callback function. I've tried with other events and the only ones I can get to work are from the 'images.roi.ROIMovingEventData' event class. What am I missing?
% draw: the main drawing method to allow for selecting and drawing
% annotations
function draw(app)
% Start drawing the polyline
try
% Draw a polyline
roi = drawpolyline("Parent", app.UIAxes);
app.roi_position = roi.Position;
catch
% The polyline is getting drawn in the LayerButton function
% and there is no need the data for this roi.
end
addlistener(roi,'VertexAdded',@(src,evt) recallPositionInUserData(src,evt));
function recallPositionInUserData(src,~)
src.Position = src.UserData;
end
end
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 ROI-Based Processing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!