[11] | 1 | %'mouse_motion': permanently called by mouse motion over a figure (Callback for 'WindowButtonMotionFcn' of the figure) |
---|
| 2 | %----------------------------------------------------------------------- |
---|
| 3 | % |
---|
| 4 | % function mouse_motion(hObject,eventdata,handles) |
---|
| 5 | % activated by the command: |
---|
| 6 | % set(hObject,'WindowButtonMotionFcn',{'mouse_motion',handles}) |
---|
| 7 | % where hObject is the handle of the figure |
---|
[809] | 8 | |
---|
| 9 | %======================================================================= |
---|
| 10 | % Copyright 2008-2014, LEGI UMR 5519 / CNRS UJF G-INP, Grenoble, France |
---|
| 11 | % http://www.legi.grenoble-inp.fr |
---|
| 12 | % Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.fr |
---|
[11] | 13 | % |
---|
| 14 | % This file is part of the toolbox UVMAT. |
---|
[809] | 15 | % |
---|
[11] | 16 | % UVMAT is free software; you can redistribute it and/or modify |
---|
[809] | 17 | % it under the terms of the GNU General Public License as published |
---|
| 18 | % by the Free Software Foundation; either version 2 of the license, |
---|
| 19 | % or (at your option) any later version. |
---|
| 20 | % |
---|
[11] | 21 | % UVMAT is distributed in the hope that it will be useful, |
---|
| 22 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 23 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
[809] | 24 | % GNU General Public License (see LICENSE.txt) for more details. |
---|
| 25 | %======================================================================= |
---|
[11] | 26 | |
---|
| 27 | function mouse_motion(hObject,eventdata,handles) |
---|
[78] | 28 | |
---|
[187] | 29 | FigData=get(hObject,'UserData'); |
---|
| 30 | 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 |
---|
[625] | 31 | hCurrentFig=get(get(FigData,'parent'),'parent'); |
---|
[187] | 32 | else |
---|
[625] | 33 | hCurrentFig=hObject;%usual plot |
---|
[187] | 34 | end |
---|
[714] | 35 | if strcmp(get(hCurrentFig,'Pointer'),'watch') |
---|
| 36 | return % no action if a calculation is running |
---|
| 37 | end |
---|
[625] | 38 | hhCurrentFig=guidata(hCurrentFig);%handles of the elements in the GUI containing the current figure (uvmat or view_field) |
---|
[622] | 39 | CheckZoom=get(hhCurrentFig.CheckZoom,'Value');% check for zoom on mode |
---|
| 40 | CheckZoomFig=get(hhCurrentFig.CheckZoomFig,'Value');% check for zoom sub fig creation mode |
---|
[625] | 41 | hPlotAxes=hhCurrentFig.PlotAxes';% handles of the main plot axes |
---|
| 42 | AxeData=get(hPlotAxes,'UserData');% data attached to the axis |
---|
[627] | 43 | htext_display(1)=handles.text_display; |
---|
| 44 | if isfield(AxeData,'htext_display')&&ishandle(AxeData.htext_display) |
---|
| 45 | htext_display(2)=AxeData.htext_display; |
---|
| 46 | end |
---|
[625] | 47 | test_draw=0;%test for mouse drawing of object, =0 by default |
---|
| 48 | if isfield(AxeData,'Drawing')&& ~isempty(AxeData.Drawing) |
---|
| 49 | test_draw=~isequal(AxeData.Drawing,'off');%=1 if mouse drawing of object is active |
---|
| 50 | end |
---|
[622] | 51 | test_zoom_draw=0; |
---|
[150] | 52 | test_object=0; %test for object editing or creation |
---|
[701] | 53 | test_create_object=0; |
---|
[681] | 54 | test_edit_object=0;% edit test for mouse shape: an arrow |
---|
[150] | 55 | test_ruler=0;%test for active ruler |
---|
[663] | 56 | test_transform=0; |
---|
[150] | 57 | huvmat=findobj(allchild(0),'tag','uvmat');%find the uvmat interface handle |
---|
[71] | 58 | if ~isempty(huvmat) |
---|
[432] | 59 | hhuvmat=guidata(huvmat);%handles of the elements in uvma |
---|
[701] | 60 | test_create_object=strcmp(get(hhuvmat.MenuObject,'checked'),'on'); |
---|
[650] | 61 | test_edit_object=get(hhuvmat.CheckEditObject,'Value'); |
---|
[156] | 62 | test_ruler=isequal(get(hhuvmat.MenuRuler,'checked'),'on'); |
---|
[664] | 63 | test_transform=~isequal(get(hhuvmat.TransformName,'Value'),1); |
---|
[150] | 64 | end |
---|
[231] | 65 | test_piv=0; |
---|
[856] | 66 | if isfield(FigData,'CivHandle')% look for handle of the civ_input GUI |
---|
[231] | 67 | if ~ishandle(FigData.CivHandle) |
---|
| 68 | delete(hObject) |
---|
[682] | 69 | set(hCurrentFig,'Pointer','arrow'); |
---|
[231] | 70 | return |
---|
| 71 | end |
---|
[856] | 72 | hhciv=guidata(FigData.CivHandle);% list of handles in the GUI civ_input |
---|
[231] | 73 | test_piv=1; |
---|
[150] | 74 | end |
---|
[432] | 75 | %find the current axe 'CurrentAxes' and display the current mouse position or uicontrol tag |
---|
[11] | 76 | text_displ_1=''; |
---|
| 77 | text_displ_2=''; |
---|
| 78 | text_displ_3=''; |
---|
| 79 | text_displ_4=''; |
---|
| 80 | |
---|
[625] | 81 | % AxeData=[];%default |
---|
[67] | 82 | xy=[];%default |
---|
[741] | 83 | set(hCurrentFig,'Units','normalized') |
---|
[622] | 84 | xy_fig=get(hObject,'CurrentPoint');% current point of the current figure (gcbo) |
---|
[11] | 85 | pointershape='arrow';% default pointer is an arrow |
---|
[150] | 86 | |
---|
[432] | 87 | %% loop on all the objects in the current figure, detect whether the mouse is over a plot axes |
---|
[622] | 88 | hchildren=get(hObject,'Children');%handles of all objects in the current figure |
---|
| 89 | check_visible=strcmp(get(hchildren,'Visible'),'on');% if visible='on', =0 otherwise |
---|
| 90 | hchildren=hchildren(check_visible); %kkep only the visible children |
---|
| 91 | PosChildren=get(hchildren,'Position');% set of object positions |
---|
| 92 | if iscell(PosChildren)% only one child |
---|
| 93 | PosLength=cellfun('length',PosChildren);% set of vector lengths for object positions |
---|
| 94 | hchildren=hchildren(PosLength==4);% keep only objects with position defined by a 4 element vector |
---|
| 95 | PosChildren=cell2mat(PosChildren(PosLength==4));% convert cells to matrix of positions |
---|
| 96 | end |
---|
| 97 | if size(PosChildren,2)~=4 |
---|
[682] | 98 | set(hCurrentFig,'Pointer','arrow'); |
---|
[622] | 99 | return |
---|
| 100 | end |
---|
| 101 | xy_fig_mat=ones(size(PosChildren,1),1)*xy_fig;% mouse position set to a matrix |
---|
| 102 | check_pos=xy_fig_mat >= PosChildren(:,1:2) & xy_fig_mat <= PosChildren(:,1:2)+PosChildren(:,3:4);% compare object to mouse position |
---|
| 103 | ind_object=find(check_pos(:,1) & check_pos(:,2),1);% select the index of the (first) object under the mouse |
---|
| 104 | hchild=hchildren(ind_object);% corresponding object handle |
---|
[432] | 105 | CurrentAxes=[]; |
---|
[622] | 106 | |
---|
| 107 | %if the mouse is over an axis, look at the data |
---|
[682] | 108 | htype=get(hchild,'Type'); |
---|
| 109 | if strcmp(htype,'axes') |
---|
[622] | 110 | CurrentAxes=hchild; |
---|
| 111 | xy=get(CurrentAxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates |
---|
| 112 | test_zoom_draw=test_draw && isequal(AxeData.Drawing,'zoom')&& isfield(AxeData,'CurrentOrigin') && isequal(get(gcf,'SelectionType'),'normal'); |
---|
| 113 | test_object=test_draw && isfield(AxeData,'CurrentObject') && ~isempty(AxeData.CurrentObject) && ishandle(AxeData.CurrentObject); |
---|
[701] | 114 | if CheckZoom |
---|
| 115 | pointershape='zoom'; |
---|
| 116 | elseif CheckZoomFig |
---|
| 117 | pointershape='zoomfig'; |
---|
| 118 | elseif ~test_edit_object && ~test_ruler |
---|
[699] | 119 | if CheckZoom |
---|
| 120 | pointershape='zoom'; |
---|
[701] | 121 | elseif test_draw|| test_create_object |
---|
| 122 | pointershape='crosshair';%set pointer with cross shape |
---|
[699] | 123 | else |
---|
[886] | 124 | pointershape='crosshair';%set pointer with large cross (default when mouse is over an axis) |
---|
[699] | 125 | end |
---|
[622] | 126 | end |
---|
[859] | 127 | FigData=get(hCurrentFig,'UserData'); % user data of the current figure |
---|
| 128 | tagaxes=get(CurrentAxes,'tag'); % tag name of the current axes, for instance PlotAxes |
---|
[622] | 129 | if isfield(FigData,tagaxes) |
---|
[859] | 130 | Field=FigData.(tagaxes); % the current field is sought as substructure of FigData with key tagaxes |
---|
[622] | 131 | if isfield(Field,'ListVarName') |
---|
| 132 | [CellInfo,NbDimArray]=find_field_cells(Field);%analyse the physical fields contained in Field |
---|
| 133 | text_displ_1=''; |
---|
| 134 | text_displ_2=''; |
---|
| 135 | text_displ_3=''; |
---|
| 136 | text_displ_4=''; |
---|
| 137 | text_displ_5=''; |
---|
| 138 | ivec=[]; |
---|
| 139 | xName=''; |
---|
| 140 | z=[]; |
---|
| 141 | for icell=1:numel(CellInfo)%look for all physical fields |
---|
| 142 | if NbDimArray(icell)>=2 % select 2D field |
---|
| 143 | if isfield(Field,'CoordMesh') && ~isempty(Field.CoordMesh)&& strcmp(CellInfo{icell}.CoordType,'scattered')%case of unstructured data |
---|
| 144 | X=Field.(Field.ListVarName{CellInfo{icell}.CoordIndex(end)}); |
---|
| 145 | Y=Field.(Field.ListVarName{CellInfo{icell}.CoordIndex(end-1)}); |
---|
| 146 | 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 |
---|
| 147 | (Y<(xy(1,2)+Field.CoordMesh/3) & Y>(xy(1,2)-Field.CoordMesh/3));%f |
---|
| 148 | ivec=find(flag_vec,1);% search the (first) selected vector index ivec |
---|
| 149 | hhh=findobj(CurrentAxes,'Tag','vector_marker'); |
---|
| 150 | if ~isempty(ivec) |
---|
| 151 | % mark the vectors with a circle in the absence of other operations |
---|
| 152 | if ~test_object && ~test_edit_object && ~test_ruler && ~CheckZoomFig |
---|
| 153 | pointershape='arrow'; %mouse indicates the detection of a vector |
---|
| 154 | if isempty(hhh) |
---|
[625] | 155 | set(0,'CurrentFigure',hCurrentFig) |
---|
| 156 | set(hCurrentFig,'CurrentAxes',CurrentAxes) |
---|
[622] | 157 | rectangle('Curvature',[1 1],... |
---|
| 158 | 'Position',[X(ivec)-Field.CoordMesh/2 Y(ivec)-Field.CoordMesh/2 Field.CoordMesh Field.CoordMesh],'EdgeColor','m',... |
---|
| 159 | 'LineStyle','-','Tag','vector_marker'); |
---|
[251] | 160 | else |
---|
[622] | 161 | set(hhh,'Visible','on') |
---|
| 162 | set(hhh,'Position',[X(ivec)-Field.CoordMesh/2 Y(ivec)-Field.CoordMesh/2 Field.CoordMesh Field.CoordMesh]) |
---|
[251] | 163 | end |
---|
[622] | 164 | end |
---|
| 165 | %display the field values |
---|
| 166 | for ivar=1:numel(CellInfo{icell}.VarIndex) |
---|
| 167 | VarName=Field.ListVarName{CellInfo{icell}.VarIndex(ivar)}; |
---|
| 168 | VarVal=Field.(VarName)(ivec); |
---|
| 169 | var_text=[VarName '=' num2str(VarVal,4) ',']; |
---|
| 170 | if isequal(ivar,CellInfo{icell}.CoordIndex(end))||isequal(ivar,CellInfo{icell}.CoordIndex(end-1))||isequal(ivar,CellInfo{icell}.CoordIndex(1)) |
---|
| 171 | text_displ_1=[text_displ_1 var_text]; |
---|
| 172 | elseif (isfield(CellInfo{icell},'VarIndex_vector_x') && isequal(ivar,CellInfo{icell}.VarIndex_vector_x))||isequal(ivar,CellInfo{icell}.VarIndex_vector_y)||... |
---|
| 173 | (isfield(CellInfo{icell},'VarIndex_vector_z') && isequal(ivar,CellInfo{icell}.VarIndex_vector_z)) |
---|
| 174 | text_displ_4=[text_displ_4 var_text]; |
---|
| 175 | else |
---|
| 176 | text_displ_5=[text_displ_5 var_text]; |
---|
[105] | 177 | end |
---|
[61] | 178 | end |
---|
[622] | 179 | else |
---|
| 180 | if ~isempty(hhh) |
---|
| 181 | set(hhh,'Visible','off') |
---|
| 182 | end |
---|
[71] | 183 | end |
---|
[622] | 184 | elseif strcmp(CellInfo{icell}.CoordType,'grid') %structured coordinates |
---|
| 185 | yName=Field.ListVarName{CellInfo{icell}.CoordIndex(1)}; |
---|
| 186 | xName=Field.ListVarName{CellInfo{icell}.CoordIndex(2)}; |
---|
| 187 | y=Field.(yName); |
---|
| 188 | x=Field.(xName); |
---|
| 189 | VarName=Field.ListVarName{CellInfo{icell}.VarIndex(1)}; |
---|
| 190 | nxy=size(Field.(VarName)); |
---|
| 191 | MaxAY=max(y(1),y(end)); |
---|
| 192 | MinAY=min(y(1),y(end)); |
---|
| 193 | if (xy(1,1)>x(1))&(xy(1,1)<x(end))&(xy(1,2)<MaxAY)&(xy(1,2)>MinAY) |
---|
| 194 | indx0=1+round((nxy(2)-1)*(xy(1,1)-x(1))/(x(end)-x(1))); % index x of pixel |
---|
| 195 | indy0=1+round((nxy(1)-1)*(xy(1,2)-y(1))/(y(end)-y(1))); % index y of pixel |
---|
| 196 | if indx0>=1 & indx0<=nxy(2) & indy0>=1 & indy0<=nxy(1) |
---|
| 197 | text_displ_2=['i=' num2str(indx0) ',j=' num2str(indy0) ',']; |
---|
| 198 | for ivar=1:numel(CellInfo{icell}.VarIndex) |
---|
| 199 | VarName=Field.ListVarName{CellInfo{icell}.VarIndex(ivar)}; |
---|
| 200 | VarVal=Field.(VarName)(indy0,indx0,:); |
---|
| 201 | var_text=[VarName '=' num2str(VarVal) ',']; |
---|
| 202 | text_displ_4=[text_displ_4 var_text]; |
---|
| 203 | end |
---|
| 204 | end |
---|
[251] | 205 | end |
---|
| 206 | end |
---|
[622] | 207 | end |
---|
| 208 | end |
---|
| 209 | % display the current x,y plot coordinates in the absence of detected vector |
---|
| 210 | if isempty(ivec) |
---|
| 211 | if isempty(xName) |
---|
| 212 | xName='x'; |
---|
| 213 | yName='y'; |
---|
| 214 | end |
---|
| 215 | text_displ_1=[xName '=' num2str(xy(1,1),4) ', ' yName '=' num2str(xy(1,2),4) ',']; |
---|
| 216 | end |
---|
| 217 | %display the z coordinate if defined by the projection plane |
---|
[741] | 218 | if isfield(Field,'ProjObjectType') && strcmp(Field.ProjObjectType,'plane') && isfield(Field,'ProjObjectCoord') && length(Field.ProjObjectCoord)>=3 |
---|
[622] | 219 | pos=[xy(1,1) xy(1,2) 0]; |
---|
[741] | 220 | if isfield(Field,'ProjObjectAngle')&&~isequal(Field.ProjObjectAngle,[0 0 0]) |
---|
| 221 | om=norm(Field.ProjObjectAngle);%norm of rotation angle in radians |
---|
| 222 | OmAxis=Field.ProjObjectAngle/om; %unit vector marking the rotation axis |
---|
[622] | 223 | cos_om=cos(pi*om/180); |
---|
| 224 | sin_om=sin(pi*om/180); |
---|
| 225 | pos=[xy(1,1) xy(1,2) 0]; |
---|
| 226 | pos=cos_om*pos+sin_om*cross(OmAxis,pos)+(1-cos_om)*(OmAxis*pos')*OmAxis; |
---|
| 227 | end |
---|
[741] | 228 | pos=pos+Field.ProjObjectCoord; |
---|
[622] | 229 | text_displ_3=[text_displ_3 'x,y,z=' num2str(pos,4)]; |
---|
| 230 | end |
---|
| 231 | % case of PIV correlation display |
---|
| 232 | if test_piv |
---|
[856] | 233 | [dd,ind_pt]=min(abs(Field.X-xy(1,1))+abs(Field.Y-xy(1,2))); |
---|
[862] | 234 | if isfield(hhciv,'TestCiv2') && strcmp(get(hhciv.Civ2,'Visible'),'on')&& ... |
---|
| 235 | strcmp(get(hhciv.TestCiv2,'Visible'),'on')&& get(hhciv.TestCiv2,'Value')% if TestCiv2 is activated |
---|
[856] | 236 | CivOption='Civ2'; |
---|
| 237 | Param.CheckCiv1=0; |
---|
| 238 | par_civ=read_GUI(hhciv.Civ2);%read the Civ2 panel in civ_input |
---|
[862] | 239 | par_civ.Civ1_SubRange=Field.Civ1_SubRange;% get the subranges used for patch |
---|
| 240 | par_civ.Civ1_NbCentres=Field.Civ1_NbCentres;% get the nbre of civ1 data points in each subrange |
---|
| 241 | par_civ.Civ1_Coord_tps=Field.Civ1_Coord_tps;% get the positions of the centres (Civ1 data) |
---|
| 242 | par_civ.Civ1_U_tps=Field.Civ1_U_tps;% get the tps coefficients for spline, U component |
---|
| 243 | par_civ.Civ1_V_tps=Field.Civ1_V_tps;% get the tps coefficients for spline, V component |
---|
[856] | 244 | par_civ.Civ1_Dt=Field.Civ1_Dt; |
---|
[858] | 245 | par_civ.Civ2_Dt=Field.Civ2_Dt; |
---|
[862] | 246 | shiftx=Field.ShiftX(ind_pt);% get field info stored in the cuirrent figure |
---|
[856] | 247 | shifty=Field.ShiftY(ind_pt); |
---|
| 248 | else |
---|
| 249 | CivOption='Civ1'; |
---|
| 250 | Param.CheckCiv2=0; |
---|
| 251 | par_civ=read_GUI(hhciv.Civ1);%read the Civ1 panel in civ_input |
---|
| 252 | shiftx=par_civ.SearchBoxShift(1); |
---|
| 253 | shifty=par_civ.SearchBoxShift(2); |
---|
| 254 | end |
---|
[622] | 255 | xround=Field.X(ind_pt); |
---|
| 256 | yround=Field.Y(ind_pt); |
---|
[856] | 257 | |
---|
[859] | 258 | % mark the correlation box with a rectangle in view_field |
---|
[856] | 259 | ibx2=floor((par_civ.CorrBoxSize(1)-1)/2); |
---|
| 260 | iby2=floor((par_civ.CorrBoxSize(2)-1)/2); |
---|
| 261 | isx2=floor((par_civ.SearchBoxSize(1)-1)/2); |
---|
| 262 | isy2=floor((par_civ.SearchBoxSize(2)-1)/2); |
---|
[622] | 263 | hhh=findobj(CurrentAxes,'Tag','PIV_box_marker'); |
---|
| 264 | hhhh=findobj(CurrentAxes,'Tag','PIV_search_marker'); |
---|
| 265 | if isempty(hhh) |
---|
[625] | 266 | set(0,'CurrentFigure',hCurrentFig) |
---|
| 267 | set(hCurrentFig,'CurrentAxes',CurrentAxes) |
---|
[622] | 268 | rectangle('Curvature',[0 0],... |
---|
| 269 | 'Position',[xround-ibx2 yround-iby2 2*ibx2 2*iby2],'EdgeColor','m',... |
---|
| 270 | 'LineStyle','-','Tag','PIV_box_marker'); |
---|
| 271 | rectangle('Curvature',[0 0],... |
---|
| 272 | 'Position',[xround-isx2+shiftx yround-isy2+shifty 2*isx2 2*isy2],'EdgeColor','m',... |
---|
| 273 | 'LineStyle','- -','Tag','PIV_search_marker'); |
---|
| 274 | else |
---|
| 275 | set(hhh,'Position',[xround-ibx2 yround-iby2 2*ibx2 2*iby2]) |
---|
| 276 | set(hhhh,'Position',[xround-isx2+shiftx yround-isy2+shifty 2*isx2 2*isy2]) |
---|
| 277 | end |
---|
[856] | 278 | |
---|
| 279 | % perform the PIV calculation as the single point xround yround |
---|
| 280 | Param.CheckFix1=0; |
---|
| 281 | Param.CheckPatch1=0;%desactivate all calculations except Civ2 or Civ1 |
---|
[855] | 282 | Param.Action.RUN=1; |
---|
| 283 | Param.ActionInput.ListCompareMode='PIV'; |
---|
[856] | 284 | par_civ.ImageA=Field.A; |
---|
| 285 | par_civ.ImageB=Field.B; |
---|
| 286 | par_civ.ImageHeight=size(par_civ.ImageA,1); |
---|
| 287 | par_civ.ImageWidth=size(par_civ.ImageA,2); |
---|
| 288 | par_civ.Grid=[xround yround];% PIV calculation with a single point |
---|
[858] | 289 | Param.ActionInput.(CivOption)=par_civ; |
---|
[855] | 290 | [Data,errormsg,result_conv]= civ_series(Param); |
---|
[622] | 291 | if ~isempty(errormsg) |
---|
| 292 | text_displ_5=errormsg; |
---|
| 293 | else |
---|
| 294 | rangx(1)=-(isx2-ibx2)+shiftx; |
---|
| 295 | rangx(2)=isx2-ibx2+shiftx; |
---|
| 296 | rangy(1)=-(isy2-iby2)-shifty; |
---|
| 297 | rangy(2)=(isy2-iby2)-shifty; |
---|
| 298 | hcorr=[]; |
---|
| 299 | if isfield(AxeData,'CurrentCorrImage') |
---|
| 300 | hcorr=AxeData.CurrentCorrImage; |
---|
| 301 | if ~ishandle(hcorr) |
---|
| 302 | hcorr=[]; |
---|
[207] | 303 | end |
---|
[11] | 304 | end |
---|
[622] | 305 | if isempty(hcorr) |
---|
| 306 | corrfig=findobj(allchild(0),'tag','corrfig'); |
---|
| 307 | if ~isempty(corrfig) |
---|
| 308 | set(0,'CurrentFigure',corrfig(1)) |
---|
[862] | 309 | AxeData.CurrentCorrImage=imagesc(rangx,-rangy,result_conv,[0 1]);% plot the correlation map, with full colormap from 0 to 1 |
---|
[858] | 310 | AxeData.CurrentVector=line([0 Data.([CivOption '_U'])],[0 Data.([CivOption '_V'])],'Tag','vector'); |
---|
[862] | 311 | AxeData.TitleHandle=title(['[x,y]= ' num2str(par_civ.Grid) ' px']); |
---|
[622] | 312 | colorbar |
---|
| 313 | set(CurrentAxes,'UserData',AxeData) |
---|
[862] | 314 | ParentAxe=get(AxeData.CurrentCorrImage,'parent'); |
---|
| 315 | set(ParentAxe,'YDir','normal') |
---|
| 316 | set(ParentAxe,'DataAspectRatio',[1 1 1]); %equal axis scale |
---|
[150] | 317 | end |
---|
[622] | 318 | else |
---|
| 319 | set(AxeData.CurrentCorrImage,'CData',result_conv) |
---|
| 320 | set(AxeData.CurrentCorrImage,'XData',rangx) |
---|
| 321 | set(AxeData.CurrentCorrImage,'YData',-rangy) |
---|
[862] | 322 | ParentAxe=get(AxeData.CurrentCorrImage,'parent'); |
---|
| 323 | rangx(1)=min(rangx(1),0); |
---|
| 324 | rangx(2)=max(rangx(2),0); |
---|
| 325 | rangy(2)=max(rangy(2),0); |
---|
| 326 | rangy(1)=min(rangy(1),0); |
---|
| 327 | set(ParentAxe,'XLim',rangx) |
---|
| 328 | set(ParentAxe,'YLim',[-rangy(2) -rangy(1)]) |
---|
[858] | 329 | set(AxeData.CurrentVector,'XData',[0 Data.([CivOption '_U'])],'YData',[0 Data.([CivOption '_V'])]); |
---|
[862] | 330 | set(AxeData.TitleHandle,'String',['[x,y]= ' num2str(par_civ.Grid) ' px']) |
---|
[11] | 331 | end |
---|
| 332 | end |
---|
[251] | 333 | end |
---|
[11] | 334 | end |
---|
| 335 | end |
---|
| 336 | end |
---|
[292] | 337 | if ~isempty(text_displ_1) |
---|
[542] | 338 | text_displ=[{text_displ_1};{text_displ_2};{text_displ_3};{text_displ_4};{text_displ_5}]; |
---|
| 339 | ind_blank=find(strcmp('',text_displ)); |
---|
| 340 | if ~isempty(ind_blank) |
---|
| 341 | text_displ(ind_blank)=[]; |
---|
| 342 | end |
---|
[627] | 343 | %set(handles.text_display,'String',text_displ) |
---|
| 344 | set(htext_display,'String',text_displ) |
---|
[292] | 345 | else |
---|
[627] | 346 | %set(handles.text_display,'String',get(handles.text_display,'UserData')) |
---|
| 347 | set(htext_display,'String',get(handles.text_display,'UserData')) |
---|
[292] | 348 | end |
---|
[11] | 349 | |
---|
[71] | 350 | %%%%%%%%%%%%% |
---|
[622] | 351 | %% draw a zoom rectangle if checkZoomFig has been selected |
---|
[71] | 352 | if test_zoom_draw |
---|
[622] | 353 | xy_rect=AxeData.CurrentOrigin;% mark the previous position from mouse down |
---|
[71] | 354 | if ~isempty(xy_rect) |
---|
| 355 | rect(1)=min(xy(1,1),xy_rect(1));%origin rectangle, x coordinate |
---|
| 356 | rect(2)=min(xy(1,2),xy_rect(2));%origin rectangle, y coordinate |
---|
| 357 | rect(3)=abs(xy(1,1)-xy_rect(1));%rectangle width |
---|
| 358 | rect(4)=abs(xy(1,2)-xy_rect(2));%rectangle height |
---|
[622] | 359 | if rect(3)>0 && rect(4)>0 |
---|
| 360 | if isfield(AxeData,'CurrentRectZoom')&& ~isempty(AxeData.CurrentRectZoom) && ishandle(AxeData.CurrentRectZoom) |
---|
[71] | 361 | set(AxeData.CurrentRectZoom,'Position',rect);%update the rectangle position |
---|
| 362 | else |
---|
[622] | 363 | AxeData.CurrentRectZoom=rectangle('Position',rect,'Tag','rect_zoom','EdgeColor','b'); |
---|
[432] | 364 | set(CurrentAxes,'UserData',AxeData) |
---|
[71] | 365 | end |
---|
| 366 | end |
---|
| 367 | end |
---|
| 368 | end |
---|
| 369 | |
---|
[11] | 370 | %%%%%%%%%%%%%%%%% |
---|
[150] | 371 | %% create or modify an object |
---|
[682] | 372 | if strcmp(htype,'axes') && ~isempty(huvmat) && test_object |
---|
[432] | 373 | UvData=get(huvmat,'UserData'); |
---|
[11] | 374 | PlotData=get(AxeData.CurrentObject,'UserData'); |
---|
[432] | 375 | if ~isfield(PlotData,'IndexObj') |
---|
[682] | 376 | set(hCurrentFig,'Pointer','arrow'); |
---|
[432] | 377 | return |
---|
| 378 | end |
---|
[622] | 379 | ObjectData=UvData.ProjObject{PlotData.IndexObj}; |
---|
[432] | 380 | if isequal(hObject,huvmat)% if the mouse ifs over the GUI uvmat |
---|
[622] | 381 | ProjObject=UvData.ProjObject{get(hhuvmat.ListObject_1,'Value')}; |
---|
[432] | 382 | else |
---|
[622] | 383 | ProjObject=UvData.ProjObject{get(hhuvmat.ListObject,'Value')}; |
---|
[432] | 384 | end |
---|
| 385 | XYData=AxeData.CurrentOrigin; |
---|
| 386 | if isequal(AxeData.Drawing,'create') && isfield(AxeData,'CurrentOrigin') && ~isempty(AxeData.CurrentOrigin) |
---|
| 387 | if strcmp(ObjectData.Type,'line')||strcmp(ObjectData.Type,'polyline')||strcmp(ObjectData.Type,'polygon')||strcmp(ObjectData.Type,'points') |
---|
| 388 | ObjectData.Coord=[ObjectData.Coord ;xy(1,1:2)]; |
---|
| 389 | % ObjectData.Coord(end,:)=xy(1,:); |
---|
| 390 | elseif strcmp(ObjectData.Type,'rectangle')||strcmp(ObjectData.Type,'ellipse')||strcmp(ObjectData.Type,'volume') |
---|
[622] | 391 | ObjectData.Coord=(AxeData.CurrentOrigin+xy(1,1:2))/2;% keep only the first point coordinate |
---|
| 392 | ObjectData.RangeX=abs(ObjectData.Coord(1,1)-xy(1,1));%rectangle width |
---|
| 393 | ObjectData.RangeY=abs(ObjectData.Coord(1,2)-xy(1,2));%rectangle height |
---|
[432] | 394 | elseif isequal(ObjectData.Type,'plane') %case of 'plane' |
---|
| 395 | DX=(xy(1,1)-ObjectData.Coord(1,1)); |
---|
| 396 | DY=(xy(1,2)-ObjectData.Coord(1,2)); |
---|
| 397 | ObjectData.Phi=(angle(DX+i*DY))*180/pi;%rectangle widt |
---|
| 398 | if isfield(ObjectData,'RangeX') |
---|
| 399 | XMax=sqrt(DX*DX+DY*DY); |
---|
| 400 | if XMax>max(ObjectData.RangeX) |
---|
| 401 | ObjectData.RangeX=[min(ObjectData.RangeX) XMax]; |
---|
[11] | 402 | end |
---|
[432] | 403 | end |
---|
[11] | 404 | end |
---|
[432] | 405 | plot_object(ObjectData,ProjObject,AxeData.CurrentObject,'m'); |
---|
| 406 | pointershape='crosshair'; |
---|
[681] | 407 | elseif test_edit_object && isequal(AxeData.Drawing,'translate') |
---|
[432] | 408 | DX=xy(1,1)-XYData(1);%translation from initial position |
---|
| 409 | DY=xy(1,2)-XYData(2); |
---|
| 410 | ObjectData.Coord(:,1)=ObjectData.Coord(:,1)+DX; |
---|
| 411 | ObjectData.Coord(:,2)=ObjectData.Coord(:,2)+DY; |
---|
| 412 | plot_object(ObjectData,ProjObject,AxeData.CurrentObject,'m'); |
---|
| 413 | pointershape='fleur'; |
---|
[681] | 414 | elseif test_edit_object && isequal(AxeData.Drawing,'deform') |
---|
[432] | 415 | ind_move=AxeData.CurrentIndex; |
---|
| 416 | ObjectData.Coord(ind_move,1)=xy(1,1); |
---|
| 417 | ObjectData.Coord(ind_move,2)=xy(1,2); |
---|
| 418 | plot_object(ObjectData,ProjObject,AxeData.CurrentObject,'m'); |
---|
| 419 | pointershape='circle'; |
---|
[11] | 420 | end |
---|
[432] | 421 | end |
---|
[67] | 422 | |
---|
[150] | 423 | %% detect calibration points if the GUI geometry_calib is opened |
---|
[67] | 424 | h_geometry_calib=findobj(allchild(0),'Name','geometry_calib'); %find the geomterty_calib GUI |
---|
[682] | 425 | if strcmp(htype,'axes') && ~CheckZoom && ~isempty(h_geometry_calib) |
---|
[67] | 426 | pointershape='crosshair';%default for geometry_calib: ready to create new points |
---|
| 427 | hh_geometry_calib=guidata(h_geometry_calib); |
---|
[156] | 428 | if ~isempty(xy) && isfield(hh_geometry_calib,'ListCoord') |
---|
[67] | 429 | h_ListCoord=hh_geometry_calib.ListCoord; %findobj(h_geometry_calib,'Tag','ListCoord'); |
---|
[657] | 430 | data.Coord=get(h_ListCoord,'Data'); |
---|
| 431 | if isnumeric(data.Coord)&&~isempty(data.Coord) |
---|
[663] | 432 | if test_transform |
---|
[738] | 433 | XCoord=(data.Coord(:,1)); |
---|
| 434 | YCoord=(data.Coord(:,2)); |
---|
[663] | 435 | else |
---|
[738] | 436 | XCoord=(data.Coord(:,4)); |
---|
| 437 | YCoord=(data.Coord(:,5)); |
---|
[663] | 438 | end |
---|
[432] | 439 | xy=get(CurrentAxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates |
---|
[67] | 440 | if ~isempty(xy) |
---|
[432] | 441 | xlim=get(CurrentAxes,'XLim'); |
---|
[738] | 442 | % ind_range_x=abs((xlim(2)-xlim(1))/50); |
---|
[432] | 443 | ylim=get(CurrentAxes,'YLim'); |
---|
[738] | 444 | ind_range=max(abs(xlim(2)-xlim(1)),abs(ylim(end)-ylim(1)))/25;%defines the size of the circle marker |
---|
| 445 | % ind_range_y=abs((ylim(2)-ylim(1))/50); |
---|
| 446 | % ind_range=sqrt(ind_range_x*ind_range_y); |
---|
| 447 | index_point=find((XCoord<xy(1,1)+ind_range/2) & (XCoord>xy(1,1)-ind_range/2) & ...%flagx=1 for the vectors with x position selected by the mouse |
---|
| 448 | (YCoord<xy(1,2)+ind_range/2) & (YCoord>xy(1,2)-ind_range/2),1);%find the first calibration point in the neighborhood of the mouse |
---|
[67] | 449 | if ~isempty(index_point) |
---|
[738] | 450 | pointershape='arrow';% default pointer is an arrow |
---|
[78] | 451 | end |
---|
| 452 | hh=findobj('Tag','calib_points');%look for handle of calibration points |
---|
[738] | 453 | if ~isempty(hh) && ~isempty(get(hh,'UserData')) %&& get(hh_geometry_calib.CheckEnableMouse,'Value') |
---|
| 454 | %set(hh,'UserData',index_point) |
---|
[173] | 455 | index_point=get(hh,'UserData'); |
---|
[78] | 456 | XCoord(index_point)=xy(1,1); |
---|
| 457 | YCoord(index_point)=xy(1,2); |
---|
| 458 | set(hh,'XData',XCoord) |
---|
| 459 | set(hh,'YData',YCoord) |
---|
[738] | 460 | end |
---|
[78] | 461 | if ~isempty(index_point) |
---|
[738] | 462 | set(hh_geometry_calib.CoordLine,'String',num2str(index_point)) |
---|
| 463 | % Data=get(h_ListCoord,'Data'); |
---|
| 464 | % Data(:,6)=zeros(size(Data,1),1); |
---|
| 465 | % Data(index_point,6)=-1;%mrk the point on the GUI geometry_calib |
---|
| 466 | % set(h_ListCoord,'Data',Data); |
---|
[67] | 467 | hhh=findobj('Tag','calib_marker');%look for handle of point marker (circle) |
---|
| 468 | if ~isempty(hhh) |
---|
[71] | 469 | set(hhh,'Position',[XCoord(index_point)-ind_range/2 YCoord(index_point)-ind_range/2 ind_range ind_range]) |
---|
[657] | 470 | else |
---|
[837] | 471 | axes(hchild) |
---|
[738] | 472 | rectangle('Curvature',[1 1],... |
---|
| 473 | 'Position',[XCoord(index_point)-ind_range/2 YCoord(index_point)-ind_range/2 ind_range ind_range],'EdgeColor','m',... |
---|
| 474 | 'LineStyle','-','Tag','calib_marker'); |
---|
[67] | 475 | end |
---|
[78] | 476 | end |
---|
[67] | 477 | end |
---|
| 478 | end |
---|
| 479 | end |
---|
| 480 | end |
---|
| 481 | |
---|
[150] | 482 | %% draw ruler |
---|
[156] | 483 | if test_ruler && isfield(AxeData,'Drawing') && isequal(AxeData.Drawing,'ruler') |
---|
| 484 | if isfield(AxeData,'RulerHandle') |
---|
| 485 | pointershape='crosshair'; %give the mouse pointer a cross shape |
---|
| 486 | RulerCoord=[AxeData.RulerCoord ;xy(1,1:2)]; %coordinates defining the ruler segment |
---|
| 487 | set(AxeData.RulerHandle,'XData',RulerCoord(:,1));% updtate the x coordinates for the ruler graphic object |
---|
| 488 | set(AxeData.RulerHandle,'YData',RulerCoord(:,2));% updtate the y coordinates for the ruler graphic object |
---|
| 489 | end |
---|
[60] | 490 | end |
---|
[150] | 491 | |
---|
| 492 | %% update the mouse pointer |
---|
[699] | 493 | if strcmp(pointershape,'zoom')||strcmp(pointershape,'zoomfig') |
---|
| 494 | CData=set_pointershape(pointershape); |
---|
| 495 | set(hCurrentFig,'Pointer','custom','PointerShapeCData',CData,'PointerShapeHotSpot',[9 9]) |
---|
| 496 | else |
---|
[625] | 497 | set(hCurrentFig,'Pointer',pointershape); |
---|
[699] | 498 | end |
---|
| 499 | |
---|
| 500 | function CData=set_pointershape(pointershape) |
---|
| 501 | CData=ones(16,16); |
---|
| 502 | [ind_x,ind_y]=meshgrid([1:16],[1:16]); |
---|
| 503 | if strcmp(pointershape,'zoom') |
---|
| 504 | radius=(ind_x-9).*(ind_x-9)+(ind_y-8.5).*(ind_y-9); |
---|
| 505 | CData(radius<25 & radius>16)=2; %make white circle |
---|
| 506 | CData(radius<16 | radius>40)=NaN; %make the centre transparent |
---|
| 507 | CData(16,16)=1; CData(15,16)=2; |
---|
| 508 | CData(15,15)=1; CData(14,15)=2; |
---|
| 509 | CData(14,14)=1; CData(13,14)=2; |
---|
| 510 | CData(13,13)=1; CData(12,13)=2; |
---|
| 511 | elseif strcmp(pointershape,'zoomfig') |
---|
| 512 | CData(:,1:3)=2; |
---|
| 513 | CData(:,14:16)=2; |
---|
| 514 | CData(1:3,:)=2; |
---|
| 515 | CData(14:16,:)=2; |
---|
| 516 | CData(CData==1)=NaN; |
---|
| 517 | end |
---|