Changeset 682 for trunk


Ignore:
Timestamp:
Sep 2, 2013, 7:44:19 PM (11 years ago)
Author:
sommeria
Message:

various bugs repaired

Location:
trunk/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/geometry_calib.m

    r680 r682  
    5050% Edit the above text to modify the response to help geometry_calib
    5151
    52 % Last Modified by GUIDE v2.5 31-Jul-2013 23:03:18
     52% Last Modified by GUIDE v2.5 02-Sep-2013 16:47:27
    5353
    5454% Begin initialization code - DO NOT edit
     
    147147end
    148148
    149 set(handles.ListCoord,'KeyPressFcn',{@key_press_fcn,handles})%set keyboard action function
    150 
    151 
    152149%------------------------------------------------------------------------
    153150% --- Outputs from this function are returned to the command line.
     
    181178%------------------------------------------------------------------------
    182179%% look for the GUI uvmat and check for an image as input
     180set(handles.APPLY,'BackgroundColor',[1 1 0])
    183181huvmat=findobj(allchild(0),'Name','uvmat');
    184182hhuvmat=guidata(huvmat);%handles of elements in the GUI uvmat
     
    198196[GeometryCalib,index]=calibrate(handles,hhuvmat);% apply calibration
    199197
    200 %% copy the xml file from the old location if appropriate, then update with the calibration parameters
    201 if ~exist(outputfile,'file') && ~isempty(SubDirBase)
    202     oldxml=[fullfile(RootPath,SubDirBase,get(hhuvmat.RootFile,'String')) '.xml'];
    203     if exist(oldxml,'file')
    204         [success,message]=copyfile(oldxml,outputfile);%copy the old xml file to a new one with the new convention
    205     end
    206 end
    207 errormsg=update_imadoc(GeometryCalib,outputfile,'GeometryCalib');% introduce the calibration data in the xml file
    208 if ~strcmp(errormsg,'')
    209     msgbox_uvmat('ERROR',errormsg);
    210 end
    211 
    212 %% display image with new calibration in the currently opened uvmat interface
    213 hhh=findobj(hhuvmat.PlotAxes,'Tag','calib_marker');% delete calib points and markers
    214 if ~isempty(hhh)
    215     delete(hhh);
    216 end
    217 hhh=findobj(hhuvmat.PlotAxes,'Tag','calib_points');
    218 if ~isempty(hhh)
    219     delete(hhh);
    220 end
    221 set(hhuvmat.CheckFixLimits,'Value',0)% put FixedLimits option to 'off'
    222 set(hhuvmat.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7])
    223 UserData=get(handles.geometry_calib,'UserData');
    224 UserData.XmlInputFile=outputfile;%save the current xml file name
    225 set(handles.geometry_calib,'UserData',UserData)
    226 uvmat('RootPath_Callback',hObject,eventdata,hhuvmat); %file input with xml reading  in uvmat, show the image in phys coordinates
    227 PLOT_Callback(hObject, eventdata, handles)
    228 Data=get(handles.ListCoord,'Data');
    229 Data(:,6)=zeros(size(Data,1),1);
    230 Data(index,6)=1;% indicate in the list the point with max deviation (possible mistake)
    231 set(handles.ListCoord,'Data',Data)% indicate in the list the point with max deviation (possible mistake)
    232 figure(handles.geometry_calib)
     198if isempty(GeometryCalib) % if calibration cancelled
     199    set(handles.APPLY,'BackgroundColor',[1 0 1])
     200else   % if calibration confirmed
     201   
     202    %% copy the xml file from the old location if appropriate, then update with the calibration parameters
     203    if ~exist(outputfile,'file') && ~isempty(SubDirBase)
     204        oldxml=[fullfile(RootPath,SubDirBase,get(hhuvmat.RootFile,'String')) '.xml'];
     205        if exist(oldxml,'file')
     206            [success,message]=copyfile(oldxml,outputfile);%copy the old xml file to a new one with the new convention
     207        end
     208    end
     209    errormsg=update_imadoc(GeometryCalib,outputfile,'GeometryCalib');% introduce the calibration data in the xml file
     210    if ~strcmp(errormsg,'')
     211        msgbox_uvmat('ERROR',errormsg);
     212    end
     213   
     214    %% display image with new calibration in the currently opened uvmat interface
     215    hhh=findobj(hhuvmat.PlotAxes,'Tag','calib_marker');% delete calib points and markers
     216    if ~isempty(hhh)
     217        delete(hhh);
     218    end
     219    hhh=findobj(hhuvmat.PlotAxes,'Tag','calib_points');
     220    if ~isempty(hhh)
     221        delete(hhh);
     222    end
     223    set(hhuvmat.CheckFixLimits,'Value',0)% put FixedLimits option to 'off'
     224    set(hhuvmat.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7])
     225    UserData=get(handles.geometry_calib,'UserData');
     226    UserData.XmlInputFile=outputfile;%save the current xml file name
     227    set(handles.geometry_calib,'UserData',UserData)
     228    uvmat('RootPath_Callback',hObject,eventdata,hhuvmat); %file input with xml reading  in uvmat, show the image in phys coordinates
     229    PLOT_Callback(hObject, eventdata, handles)
     230    Data=get(handles.ListCoord,'Data');
     231    Data(:,6)=zeros(size(Data,1),1);
     232    Data(index,6)=1;% indicate in the list the point with max deviation (possible mistake)
     233    set(handles.ListCoord,'Data',Data)% indicate in the list the point with max deviation (possible mistake)
     234    figure(handles.geometry_calib)
     235    set(handles.APPLY,'BackgroundColor',[1 0 0])
     236end
    233237
    234238%------------------------------------------------------------------------
     
    348352%% get plane position(s)
    349353if ~strcmp(answer,'Yes')
     354    GeometryCalib=[];
     355    index=1;
    350356    return
    351357end
     
    773779set(handles.ListCoordFiles,'String',{''})
    774780
    775 % %------------------------------------------------------------------------
    776 % function XObject_Callback(hObject, eventdata, handles)
    777 % %------------------------------------------------------------------------
    778 % update_list(hObject, eventdata,handles)
    779 %
    780 % %------------------------------------------------------------------------
    781 % function YObject_Callback(hObject, eventdata, handles)
    782 % %------------------------------------------------------------------------
    783 % update_list(hObject, eventdata,handles)
    784 %
    785 % %------------------------------------------------------------------------
    786 % function ZObject_Callback(hObject, eventdata, handles)
    787 % %------------------------------------------------------------------------
    788 % update_list(hObject, eventdata,handles)
    789 %
    790 % %------------------------------------------------------------------------
    791 % function update_list(hObject, eventdata, handles)
    792 % %------------------------------------------------------------------------
    793 % newval(4)=str2double(get(handles.XImage,'String'));
    794 % newval(5)=str2double(get(handles.YImage,'String'));
    795 % newval(1)=str2double(get(handles.XObject,'String'));
    796 % newval(2)=str2double(get(handles.YObject,'String'));
    797 % newval(3)=str2double(get(handles.ZObject,'String'));
    798 % if isnan(newval(3))
    799 %     newval(3)=0;%put z to 0 by default
    800 % end
    801 % Coord=get(handles.ListCoord,'String');
    802 % Coord(end)=[]; %remove last string '.....'
    803 % val=get(handles.ListCoord,'Value');
    804 % data=read_geometry_calib(Coord);
    805 % data.Coord(val,:)=newval;
    806 % for i=1:size(data.Coord,1)
    807 %     for j=1:5
    808 %           Coord_cell{i,j}=num2str(data.Coord(i,j),4);%display coordiantes with 4 digits
    809 %     end
    810 % end
    811 %
    812 % Tabchar=cell2tab(Coord_cell,' | ');
    813 % Tabchar=[Tabchar ;{'......'}];
    814 % set(handles.ListCoord,'String',Tabchar)
    815 %
    816 % %update the plot
    817 % ListCoord_Callback(hObject, eventdata, handles)
    818 % PLOT_Callback(hObject, eventdata, handles)
    819 
    820781%------------------------------------------------------------------------
    821782% --- Executes on selection change in CheckEnableMouse.
     
    836797    set(handles.CheckEnableMouse,'BackgroundColor',[0.7 0.7 0.7])
    837798end
    838    
    839 % function NEW_Callback(hObject, eventdata, handles)
    840 % %A METTRE SOUS UN BOUTON
    841 % huvmat=findobj(allchild(0),'Name','uvmat');
    842 % hchild=get(huvmat,'children');
    843 % hcoord=findobj(hchild,'Tag','menu_coord');
    844 % coordtype=get(hcoord,'Value');
    845 % haxes=findobj(hchild,'Tag','axes3');
    846 % AxeData=get(haxes,'UserData');
    847 % if ~isequal(hcoord,2)
    848 %     set(hcoord,'Value',2)
    849 %     huvmat=uvmat(AxeData);
    850 %     'relancer uvmat';
    851 % end
    852 % if ~isfield(AxeData,'ZoomAxes')
    853 %     msgbox_uvmat('ERROR','first draw a window around a grid marker')
    854 %     return
    855 % end
    856 % XLim=get(AxeData.ZoomAxes,'XLim');
    857 % YLim=get(AxeData.ZoomAxes,'YLim');
    858 % np=size(AxeData.A);
    859 % ind_sub_x=round(XLim);
    860 % ind_sub_y=np(1)-round(YLim);
    861 % Mfiltre=AxeData.A(ind_sub_y(2):ind_sub_y(1) ,ind_sub_x,:);
    862 % Mfiltre_norm=double(Mfiltre);
    863 % Mfiltre_norm=Mfiltre_norm/sum(sum(Mfiltre_norm));
    864 % Mfiltre_norm=100*(Mfiltre_norm-mean(mean(Mfiltre_norm)));
    865 % Atype=class(AxeData.A);
    866 % Data.NbDim=2;
    867 % Data.A=filter2(Mfiltre_norm,double(AxeData.A));
    868 % Data.A=feval(Atype,Data.A);
    869 % Data.AName='image';
    870 % Data.AX=AxeData.AX;
    871 % Data.AY=AxeData.AY;
    872 % Data.CoordType='px';
    873 % plot_field(Data)
    874799
    875800
     
    887812% --------------------------------------------------------------------
    888813function MenuSetScale_Callback(hObject, eventdata, handles)
    889 % hObject    handle to MenuSetScale (see GCBO)
    890 % eventdata  reserved - to be defined in a future version of MATLAB
    891 % handles    structure with handles and user data (see GUIDATA)
    892  answer=msgbox_uvmat('INPUT_TXT','scale pixel/cm?','')
     814
     815 answer=msgbox_uvmat('INPUT_TXT','scale pixel/cm?','');
    893816 %create test points
    894817 huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle
     
    902825Coord=[x y zeros(4,1) Xima Yima zeros(4,1)];
    903826set(handles.ListCoord,'Data',Coord)
     827set(handles.APPLY,'BackgroundColor',[1 0 1])
    904828
    905829%------------------------------------------------------------------------
     
    918842Coord(1:size(T,1),1:3)=T;%update the existing list of phys coordinates from the GUI create_grid
    919843set(handles.ListCoord,'Data',Coord)
     844set(handles.APPLY,'BackgroundColor',[1 0 1])
    920845
    921846% -----------------------------------------------------------------------
     
    952877[T,CalibData.grid,white_test]=create_grid(grid_input,'detect_grid');%display the GUI create_grid, read the set of phys coordinates T
    953878set(handles.geometry_calib,'UserData',CalibData)%store the phys grid parameters for later use
    954 
    955 
    956879
    957880%% read the current image, displayed in the GUI uvmat
     
    1051974set(handles.ListCoord,'Data',Coord)
    1052975PLOT_Callback(hObject, eventdata, handles)
     976set(handles.APPLY,'BackgroundColor',[1 0 1])
    1053977
    1054978%-----------------------------------------------------------------------
     
    1070994Coord(:,3)=T(3)+Coord(:,3);
    1071995set(handles.ListCoord,'Data',Coord);
     996set(handles.APPLY,'BackgroundColor',[1 0 1])
    1072997
    1073998% --------------------------------------------------------------------
     
    11031028Coord(:,2)=r3*x+r4*y;
    11041029set(handles.ListCoord,'Data',Coord)
     1030set(handles.APPLY,'BackgroundColor',[1 0 1])
    11051031
    11061032% --------------------------------------------------------------------
     
    11161042set(handles.ListCoord,'Data',Coord)
    11171043PLOT_Callback(handles.geometry_calib, [], handles)
     1044set(handles.APPLY,'BackgroundColor',[1 0 1])
    11181045
    11191046% -----------------------------------------------------------------------
     
    11871114    Heading=s.Heading;
    11881115end
    1189    
     1116
    11901117GeometryCalib=s.GeometryCalib;
    11911118fx=1;fy=1;Cx=0;Cy=0;kc=0; %default
     
    11961123    % choose the calibration option
    11971124    if isfield(GeometryCalib,'CalibrationType')
    1198        calib_list=get(handles.calib_type,'String');
    1199        for ilist=1:numel(calib_list)
    1200            if strcmp(calib_list{ilist},GeometryCalib.CalibrationType)
    1201                val_cal=ilist;
    1202                break
    1203            end
    1204        end
     1125        calib_list=get(handles.calib_type,'String');
     1126        for ilist=1:numel(calib_list)
     1127            if strcmp(calib_list{ilist},GeometryCalib.CalibrationType)
     1128                val_cal=ilist;
     1129                break
     1130            end
     1131        end
    12051132    end
    12061133    display_intrinsic(GeometryCalib,handles)%intrinsic param
     
    12181145    end
    12191146    if isfield(GeometryCalib,'SourceCalib')
    1220     calib=GeometryCalib.SourceCalib.PointCoord;
    1221     Coord=[calib zeros(size(calib,1),1)];
    1222     set(handles.ListCoord,'Data',Coord)
    1223     end
    1224 %     CoordCell=reshape(CoordCell,[],5);
    1225 %     Tabchar=cell2tab(CoordCell,' | ');%transform cells into table ready for display
     1147        calib=GeometryCalib.SourceCalib.PointCoord;
     1148        Coord=[calib zeros(size(calib,1),1)];
     1149        set(handles.ListCoord,'Data',Coord)
     1150    end
    12261151    PLOT_Callback(handles.geometry_calib, [], handles)
     1152    set(handles.APPLY,'BackgroundColor',[1 0 1])
    12271153end
    12281154set(handles.calib_type,'Value',val_cal)
     
    13471273% --- 'key_press_fcn:' function activated when a key is pressed on the keyboard
    13481274%------------------------------------------------------------------------
    1349 function key_press_fcn(hObject,eventdata,handles)
    1350 
     1275function ListCoord_KeyPressFcn(hObject, eventdata, handles)
    13511276xx=double(get(handles.geometry_calib,'CurrentCharacter'));%get the keyboard character
    1352 %if ismember(xx,[8 127])%backspace or delete
    13531277if ismember(xx,[30 31 127])% arrow upward, downward, or delete
    13541278    Coord=get(handles.ListCoord,'Data');
     
    13631287            Coord(ind,:)=[];
    13641288            PLOT_Callback(hObject,eventdata,handles)
     1289            set(handles.APPLY,'BackgroundColor',[1 0 1])
     1290        otherwise
    13651291    end
    13661292    set(handles.ListCoord,'Data',Coord);
    1367 end
    1368 
     1293else
     1294    set(handles.APPLY,'BackgroundColor',[1 0 1])
     1295end
    13691296
    13701297
  • trunk/src/mouse_motion.m

    r681 r682  
    2626
    2727if ~exist('handles','var')
     28    set(hCurrentFig,'Pointer','arrow');
    2829    return
    2930end
     
    6364    if ~ishandle(FigData.CivHandle)
    6465        delete(hObject)
     66        set(hCurrentFig,'Pointer','arrow');
    6567        return
    6668    end
     
    9193end
    9294if size(PosChildren,2)~=4
     95    set(hCurrentFig,'Pointer','arrow');
    9396    return
    9497end
     
    100103
    101104%if the mouse is over an axis, look at the data
    102 if strcmp(get(hchild,'Type'),'axes')
     105htype=get(hchild,'Type');
     106if strcmp(htype,'axes')
    103107    CurrentAxes=hchild;
    104108    xy=get(CurrentAxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
     
    323327%%%%%%%%%%%%%%%%%
    324328%% create or modify an object
    325 if ~isempty(huvmat) && test_object
     329if strcmp(htype,'axes') && ~isempty(huvmat) && test_object
    326330    UvData=get(huvmat,'UserData');
    327331    PlotData=get(AxeData.CurrentObject,'UserData');
    328332    if ~isfield(PlotData,'IndexObj')
     333        set(hCurrentFig,'Pointer','arrow');
    329334        return
    330335    end
     
    375380%% detect calibration points if the GUI geometry_calib is opened
    376381h_geometry_calib=findobj(allchild(0),'Name','geometry_calib'); %find the geomterty_calib GUI
    377 if ~CheckZoom && ~isempty(h_geometry_calib)
     382if strcmp(htype,'axes') && ~CheckZoom && ~isempty(h_geometry_calib)
    378383    pointershape='crosshair';%default for geometry_calib: ready to create new points
    379384    hh_geometry_calib=guidata(h_geometry_calib);
     
    415420                    Data(index_point,6)=1;%mrk the point on the GUI geometry_calib
    416421                    set(h_ListCoord,'Data',Data);
    417                    % set(h_ListCoord,'Value',index_point)%mrk the point on the GUI geometry_calib
    418422                    hhh=findobj('Tag','calib_marker');%look for handle of point marker (circle)
    419423                    if ~isempty(hhh)
  • trunk/src/mouse_up.m

    r681 r682  
    2525
    2626test_ruler=0;%default
    27 AxeData=get(gca,'UserData');
     27hcurrentaxes=get(hObject,'CurrentAxes');
     28if isempty(hcurrentaxes)
     29    return % no axes in the current figure
     30end
     31AxeData=get(hcurrentaxes,'UserData');
    2832if isfield(AxeData,'ParentAxes')% case of a zoom plot as current axis
    2933    hcurrentaxes=AxeData.ParentAxes;
     
    3337else
    3438    hcurrentfig=hObject;
    35     hcurrentaxes=gca; %store the current axes handle
    3639    testsubplot=0;
    3740end
     
    5457    return
    5558end
    56 xy=get(gca,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
     59xy=get(hcurrentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
    5760
    5861
     
    6063if ~isempty(huvmat) && isfield(AxeData,'Drawing') && ~isequal(AxeData.Drawing,'off') && isfield(AxeData,'CurrentObject')...
    6164        && ~isempty(AxeData.CurrentObject) && ishandle(AxeData.CurrentObject)
    62     %     xy=get(currentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
    6365    PlotData=get(AxeData.CurrentObject,'UserData');%get data attached to the current projection object
    6466    IndexObj=PlotData.IndexObj;
     
    247249            ChildAxeData.ParentAxes=hcurrentaxes;
    248250            ChildAxeData.ParentRect=AxeData.CurrentRectZoom;%set the rectangle drawing as a 'parent' associated to the new axe
    249             %PosRect=CurrentOrigin;
    250            % xy=get(hcurrentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
    251251            if xy(1,1)>CurrentOrigin(1)
    252252            set(AxeData.ZoomAxes,'Xlim',[CurrentOrigin(1) xy(1,1)])
     
    343343            h_ListCoord=hh_geometry_calib.ListCoord; %handles of the coordinate list
    344344            Coord=get(h_ListCoord,'Data');
    345            % data=read_geometry_calib(Coord);
    346             %         val=get(h_ListCoord,'Value');
    347           %  xy=get(hcurrentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
    348345            Coord(index_point,4)=xy(1,1);
    349346            Coord(index_point,5)=xy(1,2);
    350347            set(h_ListCoord,'Data',Coord)
    351 %             for ipoint=1:size(Coord,1)
    352 %                 for jcoord=1:5
    353 %                     Coord_cell{ipoint,jcoord}=num2str(data.Coord(ipoint,jcoord),4);%display coordiantes with 4 digits
    354 %                 end
    355 %             end
    356 %             Tabchar=cell2tab(Coord_cell,' | ');
    357 %             Tabchar=[Tabchar ;{'......'}];
    358 %             set(h_ListCoord,'String',Tabchar)
    359348            set(hh,'XData',Coord(:,4))
    360349            set(hh,'YData',Coord(:,5))
  • trunk/src/series.m

    r675 r682  
    29452945end
    29462946menu=menu(1:imax);
     2947
     2948
     2949% --- Executes on mouse motion over figure - except title and menu.
     2950function series_WindowButtonMotionFcn(hObject, eventdata, handles)
     2951set(hObject,'Pointer','arrow');
  • trunk/src/uvmat.m

    r681 r682  
    27002700end
    27012701ResizeFcn(handles.uvmat,[],handles)
    2702 %set(handles.uvmat,'CurrentAxes',handles.PlotAxes)% make the main axis current (usefull for key board callback)
    27032702
    27042703%------------------------------------------------------------------------
     
    27302729        end
    27312730    end
     2731elseif ~isempty(FieldName_2)
     2732    FieldHisto(:,:,2)=Field.(FieldName_2);
    27322733end
    27332734if isempty(Field)
     
    41994200        hhgeometry_calib=guidata(hgeometry_calib);
    42004201        set(hhgeometry_calib.CheckEnableMouse,'Value',0)% desactivate mouse action in geometry_calib
     4202        set(hhgeometry_calib.CheckEnableMouse,'BackgroundColor',[0.7 0.7 0.7])
    42014203    end
    42024204    set(handles.CheckViewObject,'value',1)
     
    46564658    hhgeometry_calib=guidata(hgeometry_calib);
    46574659    set(hhgeometry_calib.CheckEnableMouse,'Value',0)% desactivate mouse action in geometry_calib
     4660    set(hhgeometry_calib.CheckEnableMouse,'BackgroundColor',[0.7 0.7 0.7])
    46584661end
    46594662set(handles.CheckEditObject,'Value',0)  %desactivate the object edit mode
Note: See TracChangeset for help on using the changeset viewer.