Changeset 71 for trunk/src/mouse_motion.m
- Timestamp:
- Mar 29, 2010, 6:34:55 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/mouse_motion.m
r67 r71 27 27 return 28 28 end 29 test_draw=0; 29 30 test_create=0;%default 30 test_edit=0;%default 31 test_edit=isfield(handles,'edit') & get(handles.edit,'Value');% edit test for mouse shap: an arrow 32 test_zoom=isfield(handles,'zoom')& get(handles.zoom,'Value');% edit test for mouse shap: an arrow 31 test_object=0; %default 32 test_edit=isfield(handles,'edit') && get(handles.edit,'Value');% edit test for mouse shap: an arrow 33 test_zoom_draw=0; %default 34 test_ruler=0; 35 huvmat=findobj(allchild(0),'Name','uvmat');%find the uvmat interface handle 36 if ~isempty(huvmat) 37 UvData=get(huvmat,'UserData'); 38 test_ruler=isfield(UvData,'MouseAction') && isequal(UvData.MouseAction,'ruler'); 39 end 40 33 41 34 42 %find the current axe 'haxes' and display the current mouse position or uicontrol tag … … 38 46 text_displ_4=''; 39 47 40 haxes=[];41 48 AxeData=[];%default 42 49 mouse=[]; … … 44 51 45 52 pointershape='arrow';% default pointer is an arrow 46 currentfig= gcbo;%store gcbo as variable currentfig53 currentfig=hObject; 47 54 xy_fig=get(currentfig,'CurrentPoint');% current point of the current figure (gcbo) 48 55 hchild=get(currentfig,'Children');%handles of all objects in the current figure 49 56 50 % loop on all the objects in the current figure (selected by the last mouse click) 57 % loop on all the objects in the current figure and detect whether the mouse is over a plot axes 58 haxes=[]; 51 59 for ichild=1:length(hchild) 52 60 obj_pos=get(hchild(ichild),'Position');%position of the object … … 68 76 ivec=[]; 69 77 AxeData=get(haxes,'UserData');% data attached to the axis 70 if ~test_edit && ~test_zoom 78 if isfield(AxeData,'Drawing')&& ~isempty(AxeData.Drawing) 79 test_draw=~isequal(AxeData.Drawing,'off'); 80 end 81 test_zoom_draw=test_draw && isequal(AxeData.Drawing,'zoom')&& isfield(AxeData,'CurrentOrigin') && isequal(get(gcf,'SelectionType'),'normal'); 82 test_object=test_draw && isfield(AxeData,'CurrentObject') && ~isempty(AxeData.CurrentObject) && ishandle(AxeData.CurrentObject); 83 if ~test_edit && ~test_zoom_draw && ~test_ruler 71 84 pointershape='crosshair';%set pointer with cross shape (default when mouse is over an axis) 72 % % pointershape='crosshair';%set pointer with cross shape (default over axis)73 85 end 74 86 if isfield(AxeData,'X') && isfield(AxeData,'Y') && isfield(AxeData,'Mesh')% test on the existence of a vector field in the current axis … … 78 90 ivec=find(flag_vec,1);% search the (first) selected vector index ivec 79 91 hhh=findobj(haxes,'Tag','vector_marker'); 80 if ~isempty(ivec) 81 %ivec=ivec(1);%choice the first selected vector if several are selected 82 if ~test_create 83 pointershape='arrow'; %mouse indicates the detection of a vector 84 if isempty(hhh) 85 set(currentfig,'CurrentAxes',haxes) 86 rectangle('Curvature',[1 1],... 87 'Position',[AxeData.X(ivec)-AxeData.Mesh AxeData.Y(ivec)/2-AxeData.Mesh/2 AxeData.Mesh AxeData.Mesh],'EdgeColor','m',... 88 'LineStyle','-','Tag','vector_marker'); 89 % line(AxeData.X(ivec),AxeData.Y(ivec),'Color','m','Tag','vector_marker','LineStyle','.','Marker','o','MarkerSize',AxeData.Mesh); 90 else 91 set(hhh,'Position',[AxeData.X(ivec)-AxeData.Mesh/2 AxeData.Y(ivec)-AxeData.Mesh/2 AxeData.Mesh AxeData.Mesh]) 92 if ~isempty(ivec) 93 if ~test_object % mark the vectors with a circle in the absence of other operations 94 if ~test_create && ~test_edit && ~test_ruler 95 pointershape='arrow'; %mouse indicates the detection of a vector 96 if isempty(hhh) 97 hstack=findobj(allchild(0),'Type','figure');%current stack order of figures in matlab 98 axes(haxes) 99 rectangle('Curvature',[1 1],... 100 'Position',[AxeData.X(ivec)-AxeData.Mesh/2 AxeData.Y(ivec)-AxeData.Mesh/2 AxeData.Mesh AxeData.Mesh],'EdgeColor','m',... 101 'LineStyle','-','Tag','vector_marker'); 102 set(0,'Children',hstack);%put back the initial figure stack after plot creation 103 else 104 set(hhh,'Position',[AxeData.X(ivec)-AxeData.Mesh/2 AxeData.Y(ivec)-AxeData.Mesh/2 AxeData.Mesh AxeData.Mesh]) 105 end 92 106 end 93 end 107 end 94 108 mouse.X=AxeData.X(ivec); 95 109 mouse.Y=AxeData.Y(ivec); … … 193 207 set(handles.text_display_3,'String',text_displ_3); 194 208 set(handles.text_display_4,'String',text_displ_4); 209 if ~test_draw 210 return 211 end 212 % At this stage if no drawing operation is done 213 214 215 %%%%%%%%%%%%% 216 %draw a zoom rectangle if no object creation is selected 217 if test_zoom_draw 218 xy_rect=AxeData.CurrentOrigin; 219 if ~isempty(xy_rect) 220 rect(1)=min(xy(1,1),xy_rect(1));%origin rectangle, x coordinate 221 rect(2)=min(xy(1,2),xy_rect(2));%origin rectangle, y coordinate 222 rect(3)=abs(xy(1,1)-xy_rect(1));%rectangle width 223 rect(4)=abs(xy(1,2)-xy_rect(2));%rectangle height 224 if rect(3)>0 & rect(4)>0 225 if isfield(AxeData,'CurrentRectZoom')& ishandle(AxeData.CurrentRectZoom) 226 set(AxeData.CurrentRectZoom,'Position',rect);%update the rectangle position 227 else 228 AxeData.CurrentRectZoom=rectangle('Position',rect,'LineStyle',':','Tag','rect_zoom'); 229 set(haxes,'UserData',AxeData) 230 end 231 end 232 end 233 pointershape='arrow'; 234 end 195 235 196 236 %%%%%%%%%%%%%%%%% 197 237 %create or modify an object 198 huvmat=findobj(allchild(0),'Name','uvmat');%find the uvmat interface handle 199 if ~isempty(huvmat) 200 UvData=get(huvmat,'UserData'); 201 end 202 if ~isempty(huvmat) & isfield(AxeData,'CurrentObject') & ishandle(AxeData.CurrentObject) & isfield(AxeData,'Drawing') & ~isequal(AxeData.Drawing,'off') 238 239 if ~isempty(huvmat) && test_object 203 240 PlotData=get(AxeData.CurrentObject,'UserData'); 204 241 huvmat=findobj(allchild(0),'Name','uvmat');%find the uvmat interface handle … … 250 287 end 251 288 252 %%%%%%%%%%%%%253 %draw a zoom rectangle if no object creation is selected254 if ~isempty(haxes) & isfield(AxeData,'Drawing')& isequal(AxeData.Drawing,'zoom')& isfield(AxeData,'CurrentOrigin')...255 & isequal(get(gcf,'SelectionType'),'normal')%256 xy_rect=AxeData.CurrentOrigin;257 if ~isempty(xy_rect)258 rect(1)=min(xy(1,1),xy_rect(1));%origin rectangle, x coordinate259 rect(2)=min(xy(1,2),xy_rect(2));%origin rectangle, y coordinate260 rect(3)=abs(xy(1,1)-xy_rect(1));%rectangle width261 rect(4)=abs(xy(1,2)-xy_rect(2));%rectangle height262 if rect(3)>0 & rect(4)>0263 if isfield(AxeData,'CurrentRectZoom')& ishandle(AxeData.CurrentRectZoom)264 set(AxeData.CurrentRectZoom,'Position',rect);%update the rectangle position265 else266 AxeData.CurrentRectZoom=rectangle('Position',rect,'LineStyle',':','Tag','rect_zoom');267 set(haxes,'UserData',AxeData)268 end269 end270 end271 % end272 % if test_zoom273 pointershape='arrow';274 end275 276 289 % detect calibration points if the GUI geometry_calib is opened 277 290 h_geometry_calib=findobj(allchild(0),'Name','geometry_calib'); %find the geomterty_calib GUI 278 if ~test_zoom && ~isempty(h_geometry_calib)291 if ~test_zoom_draw && ~isempty(h_geometry_calib) 279 292 pointershape='crosshair';%default for geometry_calib: ready to create new points 280 293 hh_geometry_calib=guidata(h_geometry_calib); … … 303 316 hhh=findobj('Tag','calib_marker');%look for handle of point marker (circle) 304 317 if ~isempty(hhh) 305 set(hhh,'XData',XCoord(index_point)) 306 set(hhh,'YData',YCoord(index_point)) 318 set(hhh,'Position',[XCoord(index_point)-ind_range/2 YCoord(index_point)-ind_range/2 ind_range ind_range]) 319 % set(hhh,'XData',XCoord(index_point)) 320 % set(hhh,'YData',YCoord(index_point)) 307 321 end 308 322 end … … 313 327 314 328 %draw ruler 315 if ~isempty(huvmat) 316 UvData=get(huvmat,'UserData'); 317 if isfield(UvData,'MouseAction') && isequal(UvData.MouseAction,'ruler') 329 if test_ruler && isequal(AxeData.Drawing,'ruler') 318 330 if isfield(UvData,'RulerHandle') 319 331 pointershape='crosshair'; … … 322 334 set(UvData.RulerHandle,'YData',RulerCoord(:,2)); 323 335 end 324 end325 336 end 326 337 set(currentfig,'Pointer',pointershape);
Note: See TracChangeset
for help on using the changeset viewer.