0001 function ltpdv_calc_btn(varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010 myh = varargin{1};
0011 mainfig = varargin{end-1};
0012 nins = varargin{end};
0013
0014
0015 op = get(myh, 'String');
0016
0017
0018 objs = ltpdv_get_selected_objs(mainfig);
0019 Nobjs = length(objs);
0020
0021 if Nobjs < nins
0022 error('### Please select two objects');
0023 end
0024
0025
0026 for j=1:Nobjs
0027 if ~isa(objs{j}, 'ao')
0028 error('### Please select only AOs for math calculations');
0029 end
0030 end
0031
0032
0033 n = 1;
0034 res = {};
0035 while n <= length(objs)
0036
0037 switch nins
0038 case 1
0039 res = [res {feval(op, objs{n})}];
0040 case 2
0041 if isempty(res)
0042 res = feval(op, objs{n}, objs{n+1});
0043 n = n + 1;
0044 else
0045 res = feval(op, res, objs{n});
0046 end
0047 end
0048 n = n + 1;
0049 end
0050
0051 if nins == 2
0052 res = {res};
0053 end
0054
0055
0056 objs = getappdata(mainfig, 'LTPDAobjects');
0057 if ~isempty(res)
0058 setappdata(mainfig, 'LTPDAobjects', [objs res]);
0059
0060 ltpdv_refresh_object_list(mainfig);
0061 end
0062
0063
0064