Ignore:
Timestamp:
Jul 11, 2019, 7:02:27 PM (5 years ago)
Author:
sommeria
Message:

browse_data improved

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/browse_data.m

    r1069 r1070  
    2525function varargout = browse_data(varargin)
    2626
    27 % Last Modified by GUIDE v2.5 08-Jul-2019 23:32:39
     27% Last Modified by GUIDE v2.5 11-Jul-2019 18:52:06
    2828
    2929% Begin initialization code - DO NOT EDIT
     
    3535    'gui_LayoutFcn',  [] , ...
    3636    'gui_Callback',   []);
    37 if nargin && ischar(varargin{1}) && ~isempty(regexp(varargin{1},'_Callback','once'))
     37if nargin && ischar(varargin{1})
    3838    gui_State.gui_Callback = str2func(varargin{1});
    3939end
     
    4545end
    4646% End initialization code - DO NOT EDIT
     47
    4748
    4849%------------------------------------------------------------------------
     
    146147varargout{1} = handles.output;
    147148%%%%%%%%%%%%%%%%%%delete(handles.browse_data)
     149
     150%------------------------------------------------------------------------
     151% --- Executes on button press in SourceDir.
     152function SourceDir_Callback(hObject, eventdata, handles)
     153SourceDir=get(handles.SourceDir,'String');
     154ListExp=get(handles.ListExperiments,'String');
     155ListExp=ListExp(get(handles.ListExperiments,'Value'));
     156errormsg=scan_campaign(handles,SourceDir,ListExp);
     157if ~isempty(errormsg)
     158    msgbox_uvmat('ERROR',errormsg)
     159    return
     160end
     161%------------------------------------------------------------------------
    148162
    149163%------------------------------------------------------------------------
     
    397411
    398412%------------------------------------------------------------------------
    399 % Provide a list to display
     413% Provide the list (ListFilesTot) to display in DataSeries with the selected indices
    400414%------------------------------------------------------------------------
    401415function [ListFilesTot,indices]=list_dir_3(SourceDir,ListDir,ListSub,ListSubSub,check_fix)
     416% INPUT:
     417%SourceDir: path to the displayed directories
     418%ListDir: list of file and folder names under SourceDir (column 'Experiments')
     419%ListSub: list of file and folder in the second column 'Devices')
     420%ListSubSub: prvious list of file and folder in the third column 'DataSeries', used to mark the selected indices
    402421ListFilesTot={};
    403422for ilist=1:numel(ListDir)
     
    410429                ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray
    411430                ListFiles=ListCells(1,:);
     431                check_xml=~cellfun('isempty',regexp(ListFiles,'(\.xml|~)$'));% detect non xml files and files not marked by ~
    412432                check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files
     433                nbfiles=numel(find(~check_xml & ~check_dir));% number of non xml files
     434                check_dir=check_dir & cellfun('isempty', regexp(ListFiles,'^(-|\.|\+/\.)'));% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . )
    413435                ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display
    414                 cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . )
    415                 check_keep=cellfun('isempty', cell_remove);
    416                 ListFilesTot=[ListFilesTot (ListFiles(check_keep))];
     436                %cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . )         
     437                ListFiles=ListFiles(check_dir | check_xml);           
     438                ListFilesTot=[ListFilesTot ListFiles];
     439                if nbfiles>0
     440                    ListFilesTot=[ListFilesTot {[num2str(nbfiles) ' files']}];
     441                end
    417442            end
    418443        end
     
    426451    for ilist=1:numel(ListSubSub)
    427452        index=find(strcmp(ListSubSub{ilist},ListFilesTot));
     453        if check_fix && isempty(index)
     454            ListFilesTot=[ListFilesTot {['---' ListSubSub{ilist}]}];
     455            index=numel(ListFilesTot);
     456        end
    428457        indices=[indices index];
    429458    end
     
    676705set(handles.ListDevices,'Value',list_val);%replace Devices by DataSeries
    677706
    678 [ListFiles,indices]=list_dir_3(SourceDirNew,ListDevices(DeviceIndices),DataSeries(list_val),[]);
     707[ListFiles,indices]=list_dir_3(SourceDirNew,ListDevices(DeviceIndices),DataSeries(list_val),[],0);
    679708set(handles.DataSeries,'String',ListFiles)
    680709set(handles.DataSeries,'Value',indices)% initialise the menu selection with the folder defined by the input
     
    777806%     set(handles.DataSeries,'Value',Index)
    778807% end
     808
     809
     810% --- Executes when user attempts to close browse_data.
     811function browse_data_CloseRequestFcn(hObject, eventdata, handles)
     812% hObject    handle to browse_data (see GCBO)
     813% eventdata  reserved - to be defined in a future version of MATLAB
     814% handles    structure with handles and user data (see GUIDATA)
     815
     816% Hint: delete(hObject) closes the figure
     817delete(hObject);
Note: See TracChangeset for help on using the changeset viewer.