Home > m > gui > gltpda > pan4import.m

pan4import

PURPOSE ^

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

SYNOPSIS ^

function varargout = pan4import(varargin)

DESCRIPTION ^

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

  $Id: pan4import.m,v 1.5 2008/03/21 16:33:49 nicola Exp $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function varargout = pan4import(varargin)
0002 
0003 % ========================================================================
0004 % =============== Panel to import data from the workspace ================
0005 % ========================================================================
0006 %
0007 %  $Id: pan4import.m,v 1.5 2008/03/21 16:33:49 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             if ~ltpda_isuserobject(evalin('base',listInput{i})), listInput(i)=[]; end
0066         end
0067         
0068         if isempty(listInput)
0069             listInput = 'No LTPDA objects currently in the MATLAB workspace';
0070             set(findobj('Tag', 'ImportObjList'),'Enable', 'off','Value',[],'String',listInput)
0071         else
0072             set(findobj('Tag', 'ImportObjList'),'Enable', 'on','Value',[],'String',listInput)
0073         end
0074         
0075     end
0076     %----------------------------------------------------------------------
0077 
0078 %%
0079     %----------------------------------------------------------------------
0080     function hImportListCallback(hObject, varargin)
0081     % This callback is called whenever the user click upon one of the
0082     % objects in the workspace
0083     
0084         if ~isempty(varargin{1}) && varargin{1}==1 && ~isa(listInput,'char')
0085               % This is a call only to update the info panel
0086                 val = get(hObject, 'Value');
0087                 if length(val) == 1
0088                     objLines = get(hObject, 'String');
0089                     if isempty(objLines)
0090                         objtxt = '';
0091                     else
0092                         objname = objLines{val};
0093                         obj = evalin('base',objname);
0094                         objtxt = display(obj);
0095                     end
0096                 else
0097                     objtxt = '';
0098                 end
0099                 set(findobj('Tag', 'infoPanel'), 'String', objtxt)
0100         elseif ~isa(listInput,'char')
0101             if strcmp(get(gcf,'SelectionType'),'normal')
0102                 val = get(hObject, 'Value');
0103                 if length(val) == 1
0104                     objLines = get(hObject, 'String');
0105                     objname = objLines{val};
0106                     obj = evalin('base',objname);
0107                     objtxt = display(obj);
0108                 else
0109                     objtxt = '';
0110                 end
0111                 set(findobj('Tag', 'infoPanel'), 'String', objtxt)
0112             end
0113             if strcmp(get(gcf,'SelectionType'),'open') && ~isempty(get(hObject, 'String'))
0114                 val = get(hObject, 'Value');
0115                 objLines = get(hObject, 'String');
0116                 objname = objLines{val};
0117                 obj = evalin('base',objname);
0118                 try %#ok<ALIGN>
0119                     figure
0120                     plot(obj);
0121                 catch
0122                     close(gcf)
0123                 end
0124             end
0125         end
0126          
0127     end
0128     %----------------------------------------------------------------------
0129 
0130     %----------------------------------------------------------------------
0131     function ImportCallback(varargin)
0132     % This callback is called whenever the user click the 'Import' button
0133 
0134         objList = findobj('Tag', 'ImportObjList');
0135         val     = get(objList, 'Value');
0136         objLines   = get(objList, 'String');
0137         for i = 1:numel(val)
0138             objname = objLines{val(i)};
0139             obj = evalin('base',objname);
0140             nobj = numel(obj);
0141             if nobj>1
0142                 for jj=1:nobj
0143                     objj = {obj(jj) , 0};
0144                     LTPDAinvar = [LTPDAinvar;objj];
0145                 end
0146             else
0147                 obj = {obj , 0};
0148                 LTPDAinvar = [LTPDAinvar;obj];
0149             end
0150         end
0151         set(findobj('Tag', 'ImportObjList'),'Value',[])
0152              
0153     end
0154     %----------------------------------------------------------------------
0155 
0156 %%
0157 end

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