source: trunk/src/mouse_motion.m @ 700

Last change on this file since 700 was 699, checked in by sommeria, 10 years ago

mouse indication improved

File size: 24.4 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
112        if CheckZoom
113           pointershape='zoom';
114        elseif CheckZoomFig
115            pointershape='zoomfig';
116        elseif test_draw
117            pointershape='crosshair';%set pointer with cross shape (default when mouse is over an axis)
118        else
119        pointershape='fullcross';%set pointer with cross shape (default when mouse is over an axis)
120        end
121    end
122    FigData=get(hCurrentFig,'UserData');
123    tagaxes=get(CurrentAxes,'tag');
124    if isfield(FigData,tagaxes)
125        Field=FigData.(tagaxes);
126        if isfield(Field,'ListVarName')
127            [CellInfo,NbDimArray]=find_field_cells(Field);%analyse the physical fields contained in Field
128            text_displ_1='';
129            text_displ_2='';
130            text_displ_3='';
131            text_displ_4='';
132            text_displ_5='';
133            ivec=[];
134            xName='';
135            z=[];
136            for icell=1:numel(CellInfo)%look for all physical fields
137                if NbDimArray(icell)>=2 % select 2D field
138                    if  isfield(Field,'CoordMesh') && ~isempty(Field.CoordMesh)&& strcmp(CellInfo{icell}.CoordType,'scattered')%case of unstructured data
139                        X=Field.(Field.ListVarName{CellInfo{icell}.CoordIndex(end)});
140                        Y=Field.(Field.ListVarName{CellInfo{icell}.CoordIndex(end-1)});
141                        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
142                            (Y<(xy(1,2)+Field.CoordMesh/3) & Y>(xy(1,2)-Field.CoordMesh/3));%f
143                        ivec=find(flag_vec,1);% search the (first) selected vector index ivec
144                        hhh=findobj(CurrentAxes,'Tag','vector_marker');
145                        if ~isempty(ivec)
146                            % mark the vectors with a circle in the absence of other operations
147                            if ~test_object && ~test_edit_object && ~test_ruler && ~CheckZoomFig
148                                pointershape='arrow'; %mouse indicates  the detection of a vector
149                                if isempty(hhh)
150                                    set(0,'CurrentFigure',hCurrentFig)
151                                    set(hCurrentFig,'CurrentAxes',CurrentAxes)
152                                    rectangle('Curvature',[1 1],...
153                                        'Position',[X(ivec)-Field.CoordMesh/2 Y(ivec)-Field.CoordMesh/2 Field.CoordMesh Field.CoordMesh],'EdgeColor','m',...
154                                        'LineStyle','-','Tag','vector_marker');
155                                else
156                                    set(hhh,'Visible','on')
157                                    set(hhh,'Position',[X(ivec)-Field.CoordMesh/2 Y(ivec)-Field.CoordMesh/2 Field.CoordMesh Field.CoordMesh])
158                                end
159                            end
160                            %display the field values
161                            for ivar=1:numel(CellInfo{icell}.VarIndex)
162                                VarName=Field.ListVarName{CellInfo{icell}.VarIndex(ivar)};
163                                VarVal=Field.(VarName)(ivec);
164                                var_text=[VarName '=' num2str(VarVal,4) ','];
165                                if isequal(ivar,CellInfo{icell}.CoordIndex(end))||isequal(ivar,CellInfo{icell}.CoordIndex(end-1))||isequal(ivar,CellInfo{icell}.CoordIndex(1))
166                                    text_displ_1=[text_displ_1 var_text];
167                                elseif (isfield(CellInfo{icell},'VarIndex_vector_x') && isequal(ivar,CellInfo{icell}.VarIndex_vector_x))||isequal(ivar,CellInfo{icell}.VarIndex_vector_y)||...
168                                        (isfield(CellInfo{icell},'VarIndex_vector_z') && isequal(ivar,CellInfo{icell}.VarIndex_vector_z))
169                                    text_displ_4=[text_displ_4 var_text];
170                                else
171                                    text_displ_5=[text_displ_5 var_text];
172                                end
173                            end
174                        else
175                            if ~isempty(hhh)
176                                set(hhh,'Visible','off')
177                            end
178                        end
179                    elseif strcmp(CellInfo{icell}.CoordType,'grid') %structured coordinates
180                        yName=Field.ListVarName{CellInfo{icell}.CoordIndex(1)};
181                        xName=Field.ListVarName{CellInfo{icell}.CoordIndex(2)};
182                        y=Field.(yName);
183                        x=Field.(xName);
184                        VarName=Field.ListVarName{CellInfo{icell}.VarIndex(1)};
185                        nxy=size(Field.(VarName));
186                        MaxAY=max(y(1),y(end));
187                        MinAY=min(y(1),y(end));
188                        if (xy(1,1)>x(1))&(xy(1,1)<x(end))&(xy(1,2)<MaxAY)&(xy(1,2)>MinAY)
189                            indx0=1+round((nxy(2)-1)*(xy(1,1)-x(1))/(x(end)-x(1))); % index x of pixel
190                            indy0=1+round((nxy(1)-1)*(xy(1,2)-y(1))/(y(end)-y(1))); % index y of pixel
191                            if indx0>=1 & indx0<=nxy(2) & indy0>=1 & indy0<=nxy(1)
192                                text_displ_2=['i='  num2str(indx0) ',j=' num2str(indy0) ','];
193                                for ivar=1:numel(CellInfo{icell}.VarIndex)
194                                    VarName=Field.ListVarName{CellInfo{icell}.VarIndex(ivar)};
195                                    VarVal=Field.(VarName)(indy0,indx0,:);
196                                    var_text=[VarName '=' num2str(VarVal) ','];
197                                    text_displ_4=[text_displ_4 var_text];
198                                end
199                            end
200                        end
201                    end
202                end
203            end
204            % display the current x,y plot coordinates in the absence of detected vector
205            if isempty(ivec)
206                if isempty(xName)
207                    xName='x';
208                    yName='y';
209                end
210                text_displ_1=[xName '=' num2str(xy(1,1),4) ', ' yName '=' num2str(xy(1,2),4) ','];
211            end
212            %display the z coordinate if defined by the projection plane
213            if isfield(Field,'ObjectType') && strcmp(Field.ObjectType,'plane') && isfield(Field,'ObjectCoord') && length(Field.ObjectCoord)>=3
214                pos=[xy(1,1) xy(1,2) 0];
215                if isfield(Field,'ObjectAngle')&&~isequal(Field.ObjectAngle,[0 0 0])
216                    om=norm(Field.ObjectAngle);%norm of rotation angle in radians
217                    OmAxis=Field.ObjectAngle/om; %unit vector marking the rotation axis
218                    cos_om=cos(pi*om/180);
219                    sin_om=sin(pi*om/180);
220                    pos=[xy(1,1) xy(1,2) 0];
221                    pos=cos_om*pos+sin_om*cross(OmAxis,pos)+(1-cos_om)*(OmAxis*pos')*OmAxis;
222                end
223                pos=pos+[Field.ObjectCoord 0];
224                text_displ_3=[text_displ_3 'x,y,z=' num2str(pos,4)];
225            end
226            %                     if ~isempty(z)
227            %                         text_displ_1=[text_displ_1 ' z=' num2str(z,4)];
228            %                     end
229            % case of PIV correlation display
230            if test_piv
231                par=read_GUI(hhciv.Civ1);
232                [dd,ind_pt]=min(abs(Field.X-xy(1,1))+abs(Field.Y-xy(1,2)));
233                xround=Field.X(ind_pt);
234                yround=Field.Y(ind_pt);
235                %                         par.Grid=[xround size(Field.A,1)-yround+1];
236                par.Grid=[xround yround];
237                % mark the correlation box with a rectangle
238                par.ImageA=Field.A;
239                par.ImageB=Field.B;
240                par.ImageHeight=size(par.ImageA,1);
241                par.ImageWidth=size(par.ImageA,2);
242                Param.Civ1=par;
243                ibx2=floor((par.CorrBoxSize(1)-1)/2);
244                iby2=floor((par.CorrBoxSize(2)-1)/2);
245                isx2=floor((par.SearchBoxSize(1)-1)/2);
246                isy2=floor((par.SearchBoxSize(2)-1)/2);
247                shiftx=par.SearchBoxShift(1);
248                shifty=par.SearchBoxShift(2);
249                hhh=findobj(CurrentAxes,'Tag','PIV_box_marker');
250                hhhh=findobj(CurrentAxes,'Tag','PIV_search_marker');
251                if isempty(hhh)
252                    set(0,'CurrentFigure',hCurrentFig)
253                    set(hCurrentFig,'CurrentAxes',CurrentAxes)
254                    rectangle('Curvature',[0 0],...
255                        'Position',[xround-ibx2 yround-iby2 2*ibx2 2*iby2],'EdgeColor','m',...
256                        'LineStyle','-','Tag','PIV_box_marker');
257                    rectangle('Curvature',[0 0],...
258                        'Position',[xround-isx2+shiftx yround-isy2+shifty 2*isx2 2*isy2],'EdgeColor','m',...
259                        'LineStyle','- -','Tag','PIV_search_marker');
260                else
261                    set(hhh,'Position',[xround-ibx2 yround-iby2 2*ibx2 2*iby2])
262                    set(hhhh,'Position',[xround-isx2+shiftx yround-isy2+shifty 2*isx2 2*isy2])
263                end
264                [Data,errormsg,result_conv]= civ_matlab(Param);
265                if ~isempty(errormsg)
266                    text_displ_5=errormsg;
267                else
268                    rangx(1)=-(isx2-ibx2)+shiftx;
269                    rangx(2)=isx2-ibx2+shiftx;
270                    rangy(1)=-(isy2-iby2)-shifty;
271                    rangy(2)=(isy2-iby2)-shifty;
272                    hcorr=[];
273                    if isfield(AxeData,'CurrentCorrImage')
274                        hcorr=AxeData.CurrentCorrImage;
275                        if ~ishandle(hcorr)
276                            hcorr=[];
277                        end
278                    end
279                    if isempty(hcorr)
280                        corrfig=findobj(allchild(0),'tag','corrfig');
281                        if ~isempty(corrfig)
282                            set(0,'CurrentFigure',corrfig(1))
283                            AxeData.CurrentCorrImage=imagesc(rangx,-rangy,result_conv,[0 1]);
284                            AxeData.CurrentVector=line([0 Data.Civ1_U],[0 Data.Civ1_V],'Tag','vector');
285                            AxeData.TitleHandle=title(num2str(par.Grid));
286                            colorbar
287                            set(CurrentAxes,'UserData',AxeData)
288                            set(get(AxeData.CurrentCorrImage,'parent'),'YDir','normal')
289                        end
290                    else
291                        set(AxeData.CurrentCorrImage,'CData',result_conv)
292                        set(AxeData.CurrentCorrImage,'XData',rangx)
293                        set(AxeData.CurrentCorrImage,'YData',-rangy)
294                        set(AxeData.CurrentVector,'XData',[0 Data.Civ1_U],'YData',[0 Data.Civ1_V])
295                        set(AxeData.TitleHandle,'String',num2str(par.Grid))
296                    end
297                end
298            end
299        end
300    end
301end
302if ~isempty(text_displ_1)
303    text_displ=[{text_displ_1};{text_displ_2};{text_displ_3};{text_displ_4};{text_displ_5}];
304    ind_blank=find(strcmp('',text_displ));
305    if ~isempty(ind_blank)
306        text_displ(ind_blank)=[];
307    end
308    %set(handles.text_display,'String',text_displ)
309    set(htext_display,'String',text_displ)
310else
311   %set(handles.text_display,'String',get(handles.text_display,'UserData'))
312   set(htext_display,'String',get(handles.text_display,'UserData'))
313end
314
315%%%%%%%%%%%%%
316%% draw a zoom rectangle if checkZoomFig has been selected
317if test_zoom_draw
318   xy_rect=AxeData.CurrentOrigin;% mark the previous position from mouse down
319   if ~isempty(xy_rect)
320        rect(1)=min(xy(1,1),xy_rect(1));%origin rectangle, x coordinate
321        rect(2)=min(xy(1,2),xy_rect(2));%origin rectangle, y coordinate
322        rect(3)=abs(xy(1,1)-xy_rect(1));%rectangle width
323        rect(4)=abs(xy(1,2)-xy_rect(2));%rectangle height
324        if rect(3)>0 && rect(4)>0
325            if isfield(AxeData,'CurrentRectZoom')&& ~isempty(AxeData.CurrentRectZoom) && ishandle(AxeData.CurrentRectZoom)
326                set(AxeData.CurrentRectZoom,'Position',rect);%update the rectangle position
327            else
328                AxeData.CurrentRectZoom=rectangle('Position',rect,'Tag','rect_zoom','EdgeColor','b');
329                set(CurrentAxes,'UserData',AxeData)
330            end
331        end
332   end
333end
334
335%%%%%%%%%%%%%%%%%
336%% create or modify an object
337if strcmp(htype,'axes') && ~isempty(huvmat) && test_object
338    UvData=get(huvmat,'UserData');
339    PlotData=get(AxeData.CurrentObject,'UserData');
340    if ~isfield(PlotData,'IndexObj')
341        set(hCurrentFig,'Pointer','arrow');
342        return
343    end
344    ObjectData=UvData.ProjObject{PlotData.IndexObj};
345    if isequal(hObject,huvmat)% if the mouse ifs over the GUI uvmat
346        ProjObject=UvData.ProjObject{get(hhuvmat.ListObject_1,'Value')};
347    else
348        ProjObject=UvData.ProjObject{get(hhuvmat.ListObject,'Value')};
349    end
350    XYData=AxeData.CurrentOrigin;
351    if isequal(AxeData.Drawing,'create') && isfield(AxeData,'CurrentOrigin') && ~isempty(AxeData.CurrentOrigin)
352        if strcmp(ObjectData.Type,'line')||strcmp(ObjectData.Type,'polyline')||strcmp(ObjectData.Type,'polygon')||strcmp(ObjectData.Type,'points')
353            ObjectData.Coord=[ObjectData.Coord ;xy(1,1:2)];
354            % ObjectData.Coord(end,:)=xy(1,:);
355        elseif strcmp(ObjectData.Type,'rectangle')||strcmp(ObjectData.Type,'ellipse')||strcmp(ObjectData.Type,'volume')
356                ObjectData.Coord=(AxeData.CurrentOrigin+xy(1,1:2))/2;% keep only the first point coordinate     
357                ObjectData.RangeX=abs(ObjectData.Coord(1,1)-xy(1,1));%rectangle width
358                ObjectData.RangeY=abs(ObjectData.Coord(1,2)-xy(1,2));%rectangle height
359        elseif isequal(ObjectData.Type,'plane') %case of 'plane'
360            DX=(xy(1,1)-ObjectData.Coord(1,1));
361            DY=(xy(1,2)-ObjectData.Coord(1,2));
362            ObjectData.Phi=(angle(DX+i*DY))*180/pi;%rectangle widt
363            if isfield(ObjectData,'RangeX')
364                XMax=sqrt(DX*DX+DY*DY);
365                if XMax>max(ObjectData.RangeX)
366                    ObjectData.RangeX=[min(ObjectData.RangeX) XMax];
367                end
368            end
369        end
370        plot_object(ObjectData,ProjObject,AxeData.CurrentObject,'m');
371        pointershape='crosshair';
372    elseif test_edit_object && isequal(AxeData.Drawing,'translate')
373        DX=xy(1,1)-XYData(1);%translation from initial position
374        DY=xy(1,2)-XYData(2);
375        ObjectData.Coord(:,1)=ObjectData.Coord(:,1)+DX;
376        ObjectData.Coord(:,2)=ObjectData.Coord(:,2)+DY;
377        plot_object(ObjectData,ProjObject,AxeData.CurrentObject,'m');
378        pointershape='fleur';
379    elseif test_edit_object && isequal(AxeData.Drawing,'deform')
380        ind_move=AxeData.CurrentIndex;
381        ObjectData.Coord(ind_move,1)=xy(1,1);
382        ObjectData.Coord(ind_move,2)=xy(1,2);
383        plot_object(ObjectData,ProjObject,AxeData.CurrentObject,'m');
384        pointershape='circle';
385    end
386end
387
388%% detect calibration points if the GUI geometry_calib is opened
389h_geometry_calib=findobj(allchild(0),'Name','geometry_calib'); %find the geomterty_calib GUI
390if strcmp(htype,'axes') && ~CheckZoom && ~isempty(h_geometry_calib)
391    pointershape='crosshair';%default for geometry_calib: ready to create new points
392    hh_geometry_calib=guidata(h_geometry_calib);
393    if  ~isempty(xy) && isfield(hh_geometry_calib,'ListCoord')
394        h_ListCoord=hh_geometry_calib.ListCoord; %findobj(h_geometry_calib,'Tag','ListCoord');
395        data.Coord=get(h_ListCoord,'Data');
396        if isnumeric(data.Coord)&&~isempty(data.Coord)
397            if test_transform
398                            XCoord=(data.Coord(:,1));
399            YCoord=(data.Coord(:,2));
400            else
401            XCoord=(data.Coord(:,4));
402            YCoord=(data.Coord(:,5));
403            end
404            xy=get(CurrentAxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
405            if ~isempty(xy)
406                xlim=get(CurrentAxes,'XLim');
407                ind_range_x=abs((xlim(2)-xlim(1))/50);
408                ylim=get(CurrentAxes,'YLim');
409                ind_range_y=abs((ylim(2)-ylim(1))/50);
410                ind_range=sqrt(ind_range_x*ind_range_y);
411                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
412                              (YCoord<xy(1,2)+ind_range) & (YCoord>xy(1,2)-ind_range),1);%find the first calibration point in the neighborhood of the mouse
413                if ~isempty(index_point)
414                    pointershape='arrow';% default pointer is an arrow
415                end
416                hh=findobj('Tag','calib_points');%look for handle of calibration points
417               if ~isempty(hh) && ~isempty(get(hh,'UserData')) %&& get(hh_geometry_calib.CheckEnableMouse,'Value')
418                   %set(hh,'UserData',index_point)
419                    index_point=get(hh,'UserData');
420                    XCoord(index_point)=xy(1,1);
421                    YCoord(index_point)=xy(1,2);
422                    set(hh,'XData',XCoord)
423                    set(hh,'YData',YCoord)
424               end
425                if ~isempty(index_point)
426                    Data=get(h_ListCoord,'Data');
427                    Data(:,6)=zeros(size(Data,1),1);
428                    Data(index_point,6)=-1;%mrk the point on the GUI geometry_calib
429                    set(h_ListCoord,'Data',Data);
430                    hhh=findobj('Tag','calib_marker');%look for handle of point marker (circle)
431                    if ~isempty(hhh)
432                        set(hhh,'Position',[XCoord(index_point)-ind_range/2 YCoord(index_point)-ind_range/2 ind_range ind_range])
433                    else
434                                    rectangle('Curvature',[1 1],...
435                'Position',[xy(1,1)-ind_range/2 xy(1,2)-ind_range/2 ind_range ind_range],'EdgeColor','m',...
436                'LineStyle','-','Tag','calib_marker');
437                    end
438                end
439            end
440        end
441    end
442end
443
444%% draw ruler
445if test_ruler && isfield(AxeData,'Drawing') && isequal(AxeData.Drawing,'ruler')
446    if isfield(AxeData,'RulerHandle')
447        pointershape='crosshair'; %give  the mouse pointer a cross shape
448        RulerCoord=[AxeData.RulerCoord ;xy(1,1:2)]; %coordinates defining the ruler segment
449        set(AxeData.RulerHandle,'XData',RulerCoord(:,1));% updtate the x coordinates for the ruler graphic object
450        set(AxeData.RulerHandle,'YData',RulerCoord(:,2));% updtate the y coordinates for the ruler graphic object
451    end
452end
453
454%% update the mouse pointer
455if strcmp(pointershape,'zoom')||strcmp(pointershape,'zoomfig')
456    CData=set_pointershape(pointershape);
457    set(hCurrentFig,'Pointer','custom','PointerShapeCData',CData,'PointerShapeHotSpot',[9 9])
458else
459set(hCurrentFig,'Pointer',pointershape);
460end
461
462function CData=set_pointershape(pointershape)
463        CData=ones(16,16);
464        [ind_x,ind_y]=meshgrid([1:16],[1:16]);
465        if strcmp(pointershape,'zoom')
466        radius=(ind_x-9).*(ind_x-9)+(ind_y-8.5).*(ind_y-9);
467        CData(radius<25 & radius>16)=2; %make white circle
468        CData(radius<16 | radius>40)=NaN; %make the centre transparent
469        CData(16,16)=1; CData(15,16)=2;
470        CData(15,15)=1; CData(14,15)=2;
471        CData(14,14)=1; CData(13,14)=2;
472        CData(13,13)=1; CData(12,13)=2;
473        elseif strcmp(pointershape,'zoomfig')
474            CData(:,1:3)=2;
475            CData(:,14:16)=2;
476                        CData(1:3,:)=2;
477            CData(14:16,:)=2;
478            CData(CData==1)=NaN;
479        end
Note: See TracBrowser for help on using the repository browser.