function buttonlockCA4(hObject, eventdata, Empty_Button, Buttons, Footnote, AxesC, AxesA, AxesSOLC, AxesSOLA, uonoff, uonoffC, type)

data = get(Empty_Button,'UserData');

if data.motion > 0
    
    data.fixA{data.motion}.pt = data.actx;
    data.choosen(data.motion) = 1;
    
    data.fixA{data.motion}.complane = computecomplaneCA4(data.actx*(data.S(2:4,2:4))^(-1)*data.S(1,1), data.afsC.xm, data.afsC.ym, data.afsC.zm);
    
    for i=1:4
        if min(data.choosen(setdiff(1:4,i))) == 1
            temp = [];
            for j= setdiff(1:4,i)
                temp = [temp; 1 data.fixA{j}.pt];
            end
            
            x = null(temp)';
            if (size(x,1) == 1) && (size(x,2) == 4)
                data.fixC{i}.pt = (x(2:4)/x(1)).*(diag(data.S(2:4,2:4))'/data.S(1,1));
                data.choosenC(i) = 1;
            end
            
            data.fixC{i}.complane = computecomplaneCA4(data.actx, data.afsA.xm, data.afsA.ym, data.afsA.zm);
        end
    end
    
    if type == 1
        set(uonoff(data.motion+1), 'Value', 0);
        set(uonoff(1), 'Value', 1);
    end
    
elseif data.motionC > 0
    data.fixC{data.motionC}.pt = data.actx;
    data.choosenC(data.motionC) = 1;
    
    data.fixC{data.motionC}.complane = computecomplaneCA4(data.actx*(data.S(2:4,2:4))^(-1)*data.S(1,1), data.afsA.xm, data.afsA.ym, data.afsA.zm);

    for i=1:4
        if min(data.choosenC(setdiff(1:4,i))) == 1
            temp = [];
            for j= setdiff(1:4,i)
                temp = [temp; 1 data.fixC{j}.pt];
            end
            
            x = null(temp)';
            if (size(x,1) == 1) && (size(x,2) == 4)
                data.fixA{i}.pt = (x(2:4)/x(1)).*(diag(data.S(2:4,2:4))'/data.S(1,1));
                data.choosen(i) = 1;
            end
            
            data.fixA{i}.complane = computecomplaneCA4(data.actx*(data.S(2:4,2:4))^(-1)*data.S(1,1), data.afsC.xm, data.afsC.ym, data.afsC.zm);
        end
    end
    
    if type == 1
        set(uonoffC(data.motionC+1), 'Value', 0);
        set(uonoffC(1), 'Value', 1);
    end
else
    return;
end

if type == 1
    set(hObject, 'Enable', 'off');
    data.motion = 0;
    data.motionC = 0;
end

set(Empty_Button,'UserData',data);
