Changeset 60


Ignore:
Timestamp:
Mar 23, 2010, 2:52:49 PM (15 years ago)
Author:
sommeria
Message:

-plot projections on a new specific GUI view_field, to avoid the multiplication of active figures
-introduce a ruler in uvmat (in menu/Tools), to measure distances and angles
-insert automatic detection of points for geometric calibration: tool 'detect_grid'. Four points, deliminating the grid to determine, must be marked with the mouse, as well as the physical grid. Then the points inside are automatically detected.
-reading plane positions in ImaDoc? improved to deal with volume scans

Location:
trunk/src
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/create_grid.m

    r38 r60  
    9191   end
    9292   if isfield(input_grid,'y_0')
    93         set(handles.x_0,'String',num2str(input_grid.x_0));
     93        set(handles.y_0,'String',num2str(input_grid.y_0));
    9494   end
    9595   if isfield(input_grid,'y_1')
    96         set(handles.x_1,'String',num2str(input_grid.x_1));
     96        set(handles.y_1,'String',num2str(input_grid.y_1));
    9797   end
    9898   if isfield(input_grid,'Dy')
    99         set(handles.Dx,'String',num2str(input_grid.Dx));
     99        set(handles.Dy,'String',num2str(input_grid.Dy));
    100100   end
    101101   if isfield(input_grid,'z')
     
    115115varargout{1}=[0 0 0];%default
    116116if ~isequal(handles.output,'Cancel')
    117     x_0=str2num(get(handles.x_0,'String'));
    118     Dx=str2num(get(handles.Dx,'String'));
    119     x_1=str2num(get(handles.x_1,'String'));
    120     xarray=[x_0:Dx:x_1];
    121     y_0=str2num(get(handles.y_0,'String'));
    122     Dy=str2num(get(handles.Dy,'String'));
    123     y_1=str2num(get(handles.y_1,'String'));
    124     yarray=[y_0:Dy:y_1];
     117    T.x_0=str2num(get(handles.x_0,'String'));
     118    T.Dx=str2num(get(handles.Dx,'String'));
     119    T.x_1=str2num(get(handles.x_1,'String'));
     120    xarray=[T.x_0:T.Dx:T.x_1];
     121    T.y_0=str2num(get(handles.y_0,'String'));
     122    T.Dy=str2num(get(handles.Dy,'String'));
     123    T.y_1=str2num(get(handles.y_1,'String'));
     124    yarray=[T.y_0:T.Dy:T.y_1];
    125125    [yarray,xarray]=meshgrid(yarray,xarray);
    126126    xarray=reshape(xarray,numel(xarray),1);
    127127    yarray=reshape(yarray,numel(yarray),1);
    128     z_0=str2num(get(handles.z_0,'String'));
    129     if isempty(z_0)
    130         z_0=0;
     128    T.z_0=str2num(get(handles.z_0,'String'));
     129    if isempty(T.z_0)
     130        T.z_0=0;
    131131    end
    132     zarray=z_0*ones(size(yarray));
     132    zarray=T.z_0*ones(size(yarray));
    133133    varargout{1}=[xarray yarray zarray];
    134 %     if ~isempty(x_shift)
    135 %         varargout{1}(1)=x_shift;
    136 %     end
    137 %     if ~isempty(y_shift)
    138 %         varargout{1}(2)=y_shift;
    139 %     end
    140 %     if ~isempty(z_shift)
    141 %         varargout{1}(3)=z_shift;
    142 %     end
    143134end
     135varargout{2}=T;
    144136% The figure can be deleted now
    145137delete(handles.figure1);
  • trunk/src/geometry_calib.m

    r54 r60  
    4343% Edit the above text to modify the response to help geometry_calib
    4444
    45 % Last Modified by GUIDE v2.5 05-Jan-2010 23:22:04
     45% Last Modified by GUIDE v2.5 23-Mar-2010 06:22:33
    4646
    4747% Begin initialization code - DO NOT edit
     
    7070% PlotHandles: set of handles of the elements contolling the plotting
    7171% parameters on the uvmat interface (obtained by 'get_plot_handle.m')
     72%------------------------------------------------------------------------
    7273function geometry_calib_OpeningFcn(hObject, eventdata, handles, handles_uvmat,pos,inputfile)
    73 
     74%------------------------------------------------------------------------
    7475% Choose default command line output for geometry_calib
    7576handles.output = hObject;
     
    218219
    219220
    220 %----------------------------------------------------
     221%------------------------------------------------------------------------
    221222% executed when closing: set the parent interface button to value 0
    222223function closefcn(gcbo,eventdata,handles_uvmat)
     224%------------------------------------------------------------------------
    223225huvmat=findobj(allchild(0),'Name','uvmat');
    224226if exist('handles_uvmat','var')
     
    229231end
    230232
    231 
    232 % % --- Executes on button press in MenuCoord.
    233 % function MenuCoord_Callback(hObject, eventdata, handles)
    234 
    235 %
    236 % % --- Executes on button press in delete.
    237 % function delete_Callback(hObject, eventdata, handles)
    238 % SetData=get(gcbf,'UserData');%get the interface data
    239 % IndexObj=SetData.IndexObj;
    240 % delete_object(IndexObj);
    241 
    242 
    243 %------------------------------------------------------------------
     233%------------------------------------------------------------------------
    244234% --- Executes on button press in calibrate_lin.
    245235function APPLY_Callback(hObject, eventdata, handles)
    246 %------------------------------------------------------------------
     236%------------------------------------------------------------------------
    247237calib_cell=get(handles.calib_type,'String');
    248238val=get(handles.calib_type,'Value');
     
    280270end
    281271update_imadoc(GeometryCalib,outputfile)
    282 % testappend=0;
    283 % if exist(outputfile,'file');%=1 if the output file already exists, 0 else
    284 %     t=xmltree(outputfile); %read the file
    285 %     backupfile=outputfile;
    286 %     testexist=2;
    287 %     while testexist==2
    288 %         backupfile=[backupfile '~'];% make a backup name by adding  ~ to the xml file name
    289 %         testexist=exist(backupfile,'file');
    290 %     end
    291 %     [success,message]=copyfile(outputfile,backupfile);%make backup   
    292 %     t=xmltree(outputfile); %read the file
    293 %     uid=find(t,'ImaDoc');
    294 %     if ~isequal(uid,1)%if the xml file is not ImaDoc, delete it (after backup)
    295 %         if isequal(success,1)
    296 %             delete(outputfile)
    297 %         else
    298 %             msgbox_uvmat('ERROR',['error in the backup of the existing xml file: ' message])
    299 %             return
    300 %         end
    301 %     else
    302 %         uid_calib=find(t,'ImaDoc/GeometryCalib');
    303 %         testappend=1;
    304 %         if isempty(uid_calib)
    305 %             [t,uid_calib]=add(t,1,'element','GeometryCalib');
    306 %         else %if GeometryCalib already exists, delete its content
    307 %             uid_child=children(t,uid_calib);
    308 %             t=delete(t,uid_child);
    309 % %             testappend=1;
    310 %         end
    311 %     end
    312 % end
    313 % if ~testappend %create a new xml file for calibration data
    314 %     t=xmltree;
    315 %     t=set(t,1,'name','ImaDoc');
    316 %     [t,uid_calib]=add(t,1,'element','GeometryCalib');
    317 % end
    318 % % hgrid=get(handles.REPLICATE,'parent');%read the calibration image source on the interface userdata
    319 % % imagename=get(hgrid,'UserData');
    320 % % if exist(imagename,'file')
    321 % %     GeometryCalib.SourceCalib.ImageCalib=imagename;
    322 % % end
    323 % GeometryCalib.SourceCalib.PointCoord=Object.Coord;
    324 % t=struct2xml(GeometryCalib,t,uid_calib);
    325 % save(t,outputfile);
    326272msgbox_uvmat('CONFIRMATION',{[outputfile ' updated with calibration data'];...
    327273    ['Error rms (along x,y)=' num2str(GeometryCalib.ErrorRms) ' pixels'];...
     
    341287uvmat('RootPath_Callback',hObject,eventdata,hhuvmat); %file input with xml reading  in uvmat
    342288
    343 %------------------------------------------------------------------
     289%------------------------------------------------------------------------
    344290% --- Executes on button press in calibrate_lin.
    345291function REPLICATE_Callback(hObject, eventdata, handles)
    346 %------------------------------------------------------------------
     292%------------------------------------------------------------------------
    347293calib_cell=get(handles.calib_type,'String');
    348294val=get(handles.calib_type,'Value');
     
    388334    testinput=0;
    389335    if isfield(Heading,'SubCampaign') && isequal([filename ext],Heading.SubCampaign)
    390 %         set(hhdataview.RootDirectory,'String',XmlInput)
    391 %         set(hhdataview.SubCampaignTest,'Value',1)
    392336        SubCampaignTest='y';
    393337        testinput=1;
    394338    elseif isfield(Heading,'Campaign') && isequal([filename ext],Heading.Campaign)
    395 %         set(hhdataview.RootDirectory,'String',XmlInput)
    396 %         set(hhdataview.SubCampaignTest,'Value',0)
    397339        testinput=1;
    398340    end
     
    414356    outcome=dataview(XmlInput,SubCampaignTest,GeometryCalib);
    415357end
    416 %     %A COMPLETER
    417 %     dataview('RootDirectory_Callback',hObject,eventdata,hhdataview)
    418 %     ListDevices=get(hhdataview.ListDevices,'String');
    419 %     for ilist=1:length(ListDevices)
    420 %         if isequal(ListDevices{ilist},Device)
    421 %             set(hhdataview.ListDevices,'Value',ilist)
    422 %             dataview('ListDevices_Callback',hObject,eventdata,hhdataview)
    423 %             break
    424 %         end
    425 %     end
    426 
    427 % % hhdataview=guidata(h_dataview);
    428 % CurrentPath=get(hhdataview.RootDirectory,'String');
    429 % ListExperiments=get(hhdataview.ListExperiments,'String');
    430 % Value=get(hhdataview.ListExperiments,'Value');
    431 % if ~isequal(Value,1)
    432 %     ListExperiments=ListExperiments(Value);
    433 % end
    434 % ListDevices=get(hhdataview.ListDevices,'String');
    435 % Value=get(hhdataview.ListDevices,'Value');
    436 % if isequal(Value,1)
    437 %     msgbox_uvmat('ERROR','manually select in the GUI dataview the device being calibrated')
    438 %     return
    439 % else
    440 %     ListDevices=ListDevices(Value);
    441 % end
    442 % ListRecords=get(hhdataview.ListRecords,'String');
    443 % Value=get(hhdataview.ListRecords,'Value');
    444 % if ~isequal(Value,1)
    445 %     ListRecords=ListRecords(Value);
    446 % end
    447 % [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices,ListRecords);
    448 % ListXml=get(hhdataview.ListXml,'String');
    449 % Value=get(hhdataview.ListXml,'Value');
    450 % if isequal(Value,1)
    451 %     msgbox_uvmat('ERROR','you need to select in the GUI dataview the xml files to edit')
    452 %     return
    453 % else
    454 %     ListXml=ListXml(Value);
    455 % end
    456 %
    457 % %update all the selected xml files
    458 % answer=msgbox_uvmat('INPUT_Y-N',[num2str(length(Value)) ' xml files for device ' ListDevices{1} ' will be refreshed with ' calib_type ' calibration data'])
    459 % if ~isequal(answer,'Yes')
    460 %     return
    461 % end
    462 % 'TESTcalib'
    463 % List=DataFiles.List
    464 % for iexp=1:length(List.Experiment)
    465 %     ExpName=List.Experiment{iexp}.name;
    466 %     if isfield(List.Experiment{iexp},'Device')
    467 %         for idevice=1:length(List.Experiment{iexp}.Device)
    468 %             DeviceName=List.Experiment{iexp}.Device{idevice}.name;       
    469 %             if isfield(List.Experiment{iexp}.Device{idevice},'xmlfile')
    470 %                 for ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile)
    471 %                     FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml};
    472 %                     for ilistxml=1:length(ListXml)
    473 %                         if isequal(FileName,ListXml{ilistxml})
    474 %                             set(hhdataview.ListXml,'Value',Value(ilistxml))
    475 %                             drawnow
    476 %                             xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,FileName);
    477 %                             update_imadoc(GeometryCalib,xmlfullname)
    478 %                             break
    479 %                         end
    480 %                     end
    481 %                 end
    482 %              elseif isfield(List.Experiment{iexp}.Device{idevice},'Record')
    483 %                 for irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record)
    484 %                     RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name;
    485 %                     if isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},'xmlfile')
    486 %                         for ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile)
    487 %                             FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml};
    488 %                             for ilistxml=1:length(ListXml)
    489 %                                 if isequal(FileName,ListXml{ilistxml})
    490 %                                     set(hhdataview.ListXml,'Value',Value(ilistxml))
    491 %                                     drawnow
    492 %                                     xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,RecordName,FileName);
    493 %                                     update_imadoc(GeometryCalib,xmlfullname)
    494 %                                     break
    495 %                                 end
    496 %                             end
    497 %                         end
    498 %                     end
    499 %                 end
    500 %             end
    501 %         end
    502 %     end
    503 % end
    504 % set(hhdataview.ListXml,'Value',Value)
    505 
    506 
    507 %-----------------------------------------------------------------
     358
     359%------------------------------------------------------------------------
    508360% determine the parameters for a calibration by an affine function (rescaling and offset, no rotation)
    509361function GeometryCalib=calib_rescale(Coord)
    510 %------------------------------------------------------------------
     362%------------------------------------------------------------------------
    511363 
    512364X=Coord(:,1);
     
    542394GeometryCalib.ErrorMax(2)=max(abs(Ypoints-y_ima));
    543395
    544 
    545 %------------------------------------------------------------------
     396%------------------------------------------------------------------------
    546397% determine the parameters for a calibration by a linear transform matrix (rescale and rotation)
    547398function GeometryCalib=calib_linear(Coord)
    548 %------------------------------------------------------------------
     399%------------------------------------------------------------------------
    549400X=Coord(:,1);
    550401Y=Coord(:,2);
     
    572423GeometryCalib.ErrorMax(2)=max(abs(y1-y_ima));
    573424
    574 
    575 
    576 
    577 %------------------------------------------------------------------
     425%------------------------------------------------------------------------
    578426function GeometryCalib=calib_tsai(Coord)
    579 %------------------------------------------------------------------
     427%------------------------------------------------------------------------
    580428%TSAI
    581429% 'calibration_lin' provides a linear transform on coordinates,
     
    589437    sparam=convert(t);
    590438end
    591 % else
    592 %     %fid = fopen(fullfile(path_UVMAT,'PARAM_WIN.txt'),'r');%open the file with civ binary names
    593 %     xmlfile=fullfile(path_UVMAT,'PARAM_WIN.xml');
    594 %     if exist(xmlfile,'file')
    595 %         t=xmltree(xmlfile);
    596 %         sparam=convert(t);
    597 %     end
    598 % end
    599439if ~isfield(sparam,'GeometryCalib_exe')
    600440    msgbox_uvmat('ERROR',['calibration program <GeometryCalib_exe> undefined in parameter file ' xmlfile])
     
    618458end
    619459calibdat=dlmread('calib.dat');
     460delete('calib.dat')
     461delete('t.txt')
    620462GeometryCalib.CalibrationType='tsai';
    621463GeometryCalib.focal=calibdat(10);
     
    690532
    691533
    692 
     534%------------------------------------------------------------------------
    693535% --- Executes on button press in rotation.
    694536function rotation_Callback(hObject, eventdata, handles)
     537%------------------------------------------------------------------------
    695538angle_rot=(pi/180)*str2num(get(handles.Phi,'String'));
    696539Coord_cell=get(handles.ListCoord,'String');
     
    701544set(handles.YObject,'String',num2str(data.Coord(:,2),4));
    702545
    703 
     546%------------------------------------------------------------------------
    704547function XImage_Callback(hObject, eventdata, handles)
     548%------------------------------------------------------------------------
    705549update_list(hObject, eventdata,handles)
    706550
     551%------------------------------------------------------------------------
    707552function YImage_Callback(hObject, eventdata, handles)
     553%------------------------------------------------------------------------
    708554update_list(hObject, eventdata,handles)
    709555
     
    717563update_list(hObject, eventdata,handles)
    718564
     565%------------------------------------------------------------------------
    719566function update_list(hObject, eventdata, handles)
     567%------------------------------------------------------------------------
    720568str4=get(handles.XImage,'String');
    721569str5=get(handles.YImage,'String');
     
    732580Coord{val}=strline;
    733581set(handles.ListCoord,'String',Coord)
    734 
    735 %--------------------------------------------------------------------
     582%update the plot
     583ListCoord_Callback(hObject, eventdata, handles)
     584
     585%------------------------------------------------------------------------
    736586% --- Executes on selection change in ListCoord.
    737 %--------------------------------------------------------------------
    738587function ListCoord_Callback(hObject, eventdata, handles)
    739 % hObject    handle to ListCoord (see GCBO)
    740 % eventdata  reserved - to be defined in a future version of MATLAB
    741 % handles    structure with handles and user data (see GUIDATA)
    742 
    743 % Hints: contents = get(hObject,'String') returns ListCoord contents as cell array
    744 %        contents{get(hObject,'Value')} returns selected item from ListCoord
    745 %set(handles.edit_append,'Value',2); %set to edit mode
     588%------------------------------------------------------------------------
    746589Coord_cell=get(handles.ListCoord,'String');
    747590val=get(handles.ListCoord,'Value');
     
    788631end
    789632
    790 
    791 %----------------------------------------------------
    792 % --- Executes on button press in rotation_plus.
    793 function rotation_plus_Callback(hObject, eventdata, handles)
    794 Phi=0;
    795 Phi=get(handles.Phi,'String');
    796 if ~isempty(Phi)
    797     Phi=str2num(Phi);
    798 end
    799 rotation(handles,Phi)
    800 
    801 %-------------------------------------------------
    802 % --- Executes on button press in rotation_minus.
    803 function rotation_minus_Callback(hObject, eventdata, handles)
    804 Phi=0;
    805 Phi=get(handles.Phi,'String');
    806 if ~isempty(Phi)
    807     Phi=-str2num(Phi);
    808 end
    809 rotation(handles,Phi)
    810 
    811 
    812 
    813 function O_x_Callback(hObject, eventdata, handles)
    814 
    815 
    816 function O_y_Callback(hObject, eventdata, handles)
    817 
    818 
    819 function O_z_Callback(hObject, eventdata, handles)
    820 
    821 
     633%------------------------------------------------------------------------
    822634% --- Executes on selection change in edit_append.
    823635function edit_append_Callback(hObject, eventdata, handles)
    824 % val=get(handles.PLOT_append,'Value');
    825 % if isequal(val,2); %append mode
    826 %     %appeler mouse
    827 % end
     636%------------------------------------------------------------------------
    828637choice=get(handles.edit_append,'Value');
    829638if choice==1
     
    839648
    840649
    841 %A REVOIR
    842 % if choice==2
    843 %     %display image with px coordinates
    844 %     hrootpath=findobj(huvmat,'Tag','RootPath');
    845 %     hrootfile=findobj(huvmat,'Tag','RootFile');
    846 %     RootPath='';
    847 %     RootFile='';
    848 % %     if ~isempty(hrootpath)& ~isempty(hrootfile)
    849 %         testhandle=1;
    850 %         RootPath=get(hrootpath,'String');
    851 %         RootFile=get(hrootfile,'String');
    852 % %         filebase=fullfile(RootPath,RootFile);
    853 % %         outputfile=[filebase '.xml'];
    854 %         Indices=get(findobj(huvmat,'Tag','FileIndex'),'String');
    855 %         Ext=get(findobj(huvmat,'Tag','FileExt'),'String');
    856 %         imagename=[fullfile(RootPath,RootFile) Indices Ext];
    857 %         % input.menu_coord=1;
    858 %          h_menu_coord=findobj(huvmat,'Tag','menu_coord');
    859 %         set(h_menu_coord,'Value',3)
    860 %         huvmat=uvmat(imagename);%open uvmat, set phys coord (Value 1)
    861 %     
    862 % %     end
    863 % end
    864650   
    865651function NEW_Callback(hObject, eventdata, handles)
     
    900686 
    901687
    902 
    903 %'key_press_fcn:' function activated when a key is pressed on the keyboard
    904 %-----------------------------------
     688%------------------------------------------------------------------------
     689% --- 'key_press_fcn:' function activated when a key is pressed on the keyboard
    905690function key_press_fcn(hObject,eventdata,handles)
     691%------------------------------------------------------------------------
    906692hh=get(hObject,'parent');
    907693xx=double(get(hh,'CurrentCharacter')); %get the keyboard character
     
    930716end
    931717
    932 
     718%------------------------------------------------------------------------
    933719% --- Executes on button press in append_point.
    934720function append_point_Callback(hObject, eventdata, handles)
    935 
     721%------------------------------------------------------------------------
    936722       Coord=get(handles.ListCoord,'String');
    937723       val=length(Coord);
     
    943729       set(handles.ListCoord,'Value',val+1)
    944730
    945 
    946 % --------------------------------------------------------------------
     731%------------------------------------------------------------------------
    947732function MenuOpen_Callback(hObject, eventdata, handles)
     733%------------------------------------------------------------------------
    948734%get the object file
    949735huvmat=findobj(allchild(0),'Name','uvmat');
     
    972758
    973759
    974 % --------------------------------------------------------------------
    975 function Untitled_3_Callback(hObject, eventdata, handles)
    976 % hObject    handle to Untitled_3 (see GCBO)
    977 % eventdata  reserved - to be defined in a future version of MATLAB
    978 % handles    structure with handles and user data (see GUIDATA)
    979 
    980 
    981 % --------------------------------------------------------------------
     760%------------------------------------------------------------------------
    982761function MenuPlot_Callback(hObject, eventdata, handles)
    983 
     762%------------------------------------------------------------------------
    984763huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle
    985764UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface
    986765hhuvmat=guidata(huvmat); %handles of GUI elements in uvmat
    987766hplot=findobj(huvmat,'Tag','axes3');%main plotting axis of uvmat
    988 h_menu_coord=findobj(huvmat,'Tag','menu_coord');
     767h_menu_coord=findobj(huvmat,'Tag','transform_fct');
    989768menu=get(h_menu_coord,'String');
    990769choice=get(h_menu_coord,'Value');
     
    1033812    Tinput=CalibData.grid;
    1034813end
    1035 T=create_grid(Tinput);%display the GUI create_grid
    1036 CalibData.grid=T;
     814[T,CalibData.grid]=create_grid(grid_input);%display the GUI create_grid
    1037815set(handles.figure1,'UserData',CalibData)
    1038816
     
    1134912
    1135913
     914% --------------------------------------------------------------------
     915function MenuDetectGrid_Callback(hObject, eventdata, handles)
     916
     917CalibData=get(handles.figure1,'UserData');
     918grid_input=[];%default
     919if isfield(CalibData,'grid')
     920    grid_input=CalibData.grid;%retrieve the previously used grid
     921end
     922[T,CalibData.grid]=create_grid(grid_input);%display the GUI create_grid
     923set(handles.figure1,'UserData',CalibData)%store the phys grid for later use
     924
     925%read the four last point coordiantes in pixels
     926Coord_cell=get(handles.ListCoord,'String');%read list of coordiantes on geometry_calib
     927data=read_geometry_calib(Coord_cell);
     928nbpoints=size(data.Coord,1); %nbre of calibration points
     929if nbpoints<4
     930    msgbox_uvmat('ERROR','four points must be selected by the mouse to delimitate the detection area')
     931end
     932corners_X=(data.Coord(end-3:end,4)); %pixel absissa of the four corners
     933corners_Y=(data.Coord(end-3:end,5));
     934
     935%read the current image
     936huvmat=findobj(allchild(0),'Name','uvmat');
     937UvData=get(huvmat,'UserData');
     938A=UvData.Field.A;
     939npxy=size(A);
     940%linear transform on the current image
     941X=[CalibData.grid.x_0 CalibData.grid.x_1 CalibData.grid.x_0 CalibData.grid.x_1]';%corner absissa in the rectified image
     942Y=[CalibData.grid.y_0 CalibData.grid.y_0 CalibData.grid.y_1 CalibData.grid.y_1]';%corner absissa in the rectified image
     943XY_mat=[ones(size(X)) X Y];
     944a_X1=XY_mat\corners_X; %transformation matrix for X
     945x1=XY_mat*a_X1;%reconstruction
     946err_X1=max(abs(x1-corners_X))%error
     947a_Y1=XY_mat\corners_Y;%transformation matrix for X
     948y1=XY_mat*a_Y1;
     949err_Y1=max(abs(y1-corners_Y))%error
     950GeometryCalib.CalibrationType='linear';
     951GeometryCalib.CoordUnit=[];% default value, to be updated by the calling function
     952GeometryCalib.f=1;
     953GeometryCalib.dpx=1;
     954GeometryCalib.dpy=1;
     955GeometryCalib.sx=1;
     956GeometryCalib.Cx=0;
     957GeometryCalib.Cy=0;
     958GeometryCalib.kappa1=0;
     959GeometryCalib.Tx=a_X1(1);
     960GeometryCalib.Ty=a_Y1(1);
     961GeometryCalib.Tz=1;
     962GeometryCalib.R=[a_X1(2),a_X1(3),0;a_Y1(2),a_Y1(3),0;0,0,1];
     963[Amod,Rangx,Rangy]=phys_Ima(A-min(min(A)),GeometryCalib,0);
     964Amod=double(Amod);
     965%figure(12)
     966%Amax=max(max(Amod))
     967%image(Rangx,Rangy,uint8(255*Amod/Amax))
     968ind_range=10;% range of search of image ma around each point obtained by linear interpolation from the marked points
     969nbpoints=size(T,1);
     970for ipoint=1:nbpoints
     971    Dx=(Rangx(2)-Rangx(1))/(npxy(2)-1); %x mesh in real space
     972    Dy=(Rangy(2)-Rangy(1))/(npxy(1)-1); %y mesh in real space
     973    i0=1+round((T(ipoint,1)-Rangx(1))/Dx);%round(Xpx(ipoint));
     974    j0=1+round((T(ipoint,2)-Rangy(1))/Dy);%round(Xpx(ipoint));
     975    Asub=Amod(j0-ind_range:j0+ind_range,i0-ind_range:i0+ind_range);
     976    x_profile=sum(Asub,1);
     977    y_profile=sum(Asub,2);
     978    [Amax,ind_x_max]=max(x_profile);
     979    [Amax,ind_y_max]=max(y_profile);
     980    Delta(ipoint,1)=(ind_x_max-ind_range-1)*Dx;%shift from the initial guess
     981    Delta(ipoint,2)=(ind_y_max-ind_range-1)*Dy;
     982end
     983Tmod=T(:,(1:2))+Delta;
     984[Xpx,Ypx]=px_XYZ(GeometryCalib,Tmod(:,1),Tmod(:,2));
     985for i=1:nbpoints
     986     Coord{i,1}=num2str(T(i,1),4);%display coordiantes with 4 digits
     987     Coord{i,2}=num2str(T(i,2),4);%display coordiantes with 4 digits
     988     Coord{i,3}='0';
     989     Coord{i,4}=num2str(Xpx(i),4);%display coordiantes with 4 digi
     990     Coord{i,5}=num2str(Ypx(i),4);%display coordiantes with 4 digi
     991end
     992Tabchar=cell2tab(Coord,'    |    ');
     993set(handles.ListCoord,'Value',1)
     994set(handles.ListCoord,'String',Tabchar)
     995
     996
     997%%%%%%%%%%%%%%%%%%%%
     998function [A_out,Rangx,Rangy]=phys_Ima(A,Calib,ZIndex)
     999xcorner=[];
     1000ycorner=[];
     1001npx=[];
     1002npy=[];
     1003siz=size(A);
     1004npx=[npx siz(2)];
     1005npy=[npy siz(1)];
     1006xima=[0.5 siz(2)-0.5 0.5 siz(2)-0.5];%image coordiantes of corners
     1007yima=[0.5 0.5 siz(1)-0.5 siz(1)-0.5];
     1008[xcorner,ycorner]=phys_XYZ(Calib,xima,yima,ZIndex);%corresponding physical coordinates
     1009Rangx(1)=min(xcorner);
     1010Rangx(2)=max(xcorner);
     1011Rangy(2)=min(ycorner);
     1012Rangy(1)=max(ycorner);
     1013test_multi=(max(npx)~=min(npx)) | (max(npy)~=min(npy));
     1014npx=max(npx);
     1015npy=max(npy);
     1016x=linspace(Rangx(1),Rangx(2),npx);
     1017y=linspace(Rangy(1),Rangy(2),npy);
     1018[X,Y]=meshgrid(x,y);%grid in physical coordiantes
     1019vec_B=[];
     1020
     1021zphys=0; %default
     1022if isfield(Calib,'SliceCoord') %.Z= index of plane
     1023   SliceCoord=Calib.SliceCoord(ZIndex,:);
     1024   zphys=SliceCoord(3); %to generalize for non-parallel planes
     1025end
     1026[XIMA,YIMA]=px_XYZ(Calib,X,Y,zphys);%corresponding image indices for each point in the real space grid
     1027XIMA=reshape(round(XIMA),1,npx*npy);%indices reorganized in 'line'
     1028YIMA=reshape(round(YIMA),1,npx*npy);
     1029flagin=XIMA>=1 & XIMA<=npx & YIMA >=1 & YIMA<=npy;%flagin=1 inside the original image
     1030testuint8=isa(A,'uint8');
     1031testuint16=isa(A,'uint16');
     1032if numel(siz)==2 %(B/W images)
     1033    vec_A=reshape(A,1,npx*npy);%put the original image in line
     1034    ind_in=find(flagin);
     1035    ind_out=find(~flagin);
     1036    ICOMB=((XIMA-1)*npy+(npy+1-YIMA));
     1037    ICOMB=ICOMB(flagin);%index corresponding to XIMA and YIMA in the aligned original image vec_A
     1038    vec_B(ind_in)=vec_A(ICOMB);
     1039    vec_B(ind_out)=zeros(size(ind_out));
     1040    A_out=reshape(vec_B,npy,npx);%new image in real coordinates
     1041elseif numel(siz)==3     
     1042    for icolor=1:siz(3)
     1043        vec_A=reshape(A{icell}(:,:,icolor),1,npx*npy);%put the original image in line
     1044        ind_in=find(flagin);
     1045        ind_out=find(~flagin);
     1046        ICOMB=((XIMA-1)*npy+(npy+1-YIMA));
     1047        ICOMB=ICOMB(flagin);%index corresponding to XIMA and YIMA in the aligned original image vec_A
     1048        vec_B(ind_in)=vec_A(ICOMB);
     1049        vec_B(ind_out)=zeros(size(ind_out));
     1050        A_out(:,:,icolor)=reshape(vec_B,npy,npx);%new image in real coordinates
     1051    end
     1052end
     1053if testuint8
     1054    A_out=uint8(A_out);
     1055end
     1056if testuint16
     1057    A_out=uint16(A_out);
     1058end
     1059
     1060%INPUT:
     1061%Z: index of plane
     1062function [Xphys,Yphys,Zphys]=phys_XYZ(Calib,X,Y,Z)
     1063if exist('Z','var')& isequal(Z,round(Z))& Z>0 & isfield(Calib,'SliceCoord')&length(Calib.SliceCoord)>=Z
     1064    Zindex=Z;
     1065    Zphys=Calib.SliceCoord(Zindex,3);%GENERALISER AUX CAS AVEC ANGLE
     1066else
     1067%     if exist('Z','var')
     1068%         Zphys=Z;
     1069%     else
     1070        Zphys=0;
     1071%     end
     1072end
     1073if ~exist('X','var')||~exist('Y','var')
     1074    Xphys=[];
     1075    Yphys=[];%default
     1076    return
     1077end
     1078Xphys=X;%default
     1079Yphys=Y;
     1080%image transform
     1081if isfield(Calib,'R')
     1082    R=(Calib.R)';
     1083    Dx=R(5)*R(7)-R(4)*R(8);
     1084    Dy=R(1)*R(8)-R(2)*R(7);
     1085    D0=Calib.f*(R(2)*R(4)-R(1)*R(5));
     1086    Z11=R(6)*R(8)-R(5)*R(9);
     1087    Z12=R(2)*R(9)-R(3)*R(8); 
     1088    Z21=R(4)*R(9)-R(6)*R(7);
     1089    Z22=R(3)*R(7)-R(1)*R(9);
     1090    Zx0=R(3)*R(5)-R(2)*R(6);
     1091    Zy0=R(1)*R(6)-R(3)*R(4);
     1092    A11=R(8)*Calib.Ty-R(5)*Calib.Tz+Z11*Zphys;
     1093    A12=R(2)*Calib.Tz-R(8)*Calib.Tx+Z12*Zphys;
     1094    A21=-R(7)*Calib.Ty+R(4)*Calib.Tz+Z21*Zphys;
     1095    A22=-R(1)*Calib.Tz+R(7)*Calib.Tx+Z11*Zphys;
     1096    X0=Calib.f*(R(5)*Calib.Tx-R(2)*Calib.Ty+Zx0*Zphys);
     1097    Y0=Calib.f*(-R(4)*Calib.Tx+R(1)*Calib.Ty+Zy0*Zphys);
     1098        %px to camera:
     1099    Xd=(Calib.dpx/Calib.sx)*(X-Calib.Cx); % sensor coordinates
     1100    Yd=Calib.dpy*(Y-Calib.Cy);
     1101    dist_fact=1+Calib.kappa1*(Xd.*Xd+Yd.*Yd); %distortion factor
     1102    Xu=dist_fact.*Xd;%undistorted sensor coordinates
     1103    Yu=dist_fact.*Yd;
     1104    denom=Dx*Xu+Dy*Yu+D0;
     1105    % denom2=denom.*denom;
     1106    Xphys=(A11.*Xu+A12.*Yu+X0)./denom;%world coordinates
     1107    Yphys=(A21.*Xu+A22.*Yu+Y0)./denom;
     1108end
  • trunk/src/get_field/PLOT.m

    r36 r60  
    1414    uvmat(SubField)
    1515else
    16 hfig=str2num(list_fig{val});% chosen figure number from tyhe GUI
    17 if isempty(hfig)
    18     hfig=figure;
    19     list_fig=[list_fig;num2str(hfig)];
    20     set(handles.list_fig,'String',list_fig);
    21     haxes=axes;
    22 else
    23     figure(hfig);
     16    hfig=str2num(list_fig{val});% chosen figure number from tyhe GUI
     17    if isempty(hfig)
     18        hfig=figure;
     19        list_fig=[list_fig;num2str(hfig)];
     20        set(handles.list_fig,'String',list_fig);
     21        haxes=axes;
     22    else
     23        figure(hfig);
     24    end
     25    haxes=findobj(hfig,'Type','axes');
     26    plot_field(SubField,haxes)
    2427end
    25 haxes=findobj(hfig,'Type','axes');
    26 plot_field(SubField,haxes)
    27 end
  • trunk/src/imadoc2struct.m

    r29 r60  
    210210        %look for laser plane definitions   
    211211        uid_Angle=find(subt,'/GeometryCalib/PlaneAngle');
    212         uid_Pos=find(subt,'/GeometryCalib/PlanePos');
     212        uid_Pos=find(subt,'/GeometryCalib/SliceCoord');
     213        if isempty(uid_Pos)
     214            uid_Pos=find(subt,'/GeometryCalib/PlanePos');%old convention
     215        end
    213216        if ~isempty(uid_Angle)
    214217            tsai.PlaneAngle=str2num(get(subt,children(subt,uid_Angle),'value'));
    215218        end
    216         if ~isempty(uid_Pos)
     219        if ~isempty(uid_Pos)     
    217220            for j=1:length(uid_Pos)
    218221                tsai.SliceCoord(j,:)=str2num(get(subt,children(subt,uid_Pos(j)),'value'));
    219222            end
     223            uid_DZ=find(subt,'/GeometryCalib/SliceDZ');
     224            uid_NbSlice=find(subt,'/GeometryCalib/NbSlice');
     225            if ~isempty(uid_DZ) && ~isempty(uid_NbSlice)
     226                DZ=str2double(get(subt,children(subt,uid_DZ),'value'));
     227                NbSlice=get(subt,children(subt,uid_NbSlice),'value');
     228                if isequal(NbSlice,'volume')
     229                    tsai.NbSlice='volume';
     230                    NbSlice=NbDtj+1;
     231                else
     232                    tsai.NbSlice=str2double(NbSlice);
     233                end
     234                tsai.SliceCoord=ones(NbSlice,1)*tsai.SliceCoord+DZ*[0:NbSlice-1]'*[0 0 1];
     235            end         
    220236        end
    221237        s.GeometryCalib=tsai;
  • trunk/src/mouse_down.m

    r46 r60  
    2626MouseAction='none'; %default
    2727huvmat=findobj(allchild(0),'Name','uvmat');%find the uvmat interface handle which controls theoption of  mouse action
    28 if ~isempty(huvmat)
    29     hhuvmat=guidata(huvmat);%handles of elements in uvmat
    30     UvData=get(huvmat,'UserData');
    31     testzoom=get(hhuvmat.zoom,'Value');% get the mouse action from the uvmat GUI: options:
    32     if isfield(UvData,'MouseAction')
    33         MouseAction=UvData.MouseAction;% get the mouse action from the uvmat GUI: options:
    34     end
    35 end
     28if isempty(huvmat)
     29    return
     30end
     31hhuvmat=guidata(huvmat);%handles of elements in uvmat
     32UvData=get(huvmat,'UserData');
     33testzoom=get(hhuvmat.zoom,'Value');% get the mouse action from the uvmat GUI: options:
     34if isfield(UvData,'MouseAction')
     35    MouseAction=UvData.MouseAction;% get the mouse action from the uvmat GUI: options:
     36end
     37
    3638test_create=~testzoom && (isequal(MouseAction,'create_object') || isequal(MouseAction,'create_mask'));
    3739%test_cal=get(handles.cal,'Value');
    3840test_cal=isequal(MouseAction,'calib');
     41test_ruler=isequal(MouseAction,'ruler');
    3942menu_coord=get(hhuvmat.transform_fct,'String');
    4043coord_choice=get(hhuvmat.transform_fct,'Value');
     
    8588                end
    8689            end
    87         elseif isequal(get(hchild(ichild),'Visible'),'on')& ~isequal(get(hchild(ichild),'Style'),'frame')
    88            %FAIRE UNE OPTION D'AIDE AVEC BOUTON SOURIS DROIT (ALT)??
     90%         elseif isequal(get(hchild(ichild),'Visible'),'on')& ~isequal(get(hchild(ichild),'Style'),'frame')
     91%            %FAIRE UNE OPTION D'AIDE AVEC BOUTON SOURIS DROIT (ALT)??
    8992        end
    9093    end
     
    222225        h_edit_append=hh_geometry_calib.edit_append;%findobj(h_geometry_calib,'Tag','edit_append');
    223226        if isequal(get(h_edit_append,'Value'),1)
    224             if ~isequal(coord_type,'')
    225                 set(handles_coord,'Value',1)
    226                 coord_type='';
     227            coord_value=get(hhuvmat.transform_fct,'Value');
     228            if ~(isequal(coord_value,1)||isequal(coord_value,3)); %active only with no transform or px (no phys)
     229                set(hhuvmat.transform_fct,'Value',1)
    227230                set(hhuvmat.FixedLimits,'Value',0)% put FixedLimits option to 'off'
    228231                set(hhuvmat.FixedLimits,'BackgroundColor',[0.7 0.7 0.7])
    229232                uvmat('run0_Callback',hObject,eventdata,hhuvmat); %file input with xml reading  in uvmat
     233                return
    230234            end
    231235%             if isequal(coord_type,'px')|isequal(coord_type,'');%px cordinates
     
    286290        [PlotType,ScalOut]= plot_field(AxeData,haxes,PlotParam,1);
    287291    end   
     292   
     293    %create ruler
     294    if test_ruler
     295        UvData.RulerCoord(1,1)=xy(1,1);
     296        UvData.RulerCoord(1,2)=xy(1,2);
     297        UvData.RulerHandle=line([xy(1,1) xy(1,1)],[xy(1,2) xy(1,2)],'Color','m','Tag','proj_object');
     298        set(huvmat,'UserData',UvData)
     299    end
    288300end
    289301set(haxes,'UserData',AxeData);
  • trunk/src/mouse_motion.m

    r11 r60  
    2727    return
    2828end
    29 if ~isfield(handles, 'mouse_coord')
    30     return
    31 end
    32 if ~ishandle(handles.mouse_coord)
    33     return
    34 end
    35 proj_coord=get(handles.mouse_coord,'String');
    36 choice=get(handles.mouse_coord,'Value');
    37 if ~isempty(proj_coord); proj_coord=proj_coord{choice};else;proj_coord=[];end;
     29% if ~isfield(handles, 'mouse_coord')
     30%     'TEST'
     31%     return
     32% end
     33% if ~ishandle(handles.mouse_coord)
     34%     return
     35% end
     36% proj_coord=get(handles.mouse_coord,'String');
     37% choice=get(handles.mouse_coord,'Value');
     38% if ~isempty(proj_coord); proj_coord=proj_coord{choice};else;proj_coord=[];end;
    3839test_create=0;%default
    3940test_edit=0;%default
     
    148149            if isfield(AxeData,'CoordUnit')
    149150                  mouse.CoordUnit=AxeData.CoordUnit;
    150             end
    151             if isfield(mouse,'CoordType') &~isequal(mouse.CoordType,proj_coord)
    152                 huvmat=findobj(allchild(0),'Tag','uvmat');%find the uvmat interface handle
    153                 UvData=get(huvmat,'UserData'); %coord transformed stored in the uvmat interface, updated by file input
    154                 if isfield(AxeData,'CoordType')
    155                     mouse.CoordType=AxeData.CoordType;
    156                 end
    157                 if isfield(AxeData,'dt')
    158                     mouse.dt=AxeData.dt;
    159                 end
    160 %                 if ~isempty(z_mouse)
    161 %                     mouse.Z=z_mouse;
    162 %                 end
    163                 if length(ivec)>0 %& isfield(AxeData,'dt')                   
    164                       mouse.U=u_mouse;
    165                       mouse.V=v_mouse;
    166                 end
    167                 mouse=feval(proj_coord,mouse,UvData);%apply transform proj_coord to the position
    168                 if length(ivec)>0%& isfield(AxeData,'dt')
    169                      u_mouse=mouse.U;
    170                      v_mouse=mouse.V;
    171                 end
    172             end 
     151            end
    173152            if isfield(mouse,'CoordType')
    174153                if isequal(mouse.CoordType,'px')
     
    203182                text_displ_2=['A=' num2str(double(A_mouse)) ',i='  num2str(indx0) ',j=' num2str(indy0)];
    204183            end
    205         elseif isequal(get(hchild(ichild),'Visible'),'on')& ~isequal(get(hchild(ichild),'Style'),'frame')
     184        elseif isequal(htype,'uicontrol') && isequal(get(hchild(ichild),'Visible'),'on')&& ~isequal(get(hchild(ichild),'Style'),'frame')
    206185            text_displ_1=get(hchild(ichild),'Tag');
    207186        end
     
    287266    pointershape='arrow';
    288267end
     268
     269%draw ruler
     270UvData=get(handles.uvmat,'UserData');
     271if isfield(UvData,'MouseAction') && isequal(UvData.MouseAction,'ruler')
     272       if isfield(UvData,'RulerHandle')
     273            RulerCoord=[UvData.RulerCoord ;xy(1,1:2)];
     274            set(UvData.RulerHandle,'XData',RulerCoord(:,1));
     275            set(UvData.RulerHandle,'YData',RulerCoord(:,2));
     276       end
     277end
    289278set(currentfig,'Pointer',pointershape);
  • trunk/src/mouse_up.m

    r18 r60  
    275275      end
    276276end
     277if isequal(MouseAction,'ruler')
     278    UvData.MouseAction='none';
     279    UvData=rmfield(UvData,'RulerHandle')
     280     xy=get(currentaxes,'CurrentPoint');
     281    RulerCoord=[UvData.RulerCoord ;xy(1,1:2)]
     282    set(huvmat,'UserData',UvData)
     283    RulerCoord=diff(RulerCoord,1)
     284    RulerCoord=RulerCoord(1)+i*RulerCoord(2);
     285    distance=abs(RulerCoord)
     286    azimuth=(180/pi)*angle(RulerCoord)
     287    msgbox_uvmat('RULER','',['length: ' num2str(distance,3) ',  angle(degrees): ' num2str(azimuth,3)])
     288end
     289
    277290
    278291%display the data of the current object selected with the mouse right click
  • trunk/src/update_obj.m

    r47 r60  
    6262        if length(Object_set)>= IndexObj && isfield(Object_set{IndexObj},'plotaxes')
    6363            plotaxes=Object_set{IndexObj}.plotaxes;
     64            [PlotType,Object_out.PlotParam,plotaxes]=plot_field(ProjData,plotaxes,PlotHandles);
     65        else
     66             [plotaxes]=view_field(ProjData);
    6467        end
    65         [PlotType,Object_out.PlotParam,plotaxes]=plot_field(ProjData,plotaxes,PlotHandles);
     68       
     69%         [PlotType,Object_out.PlotParam,plotaxes]=plot_field(ProjData,plotaxes,PlotHandles);
    6670        Object_out.plotaxes=plotaxes;
    6771        plotfig=get(plotaxes,'parent');
  • trunk/src/uvmat.m

    r59 r60  
    229229addpath(fullfile(path_uvmat,'transform_field'))
    230230fct_handle{1,1}=[];
    231 testexist=zeros(size(menu_str));%default
     231testexist=zeros(size(menu_str'));%default
    232232testexist(1)=1;
    233233for ilist=2:length(menu_str)
     
    240240end
    241241rmpath(fullfile(path_uvmat,'transform_field'))
     242
     243%refresh projection plane
     244UvData.Object{1}.Style='plane';%main plotting plane
     245UvData.Object{1}.ProjMode='projection';%main plotting plane
     246if ~isfield(UvData.Object{1},'plotaxes')
     247    UvData.Object{1}.plotaxes=handles.axes3;%default plotting axis
     248    set(handles.list_object,'String',{'1-PLANE'});
     249    set(handles.list_object,'Value',1);
     250end
    242251
    243252%load the list of previously browsed files in menus Open and Open_1
     
    795804               set(handles.slices,'Value',1)
    796805           end
    797            set(handles.nb_slice,'String',num2str(NbSlice))
     806           if isequal(GeometryCalib.NbSlice,'volume')
     807               set(handles.nb_slice,'String','volume')
     808           else
     809               set(handles.nb_slice,'String',num2str(NbSlice))
     810           end
    798811           slices_Callback(hObject, eventdata, handles)
    799812    %        Coord=UvData.XmlData.GeometryCalib.SliceCoord;
    800813    %        ZIndex=num_i1-NbSlice*(floor((num_i1-1)/NbSlice));
    801814        end
     815
     816           
    802817    end
    803818end
    804819
    805820%update the data attached to the uvmat interface
    806 set(handles.nb_slice,'String',num2str(NbSlice))
     821% set(handles.nb_slice,'String',num2str(NbSlice))
    807822if ~isempty(TimeUnit)
    808823    set(handles.time_txt,'String',['time (' TimeUnit ')'])
     
    13481363    set(handles.z_index,'Visible','on')
    13491364    nb_slice_Callback(hObject, eventdata, handles)
    1350 %      z=mod(num_i1-1,nbslice)+1;
    1351 %         set(handles.z_index,'String',num2str(z))
    13521365else
    13531366    set(handles.nb_slice,'Visible','off')
     
    13621375function nb_slice_Callback(hObject, eventdata, handles)
    13631376%-------------------------------------------------------------------
    1364 num_i1=str2num(get(handles.i1,'String'));
    1365 nbslice=str2num(get(handles.nb_slice,'String'));
    1366 z=mod(num_i1-1,nbslice)+1;
     1377nb_slice_str=get(handles.nb_slice,'String')
     1378if isequal(nb_slice_str,'volume')
     1379    num=stra2num(get(handles.j1,'String'));
     1380    last_j=get(handles.last_j,'String');
     1381    nbslice=str2double(last_j{1});
     1382else
     1383    num=str2double(get(handles.i1,'String'));
     1384    nbslice=str2double(get(handles.nb_slice,'String'));
     1385end
     1386z=mod(num-1,nbslice)+1;
    13671387set(handles.z_index,'String',num2str(z))
    13681388for ilist=1:nbslice
     
    17981818            Field.A=imread(imaname_1);
    17991819end
     1820if get(handles.slices,'Value')
     1821    Field.ZIndex=str2double(get(handles.z_index,'String'));
     1822end
    18001823
    18011824%px to phys or other transform on field
     
    18851908    NomType=get(handles.FileIndex,'UserData');
    18861909    %update the z position index
    1887     nbslice=str2double(get(handles.nb_slice,'String'));
    1888     if ~isnan(nbslice)
     1910    nbslice_str=get(handles.nb_slice,'String');
     1911    z_index=1;%default
     1912    if isequal(nbslice_str,'volume')
     1913        z_index=num_j1;
     1914        set(handles.z_index,'String',num2str(z_index))
     1915    else
     1916        nbslice=str2num(nbslice_str);
    18891917        z_index=mod(num_i1-1,nbslice)+1;
    18901918        set(handles.z_index,'String',num2str(z_index))
    1891         % refresh menu for save_mask if relevant
    1892         masknumber=get(handles.masklevel,'String');
    1893         if length(masknumber)>=z_index
    1894             set(handles.masklevel,'Value',z_index)
    1895         end
    1896     end
     1919    end
     1920    % refresh menu for save_mask if relevant
     1921    masknumber=get(handles.masklevel,'String');
     1922    if length(masknumber)>=z_index
     1923        set(handles.masklevel,'Value',z_index)
     1924    end
     1925
    18971926    % determine the input file type
    18981927    if isequal(Ext,'.nc')||isequal(Ext,'.cdf')
     
    22202249       if siz(1)>1
    22212250           NbSlice=siz(1);
    2222            set(handles.slices,'Visible','on')
    2223            set(handles.slices,'Value',1)
     2251%            set(handles.slices,'Visible','on')
     2252%            set(handles.slices,'Value',1)
    22242253       else
    22252254           NbSlice=1;
    22262255       end
    2227        set(handles.nb_slice,'String',num2str(NbSlice))
    2228        slices_Callback(handles.uvmat, [], handles)
     2256       %set(handles.nb_slice,'String',num2str(NbSlice))
     2257%        slices_Callback(handles.uvmat, [], handles)
    22292258end
    22302259
     
    22562285% z index
    22572286if ~isempty(filename)
    2258     Field{1}.ZIndex=mod(num_i1-1,nbslice)+1;
     2287    Field{1}.ZIndex=z_index;
    22592288end
    22602289
     
    22622291if ~isempty(transform)
    22632292    if length(Field)>=2
    2264         Field{2}.ZIndex=mod(num_i1-1,nbslice)+1;
     2293        Field{2}.ZIndex=z_index;
    22652294        [Field{1},Field{2}]=transform(Field{1},XmlData,Field{2},XmlData_1);
    22662295        if isempty(Field{2})
     
    24262455if ~isfield(UvData.Object{1},'plotaxes')
    24272456    UvData.Object{1}.plotaxes=handles.axes3;%default plotting axis
    2428     set(handles.list_object,'String',{'1-PLANE';'...'});
     2457    set(handles.list_object,'String',{'1-PLANE'});
    24292458    set(handles.list_object,'Value',1);
    24302459end
     
    24702499    set(handles.MaxA,'String','255')
    24712500end
    2472 
     2501IndexObj=get(handles.list_object,'Value');
    24732502Object=UvData.Object;
    2474 for iobj=1:length(Object)
     2503IndexObj=min(IndexObj,numel(Object));
     2504for iobj=[1 IndexObj]
    24752505    if ~isempty(Object{iobj})%& isfield(Object{iobj},'plotaxes')& ishandle(Object{iobj}.plotaxes)
    24762506        %Projeter les champs sur l'objet:*
     
    27022732%-------------------------------------------------------------------
    27032733function zoom_Callback(hObject, eventdata, handles)
    2704 %huvmat=get(handles.zoom,'parent');%general input
    2705 UvData=get(handles.uvmat,'UserData');
     2734
    27062735if (get(handles.zoom,'Value') == 1);
    27072736    set(handles.zoom,'BackgroundColor',[1 1 0])
    27082737    set(handles.FixedLimits,'Value',1)% propose by default fixed limits for the plotting axes
    2709     set(handles.FixedLimits,'BackgroundColor',[1 1 0])
    2710     %UvData.ZoomOn=1;   %test for mouse action   
     2738    set(handles.FixedLimits,'BackgroundColor',[1 1 0])
    27112739else
    27122740    set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
    2713     %UvData.ZoomOn=0;  %test for mouse action
    2714 end
    2715 set(handles.uvmat,'UserData',UvData);
     2741end
     2742
    27162743
    27172744%-------------------------------------------------------------------
     
    33693396end
    33703397
    3371 %------------------------------------------------
    3372 function create_Callback(hObject,eventdata,handles)
    3373 %------------------------------------------------
    3374 if ishandle(handles.UVMAT_title)
    3375     delete(handles.UVMAT_title)
    3376 end
    3377 huvmat=get(handles.create,'parent');
    3378 UvData=get(huvmat,'UserData');%read UvData properties stored on the uvmat interface (handles huvmat)
    3379 if isequal(get(handles.create,'Value'),1)
    3380     set(handles.zoom,'Value',0)
    3381     zoom_Callback(hObject, eventdata, handles)
    3382      set(handles.create,'BackgroundColor',[1 1 0]) %visualise in yellow
    3383     set(handles.edit_vect,'Value',0) 
    3384     edit_vect_Callback(hObject, eventdata, handles)
    3385     set(handles.edit,'Value',0)
    3386     set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
    3387     list_object=get(handles.list_object,'String');
    3388     if ~isempty(list_object)
    3389         set(handles.list_object,'Value',length(list_object))
    3390     end
    3391     MouseAction='create_object';
    3392     hset_object=findobj(allchild(0),'Name','set_object');
    3393     uistack(hset_object,'top')
    3394 else
    3395     set(handles.create,'BackgroundColor',[0 1 0])
    3396     set(handles.edit,'Value',1)
    3397     set(handles.edit,'BackgroundColor',[1 1 0])
    3398     MouseAction='none';
    3399 end
    3400 
    3401 UvData.MouseAction=MouseAction;
    3402 set(huvmat,'UserData',UvData);
    3403 
    3404 %------------------------------------------------
    3405 function POINTS_Callback(hObject,eventdata,handles)
    3406 %------------------------------------------------
    3407 if ishandle(handles.UVMAT_title)
    3408     delete(handles.UVMAT_title)
    3409 end
    3410 huvmat=get(handles.create,'parent');
    3411 UvData=get(huvmat,'UserData');%read UvData properties stored on the uvmat interface (handles huvmat)
    3412 if isequal(get(handles.create,'Value'),1)
    3413     set(handles.zoom,'Value',0)
    3414     zoom_Callback(hObject, eventdata, handles)
    3415     set(handles.edit_vect,'Value',0) 
    3416     edit_vect_Callback(hObject, eventdata, handles)
    3417     set(handles.edit,'Value',0)
    3418     set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
    3419     %set(handles.grid,'Value',0)
    3420     %set(handles.grid,'BackgroundColor',[0 1 0])
    3421     % initiate set_object GUI
    3422      data.TITLE='POINTS';
    3423     if isfield(UvData,'CoordType')
    3424         data.CoordType=UvData.CoordType;
    3425     end
    3426     if isfield(UvData,'Mesh')&~isempty(UvData.Mesh)
    3427         data.RangeY=UvData.Mesh;
    3428     elseif isfield(UvData,'AX')&isfield(UvData,'AY')& isfield(UvData,'A')%only image
    3429         np=size(UvData.Field.A);
    3430         meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2);
    3431         meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1);
    3432         data.RangeY=max(meshx,meshy);
    3433         data.DX=max(meshx,meshy);
    3434     end
    3435     data.Coord=[0 0 0]; %default
    3436     data.ParentButton=handles.create;
    3437     PlotHandles=get_plot_handles(handles);%get the handles of the graphic objects setting the plotting parameters
    3438     [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface
    3439     if isfield(UvData,'SetObjectOrigin')
    3440     pos_uvmat=get(huvmat,'Position');
    3441     pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
    3442     pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4);
    3443     set(hset_object,'Position',pos_set_object)
    3444     end
    3445     %set(hset_object,'Position',[pos_uvmat(1) pos_uvmat(2)-0.05*pos_uvmat(4) 0.2*pos_uvmat(3)  0.5*pos_uvmat(4)]);
    3446     list_object=get(handles.list_object,'String');
    3447     if ~isempty(list_object)
    3448         set(handles.list_object,'Value',length(list_object))
    3449     end
    3450     MouseAction='create_object';
    3451     %UvData.ZoomOn=0;
    3452 else
    3453     set(handles.create,'BackgroundColor',[0 1 0])
    3454     set(handles.edit,'Value',1)
    3455     set(handles.edit,'BackgroundColor',[1 1 0])
    3456     MouseAction='none';
    3457 end
    3458 
    3459 UvData.MouseAction=MouseAction;
    3460 set(huvmat,'UserData',UvData);
    3461 
    3462 %-----------------------------------------------------------
    3463 function LINE_Callback(hObject, eventdata, handles)
    3464 %-------------------------------------------------
    3465 if ishandle(handles.UVMAT_title)
    3466     delete(handles.UVMAT_title)
    3467 end
    3468 % handles.uvmat
    3469 huvmat=get(handles.create,'parent');
    3470 UvData=get(huvmat,'UserData');%read UvData properties stored on the uvmat interface
    3471 set(handles.zoom,'Value',0)
    3472 zoom_Callback(hObject, eventdata, handles)
    3473 set(handles.edit_vect,'BackgroundColor',[0.7 0.7 0.7])
    3474 set(handles.edit_vect,'Value',0)
    3475 edit_vect_Callback(hObject, eventdata, handles)
    3476 set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
    3477 set(handles.edit,'Value',0)
    3478 set(handles.list_object,'Value',1);
    3479 edit_vect_Callback(hObject, eventdata, handles)
    3480 set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
    3481 set(handles.cal,'Value',0)
    3482 set(handles.cal,'BackgroundColor',[0 1 0])
    3483 %  initiate the set_object GUI
    3484 data.TITLE='LINE';
    3485 if isfield(UvData,'CoordType')
    3486     data.CoordType=UvData.CoordType;
    3487 end
    3488 if isfield(UvData,'Mesh')&~isempty(UvData.Mesh)
    3489     data.RangeX=UvData.Mesh;
    3490     data.RangeY=UvData.Mesh;
    3491     data.DX=UvData.Mesh;
    3492     data.DY=UvData.Mesh;
    3493 elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image
    3494     np=size(UvData.Field.A);
    3495     meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2);
    3496     meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1);
    3497     data.RangeY=max(meshx,meshy);
    3498     data.RangeX=max(meshx,meshy);
    3499     data.DX=max(meshx,meshy);
    3500 end
    3501 if isfield(data,'DX')
    3502     data.Coord=[[0 0 0];[data.DX 0 0]]; %default
    3503 else
    3504     data.Coord=[[0 0 0];[1 0 0]]; %default
    3505 end
    3506 data.ParentButton=handles.create;
    3507 PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
    3508 [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface with action on haxes,
    3509                                                   % associate the set_edit interface handle to the plotting axes
    3510 pos_uvmat=get(huvmat,'Position');
    3511 if isfield(UvData,'SetObjectOrigin')
    3512     pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
    3513     pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4); 
    3514     set(hset_object,'Position',pos_set_object)
    3515 end
    3516 list_object=get(handles.list_object,'String');
    3517 if ~isempty(list_object)
    3518     set(handles.list_object,'Value',length(list_object))
    3519 end
    3520 MouseAction='create_object';
    3521 UvData.MouseAction=MouseAction;
    3522 set(huvmat,'UserData',UvData)
    3523 
    3524 %-----------------------------------------------------------
    3525 function PATCH_Callback(hObject, eventdata, handles)
    3526 %-----------------------------------------------------------
    3527 if ishandle(handles.UVMAT_title)
    3528     delete(handles.UVMAT_title)
    3529 end
    3530 huvmat=get(handles.create,'parent');
    3531 UvData=get(huvmat,'UserData');%read UvData properties stored on the uvmat interface
    3532 % if isequal(get(handles.PATCH,'Value'),1)
    3533     set(handles.zoom,'Value',0)
    3534     set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
    3535 %     set(handles.create,'Value',0)%suppress the other options if LINE is chosen
     3398% %------------------------------------------------
     3399% function create_Callback(hObject,eventdata,handles)
     3400% %------------------------------------------------
     3401% if ishandle(handles.UVMAT_title)
     3402%     delete(handles.UVMAT_title)
     3403% end
     3404% huvmat=get(handles.create,'parent');
     3405% UvData=get(huvmat,'UserData');%read UvData properties stored on the uvmat interface (handles huvmat)
     3406% if isequal(get(handles.create,'Value'),1)
     3407%     set(handles.zoom,'Value',0)
     3408%     zoom_Callback(hObject, eventdata, handles)
     3409%      set(handles.create,'BackgroundColor',[1 1 0]) %visualise in yellow
     3410%     set(handles.edit_vect,'Value',0) 
     3411%     edit_vect_Callback(hObject, eventdata, handles)
     3412%     set(handles.edit,'Value',0)
     3413%     set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
     3414%     list_object=get(handles.list_object,'String');
     3415%     if ~isempty(list_object)
     3416%         set(handles.list_object,'Value',length(list_object))
     3417%     end
     3418%     MouseAction='create_object';
     3419%     hset_object=findobj(allchild(0),'Name','set_object');
     3420%     uistack(hset_object,'top')
     3421% else
    35363422%     set(handles.create,'BackgroundColor',[0 1 0])
    3537 %     set(handles.LINE,'Value',0)
    3538 %     set(handles.LINE,'BackgroundColor',[0 1 0])
    3539 %     set(handles.PATCH,'Value',1)
    3540 %     set(handles.PATCH,'BackgroundColor',[1 1 0])
    3541 %     set(handles.PLANE,'Value',0)
    3542 %     set(handles.PLANE,'BackgroundColor',[0 1 0])%put activated buttons to yellow
    3543 %     set(handles.VOLUME,'Value',0)
    3544 %     set(handles.VOLUME,'BackgroundColor',[0 1 0])
    3545     %set(handles.makemask,'Value',0)
    3546     %makemask_Callback(hObject, eventdata, handles)
    3547     set(handles.edit_vect,'Value',0)
    3548     edit_vect_Callback(hObject, eventdata, handles)
    3549     set(handles.edit,'Value',0)
    3550     set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
    3551     set(handles.edit_vect,'Value',0) 
    3552     edit_vect_Callback(hObject, eventdata, handles)
    3553     set(handles.cal,'Value',0)
    3554     set(handles.cal,'BackgroundColor',[0 1 0])
    3555     %set(handles.grid,'Value',0)
    3556     %set(handles.grid,'BackgroundColor',[0 1 0])
    3557     %initiate set_object GUI
    3558     data.TITLE='PATCH';
    3559     if isfield(UvData,'CoordType')
    3560         data.CoordType=UvData.CoordType;
    3561     end
    3562     if isfield(UvData,'Mesh')&~isempty(UvData.Mesh)
    3563         data.YMax=UvData.Mesh;
    3564     elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image
    3565         np=size(UvData.Field.A);
    3566         meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/(np(2)-1);
    3567         meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/(np(1)-1);
    3568         data.YMax=max(meshx,meshy);
    3569         data.DX=max(meshx,meshy);
    3570     end
    3571     data.Coord=[0 0 0]; %default
    3572     data.ParentButton=handles.create;
    3573     PlotHandles=get_plot_handles(handles);%get the handles of the graphic objects setting the plotting parameters
    3574     [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface
    3575     pos_uvmat=get(huvmat,'Position');
    3576     if isfield(UvData,'SetObjectOrigin')
    3577         pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
    3578         pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4);
    3579         set(hset_object,'Position',pos_set_object)
    3580     end
    3581     list_object=get(handles.list_object,'String');
    3582     if ~isempty(list_object)
    3583         set(handles.list_object,'Value',length(list_object))
    3584     end
    3585     UvData.MouseAction='create_object';
    3586     set(huvmat,'UserData',UvData);
    3587 %-------------------------------------------------------
    3588 function PLANE_Callback(hObject, eventdata, handles)
    3589 %-------------------------------------------------------
    3590 if ishandle(handles.UVMAT_title)
    3591     delete(handles.UVMAT_title)
    3592 end
    3593 huvmat=get(handles.create,'parent');
    3594 UvData=get(huvmat,'UserData');%read UvData properties stored on the uvmat interface
    3595 set(handles.zoom,'Value',0)
    3596 set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
    3597 set(handles.edit_vect,'Value',0)
    3598 edit_vect_Callback(hObject, eventdata, handles)
    3599 set(handles.edit,'Value',0)
    3600 set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
    3601 set(handles.cal,'Value',0)
    3602 set(handles.cal,'BackgroundColor',[0 1 0])
    3603 %set(handles.grid,'Value',0)
    3604 %set(handles.grid,'BackgroundColor',[0 1 0])
    3605 %initiate set_object GUI
    3606 data.TITLE='PLANE';
    3607 if isfield(UvData,'CoordType')
    3608     data.CoordType=UvData.CoordType;
    3609 end
    3610 %Si 3D data.nbdim=3;
    3611 %Si 2D
    3612 if isfield(UvData,'Mesh')&~isempty(UvData.Mesh)
    3613     data.ZMax=UvData.Mesh;
    3614     data.DX=UvData.Mesh;
    3615     data.DY=UvData.Mesh;
    3616 elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image
    3617     np=size(UvData.Field.A);
    3618     meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/(np(2)-1);
    3619     meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/(np(1)-1);
    3620     data.DX=max(meshx,meshy);
    3621 end
    3622 if isfield(UvData,'DX')
    3623     data.DX=UvData.DX;
    3624 end
    3625 if isfield(UvData,'DY')
    3626     data.DY=UvData.DY;
    3627 elseif isfield(UvData,'Mesh')
    3628     data.DY=UvData.Mesh;
    3629 end
    3630 if isfield(UvData.Field,'X')& isfield(UvData.Field,'Y')
    3631     data.Coord=[0 0 0];
    3632     data.Style='plane';
    3633     data.Phi=0;
    3634     data.IndexObj=1; %act on the first reference plane by default
    3635     haxes= handles.axes3;%GENERALISER
    3636     plot_object(data,[],haxes,'m'); %plot the axes of the default plane 
    3637 end
    3638 data.ParentButton=handles.create;
    3639 PlotHandles=get_plot_handles(handles);%get the handles of the graphic objects setting the plotting parameters
    3640 ZBounds=0; % default
    3641 if isfield(UvData,'ZMin') && isfield(UvData,'ZMax')
    3642     ZBounds(1)=UvData.ZMin; %minimum for the Z slider
    3643     ZBounds(2)=UvData.ZMax;%maximum for the Z slider
    3644 end
    3645 [hset_object,UvData.sethandles]=set_object(data,PlotHandles,ZBounds);% call the set_object interface with action on haxes,
    3646 if isfield(UvData,'SetObjectOrigin')
    3647 pos_uvmat=get(huvmat,'Position');
    3648 pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
    3649 pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4); 
    3650 set(hset_object,'Position',pos_set_object)
    3651 end
    3652 list_object=get(handles.list_object,'String');
    3653 nbobject=length(list_object);
    3654 set(handles.list_object,'Value',nbobject)
    3655 UvData.MouseAction='create_object';
    3656 set(huvmat,'UserData',UvData)
     3423%     set(handles.edit,'Value',1)
     3424%     set(handles.edit,'BackgroundColor',[1 1 0])
     3425%     MouseAction='none';
     3426% end
     3427%
     3428% UvData.MouseAction=MouseAction;
     3429% set(huvmat,'UserData',UvData);
     3430%
     3431% %------------------------------------------------
     3432% function POINTS_Callback(hObject,eventdata,handles)
     3433% %------------------------------------------------
     3434% if ishandle(handles.UVMAT_title)
     3435%     delete(handles.UVMAT_title)
     3436% end
     3437% huvmat=get(handles.create,'parent');
     3438% UvData=get(huvmat,'UserData');%read UvData properties stored on the uvmat interface (handles huvmat)
     3439% if isequal(get(handles.create,'Value'),1)
     3440%     set(handles.zoom,'Value',0)
     3441%     zoom_Callback(hObject, eventdata, handles)
     3442%     set(handles.edit_vect,'Value',0) 
     3443%     edit_vect_Callback(hObject, eventdata, handles)
     3444%     set(handles.edit,'Value',0)
     3445%     set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
     3446%     %set(handles.grid,'Value',0)
     3447%     %set(handles.grid,'BackgroundColor',[0 1 0])
     3448%     % initiate set_object GUI
     3449%      data.TITLE='POINTS';
     3450%     if isfield(UvData,'CoordType')
     3451%         data.CoordType=UvData.CoordType;
     3452%     end
     3453%     if isfield(UvData,'Mesh')&~isempty(UvData.Mesh)
     3454%         data.RangeY=UvData.Mesh;
     3455%     elseif isfield(UvData,'AX')&isfield(UvData,'AY')& isfield(UvData,'A')%only image
     3456%         np=size(UvData.Field.A);
     3457%         meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2);
     3458%         meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1);
     3459%         data.RangeY=max(meshx,meshy);
     3460%         data.DX=max(meshx,meshy);
     3461%     end
     3462%     data.Coord=[0 0 0]; %default
     3463%     data.ParentButton=handles.create;
     3464%     PlotHandles=get_plot_handles(handles);%get the handles of the graphic objects setting the plotting parameters
     3465%     [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface
     3466%     if isfield(UvData,'SetObjectOrigin')
     3467%     pos_uvmat=get(huvmat,'Position');
     3468%     pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
     3469%     pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4);
     3470%     set(hset_object,'Position',pos_set_object)
     3471%     end
     3472%     %set(hset_object,'Position',[pos_uvmat(1) pos_uvmat(2)-0.05*pos_uvmat(4) 0.2*pos_uvmat(3)  0.5*pos_uvmat(4)]);
     3473%     list_object=get(handles.list_object,'String');
     3474%     if ~isempty(list_object)
     3475%         set(handles.list_object,'Value',length(list_object))
     3476%     end
     3477%     MouseAction='create_object';
     3478%     %UvData.ZoomOn=0;
     3479% else
     3480%     set(handles.create,'BackgroundColor',[0 1 0])
     3481%     set(handles.edit,'Value',1)
     3482%     set(handles.edit,'BackgroundColor',[1 1 0])
     3483%     MouseAction='none';
     3484% end
     3485%
     3486% UvData.MouseAction=MouseAction;
     3487% set(huvmat,'UserData',UvData);
     3488
     3489% %-----------------------------------------------------------
     3490% function LINE_Callback(hObject, eventdata, handles)
     3491% %-------------------------------------------------
     3492% if ishandle(handles.UVMAT_title)
     3493%     delete(handles.UVMAT_title)
     3494% end
     3495% % handles.uvmat
     3496% huvmat=get(handles.create,'parent');
     3497% UvData=get(huvmat,'UserData');%read UvData properties stored on the uvmat interface
     3498% set(handles.zoom,'Value',0)
     3499% zoom_Callback(hObject, eventdata, handles)
     3500% set(handles.edit_vect,'BackgroundColor',[0.7 0.7 0.7])
     3501% set(handles.edit_vect,'Value',0)
     3502% edit_vect_Callback(hObject, eventdata, handles)
     3503% set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
     3504% set(handles.edit,'Value',0)
     3505% set(handles.list_object,'Value',1);
     3506% edit_vect_Callback(hObject, eventdata, handles)
     3507% set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
     3508% set(handles.cal,'Value',0)
     3509% set(handles.cal,'BackgroundColor',[0 1 0])
     3510% %  initiate the set_object GUI
     3511% data.TITLE='LINE';
     3512% if isfield(UvData,'CoordType')
     3513%     data.CoordType=UvData.CoordType;
     3514% end
     3515% if isfield(UvData,'Mesh')&~isempty(UvData.Mesh)
     3516%     data.RangeX=UvData.Mesh;
     3517%     data.RangeY=UvData.Mesh;
     3518%     data.DX=UvData.Mesh;
     3519%     data.DY=UvData.Mesh;
     3520% elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image
     3521%     np=size(UvData.Field.A);
     3522%     meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2);
     3523%     meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1);
     3524%     data.RangeY=max(meshx,meshy);
     3525%     data.RangeX=max(meshx,meshy);
     3526%     data.DX=max(meshx,meshy);
     3527% end
     3528% if isfield(data,'DX')
     3529%     data.Coord=[[0 0 0];[data.DX 0 0]]; %default
     3530% else
     3531%     data.Coord=[[0 0 0];[1 0 0]]; %default
     3532% end
     3533% data.ParentButton=handles.create;
     3534% PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
     3535% [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface with action on haxes,
     3536%                                                   % associate the set_edit interface handle to the plotting axes
     3537% pos_uvmat=get(huvmat,'Position');
     3538% if isfield(UvData,'SetObjectOrigin')
     3539%     pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
     3540%     pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4); 
     3541%     set(hset_object,'Position',pos_set_object)
     3542% end
     3543% list_object=get(handles.list_object,'String');
     3544% if ~isempty(list_object)
     3545%     set(handles.list_object,'Value',length(list_object))
     3546% end
     3547% MouseAction='create_object';
     3548% UvData.MouseAction=MouseAction;
     3549% set(huvmat,'UserData',UvData)
     3550
     3551% %-----------------------------------------------------------
     3552% function PATCH_Callback(hObject, eventdata, handles)
     3553% %-----------------------------------------------------------
     3554% if ishandle(handles.UVMAT_title)
     3555%     delete(handles.UVMAT_title)
     3556% end
     3557% huvmat=get(handles.create,'parent');
     3558% UvData=get(huvmat,'UserData');%read UvData properties stored on the uvmat interface
     3559% % if isequal(get(handles.PATCH,'Value'),1)
     3560%     set(handles.zoom,'Value',0)
     3561%     set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
     3562% %     set(handles.create,'Value',0)%suppress the other options if LINE is chosen
     3563% %     set(handles.create,'BackgroundColor',[0 1 0])
     3564% %     set(handles.LINE,'Value',0)
     3565% %     set(handles.LINE,'BackgroundColor',[0 1 0])
     3566% %     set(handles.PATCH,'Value',1)
     3567% %     set(handles.PATCH,'BackgroundColor',[1 1 0])
     3568% %     set(handles.PLANE,'Value',0)
     3569% %     set(handles.PLANE,'BackgroundColor',[0 1 0])%put activated buttons to yellow
     3570% %     set(handles.VOLUME,'Value',0)
     3571% %     set(handles.VOLUME,'BackgroundColor',[0 1 0])
     3572%     %set(handles.makemask,'Value',0)
     3573%     %makemask_Callback(hObject, eventdata, handles)
     3574%     set(handles.edit_vect,'Value',0)
     3575%     edit_vect_Callback(hObject, eventdata, handles)
     3576%     set(handles.edit,'Value',0)
     3577%     set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
     3578%     set(handles.edit_vect,'Value',0) 
     3579%     edit_vect_Callback(hObject, eventdata, handles)
     3580%     set(handles.cal,'Value',0)
     3581%     set(handles.cal,'BackgroundColor',[0 1 0])
     3582%     %set(handles.grid,'Value',0)
     3583%     %set(handles.grid,'BackgroundColor',[0 1 0])
     3584%     %initiate set_object GUI
     3585%     data.TITLE='PATCH';
     3586%     if isfield(UvData,'CoordType')
     3587%         data.CoordType=UvData.CoordType;
     3588%     end
     3589%     if isfield(UvData,'Mesh')&~isempty(UvData.Mesh)
     3590%         data.YMax=UvData.Mesh;
     3591%     elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image
     3592%         np=size(UvData.Field.A);
     3593%         meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/(np(2)-1);
     3594%         meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/(np(1)-1);
     3595%         data.YMax=max(meshx,meshy);
     3596%         data.DX=max(meshx,meshy);
     3597%     end
     3598%     data.Coord=[0 0 0]; %default
     3599%     data.ParentButton=handles.create;
     3600%     PlotHandles=get_plot_handles(handles);%get the handles of the graphic objects setting the plotting parameters
     3601%     [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface
     3602%     pos_uvmat=get(huvmat,'Position');
     3603%     if isfield(UvData,'SetObjectOrigin')
     3604%         pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
     3605%         pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4);
     3606%         set(hset_object,'Position',pos_set_object)
     3607%     end
     3608%     list_object=get(handles.list_object,'String');
     3609%     if ~isempty(list_object)
     3610%         set(handles.list_object,'Value',length(list_object))
     3611%     end
     3612%     UvData.MouseAction='create_object';
     3613%     set(huvmat,'UserData',UvData);
     3614% %-------------------------------------------------------
     3615% function PLANE_Callback(hObject, eventdata, handles)
     3616% %-------------------------------------------------------
     3617% if ishandle(handles.UVMAT_title)
     3618%     delete(handles.UVMAT_title)
     3619% end
     3620% huvmat=get(handles.create,'parent');
     3621% UvData=get(huvmat,'UserData');%read UvData properties stored on the uvmat interface
     3622% set(handles.zoom,'Value',0)
     3623% set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
     3624% set(handles.edit_vect,'Value',0)
     3625% edit_vect_Callback(hObject, eventdata, handles)
     3626% set(handles.edit,'Value',0)
     3627% set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
     3628% set(handles.cal,'Value',0)
     3629% set(handles.cal,'BackgroundColor',[0 1 0])
     3630% %set(handles.grid,'Value',0)
     3631% %set(handles.grid,'BackgroundColor',[0 1 0])
     3632% %initiate set_object GUI
     3633% data.TITLE='PLANE';
     3634% if isfield(UvData,'CoordType')
     3635%     data.CoordType=UvData.CoordType;
     3636% end
     3637% %Si 3D data.nbdim=3;
     3638% %Si 2D
     3639% if isfield(UvData,'Mesh')&~isempty(UvData.Mesh)
     3640%     data.ZMax=UvData.Mesh;
     3641%     data.DX=UvData.Mesh;
     3642%     data.DY=UvData.Mesh;
     3643% elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image
     3644%     np=size(UvData.Field.A);
     3645%     meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/(np(2)-1);
     3646%     meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/(np(1)-1);
     3647%     data.DX=max(meshx,meshy);
     3648% end
     3649% if isfield(UvData,'DX')
     3650%     data.DX=UvData.DX;
     3651% end
     3652% if isfield(UvData,'DY')
     3653%     data.DY=UvData.DY;
     3654% elseif isfield(UvData,'Mesh')
     3655%     data.DY=UvData.Mesh;
     3656% end
     3657% if isfield(UvData.Field,'X')& isfield(UvData.Field,'Y')
     3658%     data.Coord=[0 0 0];
     3659%     data.Style='plane';
     3660%     data.Phi=0;
     3661%     data.IndexObj=1; %act on the first reference plane by default
     3662%     haxes= handles.axes3;%GENERALISER
     3663%     plot_object(data,[],haxes,'m'); %plot the axes of the default plane 
     3664% end
     3665% data.ParentButton=handles.create;
     3666% PlotHandles=get_plot_handles(handles);%get the handles of the graphic objects setting the plotting parameters
     3667% ZBounds=0; % default
     3668% if isfield(UvData,'ZMin') && isfield(UvData,'ZMax')
     3669%     ZBounds(1)=UvData.ZMin; %minimum for the Z slider
     3670%     ZBounds(2)=UvData.ZMax;%maximum for the Z slider
     3671% end
     3672% [hset_object,UvData.sethandles]=set_object(data,PlotHandles,ZBounds);% call the set_object interface with action on haxes,
     3673% if isfield(UvData,'SetObjectOrigin')
     3674% pos_uvmat=get(huvmat,'Position');
     3675% pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
     3676% pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4); 
     3677% set(hset_object,'Position',pos_set_object)
     3678% end
     3679% list_object=get(handles.list_object,'String');
     3680% nbobject=length(list_object);
     3681% set(handles.list_object,'Value',nbobject)
     3682% UvData.MouseAction='create_object';
     3683% set(huvmat,'UserData',UvData)
    36573684
    36583685%-------------------------------------------------------
     
    45024529%--------------------------------------------------------
    45034530function list_object_Callback(hObject, eventdata, handles)
    4504 huvmat=get(handles.list_object,'parent');
    4505 UvData=get(huvmat,'UserData');%read UvData properties stored on the uvmat interface
     4531UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
    45064532list_str=get(handles.list_object,'String');
    45074533IndexObj=get(handles.list_object,'Value');
     
    45224548    end
    45234549AxeData.hset_object=set_object(ObjectData,PlotHandles,ZBounds);% call the set_object interface,
    4524 pos_uvmat=get(huvmat,'Position');
     4550pos_uvmat=get(handles.uvmat,'Position');
    45254551if isfield(UvData,'SetObjectOrigin')
    45264552pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
     
    45284554set(AxeData.hset_object,'Position',pos_set_object)
    45294555end
     4556
     4557%project the current field on the object and plot it
     4558ProjData= proj_field(UvData.Field,ObjectData,IndexObj);%project the current interface field on ObjectData
     4559if length(UvData.Object)>= IndexObj && isfield(UvData.Object{IndexObj},'plotaxes')&& ishandle(UvData.Object{IndexObj}.plotaxes)
     4560    plot_field(ProjData,UvData.Object{IndexObj}.plotaxes,PlotHandles);
     4561else
     4562     UvData.Object{IndexObj}.plotaxes=view_field(ProjData);
     4563     set(handles.uvmat,'UserData',UvData)
     4564end
     4565
    45304566hother=findobj('Tag','proj_object');%find all the proj objects
    45314567for iobj=1:length(hother)
     
    50495085zoom_Callback(handles.uvmat, [], handles)
    50505086
     5087
     5088
     5089% --------------------------------------------------------------------
     5090function MenuRuler_Callback(hObject, eventdata, handles)
     5091set(handles.zoom,'Value',0)
     5092zoom_Callback(handles.uvmat, [], handles)
     5093UvData=get(handles.uvmat,'UserData');
     5094UvData.MouseAction='ruler';
     5095set(handles.uvmat,'UserData',UvData);
     5096
     5097
Note: See TracChangeset for help on using the changeset viewer.