How link Zoom view for 3D plots belonging to a Tab (linkprop does not work?)

6 vues (au cours des 30 derniers jours)
Hi! I have several 3D plots inside a Tab. I need to link their view in zoom, pam and rotation when I tick a checkbox. I can't make it work for the zoom and the pam... I need the zoom to work with the mouse scroll. Could you suggest me how to solve it?
My code is something like this:
hTabGroup = uitabgroup;
hTabGroup.Parent.Name='Output visualization';
hTabGroup.Parent.NumberTitle='off';
drawnow;
numFaces = 600;
[x,y,z] = sphere(numFaces);
name = {'aa','bb'};
%% Plot
for iFig = 1:2
tab = uitab(hTabGroup, 'title',name{iFig});
tab_all{iFig} = tab;
a = axes('parent', tab_all{iFig});
axes_all(iFig) = a;
pc(iFig)=pcshow([x(:),y(:),z(:)],'Parent',a);
drawnow; pause(0.05);
if iFig == 1 %fig1
p = uipanel(tab_all{iFig},'Position',[0.05 0.85 0.28 0.13],'Title','Image Setup','FontSize',11,'BackgroundColor','k','ForegroundColor','w');
c4 = uicontrol('Parent', p, 'Style', 'checkbox','units', 'normalized','Position',[0.5521 0.52 0.40 0.20],'BackgroundColor','k','ForegroundColor','w','Callback',@linkView);
else %fig2
p = uipanel(tab_all{iFig},'Position',[0.05 0.75 0.28 0.23],'Title','Image Setup','FontSize',11,'BackgroundColor','k','ForegroundColor','w');
c4 = uicontrol('Parent', p, 'Style', 'checkbox','units', 'normalized','Position',[0.5521 0.1 0.40 0.20],'BackgroundColor','k','ForegroundColor','w','Callback',@linkView);
end
end
%% Callback Link views
function linkView(hObject,~,~)
value = get(hObject,'Value');
n_tab=length(hObject.Parent.Parent.Parent.Children); %n_tabs
% Axes
for ii=1:n_tab
ax_tab(ii)=hObject.Parent.Parent.Parent.Children(ii).Children(end);
end
if value == 1 % enable Link if checkbox filled
Link = linkprop([ax_tab(:)],{'CameraUpVector', 'CameraPosition', 'CameraTarget', 'XLim', 'YLim', 'ZLim'});
setappdata(gcf, 'StoreTheLink', Link);
handleCheck=findobj(gcf,'Style','checkbox');
set(handleCheck(:), 'Value',1)
else % disable Link
Link = getappdata(gcf,'StoreTheLink') ;
Link.Enabled = 'off';
handleCheck=findobj(gcf,'Style','checkbox');
set(handleCheck(:), 'Value',0)
end
end
Thank you!

Réponse acceptée

Veronica Taurino
Veronica Taurino le 17 Juin 2021
Modifié(e) : Veronica Taurino le 17 Juin 2021
I got the problem, I solved reading this:
So I just modified the callback:
%% Callback Link views
function Link = linkView(hObject,~,~)
value = get(hObject,'Value');
n_tab=length(hObject.Parent.Parent.Parent.Children); %n_tabs
% Axes
for ii=1:n_tab
ax_tab(ii)=hObject.Parent.Parent.Parent.Children(ii).Children(end);
end
if value == 1 % enable Link if checkbox filled
Link = linkprop([ax_tab(:)],{'CameraUpVector', 'CameraPosition', 'CameraTarget', 'XLim', 'YLim', 'ZLim'});
setappdata(gcf, 'StoreTheLink', Link);
handleCheck=findobj(gcf,'Style','checkbox');
set(handleCheck(:), 'Value',1)
else % disable Link
Link = getappdata(gcf,'StoreTheLink') ;
Link.Enabled = 'off';
handleCheck=findobj(gcf,'Style','checkbox');
set(handleCheck(:), 'Value',0)
end
end

Plus de réponses (1)

Veronica Taurino
Veronica Taurino le 23 Mai 2021
Any suggestion?

Catégories

En savoir plus sur Data Exploration dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by