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