diff --git a/src/gui_determ_simulation.m b/src/gui_determ_simulation.m index c584aa2907571abdc3acac87a167b6a58fffc4ea..1f1ef0e8f6f90706e255c82acee17027dc7dfbfd 100644 --- a/src/gui_determ_simulation.m +++ b/src/gui_determ_simulation.m @@ -39,43 +39,53 @@ gui_size = gui_tools.get_gui_elements_size(tabId); % --- PANELS ------------------------------------- handles.uipanelShocks = uipanel( ... 'Parent', tabId, ... - 'Tag', 'uipanelShocks','BackgroundColor', special_color,... - 'Units', 'normalized', 'Position', [0.01 0.18 0.6 0.73],... + 'Tag', 'uipanelShocks', ... + 'BackgroundColor', special_color, ... + 'Units', 'normalized', ... + 'Position', [0.01 0.18 0.6 0.73], ... 'Title', '', ... 'BorderType', 'none'); uipanelShocks_CreateFcn; handles.uipanelVars = uipanel( ... - 'Parent', tabId, 'Tag', 'uipanelVars', ... - 'UserData', zeros(1,0), 'BackgroundColor', special_color,... - 'Units', 'normalized', 'Position', [0.62 0.18 0.37 0.73], ... - 'Title', '', 'BorderType', 'none'); + 'Parent', tabId, ... + 'Tag', 'uipanelVars', ... + 'UserData', zeros(1,0), ... + 'BackgroundColor', special_color, ... + 'Units', 'normalized', ... + 'Position', [0.62 0.18 0.37 0.70], ... + 'Title', '', ... + 'BorderType', 'none'); handles = gui_tabs.create_endo_vars(handles, 'perfect_foresight'); handles.uipanelComm = uipanel( ... 'Parent', tabId, ... 'Tag', 'uipanelCommOptions', ... - 'UserData', zeros(1,0), 'BackgroundColor', bg_color, ... - 'Units', 'normalized', 'Position', [0.01 0.09 0.98 0.09], ... + 'UserData', zeros(1,0), ... + 'BackgroundColor', bg_color, ... + 'Units', 'normalized', ... + 'Position', [0.01 0.09 0.98 0.09], ... 'Title', 'Current command options:'); % --- STATIC TEXT ------------------------------------- -handles.text7 = uicontrol( ... +uicontrol( ... 'Parent', tabId, ... - 'Tag', 'text7', ... - 'Style', 'text', 'BackgroundColor', bg_color,... - 'Units','normalized','Position',[0.62 0.92 0.48 0.05],... + 'Style', 'text', ... + 'BackgroundColor', bg_color, ... + 'Units', 'normalized', ... + 'Position', [0.62 0.92 0.48 0.05], ... 'FontWeight', 'bold', ... 'String', 'Select variables for which to plot simulated trajectory:', ... 'HorizontalAlignment', 'left'); -handles.text8 = uicontrol( ... +uicontrol( ... 'Parent', tabId, ... - 'Tag', 'text8', ... - 'Style', 'text', 'BackgroundColor', bg_color,... - 'Units','normalized','Position',[0.01 0.92 0.48 0.05],... + 'Style', 'text', ... + 'BackgroundColor', bg_color, ... + 'Units', 'normalized', ... + 'Position', [0.01 0.92 0.48 0.05], ... 'FontWeight', 'bold', ... 'String', 'Define shocks on exogenous variables:', ... 'HorizontalAlignment', 'left'); @@ -88,20 +98,57 @@ comm_str = gui_tools.command_string('simul', model_settings.simul); handles.simul = uicontrol( ... 'Parent', handles.uipanelComm, ... 'Tag', 'simul', ... - 'Style', 'text', 'BackgroundColor', bg_color,... + 'Style', 'text', 'BackgroundColor', bg_color, ... 'Units', 'normalized', 'Position', [0.01 0.01 0.98 0.98], ... 'FontAngle', 'italic', ... 'String', comm_str, ... 'TooltipString', comm_str, ... 'HorizontalAlignment', 'left'); +% --- Check Boxes ------------------------------------- +uicontrol( ... + 'Parent', tabId, ... + 'Style', 'text', ... + 'BackgroundColor', bg_color, ... + 'Units', 'normalized', ... + 'Position', [0.62 0.88 0.48 0.05], ... + 'FontWeight', 'bold', ... + 'String', 'Use initial values from...', ... + 'HorizontalAlignment', 'left'); + +handles.steadystate = uicontrol( ... + 'Parent', tabId, ... + 'Style', 'checkbox', ... + 'String', 'steady state', ... + 'Units', 'normalized', ... + 'Position', [0.72 0.89 0.48 0.05], ... + 'Value', 0, ... + 'Callback', @steady_state_init_val); + +handles.smoother = uicontrol( ... + 'Parent', tabId, ... + 'Style', 'checkbox', ... + 'String', 'smoother', ... + 'Units', 'normalized', ... + 'Position', [0.79 0.89 0.48 0.05], ... + 'Value', 0, ... + 'Callback', @smoother_init_val); + +handles.zero = uicontrol( ... + 'Parent', tabId, ... + 'Style', 'checkbox', ... + 'String', 'zero', ... + 'Units', 'normalized', ... + 'Position', [0.85 0.89 0.48 0.05], ... + 'Value', 0, ... + 'Callback', @zero_init_val); % --- PUSHBUTTONS ------------------------------------- handles.pushbuttonSimulation = uicontrol( ... 'Parent', tabId, ... 'Tag', 'pushbuttonSimulation', ... 'Style', 'pushbutton', ... - 'Units','normalized','Position',[gui_size.space gui_size.bottom gui_size.button_width_small gui_size.button_height],... + 'Units','normalized','Position',[gui_size.space gui_size.bottom gui_size.button_width_small gui_size.button_height], ... 'String', 'Run Simulation', ... 'Callback', @pushbuttonSimulation_Callback); @@ -109,7 +156,7 @@ handles.pushbuttonReset = uicontrol( ... 'Parent', tabId, ... 'Tag', 'pushbuttonReset', ... 'Style', 'pushbutton', ... - 'Units','normalized','Position',[gui_size.space*2+gui_size.button_width_small gui_size.bottom gui_size.button_width_small gui_size.button_height],... + 'Units','normalized','Position',[gui_size.space*2+gui_size.button_width_small gui_size.bottom gui_size.button_width_small gui_size.button_height], ... 'String', 'Reset', ... 'Callback', @pushbuttonReset_Callback); @@ -117,7 +164,7 @@ handles.pushbuttonClose = uicontrol( ... 'Parent', tabId, ... 'Tag', 'pushbuttonReset', ... 'Style', 'pushbutton', ... - 'Units','normalized','Position',[gui_size.space*3+gui_size.button_width_small*2 gui_size.bottom gui_size.button_width_small gui_size.button_height],... + 'Units','normalized','Position',[gui_size.space*3+gui_size.button_width_small*2 gui_size.bottom gui_size.button_width_small gui_size.button_height], ... 'String', 'Close this tab', ... 'Callback',{@close_tab,tabId}); @@ -125,16 +172,16 @@ handles.pushbuttonCloseAll = uicontrol( ... 'Parent', tabId, ... 'Tag', 'pushbuttonSimulation', ... 'Style', 'pushbutton', ... - 'Units','normalized','Position',[gui_size.space*4+gui_size.button_width_small*3 gui_size.bottom gui_size.button_width_small gui_size.button_height],... + 'Units','normalized','Position',[gui_size.space*4+gui_size.button_width_small*3 gui_size.bottom gui_size.button_width_small gui_size.button_height], ... 'String', 'Close all output figures', ... - 'Enable', 'on',... + 'Enable', 'on', ... 'Callback', @pushbuttonCloseAll_Callback); handles.pushbuttonCommandDefinition = uicontrol( ... 'Parent', tabId, ... 'Tag', 'pushbuttonCommandDefinition', ... 'Style', 'pushbutton', ... - 'Units','normalized','Position',[1-gui_size.space-gui_size.button_width_small gui_size.bottom gui_size.button_width_small gui_size.button_height],... + 'Units','normalized','Position',[1-gui_size.space-gui_size.button_width_small gui_size.bottom gui_size.button_width_small gui_size.button_height], ... 'String', 'Define command options ...', ... 'Callback', @pushbuttonCommandDefinition_Callback); @@ -144,8 +191,8 @@ handles.pushbuttonCommandDefinition = uicontrol( ... handles.shocks_panel = uipanel('Parent', handles.shocks_tab, 'BackgroundColor', 'white', 'BorderType', 'none'); uicontrol( ... 'Parent', handles.shocks_panel, ... - 'Style', 'text', 'BackgroundColor', special_color,... - 'Units', 'normalized', 'Position', [0.02 0.85 0.96 0.1],... + 'Style', 'text', 'BackgroundColor', special_color, ... + 'Units', 'normalized', 'Position', [0.02 0.85 0.96 0.1], ... 'FontWeight', 'bold', ... 'String', 'Select exogenous variable for which you want to define temporary changes in the value.', ... 'HorizontalAlignment', 'left'); @@ -181,7 +228,7 @@ handles.pushbuttonCommandDefinition = uicontrol( ... 'Units', 'normalized', ... 'Position', [0.73 0.03 0.25 0.06], ... 'String', 'Remove all selected', ... - 'Enable', 'Off',... + 'Enable', 'Off', ... 'Callback', @pushbuttonRemoveValues_Callback); function pushbuttonValueChanged_Callback(hObject, ~) @@ -502,4 +549,41 @@ handles.pushbuttonCommandDefinition = uicontrol( ... % return as JSON string json = savejson('', json, 'ParseLogical', 1, 'FileName', '', 'ArrayIndent', 0); end + + function steady_state_init_val(~, evt) + if ~evt.Source.Value + return + end + if ~isfield(oo_, 'steady_state') + gui_tools.show_warning('Must first calculate the steady state') + evt.Source.Value = 0; + return + end + handles.endoTable.Data(:,3) = num2cell(oo_.steady_state); + handles.zero.Value = 0; + handles.smoother.Value = 0; + end + + function smoother_init_val(~, evt) + if ~evt.Source.Value + return + end + if ~isfield(oo_, 'SmoothedVariables') + gui_tools.show_warning('Must first run smoother') + evt.Source.Value = 0; + return + end + handles.endoTable.Data(:,3) = num2cell(oo_.SmoothedVariables); + handles.zero.Value = 0; + handles.steadystate.Value = 0; + end + + function zero_init_val(~, evt) + if ~evt.Source.Value + return + end + handles.endoTable.Data(:,3) = num2cell(zeros(M_.orig_endo_nbr, 1)); + handles.smoother.Value = 0; + handles.steadystate.Value = 0; + end end