diff --git a/src/gui_determ_simulation.m b/src/gui_determ_simulation.m index 1f1ef0e8f6f90706e255c82acee17027dc7dfbfd..8cd4a385a3d28668b103845e1e0052c4160747b5 100644 --- a/src/gui_determ_simulation.m +++ b/src/gui_determ_simulation.m @@ -105,43 +105,38 @@ handles.simul = uicontrol( ... 'TooltipString', comm_str, ... 'HorizontalAlignment', 'left'); -% --- Check Boxes ------------------------------------- -uicontrol( ... +% --- Radio Buttons ------------------------------------- +handles.buttongroup = uibuttongroup( ... 'Parent', tabId, ... + 'Position', [0.62 0.88 0.36 0.05], ... + 'Units', 'normalized', ... + 'SelectionChangedFcn', {@init_val, handles}); + +uicontrol(handles.buttongroup, ... 'Style', 'text', ... - 'BackgroundColor', bg_color, ... 'Units', 'normalized', ... - 'Position', [0.62 0.88 0.48 0.05], ... + 'Position', [0 -.2 1 1], ... 'FontWeight', 'bold', ... - 'String', 'Use initial values from...', ... + 'String', 'Initial value: ', ... 'HorizontalAlignment', 'left'); -handles.steadystate = uicontrol( ... - 'Parent', tabId, ... - 'Style', 'checkbox', ... +uicontrol(handles.buttongroup, ... + 'Style', 'radiobutton', ... + 'String', 'zero', ... + 'Units', 'normalized', ... + 'Position', [0.2 0 1 1]); + +uicontrol(handles.buttongroup, ... + 'Style', 'radiobutton', ... 'String', 'steady state', ... 'Units', 'normalized', ... - 'Position', [0.72 0.89 0.48 0.05], ... - 'Value', 0, ... - 'Callback', @steady_state_init_val); + 'Position', [0.3 0 1 1]); -handles.smoother = uicontrol( ... - 'Parent', tabId, ... - 'Style', 'checkbox', ... +uicontrol(handles.buttongroup, ... + 'Style', 'radiobutton', ... '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); + 'Position', [0.5 0 1 1]); % --- PUSHBUTTONS ------------------------------------- handles.pushbuttonSimulation = uicontrol( ... @@ -549,41 +544,25 @@ handles.pushbuttonCommandDefinition = uicontrol( ... % return as JSON string json = savejson('', json, 'ParseLogical', 1, 'FileName', '', 'ArrayIndent', 0); end +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; +function init_val(~, evt, handles) +global oo_ +if strcmp(evt.NewValue.String, 'zero') + handles.endoTable.Data(:,3) = num2cell(zeros(M_.orig_endo_nbr, 1)); +elseif strcmp(evt.NewValue.String, 'steady state') + if ~isfield(oo_, 'steady_state') + gui_tools.show_warning('Must first calculate the steady state') + evt.OldValue.Value = 1; + return 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; + handles.endoTable.Data(:,3) = num2cell(oo_.steady_state); +elseif strcmp(evt.NewValue.String, 'smoother') + if ~isfield(oo_, 'SmoothedVariables') + gui_tools.show_warning('Must first run smoother') + evt.OldValue.Value = 1; + return end + handles.endoTable.Data(:,3) = num2cell(oo_.SmoothedVariables); end +end \ No newline at end of file