source: trunk/src/mouse_motion.m @ 658

Last change on this file since 658 was 657, checked in by sommeria, 11 years ago

a few bugs corrected

File size: 22.9 KB
RevLine 
[11]1%'mouse_motion': permanently called by mouse motion over a figure (Callback for 'WindowButtonMotionFcn' of the figure)
2%-----------------------------------------------------------------------
3%
4% function mouse_motion(hObject,eventdata,handles)
5% activated by the command:
6% set(hObject,'WindowButtonMotionFcn',{'mouse_motion',handles})
7% where hObject is the handle of the figure
8%
9%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
10%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
11%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
12%     This file is part of the toolbox UVMAT.
13%
14%     UVMAT is free software; you can redistribute it and/or modify
15%     it under the terms of the GNU General Public License as published by
16%     the Free Software Foundation; either version 2 of the License, or
17%     (at your option) any later version.
18%
19%     UVMAT is distributed in the hope that it will be useful,
20%     but WITHOUT ANY WARRANTY; without even the implied warranty of
21%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
23%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
24
25function mouse_motion(hObject,eventdata,handles)
[78]26
[11]27if ~exist('handles','var')
28    return
29end
[187]30FigData=get(hObject,'UserData');
31if ishandle(FigData)% case of a zoom plot, the handle of the parent rectangle is stored in UserData, its parent is the plotting axes of the rectangle
[625]32    hCurrentFig=get(get(FigData,'parent'),'parent');
[187]33else
[625]34    hCurrentFig=hObject;%usual plot
[187]35end
[625]36hhCurrentFig=guidata(hCurrentFig);%handles of the elements in the GUI containing the current figure (uvmat or view_field)
[622]37CheckZoom=get(hhCurrentFig.CheckZoom,'Value');% check for zoom on mode
38CheckZoomFig=get(hhCurrentFig.CheckZoomFig,'Value');% check for zoom sub fig creation mode
[625]39hPlotAxes=hhCurrentFig.PlotAxes';% handles of the main plot axes
40AxeData=get(hPlotAxes,'UserData');% data attached to the axis
[627]41htext_display(1)=handles.text_display;
42if isfield(AxeData,'htext_display')&&ishandle(AxeData.htext_display)
43    htext_display(2)=AxeData.htext_display;
44end
[625]45test_draw=0;%test for mouse drawing of object, =0 by default
46if isfield(AxeData,'Drawing')&& ~isempty(AxeData.Drawing)
47    test_draw=~isequal(AxeData.Drawing,'off');%=1 if mouse drawing of object is active
48end
[622]49test_zoom_draw=0;
[150]50test_object=0; %test for object editing or creation
[156]51test_edit_object=0;% edit test for mouse shap: an arrow
[150]52test_ruler=0;%test for active ruler
53huvmat=findobj(allchild(0),'tag','uvmat');%find the uvmat interface handle
[71]54if ~isempty(huvmat)
[432]55    hhuvmat=guidata(huvmat);%handles of the elements in uvma
[650]56    test_edit_object=get(hhuvmat.CheckEditObject,'Value');
[156]57    test_ruler=isequal(get(hhuvmat.MenuRuler,'checked'),'on');
[150]58end
[231]59test_piv=0;
60if isfield(FigData,'CivHandle')
61    if ~ishandle(FigData.CivHandle)
62        delete(hObject)
63        return
64    end
65    hhciv=guidata(FigData.CivHandle);
66    test_piv=1;
[150]67end
[11]68
[432]69%find the current axe 'CurrentAxes' and display the current mouse position or uicontrol tag
[11]70text_displ_1='';
71text_displ_2='';
72text_displ_3='';
73text_displ_4='';
74
[625]75% AxeData=[];%default
[67]76xy=[];%default
[622]77xy_fig=get(hObject,'CurrentPoint');% current point of the current figure (gcbo)
[11]78pointershape='arrow';% default pointer is an arrow
[150]79
[432]80%% loop on all the objects in the current figure, detect whether the mouse is over a plot  axes
[622]81hchildren=get(hObject,'Children');%handles of all objects in the current figure
82check_visible=strcmp(get(hchildren,'Visible'),'on');% if visible='on', =0 otherwise
83hchildren=hchildren(check_visible); %kkep only the visible children
84PosChildren=get(hchildren,'Position');% set of object positions
85if iscell(PosChildren)% only one child
86    PosLength=cellfun('length',PosChildren);% set of vector lengths for object positions
87    hchildren=hchildren(PosLength==4);% keep only objects with position defined by a 4 element vector
88    PosChildren=cell2mat(PosChildren(PosLength==4));% convert cells to matrix of positions
89end
90if size(PosChildren,2)~=4
91    return
92end
93xy_fig_mat=ones(size(PosChildren,1),1)*xy_fig;% mouse position set to a matrix
94check_pos=xy_fig_mat >= PosChildren(:,1:2) & xy_fig_mat <= PosChildren(:,1:2)+PosChildren(:,3:4);% compare object to mouse position
95ind_object=find(check_pos(:,1) & check_pos(:,2),1);% select the index of the (first) object under the mouse
96hchild=hchildren(ind_object);% corresponding object handle
[432]97CurrentAxes=[];
[622]98
99%if the mouse is over an axis, look at the data
100if strcmp(get(hchild,'Type'),'axes')
101    CurrentAxes=hchild;
102    xy=get(CurrentAxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
103    test_zoom_draw=test_draw && isequal(AxeData.Drawing,'zoom')&& isfield(AxeData,'CurrentOrigin') && isequal(get(gcf,'SelectionType'),'normal');
104    test_object=test_draw && isfield(AxeData,'CurrentObject') && ~isempty(AxeData.CurrentObject) && ishandle(AxeData.CurrentObject);
105    if ~test_edit_object  && ~test_ruler && ~CheckZoom
106        pointershape='crosshair';%set pointer with cross shape (default when mouse is over an axis)
107    end
[625]108    FigData=get(hCurrentFig,'UserData');
[622]109    tagaxes=get(CurrentAxes,'tag');
110    if isfield(FigData,tagaxes)
111        Field=FigData.(tagaxes);
112        if isfield(Field,'ListVarName')
113            [CellInfo,NbDimArray]=find_field_cells(Field);%analyse the physical fields contained in Field
114            text_displ_1='';
115            text_displ_2='';
116            text_displ_3='';
117            text_displ_4='';
118            text_displ_5='';
119            ivec=[];
120            xName='';
121            z=[];
122            for icell=1:numel(CellInfo)%look for all physical fields
123                if NbDimArray(icell)>=2 % select 2D field
124                    if  isfield(Field,'CoordMesh') && ~isempty(Field.CoordMesh)&& strcmp(CellInfo{icell}.CoordType,'scattered')%case of unstructured data
125                        X=Field.(Field.ListVarName{CellInfo{icell}.CoordIndex(end)});
126                        Y=Field.(Field.ListVarName{CellInfo{icell}.CoordIndex(end-1)});
127                        flag_vec=(X<(xy(1,1)+Field.CoordMesh/3) & X>(xy(1,1)-Field.CoordMesh/3)) & ...%flagx=1 for the vectors with x position selected by the mouse
128                            (Y<(xy(1,2)+Field.CoordMesh/3) & Y>(xy(1,2)-Field.CoordMesh/3));%f
129                        ivec=find(flag_vec,1);% search the (first) selected vector index ivec
130                        hhh=findobj(CurrentAxes,'Tag','vector_marker');
131                        if ~isempty(ivec)
132                            % mark the vectors with a circle in the absence of other operations
133                            if ~test_object && ~test_edit_object && ~test_ruler && ~CheckZoomFig
134                                pointershape='arrow'; %mouse indicates  the detection of a vector
135                                if isempty(hhh)
[625]136                                    set(0,'CurrentFigure',hCurrentFig)
137                                    set(hCurrentFig,'CurrentAxes',CurrentAxes)
[622]138                                    rectangle('Curvature',[1 1],...
139                                        'Position',[X(ivec)-Field.CoordMesh/2 Y(ivec)-Field.CoordMesh/2 Field.CoordMesh Field.CoordMesh],'EdgeColor','m',...
140                                        'LineStyle','-','Tag','vector_marker');
[251]141                                else
[622]142                                    set(hhh,'Visible','on')
143                                    set(hhh,'Position',[X(ivec)-Field.CoordMesh/2 Y(ivec)-Field.CoordMesh/2 Field.CoordMesh Field.CoordMesh])
[251]144                                end
[622]145                            end
146                            %display the field values
147                            for ivar=1:numel(CellInfo{icell}.VarIndex)
148                                VarName=Field.ListVarName{CellInfo{icell}.VarIndex(ivar)};
149                                VarVal=Field.(VarName)(ivec);
150                                var_text=[VarName '=' num2str(VarVal,4) ','];
151                                if isequal(ivar,CellInfo{icell}.CoordIndex(end))||isequal(ivar,CellInfo{icell}.CoordIndex(end-1))||isequal(ivar,CellInfo{icell}.CoordIndex(1))
152                                    text_displ_1=[text_displ_1 var_text];
153                                elseif (isfield(CellInfo{icell},'VarIndex_vector_x') && isequal(ivar,CellInfo{icell}.VarIndex_vector_x))||isequal(ivar,CellInfo{icell}.VarIndex_vector_y)||...
154                                        (isfield(CellInfo{icell},'VarIndex_vector_z') && isequal(ivar,CellInfo{icell}.VarIndex_vector_z))
155                                    text_displ_4=[text_displ_4 var_text];
156                                else
157                                    text_displ_5=[text_displ_5 var_text];
[105]158                                end
[61]159                            end
[622]160                        else
161                            if ~isempty(hhh)
162                                set(hhh,'Visible','off')
163                            end
[71]164                        end
[622]165                    elseif strcmp(CellInfo{icell}.CoordType,'grid') %structured coordinates
166                        yName=Field.ListVarName{CellInfo{icell}.CoordIndex(1)};
167                        xName=Field.ListVarName{CellInfo{icell}.CoordIndex(2)};
168                        y=Field.(yName);
169                        x=Field.(xName);
170                        VarName=Field.ListVarName{CellInfo{icell}.VarIndex(1)};
171                        nxy=size(Field.(VarName));
172                        MaxAY=max(y(1),y(end));
173                        MinAY=min(y(1),y(end));
174                        if (xy(1,1)>x(1))&(xy(1,1)<x(end))&(xy(1,2)<MaxAY)&(xy(1,2)>MinAY)
175                            indx0=1+round((nxy(2)-1)*(xy(1,1)-x(1))/(x(end)-x(1))); % index x of pixel
176                            indy0=1+round((nxy(1)-1)*(xy(1,2)-y(1))/(y(end)-y(1))); % index y of pixel
177                            if indx0>=1 & indx0<=nxy(2) & indy0>=1 & indy0<=nxy(1)
178                                text_displ_2=['i='  num2str(indx0) ',j=' num2str(indy0) ','];
179                                for ivar=1:numel(CellInfo{icell}.VarIndex)
180                                    VarName=Field.ListVarName{CellInfo{icell}.VarIndex(ivar)};
181                                    VarVal=Field.(VarName)(indy0,indx0,:);
182                                    var_text=[VarName '=' num2str(VarVal) ','];
183                                    text_displ_4=[text_displ_4 var_text];
184                                end
185                            end
[251]186                        end
187                    end
[622]188                end
189            end
190            % display the current x,y plot coordinates in the absence of detected vector
191            if isempty(ivec)
192                if isempty(xName)
193                    xName='x';
194                    yName='y';
195                end
196                text_displ_1=[xName '=' num2str(xy(1,1),4) ', ' yName '=' num2str(xy(1,2),4) ','];
197            end
198            %display the z coordinate if defined by the projection plane
199            if isfield(Field,'ObjectType') && strcmp(Field.ObjectType,'plane') && isfield(Field,'ObjectCoord') && length(Field.ObjectCoord)>=3
200                pos=[xy(1,1) xy(1,2) 0];
201                if isfield(Field,'ObjectAngle')&&~isequal(Field.ObjectAngle,[0 0 0])
202                    om=norm(Field.ObjectAngle);%norm of rotation angle in radians
203                    OmAxis=Field.ObjectAngle/om; %unit vector marking the rotation axis
204                    cos_om=cos(pi*om/180);
205                    sin_om=sin(pi*om/180);
206                    pos=[xy(1,1) xy(1,2) 0];
207                    pos=cos_om*pos+sin_om*cross(OmAxis,pos)+(1-cos_om)*(OmAxis*pos')*OmAxis;
208                end
209                pos=pos+[Field.ObjectCoord 0];
210                text_displ_3=[text_displ_3 'x,y,z=' num2str(pos,4)];
211            end
212            %                     if ~isempty(z)
213            %                         text_displ_1=[text_displ_1 ' z=' num2str(z,4)];
214            %                     end
215            % case of PIV correlation display
216            if test_piv
217                par=read_GUI(hhciv.Civ1);
218                [dd,ind_pt]=min(abs(Field.X-xy(1,1))+abs(Field.Y-xy(1,2)));
219                xround=Field.X(ind_pt);
220                yround=Field.Y(ind_pt);
221                %                         par.Grid=[xround size(Field.A,1)-yround+1];
222                par.Grid=[xround yround];
223                % mark the correlation box with a rectangle
224                par.ImageA=Field.A;
225                par.ImageB=Field.B;
226                par.ImageHeight=size(par.ImageA,1);
227                par.ImageWidth=size(par.ImageA,2);
228                Param.Civ1=par;
229                ibx2=floor((par.CorrBoxSize(1)-1)/2);
230                iby2=floor((par.CorrBoxSize(2)-1)/2);
231                isx2=floor((par.SearchBoxSize(1)-1)/2);
232                isy2=floor((par.SearchBoxSize(2)-1)/2);
233                shiftx=par.SearchBoxShift(1);
234                shifty=par.SearchBoxShift(2);
235                hhh=findobj(CurrentAxes,'Tag','PIV_box_marker');
236                hhhh=findobj(CurrentAxes,'Tag','PIV_search_marker');
237                if isempty(hhh)
[625]238                    set(0,'CurrentFigure',hCurrentFig)
239                    set(hCurrentFig,'CurrentAxes',CurrentAxes)
[622]240                    rectangle('Curvature',[0 0],...
241                        'Position',[xround-ibx2 yround-iby2 2*ibx2 2*iby2],'EdgeColor','m',...
242                        'LineStyle','-','Tag','PIV_box_marker');
243                    rectangle('Curvature',[0 0],...
244                        'Position',[xround-isx2+shiftx yround-isy2+shifty 2*isx2 2*isy2],'EdgeColor','m',...
245                        'LineStyle','- -','Tag','PIV_search_marker');
246                else
247                    set(hhh,'Position',[xround-ibx2 yround-iby2 2*ibx2 2*iby2])
248                    set(hhhh,'Position',[xround-isx2+shiftx yround-isy2+shifty 2*isx2 2*isy2])
249                end
250                [Data,errormsg,result_conv]= civ_matlab(Param);
251                if ~isempty(errormsg)
252                    text_displ_5=errormsg;
253                else
254                    rangx(1)=-(isx2-ibx2)+shiftx;
255                    rangx(2)=isx2-ibx2+shiftx;
256                    rangy(1)=-(isy2-iby2)-shifty;
257                    rangy(2)=(isy2-iby2)-shifty;
258                    hcorr=[];
259                    if isfield(AxeData,'CurrentCorrImage')
260                        hcorr=AxeData.CurrentCorrImage;
261                        if ~ishandle(hcorr)
262                            hcorr=[];
[207]263                        end
[11]264                    end
[622]265                    if isempty(hcorr)
266                        corrfig=findobj(allchild(0),'tag','corrfig');
267                        if ~isempty(corrfig)
268                            set(0,'CurrentFigure',corrfig(1))
269                            AxeData.CurrentCorrImage=imagesc(rangx,-rangy,result_conv,[0 1]);
270                            AxeData.CurrentVector=line([0 Data.Civ1_U],[0 Data.Civ1_V],'Tag','vector');
271                            AxeData.TitleHandle=title(num2str(par.Grid));
272                            colorbar
273                            set(CurrentAxes,'UserData',AxeData)
274                            set(get(AxeData.CurrentCorrImage,'parent'),'YDir','normal')
[150]275                        end
[622]276                    else
277                        set(AxeData.CurrentCorrImage,'CData',result_conv)
278                        set(AxeData.CurrentCorrImage,'XData',rangx)
279                        set(AxeData.CurrentCorrImage,'YData',-rangy)
280                        set(AxeData.CurrentVector,'XData',[0 Data.Civ1_U],'YData',[0 Data.Civ1_V])
281                        set(AxeData.TitleHandle,'String',num2str(par.Grid))
[11]282                    end
283                end
[251]284            end
[11]285        end
286    end
287end
[292]288if ~isempty(text_displ_1)
[542]289    text_displ=[{text_displ_1};{text_displ_2};{text_displ_3};{text_displ_4};{text_displ_5}];
290    ind_blank=find(strcmp('',text_displ));
291    if ~isempty(ind_blank)
292        text_displ(ind_blank)=[];
293    end
[627]294    %set(handles.text_display,'String',text_displ)
295    set(htext_display,'String',text_displ)
[292]296else
[627]297   %set(handles.text_display,'String',get(handles.text_display,'UserData'))
298   set(htext_display,'String',get(handles.text_display,'UserData'))
[292]299end
[11]300
[71]301%%%%%%%%%%%%%
[622]302%% draw a zoom rectangle if checkZoomFig has been selected
[71]303if test_zoom_draw
[622]304   xy_rect=AxeData.CurrentOrigin;% mark the previous position from mouse down
[71]305   if ~isempty(xy_rect)
306        rect(1)=min(xy(1,1),xy_rect(1));%origin rectangle, x coordinate
307        rect(2)=min(xy(1,2),xy_rect(2));%origin rectangle, y coordinate
308        rect(3)=abs(xy(1,1)-xy_rect(1));%rectangle width
309        rect(4)=abs(xy(1,2)-xy_rect(2));%rectangle height
[622]310        if rect(3)>0 && rect(4)>0
311            if isfield(AxeData,'CurrentRectZoom')&& ~isempty(AxeData.CurrentRectZoom) && ishandle(AxeData.CurrentRectZoom)
[71]312                set(AxeData.CurrentRectZoom,'Position',rect);%update the rectangle position
313            else
[622]314                AxeData.CurrentRectZoom=rectangle('Position',rect,'Tag','rect_zoom','EdgeColor','b');
[432]315                set(CurrentAxes,'UserData',AxeData)
[71]316            end
317        end
318   end
319end
320
[11]321%%%%%%%%%%%%%%%%%
[150]322%% create or modify an object
[71]323if ~isempty(huvmat) && test_object
[432]324    UvData=get(huvmat,'UserData');
[11]325    PlotData=get(AxeData.CurrentObject,'UserData');
[432]326    if ~isfield(PlotData,'IndexObj')
327        return
328    end
[622]329    ObjectData=UvData.ProjObject{PlotData.IndexObj};
[432]330    if isequal(hObject,huvmat)% if the mouse ifs over the GUI uvmat
[622]331        ProjObject=UvData.ProjObject{get(hhuvmat.ListObject_1,'Value')};
[432]332    else
[622]333        ProjObject=UvData.ProjObject{get(hhuvmat.ListObject,'Value')};
[432]334    end
335    XYData=AxeData.CurrentOrigin;
336    if isequal(AxeData.Drawing,'create') && isfield(AxeData,'CurrentOrigin') && ~isempty(AxeData.CurrentOrigin)
337        if strcmp(ObjectData.Type,'line')||strcmp(ObjectData.Type,'polyline')||strcmp(ObjectData.Type,'polygon')||strcmp(ObjectData.Type,'points')
338            ObjectData.Coord=[ObjectData.Coord ;xy(1,1:2)];
339            % ObjectData.Coord(end,:)=xy(1,:);
340        elseif strcmp(ObjectData.Type,'rectangle')||strcmp(ObjectData.Type,'ellipse')||strcmp(ObjectData.Type,'volume')
[622]341                ObjectData.Coord=(AxeData.CurrentOrigin+xy(1,1:2))/2;% keep only the first point coordinate     
342                ObjectData.RangeX=abs(ObjectData.Coord(1,1)-xy(1,1));%rectangle width
343                ObjectData.RangeY=abs(ObjectData.Coord(1,2)-xy(1,2));%rectangle height
[432]344        elseif isequal(ObjectData.Type,'plane') %case of 'plane'
345            DX=(xy(1,1)-ObjectData.Coord(1,1));
346            DY=(xy(1,2)-ObjectData.Coord(1,2));
347            ObjectData.Phi=(angle(DX+i*DY))*180/pi;%rectangle widt
348            if isfield(ObjectData,'RangeX')
349                XMax=sqrt(DX*DX+DY*DY);
350                if XMax>max(ObjectData.RangeX)
351                    ObjectData.RangeX=[min(ObjectData.RangeX) XMax];
[11]352                end
[432]353            end
[11]354        end
[432]355        plot_object(ObjectData,ProjObject,AxeData.CurrentObject,'m');
356        pointershape='crosshair';
357    elseif  isequal(AxeData.Drawing,'translate')
358        DX=xy(1,1)-XYData(1);%translation from initial position
359        DY=xy(1,2)-XYData(2);
360        ObjectData.Coord(:,1)=ObjectData.Coord(:,1)+DX;
361        ObjectData.Coord(:,2)=ObjectData.Coord(:,2)+DY;
362        plot_object(ObjectData,ProjObject,AxeData.CurrentObject,'m');
363        pointershape='fleur';
364    elseif  isequal(AxeData.Drawing,'deform')
365        ind_move=AxeData.CurrentIndex;
366        ObjectData.Coord(ind_move,1)=xy(1,1);
367        ObjectData.Coord(ind_move,2)=xy(1,2);
368        plot_object(ObjectData,ProjObject,AxeData.CurrentObject,'m');
369        pointershape='circle';
[11]370    end
[432]371end
[67]372
[150]373%% detect calibration points if the GUI geometry_calib is opened
[67]374h_geometry_calib=findobj(allchild(0),'Name','geometry_calib'); %find the geomterty_calib GUI
[622]375if ~CheckZoom && ~isempty(h_geometry_calib)
[67]376    pointershape='crosshair';%default for geometry_calib: ready to create new points
377    hh_geometry_calib=guidata(h_geometry_calib);
[156]378    if  ~isempty(xy) && isfield(hh_geometry_calib,'ListCoord')
[67]379        h_ListCoord=hh_geometry_calib.ListCoord; %findobj(h_geometry_calib,'Tag','ListCoord');
[657]380        data.Coord=get(h_ListCoord,'Data');
381%         data.Coord(:,6)=[];
382       % data=read_geometry_calib(Coord);%transform char cell to numbers
383        if isnumeric(data.Coord)&&~isempty(data.Coord)
[67]384            XCoord=(data.Coord(:,4));
385            YCoord=(data.Coord(:,5));
[432]386            xy=get(CurrentAxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
[67]387            if ~isempty(xy)
[432]388                xlim=get(CurrentAxes,'XLim');
[78]389                ind_range_x=abs((xlim(2)-xlim(1))/50);
[432]390                ylim=get(CurrentAxes,'YLim');
[78]391                ind_range_y=abs((ylim(2)-ylim(1))/50);
392                ind_range=sqrt(ind_range_x*ind_range_y);
[67]393                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
394                              (YCoord<xy(1,2)+ind_range) & (YCoord>xy(1,2)-ind_range),1);%find the first calibration point in the neighborhood of the mouse
395                if ~isempty(index_point)
396                    pointershape='arrow';% default pointer is an arrow
[78]397                end
398                hh=findobj('Tag','calib_points');%look for handle of calibration points
399               if ~isempty(hh) && ~isempty(get(hh,'UserData')) && get(hh_geometry_calib.edit_append,'Value')
[657]400                   %set(hh,'UserData',index_point)
[173]401                    index_point=get(hh,'UserData');
[78]402                    XCoord(index_point)=xy(1,1);
403                    YCoord(index_point)=xy(1,2);
404                    set(hh,'XData',XCoord)
405                    set(hh,'YData',YCoord)
406               end
407                if ~isempty(index_point)
[657]408                    Data=get(h_ListCoord,'Data');
409                    Data(:,6)=zeros(size(Data,1),1);
410                    Data(index_point,6)=1;%mrk the point on the GUI geometry_calib
411                    set(h_ListCoord,'Data',Data);
412                   % set(h_ListCoord,'Value',index_point)%mrk the point on the GUI geometry_calib
[67]413                    hhh=findobj('Tag','calib_marker');%look for handle of point marker (circle)
414                    if ~isempty(hhh)
[71]415                        set(hhh,'Position',[XCoord(index_point)-ind_range/2 YCoord(index_point)-ind_range/2 ind_range ind_range])
[657]416                    else
417                                    rectangle('Curvature',[1 1],...
418                'Position',[xy(1,1)-ind_range/2 xy(1,2)-ind_range/2 ind_range ind_range],'EdgeColor','m',...
419                'LineStyle','-','Tag','calib_marker');
[67]420                    end
[78]421                end
[67]422            end
423        end
424    end
425end
426
[150]427%% draw ruler
[156]428if test_ruler && isfield(AxeData,'Drawing') && isequal(AxeData.Drawing,'ruler')
429    if isfield(AxeData,'RulerHandle')
430        pointershape='crosshair'; %give  the mouse pointer a cross shape
431        RulerCoord=[AxeData.RulerCoord ;xy(1,1:2)]; %coordinates defining the ruler segment
432        set(AxeData.RulerHandle,'XData',RulerCoord(:,1));% updtate the x coordinates for the ruler graphic object
433        set(AxeData.RulerHandle,'YData',RulerCoord(:,2));% updtate the y coordinates for the ruler graphic object
434    end
[60]435end
[150]436
437%% update the mouse pointer
[625]438set(hCurrentFig,'Pointer',pointershape);
Note: See TracBrowser for help on using the repository browser.