function buttonsaveallRAY(hObject, eventdata, Empty_Button, Footnote, AxesAFS, AxesSOL, Plotsettings)
data = get(Empty_Button,'UserData');
if (isfield(data,'ismatrix')*isfield(data,'isnmf')*isfield(data,'isafs') == 0) || (data.ismatrix*data.isnmf*data.isafs == 0)
    if data.ismatrix == 0 set(Footnote,'String',' Warning, no data has been loaded.','ForegroundColor','red');return;end
    if data.isnmf == 0 set(Footnote,'String',' Warning, no NMF has been computed.','ForegroundColor','red');return;end
    if data.isafs == 0 set(Footnote,'String',' Warning, no AFS has been computed.','ForegroundColor','red');return;end
end
U = data.U; 
S = data.S;
V = data.V;
D = data.D;
x = data.x;
t = data.t;
Cinit = U*S(:,1:data.s)*pinv(data.InitT);
Ainit = data.InitT*V(:,1:data.s)';
Draw = data.Draw;

AFS = data.afs;

bndpts = getsetvar(Plotsettings(1), 1, 200, 1, 1);
nx     = getsetvar(Plotsettings(2), 0, 50, 1, 1);

for pv = 1:data.afs.nseg
    TransformedAFS{data.afs.SegStruc(pv,2)} = transformRAY(data,bndpts,nx,pv,Footnote,2);
end

if norm(data.lvactx) > 1.E-14
    
    LockPoint1 = data.lvactx;
    ALock1 = [1 LockPoint1]*V';
    
    uisave({'U','S','V','D','x','t','Cinit','Ainit','AFS','TransformedAFS','LockPoint1','ALock1'},[data.PathName,'results_facpack_ray_',data.FileName]);
    
else
    
    uisave({'U','S','V','D','x','t','Cinit','Ainit','AFS','TransformedAFS'},[data.PathName,'results_facpack_ray_',data.FileName]);
    
end
