Changeset 733


Ignore:
Timestamp:
Apr 4, 2014, 1:31:34 PM (10 years ago)
Author:
sommeria
Message:

various improvements

Location:
trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/browse_data.m

    r651 r733  
    2222function varargout = browse_data(varargin)
    2323
    24 % Last Modified by GUIDE v2.5 07-Mar-2013 18:55:00
     24% Last Modified by GUIDE v2.5 11-Mar-2014 22:09:37
    2525
    2626% Begin initialization code - DO NOT EDIT
     
    7171set(hObject, 'Position', FigPos);
    7272set(hObject, 'Units', OldUnits);
    73 %
    74 % if exist('GeometryCalib','var')
    75 %     DataviewData.GeometryCalib=GeometryCalib;
    76 %     set(hObject,'UserData',DataviewData)
    77 % end
    78 if exist('Campaign','var')
     73if exist('Campaign','var')
    7974    [CampaignPath,CampaignName]=fileparts(Campaign);
    8075    RootXml=fullfile(Campaign,[CampaignName '.xml']);
     
    9489        set(handles.CreateMirror,'String','create_mirror')
    9590    end
    96     scan_campaign(handles,Campaign)
    97    set(handles.OK,'Visible','on')
    98    set(handles.Cancel,'Visible','on')
    99    set(handles.browse_data,'WindowStyle','modal')% Make the GUI modal
    100    set(hObject,'Visible','on')
    101    drawnow
    102    % UIWAIT makes GUI wait for user response (see UIRESUME)
    103    uiwait(handles.browse_data);
     91    errormsg=scan_campaign(handles,Campaign);
     92    if ~isempty(errormsg)
     93        msgbox_uvmat('ERROR',errormsg)
     94        return
     95    end
     96    set(handles.OK,'Visible','on')
     97    set(handles.Cancel,'Visible','on')
     98    set(handles.browse_data,'WindowStyle','modal')% Make the GUI modal
     99    set(hObject,'Visible','on')
     100    drawnow
     101    % UIWAIT makes GUI wait for user response (see UIRESUME)
     102    uiwait(handles.browse_data);
    104103end
    105104
     
    116115function CreateMirror_Callback(hObject, eventdata, handles)
    117116%------------------------------------------------------------------------
     117set(handles.SourceDir,'BackgroundColor',[1 1 0])% indicate action of button by yellow color
     118drawnow
    118119SourceDir=get(handles.SourceDir,'String');
    119120[SourcePath,ProjectName]=fileparts(SourceDir);
    120121if strcmp(get(handles.MirrorDir,'Visible'),'on')
    121     MirrorDir=get(handles.MirrorDir,'String');
    122 else
     122    MirrorDir=get(handles.MirrorDir,'String');% name of the mirror folder
     123else% create the mirror folder if it does not exist
    123124    MirrorRoot=uigetfile_uvmat('select the folder which must contain the mirror directory:',SourcePath,'uigetdir');
    124 %     MirrorRoot=uigetdir('','select the dir which must contain the mirror directory, then press OK'); %file browser
    125125    if isempty(MirrorRoot)
    126126        return
     
    138138    set(handles.MirrorDir,'Visible','on')
    139139end
    140 set(handles.SourceDir,'BackgroundColor',[1 1 0])
    141 drawnow
    142140ExpName={''};
     141
     142%% update the mirror from the source dir
    143143if exist(SourceDir,'dir')
    144144    hdir=dir(SourceDir); %list files and dirs
    145145    idir=0;
    146146    for ilist=1:length(hdir)
    147         if hdir(ilist).isdir
    148             dirname=hdir(ilist).name;
    149             if ~isequal(dirname(1),'.')&&~isequal(dirname(1),'0')
     147        if hdir(ilist).isdir% scan all subfolders
     148            dirname=hdir(ilist).name;%
     149            if ~isequal(dirname(1),'.')&&~isequal(dirname(1),'0')%skip subfolder beginning by '0'
    150150                idir=idir+1;
    151                 mirror=fullfile(MirrorDir,hdir(ilist).name);
     151                mirror=fullfile(MirrorDir,hdir(ilist).name);% corresponding name in the mirror
    152152                if ~exist(mirror,'dir')
    153                    mkdir(mirror)
     153                   mkdir(mirror)% create the mirror folder if it does not exist
    154154                end
    155                 ExpName{idir}=['+/' hdir(ilist).name];
     155                ExpName{idir}=['+/' hdir(ilist).name];% insert '+/' in the list to show that it is a folder
    156156            end
    157157            % look for the list of 'devices'
     
    162162    set(handles.ListExperiments,'String',[{'*'};ExpName'])
    163163    set(handles.ListExperiments,'Value',1)
    164     ListExperiments_Callback(hObject, eventdata, handles)
     164     update_experiments(handles,[{'*'};ExpName'],SourceDir,MirrorDir)
     165   % ListExperiments_Callback(hObject, eventdata, handles) % list the content of the experiment
    165166else
    166167    msgbox_uvmat('ERROR',['The input ' SourceDir ' is not a directory'])
     
    169170
    170171
    171 % %------------------------------------------------------------------------
    172 % function MirrorDir_Callback(hObject, eventdata, handles)
    173 % %------------------------------------------------------------------------   
    174 % MirrorDir=get(handles.MirrorDir,'String');
    175 % [tild,MirrorName]=fileparts(MirrorDir);
    176 % s=xml2struct(fullfile(MirrorDir,[MirrorName '.xml']));
    177 % set(handles.SourceDir,'String',s.SourceDir)
    178 % SourceDir_Callback([],[], handles)
    179 
    180 
    181 %------------------------------------------------------------------------
    182 function scan_campaign(handles,Campaign)
     172%------------------------------------------------------------------------
     173function errormsg=scan_campaign(handles,Campaign)
    183174%------------------------------------------------------------------------
    184175%set(handles.SourceDir,'BackgroundColor',[1 1 0])
    185 drawnow
     176%drawnow
    186177%SourceDir=get(handles.SourceDir,'String');
    187178%MirrorDir=get(handles.MirrorDir,'String');
    188179% ExpName={''};
     180errormsg='';
    189181if exist(Campaign,'dir')
    190182    ListStruct=dir(Campaign); %list files and dirs
     183    if numel(ListStruct)>1000% A campaign folder must contain maily a list of 'experiment' sub-folders
     184        errormsg=[Campaign ' contains too many items (>1000) to be a Campaign folder'];
     185        return
     186    end
    191187    ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray
    192188    ListFiles=ListCells(1,:);%list of dir and file  names
     
    218214list_val=get(handles.ListExperiments,'Value');
    219215if isequal(list_val(1),1)
    220     ListExperiments=ListExperiments(2:end); %choose all experiments
     216    ListExperiments=ListExperiments(2:end); %choose all experiments if the first line '*' is selected
    221217    set(handles.ListExperiments,'Value',1)
    222218else
    223219    ListExperiments=ListExperiments(list_val);%choose selected experiments
    224220end
    225 scan_experiments(handles,ListExperiments,CampaignPath,MirrorPath)
    226 
    227 
    228 %------------------------------------------------------------------------
    229 % --- Executes on selection change in ListExperiments.
    230 %------------------------------------------------------------------------
    231  function scan_experiments(handles,ListExperiments,CampaignPath,MirrorPath)
     221list_dataseries(handles,ListExperiments,MirrorPath)
     222
     223%------------------------------------------------------------------------
     224% --- List the DataSeries when a set of experiments is selected
     225%------------------------------------------------------------------------
     226 function list_dataseries(handles,ListExperiments,MirrorPath)
    232227
    233228ListDevices={};
     
    235230    if strcmp(ListExperiments{iexp}(1),'+')% if the item is a directory
    236231        ListExperiments{iexp}(1)=[];
    237         ListStruct=dir(fullfile(CampaignPath,ListExperiments{iexp})); %list files and dir in the experiment directory
    238         ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray
     232        ListStruct=dir(fullfile(MirrorPath,ListExperiments{iexp})); %list files and dir in the source experiment directory
     233        ListCells=struct2cell(ListStruct);%transform dir struct to a cell arrray
    239234        ListFiles=ListCells(1,:);%list of dir and file  names
    240235        cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . )
     
    242237        check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files
    243238        for ilist=1:numel(ListFiles)
    244             if check_keep(ilist)
    245                 DataSeries=fullfile(CampaignPath,ListExperiments{iexp},ListFiles{ilist});
    246                 if ~isempty(MirrorPath)
    247                     mirror=fullfile(MirrorPath,ListExperiments{iexp},ListFiles{ilist});
    248                     if ~exist(mirror)% create mirror if needed
    249                         system(['ln -s ' DataSeries ' ' mirror])
     239            if check_keep(ilist)% loop on eligible DataSeries folders
     240                mirror=fullfile(MirrorPath,ListExperiments{iexp},ListFiles{ilist});%source folder
     241                if ~exist(mirror,'file') && ~exist(mirror,'dir')% if the name is a broken link
     242                    delete(mirror)% delete broken link
     243                else %update the list of dataSeries
     244                    [tild,msg]=fileattrib(mirror);
     245                    if ~strcmp(msg.Name,mirror)% if it is a link
     246                        ListFiles{ilist}=['~' ListFiles{ilist}];%mark link by '@' in the list
    250247                    end
    251                 end
    252                 if isempty(find(strcmp(ListFiles{ilist},ListDevices), 1))% if the item is not already in ListDevices
    253248                    if check_dir(ilist)
    254249                        ListFiles{ilist}=['+/' ListFiles{ilist}];%mark dir by '+' in the list
    255250                    end
    256                     ListDevices=[ListDevices;ListFiles{ilist}]; %append the item to the list
     251                    if isempty(find(strcmp(ListFiles{ilist},ListDevices), 1))% if the item is not already in ListDevices
     252                        ListDevices=[ListDevices;ListFiles{ilist}]; %append the item to the list
     253                    end                   
     254                end
     255            end
     256        end
     257    end
     258end
     259set(handles.ListDevices,'String',sort(ListDevices))
     260
     261%------------------------------------------------------------------------
     262% --- Executes when the mirror is created or updated
     263%------------------------------------------------------------------------
     264 function update_experiments(handles,ListExperiments,CampaignPath,MirrorPath)
     265
     266ListDevices={};
     267for iexp=1:numel(ListExperiments)
     268    if strcmp(ListExperiments{iexp}(1),'+')% if the item is a directory
     269        ListExperiments{iexp}(1)=[];
     270        ListStruct=dir(fullfile(CampaignPath,ListExperiments{iexp})); %list files and dir in the source experiment directory
     271        ListCells=struct2cell(ListStruct);%transform dir struct to a cell arrray
     272        ListFiles=ListCells(1,:);%list of dir and file  names
     273        cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . )
     274        check_keep=cellfun('isempty', cell_remove);
     275        check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files
     276        for ilist=1:numel(ListFiles)
     277            if check_keep(ilist)% loop on eligible DataSeries folders
     278                DataSeries=fullfile(CampaignPath,ListExperiments{iexp},ListFiles{ilist});%source folder
     279                if ~isempty(MirrorPath)
     280                    mirror=fullfile(MirrorPath,ListExperiments{iexp},ListFiles{ilist});
     281                    if exist(mirror,'dir')||exist(mirror,'file')
     282                        [tild,msg]=fileattrib(mirror);
     283                        if strcmp(msg.Name,mirror)%if the mirror name already exists as a local file or dir
     284                            if msg.directory% case of a f
     285                                answer=msgbox_uvmat('INPUT_Y-N',['replace local folder ' msg.Name ' by a link to the source dir']);
     286                                if strcmp(answer,'Yes')
     287                                    [ss,msg]=rmdir(mirror);
     288                                    if ss==1
     289                                        system(['ln -s ' DataSeries ' ' mirror]); % create the link to the source folder
     290                                    else
     291                                        msgbox_uvmat('ERROR',['enable to delete local folder: ' msg]);
     292                                    end
     293                                end
     294                            else
     295                                answer=msgbox_uvmat('INPUT_Y-N',['replace local file ' msg.Name ' by a link to the source file']);
     296                                if strcmp(answer,'Yes')
     297                                    delete(mirror);
     298                                    system(['ln -s ' DataSeries ' ' mirror]); % create the link to the source folder
     299                                   
     300                                end
     301                            end
     302                        else% create mirror to the data series if needed
     303                            system(['ln -s ' DataSeries ' ' mirror]); % create the link to the source folder
     304                        end
     305                    end
     306                    if isempty(find(strcmp(ListFiles{ilist},ListDevices), 1))% if the item is not already in ListDevices
     307                        if check_dir(ilist)
     308                            ListFiles{ilist}=['+/' ListFiles{ilist}];%mark dir by '+' in the list
     309                        end
     310                        ListDevices=[ListDevices;ListFiles{ilist}]; %append the item to the list
     311                    end
    257312                end
    258313            end
     
    343398save(t,outputfile)
    344399
    345 %------------------------------------------------------------------------
    346 % --- Executes on button press in CampaignDoc.
    347 function edit_xml_Callback(hObject, eventdata, handles)
    348 %------------------------------------------------------------------------
    349 CurrentPath=get(handles.SourceDir,'String');
    350 %[CurrentPath,Name,Ext]=fileparts(CurrentDir);
    351 ListExperiments=get(handles.ListExperiments,'String');
    352 Value=get(handles.ListExperiments,'Value');
    353 if ~isequal(Value,1)
    354     ListExperiments=ListExperiments(Value);
    355 end
    356 ListDevices=get(handles.ListDevices,'String');
    357 Value=get(handles.ListDevices,'Value');
    358 if ~isequal(Value,1)
    359     ListDevices=ListDevices(Value);
    360 end
    361 ListRecords=get(handles.ListRecords,'String');
    362 Value=get(handles.ListRecords,'Value');
    363 if ~isequal(Value,1)
    364     ListRecords=ListRecords(Value);
    365 end
    366 [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices,ListRecords);
    367 ListXml=get(handles.ListXml,'String');
    368 Value=get(handles.ListXml,'Value');
    369 set(handles.ListXml,'Value',Value(1));
    370 if isequal(Value(1),1)
    371     msgbox_uvmat('ERROR','an xml file needs to be selected')
    372    return
    373 else
    374     XmlName=ListXml{Value(1)};
    375 end
    376 for iexp=1:length(List.Experiment)
    377     ExpName=List.Experiment{iexp}.name;
    378     if isfield(List.Experiment{iexp},'Device')
    379         for idevice=1:length(List.Experiment{iexp}.Device)
    380             DeviceName=List.Experiment{iexp}.Device{idevice}.name;
    381             if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile')
    382                 for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile)
    383                     FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml};
    384                     if isequal(FileName,XmlName)
    385                         editxml(fullfile(CurrentPath,ExpName,DeviceName,FileName));
    386                         return
    387                     end
    388                 end
    389              elseif isfield(List.Experiment{iexp}.Device{idevice},'Record')
    390                 for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record)
    391                     RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name;
    392                     if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile')
    393                         for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile)
    394                             FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml};
    395                             if isequal(FileName,XmlName)
    396                                 editxml(fullfile(CurrentPath,ExpName,DeviceName,RecordName,FileName));
    397                                 return
    398                             end                         
    399                         end
    400                     end
    401                 end
    402             end
    403         end
    404     end
    405 end
    406 
    407 
    408 
    409 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    410 % CurrentPath/Campaign: root directory
    411 function  [Title,test_mod]=check_heading(Currentpath,Campaign,Experiment,Device,Record,xmlname,testSubCampaign)
    412 
    413  %Shema for Heading:
    414 % Campaign             
    415 % (SubCampaign)
    416 % Experiment
    417 % Device
    418 % (Record)
    419 % ImageName
    420 % DateExp
    421 %                 old: %Project: suppressed ( changed to Campaign)
    422                        %Exp: suppressed (changed to experiment)
    423                        %ImaNames: changed to ImageName
    424 if exist('Record','var') && ~isempty(Record)
    425     xmlfullname=fullfile(Currentpath,Campaign,Experiment,Device,Record,xmlname); 
    426     testrecord=1;
    427 else
    428     xmlfullname=fullfile(Currentpath,Campaign,Experiment,Device,xmlname);
    429     testrecord=0;
    430 end
    431 if ~exist('testSubCampaign','var')
    432     testSubCampaign=0;
    433 end
    434 if testSubCampaign
    435    SubCampaign=Campaign;
    436    [Currentpath,Campaign,DirExt]=fileparts(Currentpath);
    437    Campaign=[Campaign DirExt];
    438 end
    439 test_mod=0; %test for the modification of the xml file
    440 t_device=xmltree(xmlfullname);
    441 Title=get(t_device,1,'name');
    442 uid_child=children(t_device,1);
    443 Heading_old=[];
    444 uidheading=0;
    445 for ilist=1:length(uid_child)
    446     name=get(t_device,uid_child(ilist),'name');
    447     if isequal(name,'Heading')
    448         uidheading=uid_child(ilist);
    449     end
    450 end
    451 if uidheading
    452     subt=branch(t_device,uidheading);
    453     Heading_old=convert(subt);
    454 else
    455    return % do not edit xml files without element 'Heading'
    456 end
    457 if ~(isfield(Heading_old,'Campaign')&& isequal(Heading_old.Campaign,Campaign))
    458     test_mod=1;
    459 end
    460 Heading.Campaign=Campaign;
    461 if testSubCampaign
    462     if ~(isfield(Heading_old,'SubCampaign')&& isequal(Heading_old.SubCampaign,SubCampaign))
    463         test_mod=1;
    464     end
    465     Heading.SubCampaign=SubCampaign;
    466 end
    467 if ~(isfield(Heading_old,'Experiment')&& isequal(Heading_old.Experiment,Experiment))
    468     test_mod=1;
    469 end
    470 Heading.Experiment=Experiment;
    471 if ~(isfield(Heading_old,'Device')&& isequal(Heading_old.Device,Device))
    472     test_mod=1;
    473 end
    474 Heading.Device=Device;
    475 if testrecord
    476     if ~(isfield(Heading_old,'Record')&& isequal(Heading_old.Record,Record))
    477         test_mod=1;
    478     end
    479     Heading.Record=Record;
    480 end
    481 if isfield(Heading_old,'ImaNames')
    482     test_mod=1;
    483     if  ~isempty(Heading_old.ImaNames)
    484         Heading.ImageName=Heading_old.ImaNames;
    485     end
    486 end
    487 if isfield(Heading_old,'ImageName')&& ~isempty(Heading_old.ImageName)
    488     Heading.ImageName=Heading_old.ImageName;
    489 end
    490 if isfield(Heading_old,'DateExp')&& ~isempty(Heading_old.DateExp)
    491     Heading.DateExp=Heading_old.DateExp;
    492 end
    493 if test_mod && uidheading
    494      uid_child=children(t_device,uidheading);
    495      t_device=delete(t_device,uid_child);
    496     t_device=struct2xml(Heading,t_device,uidheading);
    497     backupfile=xmlfullname;
    498     testexist=2;
    499     while testexist==2
    500        backupfile=[backupfile '~'];
    501        testexist=exist(backupfile,'file');
    502     end
    503     [success,message]=copyfile(xmlfullname,backupfile);%make backup
    504     if isequal(success,1)
    505         delete(xmlfullname)
    506     else
    507         return
    508     end
    509     save(t_device,xmlfullname)
    510 end
     400% %------------------------------------------------------------------------
     401% % --- Executes on button press in CampaignDoc.
     402% function edit_xml_Callback(hObject, eventdata, handles)
     403% %------------------------------------------------------------------------
     404% CurrentPath=get(handles.SourceDir,'String');
     405% %[CurrentPath,Name,Ext]=fileparts(CurrentDir);
     406% ListExperiments=get(handles.ListExperiments,'String');
     407% Value=get(handles.ListExperiments,'Value');
     408% if ~isequal(Value,1)
     409%     ListExperiments=ListExperiments(Value);
     410% end
     411% ListDevices=get(handles.ListDevices,'String');
     412% Value=get(handles.ListDevices,'Value');
     413% if ~isequal(Value,1)
     414%     ListDevices=ListDevices(Value);
     415% end
     416% ListRecords=get(handles.ListRecords,'String');
     417% Value=get(handles.ListRecords,'Value');
     418% if ~isequal(Value,1)
     419%     ListRecords=ListRecords(Value);
     420% end
     421% [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices,ListRecords);
     422% ListXml=get(handles.ListXml,'String');
     423% Value=get(handles.ListXml,'Value');
     424% set(handles.ListXml,'Value',Value(1));
     425% if isequal(Value(1),1)
     426%     msgbox_uvmat('ERROR','an xml file needs to be selected')
     427%    return
     428% else
     429%     XmlName=ListXml{Value(1)};
     430% end
     431% for iexp=1:length(List.Experiment)
     432%     ExpName=List.Experiment{iexp}.name;
     433%     if isfield(List.Experiment{iexp},'Device')
     434%         for idevice=1:length(List.Experiment{iexp}.Device)
     435%             DeviceName=List.Experiment{iexp}.Device{idevice}.name;
     436%             if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile')
     437%                 for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile)
     438%                     FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml};
     439%                     if isequal(FileName,XmlName)
     440%                         editxml(fullfile(CurrentPath,ExpName,DeviceName,FileName));
     441%                         return
     442%                     end
     443%                 end
     444%              elseif isfield(List.Experiment{iexp}.Device{idevice},'Record')
     445%                 for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record)
     446%                     RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name;
     447%                     if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile')
     448%                         for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile)
     449%                             FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml};
     450%                             if isequal(FileName,XmlName)
     451%                                 editxml(fullfile(CurrentPath,ExpName,DeviceName,RecordName,FileName));
     452%                                 return
     453%                             end                         
     454%                         end
     455%                     end
     456%                 end
     457%             end
     458%         end
     459%     end
     460% end
     461%
     462%
     463%
     464% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     465% % CurrentPath/Campaign: root directory
     466% function  [Title,test_mod]=check_heading(Currentpath,Campaign,Experiment,Device,Record,xmlname,testSubCampaign)
     467%
     468% %Shema for Heading:
     469% % Campaign             
     470% % (SubCampaign)
     471% % Experiment
     472% % Device
     473% % (Record)
     474% % ImageName
     475% % DateExp
     476% %                 old: %Project: suppressed ( changed to Campaign)
     477%                        %Exp: suppressed (changed to experiment)
     478%                        %ImaNames: changed to ImageName
     479% if exist('Record','var') && ~isempty(Record)
     480%     xmlfullname=fullfile(Currentpath,Campaign,Experiment,Device,Record,xmlname); 
     481%     testrecord=1;
     482% else
     483%     xmlfullname=fullfile(Currentpath,Campaign,Experiment,Device,xmlname);
     484%     testrecord=0;
     485% end
     486% if ~exist('testSubCampaign','var')
     487%     testSubCampaign=0;
     488% end
     489% if testSubCampaign
     490%    SubCampaign=Campaign;
     491%    [Currentpath,Campaign,DirExt]=fileparts(Currentpath);
     492%    Campaign=[Campaign DirExt];
     493% end
     494% test_mod=0; %test for the modification of the xml file
     495% t_device=xmltree(xmlfullname);
     496% Title=get(t_device,1,'name');
     497% uid_child=children(t_device,1);
     498% Heading_old=[];
     499% uidheading=0;
     500% for ilist=1:length(uid_child)
     501%     name=get(t_device,uid_child(ilist),'name');
     502%     if isequal(name,'Heading')
     503%         uidheading=uid_child(ilist);
     504%     end
     505% end
     506% if uidheading
     507%     subt=branch(t_device,uidheading);
     508%     Heading_old=convert(subt);
     509% else
     510%    return % do not edit xml files without element 'Heading'
     511% end
     512% if ~(isfield(Heading_old,'Campaign')&& isequal(Heading_old.Campaign,Campaign))
     513%     test_mod=1;
     514% end
     515% Heading.Campaign=Campaign;
     516% if testSubCampaign
     517%     if ~(isfield(Heading_old,'SubCampaign')&& isequal(Heading_old.SubCampaign,SubCampaign))
     518%         test_mod=1;
     519%     end
     520%     Heading.SubCampaign=SubCampaign;
     521% end
     522% if ~(isfield(Heading_old,'Experiment')&& isequal(Heading_old.Experiment,Experiment))
     523%     test_mod=1;
     524% end
     525% Heading.Experiment=Experiment;
     526% if ~(isfield(Heading_old,'Device')&& isequal(Heading_old.Device,Device))
     527%     test_mod=1;
     528% end
     529% Heading.Device=Device;
     530% if testrecord
     531%     if ~(isfield(Heading_old,'Record')&& isequal(Heading_old.Record,Record))
     532%         test_mod=1;
     533%     end
     534%     Heading.Record=Record;
     535% end
     536% if isfield(Heading_old,'ImaNames')
     537%     test_mod=1;
     538%     if  ~isempty(Heading_old.ImaNames)
     539%         Heading.ImageName=Heading_old.ImaNames;
     540%     end
     541% end
     542% if isfield(Heading_old,'ImageName')&& ~isempty(Heading_old.ImageName)
     543%     Heading.ImageName=Heading_old.ImageName;
     544% end
     545% if isfield(Heading_old,'DateExp')&& ~isempty(Heading_old.DateExp)
     546%     Heading.DateExp=Heading_old.DateExp;
     547% end
     548% if test_mod && uidheading
     549%      uid_child=children(t_device,uidheading);
     550%      t_device=delete(t_device,uid_child);
     551%     t_device=struct2xml(Heading,t_device,uidheading);
     552%     backupfile=xmlfullname;
     553%     testexist=2;
     554%     while testexist==2
     555%        backupfile=[backupfile '~'];
     556%        testexist=exist(backupfile,'file');
     557%     end
     558%     [success,message]=copyfile(xmlfullname,backupfile);%make backup
     559%     if isequal(success,1)
     560%         delete(xmlfullname)
     561%     else
     562%         return
     563%     end
     564%     save(t_device,xmlfullname)
     565% end
    511566
    512567%------------------------------------------------------------------------
     
    562617%------------------------------------------------------------------------
    563618function browse_data_CloseRequestFcn(hObject, eventdata, handles)
    564    
    565619if isequal(get(handles.browse_data, 'waitstatus'), 'waiting')
    566620    % The GUI is still in UIWAIT, us UIRESUME
     621    handles.output = get(hObject,'String');
     622    guidata(hObject, handles); % Update handles structure
    567623    uiresume(handles.browse_data);
    568624else
     
    589645    uiresume(handles.browse_data);
    590646end
     647
     648
     649% --- Executes during object deletion, before destroying properties.
     650function browse_data_DeleteFcn(hObject, eventdata, handles)
  • trunk/src/mouse_down.m

    r714 r733  
    145145                output=msgbox_uvmat(['uicontrol: ' get(hchild,'Tag')],display_str,get(hchild,'String'),msg_pos);
    146146                %update the parent edit box and indicat that refresh is needed with the new input
    147                 if strcmp(get(hchild,'Style'),'edit')&&strcmp(get(hchild,'Enable'),'on')
     147                if ~strcmp(output,'Cancel') && strcmp(get(hchild,'Style'),'edit')&&strcmp(get(hchild,'Enable'),'on')
    148148                    set(hchild,'String',output)
    149149                    if strcmp(get(get(hchild,'parent'),'tag'),'InputFile')
     
    185185                        output=msgbox_uvmat(['uicontrol: ' get(hhchild,'Tag')],display_str,get(hhchild,'String'),msg_pos);
    186186                        %update the parent edit box and indicat that refresh is needed with the new input
    187                         if strcmp(get(hhchild,'Style'),'edit')&&strcmp(get(hhchild,'Enable'),'on')
     187                        if ~strcmp(output,'Cancel') && strcmp(get(hhchild,'Style'),'edit')&&strcmp(get(hhchild,'Enable'),'on')
    188188                            set(hhchild,'String',output)
    189189                            if strcmp(get(get(hhchild,'parent'),'tag'),'InputFile')
     
    229229    Left=GUI_pos(1)+GUI_pos(3)-Width; %right edge close to the right, with margin=40
    230230    Bottom=GUI_pos(2)+GUI_pos(4)-Height; %put fig at top right
    231    % hfig_text=figure('Name','text_display','MenuBar','none','NumberTitle','off','Position',[Left,Bottom,Width,Height]);
     231    hfig_text=figure('Name','text_display','MenuBar','none','NumberTitle','off','Position',[Left,Bottom,Width,Height]);
    232232    AxeData.htext_display=uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.05 0.9 0.9],'Max',2,'BackgroundColor',[1 1 1],...
    233233        'FontUnits','points','FontSize',14);
  • trunk/src/msgbox_uvmat.m

    r726 r733  
     1
    12%'msgbox_uvmat': associated with GUI msgbox_uvmat.fig to display message boxes, for error, warning or input calls
    23%
     
    111112    end
    112113    set(handles.edit_box, 'String', default_answer);
    113     if exist('Position','var')
     114    if exist('Position','var')&&numel(Position)>=2
    114115        if iscell(default_answer)
    115116            widthstring=max(max(cellfun('length',default_answer)),length(display_str));
     
    138139    set(handles.text1, 'Position', [0.15 0.3 0.85 0.7]);
    139140end
    140 % Determine the position of the dialog - centered on the screen
    141 % FigPos=get(0,'DefaultFigurePosition');
    142 % OldUnits = get(hObject, 'Units');
    143 % set(hObject, 'Units', 'pixels');
    144 % OldPos = get(hObject,'Position');
    145 % FigWidth = OldPos(3);
    146 % FigHeight = OldPos(4);
    147 % ScreenUnits=get(0,'Units');
    148 % set(0,'Units','pixels');
    149 % ScreenSize=get(0,'ScreenSize');
    150 % set(0,'Units',ScreenUnits);
    151 %
    152 % FigPos(1)=1/2*(ScreenSize(3)-FigWidth);
    153 % FigPos(2)=2/3*(ScreenSize(4)-FigHeight);
    154 % FigPos(3:4)=[FigWidth FigHeight];
    155 % set(hObject, 'Position', FigPos);
    156 % set(hObject, 'Units', OldUnits);
    157141
    158142% Show a question icon from dialogicons.mat - variables questIconData and questIconMap
     
    254238function figure1_CloseRequestFcn(hObject, eventdata, handles)
    255239%------------------------------------------------------------------------
    256 if isequal(get(handles.figure1, 'waitstatus'), 'waiting')
    257     % The GUI is still in UIWAIT, us UIRESUME
    258     uiresume(handles.figure1);
    259 else
     240% Cancel_Callback(hObject, eventdata, handles)
     241% if isequal(get(handles.figure1, 'waitstatus'), 'waiting')
     242%     % The GUI is still in UIWAIT, us UIRESUME
     243%     uiresume(handles.figure1);
     244% else
    260245    % The GUI is no longer waiting, just close it
    261     delete(handles.figure1);
    262 end
     246%     delete(handles.figure1);
     247% end
     248% handles.output = get(hObject,'String');
     249% %handles.output = 'Cancel'
     250% guidata(hObject, handles); % Update handles structure
     251% Use UIRESUME instead of delete because the OutputFcn needs
     252% to get the updated handles structure.
     253% uiresume(handles.figure1);
     254
    263255
    264256%------------------------------------------------------------------------
  • trunk/src/series.m

    r727 r733  
    260260    set(handles.num_incr_j,'String',num2str(Param.incr_j))
    261261end
    262 
     262set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color to indicate that input refresh is needed
    263263
    264264%------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.