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

 Respuesta aceptada

Matt J
Matt J el 29 de Abr. de 2024

0 votos

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 comentario

Hamid
Hamid el 30 de Abr. de 2024
Thanks Matt for the answer. it worked great

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Preguntada:

el 29 de Abr. de 2024

Comentada:

el 30 de Abr. de 2024

Community Treasure Hunt

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

Start Hunting!

Translated by