moving two roi's together

trying to move a circle roi and a crosshair roi together. when I move the circle I can move the the crosshair by having the drawcrosshair in the addlistener callback. however the previous one remains. Is there any way to make a group from two roi's so both are moved together?
here is what I have:
hROI = drawcircle('Center',[x, y],'Radius',radius);
l = addlistener(hROI, 'MovingROI', @allevents);
function allevents(src,evt)
evname = evt.EventName;
switch(evname)
case {'MovingROI'}
roiCH = drawcrosshair('Position', evt.CurrentCenter, 'StripeColor','r', InteractionsAllowed = 'none');
end
end

 Accepted Answer

hROI = drawcircle('Center',[x, y],'Radius',radius);
roiCH = drawcrosshair('Position', [x,y], ...
'StripeColor','r', InteractionsAllowed = 'none');
l = addlistener(hROI, 'MovingROI', @(s,e) allevents(s,e,roiCH));
function allevents(src,evt,roiCH)
switch evt.EventName
case {'MovingROI'}
roiCH.Position=evt.CurrentCenter;
end
end

1 Comment

Thanks Matt for the answer. it worked great

Sign in to comment.

More Answers (0)

Asked:

on 29 Apr 2024

Commented:

on 30 Apr 2024

Community Treasure Hunt

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

Start Hunting!