Changeset 610


Ignore:
Timestamp:
Apr 14, 2013, 9:37:42 AM (8 years ago)
Author:
sommeria
Message:

various bugs fixed after tests under widows
introduce uigetfile_uvmat for series/status (some problems need to be solved)

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/find_file_series.m

    r609 r610  
    249249        NomType='*';
    250250    else
    251         i1_series=i1_series(:,2)*ones(0,FileInfo.NumberOfFrames);
     251        i1_series=i1_series(:,2)*ones(1,FileInfo.NumberOfFrames);
    252252        i1_series=[i1_series(:,1) i1_series];
    253253        j1_series=ones(size(i1_series,1),1)*(0:FileInfo.NumberOfFrames);
  • trunk/src/read_image.m

    r604 r610  
    1616function [A,ObjectOut]=read_image(FileName,FileType,VideoObject,num)
    1717%-----------------------------------------------------------------------
    18 if ~exist(FileType,'var')
     18if ~exist('FileType','var')
    1919    FileType='image';
    2020end
  • trunk/src/series.m

    r609 r610  
    24732473    OutputSubDir=[Param.OutputSubDir Param.OutputDirExt];% subdirectory for output files
    24742474    OutputDir=fullfile(RootPath,OutputSubDir);
    2475     hfig=findobj(allchild(0),'name','series_status');
    2476     if isempty(hfig)
    2477         ScreenSize=get(0,'ScreenSize');
    2478         hfig=figure('DeleteFcn',@stop_status,'Position',[ScreenSize(3)-600 ScreenSize(4)-640 560 600]);
    2479         set(hfig,'MenuBar','none')% suppress the menu bar
    2480         set(hfig,'NumberTitle','off')%suppress the fig number in the title
    2481         set(hfig,'name','series_status')
    2482         set(hfig,'tag','series_status')
    2483         uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', @view_file,'tag','list','UserData',OutputDir);
    2484         uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','titlebox','Max',2,'String',OutputDir);
    2485         uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]);
    2486         uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'String','Close','FontWeight','bold','FontUnits','points','FontSize',11,'Callback',@stop_status);
    2487         uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.1 0.01 0.2 0.07],'String','Refresh','FontWeight','bold','FontUnits','points','FontSize',11,'Callback',@refresh_GUI);
    2488         %set(hrefresh,'UserData',StatusData)
    2489         BarPosition=[0.05 0.81 0.01 0.05];
    2490         uicontrol('Style','frame','Units','normalized', 'Position',BarPosition ,'BackgroundColor',[1 0 0],'tag','waitbar');
    2491         drawnow
    2492     end
    2493     refresh_GUI(hfig)
     2475    uigetfile_uvmat('status_display',OutputDir)
     2476   
     2477%     hfig=findobj(allchild(0),'name','series_status');
     2478%     if isempty(hfig)
     2479%         ScreenSize=get(0,'ScreenSize');
     2480%         hfig=figure('DeleteFcn',@stop_status,'Position',[ScreenSize(3)-600 ScreenSize(4)-640 560 600]);
     2481%         set(hfig,'MenuBar','none')% suppress the menu bar
     2482%         set(hfig,'NumberTitle','off')%suppress the fig number in the title
     2483%         set(hfig,'name','series_status')
     2484%         set(hfig,'tag','series_status')
     2485%         uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', @view_file,'tag','list','UserData',OutputDir);
     2486%         uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','titlebox','Max',2,'String',OutputDir);
     2487%         uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]);
     2488%         uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'String','Close','FontWeight','bold','FontUnits','points','FontSize',11,'Callback',@stop_status);
     2489%         uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.1 0.01 0.2 0.07],'String','Refresh','FontWeight','bold','FontUnits','points','FontSize',11,'Callback',@refresh_GUI);
     2490%         %set(hrefresh,'UserData',StatusData)
     2491%         BarPosition=[0.05 0.81 0.01 0.05];
     2492%         uicontrol('Style','frame','Units','normalized', 'Position',BarPosition ,'BackgroundColor',[1 0 0],'tag','waitbar');
     2493%         drawnow
     2494%     end
     2495%     refresh_GUI(hfig)
    24942496else
    24952497    %% delete current display fig if selection is off
  • trunk/src/series/civ_series.m

    r609 r610  
    7676%% input files and indexing
    7777NbField=1;
     78MaxIndex=cell2mat(Param.IndexRange.MaxIndex);
     79MinIndex=cell2mat(Param.IndexRange.MinIndex);
    7880if isfield(Param,'InputTable')
    79     RootPath=Param.InputTable{1,1};
    80     RootFile=Param.InputTable{1,3};
    81     SubDir=Param.InputTable{1,2};
    82     NomType=Param.InputTable{1,4};
    83     FileExt=Param.InputTable{1,5};
    84     PairCiv1=Param.ActionInput.PairIndices.ListPairCiv1;
    85     PairCiv2='';
    86     if isfield(Param.ActionInput.PairIndices,'ListPairCiv2')
    87         PairCiv2=Param.ActionInput.PairIndices.ListPairCiv2;
    88     end
    89     MaxIndex=cell2mat(Param.IndexRange.MaxIndex);
    90     MinIndex=cell2mat(Param.IndexRange.MinIndex);
    9181    [filecell,i_series,tild,j_series]=get_file_series(Param);
    92     [FileType_A,FileInfo,MovieObject_A]=get_file_type(filecell{1,1});
    93     if strcmp(FileType_A,'civdata')% a civdata file has been introduced as input.
    94          [FileType_A,FileInfo,MovieObject_A]=get_file_type(filecell{2,1});
    95     end
    96     [i1_series_Civ1,i2_series_Civ1,j1_series_Civ1,j2_series_Civ1,check_bounds,NomTypeNc]=...
    97         find_pair_indices(PairCiv1,i_series{1},j_series{1},MinIndex,MaxIndex);
    98     if ~isempty(PairCiv2)
    99         [i1_series_Civ2,i2_series_Civ2,j1_series_Civ2,j2_series_Civ2,check_bounds_Civ2]=...
    100             find_pair_indices(PairCiv2,i_series{1},j_series{1},MinIndex,MaxIndex);
    101         check_bounds=check_bounds | check_bounds_Civ2;
    102     end
    103     i1_series_Civ1=i1_series_Civ1(~check_bounds);
    104     i2_series_Civ1=i2_series_Civ1(~check_bounds);
    105     j1_series_Civ1=j1_series_Civ1(~check_bounds);
    106     j2_series_Civ1=j2_series_Civ1(~check_bounds);
    107     if ~isempty(j1_series_Civ1)
    108         FrameIndex_A_Civ1=j1_series_Civ1;
    109         FrameIndex_B_Civ1=j2_series_Civ1;
     82    if ~exist(filecell{1,1},'file')
     83        displ('ERROR: the first input file does not exist')
     84        return
    11085    else
    111         FrameIndex_A_Civ1=i1_series_Civ1;
    112         FrameIndex_B_Civ1=i2_series_Civ1;
    113     end
    114     if ~isempty(PairCiv2)
    115         i1_series_Civ2=i1_series_Civ2(~check_bounds);
    116         i2_series_Civ2=i2_series_Civ2(~check_bounds);
    117         j1_series_Civ2=j1_series_Civ2(~check_bounds);
    118         j2_series_Civ2=j2_series_Civ2(~check_bounds);
    119         if ~isempty(j1_series_Civ2)
    120             FrameIndex_A_Civ2=j1_series_Civ2;
    121             FrameIndex_B_Civ2=j2_series_Civ2;
    122         else
    123             FrameIndex_A_Civ2=i1_series_Civ2;
    124             FrameIndex_B_Civ2=i2_series_Civ2;
    125         end
    126     end
    127    
    128     NbField=numel(i1_series_Civ1);
    129 
    130     FileType_B=FileType_A;
    131     MovieObject_B=MovieObject_A;
    132     if size(filecell,1)>=2 && ~strcmp(filecell{1,1},filecell{2,1})
    133         [FileType_B,FileInfo,MovieObject_B]=get_file_type(filecell{2,1});
    134     end
    135 end
    136 
     86        FileType=get_file_type(filecell{1,1});
     87        iview_nc=0;
     88        iview_A=0;
     89        iview_B=0;
     90        switch FileType
     91            case 'civdata';% =1 for images
     92                iview_nc=1;
     93                if size(filecell,1)>=2
     94                    iview_A=2;iview_B=2;
     95                    if size(filecell,1)>=3
     96                        iview_B=3;
     97                    end
     98                end
     99            case {'image','multimage','mmreader','video'}
     100                iview_A=1;
     101                if size(filecell,1)>=2
     102                    iview_B=2;
     103                end
     104        end
     105    end
     106    if iview_A~=0
     107        [FileType_A,FileInfo_A,VideoObject_A]=get_file_type(filecell{1,1});
     108        if isempty(strcmp(FileType_A,{'multimage','mmreader','video'}))
     109            displ(['ERROR: the file line ' num2str(iview_A) ' must be an image'])
     110        end
     111        RootPath=Param.InputTable{1,1};
     112        RootFile=Param.InputTable{1,3};
     113        SubDir=Param.InputTable{1,2};
     114        NomType=Param.InputTable{1,4};
     115        FileExt=Param.InputTable{1,5};
     116    end
     117    if iview_B==0
     118        FileType_B=FileType_A;
     119VideoObject_B=VideoObject_A;
     120        PairCiv1=Param.ActionInput.PairIndices.ListPairCiv1;
     121        PairCiv2='';
     122        if isfield(Param.ActionInput.PairIndices,'ListPairCiv2')
     123            PairCiv2=Param.ActionInput.PairIndices.ListPairCiv2;
     124        end
     125        [i1_series_Civ1,i2_series_Civ1,j1_series_Civ1,j2_series_Civ1,check_bounds,NomTypeNc]=...
     126            find_pair_indices(PairCiv1,i_series{1},j_series{1},MinIndex,MaxIndex);
     127        if ~isempty(PairCiv2)
     128            [i1_series_Civ2,i2_series_Civ2,j1_series_Civ2,j2_series_Civ2,check_bounds_Civ2]=...
     129                find_pair_indices(PairCiv2,i_series{1},j_series{1},MinIndex,MaxIndex);
     130            check_bounds=check_bounds | check_bounds_Civ2;
     131        end
     132        i1_series_Civ1=i1_series_Civ1(~check_bounds);
     133        i2_series_Civ1=i2_series_Civ1(~check_bounds);
     134        j1_series_Civ1=j1_series_Civ1(~check_bounds);
     135        j2_series_Civ1=j2_series_Civ1(~check_bounds);
     136        if isempty(j_series{1})
     137            FrameIndex_A_Civ1=i1_series_Civ1;
     138            FrameIndex_B_Civ1=i2_series_Civ1;
     139        else
     140            FrameIndex_A_Civ1=j1_series_Civ1;
     141            FrameIndex_B_Civ1=j2_series_Civ1;
     142        end
     143        if ~isempty(PairCiv2)
     144            i1_series_Civ2=i1_series_Civ2(~check_bounds);
     145            i2_series_Civ2=i2_series_Civ2(~check_bounds);
     146            j1_series_Civ2=j1_series_Civ2(~check_bounds);
     147            j2_series_Civ2=j2_series_Civ2(~check_bounds);
     148            if isempty(j_series{1})
     149                FrameIndex_A_Civ2=i1_series_Civ2;
     150                FrameIndex_B_Civ2=i2_series_Civ2;
     151            else
     152                FrameIndex_A_Civ2=j1_series_Civ2;
     153                FrameIndex_B_Civ2=j2_series_Civ2;
     154            end
     155        end
     156    else
     157           [FileType_B,FileInfo,VideoObject_B]=get_file_type(filecell{2,1});
     158        if isempty(strcmp(FileType_B,{'multimage','mmreader','video'}))
     159            displ(['ERROR: the file line ' num2str(iview_B) ' must be an image'])
     160        end   
     161        %TODO : introduce the second file series if relevant: case %displacement
     162    end
     163end
     164NbField=numel(i1_series_Civ1);
    137165
    138166%% Output directory
     
    172200        end
    173201end
    174 if strcmp(InputTable{iview,4},'*')
    175     if ~isempty(VideoObject)
    176         imainfo=get(VideoObject);
    177         time=zeros(imainfo.NumberOfFrames+1,2);
    178         time(:,2)=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate)';
    179         TimeSource='video';
    180        % set(han:dles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec
    181         ColorType='truecolor';
    182     elseif ~isempty(imformats(regexprep(InputTable{iview,5},'^.',''))) || isequal(InputTable{iview,5},'.vol')%&& isequal(NomType,'*')% multi-frame image
    183         if ~isempty(InputTable{iview,2})
    184             imainfo=imfinfo(fullfile(InputTable{iview,1},InputTable{iview,2},[InputTable{iview,3} InputTable{iview,5}]));
    185         else
    186             imainfo=imfinfo([FileBase InputTable{iview,5}]);
    187         end
    188         ColorType=imainfo.ColorType;%='truecolor' for color images
    189         if length(imainfo) >1 %case of image with multiple frames
    190             nbfield=length(imainfo);
    191             nbfield_j=1;
    192         end
    193     end
    194 end
    195 
    196 %TODO: get time_A and time_B
    197 
    198 if isempty(time) && (strcmp(FileType,'video') || strcmp(FileType,'mmreader'))
    199     set(handles.ListPairMode,'Value',1);
    200     dt=1/get(MovieObject,'FrameRate');%time interval between successive frames
    201     if strcmp(NomTypeIma,'*')
    202         set(handles.ListPairMode,'String',{'series(Di)'})
    203         MaxIndex_i=get(MovieObject,'NumberOfFrames');
    204         time=(dt*(0:MaxIndex_i-1))';%list of image times
    205     else
    206         set(handles.ListPairMode,'String',[{'series(Dj)'};{'series(Di)'}])
    207         MaxIndex_i=max(i1_series(i1_series>0));
    208         MaxIndex_j=get(MovieObject,'NumberOfFrames');
    209         time=ones(MaxIndex_i,1)*(dt*(0:MaxIndex_j-1));%list of image times
    210         enable_j(handles,'on')
    211     end
    212     TimeUnit='s';
    213 end
     202if ~isempty(strcmp(FileType_A,{'mmreader','video'}))% case of video input
     203    time=zeros(2,FileInfo_A.NumberOfFrames+1);
     204    time(2,:)=(0:1/FileInfo_A.FrameRate:(FileInfo_A.NumberOfFrames)/FileInfo_A.FrameRate);
     205    TimeSource='video';
     206    % set(han:dles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec
     207    ColorType='truecolor';
     208end
     209if length(FileInfo_A) >1 %case of image with multiple frames
     210    nbfield=length(FileInfo_A);
     211    nbfield_j=1;
     212end
     213
    214214%%%%% MAIN LOOP %%%%%%
    215 
    216 MovieObject_A=[];
    217215for ifield=1:NbField
    218216   
     
    232230        else
    233231            ImageName_A=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,i1_series_Civ1(ifield),[],j1_series_Civ1(ifield));
    234             [par_civ1.ImageA,MovieObject_A] = read_image(ImageName_A,FileType_A,MovieObject_A,FrameIndex_A_Civ1(ifield));
     232            [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,FileType_A,VideoObject_A,FrameIndex_A_Civ1(ifield));
    235233            ImageName_B=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,i2_series_Civ1(ifield),[],j2_series_Civ1(ifield));
    236             [par_civ1.ImageB,MovieObject_B] = read_image(ImageName_B,FileType_B,MovieObject_B,FrameIndex_B_Civ1(ifield));
     234            [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ1(ifield));
    237235        end
    238236        ncfile=fullfile_uvmat(RootPath,OutputDir,RootFile,'.nc',NomTypeNc,i1_series_Civ1(ifield),i2_series_Civ1(ifield),...
    239237            j1_series_Civ1(ifield),j2_series_Civ1(ifield));
    240         par_civ1.ImageWidth=FileInfo.Width;
    241         par_civ1.ImageHeight=FileInfo.Height;
     238        par_civ1.ImageWidth=FileInfo_A.Width;
     239        par_civ1.ImageHeight=FileInfo_A.Height;
    242240        list_param=(fieldnames(Param.ActionInput.Civ1))';
    243241        Civ1_param=regexprep(list_param,'^.+','Civ1_$0');% insert 'Civ1_' before  each string in list_param
     
    246244        Data.Civ1_ImageA=ImageName_A;
    247245        Data.Civ1_ImageB=ImageName_B;
    248         Data.Civ1_Time=((time(i2_civ1(ifile)+1,j2_civ1(j)+1)+time(i1_civ1(ifile)+1,j1_civ1(j)+1))/2);
    249         Data.Civ1_Dt=(time(i2_civ1(ifile)+1,j2_civ1(j)+1)-time(i1_civ1(ifile)+1,j1_civ1(j)+1));
     246        i1=i1_series_Civ1(ifield);
     247        i2=i1;
     248        if ~isempty(i2_series_Civ1)
     249            i2=i2_series_Civ1(ifield);
     250        end
     251        j1=1;
     252        if ~isempty(j1_series_Civ1)
     253            j1=j1_series_Civ1(ifield);
     254        end
     255        j2=j1;
     256        if ~isempty(j2_series_Civ1)
     257            j2=j2_series_Civ1(ifield);
     258        end
     259        Data.Civ1_Time=(time(j2+1,i2+1)+time(j1+1,i1+1))/2;
     260        Data.Civ1_Dt=time(j2+1,i2+1)-time(j1+1,i1+1)
    250261        for ilist=1:length(list_param)
    251262            Data.(Civ1_param{4+ilist})=Param.ActionInput.Civ1.(list_param{ilist});
     
    385396            par_civ2.ImageA=par_civ1.ImageA;
    386397        else
    387             [par_civ2.ImageA,MovieObject_A] = read_image(ImageName_A,FileType_A,MovieObject_A,FrameIndex_A_Civ2);
     398            [par_civ2.ImageA,VideoObject_A] = read_image(ImageName_A,FileType_A,VideoObject_A,FrameIndex_A_Civ2);
    388399        end
    389400        ImageName_B_Civ2=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,i2_series_Civ2(ifield),[],j2_series_Civ2(ifield));
     
    391402            par_civ2.ImageB=par_civ1.ImageB;
    392403        else
    393             [par_civ2.ImageB,MovieObject_B] = read_image(ImageName_B,FileType_B,MovieObject_B,FrameIndex_B_Civ2);
     404            [par_civ2.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ2);
    394405        end     
    395406       
     
    919930    find_pair_indices(str_civ,i_series,j_series,MinIndex,MaxIndex)
    920931%------------------------------------------------------------------------
    921 i1_series=i_series;% set of first image numbers
     932i1_series=i_series;% set of first image indexes
    922933i2_series=i_series;
    923934j1_series=ones(size(i_series));% set of first image numbers
    924935j2_series=ones(size(i_series));
    925936check_bounds=false(size(i_series));
    926 r=regexp(str_civ,'^\D(?<ind>[i|j])= (?<num1>\d+)\|(?<num2>\d+)','names');
     937r=regexp(str_civ,'^\D(?<ind>[i|j])=( -| )(?<num1>\d+)\|(?<num2>\d+)','names');
    927938if ~isempty(r)
    928939    mode=['D' r.ind];
  • trunk/src/uigetfile_uvmat.m

    r609 r610  
    1212function fileinput=uigetfile_uvmat(title,InputName)
    1313fileinput=''; %default file selection
    14 if strcmp(title,'status')
    15     option='status';
     14if strcmp(title,'status_display')
     15    option='status_display';
    1616else
    1717    option='browser';
    1818end
    19 if exist(InputName,'file')||exist(InputName,'dir')
     19if exist(InputName,'dir')
     20    InputDir=InputName;
     21      InputFileName='';
     22elseif exist(InputName,'file')
    2023    [InputDir,InputFileName,Ext]=fileparts(InputName);
    21     InputFileName=[InputFileName Ext];
     24    if isempty(InputFileName)% if InputName is already the root
     25        InputFileName=InputDir;
     26        if  ~isempty(strcmp (computer, {'PCWIN','PCWIN64'}))%case of Windows systems
     27            InputDir=[InputDir '\'];% append '\' for a correct action of dir
     28            InputFileName=[InputFileName '\'];
     29        end
     30    end
    2231    if isdir(InputName)
    23         InputFileName=['+/' InputFileName];
     32        InputFileName=['+/' InputFileName Ext];
    2433    end
    2534else
     
    4554        'String','Refresh','FontWeight','bold','FontUnits','points','FontSize',12);
    4655    %set(hrefresh,'UserData',StatusData)
    47     if strcmp(option,'status') %put a run advancement display
     56    if strcmp(option,'status_display') %put a run advancement display
    4857        set(hfig,'DeleteFcn',@stop_status)
    4958        uicontrol('Style','frame','Units','normalized', 'Position',[0.05 0.81 0.01 0.05],'BackgroundColor',[1 0 0],'tag','waitbar');
     
    5968    drawnow
    6069end
    61 refresh_GUI(findobj(hfig,'Tag','refresh'),InputFileName) 
    62 if ~strcmp(option,'status') 
     70refresh_GUI(findobj(hfig,'Tag','refresh'),InputFileName)% refresh the list of content of the current dir 
     71if ~strcmp(option,'status_display') 
    6372    uiwait(hfig)
    64 end
    65 fileinput=get(hfig,'UserData');% retrieve the input file selection
    66 delete(hfig)
     73    fileinput=get(hfig,'UserData');% retrieve the input file selection
     74    delete(hfig)
     75end
     76
     77
     78
     79%------------------------------------------------------------------------   
     80% --- launched by refreshing the display figure
     81function refresh_GUI(hObject,InputFileName)
     82%------------------------------------------------------------------------
     83if ~exist('InputFileName','var')
     84    InputFileName='';
     85end
     86hfig=get(hObject,'parent');
     87DirName=get(hfig,'UserData');
     88ListFiles=list_files(DirName);% list the directory content
     89hlist=findobj(hfig,'tag','list');% find the list object
     90set(hlist,'String',ListFiles)
     91Value=[];
     92if ~isempty(InputFileName)
     93    Value=find(strcmp(InputFileName,ListFiles));
     94end
     95if isempty(Value)
     96    Value=1;
     97end
     98set(hlist,'Value',Value)
     99
     100if strcmp(get(hfig,'Tag'),'status_display')
     101   
     102    hseries=findobj(allchild(0),'tag','series');
     103    hstatus=findobj(hseries,'tag','status_display');
     104    StatusData=get(hstatus,'UserData');
     105    TimeStart=0;
     106    if isfield(StatusData,'TimeStart')
     107        TimeStart=StatusData.TimeStart;
     108    end
     109   
     110   
     111    htitlebox=findobj(hfig,'tag','titlebox');
     112    hlist=findobj(hfig,'tag','list');
     113    OutputDir=get(hfig,'UserData');
     114   
     115    testrecent=0;
     116    datnum=zeros(numel(ListDisplay),1);
     117    for ilist=1:numel(ListDisplay)
     118        ListDisplay{ilist}=ListFiles(ilist).name;
     119        if ListFiles(ilist).isdir
     120            ListDisplay{ilist}=['/' ListDisplay{ilist}];
     121        elseif isfield(ListFiles(ilist),'datenum')
     122            datnum(ilist)=ListFiles(ilist).datenum;%only available in recent matlab versions
     123            testrecent=1;
     124            if datnum(ilist)<TimeStart
     125                ListDisplay{ilist}=[ListDisplay{ilist} '  --OLD--'];
     126            end
     127        end
     128    end
     129   
     130    %% Look at date of creation
     131    ListDisplay=ListDisplay(datnum~=0);
     132    datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files
     133   
     134    NbOutputFile=[];
     135    if isempty(datnum)
     136        if testrecent
     137            message='no result created yet';
     138        else
     139            message='';
     140        end
     141    else
     142        [first,indfirst]=min(datnum);
     143        [last,indlast]=max(datnum);
     144        NbOutputFile_str='?';
     145        if isfield(StatusData,'NbOutputFile')
     146            NbOutputFile=StatusData.NbOutputFile;
     147            NbOutputFile_str=num2str(NbOutputFile);
     148        end
     149        message={[num2str(numel(datnum)) ' file(s) done over ' NbOutputFile_str] ;['oldest modification:  ' ListDisplay{indfirst} ' : ' datestr(first)];...
     150            ['latest modification:  ' ListDisplay{indlast} ' : ' datestr(last)]};
     151    end
     152    set(htitlebox,'String', [DirName{1};message])
     153   
     154    %% update the waitbar
     155    hwaitbar=findobj(hfig,'tag','waitbar');
     156    if ~isempty(NbOutputFile)
     157        BarPosition=get(hwaitbar,'Position');
     158        BarPosition(3)=0.9*numel(datnum)/NbOutputFile;
     159        set(hwaitbar,'Position',BarPosition)
     160    end
     161end
    67162
    68163%------------------------------------------------------------------------   
     
    118213        set(hfig,'UserData',FullSelectName);
    119214        uiresume(hfig)
    120             case 'status'
     215            case 'status_display'
    121216           uvmat(FullSelectName);
    122217        end
    123218        set(gcbo,'Value',1)
    124219    end
    125 end
    126 
    127 %------------------------------------------------------------------------   
    128 % --- launched by selecting home
    129 function home_dir(hObject,event)
    130 %------------------------------------------------------------------------
    131 DirName=pwd;
    132 ListFiles=list_files(DirName);% list the directory content
    133 hfig=get(hObject,'parent');
    134     set(hfig,'UserData',DirName)% record the new dir name
    135     htitlebox=findobj(hfig,'tag','titlebox');  % display the new dir name 
    136     set(htitlebox,'String',DirName)
    137     hlist=findobj(hfig,'tag','list');% find the list object
    138 set(hlist,'String',ListFiles)
    139 %------------------------------------------------------------------------
    140 
    141 %------------------------------------------------------------------------   
    142 % --- launched by pressing the backward (<--) button
    143 function backward(hObject,event)
    144 %------------------------------------------------------------------------
    145 PrevDir=get(hObject,'UserData');
    146 if ~isempty(PrevDir)
    147 hfig=get(hObject,'parent');
    148 set(hfig,'UserData',PrevDir)
    149 htitlebox=findobj(hfig,'tag','titlebox');  % display the new dir name
    150 set(htitlebox,'String',PrevDir)
    151 refresh_GUI(findobj(hfig,'Tag','refresh'))
    152 end
    153 
    154 %------------------------------------------------------------------------
    155 
    156 %------------------------------------------------------------------------   
    157 % --- launched by refreshing the display figure
    158 function refresh_GUI(hObject,InputFileName)
    159 %------------------------------------------------------------------------
    160 if ~exist('InputFileName','var')
    161     InputFileName='';
    162 end
    163 hfig=get(hObject,'parent');
    164 DirName=get(hfig,'UserData');
    165 ListFiles=list_files(DirName);% list the directory content
    166 hlist=findobj(hfig,'tag','list');% find the list object
    167 set(hlist,'String',ListFiles)
    168 Value=[];
    169 if ~isempty(InputFileName)
    170     Value=find(strcmp(InputFileName,ListFiles));
    171 end
    172 if isempty(Value)
    173     Value=1;
    174 end
    175 set(hlist,'Value',Value)
    176 return
    177 
    178 %TODO adapt to series status
    179 hseries=findobj(allchild(0),'tag','series');
    180 hstatus=findobj(hseries,'tag','status');
    181 StatusData=get(hstatus,'UserData');
    182 TimeStart=0;
    183 if isfield(StatusData,'TimeStart')
    184     TimeStart=StatusData.TimeStart;
    185 end
    186 % testrecent=0;
    187 % datnum=zeros(numel(ListDisplay),1);
    188 % for ilist=1:numel(ListDisplay)
    189 %     ListDisplay{ilist}=ListFiles(ilist).name;
    190 %     if ListFiles(ilist).isdir
    191 %         ListDisplay{ilist}=['/' ListDisplay{ilist}];   
    192 %     elseif isfield(ListFiles(ilist),'datenum')
    193 %         datnum(ilist)=ListFiles(ilist).datenum;%only available in recent matlab versions
    194 %         testrecent=1;
    195 %         if datnum(ilist)<TimeStart
    196 %             ListDisplay{ilist}=[ListDisplay{ilist} '  --OLD--'];
    197 %         end
    198 %     end
    199 % end
    200 
    201 
    202 %% Look at date of creation
    203 ListDisplay=ListDisplay(datnum~=0);
    204 datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files
    205 
    206 NbOutputFile=[];
    207 if isempty(datnum)
    208     if testrecent
    209         message='no result created yet';
    210     else
    211         message='';
    212     end
    213 else
    214     [first,indfirst]=min(datnum);
    215     [last,indlast]=max(datnum);
    216     NbOutputFile_str='?';
    217     if isfield(StatusData,'NbOutputFile')
    218         NbOutputFile=StatusData.NbOutputFile;
    219         NbOutputFile_str=num2str(NbOutputFile);
    220     end
    221     message={[num2str(numel(datnum)) ' file(s) done over ' NbOutputFile_str] ;['oldest modification:  ' ListDisplay{indfirst} ' : ' datestr(first)];...
    222         ['latest modification:  ' ListDisplay{indlast} ' : ' datestr(last)]};
    223 end
    224 set(htitlebox,'String', [DirName{1};message])
    225 
    226 %% update the waitbar
    227 hwaitbar=findobj(hfig,'tag','waitbar');
    228 if ~isempty(NbOutputFile)
    229     BarPosition=get(hwaitbar,'Position');
    230     BarPosition(3)=0.9*numel(datnum)/NbOutputFile;
    231     set(hwaitbar,'Position',BarPosition)
    232220end
    233221
     
    236224function ListFiles=list_files(DirName)
    237225%-------------------------------------------------------------------------
    238 ListStruct=dir(DirName);
     226ListStruct=dir(DirName);% get structure of the current directory
    239227if numel(ListStruct)<1
    240228    ListFiles={};
     
    254242ListFiles=[{'+/..'} ListFiles(check_keep)];
    255243
     244%------------------------------------------------------------------------   
     245% --- launched by selecting home
     246function home_dir(hObject,event)
     247%------------------------------------------------------------------------
     248DirName=pwd;
     249ListFiles=list_files(DirName);% list the directory content
     250hfig=get(hObject,'parent');
     251    set(hfig,'UserData',DirName)% record the new dir name
     252    htitlebox=findobj(hfig,'tag','titlebox');  % display the new dir name 
     253    set(htitlebox,'String',DirName)
     254    hlist=findobj(hfig,'tag','list');% find the list object
     255set(hlist,'String',ListFiles)
     256%------------------------------------------------------------------------
     257
     258%------------------------------------------------------------------------   
     259% --- launched by pressing the backward (<--) button
     260function backward(hObject,event)
     261%------------------------------------------------------------------------
     262PrevDir=get(hObject,'UserData');
     263if ~isempty(PrevDir)
     264hfig=get(hObject,'parent');
     265set(hfig,'UserData',PrevDir)
     266htitlebox=findobj(hfig,'tag','titlebox');  % display the new dir name
     267set(htitlebox,'String',PrevDir)
     268refresh_GUI(findobj(hfig,'Tag','refresh'))
     269end
     270
    256271%-------------------------------------------------------------------------   
    257272% launched by deleting the status figure (only used in mode series status')
    258273function close(option,hObject, eventdata)
    259274%-------------------------------------------------------------------------
    260 if strcmp(option,'status')
     275if strcmp(option,'status_display')
    261276    hseries=findobj(allchild(0),'tag','series');
    262     hstatus=findobj(hfig,'Tag','status');
     277    hstatus=findobj(hfig,'Tag','status_display');
    263278    set(hhciv.status,'value',0) %reset the status uicontrol in the GUI civ
    264279    set(hhciv.status,'BackgroundColor',[0 1 0])
Note: See TracChangeset for help on using the changeset viewer.