comparison m-toolbox/classes/@modelViewer/buildParamsPanel.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 % BUILDPARAMSPANEL builds a parameter panel for the given plist.
2 %
3 % M Hewitson
4 %
5 % $Id: buildParamsPanel.m,v 1.5 2011/04/08 08:56:34 hewitson Exp $
6 %
7
8 function buildParamsPanel(ph, ii, varargin)
9
10 FONTSIZE = 12;
11
12 pmarg = 0.025;
13
14 keyl = pmarg;
15 keyh = 0.1;
16 keyw = 0.3;
17 keyb = 1-pmarg-keyh;
18
19 vall = pmarg*2 + keyw;
20 valw = 0.5;
21
22 al = vall + valw + pmarg;
23 aw = 0.05;
24
25 delete(get(ph, 'Children'))
26
27 if numel(varargin) > 0
28 activated = varargin{1};
29 if strcmpi(activated, 'on')
30 chkVal = 1;
31 else
32 chkVal = 0;
33 end
34 else
35 activated = 'on';
36 chkVal = 1;
37 end
38
39 pancomps = {};
40
41 if isa(ii, 'minfo')
42 % we give a pop-up menu of sets
43 eh = uicontrol(ph,'Style','popupmenu',...
44 'String',ii.sets,...
45 'units', 'normalized', ...
46 'BackgroundColor', 'w', ...
47 'Fontsize', FONTSIZE, ...
48 'Enable', 'on', ...
49 'Position',[vall keyb valw keyh]);
50
51 set(eh, 'Callback', {@ltpdv_preproc_sets_callback, ii});
52 else
53 pl = ii;
54
55 if numel(pl.params) == 0
56 sth = uicontrol(ph,'Style','text',...
57 'String', 'contains no parameters',...
58 'Units', 'normalized', ...
59 'BackgroundColor', 'w', ...
60 'Fontsize', FONTSIZE, ...
61 'Position',[keyl keyb 2*keyw keyh]);
62 end
63 % check for any unsupported parameters
64 unsupported = false;
65 for j=1:numel(pl.params)
66 val = pl.params(j).getVal;
67 if isa(val, 'timespan')
68 unsupported = true;
69 end
70 end
71 if unsupported
72 sth = uicontrol(ph,'Style','text',...
73 'String', ['contains unsupported parameter of type: ' class(val)],...
74 'Units', 'normalized', ...
75 'BackgroundColor', 'w', ...
76 'Fontsize', FONTSIZE, ...
77 'Position',[keyl keyb 2*keyw keyh]);
78
79 else
80 % Build parameters
81 for j=1:numel(pl.params)
82
83 % Get key and val
84 key = pl.params(j).key;
85 val = pl.params(j).getVal;
86
87 switch class(val)
88 case 'char'
89 valstr = val;
90 case 'double'
91 valstr = mat2str(val);
92 case 'specwin'
93 valstr = specwin.getTypes;
94 case 'logical'
95 if val
96 valstr = 'true';
97 else
98 valstr = 'false';
99 end
100 otherwise
101 valstr = char(val);
102 end
103
104 % key text
105 sth = uicontrol(ph,'Style','text',...
106 'String', key,...
107 'Units', 'normalized', ...
108 'BackgroundColor', 'w', ...
109 'Fontsize', FONTSIZE, ...
110 'Position',[keyl keyb keyw keyh]);
111
112 % val edit
113 if ischar(valstr) || isa(valstr, 'time') || isa(valstr, 'sym')
114 if isa(valstr, 'time') || isa(valstr, 'sym')
115 valstr = char(valstr);
116 end
117 eh = uicontrol(ph,'Style','edit',...
118 'String', valstr,...
119 'units', 'normalized', ...
120 'BackgroundColor', 'w', ...
121 'Fontsize', FONTSIZE, ...
122 'Enable', activated, ...
123 'Position',[vall keyb valw keyh]);
124 elseif iscell(valstr)
125 eh = uicontrol(ph,'Style','popupmenu',...
126 'String',valstr,...
127 'units', 'normalized', ...
128 'BackgroundColor', 'w', ...
129 'Fontsize', FONTSIZE, ...
130 'Enable', activated, ...
131 'Position',[vall keyb valw keyh]);
132 else
133 valstr
134 error('### Unknown type for value string.');
135 end
136 setappdata(eh, 'valClass', class(val));
137 % Activate
138 ah = uicontrol(ph,'Style','checkbox',...
139 'String','',...
140 'units', 'normalized', ...
141 'BackgroundColor', get(ph, 'BackgroundColor'), ...
142 'Fontsize', FONTSIZE, ...
143 'Value', chkVal, 'Position', [al keyb aw keyh], ...
144 'Callback', {@ltpdv_preproc_param_act, ph});
145
146 pancomps = [pancomps; {sth, eh, ah}];
147
148 % Do next line
149 keyb = keyb - pmarg - keyh;
150
151 end
152 end
153 end
154
155 setappdata(ph, 'pancomps', pancomps);
156
157
158 end