Ignore:
Timestamp:
Nov 29, 2018, 5:44:44 PM (5 years ago)
Author:
sommeria
Message:

various bugs repaired

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/browse_data.m

    r1039 r1059  
    2424function varargout = browse_data(varargin)
    2525
    26 % Last Modified by GUIDE v2.5 24-Jan-2015 16:55:04
     26% Last Modified by GUIDE v2.5 08-Sep-2018 19:03:40
    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, DataSeries,EnableMirror,MultiDevices)
     49function browse_data_OpeningFcn(hObject, eventdata, handles, InputDir,EnableMirror,MultiDevices)
    5050%------------------------------------------------------------------------
    5151
    5252%% Choose default command line output for browse_data
    53 handles.output = 'Cancel';
     53handles.output =hObject;% 'Cancel';
    5454
    5555%% Update handles structure
    5656guidata(hObject, handles);
    5757set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display)
     58set(hObject,'DeleteFcn',{@closefcn})%
    5859
    5960%% Determine the position of the dialog - centered on the screen
     
    8788
    8889%% initialize the GUI
    89 if isempty(regexp(DataSeries,'^http:'))&& ~(exist('DataSeries','var') && ischar(DataSeries) && exist(DataSeries,'dir'))
    90     DataSeries=pwd;% current dir is the starting data series by default
    91 end
    92 [Experiment,DataSeries,Ext]=fileparts(DataSeries);
    93 DataSeries=[DataSeries Ext];
    94 [Campaign,Experiment,Ext]=fileparts(Experiment);
    95 Experiment=[Experiment Ext];
     90if isempty(regexp(InputDir,'^http:'))&& ~(exist('InputDir','var') && ischar(InputDir) && exist(InputDir,'dir'))
     91    InputDir=pwd;% current dir is the starting data series by default
     92end
     93% [Experiment,DataSeries,Ext]=fileparts(DataSeries);
     94% DataSeries=[DataSeries Ext];
     95% [Campaign,Experiment,Ext]=fileparts(Experiment);
     96% Experiment=[Experiment Ext];
     97[ExpWithPath,DataSeries]=fileparts(InputDir);
     98[Campaign,Experiment,Ext]=fileparts(ExpWithPath);
    9699[tild,CampaignName]=fileparts(Campaign);
    97100RootXml=fullfile(Campaign,[CampaignName '.xml']);
     
    111114    set(handles.CreateMirror,'String','create_mirror')
    112115end
    113 errormsg=scan_campaign(handles,Campaign,Experiment,DataSeries);
     116errormsg=scan_campaign(handles,Campaign,Experiment,ExpWithPath);
    114117if ~isempty(errormsg)
    115118    msgbox_uvmat('ERROR',errormsg)
    116119    return
    117120end
    118 set(handles.OK,'Visible','on')
    119 set(handles.Cancel,'Visible','on')
    120 
    121 set(handles.browse_data,'WindowStyle','modal')% Make the GUI modal
     121% set(handles.OK,'Visible','on')
     122% set(handles.Cancel,'Visible','on')
     123
     124%set(handles.browse_data,'WindowStyle','modal')% Make the GUI
     125%modal%%%%%%%%%%%%%%%%%%%%%%%
    122126set(hObject,'Visible','on')
    123127drawnow
    124 % UIWAIT makes GUI wait for user response (see UIRESUME)
    125 uiwait(handles.browse_data);
     128% UIWAIT makes GUI wait for user response (see UIRESUME)%%%%%%%%%%%%%%%%TO
     129% CHECK
     130%uiwait(handles.browse_data);
    126131
    127132
     
    133138% Get default command line output from handles structure
    134139varargout{1} = handles.output;
    135 delete(handles.browse_data)
     140%%%%%%%%%%%%%%%%%%delete(handles.browse_data)
    136141
    137142%------------------------------------------------------------------------
     
    213218    ListStruct=dir_uvmat(Campaign); %list files and dirs
    214219    if numel(ListStruct)>1000% A campaign folder must contain maily a list of 'experiment' sub-folders
    215         errormsg=[Campaign ' contains too many items (>1000) to be a Campaign folder'];
     220        errormsg=[Campaign ' contains too many items (>1000) to be a Project folder'];
    216221        return
    217222    end
     
    224229    ListFiles=sort((ListFiles(check_keep))');
    225230    index=find(strcmp(['+/' Experiment],ListFiles));
    226     if isempty(index), index=0; end
    227     set(handles.ListExperiments,'String',[{'*'};ListFiles])
    228     set(handles.ListExperiments,'Value',index+1)% initialise the menu selection with the folder defined by the input
     231    if isempty(index), index=1; end
     232    set(handles.ListExperiments,'String',ListFiles)
     233    set(handles.ListExperiments,'Value',index)% initialise the menu selection with the folder defined by the input
    229234    ListExperiments_Callback([],[], handles)
    230235    ListDevices=get(handles.ListDevices,'String');
     
    252257ListExperiments=get(handles.ListExperiments,'String');
    253258list_val=get(handles.ListExperiments,'Value');
    254 if isequal(list_val(1),1)
    255     ListExperiments=ListExperiments(2:end); %choose all experiments if the first line '*' is selected
    256     set(handles.ListExperiments,'Value',1)
    257 else
     259% if isequal(list_val(1),1)
     260%     ListExperiments=ListExperiments(2:end); %choose all experiments if the first line '*' is selected
     261%     set(handles.ListExperiments,'Value',1)
     262% else
    258263    ListExperiments=ListExperiments(list_val);%choose selected experiments
    259 end
     264% end
    260265list_dataseries(handles,ListExperiments,MirrorPath)
    261266
     
    283288                else %update the list of dataSeries
    284289                    [tild,msg]=fileattrib(mirror);
    285                     msg.Name=regexprep(msg.Name,'^/.','/');%remove the dot in /. at the beginning of the name
    286                     if ~strcmp(msg.Name,mirror)% if it is a link
    287                         ListFiles{ilist}=['~' ListFiles{ilist}];%mark link by '@' in the list
    288                     end
     290%                     msg.Name=regexprep(msg.Name,'^/.','/');%remove the dot in /. at the beginning of the name
     291%                     if ~strcmp(msg.Name,mirror)% if it is a link
     292%                         ListFiles{ilist}=['~' ListFiles{ilist}];%mark link by '@' in the list
     293%                     end
    289294                    if check_dir(ilist)
    290295                        ListFiles{ilist}=['+/' ListFiles{ilist}];%mark dir by '+' in the list
     
    298303    end
    299304end
     305set(handles.ListDevices,'Value',1)
    300306set(handles.ListDevices,'String',sort(ListDevices))
    301307
     
    438444save(t,outputfile)
    439445
    440 % %------------------------------------------------------------------------
    441 % % --- Executes on button press in CampaignDoc.
    442 % function edit_xml_Callback(hObject, eventdata, handles)
    443 % %------------------------------------------------------------------------
    444 % CurrentPath=get(handles.SourceDir,'String');
    445 % %[CurrentPath,Name,Ext]=fileparts(CurrentDir);
    446 % ListExperiments=get(handles.ListExperiments,'String');
    447 % Value=get(handles.ListExperiments,'Value');
    448 % if ~isequal(Value,1)
    449 %     ListExperiments=ListExperiments(Value);
    450 % end
    451 % ListDevices=get(handles.ListDevices,'String');
    452 % Value=get(handles.ListDevices,'Value');
    453 % if ~isequal(Value,1)
    454 %     ListDevices=ListDevices(Value);
    455 % end
    456 % ListRecords=get(handles.ListRecords,'String');
    457 % Value=get(handles.ListRecords,'Value');
    458 % if ~isequal(Value,1)
    459 %     ListRecords=ListRecords(Value);
    460 % end
    461 % [ListDevices,ListRecords,ListXml,List]=dir_scan(CurrentPath,ListExperiments,ListDevices,ListRecords);
    462 % ListXml=get(handles.ListXml,'String');
    463 % Value=get(handles.ListXml,'Value');
    464 % set(handles.ListXml,'Value',Value(1));
    465 % if isequal(Value(1),1)
    466 %     msgbox_uvmat('ERROR','an xml file needs to be selected')
    467 %    return
    468 % else
    469 %     XmlName=ListXml{Value(1)};
    470 % end
    471 % for iexp=1:length(List.Experiment)
    472 %     ExpName=List.Experiment{iexp}.name;
    473 %     if isfield(List.Experiment{iexp},'Device')
    474 %         for idevice=1:length(List.Experiment{iexp}.Device)
    475 %             DeviceName=List.Experiment{iexp}.Device{idevice}.name;
    476 %             if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile')
    477 %                 for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile)
    478 %                     FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml};
    479 %                     if isequal(FileName,XmlName)
    480 %                         editxml(fullfile(CurrentPath,ExpName,DeviceName,FileName));
    481 %                         return
    482 %                     end
    483 %                 end
    484 %              elseif isfield(List.Experiment{iexp}.Device{idevice},'Record')
    485 %                 for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record)
    486 %                     RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name;
    487 %                     if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile')
    488 %                         for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile)
    489 %                             FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml};
    490 %                             if isequal(FileName,XmlName)
    491 %                                 editxml(fullfile(CurrentPath,ExpName,DeviceName,RecordName,FileName));
    492 %                                 return
    493 %                             end                         
    494 %                         end
    495 %                     end
    496 %                 end
    497 %             end
    498 %         end
    499 %     end
    500 % end
    501 %
    502 %
    503 %
    504 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    505 % % CurrentPath/Campaign: root directory
    506 % function  [Title,test_mod]=check_heading(Currentpath,Campaign,Experiment,Device,Record,xmlname,testSubCampaign)
    507 %
    508 %  %Shema for Heading:
    509 % %  Campaign             
    510 % %  (SubCampaign)
    511 % % Experiment
    512 % %  Device
    513 % %  (Record)
    514 % %  ImageName
    515 % %  DateExp
    516 % %                 old: %Project: suppressed ( changed to Campaign)
    517 %                        %Exp: suppressed (changed to experiment)
    518 %                        %ImaNames: changed to ImageName
    519 % if exist('Record','var') && ~isempty(Record)
    520 %     xmlfullname=fullfile(Currentpath,Campaign,Experiment,Device,Record,xmlname); 
    521 %     testrecord=1;
    522 % else
    523 %     xmlfullname=fullfile(Currentpath,Campaign,Experiment,Device,xmlname);
    524 %     testrecord=0;
    525 % end
    526 % if ~exist('testSubCampaign','var')
    527 %     testSubCampaign=0;
    528 % end
    529 % if testSubCampaign
    530 %    SubCampaign=Campaign;
    531 %    [Currentpath,Campaign,DirExt]=fileparts(Currentpath);
    532 %    Campaign=[Campaign DirExt];
    533 % end
    534 % test_mod=0; %test for the modification of the xml file
    535 % t_device=xmltree(xmlfullname);
    536 % Title=get(t_device,1,'name');
    537 % uid_child=children(t_device,1);
    538 % Heading_old=[];
    539 % uidheading=0;
    540 % for ilist=1:length(uid_child)
    541 %     name=get(t_device,uid_child(ilist),'name');
    542 %     if isequal(name,'Heading')
    543 %         uidheading=uid_child(ilist);
    544 %     end
    545 % end
    546 % if uidheading
    547 %     subt=branch(t_device,uidheading);
    548 %     Heading_old=convert(subt);
    549 % else
    550 %    return % do not edit xml files without element 'Heading'
    551 % end
    552 % if ~(isfield(Heading_old,'Campaign')&& isequal(Heading_old.Campaign,Campaign))
    553 %     test_mod=1;
    554 % end
    555 % Heading.Campaign=Campaign;
    556 % if testSubCampaign
    557 %     if ~(isfield(Heading_old,'SubCampaign')&& isequal(Heading_old.SubCampaign,SubCampaign))
    558 %         test_mod=1;
    559 %     end
    560 %     Heading.SubCampaign=SubCampaign;
    561 % end
    562 % if ~(isfield(Heading_old,'Experiment')&& isequal(Heading_old.Experiment,Experiment))
    563 %     test_mod=1;
    564 % end
    565 % Heading.Experiment=Experiment;
    566 % if ~(isfield(Heading_old,'Device')&& isequal(Heading_old.Device,Device))
    567 %     test_mod=1;
    568 % end
    569 % Heading.Device=Device;
    570 % if testrecord
    571 %     if ~(isfield(Heading_old,'Record')&& isequal(Heading_old.Record,Record))
    572 %         test_mod=1;
    573 %     end
    574 %     Heading.Record=Record;
    575 % end
    576 % if isfield(Heading_old,'ImaNames')
    577 %     test_mod=1;
    578 %     if  ~isempty(Heading_old.ImaNames)
    579 %         Heading.ImageName=Heading_old.ImaNames;
    580 %     end
    581 % end
    582 % if isfield(Heading_old,'ImageName')&& ~isempty(Heading_old.ImageName)
    583 %     Heading.ImageName=Heading_old.ImageName;
    584 % end
    585 % if isfield(Heading_old,'DateExp')&& ~isempty(Heading_old.DateExp)
    586 %     Heading.DateExp=Heading_old.DateExp;
    587 % end
    588 % if test_mod && uidheading
    589 %      uid_child=children(t_device,uidheading);
    590 %      t_device=delete(t_device,uid_child);
    591 %     t_device=struct2xml(Heading,t_device,uidheading);
    592 %     backupfile=xmlfullname;
    593 %     testexist=2;
    594 %     while testexist==2
    595 %        backupfile=[backupfile '~'];
    596 %        testexist=exist(backupfile,'file');
    597 %     end
    598 %     [success,message]=copyfile(xmlfullname,backupfile);%make backup
    599 %     if isequal(success,1)
    600 %         delete(xmlfullname)
    601 %     else
    602 %         return
    603 %     end
    604 %     save(t_device,xmlfullname)
    605 % end
     446
    606447
    607448%------------------------------------------------------------------------
     
    648489% --- Executes on button press in Cancel.
    649490%------------------------------------------------------------------------
    650 function Cancel_Callback(hObject, eventdata, handles)
    651    
    652 handles.output = get(hObject,'String');
    653 guidata(hObject, handles); % Update handles structure
    654 % Use UIRESUME instead of delete because the OutputFcn needs
    655 uiresume(handles.browse_data);
     491% function Cancel_Callback(hObject, eventdata, handles)
     492% % hseries=findobj(allchild(0),'Tag','series');
     493% % if ~isempty(hseries)
     494% %     hhh=guidata(hseries);
     495% %     set(hhh.Replicate,'Value',0)
     496% % end
     497% % delete(get(hObject,'parent'))
     498
     499% handles.output = get(hObject,'String');
     500% guidata(hObject, handles); % Update handles structure
     501% % Use UIRESUME instead of delete because the OutputFcn needs
     502% uiresume(handles.browse_data);
     503
     504%------------------------------------------------------------------------
     505% --- executes when user attempts to close geometry_calib.
     506function browse_data_CloseRequestFcn(hObject, eventdata, handles)
    656507
    657508%------------------------------------------------------------------------
    658509% --- Executes when user attempts to close browse_data.
    659510%------------------------------------------------------------------------
    660 function browse_data_CloseRequestFcn(hObject, eventdata, handles)
    661 if isequal(get(handles.browse_data, 'waitstatus'), 'waiting')
    662     % The GUI is still in UIWAIT, us UIRESUME
    663     handles.output = get(hObject,'String');
    664     guidata(hObject, handles); % Update handles structure
    665     uiresume(handles.browse_data);
    666 else
    667     % The GUI is no longer waiting, just close it
    668     delete(handles.browse_data);
     511function closefcn(gcbo, eventdata)
     512% if isequal(get(handles.browse_data, 'waitstatus'), 'waiting')
     513%     % The GUI is still in UIWAIT, us UIRESUME
     514%     handles.output = get(hObject,'String');
     515%     guidata(hObject, handles); % Update handles structure
     516%     uiresume(handles.browse_data);
     517% else
     518%     % The GUI is no longer waiting, just close it
     519%     delete(handles.browse_data);
     520% end
     521hseries=findobj(allchild(0),'Tag','series');
     522if ~isempty(hseries)
     523    hreplicate=findobj(hseries,'Tag','Replicate');
     524    set(hreplicate,'Value',0)
     525end
     526hcalib=findobj(allchild(0),'Tag','geometry_calib');
     527if ~isempty(hcalib)
     528    hreplicate=findobj(hcalib,'Tag','Replicate');
     529    set(hreplicate,'Value',0)
    669530end
    670531
     
    689550
    690551
    691 % --- Executes on button press in Browse.
    692 function Browse_Callback(hObject, eventdata, handles)
     552% --- Executes on button press in Up.
     553function Up_Callback(hObject, eventdata, handles)
     554SourceDir=get(handles.SourceDir,'String');
     555% Device=ListDevices{get(handles.ListDevices,'Value')};
     556% DataSeries=uigetfile_uvmat('open a data folder',Device,'uigetdir');
     557% uiresume(handles.browse_data);
     558browse_data(SourceDir)
     559
     560
     561% --- Executes on button press in Down.
     562function Down_Callback(hObject, eventdata, handles)
     563SourceDir=get(handles.SourceDir,'String');
     564ListExperiments=get(handles.ListExperiments,'String');
     565list_val=get(handles.ListExperiments,'Value');
     566SourceFolder=regexprep(ListExperiments{list_val(1)},'+','');
     567set(handles.SourceDir,'String',fullfile(SourceDir,SourceFolder))
    693568ListDevices=get(handles.ListDevices,'String');
    694 Device=ListDevices{get(handles.ListDevices,'Value')};
    695 DataSeries=uigetfile_uvmat('open a data folder',Device,'uigetdir');
    696 uiresume(handles.browse_data);
    697 browse_data(DataSeries)
     569ValueDevice=get(handles.ListDevices,'Value');
     570set(handles.ListExperiments,'String',ListDevices)
     571set(handles.ListExperiments,'Value',ValueDevice)
     572ListExperiments_Callback(hObject, [], handles)
     573% Device=regexprep(ListDevices{get(handles.ListDevices,'Value')},'+','');
     574% Device=regexprep(Device,'~','');
     575% PathDevice=fullfile(SourceDir,SourceFolder,Device);
     576% DirDevice=dir(PathDevice);
     577% NewDevice=DirDevice(end).name;
     578% % uiresume(handles.browse_data);
     579% browse_data(fullfile(PathDevice,NewDevice))
Note: See TracChangeset for help on using the changeset viewer.