allow uimenu's also for colored graphs + better organization of userdata info

time-shift
Marco Ratto 2017-01-17 17:56:45 +01:00 committed by Stéphane Adjemian (Charybdis)
parent 4ff586247e
commit 02b3e20377
3 changed files with 34 additions and 10 deletions

View File

@ -30,17 +30,18 @@ function expand_group(use_shock_groups,var_list_, ic)
M = evalin('base','M_');
oo = evalin('base','oo_');
options = evalin('base','options_');
mydata=get(findobj(gcf,'tag',['group' int2str(ic)]),'userdata');
% define expanded group
label=M.shock_groups.(use_shock_groups).(['group' int2str(ic)]).label;
shocks=M.shock_groups.(use_shock_groups).(['group' int2str(ic)]).shocks;
label = mydata.shock_group.label;
shocks = mydata.shock_group.shocks;
options.shock_decomp.fig_names = [mydata.fig_names '_expand'];
options.use_shock_groups = strrep(label,' ','_'); %[use_shock_groups_old int2str(ic)];
for j=1:length(shocks)
M.shock_groups.(options.use_shock_groups).(['group' int2str(j)]).label=shocks{j};
M.shock_groups.(options.use_shock_groups).(['group' int2str(j)]).shocks=shocks(j);
end
options.shock_decomp.fig_names = [options.shock_decomp.fig_names '_expand'];
options.shock_decomp.interactive=0;
plot_shock_decomposition(M,oo,options,var_list_);

View File

@ -48,13 +48,19 @@ if ~isempty(opts_decomp.fig_mode)
fig_mode = [fig_mode '_'];
end
fig_names = opts_decomp.fig_names;
use_shock_groups = DynareOptions.use_shock_groups;
screen_shocks = opts_decomp.screen_shocks;
if DynareOptions.use_shock_groups | comp_nbr<=18,
if use_shock_groups | comp_nbr<=18,
screen_shocks=0;
end
if use_shock_groups
shock_groups = DynareModel.shock_groups.(use_shock_groups);
shock_ind = fieldnames(shock_groups);
end
if screen_shocks
fig_names = [fig_names '_screen'];
end
interactive = opts_decomp.interactive;
gend = size(z,3);
@ -159,10 +165,26 @@ for j=1:nvar
for i=comp_nbr:-1:1
% for i=1:comp_nbr
fill([0 0 0.2 0.2],[y1 y1+0.7*height y1+0.7*height y1],i);
hl = fill([0 0 0.2 0.2],[y1 y1+0.7*height y1+0.7*height y1],i);
hold on
text(0.3,y1+0.3*height,labels(i,:),'Interpreter','none');
ht = text(0.3,y1+0.3*height,labels(i,:),'Interpreter','none');
hold on
if interactive & (~isoctave & use_shock_groups)
mydata.fig_names = DynareOptions.shock_decomp.fig_names(2:end);
mydata.use_shock_groups = DynareOptions.use_shock_groups;
mydata.shock_group = shock_groups.(shock_ind{i});
if ~isempty(mydata.shock_group.shocks{1})
c = uicontextmenu;
hl.UIContextMenu=c;
browse_menu = uimenu(c,'Label','Browse group');
expand_menu = uimenu(c,'Label','Expand group','Callback',['expand_group(''' mydata.use_shock_groups ''',''' deblank(endo_names(i_var(j),:)) ''',' int2str(i) ')']);
set(expand_menu,'UserData',mydata,'Tag',['group' int2str(i)]);
for jmember = mydata.shock_group.shocks
uimenu('parent',browse_menu,'Label',char(jmember))
end
ht.UIContextMenu=c;
end
end
y1 = y1 + height;
end

View File

@ -164,15 +164,16 @@ for j=1:nvar
set(gca,'ylim',a0(3:4))
hold on, h1=plot(x(2:end),z1(end,:),'k-','LineWidth',2);
if interactive & (~isoctave & use_shock_groups)
mydata.fig_names = DynareOptions.shock_decomp.fig_names(2:end);
mydata.use_shock_groups = DynareOptions.use_shock_groups;
mydata.group_members = shock_groups.(shock_ind{ic}).shocks;
set(gca,'UserData',mydata);
if ~isempty(mydata.group_members{1})
mydata.shock_group = shock_groups.(shock_ind{ic});
if ~isempty(mydata.shock_group.shocks{1})
c = uicontextmenu;
hax.UIContextMenu=c;
browse_menu = uimenu(c,'Label','Browse group');
expand_menu = uimenu(c,'Label','Expand group','Callback',['expand_group(''' mydata.use_shock_groups ''',''' deblank(endo_names(i_var(j),:)) ''',' int2str(ic) ')']);
for jmember = mydata.group_members
set(expand_menu,'UserData',mydata,'Tag',['group' int2str(ic)]);
for jmember = mydata.shock_group.shocks
uimenu('parent',browse_menu,'Label',char(jmember))
end
end