Mercurial > hg > ltpda
comparison m-toolbox/classes/@sigBuilder/buildMainfig.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 % BUILDMAINFIG build the main sigBuilder window | |
2 % | |
3 % M Hewitson 18-10-08 | |
4 % | |
5 % $Id: buildMainfig.m,v 1.1 2008/10/19 11:42:40 hewitson Exp $ | |
6 % | |
7 function mainfig = buildMainfig(mainfig, varargin) | |
8 % %% Check if I exist already | |
9 % id = findobj('Tag', 'SIGBUILDERmainfig'); | |
10 % if ~isempty(id) | |
11 % figure(id) | |
12 % return | |
13 % end | |
14 | |
15 %% Some initial setup | |
16 | |
17 Screen = get(0,'screensize'); | |
18 mainfig.Gproperties.Gcol = [255 255 255]/255; | |
19 mainfig.Gproperties.Screen = Screen; | |
20 mainfig.Gproperties.Gwidth = 0.5; | |
21 mainfig.Gproperties.Gheight = 0.5; | |
22 mainfig.Gproperties.Gborder = 10; | |
23 mainfig.Gproperties.fontsize = 12; | |
24 | |
25 l = (0.5-mainfig.Gproperties.Gwidth/2); | |
26 b = (0.5-mainfig.Gproperties.Gheight/2); | |
27 w = mainfig.Gproperties.Gwidth; | |
28 h = mainfig.Gproperties.Gheight; | |
29 mainfig.Gproperties.Gposition = [l b w h]; | |
30 | |
31 if ~isempty(varargin) && ishandle(varargin{1}) | |
32 mainfig.handle = varargin{1}; | |
33 set(mainfig.handle, 'Tag', 'SIGBUILDERmainfig'); | |
34 set(mainfig.handle, 'Units', 'normalized'); | |
35 else | |
36 % Initialize and hide the GUI as it is being constructed. | |
37 mainfig.handle = figure('Name', 'LTPDA Signal Builder',... | |
38 'NumberTitle', 'off',... | |
39 'Visible','off',... | |
40 'Units','normalized',... | |
41 'Position',mainfig.Gproperties.Gposition,... | |
42 'Toolbar', 'none',... | |
43 'MenuBar', 'none',... | |
44 'Color', mainfig.Gproperties.Gcol,... | |
45 'Resize', 'on',... | |
46 'Tag', 'SIGBUILDERmainfig'); | |
47 end | |
48 | |
49 % Set mainfig callbacks | |
50 set(mainfig.handle, 'CloseRequestFcn', {'sigBuilder.cb_mainfigClose', mainfig}); | |
51 | |
52 %------------------------------------------------------------------------ | |
53 %- General properties | |
54 %------------------------------------------------------------------------ | |
55 hmarg = 0.006; | |
56 vmarg = 0.012; | |
57 commHeight = 0.05; | |
58 % l b w h | |
59 | |
60 % make settings panel | |
61 w = 0.5-2*hmarg; | |
62 h = 1-2*vmarg; | |
63 l = hmarg; | |
64 b = vmarg; | |
65 span = uipanel(mainfig.handle,... | |
66 'Title', 'Settings', ... | |
67 'FontSize', mainfig.Gproperties.fontsize, ... | |
68 'BackgroundColor', [0.9 0.9 0.9], ... | |
69 'Position', [l b w h], ... | |
70 'BorderType', 'line', ... | |
71 'BorderWidth', 1, ... | |
72 'Tag', 'SettingsPanel', ... | |
73 'HighlightColor', [0.5 0.5 0.5]); | |
74 | |
75 % make list panel | |
76 w = 0.5-2*hmarg; | |
77 h = 1-2*vmarg; | |
78 l = 0.5+hmarg; | |
79 b = vmarg; | |
80 ppan = uipanel(mainfig.handle,... | |
81 'Title', 'Signal List', ... | |
82 'FontSize', mainfig.Gproperties.fontsize, ... | |
83 'BackgroundColor', [200 220 240]/255, ... | |
84 'Position', [l b w h], ... | |
85 'BorderType', 'line', ... | |
86 'BorderWidth', 1, ... | |
87 'HighlightColor', [0.5 0.5 0.5]); | |
88 | |
89 %------------------------------------------------------------------------ | |
90 % Sample rate | |
91 | |
92 % label | |
93 l = hmarg; | |
94 h = commHeight; | |
95 b = 1-2*vmarg-h; | |
96 w = 0.25; | |
97 sth = uicontrol(span, 'Style','text',... | |
98 'String', 'Sample Rate [Hz]',... | |
99 'Units', 'normalized', ... | |
100 'HorizontalAlignment', 'right',... | |
101 'BackgroundColor', [0.9 0.9 0.9], ... | |
102 'Fontsize', mainfig.Gproperties.fontsize, ... | |
103 'Position',[l b w h]); | |
104 | |
105 % edit box | |
106 l = l + w + hmarg; | |
107 w = 0.15; | |
108 sth = uicontrol(span, 'Style','edit',... | |
109 'String', '10',... | |
110 'Units', 'normalized', ... | |
111 'BackgroundColor', 'w', ... | |
112 'Fontsize', mainfig.Gproperties.fontsize, ... | |
113 'Position',[l b w h], ... | |
114 'Tag', 'SampleRateEdit'); | |
115 | |
116 %------------------------------------------------------------------------ | |
117 % T0 | |
118 | |
119 % label | |
120 l = l + w + hmarg; | |
121 w = 0.15; | |
122 sth = uicontrol(span, 'Style','text',... | |
123 'String', 'Start Time',... | |
124 'Units', 'normalized', ... | |
125 'HorizontalAlignment', 'right',... | |
126 'BackgroundColor', [0.9 0.9 0.9], ... | |
127 'Fontsize', mainfig.Gproperties.fontsize, ... | |
128 'Position',[l b w h]); | |
129 | |
130 % edit box | |
131 l = l + w + hmarg; | |
132 w = 0.35; | |
133 t0 = time(); | |
134 sth = uicontrol(span, 'Style','edit',... | |
135 'String', char(t0),... | |
136 'Units', 'normalized', ... | |
137 'BackgroundColor', 'w', ... | |
138 'Fontsize', mainfig.Gproperties.fontsize, ... | |
139 'Position',[l b w h], ... | |
140 'Tag', 'T0edit'); | |
141 | |
142 %------------------------------------------------------------------------ | |
143 % Name | |
144 | |
145 % label | |
146 b = b - h - vmarg; | |
147 l = hmarg; | |
148 w = 0.25; | |
149 sth = uicontrol(span, 'Style','text',... | |
150 'String', 'Signal Name',... | |
151 'Units', 'normalized', ... | |
152 'HorizontalAlignment', 'right',... | |
153 'BackgroundColor', [0.9 0.9 0.9], ... | |
154 'Fontsize', mainfig.Gproperties.fontsize, ... | |
155 'Position',[l b w h]); | |
156 | |
157 % edit box | |
158 l = l + w + hmarg; | |
159 w = 0.35; | |
160 sth = uicontrol(span, 'Style','edit',... | |
161 'String', 'None',... | |
162 'Units', 'normalized', ... | |
163 'BackgroundColor', 'w', ... | |
164 'Fontsize', mainfig.Gproperties.fontsize, ... | |
165 'Position',[l b w h], ... | |
166 'Tag', 'NameEdit'); | |
167 | |
168 %------------------------------------------------------------------------ | |
169 % Signal Type | |
170 | |
171 % label | |
172 w = 0.25; | |
173 l = hmarg; | |
174 b = b - h - vmarg; | |
175 sth = uicontrol(span, 'Style','text',... | |
176 'String', 'Signal Type',... | |
177 'Units', 'normalized', ... | |
178 'BackgroundColor', [0.9 0.9 0.9], ... | |
179 'HorizontalAlignment', 'right',... | |
180 'Fontsize', mainfig.Gproperties.fontsize, ... | |
181 'Position',[l b w h]); | |
182 | |
183 % drop down menu | |
184 l = l + w + hmarg; | |
185 w = 0.35; | |
186 clsh = uicontrol(span, ... | |
187 'Style', 'popupmenu', ... | |
188 'Units', 'normalized',... | |
189 'Fontsize', mainfig.Gproperties.fontsize, ... | |
190 'BackgroundColor', 'w', ... | |
191 'String', mainfig.getSignalTypes, ... | |
192 'Position', [l b w h],... | |
193 'Tag', 'SignalTypeSelect', ... | |
194 'Callback', {'sigBuilder.cb_selectSignalType', mainfig}); | |
195 | |
196 %------------------------------------------------------------------------ | |
197 % Panel for signal controls | |
198 w = 1-4*hmarg; | |
199 h = 0.65; | |
200 l = 2*hmarg; | |
201 b = 0.1+2*vmarg; | |
202 conpan = uipanel(span,... | |
203 'Title', 'Signal Properties', ... | |
204 'FontSize', mainfig.Gproperties.fontsize, ... | |
205 'FontWeight', 'bold', ... | |
206 'BackgroundColor', 'w', ... | |
207 'Position', [l b w h], ... | |
208 'BorderType', 'line', ... | |
209 'BorderWidth', 1, ... | |
210 'Tag', 'ControlsPanel', ... | |
211 'HighlightColor', [0.5 0.5 0.5]); | |
212 | |
213 % Fire the callback | |
214 sigBuilder.cb_selectSignalType(clsh, mainfig); | |
215 | |
216 %------------------------------------------------------------------------ | |
217 % Add signal button | |
218 | |
219 h = 1.2*commHeight; | |
220 w = 0.2; | |
221 l = 1-w-hmarg; | |
222 b = vmarg; | |
223 pbh = uicontrol(span,'Style','pushbutton',... | |
224 'String','Add Signal',... | |
225 'Callback', {'sigBuilder.cb_addSignal', mainfig}, ... | |
226 'Units', 'normalized', ... | |
227 'Fontsize', mainfig.Gproperties.fontsize, ... | |
228 'Position',[l b w h]); | |
229 | |
230 | |
231 %------------------------------------------------------------------------ | |
232 %------------------------------------------------------------------------ | |
233 %------------------------------------------------------------------------ | |
234 %- Right Panel | |
235 %------------------------------------------------------------------------ | |
236 %------------------------------------------------------------------------ | |
237 %------------------------------------------------------------------------ | |
238 | |
239 %------------------------------------------------------------------------ | |
240 % Signal List | |
241 | |
242 h = 0.7; | |
243 l = hmarg; | |
244 b = 1-h-vmarg; | |
245 w = 1-2*hmarg; | |
246 t = uitable(ppan, 'Data', [], ... | |
247 'ColumnName', {'Type', 'Name', 'Length', 'Start', 'Add'},... | |
248 'ColumnFormat', {'char', 'char', 'numeric', 'char', 'logical'},... | |
249 'ColumnWidth', {'auto', 'auto', 'auto', 'auto', 'auto'},... | |
250 'ColumnEditable', [false false false false true], ... | |
251 'units', 'normalized',... | |
252 'RowStriping', 'on', ... | |
253 'BackgroundColor', [1 1 1;0.8 0.8 0.8], ... | |
254 'ForegroundColor', [0 0 0], ... | |
255 'Fontsize', mainfig.Gproperties.fontsize,... | |
256 'Position', [l b w h],... | |
257 'CellSelectionCallback', {'sigBuilder.cb_sigListSelect', mainfig}, ... | |
258 'ButtonDownFcn', {'sigBuilder.cb_sigListClick', mainfig}, ... | |
259 'Tag', 'sigBuilderSignalList'); | |
260 | |
261 %------------------------------------------------------------------------ | |
262 % buttons | |
263 | |
264 % remove | |
265 h = 1.2*commHeight; | |
266 w = 0.2; | |
267 l = hmarg; | |
268 b = b - h - vmarg; | |
269 pbh = uicontrol(ppan,'Style','pushbutton',... | |
270 'String','Remove Signal',... | |
271 'Callback', {'sigBuilder.cb_removeSignal', mainfig}, ... | |
272 'Units', 'normalized', ... | |
273 'Fontsize', mainfig.Gproperties.fontsize, ... | |
274 'Position',[l b w h]); | |
275 | |
276 % clear | |
277 l = l + hmarg + w; | |
278 w = 0.2; | |
279 pbh = uicontrol(ppan,'Style','pushbutton',... | |
280 'String','Clear List',... | |
281 'Callback', {'sigBuilder.cb_clearSignals', mainfig}, ... | |
282 'Units', 'normalized', ... | |
283 'Fontsize', mainfig.Gproperties.fontsize, ... | |
284 'Position',[l b w h]); | |
285 | |
286 % Toggle select | |
287 l = l + hmarg + w; | |
288 w = 0.2; | |
289 pbh = uicontrol(ppan,'Style','pushbutton',... | |
290 'String','Toggle State',... | |
291 'Callback', {'sigBuilder.cb_toggleAddState', mainfig}, ... | |
292 'Units', 'normalized', ... | |
293 'Fontsize', mainfig.Gproperties.fontsize, ... | |
294 'Position',[l b w h]); | |
295 | |
296 % Select all | |
297 l = l + hmarg + w; | |
298 w = 0.2; | |
299 pbh = uicontrol(ppan,'Style','pushbutton',... | |
300 'String','Add All',... | |
301 'Callback', {'sigBuilder.cb_addAll', mainfig}, ... | |
302 'Units', 'normalized', ... | |
303 'Fontsize', mainfig.Gproperties.fontsize, ... | |
304 'Position',[l b w h]); | |
305 | |
306 % Join type | |
307 % label | |
308 w = 0.25; | |
309 l = hmarg; | |
310 b = b - h - vmarg; | |
311 sth = uicontrol(ppan, 'Style','text',... | |
312 'String', 'Join Type',... | |
313 'Units', 'normalized', ... | |
314 'BackgroundColor', [200 220 240]/255, ... | |
315 'HorizontalAlignment', 'right',... | |
316 'Fontsize', mainfig.Gproperties.fontsize, ... | |
317 'Position',[l b w h]); | |
318 | |
319 % drop down menu | |
320 l = l + w + hmarg; | |
321 w = 0.35; | |
322 tip = sprintf('join: overlaps taken from first time-series. (help ao/join)\nsumjoin: overlaps are sum of overlapping time-series. (help ao/sumjoin)'); | |
323 clsh = uicontrol(ppan, ... | |
324 'Style', 'popupmenu', ... | |
325 'Units', 'normalized',... | |
326 'Fontsize', mainfig.Gproperties.fontsize, ... | |
327 'BackgroundColor', 'w', ... | |
328 'String', {'sumjoin', 'join'}, ... | |
329 'Position', [l b w h],... | |
330 'Tag', 'JoinTypeSelect', ... | |
331 'Tooltip', tip); | |
332 | |
333 | |
334 % export commands | |
335 b = b - vmarg - h; | |
336 l = hmarg; | |
337 w = 0.25; | |
338 pbh = uicontrol(ppan,'Style','pushbutton',... | |
339 'String','Build Commands',... | |
340 'Callback', {'sigBuilder.cb_exportCommands', mainfig}, ... | |
341 'Units', 'normalized', ... | |
342 'Fontsize', mainfig.Gproperties.fontsize, ... | |
343 'Position',[l b w h]); | |
344 | |
345 % Save | |
346 l = l + w + hmarg; | |
347 w = 0.2; | |
348 pbh = uicontrol(ppan,'Style','pushbutton',... | |
349 'String','Build & Save',... | |
350 'Callback', {'sigBuilder.cb_buildSave', mainfig}, ... | |
351 'Units', 'normalized', ... | |
352 'Fontsize', mainfig.Gproperties.fontsize, ... | |
353 'Position',[l b w h]); | |
354 | |
355 % View | |
356 l = l + w + hmarg; | |
357 w = 0.2; | |
358 pbh = uicontrol(ppan,'Style','pushbutton',... | |
359 'String','Build & View',... | |
360 'Callback', {'sigBuilder.cb_buildView', mainfig}, ... | |
361 'Units', 'normalized', ... | |
362 'Fontsize', mainfig.Gproperties.fontsize, ... | |
363 'Position',[l b w h]); | |
364 | |
365 % View | |
366 l = l + w + hmarg; | |
367 w = 0.2; | |
368 pbh = uicontrol(ppan,'Style','pushbutton',... | |
369 'String','Build & Export',... | |
370 'Callback', {'sigBuilder.cb_buildExport', mainfig}, ... | |
371 'Units', 'normalized', ... | |
372 'Fontsize', mainfig.Gproperties.fontsize, ... | |
373 'Position',[l b w h]); | |
374 | |
375 end |