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.2 2008/03/17 20:48:47 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.2 2008/03/17 20:48:47 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  = 400;
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 220 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 
0185   cmd = sprintf('obj = evalin(''base'', ''%s'');', ws_vars(j).name);
0186   eval(cmd)
0187   if ltpda_isuserobject(obj)
0188     objs = [objs ws_vars(j)];
0189   end
0190 
0191 end
0192 
0193 
0194 %---------------- Callback for list selection
0195 function objList(varargin)
0196 
0197 mainfig = varargin{end};
0198 objs = getappdata(mainfig, 'objs');
0199 
0200 % get selection
0201 olh = findobj(mainfig, 'Tag', 'LTPDA_quicklook_objlist');
0202 idx = get(olh, 'Value');
0203 
0204 cmd = sprintf('obj = evalin(''base'', ''%s'');', objs(idx).name);
0205 eval(cmd);
0206 
0207 txt = display(obj);
0208 
0209 dh = findobj(mainfig, 'Tag', 'LTPDA_quicklook_display');
0210 set(dh, 'String', txt);
0211 
0212 
0213 %---------------- Fill the workspace object list
0214 function setWorkspaceObjsList(objs)
0215 
0216 id = findobj('Tag', 'LTPDA_quicklook_objlist');
0217 
0218 objlist = [];
0219 for j=1:length(objs)
0220   obj = objs(j);
0221   str = sprintf('%s\t\t(%s)', obj.name, obj.class);
0222   objlist = [objlist cellstr(str)];
0223 end
0224 
0225 set(id, 'Value', 1);
0226 set(id, 'String', objlist);
0227 
0228

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