function plotaddsCA4(Axes1, Axes2, AxesSOL1, AxesSOL2, AFS1, AFS2, fix1, fix2, LR1, LR2, choosen1, lin1, lin2, given1, given2, linscale1,linscale2, idfix, x, y, z, lcs, lvc, lvonoff, plotopt, ok, isact, actx)

fa = 0.2;

hold(Axes1, 'on');
hold(Axes2, 'on');

if isact
    fixpts = actx;
else
    fixpts = [];
end

if sum(choosen1) >= 3
    trigls = 1;
else
    trigls = 0;
end

for i=1:4
    if choosen1(i)
        plot3(Axes1, fix1{i}.pt(1), fix1{i}.pt(2), fix1{i}.pt(3), 'x', 'color', lcs(i,:),'Linewidth',2,'Markersize',10);
        
        plot(AxesSOL1, lin1, [1 fix1{i}.pt]*LR2, 'color', lcs(i,:),'Linewidth',2);
        hold(AxesSOL1, 'on');
        
        if (get(plotopt(1), 'Value')) && (~trigls)
            axes(Axes2)
            patch(fix1{i}.complane(1,:), fix1{i}.complane(2,:), fix1{i}.complane(3,:),min(lcs(i,:)+[.7 .7 .7],[1 1 1]),'EdgeColor',lcs(i,:),'facealpha',fa);
        end
        
        if (get(plotopt(2), 'Value')) && (~trigls) && (isact)
            plot3(Axes1, [fix1{i}.pt(1) actx(1)], [fix1{i}.pt(2) actx(2)], [fix1{i}.pt(3) actx(3)], 'k', 'Linewidth',2)
            
            l = computecomplineCA4(actx*(linscale1)^(-1)*linscale2, fix1{i}.pt*(linscale1)^(-1)*linscale2, AFS2.xm, AFS2.ym, AFS2.zm);
            plot3(Axes2, l(1,:), l(2,:), l(3,:), 'k', 'Linewidth',2)
        end
        
        fixpts = [fixpts; fix1{i}.pt];
        idfix = [idfix; i];
    end
end

id = find(choosen1==1);
if length(id) >= 2
    sel = nchoosek(id,2);
    for i=1:size(sel,1)
        
        val1 = fix1{sel(i,1)}.pt*linscale1^(-1)*linscale2;
        val2 = fix1{sel(i,2)}.pt*linscale1^(-1)*linscale2;

        if (get(plotopt(2), 'Value')) && (~trigls)
            l = computecomplineCA4(val1, val2, AFS2.xm, AFS2.ym, AFS2.zm);
            plot3(Axes2, l(1,:), l(2,:), l(3,:), 'k', 'Linewidth',2);
        end
    end
end

if size(fixpts,1) == 3
    
    if get(plotopt(1), 'Value')
        axes(Axes1)
        patch(fixpts(:,1), fixpts(:,2), fixpts(:,3), min(lcs(setdiff(1:4,idfix),:)+[.7 .7 .7],[1 1 1]),'EdgeColor','k','facealpha',fa);
    elseif get(plotopt(2), 'Value')
        plot3(Axes1, fixpts(2:3,1), fixpts(2:3,2), fixpts(2:3,3), 'k','Linewidth',2);
    end
    
    pT = fixpts\[-1; -1; -1];
    pT = linscale1*pT/linscale2;
    
    plot3(Axes2, pT(1), pT(2), pT(3), 'x','color',lcs(setdiff(1:4,idfix),:),'Linewidth',2,'Markersize',10);
    
    plot(AxesSOL2, lin2, LR1*[1; pT],'color',lcs(setdiff(1:4,idfix),:),'Linewidth',2);
    
elseif size(fixpts,1) == 4
    
    for i=1:4
        T(idfix(i),:) = [1 fixpts(i,:)];
    end
    
    pT = pinv(T);
    pT = pT*diag(1./pT(1,:));
    
    pts = diag(1./T(:,1))*T(:,2:4);
    lpts = (linscale1*pT(2:4,:)/linscale2)';
    
    if (get(plotopt(1), 'Value')) && (trigls)
        for i=1:4
            id = setdiff(1:4,i);
            axes(Axes1)
            patch(pts(id,1), pts(id,2), pts(id,3),min(lcs(i,:)+[.7 .7 .7],[1 1 1]),'EdgeColor','k','facealpha',2*fa,'Linewidth',1+get(plotopt(2), 'Value'));
            
            axes(Axes2)
            patch(lpts(id,1), lpts(id,2), lpts(id,3),min(lcs(i,:)+[.7 .7 .7],[1 1 1]),'EdgeColor','k','facealpha',2*fa,'Linewidth',1+get(plotopt(2), 'Value'));
        end
    end
    
    if (get(plotopt(2), 'Value')) && (~get(plotopt(1), 'Value')) && (trigls)
        sel = nchoosek(1:4,2);
        for i=1:size(sel,1)
            plot3(Axes1, pts(sel(i,1:2),1), pts(sel(i,1:2),2), pts(sel(i,1:2),3), 'k','Linewidth',2);
        end
        
        for i=1:size(sel,1)
            plot3(Axes2, lpts(sel(i,1:2),1), lpts(sel(i,1:2),2), lpts(sel(i,1:2),3), 'k','Linewidth',2);
        end
    end 
    
    for i=1:4
        plot3(Axes2, lpts(i,1), lpts(i,2), lpts(i,3), 'x','color',lcs(i,:),'Linewidth',2,'Markersize',10);
    end
    
    plot(AxesSOL2, lin2, LR1*pT,'Linewidth',2);
end

if isact
    plot3(Axes1, x, y, z, 'x', 'color', lvc,'Linewidth',2,'Markersize',10);
    
    if get(plotopt(1), 'Value')
        plact = computecomplaneCA4(actx*linscale1^(-1)*linscale2, AFS2.xm, AFS2.ym, AFS2.zm);
    end

    if ok
        plot(AxesSOL1, lin1, [1 actx]*LR2, 'color', lvc,'Linewidth',2);
    else
        plot(AxesSOL1, lin1, [1 actx]*LR2, '--', 'color', lvc,'Linewidth',2);
    end

    if (get(plotopt(1), 'Value')) && (~trigls)
        axes(Axes2);
        patch(plact(1,:), plact(2,:), plact(3,:),min(lvc+[.7 .7 .7],[1 1 1]),'EdgeColor',lvc,'facealpha',fa);
    end
end

if given1.is
    plot3(Axes1, given1.afs(:,1), given1.afs(:,2), given1.afs(:,3),'kx','Linewidth', 2,'Markersize',10);
    plot(AxesSOL1, lin1, given1.line, 'k--','Linewidth', 1);
end

if given2.is
    plot3(Axes2, given2.afs(:,1), given2.afs(:,2), given2.afs(:,3),'kx','Linewidth', 2,'Markersize',10);
    plot(AxesSOL2, lin2, given2.line, 'k--','Linewidth', 1);
end

hold(Axes1, 'off')
hold(Axes2, 'off')

hold(AxesSOL1, 'off')
hold(AxesSOL2, 'off')