Home > m > gui > gltpda > pan5output.m

pan5output

PURPOSE ^

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

SYNOPSIS ^

function varargout = 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.14 2008/03/28 16:24:44 nicola Exp $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function varargout = 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.14 2008/03/28 16:24:44 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','off');
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','text','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                  switch class(LTPDAoutvar{j,1})
0075                      case 'ao'
0076                          anobject  = LTPDAoutvar{j,1};
0077                          aoname    = anobject.name;
0078                          aocreated = get(get(anobject.provenance, 'created'),'time_str');
0079                          listResults{j,1} = [num2str(j) , ' . AO .' , aoname , '__' , aocreated];
0080                      case 'plist'
0081                          paramNumb = nparams(LTPDAoutvar{j,1});
0082                          objcreated = get(LTPDAoutvar{j,1}.created,'time_str');
0083                          listResults{j,1}=[num2str(j),' . PLIST .',num2str(paramNumb),' params','__',objcreated];
0084                      case 'specwin'
0085                          listResults{j,1}=[num2str(j),' . SPECWIN .','__','no creation time'];
0086                      case 'pzmodel'
0087                          objcreated = get(LTPDAoutvar{j,1}.created,'time_str');
0088                          listResults{j,1}=[num2str(j),' . PZMODEL .','__',objcreated];
0089                      case 'miir'
0090                          objcreated = get(LTPDAoutvar{j,1}.created,'time_str');
0091                          listResults{j,1}=[num2str(j),' . MIIR .','__',objcreated];
0092                      otherwise
0093                          if ltpda_isuserobject(LTPDAoutvar{j,1})
0094                              objclass  = class(LTPDAoutvar{j,1});
0095                              if ~isempty(LTPDAoutvar{j,1}), listResults{j,1}=[num2str(j),' . ',objclass]; end
0096                          end
0097                  end
0098              end
0099              for j=xx:-1:1
0100                  if isempty(listResults{j,1})
0101                      listResults(j,:)=[];
0102                  end                     
0103              end
0104          else
0105              listResults{1,1}='The memory is empty';
0106          end
0107          
0108          OutputObjList = findobj('Tag','OutputObjList');
0109          if ~isempty(OutputObjList)
0110              set(OutputObjList,'Value',1)
0111              set(OutputObjList,'String',listResults)
0112          end
0113          
0114          %==================================
0115 
0116     end
0117     %----------------------------------------------------------------------
0118 
0119 %%
0120     %----------------------------------------------------------------------
0121     function hResultListCallback(hObject, varargin)
0122     % This callback is called whenever the user double click upon one of
0123     % the AOs in use.
0124         if ~isempty(varargin{1}) && varargin{1}==1 && size(LTPDAoutvar,1)>0
0125                 val = get(hObject, 'Value');
0126                 if length(val) == 1
0127                     objLines = get(hObject, 'String');
0128                     if isempty(objLines)
0129                         objtxt = '';
0130                     else
0131                         objnumb = str2double(deblank(strtok(objLines{val})));
0132                         objtxt = display(LTPDAoutvar{objnumb});
0133                     end
0134                 else
0135                     objtxt = '';
0136                 end
0137                 set(findobj('Tag', 'infoPanel'), 'String', objtxt)
0138         elseif size(LTPDAoutvar,1)>0
0139             if strcmp(get(gcf,'SelectionType'),'normal')
0140                 val = get(hObject, 'Value');
0141                 if length(val) == 1
0142                     objLines = get(hObject, 'String');
0143                     objnumb = str2double(deblank(strtok(objLines{val})));
0144                     objtxt = display(LTPDAoutvar{objnumb});
0145                 else
0146                     objtxt = '';
0147                 end
0148                 set(findobj('Tag', 'infoPanel'), 'String', objtxt)
0149             end
0150             if strcmp(get(gcf,'SelectionType'),'open') && ~isempty(get(hObject, 'String'))
0151                 try %#ok<ALIGN>
0152                     currAO=get(hObject,'Value');
0153                     figure
0154                     plot(LTPDAoutvar{currAO,1});
0155                 catch
0156                     close(gcf)
0157                 end
0158             end
0159         end
0160          
0161     end
0162     %----------------------------------------------------------------------
0163 
0164 %     %----------------------------------------------------------------------
0165 %     function SaveWorkspaceCallback(varargin)
0166 %     % Callback function: run when the user click the "Clear all data"
0167 %     % button
0168 %
0169 %          try
0170 %              [FileName,PathName,FilterIndex] = uiputfile('*.mat','Save Workspace As');
0171 %              if ~isa(FileName,'double'), save(strcat(PathName,FileName),'LTPDAoutvar'); disp('Workspace saved'); end
0172 %              disp('Output saved')
0173 %          catch
0174 %          end
0175 %     end
0176 %     %----------------------------------------------------------------------
0177 
0178     %----------------------------------------------------------------------
0179     function hClearButtonCallback(varargin)
0180     % Callback function: run when the user click the "Clear all data"
0181     % button
0182 
0183          LTPDAoutvar={};
0184          set(OutputObjList,'Value',1)
0185          set(findobj('Tag', 'infoPanel'), 'String', '')
0186          UpdateListbox();
0187 
0188     end
0189     %----------------------------------------------------------------------
0190 
0191     %----------------------------------------------------------------------
0192     function hExportButtonCallback(varargin)   
0193     % Callback function: run when the user click the "Remove data" button
0194 
0195          currSelObjs   = get(OutputObjList,'Value');
0196          listAOs = get(OutputObjList,'String');
0197          if ~strcmp(listAOs,'The memory is empty')
0198              selectedObjs  = {};
0199              for i=1:numel(currSelObjs)
0200                  objSelect = str2double(strtok(listAOs{currSelObjs(i),1},'.'));
0201                  selectedObjs = [selectedObjs,LTPDAoutvar(objSelect,1)];
0202              end
0203              if ~isempty(selectedObjs)
0204                  for i=1:numel(selectedObjs)
0205                      objName = [class(selectedObjs{i}),'_',selectedObjs{i}.name];
0206                      objName = genvarname(objName,evalin('base','who'));
0207                      assignin('base', objName, selectedObjs{i});
0208                      disp(['Saved to workspace with name ',objName])
0209                  end
0210              end
0211          end
0212          
0213     end
0214     %----------------------------------------------------------------------
0215 
0216 %%
0217 end

Generated on Mon 31-Mar-2008 13:54:54 by m2html © 2003