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

 採用された回答

Matt J
Matt J 2024 年 4 月 29 日

0 投票

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 件のコメント

Hamid
Hamid 2024 年 4 月 30 日
Thanks Matt for the answer. it worked great

サインインしてコメントする。

その他の回答 (0 件)

質問済み:

2024 年 4 月 29 日

コメント済み:

2024 年 4 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by