Skip to content
Snippets Groups Projects
updateTsgStructWithUndoLevels.m 1.86 KiB
Newer Older
alory's avatar
alory committed
function updateTsgStructWithUndoLevels(hMainFig)
%
% This function is called after change option/parameter from preferenceForm
% or tsg_initialisation
%
% Input
% -----
% hMainFig ............ Handle to the main user interface
%
% $Id$


% Get the data from the application GUI
% -------------------------------------
tsg = getappdata( hMainFig, 'tsg_data');

% Number of QC history levels for UNDO function
% ---------------------------------------------
new_qc_history_size = str2double(tsg.preference.qc_history_size);

if isfield(tsg,'qc_history_size')
jacques.grelet_ird.fr's avatar
jacques.grelet_ird.fr committed
  
  if new_qc_history_size ~= tsg.qc_history_size
alory's avatar
alory committed
    
jacques.grelet_ird.fr's avatar
jacques.grelet_ird.fr committed
    % Modify size of QC history array if already created
    % --------------------------------------------------
    if ~isempty(tsg.qc_history_state)
      
      if new_qc_history_size > tsg.qc_history_size
alory's avatar
alory committed
        
jacques.grelet_ird.fr's avatar
jacques.grelet_ird.fr committed
        tsg.qc_history_state = cat(2, tsg.qc_history_state,...
          int8(zeros(size(tsg.SSPS_QC,1),...
          (new_qc_history_size-tsg.qc_history_size))));
        
      else
        
        if (tsg.qc_history_size-tsg.qc_history_pointer) >= (tsg.qc_history_size-new_qc_history_size)
          
          tsg.qc_history_state = tsg.qc_history_state(:,1:new_qc_history_size);
          tsg.qc_redo_possible = max(0,...
            tsg.qc_redo_possible-(tsg.qc_history_size-new_qc_history_size));
          
        else
          
          tsg.qc_history_state = tsg.qc_history_state(:,...
            (1+tsg.qc_history_pointer-new_qc_history_size):tsg.qc_history_pointer);
          tsg.qc_history_pointer = size(tsg.qc_history_state,2);
          tsg.qc_redo_possible = 0;
          set(findobj('tag','UIMENU_REDO'),'enable','off');
jacques.grelet_ird.fr's avatar
jacques.grelet_ird.fr committed
          
alory's avatar
alory committed
        end
        
jacques.grelet_ird.fr's avatar
jacques.grelet_ird.fr committed
      end
      
alory's avatar
alory committed
    end
    
jacques.grelet_ird.fr's avatar
jacques.grelet_ird.fr committed
  end
  
alory's avatar
alory committed
end

tsg.qc_history_size = str2double(tsg.preference.qc_history_size);

% Save tsg structure
% ------------------
setappdata( hMainFig, 'tsg_data', tsg);

end