function update_quantizeparams(area_to_update,hFig)
%UPDATE_QUANTIZEPARAMS Update quantize parameters.

%   Thomas A. Bryan, 12 November 1999
%   Copyright 1988-2000 The MathWorks, Inc.
%   $Revision: 1.10 $  $Date: 2000/06/15 20:44:52 $

wrn = warning('off');
ud = get(hFig,'userdata');
% Enable all the quantization parameters before possibly changing some.
enablequantized(hFig,-1);
if isa(ud.filter,'qfilt')
  ud.filter = scalevaluefixup(ud.filter);
  ud.specs.quantize.refqfilt = ud.filter;
  set(hFig,'Userdata',ud);
  ud.specs.quantize.tempqfilt = gettempqfilt(ud);
  % If converted to sos, then the scalevalues might have changed
  % outside the callback to the scalevalues edit box.
  if strcmpi(area_to_update,'scalevalues')
    ud.specs.quantize.tempqfilt = set(ud.specs.quantize.tempqfilt,...
        'scalevalues',scalevalues(ud.filter));
  end
  % If the Quantize "apply" button has been pressed, then ud.filter
  % is the same filter as the settings on the page.  If the "apply"
  % button has not been pressed, then use the temporary qfilt.
  % qfilt2ui modifies the user data, so we must set and get ud around
  % the call to qfilt2ui.
  set(hFig,'userdata',ud);
  if ud.flags.filter_quantized,
    qfilt2ui(hFig,ud.filter);
  else
    qfilt2ui(hFig,ud.specs.quantize.tempqfilt)
  end
  ud = get(hFig,'userdata');
elseif ud.flags.filter_quantized,  
  set(hFig,'userdata',ud);
  % Changes in Quantize tab have been applied. Update the tab
  % with refqfilt.
  % qfilt2ui modifies the user data, so we must set and get ud around
  % the call to qfilt2ui.
  qfilt2ui(hFig,ud.specs.quantize.refqfilt);    
  ud = get(hFig,'userdata');
  % Synchronize temp qfilt with reference.
  ud.specs.quantize.tempqfilt = ud.specs.quantize.refqfilt;
  set(hFig,'userdata',ud);
end

if ud.mode.current==3
  % Make the quantize page visible if on quantize page
  set(findobj(hFig,'Tag','quantize_params'),'Visible','on');
end
warning(wrn)

% Set the enable state depending on the quantization switch
enablequantized(hFig);

