Mercurial > hg > ltpda
comparison m-toolbox/classes/@ao/setXY.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 % SETXY sets the 'xy' property of the ao. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: SETXY sets the 'xy' property of the ao. | |
5 % | |
6 % CALL: ao = setXY(ao, x, y) | |
7 % obj = obj.setXY(plist('x', [1 2 3], 'y', [1 2 3]); | |
8 % | |
9 % <a href="matlab:utils.helper.displayMethodInfo('ao', 'setXY')">Parameters Description</a> | |
10 % | |
11 % VERSION: $Id: setXY.m,v 1.20 2011/05/27 10:28:56 mauro Exp $ | |
12 % | |
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
14 | |
15 function varargout = setXY(varargin) | |
16 | |
17 % Check if this is a call from a class method | |
18 callerIsMethod = utils.helper.callerIsMethod; | |
19 | |
20 if callerIsMethod | |
21 as = varargin{1}; | |
22 x = varargin{2}; | |
23 y = varargin{3}; | |
24 | |
25 else | |
26 %%% Check if this is a call for parameters | |
27 if utils.helper.isinfocall(varargin{:}) | |
28 varargout{1} = getInfo(varargin{3}); | |
29 return | |
30 end | |
31 | |
32 import utils.const.* | |
33 utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename); | |
34 | |
35 % Collect input variable names | |
36 in_names = cell(size(varargin)); | |
37 for ii = 1:nargin,in_names{ii} = inputname(ii);end | |
38 | |
39 % Collect all AOs | |
40 [as, ao_invars,rest] = utils.helper.collect_objects(varargin(:), 'ao', in_names); | |
41 [pls, invars, rest] = utils.helper.collect_objects(rest(:), 'plist'); | |
42 | |
43 %%% Look for numeric values in rest | |
44 x = []; | |
45 y = []; | |
46 if numel(rest) == 2 && isnumeric(rest{1}) && isnumeric(rest{2}) && numel(rest{1}) == numel(rest{2}) | |
47 x = rest{1}; | |
48 y = rest{2}; | |
49 end | |
50 | |
51 %%% If pls contains parameters X and Y, get the values from there | |
52 if isempty(x) | |
53 x = pls.find('x'); | |
54 end | |
55 if isempty(y) | |
56 y = pls.find('y'); | |
57 end | |
58 | |
59 if isempty(x) || isempty(y) | |
60 error('### Please specify a value for X and Y, either in a plist or directly.'); | |
61 end | |
62 | |
63 %%% Combine plists | |
64 pl = plist('x', x, 'y', y); | |
65 | |
66 end % callerIsMethod | |
67 | |
68 % Decide on a deep copy or a modify | |
69 bs = copy(as, nargout); | |
70 | |
71 % Loop over AOs | |
72 for jj = 1:numel(bs) | |
73 bs(jj).data.setXY(x, y); | |
74 if ~callerIsMethod | |
75 bs(jj).addHistory(getInfo('None'), pl, ao_invars(jj), bs(jj).hist); | |
76 end | |
77 end | |
78 | |
79 % Set output | |
80 varargout = utils.helper.setoutputs(nargout, bs); | |
81 end | |
82 | |
83 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
84 % Local Functions % | |
85 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
86 %-------------------------------------------------------------------------- | |
87 % Get Info Object | |
88 %-------------------------------------------------------------------------- | |
89 function ii = getInfo(varargin) | |
90 | |
91 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
92 sets = {}; | |
93 pl = []; | |
94 else | |
95 sets = {'Default'}; | |
96 pl = getDefaultPlist(); | |
97 end | |
98 % Build info object | |
99 ii = minfo(mfilename, 'ao', 'ltpda', utils.const.categories.helper, '$Id: setXY.m,v 1.20 2011/05/27 10:28:56 mauro Exp $', sets, pl); | |
100 end | |
101 | |
102 %-------------------------------------------------------------------------- | |
103 % Get Default Plist | |
104 %-------------------------------------------------------------------------- | |
105 function plout = getDefaultPlist() | |
106 persistent pl; | |
107 if ~exist('pl', 'var') || isempty(pl) | |
108 pl = buildplist(); | |
109 end | |
110 plout = pl; | |
111 end | |
112 | |
113 function pl = buildplist() | |
114 pl = plist(); | |
115 | |
116 % X | |
117 p = param({'x', 'A vector to set to the x field.'}, paramValue.EMPTY_DOUBLE); | |
118 pl.append(p); | |
119 | |
120 % Y | |
121 p = param({'y', 'A vector to set to the y field.'}, paramValue.EMPTY_DOUBLE); | |
122 pl.append(p); | |
123 | |
124 end | |
125 |