Changeset 12 for trunk/src/dataview.m
- Timestamp:
- Feb 16, 2010, 3:19:38 PM (15 years ago)
- 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 2 2 %------------------------------------------------------------------------ 3 3 % function varargout = series(varargin) … … 22 22 function varargout = dataview(varargin) 23 23 24 % Last Modified by GUIDE v2.5 28-Apr-2009 00:12:3624 % Last Modified by GUIDE v2.5 13-Jan-2010 07:28:19 25 25 26 26 % Begin initialization code - DO NOT EDIT … … 32 32 'gui_LayoutFcn', [] , ... 33 33 'gui_Callback', []); 34 if nargin & is str(varargin{1})34 if nargin & ischar(varargin{1}) 35 35 gui_State.gui_Callback = str2func(varargin{1}); 36 36 end … … 45 45 46 46 % --- Executes just before dataview is made visible. 47 function dataview_OpeningFcn(hObject, eventdata, handles, varargin)47 function dataview_OpeningFcn(hObject, eventdata, handles, RootDir, SubCampaignTst,GeometryCalib) 48 48 49 49 % Choose default command line output for dataview 50 handles.output = hObject;50 handles.output = 'Cancel'; 51 51 52 52 % Update handles structure 53 53 guidata(hObject, handles); 54 55 %---------------------------------------------------------------- 54 testCancel=1; 55 testinputstring=0; 56 icontype='quest';%default question icon (text input asked) 57 58 % Determine the position of the dialog - centered on the screen 59 FigPos=get(0,'DefaultFigurePosition'); 60 OldUnits = get(hObject, 'Units'); 61 set(hObject, 'Units', 'pixels'); 62 OldPos = get(hObject,'Position'); 63 FigWidth = OldPos(3); 64 FigHeight = OldPos(4); 65 ScreenUnits=get(0,'Units'); 66 set(0,'Units','pixels'); 67 ScreenSize=get(0,'ScreenSize'); 68 set(0,'Units',ScreenUnits); 69 70 FigPos(1)=1/2*(ScreenSize(3)-FigWidth); 71 FigPos(2)=2/3*(ScreenSize(4)-FigHeight); 72 FigPos(3:4)=[FigWidth FigHeight]; 73 set(hObject, 'Position', FigPos); 74 set(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 % ); 89 if exist('GeometryCalib','var') 90 DataviewData.GeometryCalib=GeometryCalib; 91 set(hObject,'UserData',DataviewData) 92 end 93 if exist('SubCampaignTst','var') && isequal(SubCampaignTst,'y') 94 set(handles.SubCampaignTest,'Value',1); 95 end 96 if 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); 107 end 108 109 110 111 %------------------------------------------------------------------------ 56 112 % --- Outputs from this function are returned to the command line. 57 113 function varargout = dataview_OutputFcn(hObject, eventdata, handles) 58 114 %------------------------------------------------------------------------ 59 115 % Get default command line output from handles structure 60 116 varargout{1} = handles.output; 61 62 63 64 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 65 %------------------------------------------------------ 117 delete(handles.figure) 118 119 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 120 %------------------------------------------------------------------------ 66 121 % --- Executes on button press in browser. 67 122 function browser_Callback(hObject, eventdata, handles) 68 %------------------------------------------------------------------------ 69 70 CurrentFile='/coriolis/bigone/PROJETS';%get(handles.RootDirectory,'String'); 123 %------------------------------------------------------------------------ 124 CurrentFile='/raid/PROJETS';%get(handles.RootDirectory,'String'); 71 125 set(handles.SubCampaignTest,'Value',0) 72 126 CampaignDir=uigetdir(CurrentFile,'Open the Campaign directory'); %file browser … … 74 128 RootDirectory_Callback(hObject, eventdata, handles) 75 129 130 %------------------------------------------------------------------------ 76 131 % --- Executes on button press in open_SubCampaign. 77 132 function OpenSubCampaign_Callback(hObject, eventdata, handles) 133 %------------------------------------------------------------------------ 78 134 CurrentFile='/coriolis/bigone/PROJETS';%get(handles.RootDirectory,'String'); 79 135 set(handles.SubCampaignTest,'Value',1) … … 84 140 85 141 %------------------------------------------------------------------------ 86 87 142 function RootDirectory_Callback(hObject, eventdata, handles) 143 %------------------------------------------------------------------------ 88 144 CampaignDir=get(handles.RootDirectory,'String'); 145 ExpName={''}; 89 146 if exist(CampaignDir,'dir') 90 147 hdir=dir(CampaignDir); %list files and dirs … … 106 163 ListExperiments_Callback(hObject, eventdata, handles) 107 164 else 108 warndlg_uvmat(['The input ' CampaignDir ' is not a directory'],'ERROR')165 msgbox_uvmat('ERROR',['The input ' CampaignDir ' is not a directory']) 109 166 end 110 167 … … 112 169 % --- Executes on selection change in ListExperiments. 113 170 function ListExperiments_Callback(hObject, eventdata, handles) 171 %------------------------------------------------------------------------ 114 172 CurrentPath=get(handles.RootDirectory,'String'); 115 173 ListExperiments=get(handles.ListExperiments,'String'); … … 131 189 set(handles.ListXml,'String',[{'*'};ListXml']) 132 190 if 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) 135 194 end 136 195 set(handles.CampaignDoc,'Visible','on') 137 set(handles.edit_xml,'Visible','on')196 % set(handles.edit_xml,'Visible','on') 138 197 139 198 %------------------------------------------------------------------------ … … 184 243 set(handles.ListExperiments,'Value',1) 185 244 ListExperiments_Callback(hObject, eventdata, handles)%update the overview of the experiment directories 186 hh=get(handles.CampaignDoc,'parent');187 List= get(hh,'UserData');245 DataviewData=get(handles.figure,'UserData'); 246 List=DataviewData.List; 188 247 Currentpath=get(handles.RootDirectory,'String'); 189 248 [Currentpath,Campaign,DirExt]=fileparts(Currentpath); … … 422 481 end 423 482 483 %------------------------------------------------------------------------ 424 484 % --- Executes on button press in HELP. 425 485 function HELP_Callback(hObject, eventdata, handles) … … 427 487 pathelp=fileparts(path_to_uvmat); 428 488 helpfile=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')489 if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC') 430 490 else 431 491 web([helpfile '#dataview']) 432 492 end 433 493 434 435 436 437 % --- Executes on button press in SubCampaignTest.438 function SubCampaignTest_Callback(hObject, eventdata, handles)439 494 440 495 … … 456 511 set(handles.ListExperiments,'Value',1) 457 512 ListExperiments_Callback(hObject, eventdata, handles)%update the overview of the experiment directories 458 hh=get(handles.CampaignDoc,'parent');459 List= get(hh,'UserData');513 DataviewData=get(handles.figure,'UserData'); 514 List=DataviewData.List; 460 515 Currentpath=get(handles.RootDirectory,'String'); 461 516 [Currentpath,Campaign,DirExt]=fileparts(Currentpath); … … 510 565 511 566 512 513 567 % --- Executes on button press in OK. 568 function OK_Callback(hObject, eventdata, handles) 569 %------------------------------------------------------------------------ 570 CurrentPath=get(handles.RootDirectory,'String'); 571 ListExperiments=get(handles.ListExperiments,'String'); 572 IndicesExp=get(handles.ListExperiments,'Value'); 573 if ~isequal(IndicesExp,1) 574 ListExperiments=ListExperiments(IndicesExp); 575 end 576 ListDevices=get(handles.ListDevices,'String'); 577 Value=get(handles.ListDevices,'Value'); 578 if isequal(Value,1) 579 msgbox_uvmat('ERROR','manually select in the GUI dataview the device being calibrated') 580 return 581 else 582 ListDevices=ListDevices(Value); 583 end 584 ListRecords=get(handles.ListRecords,'String'); 585 Value=get(handles.ListRecords,'Value'); 586 if ~isequal(Value,1) 587 ListRecords=ListRecords(Value); 588 end 589 [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices,ListRecords); 590 ListXml=get(handles.ListXml,'String'); 591 Value=get(handles.ListXml,'Value'); 592 if isequal(Value,1) 593 msgbox_uvmat('ERROR','you need to select in the GUI dataview the xml files to edit') 594 return 595 else 596 ListXml=ListXml(Value); 597 end 598 599 %update all the selected xml files 600 DataviewData=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} 608 for 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 650 end 651 set(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; 693 handles.output ='OK, Calibration replicated'; 694 guidata(hObject, handles);% Update handles structure 695 uiresume(handles.figure); 696 697 % --- Executes on button press in Cancel. 698 function Cancel_Callback(hObject, eventdata, handles) 699 handles.output = get(hObject,'String'); 700 guidata(hObject, handles); % Update handles structure 701 % Use UIRESUME instead of delete because the OutputFcn needs 702 uiresume(handles.figure); 703 704 % --- Executes when user attempts to close figure. 705 function figure_CloseRequestFcn(hObject, eventdata, handles) 706 if isequal(get(handles.figure, 'waitstatus'), 'waiting') 707 % The GUI is still in UIWAIT, us UIRESUME 708 uiresume(handles.figure); 709 else 710 % The GUI is no longer waiting, just close it 711 delete(handles.figure); 712 end 713 714 % --- Executes on key press over figure1 with no controls selected. 715 function figure_KeyPressFcn(hObject, eventdata, handles) 716 % Check for "enter" or "escape" 717 if 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); 725 end 726 if isequal(get(hObject,'CurrentKey'),'return') 727 uiresume(handles.figure); 728 end
Note: See TracChangeset
for help on using the changeset viewer.