SETXY sets the 'xy' property of the ao. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: SETXY sets the 'xy' property of the ao. CALL: ao = setXY(ao, x, y) obj = obj.setXY(plist('x', [1 2 3], 'y', [1 2 3]); M-FILE INFO: Get information about this methods by calling >> ao.getInfo('setXY') Get information about a specified set-plist by calling: >> ao.getInfo('setXY', 'None') VERSION: $Id: setXY.m,v 1.6 2008/09/05 11:05:29 ingo Exp $ HISTORY: 31-01-2007 M Hewitson Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 % SETXY sets the 'xy' property of the ao. 0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0003 % 0004 % DESCRIPTION: SETXY sets the 'xy' property of the ao. 0005 % 0006 % CALL: ao = setXY(ao, x, y) 0007 % obj = obj.setXY(plist('x', [1 2 3], 'y', [1 2 3]); 0008 % 0009 % M-FILE INFO: Get information about this methods by calling 0010 % >> ao.getInfo('setXY') 0011 % 0012 % Get information about a specified set-plist by calling: 0013 % >> ao.getInfo('setXY', 'None') 0014 % 0015 % VERSION: $Id: setXY.m,v 1.6 2008/09/05 11:05:29 ingo Exp $ 0016 % 0017 % HISTORY: 31-01-2007 M Hewitson 0018 % Creation 0019 % 0020 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0021 0022 function varargout = setXY(varargin) 0023 0024 %%% Check if this is a call for parameters 0025 if utils.helper.isinfocall(varargin{:}) 0026 varargout{1} = getInfo(varargin{3}); 0027 return 0028 end 0029 0030 %%% Internal call: Only one object + don't look for a plist 0031 if strcmp(varargin{end}, 'internal') 0032 0033 %%% decide whether we modify the first object, or create a new one. 0034 varargin{1} = copy(varargin{1}, nargout); 0035 0036 varargin{1}.data.setXY(varargin{2}, varargin{3}); 0037 varargout{1} = varargin{1}; 0038 return 0039 end 0040 0041 import utils.const.* 0042 utils.helper.msg(msg.MNAME, 'running %s/%s', mfilename('class'), mfilename); 0043 0044 % Collect input variable names 0045 in_names = cell(size(varargin)); 0046 for ii = 1:nargin,in_names{ii} = inputname(ii);end 0047 0048 % Collect all AOs 0049 [as, ao_invars,rest] = utils.helper.collect_objects(varargin(:), 'ao', in_names); 0050 [pls, invars, rest] = utils.helper.collect_objects(rest(:), 'plist'); 0051 0052 %%% Look for numeric values in rest 0053 x = []; 0054 y = []; 0055 if numel(rest) == 2 && isnumeric(rest{1}) && isnumeric(rest{2}) && numel(rest{1}) == numel(rest{2}) 0056 x = rest{1}; 0057 y = rest{2}; 0058 end 0059 0060 %%% If pls contains parameters X and Y, get the values from there 0061 if isempty(x) 0062 x = pls.find('x'); 0063 end 0064 if isempty(y) 0065 y = pls.find('y'); 0066 end 0067 0068 if isempty(x) || isempty(y) 0069 error('### Please specify a value for X and Y, either in a plist or directly.'); 0070 end 0071 0072 %%% Combine plists 0073 pl = plist('x', x, 'y', y); 0074 0075 % Decide on a deep copy or a modify 0076 bs = copy(as, nargout); 0077 0078 % Loop over AOs 0079 for j=1:numel(bs) 0080 bs(j).data.setXY(x, y); 0081 bs(j).addHistory(getInfo, pl, ao_invars(j), bs(j).hist); 0082 end 0083 0084 if nargout > 0 0085 varargout{1} = bs; 0086 end 0087 end 0088 0089 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0090 % Local Functions % 0091 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0092 %-------------------------------------------------------------------------- 0093 % Get Info Object 0094 %-------------------------------------------------------------------------- 0095 function ii = getInfo(varargin) 0096 0097 if nargin == 1 && strcmpi(varargin{1}, 'None') 0098 sets = {}; 0099 pl = []; 0100 else 0101 sets = {'Default'}; 0102 pl = getDefaultPlist; 0103 end 0104 % Build info object 0105 ii = minfo(mfilename, 'ao', '', utils.const.categories.helper, '$Id: setXY.m,v 1.6 2008/09/05 11:05:29 ingo Exp $', sets, pl); 0106 end 0107 0108 %-------------------------------------------------------------------------- 0109 % Get Default Plist 0110 %-------------------------------------------------------------------------- 0111 function pl = getDefaultPlist() 0112 pl = plist('x', [], 'y', []); 0113 end 0114