Changeset 622 for trunk/src/mouse_motion.m
- Timestamp:
- Apr 29, 2013, 11:35:27 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/mouse_motion.m
r575 r622 35 35 end 36 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 37 CheckZoom=get(hhCurrentFig.CheckZoom,'Value');% check for zoom on mode 38 CheckZoomFig=get(hhCurrentFig.CheckZoomFig,'Value');% check for zoom sub fig creation mode 39 test_zoom_draw=0; 38 40 test_draw=0;%test for mouse drawing of object, =0 by default 39 41 test_object=0; %test for object editing or creation 40 42 test_edit_object=0;% edit test for mouse shap: an arrow 41 test_zoom_draw=0; % test for zoom drawing42 43 test_ruler=0;%test for active ruler 43 44 huvmat=findobj(allchild(0),'tag','uvmat');%find the uvmat interface handle … … 64 65 65 66 AxeData=[];%default 66 mouse=[];67 67 xy=[];%default 68 68 xy_fig=get(hObject,'CurrentPoint');% current point of the current figure (gcbo) 69 69 pointershape='arrow';% default pointer is an arrow 70 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 figure73 74 71 %% loop on all the objects in the current figure, detect whether the mouse is over a plot axes 72 hchildren=get(hObject,'Children');%handles of all objects in the current figure 73 check_visible=strcmp(get(hchildren,'Visible'),'on');% if visible='on', =0 otherwise 74 hchildren=hchildren(check_visible); %kkep only the visible children 75 PosChildren=get(hchildren,'Position');% set of object positions 76 if iscell(PosChildren)% only one child 77 PosLength=cellfun('length',PosChildren);% set of vector lengths for object positions 78 hchildren=hchildren(PosLength==4);% keep only objects with position defined by a 4 element vector 79 PosChildren=cell2mat(PosChildren(PosLength==4));% convert cells to matrix of positions 80 end 81 if size(PosChildren,2)~=4 82 return 83 end 84 xy_fig_mat=ones(size(PosChildren,1),1)*xy_fig;% mouse position set to a matrix 85 check_pos=xy_fig_mat >= PosChildren(:,1:2) & xy_fig_mat <= PosChildren(:,1:2)+PosChildren(:,3:4);% compare object to mouse position 86 ind_object=find(check_pos(:,1) & check_pos(:,2),1);% select the index of the (first) object under the mouse 87 hchild=hchildren(ind_object);% corresponding object handle 75 88 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 89 90 %if the mouse is over an axis, look at the data 91 if strcmp(get(hchild,'Type'),'axes') 92 CurrentAxes=hchild; 93 xy=get(CurrentAxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates 94 AxeData=get(CurrentAxes,'UserData');% data attached to the axis 95 if isfield(AxeData,'Drawing')&& ~isempty(AxeData.Drawing) 96 test_draw=~isequal(AxeData.Drawing,'off');%=1 if mouse drawing of object is active 97 end 98 test_zoom_draw=test_draw && isequal(AxeData.Drawing,'zoom')&& isfield(AxeData,'CurrentOrigin') && isequal(get(gcf,'SelectionType'),'normal'); 99 test_object=test_draw && isfield(AxeData,'CurrentObject') && ~isempty(AxeData.CurrentObject) && ishandle(AxeData.CurrentObject); 100 %if ~test_edit_object && ~test_zoom_draw && ~test_ruler 101 if ~test_edit_object && ~test_ruler && ~CheckZoom 102 pointershape='crosshair';%set pointer with cross shape (default when mouse is over an axis) 103 end 104 FigData=get(CurrentFig,'UserData'); 105 tagaxes=get(CurrentAxes,'tag'); 106 if isfield(FigData,tagaxes) 107 Field=FigData.(tagaxes); 108 if isfield(Field,'ListVarName') 109 [CellInfo,NbDimArray]=find_field_cells(Field);%analyse the physical fields contained in Field 110 text_displ_1=''; 111 text_displ_2=''; 112 text_displ_3=''; 113 text_displ_4=''; 114 text_displ_5=''; 115 ivec=[]; 116 xName=''; 117 z=[]; 118 for icell=1:numel(CellInfo)%look for all physical fields 119 if NbDimArray(icell)>=2 % select 2D field 120 if isfield(Field,'CoordMesh') && ~isempty(Field.CoordMesh)&& strcmp(CellInfo{icell}.CoordType,'scattered')%case of unstructured data 121 X=Field.(Field.ListVarName{CellInfo{icell}.CoordIndex(end)}); 122 Y=Field.(Field.ListVarName{CellInfo{icell}.CoordIndex(end-1)}); 123 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 124 (Y<(xy(1,2)+Field.CoordMesh/3) & Y>(xy(1,2)-Field.CoordMesh/3));%f 125 ivec=find(flag_vec,1);% search the (first) selected vector index ivec 126 hhh=findobj(CurrentAxes,'Tag','vector_marker'); 127 if ~isempty(ivec) 128 % mark the vectors with a circle in the absence of other operations 129 if ~test_object && ~test_edit_object && ~test_ruler && ~CheckZoomFig 130 pointershape='arrow'; %mouse indicates the detection of a vector 131 if isempty(hhh) 132 set(0,'CurrentFigure',CurrentFig) 133 set(CurrentFig,'CurrentAxes',CurrentAxes) 134 rectangle('Curvature',[1 1],... 135 'Position',[X(ivec)-Field.CoordMesh/2 Y(ivec)-Field.CoordMesh/2 Field.CoordMesh Field.CoordMesh],'EdgeColor','m',... 136 'LineStyle','-','Tag','vector_marker'); 148 137 else 149 if ~isempty(hhh) 150 set(hhh,'Visible','off') 151 end 138 set(hhh,'Visible','on') 139 set(hhh,'Position',[X(ivec)-Field.CoordMesh/2 Y(ivec)-Field.CoordMesh/2 Field.CoordMesh Field.CoordMesh]) 152 140 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 141 end 142 %display the field values 143 for ivar=1:numel(CellInfo{icell}.VarIndex) 144 VarName=Field.ListVarName{CellInfo{icell}.VarIndex(ivar)}; 145 VarVal=Field.(VarName)(ivec); 146 var_text=[VarName '=' num2str(VarVal,4) ',']; 147 if isequal(ivar,CellInfo{icell}.CoordIndex(end))||isequal(ivar,CellInfo{icell}.CoordIndex(end-1))||isequal(ivar,CellInfo{icell}.CoordIndex(1)) 148 text_displ_1=[text_displ_1 var_text]; 149 elseif (isfield(CellInfo{icell},'VarIndex_vector_x') && isequal(ivar,CellInfo{icell}.VarIndex_vector_x))||isequal(ivar,CellInfo{icell}.VarIndex_vector_y)||... 150 (isfield(CellInfo{icell},'VarIndex_vector_z') && isequal(ivar,CellInfo{icell}.VarIndex_vector_z)) 151 text_displ_4=[text_displ_4 var_text]; 152 else 153 text_displ_5=[text_displ_5 var_text]; 154 end 155 end 156 else 157 if ~isempty(hhh) 158 set(hhh,'Visible','off') 159 end 160 end 161 elseif strcmp(CellInfo{icell}.CoordType,'grid') %structured coordinates 162 yName=Field.ListVarName{CellInfo{icell}.CoordIndex(1)}; 163 xName=Field.ListVarName{CellInfo{icell}.CoordIndex(2)}; 164 y=Field.(yName); 165 x=Field.(xName); 166 VarName=Field.ListVarName{CellInfo{icell}.VarIndex(1)}; 167 nxy=size(Field.(VarName)); 168 MaxAY=max(y(1),y(end)); 169 MinAY=min(y(1),y(end)); 170 if (xy(1,1)>x(1))&(xy(1,1)<x(end))&(xy(1,2)<MaxAY)&(xy(1,2)>MinAY) 171 indx0=1+round((nxy(2)-1)*(xy(1,1)-x(1))/(x(end)-x(1))); % index x of pixel 172 indy0=1+round((nxy(1)-1)*(xy(1,2)-y(1))/(y(end)-y(1))); % index y of pixel 173 if indx0>=1 & indx0<=nxy(2) & indy0>=1 & indy0<=nxy(1) 174 text_displ_2=['i=' num2str(indx0) ',j=' num2str(indy0) ',']; 175 for ivar=1:numel(CellInfo{icell}.VarIndex) 176 VarName=Field.ListVarName{CellInfo{icell}.VarIndex(ivar)}; 177 VarVal=Field.(VarName)(indy0,indx0,:); 178 var_text=[VarName '=' num2str(VarVal) ',']; 179 text_displ_4=[text_displ_4 var_text]; 174 180 end 175 181 end 176 182 end 177 183 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'; 184 end 185 end 186 % display the current x,y plot coordinates in the absence of detected vector 187 if isempty(ivec) 188 if isempty(xName) 189 xName='x'; 190 yName='y'; 191 end 192 text_displ_1=[xName '=' num2str(xy(1,1),4) ', ' yName '=' num2str(xy(1,2),4) ',']; 193 end 194 %display the z coordinate if defined by the projection plane 195 if isfield(Field,'ObjectType') && strcmp(Field.ObjectType,'plane') && isfield(Field,'ObjectCoord') && length(Field.ObjectCoord)>=3 196 pos=[xy(1,1) xy(1,2) 0]; 197 if isfield(Field,'ObjectAngle')&&~isequal(Field.ObjectAngle,[0 0 0]) 198 om=norm(Field.ObjectAngle);%norm of rotation angle in radians 199 OmAxis=Field.ObjectAngle/om; %unit vector marking the rotation axis 200 cos_om=cos(pi*om/180); 201 sin_om=sin(pi*om/180); 202 pos=[xy(1,1) xy(1,2) 0]; 203 pos=cos_om*pos+sin_om*cross(OmAxis,pos)+(1-cos_om)*(OmAxis*pos')*OmAxis; 204 end 205 pos=pos+[Field.ObjectCoord 0]; 206 text_displ_3=[text_displ_3 'x,y,z=' num2str(pos,4)]; 207 end 208 % if ~isempty(z) 209 % text_displ_1=[text_displ_1 ' z=' num2str(z,4)]; 210 % end 211 % case of PIV correlation display 212 if test_piv 213 par=read_GUI(hhciv.Civ1); 214 [dd,ind_pt]=min(abs(Field.X-xy(1,1))+abs(Field.Y-xy(1,2))); 215 xround=Field.X(ind_pt); 216 yround=Field.Y(ind_pt); 217 % par.Grid=[xround size(Field.A,1)-yround+1]; 218 par.Grid=[xround yround]; 219 % mark the correlation box with a rectangle 220 par.ImageA=Field.A; 221 par.ImageB=Field.B; 222 par.ImageHeight=size(par.ImageA,1); 223 par.ImageWidth=size(par.ImageA,2); 224 Param.Civ1=par; 225 ibx2=floor((par.CorrBoxSize(1)-1)/2); 226 iby2=floor((par.CorrBoxSize(2)-1)/2); 227 isx2=floor((par.SearchBoxSize(1)-1)/2); 228 isy2=floor((par.SearchBoxSize(2)-1)/2); 229 shiftx=par.SearchBoxShift(1); 230 shifty=par.SearchBoxShift(2); 231 hhh=findobj(CurrentAxes,'Tag','PIV_box_marker'); 232 hhhh=findobj(CurrentAxes,'Tag','PIV_search_marker'); 233 if isempty(hhh) 234 set(0,'CurrentFigure',CurrentFig) 235 set(CurrentFig,'CurrentAxes',CurrentAxes) 236 rectangle('Curvature',[0 0],... 237 'Position',[xround-ibx2 yround-iby2 2*ibx2 2*iby2],'EdgeColor','m',... 238 'LineStyle','-','Tag','PIV_box_marker'); 239 rectangle('Curvature',[0 0],... 240 'Position',[xround-isx2+shiftx yround-isy2+shifty 2*isx2 2*isy2],'EdgeColor','m',... 241 'LineStyle','- -','Tag','PIV_search_marker'); 242 else 243 set(hhh,'Position',[xround-ibx2 yround-iby2 2*ibx2 2*iby2]) 244 set(hhhh,'Position',[xround-isx2+shiftx yround-isy2+shifty 2*isx2 2*isy2]) 245 end 246 [Data,errormsg,result_conv]= civ_matlab(Param); 247 if ~isempty(errormsg) 248 text_displ_5=errormsg; 249 else 250 rangx(1)=-(isx2-ibx2)+shiftx; 251 rangx(2)=isx2-ibx2+shiftx; 252 rangy(1)=-(isy2-iby2)-shifty; 253 rangy(2)=(isy2-iby2)-shifty; 254 hcorr=[]; 255 if isfield(AxeData,'CurrentCorrImage') 256 hcorr=AxeData.CurrentCorrImage; 257 if ~ishandle(hcorr) 258 hcorr=[]; 183 259 end 184 text_displ_1=[xName '=' num2str(xy(1,1),4) ', ' yName '=' num2str(xy(1,2),4) ','];185 260 end 186 %display the z coordinate if defined by the projection plane187 if isfield(Field,'ObjectCoord') && length(Field.ObjectCoord)>=3188 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 radians191 OmAxis=Field.ObjectAngle/om; %unit vector marking the rotation axis192 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;261 if isempty(hcorr) 262 corrfig=findobj(allchild(0),'tag','corrfig'); 263 if ~isempty(corrfig) 264 set(0,'CurrentFigure',corrfig(1)) 265 AxeData.CurrentCorrImage=imagesc(rangx,-rangy,result_conv,[0 1]); 266 AxeData.CurrentVector=line([0 Data.Civ1_U],[0 Data.Civ1_V],'Tag','vector'); 267 AxeData.TitleHandle=title(num2str(par.Grid)); 268 colorbar 269 set(CurrentAxes,'UserData',AxeData) 270 set(get(AxeData.CurrentCorrImage,'parent'),'YDir','normal') 196 271 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 else 273 set(AxeData.CurrentCorrImage,'CData',result_conv) 274 set(AxeData.CurrentCorrImage,'XData',rangx) 275 set(AxeData.CurrentCorrImage,'YData',-rangy) 276 set(AxeData.CurrentVector,'XData',[0 Data.Civ1_U],'YData',[0 Data.Civ1_V]) 277 set(AxeData.TitleHandle,'String',num2str(par.Grid)) 272 278 end 273 279 end … … 288 294 289 295 %%%%%%%%%%%%% 290 %% draw a zoom rectangle if no object creation isselected296 %% draw a zoom rectangle if checkZoomFig has been selected 291 297 if test_zoom_draw 292 xy_rect=AxeData.CurrentOrigin; 298 xy_rect=AxeData.CurrentOrigin;% mark the previous position from mouse down 293 299 if ~isempty(xy_rect) 294 300 rect(1)=min(xy(1,1),xy_rect(1));%origin rectangle, x coordinate … … 296 302 rect(3)=abs(xy(1,1)-xy_rect(1));%rectangle width 297 303 rect(4)=abs(xy(1,2)-xy_rect(2));%rectangle height 298 if rect(3)>0 & rect(4)>0299 if isfield(AxeData,'CurrentRectZoom')& ishandle(AxeData.CurrentRectZoom)304 if rect(3)>0 && rect(4)>0 305 if isfield(AxeData,'CurrentRectZoom')&& ~isempty(AxeData.CurrentRectZoom) && ishandle(AxeData.CurrentRectZoom) 300 306 set(AxeData.CurrentRectZoom,'Position',rect);%update the rectangle position 301 307 else 302 AxeData.CurrentRectZoom=rectangle('Position',rect,' LineStyle',':','Tag','rect_zoom');308 AxeData.CurrentRectZoom=rectangle('Position',rect,'Tag','rect_zoom','EdgeColor','b'); 303 309 set(CurrentAxes,'UserData',AxeData) 304 310 end 305 311 end 306 312 end 307 pointershape='arrow';308 313 end 309 314 … … 316 321 return 317 322 end 318 ObjectData=UvData.Object{PlotData.IndexObj}; 319 ProjObject=[];% object (plane) whose projection is represented on the current axes 323 ObjectData=UvData.ProjObject{PlotData.IndexObj}; 320 324 if isequal(hObject,huvmat)% if the mouse ifs over the GUI uvmat 321 ProjObject=UvData. Object{get(hhuvmat.ListObject_1,'Value')};325 ProjObject=UvData.ProjObject{get(hhuvmat.ListObject_1,'Value')}; 322 326 else 323 ProjObject=UvData. Object{get(hhuvmat.ListObject,'Value')};327 ProjObject=UvData.ProjObject{get(hhuvmat.ListObject,'Value')}; 324 328 end 325 329 XYData=AxeData.CurrentOrigin; … … 329 333 % ObjectData.Coord(end,:)=xy(1,:); 330 334 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 ObjectData.Coord=(AxeData.CurrentOrigin+xy(1,1:2))/2;% keep only the first point coordinate 336 ObjectData.RangeX=abs(ObjectData.Coord(1,1)-xy(1,1));%rectangle width 337 ObjectData.RangeY=abs(ObjectData.Coord(1,2)-xy(1,2));%rectangle height 335 338 elseif isequal(ObjectData.Type,'plane') %case of 'plane' 336 339 DX=(xy(1,1)-ObjectData.Coord(1,1)); … … 364 367 %% detect calibration points if the GUI geometry_calib is opened 365 368 h_geometry_calib=findobj(allchild(0),'Name','geometry_calib'); %find the geomterty_calib GUI 366 if ~ test_zoom && ~isempty(h_geometry_calib)369 if ~CheckZoom && ~isempty(h_geometry_calib) 367 370 pointershape='crosshair';%default for geometry_calib: ready to create new points 368 371 hh_geometry_calib=guidata(h_geometry_calib);
Note: See TracChangeset
for help on using the changeset viewer.