Changeset 82 for trunk/src/mouse_up.m


Ignore:
Timestamp:
Apr 15, 2010, 5:12:42 AM (14 years ago)
Author:
sommeria
Message:

mouse_up: improve zoom : keep the selected point at the same place on the graph
plot_field: memorize the max coordiantes on the graph (AxeData?) for zoom out
set_object: input possibilities extende to restrict menu (for mask objects)
uvmat: improvement of mask creation
civ: select mask option for civ2 when select(ed for civ1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/mouse_up.m

    r81 r82  
    213213        end
    214214end
    215 %zoom in if no new figure is created
     215%zoom in by a factor 2 if no new figure is created
    216216if zoomstate
     217    xy=get(currentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
    217218     if  isequal(get(currentfig,'SelectionType'),'normal');%if left button has been pressed
    218         %zoom(2)% zoom in by a factor of 2
    219         alpha=0.5; %zoom factor (zoom in by a factor 2)
    220219        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);
    223222        set(currentaxes,'XLim',xlim_new)
    224223        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);
    227226        set(currentaxes,'YLim',ylim_new)
    228227        if isfield(AxeData,'ParentRect')% update the position of the parent rectangle represneting the field
     
    234233            set(hparentrect,'Position',rect)
    235234        end
    236 
     235     %zoom out by a factor of 2 out when the right mouse button has been used
    237236     elseif isequal(get(currentfig,'SelectionType'),'alt'); %if right button has been pressed
    238             %zoom(0.5)% zoom out by a factor of 2
    239237            alpha=2; %zoom factor (zoom out by a factor 2)
    240238            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;
    243243            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
    246260            set(currentaxes,'XLim',xlim_new)
    247261            set(currentaxes,'YLim',ylim_new)
    248262            %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)
    250264                AxeData.CurrentXLim=xlim;%
    251265            end
     
    338352        display(['UserData of ' objtype ':'])
    339353        evalin('base','CurData') %display CurData in the workspace
    340         commandwindow
     354        commandwindow %brings the Matlab command window to the front
    341355    end
    342356end
Note: See TracChangeset for help on using the changeset viewer.