Changeset 82 for trunk/src/mouse_up.m
- Timestamp:
- Apr 15, 2010, 5:12:42 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/mouse_up.m
r81 r82 213 213 end 214 214 end 215 %zoom in if no new figure is created215 %zoom in by a factor 2 if no new figure is created 216 216 if zoomstate 217 xy=get(currentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates 217 218 if isequal(get(currentfig,'SelectionType'),'normal');%if left button has been pressed 218 %zoom(2)% zoom in by a factor of 2219 alpha=0.5; %zoom factor (zoom in by a factor 2)220 219 xlim=get(currentaxes,'XLim'); 221 xlim_new( 1)=(1+alpha)*xlim(1)/2+(1-alpha)*xlim(2)/2;222 xlim_new( 2)=(1-alpha)*xlim(1)/2+(1+alpha)*xlim(2)/2;220 xlim_new(2)=0.5*xy(1,1)+0.5*xlim(2); 221 xlim_new(1)=0.5*xy(1,1)+0.5*xlim(1); 223 222 set(currentaxes,'XLim',xlim_new) 224 223 ylim=get(currentaxes,'YLim'); 225 ylim_new( 1)=(1+alpha)*ylim(1)/2+(1-alpha)*ylim(2)/2;226 ylim_new( 2)=(1-alpha)*ylim(1)/2+(1+alpha)*ylim(2)/2;224 ylim_new(2)=0.5*xy(1,2)+0.5*ylim(2); 225 ylim_new(1)=0.5*xy(1,2)+0.5*ylim(1); 227 226 set(currentaxes,'YLim',ylim_new) 228 227 if isfield(AxeData,'ParentRect')% update the position of the parent rectangle represneting the field … … 234 233 set(hparentrect,'Position',rect) 235 234 end 236 235 %zoom out by a factor of 2 out when the right mouse button has been used 237 236 elseif isequal(get(currentfig,'SelectionType'),'alt'); %if right button has been pressed 238 %zoom(0.5)% zoom out by a factor of 2239 237 alpha=2; %zoom factor (zoom out by a factor 2) 240 238 xlim=get(currentaxes,'XLim'); 241 xlim_new(1)=(1+alpha)*xlim(1)/2+(1-alpha)*xlim(2)/2; 242 xlim_new(2)=(1-alpha)*xlim(1)/2+(1+alpha)*xlim(2)/2; 239 xlim_new(1)=2*xlim(1)-xy(1,1); 240 xlim_new(2)=2*xlim(2)-xy(1,1); 241 % xlim_new(1)=(1+alpha)*xlim(1)/2+(1-alpha)*xlim(2)/2; 242 % xlim_new(2)=(1-alpha)*xlim(1)/2+(1+alpha)*xlim(2)/2; 243 243 ylim=get(currentaxes,'YLim'); 244 ylim_new(1)=(1+alpha)*ylim(1)/2+(1-alpha)*ylim(2)/2; 245 ylim_new(2)=(1-alpha)*ylim(1)/2+(1+alpha)*ylim(2)/2; 244 ylim_new(1)=2*ylim(1)-xy(1,2); 245 ylim_new(2)=2*ylim(2)-xy(1,2); 246 % ylim_new(1)=(1+alpha)*ylim(1)/2+(1-alpha)*ylim(2)/2; 247 % ylim_new(2)=(1-alpha)*ylim(1)/2+(1+alpha)*ylim(2)/2; 248 if isfield(AxeData,'RangeX') && isfield(AxeData,'RangeY') 249 xlim_new(1)=max(AxeData.RangeX(1),xlim_new(1)); 250 xlim_new(2)=min(AxeData.RangeX(2),xlim_new(2)); 251 ylim_new(1)=max(AxeData.RangeY(1),ylim_new(1)); 252 ylim_new(2)=min(AxeData.RangeY(2),ylim_new(2)); 253 if isequal(xlim_new,AxeData.RangeX) && isequal(ylim_new,AxeData.RangeY) 254 set(hhuvmat.zoom,'Value',0) 255 set(hhuvmat.zoom,'BackgroundColor',[0.7 0.7 0.7]) 256 set(hhuvmat.FixedLimits,'Value',0) 257 set(hhuvmat.FixedLimits,'BackgroundColor',[0.7 0.7 0.7]) 258 end 259 end 246 260 set(currentaxes,'XLim',xlim_new) 247 261 set(currentaxes,'YLim',ylim_new) 248 262 %test whther zoom out is operating (to inactivate AxedAta 249 if ~isfield(AxeData,'CurrentXLim')| ~isequal(xlim,AxeData.CurrentXLim)263 if ~isfield(AxeData,'CurrentXLim')|| ~isequal(xlim,AxeData.CurrentXLim) 250 264 AxeData.CurrentXLim=xlim;% 251 265 end … … 338 352 display(['UserData of ' objtype ':']) 339 353 evalin('base','CurData') %display CurData in the workspace 340 commandwindow 354 commandwindow %brings the Matlab command window to the front 341 355 end 342 356 end
Note: See TracChangeset
for help on using the changeset viewer.