view m-toolbox/m/gui/gltpda/g_ApplyButtonCallback.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
line wrap: on
line source

function g_ApplyButtonCallback(hObject,varargin)
   % Whenever the user clicks on the 'Apply' button.
   
   global params paramEnabled oldparams oldparamEnabled selBlocks
   
   % If it's executed automacally (upon button deletion), check whether
   % there's something to apply or not:
   if (nargin>2 && strcmp(get(hObject,'enable'),'off')) || (isempty(params) && isempty(oldparams)), return; end
   
   % This is to update the old params with those currently stored into
   % the block:
   temp1 = paramEnabled;
   temp2 = params;
   paramcommand = get_param(gcbh,'Description');
   eval(paramcommand) % This overwrites also the current 'paramEnabled'
   oldparamEnabled = paramEnabled;
   paramEnabled = temp1;
   oldparams = params;
   params = temp2;
   clear temp1 temp2
   
   % Now to update the block with the latest changed params:
   paramcommand = g_BuildParamCommand(params);
   for kk=1:length(selBlocks)
      try set_param(selBlocks(kk),'Description',paramcommand); catch, end
   end
   g_AnnotationUpdate(params);
   
   try set(hObject,'enable','off'); catch, end
   
   % Redraw the panel only if the user hasn't changed selection or
   % clicked on a different tab:
   if nargin>2 && varargin{2}, selBlocks = nan; end
   
end