function buttonacceptcurrentaPGA(hObject, eventdata, Empty_Button, Buttons, AxesD, AxesSVD, AxesSOL, AxesAOM, lcs, LCS, rbplotsvd, Recondition, RegSlider, RegText, usmn, usmf)
data = get(Empty_Button,'UserData');

if (isfield(data,'issol') == 1) && (data.issol == 1)
    
    s = data.noc+1;
    data.noc = s;
    
    data.SOL(s).xbd = data.xbd;
    data.SOL(s).ifir = data.ifir;
    data.SOL(s).ilas = data.ilas;
    data.SOL(s).isamp = data.isamp;
    data.SOL(s).ampl = data.ampl;
    data.SOL(s).novctrs = data.novctrs;
    data.SOL(s).U = data.U(:,1:data.novctrs);
    data.SOL(s).S = diag(data.S(1:data.novctrs,1:data.novctrs));
    data.SOL(s).V = data.V(:,1:data.novctrs);
    data.SOL(s).a = data.a;
    data.SOL(s).c = data.c;
    data.SOL(s).t = data.t;
    data.SOL(s).W = data.W;
    data.SOL(s).y = data.y;
    
    data.isSOL = 1;
    
    if data.isamp
        plot(AxesSOL, data.x, data.a*diag(data.ampl), 'r--', 'Linewidth',1);
        hold(AxesSOL, 'on');
        
        plot(AxesSOL, data.x, data.a, 'k', 'Linewidth',2);
        hold(AxesSOL, 'off');
        
        legend(AxesSOL, 'amplified data', 'regular data');
    else
        
        plot(AxesSOL, data.x, data.a, 'k', 'Linewidth',2);
    end
    
    axis(AxesSOL,'tight');
    yl = get(AxesSOL,'ylim');
    yl = [min(0,yl(1)), yl(2)*1.1];
    set(AxesSOL,'ylim',yl);
    xlabel(AxesSOL,'channel');
    
    plot(AxesAOM(1),0,0,'w');
    set(AxesAOM(1), 'XTick', [], 'YTick', []);
    
    for i=1:s
        plot(AxesAOM(2), data.x, data.SOL(i).a, 'color', lcs(mod(i-1,size(lcs,1))+1,:),'Linewidth',1);
        hold(AxesAOM(2), 'on');
    end
    hold(AxesAOM(2), 'off');
    axis(AxesAOM(2),'tight');
    yl = get(AxesAOM(2),'ylim');
    yl = [min(0,yl(1)), yl(2)*1.1];
    set(AxesAOM(2),'ylim',yl, 'XTick', [], 'YTick', []);
    
    lc = [];
    lcf = [];
    yl = [inf, -inf];
    for i=1:s
        lc(i,:) = lcs(mod(i-1,size(lcs,1))+1,:);
        lcf(i,:) = LCS(mod(i-1,size(lcs,1))+1,:);
        
        yl = [min(yl(1), min(data.SOL(i).a)), max(yl(2), max(data.SOL(i).a))];
    end
    yl = [min(0,yl(1)), yl(2)*1.1];
    
    lgntxt = {};
    axes(AxesSOL);
    for i=1:s
        if data.SOL(i).xbd(1) < data.SOL(i).xbd(2)
            fill(data.SOL(i).xbd([1 2 2 1 1]), yl([1 1 2 2 1]), lcf(i,:));
            lgntxt{i} = [num2str(round(data.SOL(i).xbd(1))),' - ',num2str(round(data.SOL(i).xbd(2)))];
        else
            plot(data.SOL(i).xbd([1 1]),yl([1 2]),'color',lcs(mod(i-1,6)+1,:));
            lgntxt{i} = num2str(round(data.SOL(i).xbd(1)));
        end
        hold(AxesSOL, 'on');
    end
    for i=1:s
        plot(AxesSOL, data.x, data.SOL(i).a, 'color', lc(i,:),'Linewidth',2);
    end
    hold(AxesSOL, 'off');
    lgn = legend(AxesSOL,lgntxt);
    set(lgn,'fontsize',12);
        
    set(AxesSOL, 'Xlim', [min(data.x), max(data.x)], 'ylim',yl);
    xlabel(AxesSOL,'channel');
    title(AxesSOL, 'All spectra');
    
    if data.isamp == 1
        data.issvd = 0;
        data.isamp = 0;
        
        set(rbplotsvd(1), 'Value', 0);
        set(rbplotsvd(2), 'Value', 0);
        set(rbplotsvd(3), 'Value', 1);
        
        plot(AxesSVD,1,0,'w');
    end
    
    plot(AxesD,data.x,data.D','k');
    axis(AxesD,'tight');
    yl = get(AxesD,'ylim');
    yl = [min(0,yl(1)), yl(2)*1.1];
    set(AxesD,'ylim',yl);
    xlabel(AxesD,'channel');
    
    set(RegText(8), 'Enable', 'on');
    set(RegText(28), 'Enable', 'on');
    set(RegText(67), 'Enable', 'on');
    set(RegSlider(8), 'Enable', 'on');
    set(Buttons(12), 'Enable', 'on');
    set(Recondition(9), 'Enable', 'on');
    set(Recondition(10), 'Enable', 'on');
    
    set(RegSlider(9), 'Enable', 'on');
    set(RegText(9), 'Enable', 'on');
    set(RegText(29), 'Enable', 'on');
    
%     set(RegSlider(8), 'Value', 0);
%     set(RegText(28), 'String', '0');
    set(Recondition(4),'String','missing','ForegroundColor','r');
    set(Recondition(10),'String','nonrelevant','ForegroundColor','k');
    
    
    onoffButton(Buttons,[7:10 14 16 19],[4:5 12]);
    set(hObject,'BackgroundColor',0.94*[1 1 1]);
    set(hObject, 'Enable', 'off');
    
%     data.isgivenspec = 0;
%     data.givenspec = [];
    
    data.isbd = 0;
    data.issol = 0;
    
    data.isred = 0;
    data.issol = 0;
    data.islive = 0;
    data.livet = [];
    set(usmn,'Value',0);
    set(usmf,'Value',1);
    SliderOnOffPGA(RegSlider, RegText, data, 0);
    
    text(AxesD,0.5,0.7,data.peakhint,'Color',[1 0.7 0.6],'FontSize',18,'Units','normalized','HorizontalAlignment', 'center');
    hold(AxesD, 'off');
    pause(0.02);
    
    set(Empty_Button,'UserData',data);
    %%
    buttoncomputeCPGA([], [], Empty_Button, Buttons, [], AxesAOM, lcs, RegSlider, RegText)
%     set(Buttons(10),'BackgroundColor',0.8*[1 1 1])
    %%
elseif (isfield(data,'isautosol') == 1) && (data.isautosol == 1)
    for i=1:data.new
        data.SOL(data.noc+i).xbd(1:2) = data.x(data.final(i))*[1 1];
        data.SOL(data.noc+i).ifir = data.final(i);
        data.SOL(data.noc+i).ilas = data.final(i);
        data.SOL(data.noc+i).isamp = 0;
        data.SOL(data.noc+i).ampl = [];
        data.SOL(data.noc+i).novctrs = data.novctrs;
        data.SOL(data.noc+i).U = data.U(:,1:data.novctrs);
        data.SOL(data.noc+i).S = diag(data.S(1:data.novctrs,1:data.novctrs));
        data.SOL(data.noc+i).V = data.V(:,1:data.novctrs);
        data.SOL(data.noc+i).a = data.ainter(i,:)/max(data.ainter(i,:));
        vstar = data.V(data.final(i),1:data.novctrs)'/data.ainter(i,data.final(i));
        data.SOL(data.noc+i).c = data.U*data.S(:,1:data.novctrs)*vstar;
        data.SOL(data.noc+i).t = data.tinter;
        data.SOL(data.noc+i).W = data.W(i,:);
        data.SOL(data.noc+i).y = data.yinter(i,:)';
    end
    
    s = data.noc+length(data.final);
    data.noc = s;
    
    data.isSOL = 1;
    
    if size(data.ainter,1)>0
        plot(AxesSOL, data.x, data.ainter, 'k', 'Linewidth',2);
        axis(AxesSOL,'tight');
        yl = get(AxesSOL,'ylim');
        yl = [min(0,yl(1)), yl(2)*1.1];
        set(AxesSOL,'ylim',yl);
        xlabel(AxesSOL,'channel');
    end
    
    plot(AxesAOM(1),0,0,'w');
    set(AxesAOM(1), 'XTick', [], 'YTick', []);
    
    for i=1:s
        plot(AxesAOM(2), data.x, data.SOL(i).a, 'color', lcs(mod(i-1,size(lcs,1))+1,:),'Linewidth',1);
        hold(AxesAOM(2), 'on');
    end
    hold(AxesAOM(2), 'off');
    axis(AxesAOM(2),'tight');
    yl = get(AxesAOM(2),'ylim');
    yl = [min(0,yl(1)), yl(2)*1.1];
    set(AxesAOM(2),'ylim',yl, 'XTick', [], 'YTick', []);
    
    lc = [];
    lcf = [];
    yl = [inf, -inf];
    for i=1:s
        lc(i,:) = lcs(mod(i-1,size(lcs,1))+1,:);
        lcf(i,:) = LCS(mod(i-1,size(lcs,1))+1,:);
        
        yl = [min(yl(1), min(data.SOL(i).a)), max(yl(2), max(data.SOL(i).a))];
    end
    yl = [min(0,yl(1)), yl(2)*1.1];
    
    lgntxt = {};
    axes(AxesSOL);
    for i=1:s
        if data.SOL(i).xbd(1) < data.SOL(i).xbd(2)
            fill(data.SOL(i).xbd([1 2 2 1 1]), yl([1 1 2 2 1]), lcf(mod(i-1,6)+1,:));
            lgntxt{i} = [num2str(round(data.SOL(i).xbd(1))),' - ',num2str(round(data.SOL(i).xbd(2)))];
        else
            plot(data.SOL(i).xbd([1 1]),yl([1 2]),'color',lcs(mod(i-1,6)+1,:));
            lgntxt{i} = num2str(round(data.SOL(i).xbd(1)));
        end
        hold(AxesSOL, 'on');
    end
    for i=1:s
        plot(AxesSOL, data.x, data.SOL(i).a, 'color', lc(i,:),'Linewidth',2);
    end
    hold(AxesSOL, 'off');
    lgn = legend(AxesSOL,lgntxt);
    set(lgn,'fontsize',12);
    set(AxesSOL, 'Xlim', [min(data.x), max(data.x)], 'ylim',yl);
    xlabel(AxesSOL,'channel');
    title(AxesSOL, 'All spectra');
    
    if data.isamp == 1
        data.issvd = 0;
        data.isamp = 0;
        
        set(rbplotsvd(1), 'Value', 0);
        set(rbplotsvd(2), 'Value', 0);
        set(rbplotsvd(3), 'Value', 1);
        
        plot(AxesSVD,1,0,'w');
    end
    
    plot(AxesD,data.x,data.D','k');
    axis(AxesD,'tight');
    yl = get(AxesD,'ylim');
    yl = [min(0,yl(1)), yl(2)*1.1];
    set(AxesD,'ylim',yl);
    xlabel(AxesD,'channel');
    text(AxesD,0.5,0.7,data.peakhint,'Color',[1 0.7 0.6],'FontSize',18,'Units','normalized','HorizontalAlignment', 'center');
    hold(AxesD, 'off');
    pause(0.02);
    
    set(RegText(8), 'Enable', 'on');
    set(RegText(28), 'Enable', 'on');
    set(RegText(67), 'Enable', 'on');
    set(RegSlider(8), 'Enable', 'on');
    set(Buttons(12), 'Enable', 'on');
    set(Recondition(9), 'Enable', 'on');
    set(Recondition(10), 'Enable', 'on');
    
    set(RegSlider(9), 'Enable', 'on');
    set(RegText(9), 'Enable', 'on');
    set(RegText(29), 'Enable', 'on');
    
%     set(RegSlider(8), 'Value', 0);
%     set(RegText(28), 'String', '0');
    set(Recondition(4),'String','missing','ForegroundColor','r');
    set(Recondition(10),'String','nonrelevant','ForegroundColor','k');
    
    onoffButton(Buttons,[7:10 14 16 19],[4:5 12]);
    set(Buttons(17),'BackgroundColor',0.94*[1 1 1]);
    set(hObject, 'Enable', 'off');
    
%     data.isgivenspec = 0;
%     data.givenspec = [];
    
    data.isbd = 0;
    data.issol = 0;
    data.isautosol = 0;
    
    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);
    buttoncomputeCPGA([], [], Empty_Button, Buttons, [], AxesAOM, lcs, RegSlider, RegText)
end
