diff m-toolbox/m/gui/ltpdv/callbacks/ltpdv_search_channels.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/m/gui/ltpdv/callbacks/ltpdv_search_channels.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,61 @@
+function ltpdv_search_channels(varargin)
+
+% LTPDV_SEARCH_CHANNELS search the channel list and reduce it to those that
+% match the search criteria.
+% 
+% M Hewitson 26-07-06
+% 
+% $Id: ltpdv_search_channels.m,v 1.1 2008/05/11 10:38:43 hewitson Exp $
+
+% Handles
+myh = varargin{1};
+mainfig = varargin{end};
+
+% channels
+ch = findobj(mainfig, 'Tag', 'LTPDVchannelList');
+chans = get(ch, 'String');
+
+nchans = size(chans,1);
+chansout = [];
+
+% First tokenize the search string
+sh = findobj(mainfig, 'Tag', 'LTPDVchannelSearchEdit');
+sstr = get(sh, 'String');
+curr = upper(sstr);
+if isempty(curr)
+   [latest, chans] = ltpdv_server_get_latest_chans(mainfig);
+   % Set channel list
+   ltpdv_server_set_channel_list(mainfig, chans);
+else
+  
+  [t, r] = strtok(curr);
+  cstr = [];
+  cstr = [cstr; cellstr(t)];
+  while ~isempty(r)
+    [t, r] = strtok(r);
+    cstr = [cstr; cellstr(t)];
+  end
+
+  if strcmp(curr, '')
+    chansout = chans;
+  else
+    for str=1:length(cstr)
+      for c=1:nchans
+        idx = strfind(upper(chans(c,:)), char(cstr(str)));
+        if ~isempty(idx)
+          chansout = strvcat(chansout, deblank(chans(c,:)));
+        end
+      end
+    end
+  end
+
+  if ~isempty(chansout)
+    chansout = char(sort(cellstr(chansout)));
+  end
+
+  ltpdv_server_set_channel_list(mainfig, chansout);
+
+end
+
+
+% END
\ No newline at end of file