Changeset 657 for trunk/src/mouse_down.m


Ignore:
Timestamp:
Jul 3, 2013, 12:07:26 PM (8 years ago)
Author:
sommeria
Message:

a few bugs corrected

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/mouse_down.m

    r650 r657  
    400400
    401401%% create calibration points if the GUI geometry_calib is opened, if the main axes PlotAxes of uvmat has ben selected
    402 if  test_cal && ~isempty(haxes) && strcmp(get(haxes,'tag'),'PlotAxes') 
     402if  test_cal && ~isempty(haxes) && strcmp(get(haxes,'tag'),'PlotAxes')
    403403    h_geometry_calib=findobj(allchild(0),'Name','geometry_calib'); %find the geomterty_calib GUI
    404404    hh_geometry_calib=guidata(h_geometry_calib);
    405405    h_edit_append=hh_geometry_calib.edit_append;%findobj(h_geometry_calib,'Tag','edit_append');
    406406    if isequal(get(h_edit_append,'Value'),1) && ~isempty(haxes)
    407         h_ListCoord=hh_geometry_calib.ListCoord; %findobj(h_geometry_calib,'Tag','ListCoord');
    408         coord_value=get(hhuvmat.TransformName,'Value');% set uvmat to pixel coordinates, run it again if not
    409         if ~(isequal(coord_value,1)||isequal(coord_value,3)); %active only with no transform or px (no phys)
     407        if ~isequal(get(hhuvmat.TransformName,'Value'),1); %active only with no transform (px coordinates)
    410408            set(hhuvmat.TransformName,'Value',1)
    411409            uvmat('TransformName_Callback',hObject,eventdata,hhuvmat); %file input with xml reading  in uvmat
    412             set(hhuvmat.CheckFixedLimits,'Value',0)% put FixedLimits option to 'off'
    413             set(hhuvmat.CheckFixedLimits,'BackgroundColor',[0.7 0.7 0.7])
     410            set(hhuvmat.CheckFixLimits,'Value',0)% put FixedLimits option to 'off' (to sse the whole field)
    414411            return
    415412        end
    416         Coord=get(h_ListCoord,'String');
    417         data=read_geometry_calib(Coord);%transform char cell to numbers
     413        h_ListCoord=hh_geometry_calib.ListCoord; %findobj(h_geometry_calib,'Tag','ListCoord');
     414        Coord=get(h_ListCoord,'Data');
     415        %data=read_geometry_calib(Coord);%transform char cell to numbers
    418416        xlim=get(haxes,'XLim');
    419417        ind_range_x=abs((xlim(2)-xlim(1))/50);
     
    422420        ind_range=sqrt(ind_range_x*ind_range_y);
    423421        test_newpoint=1;
    424         if size(data.Coord,2)>=5 %if calibration points already exist
    425             XCoord=(data.Coord(:,4));
    426             YCoord=(data.Coord(:,5));
    427             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
    428                           (YCoord<xy(1,2)+ind_range) & (YCoord>xy(1,2)-ind_range),1);%find the first calibration point in the neighborhood of the mouse
    429             test_newpoint=isempty(index_point);%test for no existing calibration point near the mouse position
    430         end
    431         val=get(h_ListCoord,'Value');
     422        %if size(data.Coord,2)>=5 %if calibration points already exist
     423        if ~isempty(Coord)
     424        XCoord=(Coord(:,4));
     425        YCoord=(Coord(:,5));
     426        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
     427            (YCoord<xy(1,2)+ind_range) & (YCoord>xy(1,2)-ind_range),1);%find the first calibration point in the neighborhood of the mouse
     428        test_newpoint=isempty(index_point);%test for no existing calibration point near the mouse position
     429        end
     430        %end
     431        %val=find(Data.Coord(:,6));
     432       
    432433        %create a new calib point if we are not close to an existing one
    433         if test_newpoint                 
    434              strline=[ '    |    '  '    |    '  '    |    ' num2str(xy(1,1),4) '    |    ' num2str(xy(1,2),4)];
    435            
    436              if length(Coord)>=val
    437                  Coord(val+1:length(Coord)+1)=Coord(val:length(Coord));% push the list forward beyond the current point
    438              end
    439              Coord{val}=strline;
    440              set(h_ListCoord,'String',Coord)
    441              data=read_geometry_calib(Coord);%transform char cell to numbers
    442              XCoord=data.Coord(:,4);
    443              YCoord=data.Coord(:,5);
    444         end
    445         hh=findobj('Tag','calib_points');%look for handle of calibration points           
     434        hh=findobj('Tag','calib_points');%look for handle of calibration points
     435        if test_newpoint
     436            Coord=[Coord;[0 0 0 xy(1,1) xy(1,2) 0]];
     437            set(h_ListCoord,'Data',Coord)
     438        end
    446439        if isempty(hh)
    447             hh=line(XCoord,YCoord,'Color','m','Tag','calib_points','LineStyle','.','Marker','+');
     440            hh=line(Coord(:,4),Coord(:,5),'Color','m','Tag','calib_points','LineStyle','.','Marker','+');
    448441        else
    449             set(hh,'XData',XCoord)
    450             set(hh,'YData',YCoord)
    451         end
    452         set(hh,'UserData',val)% flag the points to edit mode
     442            set(hh,'XData',Coord(:,4))
     443            set(hh,'YData',Coord(:,5))
     444        end
     445         if test_newpoint
     446             set(hh,'UserData',size(Coord,1))% flag the points to edit mode
     447         else
     448             set(hh,'UserData',index_point)% mark the selected point index for future mouse motion
     449         end
    453450        hhh=findobj('Tag','calib_marker');%look for handle of point marker (circle)
    454451        if ~isempty(hhh)
     
    456453        else
    457454            rectangle('Curvature',[1 1],...
    458                   'Position',[xy(1,1)-ind_range/2 xy(1,2)-ind_range/2 ind_range ind_range],'EdgeColor','m',...
    459                   'LineStyle','-','Tag','calib_marker');
    460            % line([xy(1,1) xy(1,1)],[xy(1,2) xy(1,2)],'Color','m','Tag','calib_marker','LineStyle','.','Marker','o','MarkerSize',ind_range);
     455                'Position',[xy(1,1)-ind_range/2 xy(1,2)-ind_range/2 ind_range ind_range],'EdgeColor','m',...
     456                'LineStyle','-','Tag','calib_marker');
    461457        end
    462458        AxeData.Drawing='calibration';
Note: See TracChangeset for help on using the changeset viewer.