source: trunk/src/mouse_motion.m @ 688

Last change on this file since 688 was 682, checked in by sommeria, 11 years ago

various bugs repaired

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