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

조회 수: 6 (최근 30일)
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!

채택된 답변

Veronica Taurino
Veronica Taurino 2021년 6월 17일
편집: Veronica Taurino 2021년 6월 17일
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

추가 답변 (1개)

Veronica Taurino
Veronica Taurino 2021년 5월 23일
Any suggestion?

카테고리

Help CenterFile Exchange에서 Data Exploration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by