Does `uiopen('p​ath\to\pic​.fig')` reset the user modified toolbars?

24 次查看(过去 30 天)
I wrote a GUI program. It saved figures automatically by certain rules. For convenience I changed some toolbars of the figure, and they worked just fine when the figure was created. But when that figure was closed and reopened using uiopen('\path\to\pic.fig'), the modified toolbars functioned as the default ones.
So does uiopen just reset the toolbars? Is it possible to save the modified toolbars with figure permanently?
Here is a example of my script.
f = figure;
mesh(peaks);
legend('test');
f.UserData.pic_name = 'peaks_test';
f.UserData.pic_path = '.';
f.UserData.fig_path = 'fig'; % make sure the folder 'fig' exist
function auto_save_figure(fig)
ftb = findall(fig, 'Tag', 'FigureToolBar');
ftbs = findall(ftb);
h1 = findobj(ftbs, 'Tag', 'Standard.NewFigure');
h2 = findobj(ftbs, 'Tag', 'Standard.FileOpen');
h3 = findobj(ftbs, 'Tag', 'Standard.PrintFigure');
h4 = findobj(ftbs, 'Tag', 'DataManager.Linking');
set([h1, h2, h3], 'Enable', 'off');
set(h4, 'Enable', 'off');
save_fig = findobj(ftbs, 'Tag', 'Standard.SaveFigure');
save_fig.ClickedCallback = @auto_save; % when the user modified the figure, like legend, title, etc.
% the previous "save" button would save the changes automatically.
end
function auto_save(hObj, ~)
resolution = '-r160';
fig = ancestor(hObj, 'figure');
pic_name = fig.UserData.pic_name;
pic_path = fig.UserData.pic_path;
fig_path = fig.UserData.fig_path;
print(fig, fullfile(pic_path, [pic_name, '.png']), '-dpng', resolution);
saveas(fig, fullfile(pic_path, fig_path, [pic_name, '.fig']));
end

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Colormaps 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by