0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 function out = uipickfiles(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2 %uipickfiles: GUI program to select file(s) and/or directories.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 % Syntax:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 % files = uipickfiles('PropertyName',PropertyValue,...)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7 % The current directory can be changed by operating in the file navigator:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8 % double-clicking on a directory in the list to move further down the tree,
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9 % using the popup menu to move up the tree, typing a path in the box to
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 % move to any directory or right-clicking on the path box to revisit a
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 % previously-listed directory.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13 % Files can be added to the list by double-clicking or selecting files
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 % (non-contiguous selections are possible with the control key) and
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 % pressing the Add button. Files in the list can be removed or re-ordered.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 % When finished, a press of the Done button will return the full paths to
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17 % the selected files in a cell array, structure array or character array.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18 % If the Cancel button is pressed then zero is returned.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 % The following optional property/value pairs can be specified as arguments
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 % to control the indicated behavior:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23 % Property Value
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 % ---------- ----------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 % FilterSpec String to specify starting directory and/or file filter.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 % Ex: 'C:\bin' will start up in that directory. '*.txt'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 % will list only files ending in '.txt'. 'c:\bin\*.txt' will
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28 % do both. Default is to start up in the current directory
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29 % and list all files. Can be changed with the GUI.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 % REFilter String containing a regular expression used to filter the
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32 % file list. Ex: '\.m$|\.mat$' will list files ending in
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33 % '.m' and '.mat'. Default is empty string. Can be used
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34 % with FilterSpec and both filters are applied. Can be
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35 % changed with the GUI.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37 % Prompt String containing a prompt appearing in the title bar of
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38 % the figure. Default is 'Select files'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40 % NumFiles Scalar or vector specifying number of files that must be
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41 % selected. A scalar specifies an exact value; a two-element
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42 % vector can be used to specify a range, [min max]. The
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43 % function will not return unless the specified number of
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44 % files have been chosen. Default is [] which accepts any
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45 % number of files.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47 % Output String specifying the data type of the output: 'cell',
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48 % 'struct' or 'char'. Specifying 'cell' produces a cell
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49 % array of strings, the strings containing the full paths of
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50 % the chosen files. 'Struct' returns a structure array like
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
51 % the result of the dir function except that the 'name' field
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
52 % contains a full path instead of just the file name. 'Char'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
53 % returns a character array of the full paths. This is most
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
54 % useful when you have just one file and want it in a string
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
55 % instead of a cell array containing just one string. The
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
56 % default is 'cell'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
57 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
58 % All properties and values are case-insensitive and need only be
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
59 % unambiguous. For example,
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
60 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
61 % files = uipickfiles('num',1,'out','ch')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
62 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
63 % is valid usage.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
64
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
65 % Version: 1.0, 25 April 2006
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
66 % Author: Douglas M. Schwarz
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
67 % Email: dmschwarz=ieee*org, dmschwarz=urgrad*rochester*edu
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
68 % Real_email = regexprep(Email,{'=','*'},{'@','.'})
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
69 % $Id: uipickfiles.m,v 1.1 2008/03/01 13:43:20 nicola Exp $
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
70
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
71
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
72 % Define properties and set default values.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
73 prop.filterspec = '*';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
74 prop.refilter = '';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
75 prop.prompt = 'Select files';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
76 prop.numfiles = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
77 prop.output = 'cell';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
78
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
79 % Process inputs and set prop fields.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
80 properties = fieldnames(prop);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
81 arg_index = 1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
82 while arg_index <= nargin
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
83 arg = varargin{arg_index};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
84 if ischar(arg)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
85 prop_index = find(strncmpi(arg,properties,length(arg)));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
86 if length(prop_index) == 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
87 prop.(properties{prop_index}) = varargin{arg_index + 1};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
88 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
89 error('Property ''%s'' does not exist or is ambiguous.',arg)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
90 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
91 arg_index = arg_index + 2;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
92 elseif isstruct(arg)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
93 arg_fn = fieldnames(arg);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
94 for i = 1:length(arg_fn)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
95 prop_index = find(strncmpi(arg_fn{i},properties,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
96 length(arg_fn{i})));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
97 if length(prop_index) == 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
98 prop.(properties{prop_index}) = arg.(arg_fn{i});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
99 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
100 error('Property ''%s'' does not exist or is ambiguous.',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
101 arg_fn{i})
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
102 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
103 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
104 arg_index = arg_index + 1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
105 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
106 error(['Properties must be specified by property/value pairs',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
107 ' or structures.'])
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
108 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
109 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
110
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
111 % Validate FilterSpec property.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
112 if isempty(prop.filterspec)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
113 prop.filterspec = '*';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
114 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
115 if ~ischar(prop.filterspec)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
116 error('FilterSpec property must contain a string.')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
117 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
118
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
119 % Validate REFilter property.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
120 if ~ischar(prop.refilter)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
121 error('REFilter property must contain a string.')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
122 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
123
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
124 % Validate Prompt property.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
125 if ~ischar(prop.prompt)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
126 error('Prompt property must contain a string.')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
127 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
128
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
129 % Validate NumFiles property.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
130 if numel(prop.numfiles) > 2 || any(prop.numfiles < 0)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
131 error('NumFiles must be empty, a scalar or two-element vector.')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
132 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
133 prop.numfiles = unique(prop.numfiles);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
134 if isequal(prop.numfiles,1)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
135 numstr = 'Select exactly 1 file.';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
136 elseif length(prop.numfiles) == 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
137 numstr = sprintf('Select exactly %d files.',prop.numfiles);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
138 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
139 numstr = sprintf('Select %d to %d files.',prop.numfiles);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
140 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
141
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
142 % Validate Output property.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
143 legal_outputs = {'cell','struct','char'};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
144 out_idx = find(strncmpi(prop.output,legal_outputs,length(prop.output)));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
145 if length(out_idx) == 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
146 prop.output = legal_outputs{out_idx};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
147 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
148 error(['Value of ''Output'' property, ''%s'', is illegal or '...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
149 'ambiguous.'],prop.output)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
150 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
151
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
152
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
153 % Initialize file lists.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
154 [current_dir,f,e] = fileparts(prop.filterspec);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
155 filter = [f,e];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
156 if isempty(current_dir)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
157 current_dir = pwd;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
158 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
159 if isempty(filter)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
160 filter = '*';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
161 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
162 re_filter = prop.refilter;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
163 full_filter = fullfile(current_dir,filter);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
164 path_cell = path2cell(current_dir);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
165 fdir = filtered_dir(full_filter,re_filter);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
166 filenames = {fdir.name}';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
167 filenames = annotate_file_names(filenames,fdir);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
168
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
169 % Initialize some data.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
170 file_picks = {};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
171 full_file_picks = {};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
172 dir_picks = dir(' '); % Create empty directory structure.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
173 show_full_path = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
174 nodupes = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
175 history = {current_dir};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
176
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
177 % Create figure.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
178 gray = get(0,'DefaultUIControlBackgroundColor');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
179 fig = figure('Position',[0 0 740 445],...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
180 'Color',gray,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
181 'WindowStyle','modal',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
182 'Resize','off',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
183 'NumberTitle','off',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
184 'Name',prop.prompt,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
185 'IntegerHandle','off',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
186 'CloseRequestFcn',@cancel,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
187 'CreateFcn',{@movegui,'center'});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
188
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
189 % Create uicontrols.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
190 uicontrol('Style','frame',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
191 'Position',[255 260 110 70])
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
192 uicontrol('Style','frame',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
193 'Position',[275 135 110 100])
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
194
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
195 navlist = uicontrol('Style','listbox',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
196 'Position',[10 10 250 320],...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
197 'String',filenames,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
198 'Value',[],...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
199 'BackgroundColor','w',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
200 'Callback',@clicknav,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
201 'Max',2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
202 pickslist = uicontrol('Style','listbox',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
203 'Position',[380 10 350 320],...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
204 'String',{},...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
205 'BackgroundColor','w',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
206 'Callback',@clickpicks,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
207 'Max',2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
208
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
209 openbut = uicontrol('Style','pushbutton',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
210 'Position',[270 300 80 20],...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
211 'String','Open',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
212 'Enable','off',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
213 'Callback',@open);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
214 arrow = [2 2 2 2 2 2 2 2 1 2 2 2;...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
215 2 2 2 2 2 2 2 2 2 0 2 2;...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
216 2 2 2 2 2 2 2 2 2 2 0 2;...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
217 0 0 0 0 0 0 0 0 0 0 0 0;...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
218 2 2 2 2 2 2 2 2 2 2 0 2;...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
219 2 2 2 2 2 2 2 2 2 0 2 2;...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
220 2 2 2 2 2 2 2 2 1 2 2 2];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
221 arrow(arrow == 2) = NaN;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
222 arrow_im = NaN*ones(16,76);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
223 arrow_im(6:12,45:56) = arrow/2;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
224 im = repmat(arrow_im,[1 1 3]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
225 addbut = uicontrol('Style','pushbutton',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
226 'Position',[270 270 80 20],...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
227 'String','Add ',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
228 'Enable','off',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
229 'CData',im,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
230 'Callback',@add);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
231
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
232 removebut = uicontrol('Style','pushbutton',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
233 'Position',[290 205 80 20],...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
234 'String','Remove',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
235 'Enable','off',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
236 'Callback',@remove);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
237 moveupbut = uicontrol('Style','pushbutton',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
238 'Position',[290 175 80 20],...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
239 'String','Move Up',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
240 'Enable','off',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
241 'Callback',@moveup);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
242 movedownbut = uicontrol('Style','pushbutton',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
243 'Position',[290 145 80 20],...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
244 'String','Move Down',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
245 'Enable','off',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
246 'Callback',@movedown);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
247
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
248 uicontrol('Position',[10 380 250 16],...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
249 'Style','text',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
250 'String','Current Directory',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
251 'HorizontalAlignment','center')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
252 dir_popup = uicontrol('Style','popupmenu',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
253 'Position',[10 335 250 20],...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
254 'BackgroundColor','w',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
255 'String',path_cell(end:-1:1),...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
256 'Value',1,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
257 'Callback',@dirpopup);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
258 hist_cm = uicontextmenu;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
259 pathbox = uicontrol('Position',[10 360 250 20],...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
260 'Style','edit',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
261 'BackgroundColor','w',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
262 'String',current_dir,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
263 'HorizontalAlignment','left',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
264 'Callback',@change_path,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
265 'UIContextMenu',hist_cm);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
266 hist_menus = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
267 hist_cb = @history_cb;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
268 hist_menus = make_history_cm(hist_cb,hist_cm,hist_menus,history);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
269
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
270 uicontrol('Position',[10 425 80 16],...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
271 'Style','text',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
272 'String','File Filter',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
273 'HorizontalAlignment','left')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
274 uicontrol('Position',[100 425 160 16],...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
275 'Style','text',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
276 'String','Reg. Exp. Filter',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
277 'HorizontalAlignment','left')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
278 showallfiles = uicontrol('Position',[270 405 100 20],...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
279 'Style','checkbox',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
280 'String','Show All Files',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
281 'Value',0,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
282 'HorizontalAlignment','left',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
283 'Callback',@togglefilter);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
284 filter_ed = uicontrol('Position',[10 405 80 20],...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
285 'Style','edit',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
286 'BackgroundColor','w',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
287 'String',filter,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
288 'HorizontalAlignment','left',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
289 'Callback',@setfilspec);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
290 refilter_ed = uicontrol('Position',[100 405 160 20],...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
291 'Style','edit',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
292 'BackgroundColor','w',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
293 'String',re_filter,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
294 'HorizontalAlignment','left',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
295 'Callback',@setrefilter);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
296
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
297 viewfullpath = uicontrol('Style','checkbox',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
298 'Position',[380 335 230 20],...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
299 'String','Show full paths',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
300 'Value',show_full_path,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
301 'HorizontalAlignment','left',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
302 'Callback',@showfullpath);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
303 remove_dupes = uicontrol('Style','checkbox',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
304 'Position',[380 360 230 20],...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
305 'String','Remove duplicates (as per full path)',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
306 'Value',nodupes,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
307 'HorizontalAlignment','left',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
308 'Callback',@removedupes);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
309 uicontrol('Position',[380 405 350 20],...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
310 'Style','text',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
311 'String','Selected Files',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
312 'HorizontalAlignment','center')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
313 uicontrol('Position',[280 80 80 30],'String','Done',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
314 'Callback',@done);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
315 uicontrol('Position',[280 30 80 30],'String','Cancel',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
316 'Callback',@cancel);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
317
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
318 if ~isempty(prop.numfiles)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
319 uicontrol('Position',[380 385 350 16],...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
320 'Style','text',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
321 'String',numstr,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
322 'ForegroundColor','r',...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
323 'HorizontalAlignment','center')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
324 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
325
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
326 set(fig,'HandleVisibility','off')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
327
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
328 uiwait(fig)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
329
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
330 % Compute desired output.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
331 switch prop.output
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
332 case 'cell'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
333 out = full_file_picks;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
334 case 'struct'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
335 out = dir_picks(:);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
336 case 'char'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
337 out = char(full_file_picks);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
338 case 'cancel'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
339 out = 0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
340 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
341
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
342 % -------------------- Callback functions --------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
343
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
344 function add(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
345 values = get(navlist,'Value');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
346 for i = 1:length(values)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
347 dir_pick = fdir(values(i));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
348 pick = dir_pick.name;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
349 pick_full = fullfile(current_dir,pick);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
350 dir_pick.name = pick_full;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
351 if ~nodupes || ~any(strcmp(full_file_picks,pick_full))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
352 file_picks{end + 1} = pick;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
353 full_file_picks{end + 1} = pick_full;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
354 dir_picks(end + 1) = dir_pick;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
355 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
356 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
357 if show_full_path
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
358 set(pickslist,'String',full_file_picks,'Value',[]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
359 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
360 set(pickslist,'String',file_picks,'Value',[]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
361 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
362 set([removebut,moveupbut,movedownbut],'Enable','off');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
363 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
364
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
365 function remove(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
366 values = get(pickslist,'Value');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
367 file_picks(values) = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
368 full_file_picks(values) = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
369 dir_picks(values) = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
370 top = get(pickslist,'ListboxTop');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
371 num_above_top = sum(values < top);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
372 top = top - num_above_top;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
373 num_picks = length(file_picks);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
374 new_value = min(min(values) - num_above_top,num_picks);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
375 if num_picks == 0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
376 new_value = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
377 set([removebut,moveupbut,movedownbut],'Enable','off')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
378 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
379 if show_full_path
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
380 set(pickslist,'String',full_file_picks,'Value',new_value,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
381 'ListboxTop',top)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
382 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
383 set(pickslist,'String',file_picks,'Value',new_value,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
384 'ListboxTop',top)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
385 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
386 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
387
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
388 function open(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
389 values = get(navlist,'Value');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
390 if fdir(values).isdir
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
391 if strcmp(fdir(values).name,'.')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
392 return
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
393 elseif strcmp(fdir(values).name,'..')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
394 set(dir_popup,'Value',min(2,length(path_cell)))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
395 dirpopup();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
396 return
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
397 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
398 current_dir = fullfile(current_dir,fdir(values).name);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
399 history{end+1} = current_dir;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
400 history = unique(history);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
401 hist_menus = make_history_cm(hist_cb,hist_cm,hist_menus,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
402 history);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
403 full_filter = fullfile(current_dir,filter);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
404 path_cell = path2cell(current_dir);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
405 fdir = filtered_dir(full_filter,re_filter);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
406 filenames = {fdir.name}';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
407 filenames = annotate_file_names(filenames,fdir);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
408 set(dir_popup,'String',path_cell(end:-1:1),'Value',1)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
409 set(pathbox,'String',current_dir)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
410 set(navlist,'ListboxTop',1,'Value',[],'String',filenames)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
411 set(addbut,'Enable','off')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
412 set(openbut,'Enable','off')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
413 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
414 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
415
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
416 function clicknav(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
417 value = get(navlist,'Value');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
418 nval = length(value);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
419 dbl_click_fcn = @add;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
420 switch nval
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
421 case 0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
422 set([addbut,openbut],'Enable','off')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
423 case 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
424 set(addbut,'Enable','on');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
425 if fdir(value).isdir
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
426 set(openbut,'Enable','on')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
427 dbl_click_fcn = @open;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
428 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
429 set(openbut,'Enable','off')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
430 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
431 otherwise
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
432 set(addbut,'Enable','on')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
433 set(openbut,'Enable','off')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
434 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
435 if strcmp(get(fig,'SelectionType'),'open')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
436 dbl_click_fcn();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
437 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
438 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
439
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
440 function clickpicks(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
441 value = get(pickslist,'Value');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
442 if isempty(value)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
443 set([removebut,moveupbut,movedownbut],'Enable','off')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
444 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
445 set(removebut,'Enable','on')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
446 if min(value) == 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
447 set(moveupbut,'Enable','off')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
448 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
449 set(moveupbut,'Enable','on')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
450 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
451 if max(value) == length(file_picks)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
452 set(movedownbut,'Enable','off')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
453 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
454 set(movedownbut,'Enable','on')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
455 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
456 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
457 if strcmp(get(fig,'SelectionType'),'open')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
458 remove();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
459 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
460 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
461
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
462 function dirpopup(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
463 value = get(dir_popup,'Value');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
464 len = length(path_cell);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
465 path_cell = path_cell(1:end-value+1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
466 if ispc && value == len
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
467 current_dir = '';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
468 full_filter = filter;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
469 fdir = struct('name',getdrives,'date',datestr(now),...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
470 'bytes',0,'isdir',1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
471 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
472 current_dir = cell2path(path_cell);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
473 history{end+1} = current_dir;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
474 history = unique(history);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
475 hist_menus = make_history_cm(hist_cb,hist_cm,hist_menus,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
476 history);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
477 full_filter = fullfile(current_dir,filter);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
478 fdir = filtered_dir(full_filter,re_filter);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
479 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
480 filenames = {fdir.name}';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
481 filenames = annotate_file_names(filenames,fdir);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
482 set(dir_popup,'String',path_cell(end:-1:1),'Value',1)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
483 set(pathbox,'String',current_dir)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
484 set(navlist,'String',filenames,'Value',[])
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
485 set(addbut,'Enable','off')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
486 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
487
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
488 function change_path(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
489 proposed_path = get(pathbox,'String');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
490 % Process any directories named '..'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
491 proposed_path_cell = path2cell(proposed_path);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
492 ddots = strcmp(proposed_path_cell,'..');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
493 ddots(find(ddots) - 1) = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
494 proposed_path_cell(ddots) = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
495 proposed_path = cell2path(proposed_path_cell);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
496 % Check for existance of directory.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
497 if ~exist(proposed_path,'dir')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
498 uiwait(errordlg(['Directory "',proposed_path,...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
499 '" does not exist.'],'','modal'))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
500 return
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
501 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
502 current_dir = proposed_path;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
503 history{end+1} = current_dir;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
504 history = unique(history);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
505 hist_menus = make_history_cm(hist_cb,hist_cm,hist_menus,history);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
506 full_filter = fullfile(current_dir,filter);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
507 path_cell = path2cell(current_dir);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
508 fdir = filtered_dir(full_filter,re_filter);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
509 filenames = {fdir.name}';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
510 filenames = annotate_file_names(filenames,fdir);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
511 set(dir_popup,'String',path_cell(end:-1:1),'Value',1)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
512 set(pathbox,'String',current_dir)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
513 set(navlist,'String',filenames,'Value',[])
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
514 set(addbut,'Enable','off')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
515 set(openbut,'Enable','off')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
516 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
517
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
518 function showfullpath(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
519 show_full_path = get(viewfullpath,'Value');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
520 if show_full_path
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
521 set(pickslist,'String',full_file_picks)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
522 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
523 set(pickslist,'String',file_picks)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
524 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
525 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
526
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
527 function removedupes(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
528 nodupes = get(remove_dupes,'Value');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
529 if nodupes
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
530 num_picks = length(full_file_picks);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
531 [unused,rev_order] = unique(full_file_picks(end:-1:1));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
532 order = sort(num_picks + 1 - rev_order);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
533 full_file_picks = full_file_picks(order);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
534 file_picks = file_picks(order);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
535 if show_full_path
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
536 set(pickslist,'String',full_file_picks,'Value',[])
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
537 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
538 set(pickslist,'String',file_picks,'Value',[])
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
539 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
540 set([removebut,moveupbut,movedownbut],'Enable','off')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
541 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
542 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
543
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
544 function moveup(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
545 value = get(pickslist,'Value');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
546 set(removebut,'Enable','on')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
547 n = length(file_picks);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
548 omega = 1:n;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
549 index = zeros(1,n);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
550 index(value - 1) = omega(value);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
551 index(setdiff(omega,value - 1)) = omega(setdiff(omega,value));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
552 file_picks = file_picks(index);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
553 full_file_picks = full_file_picks(index);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
554 value = value - 1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
555 if show_full_path
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
556 set(pickslist,'String',full_file_picks,'Value',value)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
557 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
558 set(pickslist,'String',file_picks,'Value',value)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
559 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
560 if min(value) == 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
561 set(moveupbut,'Enable','off')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
562 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
563 set(movedownbut,'Enable','on')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
564 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
565
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
566 function movedown(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
567 value = get(pickslist,'Value');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
568 set(removebut,'Enable','on')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
569 n = length(file_picks);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
570 omega = 1:n;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
571 index = zeros(1,n);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
572 index(value + 1) = omega(value);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
573 index(setdiff(omega,value + 1)) = omega(setdiff(omega,value));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
574 file_picks = file_picks(index);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
575 full_file_picks = full_file_picks(index);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
576 value = value + 1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
577 if show_full_path
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
578 set(pickslist,'String',full_file_picks,'Value',value)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
579 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
580 set(pickslist,'String',file_picks,'Value',value)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
581 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
582 if max(value) == n
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
583 set(movedownbut,'Enable','off')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
584 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
585 set(moveupbut,'Enable','on')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
586 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
587
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
588 function togglefilter(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
589 value = get(showallfiles,'Value');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
590 if value
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
591 filter = '*';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
592 re_filter = '';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
593 set([filter_ed,refilter_ed],'Enable','off')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
594 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
595 filter = get(filter_ed,'String');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
596 re_filter = get(refilter_ed,'String');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
597 set([filter_ed,refilter_ed],'Enable','on')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
598 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
599 full_filter = fullfile(current_dir,filter);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
600 fdir = filtered_dir(full_filter,re_filter);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
601 filenames = {fdir.name}';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
602 filenames = annotate_file_names(filenames,fdir);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
603 set(navlist,'String',filenames,'Value',[])
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
604 set(addbut,'Enable','off')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
605 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
606
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
607 function setfilspec(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
608 filter = get(filter_ed,'String');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
609 if isempty(filter)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
610 filter = '*';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
611 set(filter_ed,'String',filter)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
612 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
613 % Process file spec if a subdirectory was included.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
614 [p,f,e] = fileparts(filter);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
615 if ~isempty(p)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
616 newpath = fullfile(current_dir,p,'');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
617 set(pathbox,'String',newpath)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
618 filter = [f,e];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
619 if isempty(filter)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
620 filter = '*';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
621 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
622 set(filter_ed,'String',filter)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
623 change_path();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
624 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
625 full_filter = fullfile(current_dir,filter);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
626 fdir = filtered_dir(full_filter,re_filter);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
627 filenames = {fdir.name}';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
628 filenames = annotate_file_names(filenames,fdir);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
629 set(navlist,'String',filenames,'Value',[])
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
630 set(addbut,'Enable','off')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
631 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
632
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
633 function setrefilter(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
634 re_filter = get(refilter_ed,'String');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
635 fdir = filtered_dir(full_filter,re_filter);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
636 filenames = {fdir.name}';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
637 filenames = annotate_file_names(filenames,fdir);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
638 set(navlist,'String',filenames,'Value',[])
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
639 set(addbut,'Enable','off')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
640 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
641
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
642 function done(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
643 % Optional shortcut: click on a file and press 'Done'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
644 % if isempty(full_file_picks) && strcmp(get(addbut,'Enable'),'on')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
645 % add();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
646 % end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
647 numfiles = length(full_file_picks);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
648 if ~isempty(prop.numfiles)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
649 if numfiles < prop.numfiles(1)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
650 msg = {'Too few files selected.',numstr};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
651 uiwait(errordlg(msg,'','modal'))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
652 return
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
653 elseif numfiles > prop.numfiles(end)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
654 msg = {'Too many files selected.',numstr};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
655 uiwait(errordlg(msg,'','modal'))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
656 return
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
657 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
658 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
659 delete(fig)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
660 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
661
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
662 function cancel(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
663 prop.output = 'cancel';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
664 delete(fig)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
665 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
666
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
667 function history_cb(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
668 current_dir = history{varargin{3}};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
669 full_filter = fullfile(current_dir,filter);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
670 path_cell = path2cell(current_dir);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
671 fdir = filtered_dir(full_filter,re_filter);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
672 filenames = {fdir.name}';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
673 filenames = annotate_file_names(filenames,fdir);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
674 set(dir_popup,'String',path_cell(end:-1:1),'Value',1)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
675 set(pathbox,'String',current_dir)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
676 set(navlist,'ListboxTop',1,'Value',[],'String',filenames)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
677 set(addbut,'Enable','off')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
678 set(openbut,'Enable','off')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
679 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
680 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
681
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
682
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
683 % -------------------- Subfunctions --------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
684
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
685 function c = path2cell(p)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
686 % Turns a path string into a cell array of path elements.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
687 c = strread(p,'%s','delimiter','\\/');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
688 if ispc
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
689 c = [{'My Computer'};c];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
690 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
691 c = [{filesep};c(2:end)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
692 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
693 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
694
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
695
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
696 function p = cell2path(c)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
697 % Turns a cell array of path elements into a path string.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
698 if ispc
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
699 p = fullfile(c{2:end},'');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
700 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
701 p = fullfile(c{:},'');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
702 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
703 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
704
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
705
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
706 function d = filtered_dir(full_filter,re_filter)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
707 % Like dir, but applies filters and sorting.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
708 p = fileparts(full_filter);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
709 if isempty(p) && full_filter(1) == '/'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
710 p = '/';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
711 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
712 if exist(full_filter,'dir')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
713 c = cell(0,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
714 dfiles = struct('name',c,'date',c,'bytes',c,'isdir',c);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
715 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
716 dfiles = dir(full_filter);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
717 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
718 if ~isempty(dfiles)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
719 dfiles([dfiles.isdir]) = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
720 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
721 ddir = dir(p);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
722 ddir = ddir([ddir.isdir]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
723 % Additional regular expression filter.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
724 if nargin > 1 && ~isempty(re_filter)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
725 if ispc
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
726 no_match = cellfun('isempty',regexpi({dfiles.name},re_filter));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
727 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
728 no_match = cellfun('isempty',regexp({dfiles.name},re_filter));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
729 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
730 dfiles(no_match) = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
731 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
732 % Set navigator style:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
733 % 1 => mix file and directory names
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
734 % 2 => means list all files before all directories
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
735 % 3 => means list all directories before all files
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
736 % 4 => same as 2 except put . and .. directories first
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
737 if isunix
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
738 style = 4;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
739 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
740 style = 4;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
741 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
742 switch style
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
743 case 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
744 d = [dfiles;ddir];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
745 [unused,index] = sort({d.name});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
746 d = d(index);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
747 case 2
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
748 [unused,index1] = sort({dfiles.name});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
749 [unused,index2] = sort({ddir.name});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
750 d = [dfiles(index1);ddir(index2)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
751 case 3
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
752 [unused,index1] = sort({dfiles.name});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
753 [unused,index2] = sort({ddir.name});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
754 d = [ddir(index2);dfiles(index1)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
755 case 4
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
756 [unused,index1] = sort({dfiles.name});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
757 dot1 = find(strcmp({ddir.name},'.'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
758 dot2 = find(strcmp({ddir.name},'..'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
759 ddot1 = ddir(dot1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
760 ddot2 = ddir(dot2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
761 ddir([dot1,dot2]) = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
762 [unused,index2] = sort({ddir.name});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
763 d = [ddot1;ddot2;dfiles(index1);ddir(index2)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
764 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
765 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
766
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
767
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
768 function drives = getdrives
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
769 % Returns a cell array of drive names on Windows.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
770 letters = char('A':'Z');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
771 num_letters = length(letters);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
772 drives = cell(1,num_letters);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
773 for i = 1:num_letters
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
774 if exist([letters(i),':\'],'dir');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
775 drives{i} = [letters(i),':'];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
776 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
777 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
778 drives(cellfun('isempty',drives)) = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
779 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
780
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
781
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
782 function filenames = annotate_file_names(filenames,dir_listing)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
783 % Adds a trailing filesep character to directory names.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
784 fs = filesep;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
785 for i = 1:length(filenames)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
786 if dir_listing(i).isdir
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
787 filenames{i} = [filenames{i},fs];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
788 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
789 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
790 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
791
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
792
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
793 function hist_menus = make_history_cm(cb,hist_cm,hist_menus,history)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
794 % Make context menu for history.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
795 if ~isempty(hist_menus)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
796 delete(hist_menus)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
797 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
798 num_hist = length(history);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
799 hist_menus = zeros(1,num_hist);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
800 for i = 1:num_hist
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
801 hist_menus(i) = uimenu(hist_cm,'Label',history{i},...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
802 'Callback',{cb,i});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
803 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
804 end
|