Ignore:
Timestamp:
Jan 26, 2015, 12:37:56 AM (9 years ago)
Author:
sommeria
Message:

civtest_implemented_civ2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/browse_data.m

    r837 r856  
    2424function varargout = browse_data(varargin)
    2525
    26 % Last Modified by GUIDE v2.5 11-Mar-2014 22:09:37
     26% Last Modified by GUIDE v2.5 24-Jan-2015 16:55:04
    2727
    2828% Begin initialization code - DO NOT EDIT
     
    4747%------------------------------------------------------------------------
    4848% --- Executes just before browse_data is made visible.
    49 function browse_data_OpeningFcn(hObject, eventdata, handles, Campaign,EnableMirror)
     49function browse_data_OpeningFcn(hObject, eventdata, handles, DataSeries,EnableMirror)
    5050%------------------------------------------------------------------------
    5151
     
    8080    set(handles.mirror_txt,'Visible','off')
    8181end
    82 if exist('Campaign','var')
    83     [tild,CampaignName]=fileparts(Campaign);
    84     RootXml=fullfile(Campaign,[CampaignName '.xml']);
    85     s=[];
    86     if exist(RootXml,'file')
    87         [s,Heading]=xml2struct(RootXml);%read the xml file
    88         if isfield(s,'SourceDir')
    89             set(handles.SourceDir,'String',s.SourceDir);%display the source dir if a mirror has been opened
    90             set(handles.MirrorDir,'Visible','on');%  mirror dir display
    91             set(handles.MirrorDir,'String',Campaign);%display the opened mirror dir
    92             set(handles.CreateMirror,'String','update_mirror')
    93         end
    94     end
    95     if isempty(s) %a source dir has been opened
    96         set(handles.SourceDir,'String',Campaign);
    97         set(handles.MirrorDir,'Visible','off');% no mirror dir display
    98         set(handles.CreateMirror,'String','create_mirror')
    99     end
    100     errormsg=scan_campaign(handles,Campaign);
    101     if ~isempty(errormsg)
    102         msgbox_uvmat('ERROR',errormsg)
    103         return
    104     end
    105     set(handles.OK,'Visible','on')
    106     set(handles.Cancel,'Visible','on')
    107     set(handles.browse_data,'WindowStyle','modal')% Make the GUI modal
    108     set(hObject,'Visible','on')
    109     drawnow
    110     % UIWAIT makes GUI wait for user response (see UIRESUME)
    111     uiwait(handles.browse_data);
    112 end
     82
     83%% initialize the GUI
     84if ~(exist('DataSeries','var') && exist(DataSeries,'dir'))
     85    DataSeries=pwd;% current dir is the starting data series by default
     86end
     87[Experiment,DataSeries,Ext]=fileparts(DataSeries);
     88DataSeries=[DataSeries Ext];
     89[Campaign,Experiment,Ext]=fileparts(Experiment);
     90Experiment=[Experiment Ext];
     91[tild,CampaignName]=fileparts(Campaign);
     92RootXml=fullfile(Campaign,[CampaignName '.xml']);
     93s=[];
     94if exist(RootXml,'file')
     95    [s,Heading]=xml2struct(RootXml);%read the xml file
     96    if isfield(s,'SourceDir')
     97        set(handles.SourceDir,'String',s.SourceDir);%display the source dir if a mirror has been opened
     98        set(handles.MirrorDir,'Visible','on');%  mirror dir display
     99        set(handles.MirrorDir,'String',Campaign);%display the opened mirror dir
     100        set(handles.CreateMirror,'String','update_mirror')
     101    end
     102end
     103if isempty(s) %a source dir has been opened
     104    set(handles.SourceDir,'String',Campaign);
     105    set(handles.MirrorDir,'Visible','off');% no mirror dir display
     106    set(handles.CreateMirror,'String','create_mirror')
     107end
     108errormsg=scan_campaign(handles,Campaign,Experiment,DataSeries);
     109if ~isempty(errormsg)
     110    msgbox_uvmat('ERROR',errormsg)
     111    return
     112end
     113set(handles.OK,'Visible','on')
     114set(handles.Cancel,'Visible','on')
     115
     116set(handles.browse_data,'WindowStyle','modal')% Make the GUI modal
     117set(hObject,'Visible','on')
     118drawnow
     119% UIWAIT makes GUI wait for user response (see UIRESUME)
     120uiwait(handles.browse_data);
     121
    113122
    114123
     
    190199set(handles.SourceDir,'BackgroundColor',[1 1 1])
    191200
    192 
    193 %------------------------------------------------------------------------
    194 function errormsg=scan_campaign(handles,Campaign)
    195 %------------------------------------------------------------------------
    196 %set(handles.SourceDir,'BackgroundColor',[1 1 0])
    197 %drawnow
    198 %SourceDir=get(handles.SourceDir,'String');
    199 %MirrorDir=get(handles.MirrorDir,'String');
    200 % ExpName={''};
     201%------------------------------------------------------------------------
     202% List the experiments in a campaign, filling the menu ListExperiments
     203%------------------------------------------------------------------------
     204function errormsg=scan_campaign(handles,Campaign,Experiment,DataSeries)
     205%------------------------------------------------------------------------
    201206errormsg='';
    202207if exist(Campaign,'dir')
     
    213218    check_keep=cellfun('isempty', cell_remove);
    214219    ListFiles=sort((ListFiles(check_keep))');
     220    index=find(strcmp(['+/' Experiment],ListFiles));
     221    if isempty(index), index=0; end
    215222    set(handles.ListExperiments,'String',[{'*'};ListFiles])
    216     set(handles.ListExperiments,'Value',1)
     223    set(handles.ListExperiments,'Value',index+1)% initialise the menu selection with the folder defined by the input
    217224    ListExperiments_Callback([],[], handles)
     225    ListDevices=get(handles.ListDevices,'String');
     226    index=find(strcmp(['+/' DataSeries],ListDevices));
     227    if isempty(index)
     228        index=find(strcmp(['~/' DataSeries],ListDevices));
     229    end
     230    if ~isempty(index)
     231          set(handles.ListDevices,'Value',index)
     232    end
    218233else
    219234    msgbox_uvmat('ERROR',['The input ' Campaign ' is not a directory'])
    220235end
    221 %set(handles.SourceDir,'BackgroundColor',[1 1 1])
    222 
    223236
    224237%------------------------------------------------------------------------
     
    668681
    669682
    670 % --- Executes during object deletion, before destroying properties.
    671 function browse_data_DeleteFcn(hObject, eventdata, handles)
     683% --- Executes on button press in Browse.
     684function Browse_Callback(hObject, eventdata, handles)
     685ListDevices=get(handles.ListDevices,'String');
     686Device=ListDevices{get(handles.ListDevices,'Value')};
     687DataSeries=uigetfile_uvmat('open a data folder',Device,'uigetdir');
     688uiresume(handles.browse_data);
     689browse_data(DataSeries)
Note: See TracChangeset for help on using the changeset viewer.