Changeset 432 for trunk/src/mouse_motion.m
- Timestamp:
- May 25, 2012, 8:59:59 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/mouse_motion.m
r413 r432 29 29 end 30 30 FigData=get(hObject,'UserData'); 31 32 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 33 currentfig=get(get(FigData,'parent'),'parent');32 CurrentFig=get(get(FigData,'parent'),'parent'); 34 33 else 35 currentfig=hObject;%usual plot36 end 37 hh currentfig=guidata(currentfig);38 test_zoom=get(hh currentfig.CheckZoom,'Value');%test for zoom activated on the current figure34 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 39 38 test_draw=0;%test for mouse drawing of object, =0 by default 40 39 test_object=0; %test for object editing or creation … … 42 41 test_zoom_draw=0; % test for zoom drawing 43 42 test_ruler=0;%test for active ruler 44 % test_piv=0;% test for PIV correlation display45 43 huvmat=findobj(allchild(0),'tag','uvmat');%find the uvmat interface handle 46 44 if ~isempty(huvmat) 47 hhuvmat=guidata(huvmat); 45 hhuvmat=guidata(huvmat);%handles of the elements in uvma 48 46 test_edit_object=get(hhuvmat.edit_object,'Value'); 49 47 test_ruler=isequal(get(hhuvmat.MenuRuler,'checked'),'on'); … … 59 57 end 60 58 61 %find the current axe ' haxes' and display the current mouse position or uicontrol tag59 %find the current axe 'CurrentAxes' and display the current mouse position or uicontrol tag 62 60 text_displ_1=''; 63 61 text_displ_2=''; … … 74 72 hchild=get(hObject,'Children');%handles of all objects in the current figure 75 73 76 %% loop on all the objects in the current figure anddetect whether the mouse is over a plot axes77 haxes=[];74 %% loop on all the objects in the current figure, detect whether the mouse is over a plot axes 75 CurrentAxes=[]; 78 76 for ichild=1:length(hchild) 79 77 obj_pos=get(hchild(ichild),'Position'); … … 85 83 %if the mouse is over an axis, look at the data 86 84 if strcmp(htype,'axes') 87 haxes=hchild(ichild);88 xy=get( haxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates89 AxeData=get( haxes,'UserData');% data attached to the axis85 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 90 88 if isfield(AxeData,'Drawing')&& ~isempty(AxeData.Drawing) 91 89 test_draw=~isequal(AxeData.Drawing,'off');%=1 if mouse drawing of object is active … … 96 94 pointershape='crosshair';%set pointer with cross shape (default when mouse is over an axis) 97 95 end 98 FigData=get( currentfig,'UserData');99 tagaxes=get( haxes,'tag');96 FigData=get(CurrentFig,'UserData'); 97 tagaxes=get(CurrentAxes,'tag'); 100 98 if isfield(FigData,tagaxes) 101 99 eval(['Field=FigData.' tagaxes ';']) … … 117 115 (Y<(xy(1,2)+Field.Mesh/3) & Y>(xy(1,2)-Field.Mesh/3));%f 118 116 ivec=find(flag_vec,1);% search the (first) selected vector index ivec 119 hhh=findobj( haxes,'Tag','vector_marker');117 hhh=findobj(CurrentAxes,'Tag','vector_marker'); 120 118 if ~isempty(ivec) 121 119 % mark the vectors with a circle in the absence of other operations … … 123 121 pointershape='arrow'; %mouse indicates the detection of a vector 124 122 if isempty(hhh) 125 set(0,'CurrentFigure', currentfig)126 set( currentfig,'CurrentAxes',haxes)123 set(0,'CurrentFigure',CurrentFig) 124 set(CurrentFig,'CurrentAxes',CurrentAxes) 127 125 rectangle('Curvature',[1 1],... 128 126 'Position',[X(ivec)-Field.Mesh/2 Y(ivec)-Field.Mesh/2 Field.Mesh Field.Mesh],'EdgeColor','m',... … … 226 224 shiftx=par.Shiftx; 227 225 shifty=par.Shifty; 228 hhh=findobj( haxes,'Tag','PIV_box_marker');229 hhhh=findobj( haxes,'Tag','PIV_search_marker');226 hhh=findobj(CurrentAxes,'Tag','PIV_box_marker'); 227 hhhh=findobj(CurrentAxes,'Tag','PIV_search_marker'); 230 228 if isempty(hhh) 231 set(0,'CurrentFigure', currentfig)232 set( currentfig,'CurrentAxes',haxes)229 set(0,'CurrentFigure',CurrentFig) 230 set(CurrentFig,'CurrentAxes',CurrentAxes) 233 231 rectangle('Curvature',[0 0],... 234 232 'Position',[xround-ibx2 yround-iby2 2*ibx2 2*iby2],'EdgeColor','m',... … … 264 262 AxeData.TitleHandle=title(num2str(par.Grid)); 265 263 colorbar 266 set( haxes,'UserData',AxeData)264 set(CurrentAxes,'UserData',AxeData) 267 265 set(get(AxeData.CurrentCorrImage,'parent'),'YDir','normal') 268 266 end … … 301 299 else 302 300 AxeData.CurrentRectZoom=rectangle('Position',rect,'LineStyle',':','Tag','rect_zoom'); 303 set( haxes,'UserData',AxeData)301 set(CurrentAxes,'UserData',AxeData) 304 302 end 305 303 end … … 311 309 %% create or modify an object 312 310 if ~isempty(huvmat) && test_object 311 UvData=get(huvmat,'UserData'); 313 312 PlotData=get(AxeData.CurrentObject,'UserData'); 314 huvmat=findobj(allchild(0),'Name','uvmat');%find the uvmat interface handle 315 if ~isempty(huvmat) 316 UvData=get(huvmat,'UserData'); 317 if ~isfield(PlotData,'IndexObj') 318 return 313 if ~isfield(PlotData,'IndexObj') 314 return 315 end 316 ObjectData=UvData.Object{PlotData.IndexObj}; 317 ProjObject=[];% object (plane) whose projection is represented on the current axes 318 if isequal(hObject,huvmat)% if the mouse ifs over the GUI uvmat 319 ProjObject=UvData.Object{get(hhuvmat.ListObject_1,'Value')}; 320 else 321 ProjObject=UvData.Object{get(hhuvmat.ListObject,'Value')}; 322 end 323 XYData=AxeData.CurrentOrigin; 324 if isequal(AxeData.Drawing,'create') && isfield(AxeData,'CurrentOrigin') && ~isempty(AxeData.CurrentOrigin) 325 if strcmp(ObjectData.Type,'line')||strcmp(ObjectData.Type,'polyline')||strcmp(ObjectData.Type,'polygon')||strcmp(ObjectData.Type,'points') 326 ObjectData.Coord=[ObjectData.Coord ;xy(1,1:2)]; 327 % ObjectData.Coord(end,:)=xy(1,:); 328 elseif strcmp(ObjectData.Type,'rectangle')||strcmp(ObjectData.Type,'ellipse')||strcmp(ObjectData.Type,'volume') 329 ObjectData.Coord(1,1)=(xy(1,1)+XYData(1))/2;%origin rectangle, x coordinate 330 ObjectData.Coord(1,2)=(xy(1,2)+XYData(2))/2; 331 ObjectData.RangeX=abs(xy(1,1)-XYData(1))/2;%rectangle width 332 ObjectData.RangeY=abs(xy(1,2)-XYData(2))/2;%rectangle height 333 elseif isequal(ObjectData.Type,'plane') %case of 'plane' 334 DX=(xy(1,1)-ObjectData.Coord(1,1)); 335 DY=(xy(1,2)-ObjectData.Coord(1,2)); 336 ObjectData.Phi=(angle(DX+i*DY))*180/pi;%rectangle widt 337 if isfield(ObjectData,'RangeX') 338 XMax=sqrt(DX*DX+DY*DY); 339 if XMax>max(ObjectData.RangeX) 340 ObjectData.RangeX=[min(ObjectData.RangeX) XMax]; 341 end 342 end 319 343 end 320 ObjectData=UvData.Object{PlotData.IndexObj}; 321 XYData=AxeData.CurrentOrigin; 322 if isequal(AxeData.Drawing,'create') && isfield(AxeData,'CurrentOrigin') && ~isempty(AxeData.CurrentOrigin) 323 if strcmp(ObjectData.Type,'line')||strcmp(ObjectData.Type,'polyline')||strcmp(ObjectData.Type,'polygon')||strcmp(ObjectData.Type,'points') 324 ObjectData.Coord=[ObjectData.Coord ;xy(1,1:2)]; 325 % ObjectData.Coord(end,:)=xy(1,:); 326 elseif strcmp(ObjectData.Type,'rectangle')||strcmp(ObjectData.Type,'ellipse')||strcmp(ObjectData.Type,'volume') 327 ObjectData.Coord(1,1)=(xy(1,1)+XYData(1))/2;%origin rectangle, x coordinate 328 ObjectData.Coord(1,2)=(xy(1,2)+XYData(2))/2; 329 ObjectData.RangeX=abs(xy(1,1)-XYData(1))/2;%rectangle width 330 ObjectData.RangeY=abs(xy(1,2)-XYData(2))/2;%rectangle height 331 elseif isequal(ObjectData.Type,'plane') %case of 'plane' 332 DX=(xy(1,1)-ObjectData.Coord(1,1)); 333 DY=(xy(1,2)-ObjectData.Coord(1,2)); 334 ObjectData.Phi=(angle(DX+i*DY))*180/pi;%rectangle widt 335 if isfield(ObjectData,'RangeX') 336 XMax=sqrt(DX*DX+DY*DY); 337 if XMax>max(ObjectData.RangeX) 338 ObjectData.RangeX=[min(ObjectData.RangeX) XMax]; 339 end 340 end 341 end 342 plot_object(ObjectData,[],AxeData.CurrentObject,'m'); 343 pointershape='crosshair'; 344 elseif isequal(AxeData.Drawing,'translate') 345 DX=xy(1,1)-XYData(1);%translation from initial position 346 DY=xy(1,2)-XYData(2); 347 ObjectData.Coord(:,1)=ObjectData.Coord(:,1)+DX; 348 ObjectData.Coord(:,2)=ObjectData.Coord(:,2)+DY; 349 plot_object(ObjectData,[],AxeData.CurrentObject,'m'); 350 pointershape='fleur'; 351 elseif isequal(AxeData.Drawing,'deform') 352 ind_move=AxeData.CurrentIndex; 353 ObjectData.Coord(ind_move,1)=xy(1,1); 354 ObjectData.Coord(ind_move,2)=xy(1,2); 355 plot_object(ObjectData,[],AxeData.CurrentObject,'m'); 356 pointershape='circle'; 357 end 358 end 359 end 344 plot_object(ObjectData,ProjObject,AxeData.CurrentObject,'m'); 345 pointershape='crosshair'; 346 elseif isequal(AxeData.Drawing,'translate') 347 DX=xy(1,1)-XYData(1);%translation from initial position 348 DY=xy(1,2)-XYData(2); 349 ObjectData.Coord(:,1)=ObjectData.Coord(:,1)+DX; 350 ObjectData.Coord(:,2)=ObjectData.Coord(:,2)+DY; 351 plot_object(ObjectData,ProjObject,AxeData.CurrentObject,'m'); 352 pointershape='fleur'; 353 elseif isequal(AxeData.Drawing,'deform') 354 ind_move=AxeData.CurrentIndex; 355 ObjectData.Coord(ind_move,1)=xy(1,1); 356 ObjectData.Coord(ind_move,2)=xy(1,2); 357 plot_object(ObjectData,ProjObject,AxeData.CurrentObject,'m'); 358 pointershape='circle'; 359 end 360 end 360 361 361 362 %% detect calibration points if the GUI geometry_calib is opened … … 371 372 XCoord=(data.Coord(:,4)); 372 373 YCoord=(data.Coord(:,5)); 373 xy=get( haxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates374 xy=get(CurrentAxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates 374 375 if ~isempty(xy) 375 xlim=get( haxes,'XLim');376 xlim=get(CurrentAxes,'XLim'); 376 377 ind_range_x=abs((xlim(2)-xlim(1))/50); 377 ylim=get( haxes,'YLim');378 ylim=get(CurrentAxes,'YLim'); 378 379 ind_range_y=abs((ylim(2)-ylim(1))/50); 379 380 ind_range=sqrt(ind_range_x*ind_range_y); … … 414 415 415 416 %% update the mouse pointer 416 set( currentfig,'Pointer',pointershape);417 set(CurrentFig,'Pointer',pointershape);
Note: See TracChangeset
for help on using the changeset viewer.