function liveviewPGA(hObject, eventdata, Empty_Button, Buttons, RegText, RegSlider, AxesSOL, AxesAOM, calcp)
data = get(Empty_Button,'UserData');

if (isfield(data,'islive')*isfield(data,'issol') == 1) && (data.islive*data.issol == 1)
    data.issol = 0;
    
    [k,n] = size(data.D);
    ifir = data.ifir;
    ilas = data.ilas;
    isgs = data.isgivenspec;
    
    givenadaptedis = data.givenadaptedis;
    
    if isfield(data,'noc') == 1
        noc = data.noc;
        A = [];
        for i=1:data.noc
            A = [A; data.SOL(i).a];
        end
    else
        noc = 0;
        A = 0;
    end
    
    z   = data.novctrs;
    L   = data.U*data.S(:,1:z);
    S   = diag(data.S(1:z,1:z));
    R   = data.V(:,1:z)';
    
    nw = 6;
    for i=1:nw
        W(i) = get(RegSlider(3+i), 'Value');
        if (i>1) && (abs(W(i)-get(RegSlider(3+i), 'Min')) < 1.E-14)
            W(i) = -1;
        end
    end
    
    if data.isred == 0
        t0 = data.t(2:end)';
    else
        t0 = data.t';
    end
    
    actpwd = pwd;
    cd(calcp);
    
    dlmwrite('wrap/t0.txt',t0,'precision','%15.15e','delimiter',' ');
    dlmwrite('wrap/W.txt',W,'precision','%15.15e','delimiter',' ');
    
    arch = computer('arch');
    
    fprintf(' C routine (PeakGroupAnalysis) in live view mode ... (press CTRL + C to cancel) ... ');
    
    opt = 2;
    opt2 = 0;     % 0 fuer nl2sno, 1 fuer nl2sol
    
    if (strcmp(arch,'maci64') == 1) || (strcmp(arch,'maca64') == 1)
        system(['./PeakGroupAnalysisM64.exe ',num2str(opt),' 1']);
    if (strcmp(arch,'win32') == 1) || (strcmp(arch,'win64') == 1)
        system(['PeakGroupAnalysisW32.exe ',num2str(opt),' ',num2str(opt2)]);
%     elseif strcmp(arch,'glnx86') == 1
%         system(['./PeakGroupAnalysisU32.exe ',num2str(opt),' 1']);
    elseif strcmp(arch,'glnxa64') == 1
        system(['./PeakGroupAnalysisU64.exe ',num2str(opt),' ',num2str(opt2)]);
    else
        fprintf(2,'No executable version for this type of system.\n');
        cd(actpwd);
        return;
    end
    
    tim = [];
    tim = load('wrap/tim.txt');
    
    if tim(1) < 1
        fprintf('computation canceled.\n');
        return;
    else
        tim = tim(2);
    end
    
    data.timeFAC = data.timeFAC+tim;
    
    fprintf('ready, time: %2.2f s.\n',tim);
    
    results = load('wrap/results.txt');
    t = results(1:z)';
    y = results(z+1:z+nw);
    a = t*R;
    vs = R(:,ifir:ilas)*a(ifir:ilas)'/(a(ifir:ilas)*a(ifir:ilas)');
    
    cd(actpwd);
    
    for i=1:nw
        set(RegText(43+i), 'String', [num2str(100*y(i),3) '%']);
    end
    
    data.W = W;
    data.y = 100*y;
    
    data.t = t;
    data.a = a;
    data.c = L*vs;
    
    if data.isamp
        plot(AxesSOL, data.x, data.a/max(data.a), 'r--', 'Linewidth',1);
        hold(AxesSOL, 'on');
        
        data.a = data.a*diag(1./data.ampl);
        data.a = data.a/max(data.a);
        
        plot(AxesSOL, data.x, data.a, 'k', 'Linewidth',2);
        plot(AxesSOL, data.x(ifir:ilas), data.a(ifir:ilas), 'k','Linewidth',5,'markersize',12);
        hold(AxesSOL, 'off');
        
        legend(AxesSOL, 'amplified data', 'regular data');
        
    elseif isgs
        if givenadaptedis == 1
            plot(AxesSOL, data.x(data.givenadaptedI(1):data.givenadaptedI(2)), data.givena/max(data.givena), 'g--', 'Linewidth',1);
        else
            plot(AxesSOL, data.x, data.givena/max(data.givena), 'g--', 'Linewidth',1);
        end
        hold(AxesSOL, 'on');
        
        data.a = data.a/max(data.a);
        plot(AxesSOL, data.x, data.a, 'k', 'Linewidth',2);
        plot(AxesSOL, data.x(ifir:ilas), data.a(ifir:ilas), 'k','Linewidth',5,'markersize',12);
        hold(AxesSOL, 'off');
        
        legend(AxesSOL, 'given spectrum', 'regular data');
        
    else
        data.a = data.a/max(data.a);
        plot(AxesSOL, data.x, data.a, 'k', 'Linewidth',2);
        hold(AxesSOL, 'on');
        plot(AxesSOL, data.x(ifir:ilas), data.a(ifir:ilas), 'k','Linewidth',5,'markersize',12);
        hold(AxesSOL, 'off');
    end
    autodetect = detectallpeaks(data.x,data.a,1,ifir,ilas);
    for l=1:length(autodetect)
        text(AxesSOL,data.x(autodetect(l)),data.a(autodetect(l)),num2str(round(data.x(autodetect(l)))));
    end
    [tey,idmax] = max(data.a(ifir:ilas));
    tex = data.x(ifir+idmax)+(max(data.x)-min(data.x))/100;
    text(AxesSOL,tex,tey,num2str(round(tex)));
    hold(AxesSOL, 'off');

    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), data.x, data.a, 'k', 'Linewidth',2);
    axis(AxesAOM(1),'tight');
    yl = get(AxesAOM(1),'ylim');
    yl = [min(0,yl(1)), yl(2)*1.1];
    set(AxesAOM(1),'ylim',yl, 'XTick', [], 'YTick', []);
    
    data.issol = 1;
    
    set(Empty_Button,'UserData',data);
end
