Changeset 738 for trunk


Ignore:
Timestamp:
Apr 14, 2014, 11:41:21 AM (7 years ago)
Author:
sommeria
Message:

various bug resolutions and improvements in particular with geometry_calib. Introduction of a tool set_slices in uvmat.

Location:
trunk/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/find_imadoc.m

    r737 r738  
    2222    end   
    2323end
    24 % SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.'
    25 % XmlFileName=[fullfile(RootPath,SubDirBase) '.xml'];%new convention: xml at the level of the image folder
    2624if ~exist(XmlFileName,'file')
    2725    XmlFileName=[fullfile(RootPath,SubDirBase,RootFile) '.xml']; % old convention: xml inside the image folder, case of images or new civ files
  • trunk/src/geometry_calib.m

    r724 r738  
    5050% Edit the above text to modify the response to help geometry_calib
    5151
    52 % Last Modified by GUIDE v2.5 29-Oct-2013 06:46:10
     52% Last Modified by GUIDE v2.5 11-Apr-2014 23:10:57
    5353
    5454% Begin initialization code - DO NOT edit
     
    110110set(handles.Extrinsic,'Position',[1 Height-40-4-92-75 418 75])%  rank 3
    111111set(handles.PointLists,'Position',[1 Height-40-6-92-75-117 418 117]) %  rank 4
    112 set(handles.CheckEnableMouse,'Position',[3 Height-40-8-92-75-117-30 203 30])%  rank 5
     112set(handles.CheckEnableMouse,'Position',[3 Height-40-8-92-75-117-30 180 30])%  rank 5
    113113set(handles.PLOT,'Position',[3 Height-394 120 30])%  rank 6
    114114set(handles.Copy,'Position',[151 Height-394 120 30])%  rank 6
    115115set(handles.CLEAR_PTS,'Position',[297 Height-394 120 30])%  rank 6
    116116set(handles.ClearLine,'Position',[297 Height-364 120 30])%  rank 6
     117set(handles.CoordLine,'Position',[177 Height-364 120 30])%  rank 6
    117118set(handles.phys_title,'Position',[38 Height-426 125 20])%  rank 7
    118119set(handles.CoordUnit,'Position',[151 Height-426 120 30])%  rank 7
     
    124125set(handles.calib_type,'String',{'rescale';'linear';'3D_linear';'3D_quadr';'3D_extrinsic'})
    125126if exist('inputfile','var')&& ~isempty(inputfile)
    126     struct.XmlInputFile=inputfile;
     127%     struct.XmlInputFile=inputfile;
    127128    [RootPath,SubDir,RootFile,tild,tild,tild,tild,FileExt]=fileparts_uvmat(inputfile);
    128     if ~strcmp(FileExt,'.xml')
    129         inputfile=fullfile(RootPath,[SubDir '.xml']);%xml file corresponding to the input file
    130         if ~exist(inputfile,'file')% case of civ files , removes the extension for subdir
    131             inputfile=fullfile(RootPath,[regexprep(SubDir,'\..+$','') '.xml']);
    132             if ~exist(inputfile,'file')
    133                 inputfile=[fullfile(RootPath,SubDir,RootFile) '.xml'];%old convention
    134                 if ~exist(inputfile,'file')
    135                     inputfile='';
    136                 end
    137             end
    138         end
    139     end
     129    struct.XmlInputFile=find_imadoc(RootPath,SubDir,RootFile,FileExt);
     130%     if ~strcmp(FileExt,'.xml')
     131%         inputfile=fullfile(RootPath,[SubDir '.xml']);%xml file corresponding to the input file
     132%         if ~exist(inputfile,'file')% case of civ files , removes the extension for subdir
     133%             inputfile=fullfile(RootPath,[regexprep(SubDir,'\..+$','') '.xml']);
     134%             if ~exist(inputfile,'file')
     135%                 inputfile=[fullfile(RootPath,SubDir,RootFile) '.xml'];%old convention
     136%                 if ~exist(inputfile,'file')
     137%                     inputfile='';
     138%                 end
     139%             end
     140%         end
     141%     end
    140142    set(handles.ListCoord,'Data',[])
    141     if exist(inputfile,'file')
    142         Heading=loadfile(handles,inputfile);% load data from the xml file
     143    if exist(struct.XmlInputFile,'file')
     144        Heading=loadfile(handles,struct.XmlInputFile);% load data from the xml file
    143145        if isfield(Heading,'Campaign')&& ischar(Heading.Campaign)
    144146            struct.Campaign=Heading.Campaign;
     
    214216   
    215217    %% display image with new calibration in the currently opened uvmat interface
    216     hhh=findobj(hhuvmat.PlotAxes,'Tag','calib_marker');% delete calib points and markers
    217     if ~isempty(hhh)
    218         delete(hhh);
    219     end
    220     hhh=findobj(hhuvmat.PlotAxes,'Tag','calib_points');
    221     if ~isempty(hhh)
    222         delete(hhh);
    223     end
    224     set(hhuvmat.CheckFixLimits,'Value',0)% put FixedLimits option to 'off'
    225     set(hhuvmat.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7])
     218    set(hhuvmat.CheckFixLimits,'Value',0)% put FixedLimits option to 'off' to plot the whole image
    226219    UserData=get(handles.geometry_calib,'UserData');
    227220    UserData.XmlInputFile=outputfile;%save the current xml file name
    228221    set(handles.geometry_calib,'UserData',UserData)
    229     uvmat('RootPath_Callback',hObject,eventdata,hhuvmat); %file input with xml reading  in uvmat, show the image in phys coordinates
     222    uvmat('InputFileREFRESH_Callback',hObject,eventdata,hhuvmat); %file input with xml reading  in uvmat, show the image in phys coordinates
    230223    PLOT_Callback(hObject, eventdata, handles)
    231     Data=get(handles.ListCoord,'Data');
    232     Data(:,6)=zeros(size(Data,1),1);
    233     Data(index,6)=-1;% indicate in the list the point with max deviation (possible mistake)
    234     set(handles.ListCoord,'Data',Data)% indicate in the list the point with max deviation (possible mistake)
    235     figure(handles.geometry_calib)
    236     set(handles.APPLY,'BackgroundColor',[1 0 0])
     224    set(handles.CoordLine,'string',num2str(index))
     225    Coord=get(handles.ListCoord,'Data');
     226    update_calib_marker(Coord(index,:)); %indicate the point with max deviations from phys coord to calibration
     227    figure(handles.geometry_calib)% put the GUI geometry_calib in front
     228    set(handles.APPLY,'BackgroundColor',[1 0 0]) % set APPLY button to red color
    237229end
    238230
     
    338330%% store the calibration data, by default in the xml file of the currently displayed image
    339331UvData=get(hhuvmat.uvmat,'UserData');
    340 NbSlice_j=1;%default
    341 ZStart=Z_plane;
    342 ZEnd=Z_plane;
    343 volume_scan='n';
    344 if isfield(UvData,'XmlData')
    345     if isfield(UvData.XmlData,'TranslationMotor')
    346         NbSlice_j=UvData.XmlData.TranslationMotor.Nbslice;
    347         ZStart=UvData.XmlData.TranslationMotor.ZStart/10;
    348         ZEnd=UvData.XmlData.TranslationMotor.ZEnd/10;
    349         volume_scan='y';
    350     end
    351 end
     332% NbSlice_j=1;%default
     333% ZStart=Z_plane;
     334% ZEnd=Z_plane;
     335% volume_scan='n';
     336% if isfield(UvData,'XmlData')
     337%     if isfield(UvData.XmlData,'TranslationMotor')
     338%         NbSlice_j=UvData.XmlData.TranslationMotor.Nbslice;
     339%         ZStart=UvData.XmlData.TranslationMotor.ZStart/10;
     340%         ZEnd=UvData.XmlData.TranslationMotor.ZEnd/10;
     341%         volume_scan='y';
     342%     end
     343% end
    352344
    353345answer=msgbox_uvmat('INPUT_Y-N',{'store calibration data';...
     
    362354end
    363355if strcmp(calib_cell{val}(1:2),'3D')%set the plane position for 3D (projection) calibration
    364     input_key={'Z (first position)','Z (last position)','Z (water surface)', 'refractive index','NbSlice','volume scan (y/n)','tilt angle y axis','tilt angle x axis'};
    365     input_val=[{num2str(ZEnd)} {num2str(ZStart)} {num2str(ZStart)} {'1.333'} num2str(NbSlice_j) {volume_scan} {'0'} {'0'}];
    366     answer=inputdlg(input_key,'slice position(s)',ones(1,8), input_val,'on');
    367     GeometryCalib.NbSlice=str2double(answer{5});
    368     GeometryCalib.VolumeScan=answer{6};
    369     if isempty(answer)
    370         Z_plane=0; %default
    371     else
    372         Z_plane=linspace(str2double(answer{1}),str2double(answer{2}),GeometryCalib.NbSlice);
    373     end
    374     GeometryCalib.SliceCoord=Z_plane'*[0 0 1];
    375     GeometryCalib.SliceAngle(:,3)=0;
    376     GeometryCalib.SliceAngle(:,2)=str2double(answer{7})*ones(GeometryCalib.NbSlice,1);%rotation around y axis (to generalise)
    377     GeometryCalib.SliceAngle(:,1)=str2double(answer{8})*ones(GeometryCalib.NbSlice,1);%rotation around x axis (to generalise)
    378     GeometryCalib.InterfaceCoord=[0 0 str2double(answer{3})];
    379     GeometryCalib.RefractionIndex=str2double(answer{4});
    380 end
    381 
    382 
    383 
    384 %------------------------------------------------------------------------
    385 % determine the parameters for a calibration by an affine function (rescaling and offset, no rotation)
     356    msgbox_uvmat('CONFIRMATION',{['The current image series is assumed by default in the plane of the calib points z=' num2str(Z_plane) ] ; 'can be modified by MenuSetSlice in the upper bar menu of uvmat'})
     357%     input_key={'Z (first position)','Z (last position)','Z (water surface)', 'refractive index','NbSlice','volume scan (y/n)','tilt angle y axis','tilt angle x axis'};
     358%     input_val=[{num2str(ZEnd)} {num2str(ZStart)} {num2str(ZStart)} {'1.333'} num2str(NbSlice_j) {volume_scan} {'0'} {'0'}];
     359%     answer=inputdlg(input_key,'slice position(s)',ones(1,8), input_val,'on');
     360%     GeometryCalib.NbSlice=str2double(answer{5});
     361%     GeometryCalib.VolumeScan=answer{6};
     362%     if isempty(answer)
     363%         Z_plane=0; %default
     364%     else
     365%         Z_plane=linspace(str2double(answer{1}),str2double(answer{2}),GeometryCalib.NbSlice);
     366%     end
     367     GeometryCalib.SliceCoord=Z_plane'*[0 0 1];
     368%     GeometryCalib.SliceAngle(:,3)=0;
     369%     GeometryCalib.SliceAngle(:,2)=str2double(answer{7})*ones(GeometryCalib.NbSlice,1);%rotation around y axis (to generalise)
     370%     GeometryCalib.SliceAngle(:,1)=str2double(answer{8})*ones(GeometryCalib.NbSlice,1);%rotation around x axis (to generalise)
     371%     GeometryCalib.InterfaceCoord=[0 0 str2double(answer{3})];
     372%     GeometryCalib.RefractionIndex=str2double(answer{4});
     373end
     374
     375%------------------------------------------------------------------------
     376% --- determine the parameters for a calibration by an affine function (rescaling and offset, no rotation)
    386377function GeometryCalib=calib_rescale(Coord,handles)
    387378%------------------------------------------------------------------------
     
    401392
    402393%------------------------------------------------------------------------
    403 % determine the parameters for a calibration by a linear transform matrix (rescale and rotation)
    404 
    405 
     394% --- determine the parameters for a calibration by a linear transform matrix (rescale and rotation)
    406395function GeometryCalib=calib_linear(Coord,handles)
    407396%------------------------------------------------------------------------
     
    432421
    433422%------------------------------------------------------------------------
    434 % determine the tsai parameters for a view normal to the grid plane
     423% --- determine the tsai parameters for a view normal to the grid plane
    435424% NOT USED
    436425function GeometryCalib=calib_normal(Coord,handles)
     
    498487%------------------------------------------------------------------------
    499488function GeometryCalib=calib_3D_linear(Coord,handles)
    500 %------------------------------------------------------------------
     489%------------------------------------------------------------------------
    501490path_uvmat=which('uvmat');% check the path detected for source file uvmat
    502491path_UVMAT=fileparts(path_uvmat); %path to UVMAT
     
    708697% --- determine the rms of calibration error
    709698function ErrorRms=error_calib(calib_param,Calib,Coord)
     699%------------------------------------------------------------------------
    710700%calib_param: vector of free calibration parameters (to optimise)
    711701%Calib: structure of the given calibration parameters
     
    734724ErrorRms=mean(ErrorRms);
    735725
    736 % %------------------------------------------------------------------------
    737 % function XImage_Callback(hObject, eventdata, handles)
    738 % %------------------------------------------------------------------------
    739 % update_list(hObject, eventdata,handles)
    740 %
    741 % %------------------------------------------------------------------------
    742 % function YImage_Callback(hObject, eventdata, handles)
    743 % %------------------------------------------------------------------------
    744 % update_list(hObject, eventdata,handles)
    745726
    746727%------------------------------------------------------------------------
    747728% --- Executes on button press in STORE.
    748729function STORE_Callback(hObject, eventdata, handles)
     730%------------------------------------------------------------------------
    749731Coord=get(handles.ListCoord,'Data');
    750732%Object=read_geometry_calib(Coord_cell);
     
    761743    RootPath=get(hhuvmat.RootPath,'String');
    762744    RootFile=get(hhuvmat.RootFile,'String');
    763     filebase=fullfile(RootPath,RootFile);
     745    filebase=[fullfile(RootPath,RootFile) '~'];
    764746    while exist([filebase '.xml'],'file')
    765747        filebase=[filebase '~'];
     
    778760    set(handles.ListCoordFiles,'string',listfile);
    779761end
    780 set(handles.ListCoord,'Data',[])
     762CLEAR_PTS_Callback(hObject, eventdata, handles)% clear the current list and point plots
    781763
    782764% --------------------------------------------------------------------
     
    786768set(handles.ListCoord,'Data',[])
    787769PLOT_Callback(hObject, eventdata, handles)
    788 
    789 %------------------------------------------------------------------------
    790 % --- Executes on button press in CLEAR.
     770update_calib_marker([]);%remove circle marker
     771set(handles.APPLY,'backgroundColor',[1 0 0])% set APPLY button to red color: no calibration wanted without points
     772set(handles.CheckEnableMouse,'value',1); %activate mouse to pick new points
     773
     774%------------------------------------------------------------------------
     775% --- Executes on button press in CLEAR LIST
    791776function CLEAR_Callback(hObject, eventdata, handles)
    792777%------------------------------------------------------------------------
     
    800785choice=get(handles.CheckEnableMouse,'Value');
    801786if choice
    802     set(handles.CheckEnableMouse,'BackgroundColor',[1 1 0])
    803787    huvmat=findobj(allchild(0),'tag','uvmat');
    804788    if ishandle(huvmat)
    805789        hhuvmat=guidata(huvmat);
     790        set(hhuvmat.MenuRuler,'checked','off')%desactivate ruler
    806791        if get(hhuvmat.CheckEditObject,'Value')
    807         set(hhuvmat.CheckEditObject,'Value',0)
    808         uvmat('CheckEditObject_Callback',hhuvmat.CheckEditObject,[],hhuvmat)
     792            set(hhuvmat.CheckEditObject,'Value',0)
     793            uvmat('CheckEditObject_Callback',hhuvmat.CheckEditObject,[],hhuvmat)
    809794        end
    810     end
    811 else
    812     set(handles.CheckEnableMouse,'BackgroundColor',[0.7 0.7 0.7])
     795        set(hhuvmat.MenuRuler,'checked','off')%desactivate ruler
     796    end
    813797end
    814798
     
    841825set(handles.ListCoord,'Data',Coord)
    842826set(handles.APPLY,'BackgroundColor',[1 0 1])
     827set(handles.CheckEnableMouse,'value',0); %desactivate mouse to avoid spurious points
    843828
    844829%------------------------------------------------------------------------
     
    858843set(handles.ListCoord,'Data',Coord)
    859844set(handles.APPLY,'BackgroundColor',[1 0 1])
     845set(handles.CheckEnableMouse,'value',0); %desactivate mouse to avoid spurious points
    860846
    861847% -----------------------------------------------------------------------
     
    1002988PLOT_Callback(hObject, eventdata, handles)
    1003989set(handles.APPLY,'BackgroundColor',[1 0 1])
    1004 
    1005 % figure(10)
    1006 % hold off
    1007 % imagesc(Amod)
    1008 % hold on
    1009 % plot(Tmod(:,1),Tmod(:,2),'+')
     990set(handles.CheckEnableMouse,'value',0); %desactivate mouse to avoid spurious points
    1010991
    1011992
     
    10851066PLOT_Callback(handles.geometry_calib, [], handles)
    10861067set(handles.APPLY,'BackgroundColor',[1 0 1])
     1068set(handles.CheckEnableMouse,'value',0); %desactivate mouse to avoid modifications by default
    10871069
    10881070% -----------------------------------------------------------------------
     
    11041086    loadfile(handles,fileinput)
    11051087end
     1088set(handles.CheckEnableMouse,'value',0); %desactivate mouse to avoid modifications by default
    11061089
    11071090% -----------------------------------------------------------------------
     
    11161099    listfile=[listfile;{inputfile}];%update the list of coord files
    11171100end
    1118 set(handles.ListCoordFiles,'string',listfile);
     1101set(handles.ListCoordFiles,'String',listfile);
    11191102
    11201103
     
    12431226menu=get(h_menu_coord,'String');
    12441227choice=get(h_menu_coord,'Value');
     1228option='';
    12451229if iscell(menu)
    12461230    option=menu{choice};
    1247 else
    1248     option='px'; %default
    12491231end
    12501232Coord=get(handles.ListCoord,'Data');
     
    12521234    if isequal(option,'phys')
    12531235        Coord_plot=Coord(:,1:3);
    1254     elseif isequal(option,'px')||isequal(option,'')
     1236    elseif isempty(option);%optionoption,'px')||isequal(option,'')
    12551237        Coord_plot=Coord(:,4:5);
    12561238    else
    1257         msgbox_uvmat('ERROR','the choice in menu_coord of uvmat must be blank, px or phys ')
     1239        msgbox_uvmat('ERROR','the choice in menu_coord of uvmat must be blank or phys ')
    12581240    end
    12591241end
     
    12901272if ~isempty(eventdata.Indices)
    12911273    iline=eventdata.Indices(1);% selected line number
    1292     Data=get(handles.ListCoord,'Data');
    1293     Data(:,6)=zeros(size(Data,1),1);
    1294     Data(iline,6)=-1;% mark the selected line
    1295     set(handles.ListCoord,'Data',Data)
    1296     update_calib_marker(Data(iline,:))
     1274    set(handles.CoordLine,'String',num2str(iline))
     1275     Data=get(handles.ListCoord,'Data');
     1276     update_calib_marker(Data(iline,:))
    12971277end
    12981278
     
    13161296%------------------------------------------------------------------------
    13171297function ListCoord_KeyPressFcn(hObject, eventdata, handles)
     1298iline=str2num(get(handles.CoordLine,'String'));
    13181299xx=double(get(handles.geometry_calib,'CurrentCharacter'));%get the keyboard character
    1319 if ismember(xx,[30 31 127])% arrow upward, downward, or delete
     1300if ismember(xx,[28 29 30 31])% directional arrow
    13201301    Coord=get(handles.ListCoord,'Data');
    1321     ind=find(Coord(:,6));%find the marker '+' for line selection
    1322     Coord(:,6)=zeros(size(Coord,1),1);% desactivate the current line mark
    13231302    switch xx
    13241303        case 30 % arrow upward
    1325             Coord(ind-1,6)=1;
     1304            iline=iline-1;
    13261305        case 31% arrow downward
    1327             Coord(ind+1,6)=1;
    1328         case 127% remove line
    1329             Coord(ind,:)=[];
    1330             PLOT_Callback(hObject,eventdata,handles)
    1331             set(handles.APPLY,'BackgroundColor',[1 0 1])
    1332         otherwise
    1333     end
    1334     set(handles.ListCoord,'Data',Coord);
     1306            iline=iline+1;
     1307    end
     1308    if iline>=1 && iline<=size(Coord,1)
     1309        set(handles.CoordLine,'String',num2str(iline))
     1310        update_calib_marker(Coord(iline,1:5))% show the point corresponding to the selected line
     1311    end
    13351312else
    1336     set(handles.APPLY,'BackgroundColor',[1 0 1])
     1313    set(handles.APPLY,'BackgroundColor',[1 0 1])% paint APPLY in magenta to indicate that the table content has be modified
    13371314end
    13381315
     
    13411318% --- update the plot of calibration points
    13421319%------------------------------------------------------------------------
     1320% draw a circle around the point defined by the input coordinates Coord as given by line in the table Listcoord
    13431321function update_calib_marker(Coord)
    1344 %% update the plot on uvmat
     1322
     1323%% read config on uvmat
    13451324huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle
    1346 hplot=findobj(huvmat,'Tag','PlotAxes');%main plotting axis of uvmat
    1347 hhh=findobj(hplot,'Tag','calib_marker');
    1348 
    1349 h_menu_coord=findobj(huvmat,'Tag','TransformName');
    1350 menu=get(h_menu_coord,'String');
    1351 choice=get(h_menu_coord,'Value');
     1325hhuvmat=guidata(huvmat);
     1326hhh=findobj(hhuvmat.PlotAxes,'Tag','calib_marker');
     1327if numel(Coord)<5
     1328    if ~isempty(hhh)
     1329        delete(hhh)%delete the circle marker in case of no valid input
     1330    end
     1331    return
     1332end
     1333menu=get(hhuvmat.TransformName,'String');
     1334choice=get(hhuvmat.TransformName,'Value');
     1335option='';
    13521336if iscell(menu)
    13531337    option=menu{choice};
    1354 else
    1355     option='px'; %default
    1356 end
    1357 if isequal(option,'phys')
     1338end
     1339
     1340%% read appropriate coordinates (px or phys) in the table ListCoord
     1341if isequal(option,'phys') % use phys coord
    13581342    XCoord=Coord(1);
    13591343    YCoord=Coord(2);
    1360 elseif isequal(option,'px')|| isequal(option,'')
     1344elseif isempty(option)% use coord in pixels
    13611345    XCoord=Coord(4);
    13621346    YCoord=Coord(5);
    13631347else
    1364     msgbox_uvmat('ERROR','the choice in menu_coord of uvmat must be blank, px or phys ')
    1365 end
    1366 if isempty(XCoord)||isempty(YCoord)
    1367      if ~isempty(hhh)
    1368         delete(hhh)%delete the circle marker
    1369     end
     1348    msgbox_uvmat('ERROR','the choice in menu_coord of uvmat must be blank or phys ')
    13701349    return
    13711350end
    1372 xlim=get(hplot,'XLim');
    1373 ylim=get(hplot,'YLim');
    1374 ind_range=max(abs(xlim(2)-xlim(1)),abs(ylim(end)-ylim(1)))/20;%defines the size of the circle marker
     1351
     1352%% adjust the plot limits if needed
     1353xlim=get(hhuvmat.PlotAxes,'XLim');
     1354ylim=get(hhuvmat.PlotAxes,'YLim');
     1355ind_range=max(abs(xlim(2)-xlim(1)),abs(ylim(end)-ylim(1)))/25;%defines the size of the circle marker
     1356check_xlim=0;
     1357if XCoord>xlim(2)
     1358    xlim=xlim+XCoord-xlim(2)+ind_range;% translate plot limit
     1359    check_xlim=1;
     1360elseif XCoord<xlim(1)
     1361    xlim=xlim-XCoord+xlim(1)-ind_range;% translate plot limit
     1362    check_xlim=1;
     1363end
     1364if check_xlim
     1365    set(hhuvmat.PlotAxes,'XLim',xlim);
     1366    set(hhuvmat.num_MaxX,'String',num2str(xlim(2)));
     1367    set(hhuvmat.num_MinX,'String',num2str(xlim(1)));
     1368end
     1369check_ylim=0;
     1370if YCoord>ylim(2)
     1371    ylim=ylim+YCoord-ylim(2)+ind_range;% translate plot limit
     1372    check_ylim=1;
     1373elseif YCoord<ylim(1)
     1374    ylim=ylim-YCoord+ylim(1)-ind_range;% translate plot limit
     1375    check_ylim=1;
     1376end
     1377if check_ylim
     1378    set(hhuvmat.PlotAxes,'YLim',ylim);
     1379    set(hhuvmat.num_MaxY,'String',num2str(ylim(2)));
     1380    set(hhuvmat.num_MinY,'String',num2str(ylim(1)));
     1381end
     1382
     1383%% plot a circle around the selected point
    13751384if isempty(hhh)
    13761385    set(0,'CurrentFig',huvmat)
    1377     set(huvmat,'CurrentAxes',hplot)
     1386    set(huvmat,'CurrentAxes',hhuvmat.PlotAxes)
    13781387    rectangle('Curvature',[1 1],...
    1379               'Position',[XCoord-ind_range/2 YCoord-ind_range/2 ind_range ind_range],'EdgeColor','m',...
    1380               'LineStyle','-','Tag','calib_marker');
     1388        'Position',[XCoord-ind_range/2 YCoord-ind_range/2 ind_range ind_range],'EdgeColor','m',...
     1389        'LineStyle','-','Tag','calib_marker');
    13811390else
    13821391    set(hhh,'Position',[XCoord-ind_range/2 YCoord-ind_range/2 ind_range ind_range])
     
    13891398
    13901399Coord=get(handles.ListCoord,'Data');
    1391 ind=find(Coord(:,6));%find the marker '-' for line selection
    1392 if isempty(ind)
     1400iline=str2num(get(handles.CoordLine,'String'));
     1401if isempty(iline)
    13931402    msgbox_uvmat('WARNING','no line suppressed, select a line in the table')
    13941403else
    1395     answer=msgbox_uvmat('INPUT_Y-N',['suppress line ' num2str(ind) '?']);
     1404    answer=msgbox_uvmat('INPUT_Y-N',['suppress line ' num2str(iline) '?']);
    13961405    if isequal(answer,'Yes')
    1397 Coord(:,6)=zeros(size(Coord,1),1);% desactivate the current line mark
    1398 Coord(ind,:)=[];
    1399 PLOT_Callback(hObject,eventdata,handles)
    1400 set(handles.APPLY,'BackgroundColor',[1 0 1])
    1401 set(handles.ListCoord,'Data',Coord);
    1402     end
    1403 end
     1406        Coord(iline,:)=[];
     1407        set(handles.APPLY,'BackgroundColor',[1 0 1])
     1408        set(handles.ListCoord,'Data',Coord);
     1409        set(handles.CoordLine,'String','')
     1410        PLOT_Callback(hObject,eventdata,handles)
     1411        update_calib_marker([]);%remove circle marker
     1412    end
     1413end
     1414
  • trunk/src/mouse_motion.m

    r714 r738  
    403403        if isnumeric(data.Coord)&&~isempty(data.Coord)
    404404            if test_transform
    405                             XCoord=(data.Coord(:,1));
    406             YCoord=(data.Coord(:,2));
     405                XCoord=(data.Coord(:,1));
     406                YCoord=(data.Coord(:,2));
    407407            else
    408             XCoord=(data.Coord(:,4));
    409             YCoord=(data.Coord(:,5));
     408                XCoord=(data.Coord(:,4));
     409                YCoord=(data.Coord(:,5));
    410410            end
    411411            xy=get(CurrentAxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
    412412            if ~isempty(xy)
    413413                xlim=get(CurrentAxes,'XLim');
    414                 ind_range_x=abs((xlim(2)-xlim(1))/50);
     414%                 ind_range_x=abs((xlim(2)-xlim(1))/50);
    415415                ylim=get(CurrentAxes,'YLim');
    416                 ind_range_y=abs((ylim(2)-ylim(1))/50);
    417                 ind_range=sqrt(ind_range_x*ind_range_y);
    418                 index_point=find((XCoord<xy(1,1)+ind_range) & (XCoord>xy(1,1)-ind_range) & ...%flagx=1 for the vectors with x position selected by the mouse
    419                               (YCoord<xy(1,2)+ind_range) & (YCoord>xy(1,2)-ind_range),1);%find the first calibration point in the neighborhood of the mouse
     416                ind_range=max(abs(xlim(2)-xlim(1)),abs(ylim(end)-ylim(1)))/25;%defines the size of the circle marker
     417%                 ind_range_y=abs((ylim(2)-ylim(1))/50);
     418%                 ind_range=sqrt(ind_range_x*ind_range_y);
     419                index_point=find((XCoord<xy(1,1)+ind_range/2) & (XCoord>xy(1,1)-ind_range/2) & ...%flagx=1 for the vectors with x position selected by the mouse
     420                    (YCoord<xy(1,2)+ind_range/2) & (YCoord>xy(1,2)-ind_range/2),1);%find the first calibration point in the neighborhood of the mouse
    420421                if ~isempty(index_point)
    421                     pointershape='arrow';% default pointer is an arrow 
     422                    pointershape='arrow';% default pointer is an arrow
    422423                end
    423424                hh=findobj('Tag','calib_points');%look for handle of calibration points
    424                if ~isempty(hh) && ~isempty(get(hh,'UserData')) %&& get(hh_geometry_calib.CheckEnableMouse,'Value')
    425                    %set(hh,'UserData',index_point)
     425                if ~isempty(hh) && ~isempty(get(hh,'UserData')) %&& get(hh_geometry_calib.CheckEnableMouse,'Value')
     426                    %set(hh,'UserData',index_point)
    426427                    index_point=get(hh,'UserData');
    427428                    XCoord(index_point)=xy(1,1);
     
    429430                    set(hh,'XData',XCoord)
    430431                    set(hh,'YData',YCoord)
    431                end
     432                end
    432433                if ~isempty(index_point)
    433                     Data=get(h_ListCoord,'Data');
    434                     Data(:,6)=zeros(size(Data,1),1);
    435                     Data(index_point,6)=-1;%mrk the point on the GUI geometry_calib
    436                     set(h_ListCoord,'Data',Data);
     434                    set(hh_geometry_calib.CoordLine,'String',num2str(index_point))
     435                   % Data=get(h_ListCoord,'Data');
     436%                     Data(:,6)=zeros(size(Data,1),1);
     437%                     Data(index_point,6)=-1;%mrk the point on the GUI geometry_calib
     438%                     set(h_ListCoord,'Data',Data);
    437439                    hhh=findobj('Tag','calib_marker');%look for handle of point marker (circle)
    438440                    if ~isempty(hhh)
    439441                        set(hhh,'Position',[XCoord(index_point)-ind_range/2 YCoord(index_point)-ind_range/2 ind_range ind_range])
    440442                    else
    441                                     rectangle('Curvature',[1 1],...
    442                 'Position',[xy(1,1)-ind_range/2 xy(1,2)-ind_range/2 ind_range ind_range],'EdgeColor','m',...
    443                 'LineStyle','-','Tag','calib_marker');
     443                        rectangle('Curvature',[1 1],...
     444                            'Position',[XCoord(index_point)-ind_range/2 YCoord(index_point)-ind_range/2 ind_range ind_range],'EdgeColor','m',...
     445                            'LineStyle','-','Tag','calib_marker');
    444446                    end
    445447                end
  • trunk/src/mouse_up.m

    r714 r738  
    349349%% finalising ruler
    350350if test_ruler && ~isempty(xy)
    351     set(hhuvmat.MenuRuler,'checked','off')%desable the ruler option in uvmat
     351    %set(hhuvmat.MenuRuler,'checked','off')%desable the ruler option in uvmat
    352352    xy=get(hcurrentaxes,'CurrentPoint');% get the current mouse coordinates
    353353    RulerCoord=[AxeData.RulerCoord ;xy(1,1:2)];% append the recorded ruler origin to the current mouse coordinates
  • trunk/src/proj_field.m

    r735 r738  
    920920
    921921%% extrema along each axis
    922 testXMin=0;
    923 testXMax=0;
    924 testYMin=0;
    925 testYMax=0;
    926 if isfield(ObjectData,'RangeX')
     922testXMin=0;% test if min of X coordinates defined on the projection object, =0 by default
     923testXMax=0;% test if max of X coordinates defined on the projection object, =0 by default
     924testYMin=0;% test if min of Y coordinates defined on the projection object, =0 by default
     925testYMax=0;% test if max of Y coordinates defined on the projection object, =0 by default
     926if isfield(ObjectData,'RangeX') % rangeX defined by the projection object
    927927    XMin=min(ObjectData.RangeX);
    928928    XMax=max(ObjectData.RangeX);
    929     testXMin=XMax>XMin;%=1 if XMin defined (i.e. RangeY has tow distinct elements)
    930     testXMax=1;% range restriction along X
    931 end
    932 if isfield(ObjectData,'RangeY')
     929    testXMin=XMax>XMin;%=1 if XMin defined (i.e. RangeY has two distinct elements)
     930    testXMax=1;% max of X coordinates defined on the projection object
     931end
     932if isfield(ObjectData,'RangeY') % rangeY defined by the projection object
    933933    YMin=min(ObjectData.RangeY);
    934934    YMax=max(ObjectData.RangeY);
    935935    testYMin=YMax>YMin;%=1 if YMin defined (i.e. RangeY has tow distinct elements)
    936     testYMax=1;
     936    testYMax=1;% max of Y coordinates defined on the projection object
    937937end
    938938width=0;%default width of the projection band
     
    13711371                    end
    13721372                end
    1373             else       % case with interpolation
     1373            else       % case with interpolation on a grid
    13741374                if NbDim==2 %2D case
    13751375                    if isequal(ProjMode{icell},'interp_tps')
     
    13831383                    Coord{1}=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(1)});
    13841384                    Coord{2}=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(2)});
    1385                     xcorner=[min(Coord{NbDim}) max(Coord{NbDim}) max(Coord{NbDim}) min(Coord{NbDim})]-ObjectData.Coord(1,1);% corner absissa of the original grid with respect to the new origin
    1386                     ycorner=[min(Coord{NbDim-1}) min(Coord{NbDim-1}) max(Coord{NbDim-1}) max(Coord{NbDim-1})]-ObjectData.Coord(1,2);% corner ordinates of the original grid
    1387                     xcor_new=xcorner*cos(PlaneAngle(3))+ycorner*sin(PlaneAngle(3));%coordinates of the corners in new frame
    1388                     ycor_new=-xcorner*sin(PlaneAngle(3))+ycorner*cos(PlaneAngle(3));
    1389                     if testXMin
    1390                         xcor_new=max(xcor_new,XMin);
    1391                     end
    1392                     if testXMax
    1393                         xcor_new=min(xcor_new,XMax);
    1394                     end
    1395                     if testYMin
    1396                         ycor_new=max(ycor_new,YMin);
    1397                     end
    1398                     if testYMax
    1399                         ycor_new=min(ycor_new,YMax);
    1400                     end
    1401                     coord_x_proj=min(xcor_new):DX:max(xcor_new);
    1402                     coord_y_proj=min(ycor_new):DY:max(ycor_new);
     1385                    if ~(testXMin && testYMin)% % if the range of the projected coordinates is not fully defined by the projection object, find the extrema of the projected field
     1386                        xcorner=[min(Coord{NbDim}) max(Coord{NbDim}) max(Coord{NbDim}) min(Coord{NbDim})]-ObjectData.Coord(1,1);% corner absissa of the original grid with respect to the new origin
     1387                        ycorner=[min(Coord{NbDim-1}) min(Coord{NbDim-1}) max(Coord{NbDim-1}) max(Coord{NbDim-1})]-ObjectData.Coord(1,2);% corner ordinates of the original grid
     1388                        xcor_new=xcorner*cos(PlaneAngle(3))+ycorner*sin(PlaneAngle(3));%coordinates of the corners in new frame
     1389                        ycor_new=-xcorner*sin(PlaneAngle(3))+ycorner*cos(PlaneAngle(3));
     1390                        if ~testXMin
     1391                            XMin=min(xcor_new);
     1392                        end
     1393                        if ~testXMax
     1394                            XMax=max(xcor_new);
     1395                        end
     1396                        if ~testYMin
     1397                            YMin=min(ycor_new);
     1398                        end
     1399                        if ~testYMax
     1400                            YMax=max(ycor_new);
     1401                        end
     1402                    end
     1403                    coord_x_proj=XMin:DX:XMax;
     1404                    coord_y_proj=YMin:DY:YMax;
    14031405                    ProjData.(AYName)=[coord_y_proj(1) coord_y_proj(end)]; %record the new (projected ) y coordinates
    14041406                    ProjData.(AXName)=[coord_x_proj(1) coord_x_proj(end)]; %record the new (projected ) x coordinates
  • trunk/src/set_object.m

    r729 r738  
    3636function varargout = set_object(varargin)
    3737
    38 % Last Modified by GUIDE v2.5 11-Feb-2014 20:08:17
     38% Last Modified by GUIDE v2.5 13-Apr-2014 19:31:58
    3939
    4040% Begin initialization code - DO NOT REFRESH
     
    594594set(handles.num_RangeY_2,'BackgroundColor',[1 1 1])
    595595
    596 %------------------------------------------------------------------------
    597 % --- Executes on button press in MenuCoord.
    598 function MenuCoord_Callback(hObject, eventdata, handles)
    599 %------------------------------------------------------------------------
     596% --- Executes on button press in ExportCoord.
     597function ExportCoord_Callback(hObject, eventdata, handles)
     598global Coord
     599Coord=get(handles.Coord,'Data');
     600evalin('base','global Coord')%make Coord global in the workspace
     601display('object coordinates:')
     602evalin('base','Coord') %display Coord in the workspace
     603commandwindow; %brings the Matlab command window to the front
     604
    600605%----------------------------------------------------
    601606function num_RangeY_1_Callback(hObject, eventdata, handles)
     
    785790    set(handles.Coord,'Data',Coord);
    786791end
     792
     793
     794
     795
  • trunk/src/uvmat.m

    r735 r738  
    38113811
    38123812%% delete drawn objects if the output CooordUnit is different from the previous one
    3813 if ~strcmp(CoordUnit,CoordUnitPrev)
     3813if  ~strcmp(CoordUnit,CoordUnitPrev)
    38143814    set(handles.CheckFixLimits,'Value',0)
    3815 % set(handles.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7])
    38163815    hother=findobj('Tag','proj_object');%find all the proj objects
    38173816    for iobj=1:length(hother)
     
    45444543    UvData.ProjObject(IndexObj)=[];
    45454544end
    4546     if ~isempty(list_str)
    4547         list_str(IndexObj)=[];
    4548     end
    4549 % end
     4545if numel(list_str)>=IndexObj
     4546    list_str(IndexObj)=[];
     4547end
    45504548set(huvmat,'UserData',UvData);
    45514549set(hlist_object,'String',list_str)
     
    48374835%------------------------------------------------------------------------
    48384836%% desactivate concurrent tools
     4837set(handles.MenuRuler,'checked','off')%desactivate ruler
    48394838hgeometry_calib=findobj(allchild(0),'tag','geometry_calib');% search the GUI geometric calibration
    48404839if ishandle(hgeometry_calib)
     
    49454944function MenuCalib_Callback(hObject, eventdata, handles)
    49464945%------------------------------------------------------------------------
    4947 
     4946%% suppress the second field if exists
     4947if get(handles.SubField,'Value')
     4948    set(handles.SubField,'Value',0)
     4949    SubField_Callback(hObject, eventdata, handles)
     4950end
    49484951UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
    49494952
    4950 %suppress competing options
     4953%% suppress competing tools
     4954set(handles.MenuRuler,'checked','off')%desactivate ruler
    49514955set(handles.CheckZoom,'Value',0)
    49524956set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7])
    4953 set(handles.ListObject,'Value',1)     
    4954 % initiate display of GUI geometry_calib
     4957set(handles.ListObject,'Value',1)
     4958
     4959%% initiate display of the GUI geometry_calib
    49554960data=[]; %default
    49564961if isfield(UvData,'CoordType')
     
    49644969set(handles.MenuCalib,'checked','on')% indicate that MenuCalib is activated, test used by mouse action
    49654970
     4971
     4972% --------------------------------------------------------------------
     4973% --- set the slice plane ro the set of slice planes when volume scan is used
     4974function MenuSetSlice_Callback(hObject, eventdata, handles)
     4975% --------------------------------------------------------------------
     4976%% suppress the second input field if exists
     4977if get(handles.SubField,'Value')
     4978    set(handles.SubField,'Value',0)
     4979    SubField_Callback(hObject, eventdata, handles)
     4980end
     4981
     4982UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
     4983check=0;
     4984if isfield(UvData,'XmlData')&&isfield(UvData.XmlData{1},'GeometryCalib')&& isfield(UvData.XmlData{1}.GeometryCalib,'SliceCoord')
     4985    GeometryCalib=UvData.XmlData{1}.GeometryCalib;
     4986    SliceCoord=GeometryCalib.SliceCoord;
     4987else
     4988    msgbox_uvmat('ERROR','3D geometric calibration needed before defining slices')
     4989    return
     4990end   
     4991NbSlice_j=1;%default
     4992Z=SliceCoord(:,3);
     4993% index=index(ind_dim);
     4994%set the Z position of the reference plane used for calibration
     4995if isequal(max(Z),min(Z))%Z constant
     4996    Z_plane=Z(1);
     4997    GeometryCalib.NbSlice=1;
     4998    GeometryCalib.SliceCoord=[0 0 Z_plane];
     4999end
     5000ZStart=SliceCoord(1,3);% first Z coordinate present in the calibration file
     5001ZEnd=SliceCoord(end,3);% last Z coordinate present in the calibration file
     5002volume_scan='n';
     5003if isfield(UvData,'XmlData')
     5004    if isfield(UvData.XmlData{1},'TranslationMotor')
     5005        NbSlice_j=UvData.XmlData.TranslationMotor.Nbslice;
     5006        ZStart=UvData.XmlData.TranslationMotor.ZStart/10;
     5007        ZEnd=UvData.XmlData.TranslationMotor.ZEnd/10;
     5008        volume_scan='y';
     5009    end
     5010end     
     5011input_key={'Z (first position)','Z (last position)','Z (water surface)', 'refractive index','NbSlice','volume scan (y/n)','tilt angle y axis','tilt angle x axis'};
     5012input_val=[{num2str(ZEnd)} {num2str(ZStart)} {num2str(ZStart)} {'1.333'} num2str(NbSlice_j) {volume_scan} {'0'} {'0'}];
     5013answer=inputdlg(input_key,'slice position(s)',ones(1,8), input_val,'on');
     5014GeometryCalib.NbSlice=str2double(answer{5});
     5015GeometryCalib.VolumeScan=answer{6};
     5016if isempty(answer)
     5017    Z_plane=0; %default
     5018else
     5019    Z_plane=linspace(str2double(answer{1}),str2double(answer{2}),GeometryCalib.NbSlice);
     5020end
     5021GeometryCalib.SliceCoord=Z_plane'*[0 0 1];
     5022GeometryCalib.SliceAngle(:,3)=0;
     5023GeometryCalib.SliceAngle(:,2)=str2double(answer{7})*ones(GeometryCalib.NbSlice,1);%rotation around y axis (to generalise)
     5024GeometryCalib.SliceAngle(:,1)=str2double(answer{8})*ones(GeometryCalib.NbSlice,1);%rotation around x axis (to generalise)
     5025GeometryCalib.InterfaceCoord=[0 0 str2double(answer{3})];
     5026GeometryCalib.RefractionIndex=str2double(answer{4});
     5027
     5028%% store the result in the xml file used for calibration
     5029[RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);
     5030FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];%name of the xml file for calibration
     5031[RootPath,SubDir,RootFile,tild,tild,tild,tild,FileExt]=fileparts_uvmat(FileName);
     5032XmlFile=find_imadoc(RootPath,SubDir,RootFile,FileExt);
     5033errormsg=update_imadoc(GeometryCalib,XmlFile,'GeometryCalib');% introduce the calibration data in the xml file
     5034if ~strcmp(errormsg,'')
     5035    msgbox_uvmat('ERROR',errormsg);
     5036end
     5037
     5038%% display image with new calibration in the currently opened uvmat interface
     5039set(handles.CheckFixLimits,'Value',0)% put FixedLimits option to 'off' to plot the whole image
     5040InputFileREFRESH_Callback(hObject,eventdata,handles); %file input with xml reading  in uvmat, show the image in phys coordinates
    49665041
    49675042%-----------------------------------------------------------------------
     
    52345309function MenuRuler_Callback(hObject, eventdata, handles)
    52355310%------------------------------------------------------------------------
    5236 set(handles.CheckZoom,'Value',0)
    5237 CheckZoom_Callback(handles.uvmat, [], handles)
    5238 set(handles.MenuRuler,'checked','on')
    5239 UvData=get(handles.uvmat,'UserData');
    5240 UvData.MouseAction='ruler';
    5241 set(handles.uvmat,'UserData',UvData);
     5311if strcmp(get(handles.MenuRuler,'checked'),'on')
     5312    set(handles.MenuRuler,'checked','off')%desactivate if activated
     5313else
     5314    set(handles.MenuRuler,'checked','on')%activate if selected
     5315    set(handles.CheckZoom,'Value',0)
     5316    CheckZoom_Callback(handles.uvmat, [], handles)
     5317    UvData=get(handles.uvmat,'UserData');
     5318    UvData.MouseAction='ruler';
     5319    set(handles.uvmat,'UserData',UvData);
     5320end
    52425321
    52435322%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     
    54535532end
    54545533
    5455 
     5534% --------------------------------------------------------------------
    54565535% --- Executes on button press in CheckTable.
     5536% --------------------------------------------------------------------
    54575537function CheckTable_Callback(hObject, eventdata, handles)
    54585538if get(handles.CheckTable,'Value')
Note: See TracChangeset for help on using the changeset viewer.