Home > m > gui > quicklook > ltpdaquicklook.m

ltpdaquicklook

PURPOSE ^

LTPDAQUICKLOOK allows the user to quicklook LTPDA objects.

SYNOPSIS ^

function varargout = ltpdaquicklook(varargin)

DESCRIPTION ^

 LTPDAQUICKLOOK allows the user to quicklook LTPDA objects.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: LTPDAQUICKLOOK allows the user to quicklook LTPDA objects.

 CALL:        ltpdaquicklook


 VERSION:     $Id: ltpdaquicklook.m,v 1.4 2008/08/04 18:15:09 hewitson Exp $

 HISTORY: 07-03-08 M Hewitson
             Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function varargout = ltpdaquicklook(varargin)
0002 
0003 % LTPDAQUICKLOOK allows the user to quicklook LTPDA objects.
0004 %
0005 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0006 %
0007 % DESCRIPTION: LTPDAQUICKLOOK allows the user to quicklook LTPDA objects.
0008 %
0009 % CALL:        ltpdaquicklook
0010 %
0011 %
0012 % VERSION:     $Id: ltpdaquicklook.m,v 1.4 2008/08/04 18:15:09 hewitson Exp $
0013 %
0014 % HISTORY: 07-03-08 M Hewitson
0015 %             Creation
0016 %
0017 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0018 
0019 
0020 %% Check if I exist already
0021 hs = findall(0);
0022 found = -1;
0023 for j=1:length(hs)
0024   h = hs(j);
0025   if strcmp(get(h, 'Tag'), 'LTPDAquicklook')
0026     found = h;
0027   end
0028 end
0029 if found ~= -1
0030   figure(found);
0031   return
0032 end
0033 
0034 % id = findobj('Tag', 'LTPDAquicklook');
0035 % if ~isempty(id)
0036 %   figure(id)
0037 %   return
0038 % end
0039 
0040 %% Some initial setup
0041 
0042 Gproperties.Gcol    = [240 240 240]/255;
0043 Gproperties.Gwidth  = 600;
0044 Gproperties.Gheight = 400;
0045 Gproperties.Gborder = 10;
0046 fontsize = getappdata(0, 'ltpda_repo_gui_fontsize');
0047 
0048 Gproperties.Screen   = get(0,'screensize');
0049 Gproperties.Gposition = [150 ...
0050   100 ...
0051   Gproperties.Gwidth...
0052   Gproperties.Gheight];
0053 
0054 %  Initialize and hide the GUI as it is being constructed.
0055 mainfig = figure('Name', 'LTPDA Quicklook',...
0056   'NumberTitle', 'off',...
0057   'Visible','off',...
0058   'Position',Gproperties.Gposition,...
0059   'Color', Gproperties.Gcol,...
0060   'Toolbar', 'none',...
0061   'MenuBar', 'none',...
0062   'Resize', 'off',...
0063   'HandleVisibility', 'callback', ...
0064   'Tag', 'LTPDAquicklook');
0065 
0066 % Set mainfig callbacks
0067 set(mainfig, 'CloseRequestFcn', {@ltpda_quicklook_close, mainfig});
0068 
0069 % Set Application data
0070 setappdata(mainfig, 'Gproperties', Gproperties);
0071 
0072 
0073 %% GUI Parts
0074 
0075 % Objects list
0076 objs = getWorkspaceObjs();
0077 setappdata(mainfig, 'objs', objs);
0078 
0079 lbh = uicontrol(mainfig,'Style','listbox',...
0080   'String',{' '},...
0081   'Value',1,...
0082   'BackgroundColor', 'w',...
0083   'Fontsize', fontsize,...
0084   'Max', 1000,...
0085   'Position',[10 90 150 300],...
0086   'Tag', 'LTPDA_quicklook_objlist');
0087 
0088 % Set callback
0089 set(lbh, 'Callback', {@objList, mainfig});
0090 
0091 setWorkspaceObjsList(objs)
0092 
0093 % Refresh button
0094 pbh = uicontrol(mainfig,'Style','pushbutton',...
0095   'String','Refresh',...
0096   'Callback', {@refresh, mainfig}, ...
0097   'Position',[10 70 60 25]);
0098 
0099 
0100 % Object display
0101 sth = uicontrol(mainfig,'Style','text',...
0102   'String','',...
0103   'BackgroundColor', 'w', ...
0104   'ForegroundColor', 'b', ...
0105   'HorizontalAlignment', 'left', ...
0106   'Tag', 'LTPDA_quicklook_display', ...
0107   'Position',[170 90 420 300]);
0108 
0109 % Plot button
0110 pbh = uicontrol(mainfig,'Style','pushbutton',...
0111   'String','iplot',...
0112   'Callback', {@call_iplot, mainfig}, ...
0113   'Position',[10 10 60 25]);
0114 
0115 % history plot
0116 pbh = uicontrol(mainfig,'Style','pushbutton',...
0117   'String','plot history',...
0118   'Callback', {@call_histplot, mainfig}, ...
0119   'Position',[80 10 80 25]);
0120 
0121 
0122 %% Start the GUI
0123 
0124 % Make the GUI visible.
0125 set(mainfig,'Visible','on')
0126 
0127 %% Callbacks
0128 
0129 %---------------- history plot
0130 function call_histplot(varargin)
0131 
0132 mainfig = varargin{end};
0133 objs = getappdata(mainfig, 'objs');
0134 
0135 % get selection
0136 olh = findobj(mainfig, 'Tag', 'LTPDA_quicklook_objlist');
0137 idx = get(olh, 'Value');
0138 
0139 cmd = sprintf('obj = evalin(''base'', ''%s'');', objs(idx).name);
0140 eval(cmd);
0141 
0142 plot(obj.hist);
0143 
0144 
0145 %---------------- iplot
0146 function call_iplot(varargin)
0147 
0148 mainfig = varargin{end};
0149 objs = getappdata(mainfig, 'objs');
0150 
0151 % get selection
0152 olh = findobj(mainfig, 'Tag', 'LTPDA_quicklook_objlist');
0153 idx = get(olh, 'Value');
0154 
0155 cmd = sprintf('obj = evalin(''base'', ''%s'');', objs(idx).name);
0156 eval(cmd);
0157 
0158 iplot(obj);
0159 
0160 %---------------- refresh
0161 function refresh(varargin)
0162 
0163 mainfig = varargin{end};
0164 objs = getWorkspaceObjs();
0165 setWorkspaceObjsList(objs)
0166 setappdata(mainfig, 'objs', objs);
0167 
0168 %---------------- Close function
0169 function ltpda_quicklook_close(varargin)
0170 % Callback executed when the GUI is closed
0171 
0172 disp('* Goodbye from the LTPDA Quicklook GUI *')
0173 delete(varargin{1})
0174 
0175 
0176 %---------------- Get a list of LTPDA objects in the MATLAB workspace
0177 function objs = getWorkspaceObjs()
0178 
0179 % get base workspace variables
0180 ws_vars = evalin('base','whos');
0181 
0182 objs = [];
0183 for j=1:length(ws_vars)
0184   cmd = sprintf('obj = evalin(''base'', ''%s'');', ws_vars(j).name);
0185   eval(cmd)
0186   if isa(obj, 'ltpda_uo')
0187     objs = [objs ws_vars(j)];
0188   end
0189 end
0190 
0191 
0192 %---------------- Callback for list selection
0193 function objList(varargin)
0194 
0195 mainfig = varargin{end};
0196 objs = getappdata(mainfig, 'objs');
0197 
0198 % get selection
0199 olh = findobj(mainfig, 'Tag', 'LTPDA_quicklook_objlist');
0200 idx = get(olh, 'Value');
0201 
0202 cmd = sprintf('obj = evalin(''base'', ''%s'');', objs(idx).name);
0203 eval(cmd);
0204 
0205 txt = display(obj);
0206 
0207 dh = findobj(mainfig, 'Tag', 'LTPDA_quicklook_display');
0208 set(dh, 'String', txt);
0209 
0210 
0211 %---------------- Fill the workspace object list
0212 function setWorkspaceObjsList(objs)
0213 
0214 id = findobj('Tag', 'LTPDA_quicklook_objlist');
0215 
0216 objlist = [];
0217 for j=1:length(objs)
0218   obj = objs(j);
0219   str = sprintf('%s\t\t(%s)', obj.name, obj.class);
0220   objlist = [objlist cellstr(str)];
0221 end
0222 
0223 set(id, 'Value', 1);
0224 set(id, 'String', objlist);
0225 
0226

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