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

 Réponse acceptée

Matt J
Matt J le 29 Avr 2024

0 votes

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 commentaire

Hamid
Hamid le 30 Avr 2024
Thanks Matt for the answer. it worked great

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by