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!