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.2 2008/03/03 02:16:01 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.2 2008/03/03 02:16:01 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(listInput{i}), listInput(i)=[]; end
0066         end
0067         
0068         if isempty(listInput)
0069             listInput = 'No 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                     lines = get(hObject, 'String');
0089                     objname = lines{val};
0090                     obj = evalin('base',objname);
0091                     objtxt = display(obj);
0092                 else
0093                     objtxt = '';
0094                 end
0095                 set(findobj('Tag', 'infoPanel'), 'String', objtxt)
0096         elseif ~isa(listInput,'char')
0097             if strcmp(get(gcf,'SelectionType'),'normal')
0098                 val = get(hObject, 'Value');
0099                 if length(val) == 1
0100                     lines = get(hObject, 'String');
0101                     objname = lines{val};
0102                     obj = evalin('base',objname);
0103                     objtxt = display(obj);
0104                 else
0105                     objtxt = '';
0106                 end
0107                 set(findobj('Tag', 'infoPanel'), 'String', objtxt)
0108             end
0109             if strcmp(get(gcf,'SelectionType'),'open')
0110                 val = get(hObject, 'Value');
0111                 lines = get(hObject, 'String');
0112                 objname = lines{val};
0113                 obj = evalin('base',objname);
0114                 figure
0115                 plot(obj);
0116             end
0117         end
0118          
0119     end
0120     %----------------------------------------------------------------------
0121 
0122     %----------------------------------------------------------------------
0123     function ImportCallback(hObject,varargin)
0124     % This callback is called whenever the user click the 'Import' button
0125 
0126         objList = findobj('Tag', 'ImportObjList');
0127         val     = get(objList, 'Value');
0128         lines   = get(objList, 'String');
0129         for i = 1:numel(val)
0130             objname = lines{val};
0131             obj = evalin('base',objname);
0132             obj = {obj , 0};
0133             LTPDAinvar = [LTPDAinvar;obj];
0134         end
0135         set(findobj('Tag', 'ImportObjList'),'Value',[])
0136              
0137     end
0138     %----------------------------------------------------------------------
0139 
0140 %%
0141 end

Generated on Fri 07-Mar-2008 15:46:43 by m2html © 2003