Changeset 421 for trunk/src/civ.m


Ignore:
Timestamp:
May 14, 2012, 7:03:14 AM (12 years ago)
Author:
sommeria
Message:

bugs corrections and improvements following tutorial presentation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r419 r421  
    922922if isempty(hfig)
    923923    hfig=figure('DeleteFcn',@stop_status);
     924    set(hfig,'MenuBar','none')% suppress the menu bar
     925    set(hfig,'NumberTitle','off')%suppress the fig number in the title
    924926    set(hfig,'name','civ_status')
    925      uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', {'open_uvmat'},'tag','list');
     927    set(hfig,'tag','civ_status')
     928    set(hfig,'UserData',civ_files)
     929    hlist= uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', {'open_uvmat'},'tag','list');
    926930    uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','msgbox','Max',2,'String','checking files...');
    927931    uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]);
    928     uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'String','OK','FontWeight','bold','FontUnits','normalized','FontSize',0.9,'Callback',@close_GUI);
     932    uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'String','Close','FontWeight','bold','FontUnits','normalized','FontSize',0.9,'Callback',@close_GUI);
     933    hrefresh=uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.1 0.01 0.2 0.07],'String','Refresh','FontWeight','bold','FontUnits','normalized','FontSize',0.9,'Callback',@refresh_GUI);
    929934    BarPosition=[0.05 0.81 0.01 0.05];
    930     hwaitbar=uicontrol('Style','frame','Units','normalized', 'Position',BarPosition ,'BackgroundColor',[1 0 0],'tag','waitbar');
    931     drawnow
    932 end
     935    uicontrol('Style','frame','Units','normalized', 'Position',BarPosition ,'BackgroundColor',[1 0 0],'tag','waitbar');
     936    drawnow
     937end
     938set(hrefresh,'UserData',option_civ)
     939        filepath=fileparts(civ_files{1});
     940set(hlist,'UserData',fileparts(filepath))
     941refresh_GUI(hrefresh,[])
     942
     943%------------------------------------------------------------------------   
     944% launched by refreshing the status figure
     945function refresh_GUI(hObject, eventdata)
     946%------------------------------------------------------------------------
    933947Tabchar={};
     948BarPosition=[0.05 0.81 0.01 0.05];
     949hfig=get(hObject,'parent');
     950civ_files=get(hfig,'UserData');
     951        [filepath,filename,ext]=fileparts(civ_files{1});
     952        [tild,SubDir,extdir]=fileparts(filepath);
     953        SubDir=[SubDir extdir];
     954option_civ=get(hObject,'UserData');
    934955nbfiles=numel(civ_files);
    935956count=0;
    936957testrecent=0;
    937 while count<nbfiles
     958% while count<nbfiles
    938959    count=0;
    939960    datnum=zeros(1,nbfiles);
     
    976997            count=count+1;
    977998        end
    978         [rr,filename,ext]=fileparts(civ_files{ifile});
    979         Tabchar{ifile,1}=[fullfile([SubDir extdir],filename) ext  '...' option_str];
     999        [filepath,filename,ext]=fileparts(civ_files{ifile});
     1000        Tabchar{ifile,1}=[fullfile(SubDir,filename) ext  '...' option_str];
    9801001    end
    9811002    datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files
     
    9901011        [first,ind]=min(datnum);
    9911012        [last,indlast]=max(datnum);
    992         if test_new
    993             message='existing file status, no processing launched yet';
    994         else
     1013%         if test_new
     1014%             message='existing file status, no processing launched yet';
     1015%         else
    9951016        message={[num2str(count) ' file(s) done over ' num2str(nbfiles)] ;['oldest modification:  ' cell2mat(filefound(ind)) ' : ' datestr(first)];...
    9961017            ['latest modification:  ' cell2mat(filefound(indlast)) ' : ' datestr(last)]};
    997         end
    998     end
    999     hfig=findobj(allchild(0),'name','civ_status');
    1000     if isempty(hfig)% the status list has been deleted
    1001         return
    1002     else
     1018%         end
     1019    end
     1020    %hfig=findobj(allchild(0),'name','civ_status');
     1021%     if isempty(hfig)% the status list has been deleted
     1022%         return
     1023%     else
    10031024        hlist=findobj(hfig,'tag','list');
    10041025        hmsgbox=findobj(hfig,'tag','msgbox');
     
    10061027        set(hlist,'String',Tabchar)
    10071028        set(hmsgbox,'String', message)
    1008         if count>0 && ~test_new
     1029        if count>0 %&& ~test_new
    10091030            BarPosition(3)=0.9*count/nbfiles;
    10101031            set(hwaitbar,'Position',BarPosition)
    10111032        end
    1012     end
    1013     set(hlist,'UserData',rootroot)
    1014     if count<10||(nbfiles-count)<10
    1015     pause(.5)% wait 0.5 seconds for next check
    1016     else
    1017         pause(10)% wait 10 seconds for next check
    1018     end
    1019 end
     1033%     end
     1034%     [root,filename,ext]=fileparts(civ_files{1});
     1035% [rootroot,SubDir,extdir]=fileparts(root);
     1036%
     1037%     set(hlist,'UserData',rootroot)
     1038%     if count<10||(nbfiles-count)<10
     1039%     pause(.5)% wait 0.5 seconds for next check
     1040%     else
     1041%         pause(10)% wait 10 seconds for next check
     1042%     end
     1043% end
     1044
     1045%------------------------------------------------------------------------   
     1046% launched by deleting the status figure
     1047function stop_status(hObject, eventdata)
     1048%------------------------------------------------------------------------
     1049hciv=findobj(allchild(0),'tag','civ');
     1050hhciv=guidata(hciv);
     1051set(hhciv.status,'value',0) %reset the status uicontrol in the GUI civ
     1052set(hhciv.status,'BackgroundColor',[0 1 0])
     1053
     1054%------------------------------------------------------------------------   
     1055% launched by pressing OK on the status figure
     1056function close_GUI(hObject, eventdata)
     1057%------------------------------------------------------------------------
     1058    delete(gcbf)
     1059
    10201060
    10211061%------------------------------------------------------------------------
     
    11431183for bin_name=binary_list %loop on the list of binaries
    11441184    if isfield(Param.xml,bin_name{1})% bin_name{1} =current name in the list
    1145         if ~exist(Param.xml.(bin_name{1}),'file')%look for the full path if the file name has been defined with a relative path in PARAM.xml
     1185        if exist(Param.xml.(bin_name{1}),'file')
     1186            [path,name,ext]=fileparts(Param.xml.(bin_name{1}));
     1187            currentdir=pwd;
     1188            if exist(path,'dir')
     1189                cd(path);
     1190                binpath=pwd;%path of the binary
     1191                Param.xml.(bin_name{1})=fullfile(binpath,[name ext]);
     1192                cd(currentdir)
     1193            else
     1194                errormsg=['path ' path ' for binaries defined in PARAM.xml does not exist'];
     1195                return
     1196            end
     1197        else  %look for the full path if the file name has been defined with a relative path in PARAM.xm
    11461198            fullname=fullfile(path_civ,Param.xml.(bin_name{1}));
    11471199            if exist(fullname,'file')
     
    11511203                return
    11521204            end
    1153         else
    1154             [path,name,ext]=fileparts(Param.xml.(bin_name{1}));
    1155             currentdir=pwd;
    1156             cd(path);
    1157             binpath=pwd;%path of the binary
    1158             Param.xml.(bin_name{1})=fullfile(binpath,[name ext]);
    1159             cd(currentdir);
    1160         end
    1161        
     1205        end
    11621206    end
    11631207end
     
    32153259% end
    32163260
    3217 %------------------------------------------------------------------------   
    3218 % launched by pressing OK on the status figure
    3219 function close_GUI(hObject, eventdata)
    3220 %------------------------------------------------------------------------
    3221     delete(gcbf)
    3222    
    3223 %------------------------------------------------------------------------   
    3224 % launched by deleting the status figure
    3225 function stop_status(hObject, eventdata)
    3226 %------------------------------------------------------------------------
    3227 hciv=findobj(allchild(0),'tag','civ');
    3228 hhciv=guidata(hciv);
    3229 set(hhciv.status,'value',0) %reset the status uicontrol in the GUI civ
    3230 set(hhciv.status,'BackgroundColor',[0 1 0])
    3231 
    32323261
    32333262%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Note: See TracChangeset for help on using the changeset viewer.