Home > functions > gui > preAnalysis > utility > pa_prjfile_select.m

pa_prjfile_select

PURPOSE ^

file select dialog

SYNOPSIS ^

function [dirname, fnames, canceled] = pa_prjfile_select(proj_root, ext, caption)

DESCRIPTION ^

 file select dialog 
  - The file is in under the project directory

 [IN]  proj_root : Top of the selectable directory.
       ext{n}    : file extension (ex. '.img', '.txt')
         caption : dialog title(string)                  [string]
 [OUT] dirname   : relative directory name from proj_root
       fnames{n} : selected filenames.
       canceled  : true/false (true means dialog closed by cancel)


 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [dirname, fnames, canceled] = pa_prjfile_select(proj_root, ext, caption)
0002 % file select dialog
0003 %  - The file is in under the project directory
0004 %
0005 % [IN]  proj_root : Top of the selectable directory.
0006 %       ext{n}    : file extension (ex. '.img', '.txt')
0007 %         caption : dialog title(string)                  [string]
0008 % [OUT] dirname   : relative directory name from proj_root
0009 %       fnames{n} : selected filenames.
0010 %       canceled  : true/false (true means dialog closed by cancel)
0011 %
0012 %
0013 % Copyright (C) 2011, ATR All Rights Reserved.
0014 % License : New BSD License(see VBMEG_LICENSE.txt)
0015 persistent h;       % for singleton check
0016 persistent HISTORY; % file choice history
0017 
0018 dirname = [];
0019 fnames= [];
0020 canceled = false;
0021 
0022 % dialog can open 1 at a same time.
0023 if ~isempty(h)
0024     canceled = true;
0025     return;
0026 end  
0027 
0028 h = file_dialog;
0029 h = set(h, 'file_extensions', ext);
0030 if exist('caption', 'var')
0031     h.dialog_title = caption;
0032 end
0033 h = set(h, 'current_dir', proj_root);
0034 
0035 % ディレクトリの履歴の追加
0036 hist_num = length(HISTORY);
0037 if ~isempty(HISTORY)
0038     k=1;
0039     for k=1:hist_num
0040         h = set(h, 'hist_dir', HISTORY{k});
0041     end
0042     h = set(h, 'current_dir', char(HISTORY{k}));
0043 end
0044 [dirname fnames] = visible(h);
0045 
0046 % CANCEL押下かどうか判断
0047 if isempty(dirname)
0048     canceled = true;
0049 end
0050 
0051 % save history
0052 if ~isempty(dirname)
0053     HISTORY{hist_num+1} = {dirname};
0054 end
0055 
0056 % パスをproj_rootからの相対パスにする
0057 if ~isempty(dirname) & ~isempty(proj_root)
0058     dirname = vb_relativepath(dirname, proj_root);
0059     dirname = dirname(1:length(dirname)-1);
0060 end
0061 
0062 h = [];

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005