Changeset 12 for trunk/src/dataview.m


Ignore:
Timestamp:
Feb 16, 2010, 3:19:38 PM (11 years ago)
Author:
gostiaux
Message:

The files from uvmat.2.2.beta that differed from the current version have been updated.
Now the /raid/soft/UVMAT/src should be operational

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/dataview.m

    r2 r12  
    1 %TEST 'dataview': function for scanning directories in a campaign (TEST)
     1%'dataview': function for scanning directories in a campaign
    22%------------------------------------------------------------------------
    33% function varargout = series(varargin)
     
    2222function varargout = dataview(varargin)
    2323
    24 % Last Modified by GUIDE v2.5 28-Apr-2009 00:12:36
     24% Last Modified by GUIDE v2.5 13-Jan-2010 07:28:19
    2525
    2626% Begin initialization code - DO NOT EDIT
     
    3232                   'gui_LayoutFcn',  [] , ...
    3333                   'gui_Callback',   []);
    34 if nargin & isstr(varargin{1})
     34if nargin & ischar(varargin{1})
    3535    gui_State.gui_Callback = str2func(varargin{1});
    3636end
     
    4545
    4646% --- Executes just before dataview is made visible.
    47 function dataview_OpeningFcn(hObject, eventdata, handles, varargin)
     47function dataview_OpeningFcn(hObject, eventdata, handles, RootDir, SubCampaignTst,GeometryCalib)
    4848
    4949% Choose default command line output for dataview
    50 handles.output = hObject;
     50handles.output = 'Cancel';
    5151
    5252% Update handles structure
    5353guidata(hObject, handles);
    54 
    55 %----------------------------------------------------------------
     54testCancel=1;
     55testinputstring=0;
     56icontype='quest';%default question icon (text input asked)
     57
     58% Determine the position of the dialog - centered on the screen
     59FigPos=get(0,'DefaultFigurePosition');
     60OldUnits = get(hObject, 'Units');
     61set(hObject, 'Units', 'pixels');
     62OldPos = get(hObject,'Position');
     63FigWidth = OldPos(3);
     64FigHeight = OldPos(4);
     65ScreenUnits=get(0,'Units');
     66set(0,'Units','pixels');
     67ScreenSize=get(0,'ScreenSize');
     68set(0,'Units',ScreenUnits);
     69
     70FigPos(1)=1/2*(ScreenSize(3)-FigWidth);
     71FigPos(2)=2/3*(ScreenSize(4)-FigHeight);
     72FigPos(3:4)=[FigWidth FigHeight];
     73set(hObject, 'Position', FigPos);
     74set(hObject, 'Units', OldUnits);
     75
     76% % Show a question icon from dialogicons.mat - variables questIconData and questIconMap
     77% load dialogicons.mat
     78% eval(['IconData=' icontype 'IconData;'])
     79% eval(['IconCMap=' icontype 'IconMap;'])
     80% questIconMap(256,:) = get(handles.figure1, 'Color');
     81% Img=image(IconData, 'Parent', handles.axes1);
     82% set(handles.figure1, 'Colormap', IconCMap);
     83% set(handles.axes1, ...
     84%     'Visible', 'off', ...
     85%     'YDir'   , 'reverse'       , ...
     86%     'XLim'   , get(Img,'XData'), ...
     87%     'YLim'   , get(Img,'YData')  ...
     88%     );
     89if exist('GeometryCalib','var')
     90    DataviewData.GeometryCalib=GeometryCalib;
     91    set(hObject,'UserData',DataviewData)
     92end
     93if exist('SubCampaignTst','var') && isequal(SubCampaignTst,'y')
     94   set(handles.SubCampaignTest,'Value',1);
     95end
     96if exist('RootDir','var')
     97   set(handles.RootDirectory,'String',RootDir);
     98   set(handles.clean_civ_cmx,'Visible','off')
     99   set(handles.edit_xml,'Visible','off')
     100   set(handles.HELP,'Visible','off')
     101   set(handles.OK,'Visible','on')
     102   set(handles.Cancel,'Visible','on')
     103   set(handles.figure,'WindowStyle','modal')% Make% Make the GUI modal
     104   RootDirectory_Callback(hObject, eventdata, handles)
     105   % UIWAIT makes translate_points wait for user response (see UIRESUME)
     106   uiwait(handles.figure);
     107end
     108
     109
     110
     111%------------------------------------------------------------------------
    56112% --- Outputs from this function are returned to the command line.
    57113function varargout = dataview_OutputFcn(hObject, eventdata, handles)
    58 
     114%------------------------------------------------------------------------
    59115% Get default command line output from handles structure
    60116varargout{1} = handles.output;
    61 
    62 
    63 
    64 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    65 %------------------------------------------------------
     117delete(handles.figure)
     118
     119%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     120%------------------------------------------------------------------------
    66121% --- Executes on button press in browser.
    67122function browser_Callback(hObject, eventdata, handles)
    68 %------------------------------------------------------------------------   
    69 
    70 CurrentFile='/coriolis/bigone/PROJETS';%get(handles.RootDirectory,'String');
     123%------------------------------------------------------------------------
     124CurrentFile='/raid/PROJETS';%get(handles.RootDirectory,'String');
    71125set(handles.SubCampaignTest,'Value',0)
    72126CampaignDir=uigetdir(CurrentFile,'Open the Campaign directory'); %file browser
     
    74128RootDirectory_Callback(hObject, eventdata, handles)
    75129
     130%------------------------------------------------------------------------
    76131% --- Executes on button press in open_SubCampaign.
    77132function OpenSubCampaign_Callback(hObject, eventdata, handles)
     133%------------------------------------------------------------------------
    78134CurrentFile='/coriolis/bigone/PROJETS';%get(handles.RootDirectory,'String');
    79135set(handles.SubCampaignTest,'Value',1)
     
    84140
    85141%------------------------------------------------------------------------
    86 
    87142function RootDirectory_Callback(hObject, eventdata, handles)
     143%------------------------------------------------------------------------
    88144CampaignDir=get(handles.RootDirectory,'String');
     145ExpName={''};
    89146if exist(CampaignDir,'dir')
    90147    hdir=dir(CampaignDir); %list files and dirs
     
    106163    ListExperiments_Callback(hObject, eventdata, handles)
    107164else
    108     warndlg_uvmat(['The input ' CampaignDir ' is not a directory'],'ERROR')
     165    msgbox_uvmat('ERROR',['The input ' CampaignDir ' is not a directory'])
    109166end
    110167
     
    112169% --- Executes on selection change in ListExperiments.
    113170 function ListExperiments_Callback(hObject, eventdata, handles)
     171%------------------------------------------------------------------------
    114172CurrentPath=get(handles.RootDirectory,'String');
    115173ListExperiments=get(handles.ListExperiments,'String');
     
    131189set(handles.ListXml,'String',[{'*'};ListXml'])
    132190if testList
    133     hh=get(handles.ListExperiments,'parent');
    134     set(hh,'UserData',List)
     191    DataviewData=get(handles.figure,'UserData');
     192    DataView.List=List;
     193    set(handles.figure,'UserData',DataviewData)
    135194end
    136195set(handles.CampaignDoc,'Visible','on')
    137 set(handles.edit_xml,'Visible','on')
     196% set(handles.edit_xml,'Visible','on')
    138197
    139198%------------------------------------------------------------------------
     
    184243set(handles.ListExperiments,'Value',1)
    185244ListExperiments_Callback(hObject, eventdata, handles)%update the overview of the experiment directories
    186 hh=get(handles.CampaignDoc,'parent');
    187 List=get(hh,'UserData');
     245DataviewData=get(handles.figure,'UserData');
     246List=DataviewData.List;
    188247Currentpath=get(handles.RootDirectory,'String');
    189248[Currentpath,Campaign,DirExt]=fileparts(Currentpath);
     
    422481end
    423482
     483%------------------------------------------------------------------------
    424484% --- Executes on button press in HELP.
    425485function HELP_Callback(hObject, eventdata, handles)
     
    427487pathelp=fileparts(path_to_uvmat);
    428488helpfile=fullfile(pathelp,'UVMAT_DOC','uvmat_doc.html');
    429 if isempty(dir(helpfile)), errordlg('Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC')
     489if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC')
    430490else
    431491web([helpfile '#dataview'])   
    432492end
    433493
    434 
    435 
    436 
    437 % --- Executes on button press in SubCampaignTest.
    438 function SubCampaignTest_Callback(hObject, eventdata, handles)
    439494
    440495
     
    456511set(handles.ListExperiments,'Value',1)
    457512ListExperiments_Callback(hObject, eventdata, handles)%update the overview of the experiment directories
    458 hh=get(handles.CampaignDoc,'parent');
    459 List=get(hh,'UserData');
     513DataviewData=get(handles.figure,'UserData');
     514List=DataviewData.List;
    460515Currentpath=get(handles.RootDirectory,'String');
    461516[Currentpath,Campaign,DirExt]=fileparts(Currentpath);
     
    510565
    511566
    512 
    513 
     567% --- Executes on button press in OK.
     568function OK_Callback(hObject, eventdata, handles)
     569%------------------------------------------------------------------------
     570CurrentPath=get(handles.RootDirectory,'String');
     571ListExperiments=get(handles.ListExperiments,'String');
     572IndicesExp=get(handles.ListExperiments,'Value');
     573if ~isequal(IndicesExp,1)
     574    ListExperiments=ListExperiments(IndicesExp);
     575end
     576ListDevices=get(handles.ListDevices,'String');
     577Value=get(handles.ListDevices,'Value');
     578if isequal(Value,1)
     579    msgbox_uvmat('ERROR','manually select in the GUI dataview the device being calibrated')
     580    return
     581else
     582    ListDevices=ListDevices(Value);
     583end
     584ListRecords=get(handles.ListRecords,'String');
     585Value=get(handles.ListRecords,'Value');
     586if ~isequal(Value,1)
     587    ListRecords=ListRecords(Value);
     588end
     589[ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices,ListRecords);
     590ListXml=get(handles.ListXml,'String');
     591Value=get(handles.ListXml,'Value');
     592if isequal(Value,1)
     593    msgbox_uvmat('ERROR','you need to select in the GUI dataview the xml files to edit')
     594    return
     595else
     596    ListXml=ListXml(Value);
     597end
     598
     599%update all the selected xml files
     600DataviewData=get(handles.figure,'UserData');
     601% answer=msgbox_uvmat('INPUT_Y-N',[num2str(length(Value)) ' xml files for device ' ListDevices{1} ' will be refreshed with ' ...
     602%     DataviewData.GeometryCalib.CalibrationType ' calibration data'])
     603% if ~isequal(answer,'Yes')
     604%     return
     605% end
     606%List.Experiment{1}.Device{1}
     607%List.Experiment{2}.Device{1}
     608for iexp=1:length(List.Experiment)
     609    ExpName=List.Experiment{iexp}.name;
     610    set(handles.ListExperiments,'Value',IndicesExp(iexp));
     611    if isfield(List.Experiment{iexp},'Device')
     612        for idevice=1:length(List.Experiment{iexp}.Device)
     613            DeviceName=List.Experiment{iexp}.Device{idevice}.name;     
     614            if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile')
     615                for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile)
     616                    FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml};
     617                    for ilistxml=1:length(ListXml)
     618                        if isequal(FileName,ListXml{ilistxml})
     619                            set(handles.ListXml,'Value',Value(ilistxml))
     620                            drawnow
     621                            xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,FileName);
     622                            update_imadoc(DataviewData.GeometryCalib,xmlfullname)
     623                            display([xmlfullname ' updated'])
     624                            break
     625                        end
     626                    end
     627                end
     628             elseif isfield(List.Experiment{iexp}.Device{idevice},'Record')
     629                for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record)
     630                    RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name;
     631                    if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile')
     632                        for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile)
     633                            FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml};
     634                            for ilistxml=1:length(ListXml)
     635                                if isequal(FileName,ListXml{ilistxml})
     636                                    set(handles.ListXml,'Value',Value(ilistxml))
     637                                    drawnow
     638                                    xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,RecordName,FileName);
     639                                    update_imadoc(DataviewData.GeometryCalib,xmlfullname)
     640                                    display([xmlfullname ' updated'])
     641                                    break
     642                                end
     643                            end
     644                        end
     645                    end
     646                end
     647            end
     648        end
     649    end
     650end
     651set(handles.ListXml,'Value',Value)   
     652%     
     653%     
     654%     
     655%     
     656%     
     657%     
     658%     
     659% CurrentPath=get(handles.RootDirectory,'String');%= get(hObject,'String');
     660% ListExperiments=get(handles.ListExperiments,'String');
     661% Value=get(handles.ListExperiments,'Value');
     662% if ~isequal(Value,1)
     663%     ListExperiments=ListExperiments(Value);
     664% end
     665% ListDevices=get(handles.ListDevices,'String');
     666% Value=get(handles.ListDevices,'Value');
     667% if isequal(Value,1)
     668%     msgbox_uvmat('ERROR','manually select in the GUI dataview the device being calibrated')
     669%     return
     670% else
     671%     ListDevices=ListDevices(Value);
     672% end
     673% ListRecords=get(handles.ListRecords,'String');
     674% Value=get(handles.ListRecords,'Value');
     675% if ~isequal(Value,1)
     676%     ListRecords=ListRecords(Value);
     677% end
     678% [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices,ListRecords);
     679% ListXml=get(handles.ListXml,'String');
     680% Value=get(handles.ListXml,'Value');
     681% if isequal(Value,1)
     682%     msgbox_uvmat('ERROR','you need to select in the GUI dataview the xml files to edit')
     683%     return
     684% else
     685%     ListXml=ListXml(Value);
     686% end
     687% handles.output.CurrentPath=CurrentPath;
     688% handles.output.ListExperiments=ListExperiments;
     689% handles.output.ListDevices=ListDevices;
     690% handles.output.ListRecords=ListRecords;
     691% handles.output.ListXml=ListXml;
     692% handles.output.List=List;
     693handles.output ='OK, Calibration replicated';
     694guidata(hObject, handles);% Update handles structure
     695uiresume(handles.figure);
     696
     697% --- Executes on button press in Cancel.
     698function Cancel_Callback(hObject, eventdata, handles)
     699handles.output = get(hObject,'String');
     700guidata(hObject, handles); % Update handles structure
     701% Use UIRESUME instead of delete because the OutputFcn needs
     702uiresume(handles.figure);
     703
     704% --- Executes when user attempts to close figure.
     705function figure_CloseRequestFcn(hObject, eventdata, handles)
     706if isequal(get(handles.figure, 'waitstatus'), 'waiting')
     707    % The GUI is still in UIWAIT, us UIRESUME
     708    uiresume(handles.figure);
     709else
     710    % The GUI is no longer waiting, just close it
     711    delete(handles.figure);
     712end
     713
     714% --- Executes on key press over figure1 with no controls selected.
     715function figure_KeyPressFcn(hObject, eventdata, handles)
     716% Check for "enter" or "escape"
     717if isequal(get(hObject,'CurrentKey'),'escape')
     718    % User said no by hitting escape
     719    handles.output = 'Cancel';
     720   
     721    % Update handles structure
     722    guidata(hObject, handles);
     723   
     724    uiresume(handles.figure);
     725end
     726if isequal(get(hObject,'CurrentKey'),'return')
     727    uiresume(handles.figure);
     728end
Note: See TracChangeset for help on using the changeset viewer.