comparison m-toolbox/m/gui/gltpda/pan5output.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 function pan5output(varargin)
2
3 % ========================================================================
4 % ====================== Panel for the outputs ===========================
5 % ========================================================================
6 % This is the GUI m-file to show that the panel relative to the outputs
7 %
8 % $Id: pan5output.m,v 1.17 2008/12/16 19:30:26 nicola Exp $
9
10 global LTPDAoutvar
11
12 InputObjList=''; OutputObjList='';
13 UpdateListbox();
14 set(gcf,'NextPlot','new');
15
16 currPanel = varargin{1};
17 panelDimens = get(currPanel, 'Position');
18 backColor = get(currPanel, 'BackgroundColor');
19
20 DataPanPos = [20 panelDimens(4)-320 panelDimens(3)-40 285];
21 hDataPanel = uipanel(...
22 'Title','Data Control Panel',...
23 'BackgroundColor',[1,1,1],...
24 'FontSize',7,...
25 'Units','pixels',...
26 'Position',DataPanPos);
27 nbuttons = 5;
28 buttonWidth = (DataPanPos(3)-10*(nbuttons+1))/nbuttons;
29 buttonPos = [10 DataPanPos(4)-45 buttonWidth 25];
30 % 'Export to workspace' button:
31 uicontrol('Parent',hDataPanel,'Units','pixels','HorizontalAlignment','center','Position',buttonPos,'String','Export to workspace','FontSize',8,'Visible','on','Callback',@hExportButtonCallback,'Style','pushbutton','enable','on');
32 buttonPos(1) = buttonPos(1)+buttonWidth+10;
33 % 'Remove' button:
34 uicontrol('Parent',hDataPanel,'Units','pixels','HorizontalAlignment','center','Position',buttonPos,'String','Remove','FontSize',8,'Visible','on','Callback',@hRemoveButtonCallback,'Style','pushbutton','enable','on');
35 buttonPos(1) = buttonPos(1)+buttonWidth+10;
36 % 'Send to repository' button:
37 uicontrol('Parent',hDataPanel,'Units','pixels','HorizontalAlignment','center','Position',buttonPos,'String','Send to repository','FontSize',8,'Visible','on','Callback',@hClearButtonCallback,'Style','pushbutton','enable','off');
38 buttonPos(1) = buttonPos(1)+buttonWidth+10;
39 % 'Explore' button:
40 uicontrol('Parent',hDataPanel,'Units','pixels','HorizontalAlignment','center','Position',buttonPos,'String','Explore','FontSize',8,'Visible','on','UserData',InputObjList,'Callback',@hExploreButtonCallback,'Style','pushbutton','enable','on');
41 % buttonPos(1) = buttonPos(1)+buttonWidth+10;
42 % hSaveOutButton = uicontrol('Parent',hDataPanel,'Units','pixels','HorizontalAlignment','center','Position',buttonPos,'String','Save workspace','FontSize',8,'Visible','on','Enable','on','Callback',@SaveWorkspaceCallback,'Style','pushbutton');
43 buttonPos(1) = buttonPos(1)+buttonWidth+10;
44 % 'Clear all output' button:
45 uicontrol('Parent',hDataPanel,'Units','pixels','HorizontalAlignment','center','Position',buttonPos,'String','Clear output','FontSize',8,'Visible','on','Enable','on','Callback',{@AskConfirm,'clear'},'Style','pushbutton');
46 clear nbuttons buttonWidth buttonPos
47
48
49 ntexts = 2;
50 textWidth = (DataPanPos(3)-10*(ntexts+1))/ntexts;
51 textPos = [10 DataPanPos(4)-80 textWidth 25];
52 % hListAOText = uicontrol('Parent',hDataPanel,'BackgroundColor',get(hDataPanel,'BackgroundColor'),'HorizontalAlignment','center','Position',textPos,'String','Input:','FontName','Times New Roman','FontSize',8,'FontWeight','normal','Visible','on','Style','text');
53 textPos(1) = textPos(1)+textWidth+10;
54 hResultAOText = uicontrol('Parent',hDataPanel,'BackgroundColor',get(hDataPanel,'BackgroundColor'),'HorizontalAlignment','center','Position',textPos,'String','Output:','FontName','Times New Roman','FontSize',8,'FontWeight','normal','Visible','on','Style','text');
55 clear ntexts textWidth textPos
56
57
58 nlists = 2;
59 listWidth = (DataPanPos(3)-10*(nlists+1))/nlists;
60 listPos = [10 DataPanPos(4)-275 listWidth 200];
61 % Info panel:
62 uicontrol('Parent',hDataPanel,'BackgroundColor',[0.94,0.94,1],'Style','listbox','HorizontalAlignment', 'left','Fontsize', 8,'Units','pixels','Position',listPos,'Tag','infoPanel');
63 listPos(1) = listPos(1)+listWidth+10;
64 OutputObjList = uicontrol('Parent',hDataPanel,'BackgroundColor',[0.95,0.95,0.95],'HorizontalAlignment','center','Position',listPos,'String',listResults,'Value',[],'Max',10,'Min',1,'FontSize',8,'FontWeight','normal','Visible','on','Callback',@hResultListCallback,'Tag','OutputObjList','Style','listbox');
65 hResultListCallback(OutputObjList,1)
66 clear DataPanPos nlists listWidth listPos
67
68
69 %%
70 %----------------------------------------------------------------------
71 function UpdateListbox(varargin)
72 % Updates the LTPDAoutvar listbox
73
74 %==================================
75 % Update the list of results AOs
76 xx = size(LTPDAoutvar,1);
77 listResults = cell(xx,1);
78 if xx>0
79 for j=1:xx
80 listResults{j,1} = num2str(j);
81 [rows,columns] = size(LTPDAoutvar{j,1});
82 if (rows>1 && columns==1) || (rows==1 && columns>1), listResults{j,1} = [listResults{j,1}, ' .(Vector ',num2str(rows),'x',num2str(columns),') '];
83 elseif rows>1 && columns>1, listResults{j,1} = [listResults{j,1}, ' .(Matrix ',num2str(rows),'x',num2str(columns),') '];
84 end
85 switch class(LTPDAoutvar{j,1})
86 case 'ao'
87 anobject = LTPDAoutvar{j,1};
88 aoname = anobject.name;
89 aocreated = char(anobject.created);
90 listResults{j,1} = [listResults{j,1}, ' . AO .' , aoname , '__' , aocreated];
91 case 'plist'
92 paramNumb = nparams(LTPDAoutvar{j,1});
93 objcreated = char(LTPDAoutvar{j,1}.created);
94 listResults{j,1}=[listResults{j,1}, ' . PLIST .',num2str(paramNumb),' params','__',objcreated];
95 case {'pzmodel','miir','mfir'}
96 objcreated = char(LTPDAoutvar{j,1}.created);
97 listResults{j,1}=[listResults{j,1}, ' . ',upper(class(LTPDAoutvar{j,1})),' .__',objcreated];
98 case 'double'
99 if numel(LTPDAoutvar{j,1})==1, objclass = ' . Scalar .__ ';
100 elseif size(LTPDAoutvar{j,1},1)==1 || size(LTPDAoutvar{j,1},2)==1, objclass = ' . Vector .__ ';
101 else objclass = ' . Matrix .__ ';
102 end
103 listResults{j,1}=[listResults{j,1}, objclass, mat2str(LTPDAoutvar{j,1})];
104 otherwise
105 listResults{j,1}=[listResults{j,1}, ' . ',class(LTPDAoutvar{j,1})];
106 end
107 end
108 for j=xx:-1:1, if isempty(listResults{j,1}), listResults(j,:)=[]; end; end
109 else
110 listResults{1,1}='The workspace is empty';
111 end
112
113 OutputObjList = findobj('Tag','OutputObjList');
114 if ~isempty(OutputObjList)
115 set(OutputObjList,'Value',1)
116 set(OutputObjList,'String',listResults)
117 end
118
119 %==================================
120
121 end
122 %----------------------------------------------------------------------
123
124 %----------------------------------------------------------------------
125 function hResultListCallback(hObject, varargin)
126 % This callback is called whenever the user double click upon one of
127 % the AOs in use.
128 if ~isempty(varargin{1}) && varargin{1}==1 && size(LTPDAoutvar,1)>0
129 val = get(hObject, 'Value');
130 if length(val) == 1
131 objLines = get(hObject, 'String');
132 if isempty(objLines)
133 objtxt = '';
134 else
135 objnumb = str2double(deblank(strtok(objLines{val})));
136 objtxt = display(LTPDAoutvar{objnumb});
137 end
138 else
139 objtxt = '';
140 end
141 set(findobj('Tag', 'infoPanel'), 'String', objtxt)
142 elseif size(LTPDAoutvar,1)>0
143 if strcmp(get(gcf,'SelectionType'),'normal')
144 val = get(hObject, 'Value');
145 if length(val) == 1
146 objLines = get(hObject, 'String');
147 objnumb = str2double(deblank(strtok(objLines{val})));
148 objtxt = display(LTPDAoutvar{objnumb});
149 else
150 objtxt = '';
151 end
152 set(findobj('Tag', 'infoPanel'), 'String', objtxt)
153 end
154 if strcmp(get(gcf,'SelectionType'),'open') && ~isempty(get(hObject, 'String'))
155 try %#ok<ALIGN>
156 currIndex = get(hObject,'Value');
157 figure
158 plot(LTPDAoutvar{currIndex,1});
159 catch
160 close(gcf)
161 end
162 end
163 end
164
165 end
166 %----------------------------------------------------------------------
167
168 %%
169 % %----------------------------------------------------------------------
170 % function SaveWorkspaceCallback(varargin)
171 % % Callback function: run when the user click the "Clear all data"
172 % % button
173 %
174 % try
175 % [FileName,PathName,FilterIndex] = uiputfile('*.mat','Save Workspace As');
176 % if ~isa(FileName,'double'), save(strcat(PathName,FileName),'LTPDAoutvar'); disp('Workspace saved'); end
177 % disp('Output saved')
178 % catch
179 % end
180 % end
181 % %----------------------------------------------------------------------
182
183 %----------------------------------------------------------------------
184 function AskConfirm(varargin)
185 % Whenever the user click the Reset Parameters button
186
187 if strcmp(varargin{3},'close'), set(gcf,'Visible','off'); end
188
189 % Ask for confirmation:
190 screenSize = get(0,'ScreenSize');
191 backColor = [1 1 1];
192 position = [(screenSize(3)-250)/2,(screenSize(4)-160)/2,250,160];
193 confirmFig = figure('Position',position,'Name','Please confirm','Tag','ConfirmReset','Resize','off','NumberTitle','off','Toolbar','none','Menubar','none');
194 % Text
195 uicontrol('Parent',confirmFig,'BackgroundColor',backColor,'HorizontalAlignment','center','Position',[0 position(4)-40 position(3) 20],'String','Are you sure?','FontName','Times New Roman','FontSize',13,'FontWeight','normal','Visible','on','Style','text');
196 % Button Yes
197 dimension = position;
198 logosize = [77 95];
199 dimension = [50 , dimension(4)-logosize(2)-50 , logosize];
200 yesbut = axes('Parent',confirmFig,'Units','pixels','Position',dimension,'Tag','Yes');
201 image(imread('buttonyes2.jpg'),'Parent',yesbut,'ButtonDownFcn','set(findobj(''Tag'',''ConfirmReset''),''UserData'',0); uiresume;','Tag','YesButton');
202 axis(yesbut,'off');
203 % Button No
204 dimension = position;
205 logosize = [77 95];
206 dimension = [127 , dimension(4)-logosize(2)-50 , logosize];
207 nobut = axes('Parent',confirmFig,'Units','pixels','Position',dimension,'Tag','No');
208 image(imread('buttonno2.jpg'),'Parent',nobut,'ButtonDownFcn','set(findobj(''Tag'',''ConfirmReset''),''UserData'',1); uiresume;','Tag','NoButton');
209 axis(nobut,'off');
210
211 uiwait;
212
213 if get(confirmFig,'UserData'), delete(confirmFig); set(findobj('Tag','LTPDAGUI'),'Visible','on'); return; end
214
215 if strcmp(varargin{3},'close')
216 delete(confirmFig);
217 disp('Closing LTPDA GUI...');
218 delete(timerfindall);
219 clear global LTPDAinvar LTPDAoutvar;
220 setappdata(0,'ltpda_repo_user',''); setappdata(0,'ltpda_repo_pass','');
221 closereq
222 elseif strcmp(varargin{3},'clear')
223 delete(confirmFig);
224 LTPDAoutvar={};
225 set(OutputObjList,'Value',1)
226 set(findobj('Tag', 'infoPanel'), 'String', '')
227 set_param(find_system(bdroot,'FindAll','on','Type','Annotation','Tag','ltpda model'),'UserData','');
228 UpdateListbox();
229 end
230
231 end
232 %----------------------------------------------------------------------
233
234 %----------------------------------------------------------------------
235 function hRemoveButtonCallback(varargin)
236 % Callback function: run when the user click the "Remove data" button
237
238 index_selected = get(OutputObjList,'Value');
239 listObjs = get(OutputObjList,'String');
240 if ~strcmp(listObjs,'The memory is empty')
241 for i=1:numel(index_selected)
242 objSelect = str2double(strtok(listObjs{index_selected(i),1},'.'));
243 LTPDAoutvar(objSelect,:) = [];
244 end
245 UpdateListbox();
246 end
247 set(findobj('Tag', 'infoPanel'), 'String', '')
248
249 end
250 %----------------------------------------------------------------------
251
252 %----------------------------------------------------------------------
253 function hExportButtonCallback(varargin)
254 % Callback function: run when the user click the "Remove data" button
255
256 currSelObjs = get(OutputObjList,'Value');
257 listObjs = get(OutputObjList,'String');
258 if ~strcmp(listObjs,'The memory is empty')
259 selectedObjs = {};
260 for i=1:numel(currSelObjs)
261 objSelect = str2double(strtok(listObjs{currSelObjs(i),1},'.'));
262 selectedObjs = [selectedObjs,LTPDAoutvar(objSelect,1)];
263 end
264 if ~isempty(selectedObjs)
265 for i=1:numel(selectedObjs)
266 objName = [class(selectedObjs{i}),'_',selectedObjs{i}.name];
267 objName = genvarname(objName,evalin('base','who'));
268 assignin('base', objName, selectedObjs{i});
269 disp(['Saved to workspace with name ',objName])
270 end
271 end
272 end
273
274 end
275 %----------------------------------------------------------------------
276
277 %----------------------------------------------------------------------
278 function hExploreButtonCallback(varargin)
279 % Callback function: run when the user click the "Update list" button
280
281 currSelObjs = get(OutputObjList,'Value');
282 listObjs = get(OutputObjList,'String');
283 if ~strcmp(listObjs,'The memory is empty')
284 selectedObjs = {};
285 for i=1:numel(currSelObjs)
286 objSelect = str2double(strtok(listObjs{currSelObjs(i),1},'.'));
287 selectedObjs = [selectedObjs,LTPDAoutvar(objSelect,1)];
288 end
289
290 if ~isempty(selectedObjs)
291 ltpda_explorer(selectedObjs);
292 else
293 ltpda_explorer(LTPDAoutvar);
294 end
295
296 UpdateListbox();
297 end
298
299 end
300 %----------------------------------------------------------------------
301
302
303 %%
304 end