Ignore:
Timestamp:
Feb 14, 2011, 7:03:10 PM (13 years ago)
Author:
sommeria
Message:

civ: version working for all systems: windows, linux, mac
plots: introduction of axes limits , bug repairs (still further work needed)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/keyboard_callback.m

    r71 r192  
    22%-----------------------------------
    33function keyboard_callback(hObject,eventdata,handleshaxes)
     4cur_axes=get(hObject,'CurrentAxes');%current plotting axes of the figure with handle hObject
    45xx=double(get(hObject,'CurrentCharacter')); %get the keyboard character
    5 cur_axes=get(gcbf,'CurrentAxes');
    6 if ~isempty(cur_axes)
    7     xlimit=get(cur_axes,'XLim');
    8     ylimit=get(cur_axes,'Ylim');
    9     dx=(xlimit(2)-xlimit(1))/10;
    10     dy=(ylimit(2)-ylimit(1))/10;
    11    
    12     if isequal(xx,29)%move arrow right
    13         xlimit=xlimit+dx;
    14     elseif isequal(xx,28)%move arrow left
    15         xlimit=xlimit-dx;
    16     elseif isequal(xx,30)%move arrow up
    17         ylimit=ylimit+dy;
    18     elseif isequal(xx,31)%move arrow down
    19         ylimit=ylimit-dy;
    20     end
    21     set(cur_axes,'XLim',xlimit)
    22     set(cur_axes,'YLim',ylimit)
    23 end
    24 if ismember(xx,[8 127]) %if the delete or suppr key is pressed, delete the current object
    25     currentobject=gco;
    26     huvmat=findobj(allchild(0),'tag','uvmat');
    27 %     UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface
    28     hlist_object=findobj(huvmat,'Tag','list_object_1');
    29     ObjIndex=get(hlist_object,'Value')
    30     if ObjIndex>1
    31         delete_object(ObjIndex)
    32     end
    33     if ishandle(currentobject)
    34         tag=get(currentobject,'Tag');%tag of the current selected object
    35         if isequal(tag,'proj_object')
    36             delete_object(currentobject)
     6switch xx
     7    case {29,28,30,31}    %arrows for displacement
     8        if ~isempty(cur_axes)
     9            xlimit=get(cur_axes,'XLim');
     10            ylimit=get(cur_axes,'Ylim');
     11            dx=(xlimit(2)-xlimit(1))/10;
     12            dy=(ylimit(2)-ylimit(1))/10;
     13            if isequal(xx,29)%move arrow right
     14                xlimit=xlimit+dx;
     15            elseif isequal(xx,28)%move arrow left
     16                xlimit=xlimit-dx;
     17            elseif isequal(xx,30)%move arrow up
     18                ylimit=ylimit+dy;
     19            elseif isequal(xx,31)%move arrow down
     20                ylimit=ylimit-dy;
     21            end
     22            set(cur_axes,'XLim',xlimit)
     23            set(cur_axes,'YLim',ylimit)
     24            hfig=hObject; %master figure
     25            AxeData=get(cur_axes,'UserData');
     26            if isfield(AxeData,'ParentRect')% update the position of the parent rectangle representing the field
     27                hparentrect=AxeData.ParentRect;
     28                rect([1 2])=[xlimit(1) ylimit(1)];
     29                rect([3 4])=[xlimit(2)-xlimit(1) ylimit(2)-ylimit(1)];
     30                set(hparentrect,'Position',rect)
     31                hfig=get(hparentrect,'parent');
     32                hfig=get(hfig,'parent');
     33            elseif isfield(AxeData,'LimEditBox')&& isequal(AxeData.LimEditBox,1)% update display of the GUI containing the axis (uvmat or view_field)
     34                hh=guidata(hfig);
     35                if isfield(hh,'MinX')
     36                    set(hh.MinX,'String',num2str(xlimit(1)))
     37                    set(hh.MaxX,'String',num2str(xlimit(2)))
     38                    set(hh.MinY,'String',num2str(ylimit(1)))
     39                    set(hh.MaxY,'String',num2str(ylimit(2)))
     40                end
     41            end
    3742        end
    38     end
    39 elseif isequal(xx,112)%  key 'p'
    40     uvmat('runplus_Callback',hObject,eventdata,handleshaxes)
    41 elseif isequal(xx,109)%  key 'm'
    42     uvmat('runmin_Callback',hObject,eventdata,handleshaxes)
     43    case {8, 127} %if the delete or suppr key is pressed, delete the current object
     44        currentobject=gco;
     45        huvmat=findobj(allchild(0),'tag','uvmat');
     46        hlist_object=findobj(huvmat,'Tag','list_object_1');
     47        ObjIndex=get(hlist_object,'Value');
     48        if ObjIndex>1
     49            delete_object(ObjIndex)
     50        end
     51        if ishandle(currentobject)
     52            tag=get(currentobject,'Tag');%tag of the current selected object
     53            if isequal(tag,'proj_object')
     54                delete_object(currentobject)
     55            end
     56        end
     57    case 112%  key 'p'
     58        uvmat('runplus_Callback',hObject,eventdata,handleshaxes)
     59    case 109%  key 'm'
     60        uvmat('runmin_Callback',hObject,eventdata,handleshaxes)
    4361end
    4462
    45 AxeData=get(cur_axes,'UserData');
    46 if isfield(AxeData,'ParentRect')% update the position of the parent rectangle represneting the field
    47     hparentrect=AxeData.ParentRect;
    48     rect([1 2])=[xlimit(1) ylimit(1)];
    49     rect([3 4])=[xlimit(2)-xlimit(1) ylimit(2)-ylimit(1)];
    50     set(hparentrect,'Position',rect)
    51 end
Note: See TracChangeset for help on using the changeset viewer.