Changeset 78 for trunk/src/mouse_down.m


Ignore:
Timestamp:
Apr 2, 2010, 9:01:21 PM (14 years ago)
Author:
sommeria
Message:

debugging of geometry_calib and mouse operations
merge_proj: call to read_image replaced. Still problems to solve to merge images

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/mouse_down.m

    r71 r78  
    6363        %if the mouse is over an axis, look at the data
    6464        if isequal(htype,'axes')
     65            y_lim=get(hchild(ichild),'YLim');
     66            x_lim=get(hchild(ichild),'XLim');
    6567            haxes=hchild(ichild);
    6668            xy=get(haxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
    67             AxeData=get(haxes,'UserData');% data attached to the axis
    68             AxeData.CurrentOrigin=[xy(1,1) xy(1,2)];% The current point set by the mouse becomes the current origin
    69             if ~isequal(tag_obj,'proj_object') & ~test_create
    70                 x_mouse=xy(1,1);%default
    71                 y_mouse=xy(1,2);%default
    72                 u_mouse=[];
    73                 v_mouse=[];
    74                 w_mouse=[];
    75                 A_mouse=[];
    76                 c_text=[];
    77                 f_text=[];
    78                 ff_text=[];     
    79                 ivec=[];   
    80                 if isfield(AxeData,'X') & isfield(AxeData,'Y') & isfield(AxeData,'Mesh')% test on the existence of a vector field in the current axis
    81                     flag_vec=(AxeData.X<(xy(1,1)+AxeData.Mesh/4) & AxeData.X>(xy(1,1)-AxeData.Mesh/4)) & ...%flagx=1 for the vectors with x position selected by the mouse
    82                       (AxeData.Y<(xy(1,2)+AxeData.Mesh/4) & AxeData.Y>(xy(1,2)-AxeData.Mesh/4));%f
    83                     ivec=find(flag_vec,1);% search the (first) selected vector index ivec
     69            if xy(1,1)>x_lim(1) && xy(1,1)<x_lim(2) && xy(1,2)>y_lim(1) && xy(1,2)<y_lim(2)
     70                AxeData=get(haxes,'UserData');% data attached to the axis
     71                AxeData.CurrentOrigin=[xy(1,1) xy(1,2)];% The current point set by the mouse becomes the current origin
     72                if ~isequal(tag_obj,'proj_object') & ~test_create
     73                    x_mouse=xy(1,1);%default
     74                    y_mouse=xy(1,2);%default
     75                    u_mouse=[];
     76                    v_mouse=[];
     77                    w_mouse=[];
     78                    A_mouse=[];
     79                    c_text=[];
     80                    f_text=[];
     81                    ff_text=[];     
     82                    ivec=[];   
     83                    if isfield(AxeData,'X') & isfield(AxeData,'Y') & isfield(AxeData,'Mesh')% test on the existence of a vector field in the current axis
     84                        flag_vec=(AxeData.X<(xy(1,1)+AxeData.Mesh/4) & AxeData.X>(xy(1,1)-AxeData.Mesh/4)) & ...%flagx=1 for the vectors with x position selected by the mouse
     85                          (AxeData.Y<(xy(1,2)+AxeData.Mesh/4) & AxeData.Y>(xy(1,2)-AxeData.Mesh/4));%f
     86                        ivec=find(flag_vec,1);% search the (first) selected vector index ivec
     87                    end
    8488                end
    85             end
    86 %         elseif isequal(get(hchild(ichild),'Visible'),'on')& ~isequal(get(hchild(ichild),'Style'),'frame')
    87 %            %FAIRE UNE OPTION D'AIDE AVEC BOUTON SOURIS DROIT (ALT)??
     89            else
     90                haxes=[];%mouse out of axes
     91            end
    8892        end
    8993    end
     
    240244
    241245% create calibration points if the GUI geometry_calib is opened, if the main axes axes3 of uvmat has ben selected
    242 if test_cal && ~isempty(haxes) && strcmp(get(haxes,'tag'),'axes3')
     246if ~testzoom && test_cal && ~isempty(haxes) && strcmp(get(haxes,'tag'),'axes3')
    243247    h_geometry_calib=findobj(allchild(0),'Name','geometry_calib'); %find the geomterty_calib GUI
    244248    hh_geometry_calib=guidata(h_geometry_calib);
    245249    h_ListCoord=hh_geometry_calib.ListCoord; %findobj(h_geometry_calib,'Tag','ListCoord');
    246250    h_edit_append=hh_geometry_calib.edit_append;%findobj(h_geometry_calib,'Tag','edit_append');
    247     if isequal(get(h_edit_append,'Value'),1)
     251    if isequal(get(h_edit_append,'Value'),1) && ~isempty(haxes)
    248252        coord_value=get(hhuvmat.transform_fct,'Value');% set uvmat to pixel coordinates, run it again if not
    249253        if ~(isequal(coord_value,1)||isequal(coord_value,3)); %active only with no transform or px (no phys)
     
    256260        Coord=get(h_ListCoord,'String');
    257261        data=read_geometry_calib(Coord);%transform char cell to numbers
    258         ind_range=10;%range of research around each existing point
     262        xlim=get(haxes,'XLim');
     263        ind_range_x=abs((xlim(2)-xlim(1))/50);
     264        ylim=get(haxes,'YLim');
     265        ind_range_y=abs((ylim(2)-ylim(1))/50);
     266        ind_range=sqrt(ind_range_x*ind_range_y);
    259267        test_newpoint=1;
    260268        if size(data.Coord,2)>=5 %if calibration points already exist
     
    265273            test_newpoint=isempty(index_point);%test for no existing calibration point near the mouse position
    266274        end
     275        val=get(h_ListCoord,'Value');
    267276        %create a new calib point if we are not close to an existing one
    268277        if test_newpoint                 
    269278             strline=[ '    |    '  '    |    '  '    |    ' num2str(xy(1,1),4) '    |    ' num2str(xy(1,2),4)];
    270              val=get(h_ListCoord,'Value');
     279           
    271280             if length(Coord)>=val
    272281                 Coord(val+1:length(Coord)+1)=Coord(val:length(Coord));% push the list forward beyond the current point
     
    286295            set(hh,'YData',YCoord)
    287296        end
    288         set(hh,'UserData','edit_mode')% flag the points to edit mode
     297        set(hh,'UserData',val)% flag the points to edit mode
    289298        hhh=findobj('Tag','calib_marker');%look for handle of point marker (circle)
    290299        if ~isempty(hhh)
Note: See TracChangeset for help on using the changeset viewer.