Home > m > gui > gltpda > pan4import.m

pan4import

PURPOSE ^

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

SYNOPSIS ^

function pan4import(varargin)

DESCRIPTION ^

 ========================================================================
 =============== Panel to import data from the workspace ================
 ========================================================================

  $Id: pan4import.m,v 1.8 2008/08/30 12:27:08 nicola Exp $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function pan4import(varargin)
0002 
0003 % ========================================================================
0004 % =============== Panel to import data from the workspace ================
0005 % ========================================================================
0006 %
0007 %  $Id: pan4import.m,v 1.8 2008/08/30 12:27:08 nicola Exp $
0008 
0009 global LTPDAinvar
0010 
0011 ImportObjList='';
0012 UpdateListbox();
0013 
0014 currPanel   = varargin{1};
0015 panelDimens = get(currPanel, 'Position');
0016 backColor   = get(currPanel, 'BackgroundColor');
0017 
0018     DataPanPos   = [20 panelDimens(4)-470 panelDimens(3)-40 450];
0019   hDataPanel    =  uipanel(...
0020                       'Title','Data currently in the workspace',...
0021                       'BackgroundColor',[1,1,1],...
0022                       'FontSize',7,...
0023                       'Units','pixels',...
0024                       'Position',DataPanPos);
0025    
0026     nbuttons    = 3;
0027     buttonWidth = (DataPanPos(3)-10*(nbuttons+1))/nbuttons;
0028     buttonPos   = [10 DataPanPos(4)-45 buttonWidth 25];
0029   hPlotButton   =   uicontrol('Parent',hDataPanel,'Units','pixels','HorizontalAlignment','center','Position',buttonPos,'String','Plot','FontSize',8,'Visible','on','Callback','','Style','pushbutton','enable','off');
0030     buttonPos(1) = buttonPos(1)+buttonWidth+10;
0031   hRefreshButton =   uicontrol('Parent',hDataPanel,'Units','pixels','HorizontalAlignment','center','Position',buttonPos,'String','Refresh','FontSize',8,'Visible','on','Callback',@UpdateListbox,'Style','pushbutton','enable','on');
0032     buttonPos(1) = buttonPos(1)+buttonWidth+10;
0033   hImportButton =   uicontrol('Parent',hDataPanel,'Units','pixels','HorizontalAlignment','center','Position',buttonPos,'String','Import','FontSize',8,'Visible','on','Callback',@ImportCallback,'Style','pushbutton','enable','on');
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',ImportObjList,'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','FontSize',8,'Visible','on','Enable','off','Callback',@SaveOutputCallback,'Style','pushbutton');
0038 %     clear nbuttons buttonWidth buttonPos
0039 
0040 
0041     textWidth = (DataPanPos(3)-10*(3))/2;
0042     textPos   = [10 DataPanPos(4)-80 textWidth 25];
0043   uicontrol('Parent',hDataPanel,'BackgroundColor',get(hDataPanel,'BackgroundColor'),'HorizontalAlignment','center','Position',textPos,'String','Objects:','FontName','Times New Roman','FontSize',8,'FontWeight','normal','Visible','on','Style','text');
0044     clear textWidth textPos
0045 
0046     nlists    = 2;
0047     listWidth = (DataPanPos(3)-10*(nlists+1))/nlists;
0048     listPos   = [10 DataPanPos(4)-315 listWidth 240];
0049   ImportObjList   =   uicontrol('Parent',hDataPanel,'BackgroundColor',[0.95,0.95,0.95],'HorizontalAlignment','center','Position',listPos,'String',listInput,'Value',[],'Max',10,'Min',0,'FontSize',8,'FontWeight','normal','Visible','on','Enable','on','Tag','ImportObjList','Callback',@hImportListCallback,'Style','listbox');
0050     listPos(1) = listPos(1)+listWidth+10;
0051   % Info panel:
0052   uicontrol('Parent',hDataPanel,'BackgroundColor',[0.94,0.94,1],'Style','text','HorizontalAlignment', 'left','Fontsize', 7,'Units','pixels','Position',listPos,'Tag','infoPanel');
0053     hImportListCallback(ImportObjList,1)
0054     clear DataPanPos nlists listWidth listPos
0055 
0056         
0057 %%
0058     %----------------------------------------------------------------------
0059     function UpdateListbox(varargin)
0060     % Updates the listbox of objects in the current workspace
0061     
0062         listInput = evalin('base','who');
0063         
0064         for i=numel(listInput):-1:1
0065             obj = evalin('base',listInput{i});
0066             if ~isa(obj,'ltpda_uo') || isa(obj,'cell'), listInput(i)=[]; end
0067         end
0068         
0069         if isempty(listInput)
0070             listInput = 'No LTPDA objects currently in the MATLAB workspace';
0071             set(findobj('Tag', 'ImportObjList'),'Enable', 'off','Value',[],'String',listInput)
0072         else
0073             set(findobj('Tag', 'ImportObjList'),'Enable', 'on','Value',[],'String',listInput)
0074         end
0075         
0076     end
0077     %----------------------------------------------------------------------
0078 
0079 %%
0080     %----------------------------------------------------------------------
0081     function hImportListCallback(hObject, varargin)
0082     % This callback is called whenever the user click upon one of the
0083     % objects in the workspace
0084     
0085         if ~isempty(varargin{1}) && varargin{1}==1 && ~isa(listInput,'char')
0086               % This is a call only to update the info panel
0087                 val = get(hObject, 'Value');
0088                 if length(val) == 1
0089                     objLines = get(hObject, 'String');
0090                     if isempty(objLines)
0091                         objtxt = '';
0092                     else
0093                         objname = objLines{val};
0094                         obj = evalin('base',objname);
0095                         objtxt = display(obj);
0096                     end
0097                 else
0098                     objtxt = '';
0099                 end
0100                 set(findobj('Tag', 'infoPanel'), 'String', objtxt)
0101         elseif ~isa(listInput,'char')
0102             if strcmp(get(gcf,'SelectionType'),'normal')
0103                 val = get(hObject, 'Value');
0104                 if length(val) == 1
0105                     objLines = get(hObject, 'String');
0106                     objname = objLines{val};
0107                     obj = evalin('base',objname);
0108                     objtxt = display(obj);
0109                 else
0110                     objtxt = '';
0111                 end
0112                 set(findobj('Tag', 'infoPanel'), 'String', objtxt)
0113             end
0114             if strcmp(get(gcf,'SelectionType'),'open') && ~isempty(get(hObject, 'String'))
0115                 val = get(hObject, 'Value');
0116                 objLines = get(hObject, 'String');
0117                 objname = objLines{val};
0118                 obj = evalin('base',objname);
0119                 try %#ok<ALIGN>
0120                     figure
0121                     plot(obj);
0122                 catch
0123                     close(gcf)
0124                 end
0125             end
0126         end
0127          
0128     end
0129     %----------------------------------------------------------------------
0130 
0131     %----------------------------------------------------------------------
0132     function ImportCallback(varargin)
0133     % This callback is called whenever the user click the 'Import' button
0134 
0135         objList = findobj('Tag', 'ImportObjList');
0136         val     = get(objList, 'Value');
0137         objLines   = get(objList, 'String');
0138         for i = 1:numel(val)
0139             objname = objLines{val(i)};
0140             obj = evalin('base',objname);
0141             nobj = numel(obj);
0142             if nobj>1
0143                 for jj=1:nobj
0144                     objj = {obj(jj) , 0};
0145                     LTPDAinvar = [LTPDAinvar;objj];
0146                 end
0147             else
0148                 obj = {obj , 0};
0149                 LTPDAinvar = [LTPDAinvar;obj];
0150             end
0151         end
0152         set(findobj('Tag', 'ImportObjList'),'Value',[])
0153              
0154     end
0155     %----------------------------------------------------------------------
0156 
0157 %%
0158 end

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