function buttoncomputeCPGA(hObject, eventdata, Empty_Button, Buttons, AxesSOL, AxesAOM, lcs, RegSlider, RegText)
data = get(Empty_Button,'UserData');
% set(Buttons(9),'BackgroundColor',0.94*[1 1 1])
% set(Buttons(10),'BackgroundColor',0.94*[1 1 1])
% set(Buttons(8+kind),'BackgroundColor',0.8*[1 1 1])
plok = 0;
noc = 0;
if strcmp(get(hObject,'Style'),'popupmenu')
    kind = get(hObject,'Value');
else
    kind = get(Buttons(10),'Value');
end


if (isfield(data,'isSOL') == 1) && (data.isSOL == 1)
    [k,n] = size(data.D);
    
    mz = 1;
    A = [];
    for i=1:data.noc
        mz = max(mz, data.SOL(i).novctrs);
        A(i,:) = data.SOL(i).a;
        localC(:,i) = data.SOL(i).c;
    end
    noc = noc+data.noc;
    plok = 1;
end

if (isfield(data,'issol') == 1) && (data.issol == 1)
    mz = max(mz, data.novctrs);
    A(noc+1,:) = data.a;
    localC(:,noc+1) = data.c;
    noc = noc+1;
    plok = 1;
end

if plok
    if kind == 1
        data.C = localC;
    else
        T = A*data.V0(:,1:mz);
        data.C = data.U0*data.S0(:,1:mz)*pinv(T);
    end
    if ~isempty(AxesSOL)
        plot(AxesSOL, data.time, data.C, 'Linewidth',2)
        axis(AxesSOL,'tight');
        yl = get(AxesSOL,'ylim');
        yl = [min(0,yl(1)), yl(2)*1.1];
        set(AxesSOL,'ylim',yl);
        if kind == 1
            title(AxesSOL, 'All concentration profiles (local fit)');
        else
            title(AxesSOL, 'All concentration profiles (global fit)');
        end
        xlabel(AxesSOL,'time');
    end
    
    plot(AxesAOM(3), data.time, data.C, 'Linewidth',1);
    axis(AxesAOM(3),'tight');
    yl = get(AxesAOM(3),'ylim');
    yl = [min(0,yl(1)), yl(2)*1.1];
    set(AxesAOM(3),'ylim',yl, 'XTick', [], 'YTick', []);
    
    data.congloballocal = kind;
    data.iscon = 1;
    
    data.isred = 0;
%     data.issol = 0;
    data.islive = 0;
    data.livet = [];
    
%     set(usmn,'Value',0);
%     set(usmf,'Value',1);
    SliderOnOffPGA(RegSlider, RegText, data, 0);
    
    set(Empty_Button,'UserData',data);
end
