source: trunk/src/mouse_motion.m @ 714

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

various improvements

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