Home > m > gui > gltpda > pan5output.m

pan5output

PURPOSE ^

========================================================================

SYNOPSIS ^

function pan5output(varargin)

DESCRIPTION ^

 ========================================================================
 ====================== Panel for the outputs ===========================
 ========================================================================
 This is the GUI m-file to show that the panel relative to the outputs

  $Id: pan5output.m,v 1.16 2008/08/12 18:50:06 nicola Exp $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function pan5output(varargin)
0002 
0003 % ========================================================================
0004 % ====================== Panel for the outputs ===========================
0005 % ========================================================================
0006 % This is the GUI m-file to show that the panel relative to the outputs
0007 %
0008 %  $Id: pan5output.m,v 1.16 2008/08/12 18:50:06 nicola Exp $
0009 
0010 global LTPDAoutvar
0011 
0012 InputObjList=''; OutputObjList='';
0013 UpdateListbox();
0014 
0015 currPanel   = varargin{1};
0016 panelDimens = get(currPanel, 'Position');
0017 backColor   = get(currPanel, 'BackgroundColor');
0018 
0019     DataPanPos   = [20 panelDimens(4)-320 panelDimens(3)-40 285];
0020   hDataPanel    =  uipanel(...
0021                       'Title','Data Control Panel',...
0022                       'BackgroundColor',[1,1,1],...
0023                       'FontSize',7,...
0024                       'Units','pixels',...
0025                       'Position',DataPanPos);
0026     nbuttons    = 5;
0027     buttonWidth = (DataPanPos(3)-10*(nbuttons+1))/nbuttons;
0028     buttonPos   = [10 DataPanPos(4)-45 buttonWidth 25];
0029   hExportButton =   uicontrol('Parent',hDataPanel,'Units','pixels','HorizontalAlignment','center','Position',buttonPos,'String','Export to workspace','FontSize',8,'Visible','on','Callback',@hExportButtonCallback,'Style','pushbutton','enable','on');
0030     buttonPos(1) = buttonPos(1)+buttonWidth+10;
0031   hRemoveButton =   uicontrol('Parent',hDataPanel,'Units','pixels','HorizontalAlignment','center','Position',buttonPos,'String','Remove','FontSize',8,'Visible','on','Callback',@hRemoveButtonCallback,'Style','pushbutton','enable','off');
0032     buttonPos(1) = buttonPos(1)+buttonWidth+10;
0033   hRepoButton   =   uicontrol('Parent',hDataPanel,'Units','pixels','HorizontalAlignment','center','Position',buttonPos,'String','Send to repository','FontSize',8,'Visible','on','Callback',@hClearButtonCallback,'Style','pushbutton','enable','off');
0034     buttonPos(1) = buttonPos(1)+buttonWidth+10;
0035   hExploreButton =  uicontrol('Parent',hDataPanel,'Units','pixels','HorizontalAlignment','center','Position',buttonPos,'String','Explore','FontSize',8,'Visible','on','UserData',InputObjList,'Callback',@hExploreButtonCallback,'Style','pushbutton','enable','on');
0036 %     buttonPos(1) = buttonPos(1)+buttonWidth+10;
0037 %   hSaveOutButton =  uicontrol('Parent',hDataPanel,'Units','pixels','HorizontalAlignment','center','Position',buttonPos,'String','Save workspace','FontSize',8,'Visible','on','Enable','on','Callback',@SaveWorkspaceCallback,'Style','pushbutton');
0038     buttonPos(1) = buttonPos(1)+buttonWidth+10;
0039   hClearButton  =   uicontrol('Parent',hDataPanel,'Units','pixels','HorizontalAlignment','center','Position',buttonPos,'String','Clear output','FontSize',8,'Visible','on','Enable','on','Callback',@hClearButtonCallback,'Style','pushbutton');
0040     clear nbuttons buttonWidth buttonPos
0041 
0042 
0043     ntexts    = 2;
0044     textWidth = (DataPanPos(3)-10*(ntexts+1))/ntexts;
0045     textPos   = [10 DataPanPos(4)-80 textWidth 25];
0046   % 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');
0047     textPos(1) = textPos(1)+textWidth+10;
0048   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');
0049     clear ntexts textWidth textPos
0050 
0051 
0052     nlists    = 2;
0053     listWidth = (DataPanPos(3)-10*(nlists+1))/nlists;
0054     listPos   = [10 DataPanPos(4)-275 listWidth 200];
0055   % Info panel:
0056   uicontrol('Parent',hDataPanel,'BackgroundColor',[0.94,0.94,1],'Style','listbox','HorizontalAlignment', 'left','Fontsize', 8,'Units','pixels','Position',listPos,'Tag','infoPanel');
0057     listPos(1) = listPos(1)+listWidth+10;
0058   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');
0059     hResultListCallback(OutputObjList,1)
0060     clear DataPanPos nlists listWidth listPos
0061     
0062     
0063 %%
0064     %----------------------------------------------------------------------
0065     function UpdateListbox(varargin)
0066     % Updates the LTPDAoutvar listbox
0067 
0068          %==================================
0069          % Update the list of results AOs
0070          xx = size(LTPDAoutvar,1);
0071          listResults = cell(xx,1);
0072          if xx>0
0073              for j=1:xx
0074                  listResults{j,1} = num2str(j);
0075                  [rows,columns] = size(LTPDAoutvar{j,1});
0076                  if (rows>1 && columns==1) || (rows==1 && columns>1), listResults{j,1} = [listResults{j,1}, ' .(Vector ',num2str(rows),'x',num2str(columns),') '];
0077                  elseif rows>1 && columns>1, listResults{j,1} = [listResults{j,1}, ' .(Matrix ',num2str(rows),'x',num2str(columns),') '];
0078                  end
0079                  switch class(LTPDAoutvar{j,1})
0080                      case 'ao'
0081                          anobject  = LTPDAoutvar{j,1};
0082                          aoname    = anobject.name;
0083                          aocreated = char(anobject.created);
0084                          listResults{j,1} = [listResults{j,1} , ' . AO .' , aoname , '__' , aocreated];
0085                      case 'plist'
0086                          paramNumb = nparams(LTPDAoutvar{j,1});
0087                          objcreated = get(LTPDAoutvar{j,1}.created,'time_str');
0088                          listResults{j,1}=[listResults{j,1},' . PLIST .',num2str(paramNumb),' params','__',objcreated];
0089                      case 'specwin'
0090                          listResults{j,1}=[listResults{j,1},' . SPECWIN .','__','no creation time'];
0091                      case 'pzmodel'
0092                          objcreated = get(LTPDAoutvar{j,1}.created,'time_str');
0093                          listResults{j,1}=[listResults{j,1},' . PZMODEL .','__',objcreated];
0094                      case 'miir'
0095                          objcreated = get(LTPDAoutvar{j,1}.created,'time_str');
0096                          listResults{j,1}=[listResults{j,1},' . MIIR .','__',objcreated];
0097                      otherwise
0098                          if isa(LTPDAoutvar{j,1},'ltpda_uo')
0099                              objclass  = class(LTPDAoutvar{j,1});
0100                              if ~isempty(LTPDAoutvar{j,1}), listResults{j,1} = [listResults{j,1},' . ',objclass]; end
0101                          end
0102                  end
0103              end
0104              for j=xx:-1:1
0105                  if isempty(listResults{j,1})
0106                      listResults(j,:)=[];
0107                  end                     
0108              end
0109          else
0110              listResults{1,1}='The memory is empty';
0111          end
0112          
0113          OutputObjList = findobj('Tag','OutputObjList');
0114          if ~isempty(OutputObjList)
0115              set(OutputObjList,'Value',1)
0116              set(OutputObjList,'String',listResults)
0117          end
0118          
0119          %==================================
0120 
0121     end
0122     %----------------------------------------------------------------------
0123 
0124 %%
0125     %----------------------------------------------------------------------
0126     function hResultListCallback(hObject, varargin)
0127     % This callback is called whenever the user double click upon one of
0128     % the AOs in use.
0129         if ~isempty(varargin{1}) && varargin{1}==1 && size(LTPDAoutvar,1)>0
0130                 val = get(hObject, 'Value');
0131                 if length(val) == 1
0132                     objLines = get(hObject, 'String');
0133                     if isempty(objLines)
0134                         objtxt = '';
0135                     else
0136                         objnumb = str2double(deblank(strtok(objLines{val})));
0137                         objtxt = display(LTPDAoutvar{objnumb});
0138                     end
0139                 else
0140                     objtxt = '';
0141                 end
0142                 set(findobj('Tag', 'infoPanel'), 'String', objtxt)
0143         elseif size(LTPDAoutvar,1)>0
0144             if strcmp(get(gcf,'SelectionType'),'normal')
0145                 val = get(hObject, 'Value');
0146                 if length(val) == 1
0147                     objLines = get(hObject, 'String');
0148                     objnumb = str2double(deblank(strtok(objLines{val})));
0149                     objtxt = display(LTPDAoutvar{objnumb});
0150                 else
0151                     objtxt = '';
0152                 end
0153                 set(findobj('Tag', 'infoPanel'), 'String', objtxt)
0154             end
0155             if strcmp(get(gcf,'SelectionType'),'open') && ~isempty(get(hObject, 'String'))
0156                 try %#ok<ALIGN>
0157                     currIndex = get(hObject,'Value');
0158                     figure
0159                     plot(LTPDAoutvar{currIndex,1});
0160                 catch
0161                     close(gcf)
0162                 end
0163             end
0164         end
0165          
0166     end
0167     %----------------------------------------------------------------------
0168 
0169 %     %----------------------------------------------------------------------
0170 %     function SaveWorkspaceCallback(varargin)
0171 %     % Callback function: run when the user click the "Clear all data"
0172 %     % button
0173 %
0174 %          try
0175 %              [FileName,PathName,FilterIndex] = uiputfile('*.mat','Save Workspace As');
0176 %              if ~isa(FileName,'double'), save(strcat(PathName,FileName),'LTPDAoutvar'); disp('Workspace saved'); end
0177 %              disp('Output saved')
0178 %          catch
0179 %          end
0180 %     end
0181 %     %----------------------------------------------------------------------
0182 
0183     %----------------------------------------------------------------------
0184     function hClearButtonCallback(varargin)
0185     % Callback function: run when the user click the "Clear all data"
0186     % button
0187 
0188          LTPDAoutvar={};
0189          set(OutputObjList,'Value',1)
0190          set(findobj('Tag', 'infoPanel'), 'String', '')
0191          UpdateListbox();
0192 
0193     end
0194     %----------------------------------------------------------------------
0195 
0196     %----------------------------------------------------------------------
0197     function hExportButtonCallback(varargin)   
0198     % Callback function: run when the user click the "Remove data" button
0199 
0200          currSelObjs   = get(OutputObjList,'Value');
0201          listObjs = get(OutputObjList,'String');
0202          if ~strcmp(listObjs,'The memory is empty')
0203              selectedObjs  = {};
0204              for i=1:numel(currSelObjs)
0205                  objSelect = str2double(strtok(listObjs{currSelObjs(i),1},'.'));
0206                  selectedObjs = [selectedObjs,LTPDAoutvar(objSelect,1)];
0207              end
0208              if ~isempty(selectedObjs)
0209                  for i=1:numel(selectedObjs)
0210                      objName = [class(selectedObjs{i}),'_',selectedObjs{i}.name];
0211                      objName = genvarname(objName,evalin('base','who'));
0212                      assignin('base', objName, selectedObjs{i});
0213                      disp(['Saved to workspace with name ',objName])
0214                  end
0215              end
0216          end
0217          
0218     end
0219     %----------------------------------------------------------------------
0220 
0221     %----------------------------------------------------------------------
0222     function hExploreButtonCallback(varargin)   
0223     % Callback function: run when the user click the "Update list" button
0224 
0225          currSelObjs   = get(OutputObjList,'Value');
0226          listObjs = get(OutputObjList,'String');
0227          if ~strcmp(listObjs,'The memory is empty')
0228              selectedObjs  = {};
0229              for i=1:numel(currSelObjs)
0230                  objSelect = str2double(strtok(listObjs{currSelObjs(i),1},'.'));
0231                  selectedObjs = [selectedObjs,LTPDAoutvar(objSelect,1)];
0232              end
0233 
0234              if ~isempty(selectedObjs)
0235                  ltpda_explorer(selectedObjs);
0236              else
0237                  ltpda_explorer(LTPDAoutvar);
0238              end
0239 
0240              UpdateListbox();
0241          end
0242 
0243     end
0244     %----------------------------------------------------------------------
0245 
0246 
0247 %%
0248 end

Generated on Mon 08-Sep-2008 13:18:47 by m2html © 2003