Changeset 651 for trunk/src/series.m


Ignore:
Timestamp:
Jun 25, 2013, 12:48:10 AM (10 years ago)
Author:
sommeria
Message:

various bugs corrected. Introduction of campaign lists in Open menu

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/series.m

    r650 r651  
    153153    if isfield(h,'MenuFile')
    154154        for ifile=1:min(length(h.MenuFile),5)
    155             eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',h.MenuFile{ifile});'])
     155            set(handles.(['MenuFile_' num2str(ifile)]),'Label',h.MenuFile{ifile});
     156        end
     157    end
     158    %get the list of previous camapigns in the upper bar menu Open campaign
     159    if isfield(h,'MenuCampaign')
     160        for ifile=1:min(length(h.MenuCampaign),5)
     161            set(handles.(['MenuCampaign_' num2str(ifile)]),'Label',h.MenuCampaign{ifile});
    156162        end
    157163    end
     
    224230    set(handles.Coord_y,'Value',Param.Coord_y_val);% selected string index
    225231end
    226 
    227 %% Adjust the GUI according to the binaries available in PARAM.xml
    228 % path_uvmat=fileparts(which('uvmat')); %path to civ
    229 % addpath (path_uvmat) ; %add the path to civ, (useful in case of change of working directory after civ has been s opened in the working directory)
    230 % errormsg=[];%default error message
    231 % xmlfile='PARAM.xml';
    232 % if exist(xmlfile,'file')
    233 %     try
    234 %         t=xmltree(xmlfile);
    235 %         sparam=convert(t);
    236 %     catch ME
    237 %         errormsg={' Unable to read the file PARAM.xml defining the  binaries:';ME.message};
    238 %     end
    239 % else
    240 %     errormsg=[xmlfile ' not found: path to binaries undefined'];
    241 % end
    242 % if ~isempty(errormsg)
    243 %     msgbox_uvmat('WARNING',errormsg);
    244 % end
    245 % test_batch=0;%default: ,no batch mode available
    246 % if isfield(sparam,'BatchParam') && isfield(sparam.BatchParam,'BatchMode')
    247 %     test_batch=strcmp(sparam.BatchParam.BatchMode,'sge'); %sge is currently the only implemented batch mod
    248 % end
    249 % RUNVal=get(handles.RunMode,'Value');
    250 % if test_batch==0
    251 %    if RUNVal>2
    252 %        set(handles.RunMode,'Value',1)
    253 %    end
    254 %    set(handles.RunMode,'String',{'local';'background'})
    255 % else
    256 %     set(handles.RunMode,'String',{'local';'background';'cluster'})
    257 % end
    258232
    259233%% introduce the input file name(s) if defined from input Param
     
    296270%------------------------------------------------------------------------
    297271%------------------------------------------------------------------------
     272% --- fct activated by the browser under 'Open'
     273%------------------------------------------------------------------------ 
    298274function MenuBrowse_Callback(hObject, eventdata, handles)
    299 %------------------------------------------------------------------------   
    300 %get the previous input file in the Input Table
     275
     276%% look for the previously opened file 'oldfile'
    301277oldfile=''; %default
    302 SeriesData=get(handles.series,'UserData');
    303 if isfield(SeriesData,'RefFile')
    304     oldfile=SeriesData.RefFile{1};
    305 end
    306 if ~exist(oldfile,'file')
     278if get(handles.CheckAppend,'Value')
     279    % case 'checkappend': new series appended to the input table
     280    InputTable=get(handles.InputTable,'Data');
     281    RootPathCell=InputTable(:,1);
     282    SubDirCell=InputTable(:,3);
     283    oldfile=''; %default
     284    if ~(isempty(RootPathCell) || isequal(RootPathCell,{''}))%loads the previously stored file name and set it as default in the file_input box
     285        oldfile=fullfile(RootPathCell{1},SubDirCell{1});
     286    end
     287else
     288    % case refresh the input table by a new series
     289    SeriesData=get(handles.series,'UserData');
     290    if isfield(SeriesData,'RefFile')
     291        oldfile=SeriesData.RefFile{1};
     292    end
     293end
     294
     295%% use a file name stored in prefdir
     296dir_perso=prefdir;
     297profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
     298if exist(profil_perso,'file')
     299    h=load (profil_perso);
     300    if isfield(h,'RootPath') && ischar(h.RootPath)
     301        oldfile=h.RootPath;
     302    end
     303end
     304
     305%% launch the browser
     306fileinput=uigetfile_uvmat('pick a file to append in the input table',oldfile);
     307if ~isempty(fileinput)
     308    if get(handles.CheckAppend,'Value')
     309        display_file_name(handles,fileinput,'append')
     310    else
     311        display_file_name(handles,fileinput,'one')
     312    end
     313end
     314
     315%------------------------------------------------------------------------
     316% --- fct activated by selecting a previous file under the menu Open
     317%------------------------------------------------------------------------
     318function MenuFile_Callback(hObject, eventdata, handles)
     319
     320fileinput=get(hObject,'Label');
     321if get(handles.CheckAppend,'Value')
     322    display_file_name(handles,fileinput,'append')
     323else
     324    display_file_name(handles,fileinput,'one')
     325end
     326
     327%------------------------------------------------------------------------
     328% --- fct activated by the browser under 'Open campaign'
     329%------------------------------------------------------------------------
     330function MenuBrowseCampaign_Callback(hObject, eventdata, handles)
     331
     332set(handles.MenuOpenCampaign,'ForegroundColor',[1 1 0])
     333drawnow
     334InputTable=get(handles.InputTable,'Data');
     335RootPath=InputTable{1,1};
     336CampaignPath=fileparts(fileparts(RootPath));
     337DirFull=uigetfile_uvmat('define this path as the Campaign folder:',CampaignPath,'uigetdir');
     338if ~ischar(DirFull)|| ~exist(DirFull,'dir')
     339    return
     340end
     341OutPut=browse_data(DirFull);% open the GUI browse_data to get select a campaign dir, experiment and device
     342if ~isfield(OutPut,'Campaign')
     343    return
     344end
     345DirName=fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.DataSeries{1});
     346ListStruct=dir(DirName); %list files and the dir DataSeries
     347% select the first appropriate file in the dir
     348FileName='';
     349for ilist=1:numel(ListStruct)
     350    if ~isequal(ListStruct(ilist).isdir,1)%look for files, not dir
     351        FileName=ListStruct(ilist).name;
     352        FileType=get_file_type(fullfile(DirName,FileName));
     353        switch FileType
     354            case {'image','multimage','civx','civdata','netcdf'}
     355                break
     356        end
     357    end
     358end
     359if isempty(FileName)
     360    msgbox_uvmat('ERROR',['no appropriate input file in the DataSeries folder ' fullfile(DirName)])
     361    return
     362end
     363
     364%% update the list of campaigns in the menubar
     365MenuCampaign=[{get(handles.MenuCampaign_1,'Label')};{get(handles.MenuCampaign_2,'Label')};...
     366    {get(handles.MenuCampaign_3,'Label')};{get(handles.MenuCampaign_4,'Label')};{get(handles.MenuCampaign_5,'Label')}];
     367check_dir=isempty(find(strcmp(DirFull,MenuCampaign)));
     368if check_dir %insert the new campaign in the list if it is not found
     369    MenuCampaign(end)=[]; %suppress the last item
     370    MenuCampaign=[{DirFull};MenuCampaign];%insert the new campaign
     371    for ilist=1:numel(MenuCampaign)
     372        set(handles.(['MenuCampaign_' num2str(ilist)]),'Label',MenuCampaign{ilist})
     373    end
     374    % save the list for future opening:
    307375    dir_perso=prefdir;
    308376    profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
    309377    if exist(profil_perso,'file')
    310          h=load (profil_perso);
    311         if isfield(h,'RootPath')&&ischar(h.RootPath)
    312             oldfile=h.RootPath;
    313         end
    314     end
    315 end
    316 fileinput=uigetfile_uvmat('pick a file to refresh the input table',oldfile);
    317 if ~isempty(fileinput)
    318      display_file_name(handles,fileinput,'one')
    319 end
    320 
     378        save (profil_perso,'MenuCampaign','RootPath','-append'); %store the file names for future opening of uvmat
     379    else
     380        save (profil_perso,'MenuCampaign','RootPath','-V6'); %store the file names for future opening of uvmat
     381    end
     382end
     383
     384%% display the selected field and related information
     385if get(handles.CheckAppend,'Value')
     386    display_file_name(handles,fullfile(DirName,FileName),'append')
     387else
     388    display_file_name(handles,fullfile(DirName,FileName),'one')
     389end
     390set(handles.MenuOpenCampaign,'ForegroundColor',[0 0 0])
    321391
    322392% --------------------------------------------------------------------
    323 function MenuFile_1_Callback(hObject, eventdata, handles)
    324 fileinput=get(handles.MenuFile_1,'Label');
    325 display_file_name(handles,fileinput,'one')
    326 
    327 % --------------------------------------------------------------------
    328 function MenuFile_2_Callback(hObject, eventdata, handles)
    329 fileinput=get(handles.MenuFile_2,'Label');
    330 display_file_name(handles,fileinput,'one')
    331 
    332 % --------------------------------------------------------------------
    333 function MenuFile_3_Callback(hObject, eventdata, handles)
    334 fileinput=get(handles.MenuFile_3,'Label');
    335 display_file_name( handles,fileinput,'one')
    336 
    337 % --------------------------------------------------------------------
    338 function MenuFile_4_Callback(hObject, eventdata, handles)
    339 fileinput=get(handles.MenuFile_4,'Label');
    340 display_file_name(handles,fileinput,'one')
    341 
    342 % --------------------------------------------------------------------
    343 function MenuFile_5_Callback(hObject, eventdata, handles)
    344 fileinput=get(handles.MenuFile_5,'Label');
    345 display_file_name(handles,fileinput,'one')
    346 
    347 % --------------------------------------------------------------------
    348 function MenuBrowse_insert_Callback(hObject, eventdata, handles)
    349 InputTable=get(handles.InputTable,'Data');
    350 RootPathCell=InputTable(:,1);
    351 SubDirCell=InputTable(:,3);
    352 RootFileCell=InputTable(:,2);
    353 oldfile=''; %default
    354 if isempty(RootPathCell)||isequal(RootPathCell,{''})%loads the previously stored file name and set it as default in the file_input box
    355      dir_perso=prefdir;
    356      profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
    357      if exist(profil_perso,'file')
    358           h=load (profil_perso);
    359          if isfield(h,'filebase')&ischar(h.filebase)
    360                  oldfile=h.filebase;
    361          end
    362          if isfield(h,'RootPath')&ischar(h.RootPath)
    363                  oldfile=h.RootPath;
    364          end
    365      end
    366  else
    367      oldfile=fullfile(RootPathCell{1},RootFileCell{1});
    368 end
    369  fileinput=uigetfile_uvmat('pick a file to append in the input table',oldfile);
    370 if ~isempty(fileinput)
    371      display_file_name(handles,fileinput,'append')
    372 end
    373 % [FileName, PathName, filterindex] = uigetfile( ...
    374 %        {'*.xml;*.xls;*.png;*.avi;*.AVI;*.nc', ' (*.xml,*.xls, *.png, *.avi,*.nc)';
    375 %        '*.xml',  '.xml files '; ...
    376 %         '*.xls',  '.xls files '; ...
    377 %         '*.png','.png image files'; ...
    378 %         '*.avi;*.AVI','.avi movie files'; ...
    379 %         '*.nc','.netcdf files'; ...
    380 %         '*.*',  'All Files (*.*)'}, ...
    381 %         'Pick a file',oldfile);
    382 % fileinput=[PathName FileName];%complete file name
    383 % sizf=size(fileinput);
    384 % if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end
    385 % [path,name,ext]=fileparts(fileinput);
    386 % if isequal(ext,'.xml')
    387 %     msgbox_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer
    388 % elseif isequal(ext,'.xls')
    389 %     msgbox_uvmat('ERROR','input file type not implemented')%A Faire: ouvrir le fichier pour naviguer
    390 % else
    391 %     display_file_name(handles,fileinput,'append')
    392 % end
    393 
    394 % --------------------------------------------------------------------
    395 function MenuFile_insert_1_Callback(hObject, eventdata, handles)
    396 % --------------------------------------------------------------------   
    397 fileinput=get(handles.MenuFile_insert_1,'Label');
    398 display_file_name(handles,fileinput,'append')
    399 
    400 % --------------------------------------------------------------------
    401 function MenuFile_insert_2_Callback(hObject, eventdata, handles)
    402 % --------------------------------------------------------------------   
    403 fileinput=get(handles.MenuFile_insert_2,'Label');
    404 display_file_name(handles,fileinput,'append')
    405 
    406 % --------------------------------------------------------------------
    407 function MenuFile_insert_3_Callback(hObject, eventdata, handles)
    408 % --------------------------------------------------------------------   
    409 fileinput=get(handles.MenuFile_insert_3,'Label');
    410 display_file_name( handles,fileinput,'append')
    411 
    412 % --------------------------------------------------------------------
    413 function MenuFile_insert_4_Callback(hObject, eventdata, handles)
    414 % --------------------------------------------------------------------   
    415 fileinput=get(handles.MenuFile_insert_4,'Label');
    416 display_file_name( handles,fileinput,'append')
    417 
    418 % --------------------------------------------------------------------
    419 function MenuFile_insert_5_Callback(hObject, eventdata, handles)
    420 % --------------------------------------------------------------------   
    421 fileinput=get(handles.MenuFile_insert_5,'Label');
    422 display_file_name(handles,fileinput,'append')
     393function MenuCampaign_Callback(hObject, eventdata, handles)
     394% --------------------------------------------------------------------
     395set(handles.MenuOpenCampaign,'ForegroundColor',[1 1 0])
     396OutPut=browse_data(get(hObject,'Label'));% open the GUI browse_data to get select a campaign dir, experiment and device
     397if ~isfield(OutPut,'Campaign')
     398    return
     399end
     400DirName=fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.DataSeries{1});
     401hdir=dir(DirName); %list files and dirs
     402for ilist=1:numel(hdir)
     403    if ~isequal(hdir(ilist).isdir,1)%look for files, not dir
     404        FileName=hdir(ilist).name;
     405        FileType=get_file_type(fullfile(DirName,FileName));
     406        switch FileType
     407            case {'image','multimage','civx','civdata','netcdf'}
     408            break
     409        end
     410    end
     411end
     412if get(handles.CheckAppend,'Value')
     413    display_file_name(handles,fullfile(DirName,FileName),'append')
     414else
     415    display_file_name(handles,fullfile(DirName,FileName),'one')
     416end
     417set(handles.MenuOpenCampaign,'ForegroundColor',[0 0 0])
     418
     419
    423420
    424421%------------------------------------------------------------------------
     
    434431end
    435432%% enable other menus and uicontrols
    436 set(handles.MenuOpen_insert,'Enable','on')
    437 set(handles.MenuFile_insert_1,'Enable','on')
    438 set(handles.MenuFile_insert_2,'Enable','on')
    439 set(handles.MenuFile_insert_3,'Enable','on')
    440 set(handles.MenuFile_insert_4,'Enable','on')
    441 set(handles.MenuFile_insert_5,'Enable','on')
     433set(handles.MenuOpenCampaign,'Enable','on')
     434set(handles.MenuCampaign_1,'Enable','on')
     435set(handles.MenuCampaign_2,'Enable','on')
     436set(handles.MenuCampaign_3,'Enable','on')
     437set(handles.MenuCampaign_4,'Enable','on')
     438set(handles.MenuCampaign_5,'Enable','on')
    442439set(handles.RUN, 'Enable','On')
    443440set(handles.RUN,'BackgroundColor',[1 0 0])% set RUN button to red
     
    492489% iview: line index in the input table
    493490%       or 'one': refresh the list
    494 %       'append': add a new line to the list
     491%       'checkappend': add a new line to the list
    495492
    496493%% get the input root name, indices, file extension and nomenclature NomType
     
    521518
    522519%% enable other menus and uicontrols
    523 set(handles.MenuOpen_insert,'Enable','on')
    524 set(handles.MenuFile_insert_1,'Enable','on')
    525 set(handles.MenuFile_insert_2,'Enable','on')
    526 set(handles.MenuFile_insert_3,'Enable','on')
    527 set(handles.MenuFile_insert_4,'Enable','on')
    528 set(handles.MenuFile_insert_5,'Enable','on')
     520set(handles.MenuOpenCampaign,'Enable','on')
     521set(handles.MenuCampaign_1,'Enable','on')
     522set(handles.MenuCampaign_2,'Enable','on')
     523set(handles.MenuCampaign_3,'Enable','on')
     524set(handles.MenuCampaign_4,'Enable','on')
     525set(handles.MenuCampaign_5,'Enable','on')
    529526set(handles.RUN, 'Enable','On')
    530527set(handles.RUN,'BackgroundColor',[1 0 0])% set RUN button to red
     
    595592for ifile=1:min(length(MenuFile),5)
    596593    eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',MenuFile{ifile});'])
    597     eval(['set(handles.MenuFile_insert_' num2str(ifile) ',''Label'',MenuFile{ifile});'])
    598594end
    599595dir_perso=prefdir;
     
    731727%% number of slices set by default
    732728NbSlice=1;%default
    733 % read  value set by the first series for the append mode (iwiew >1)
     729% read  value set by the first series for the checkappend mode (iwiew >1)
    734730if iview>1 && strcmp(get(handles.num_NbSlice,'Visible'),'on')
    735731    NbSlice=str2num(get(handles.num_NbSlice,'String'));
     
    738734%% default time unit
    739735TimeUnit='';
    740 % read  value set by the first series for the append mode (iwiew >1)
     736% read  value set by the first series for the checkappend mode (iwiew >1)
    741737if iview>1
    742738    TimeUnit=get(handles.TimeUnit,'String');
Note: See TracChangeset for help on using the changeset viewer.