source: trunk/src/keyboard_callback.m @ 279

Last change on this file since 279 was 192, checked in by sommeria, 14 years ago

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

File size: 2.7 KB
RevLine 
[11]1%'keyboard_callback:' function activated when a key is pressed on the keyboard
2%-----------------------------------
3function keyboard_callback(hObject,eventdata,handleshaxes)
[192]4cur_axes=get(hObject,'CurrentAxes');%current plotting axes of the figure with handle hObject
[11]5xx=double(get(hObject,'CurrentCharacter')); %get the keyboard character
[192]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
[11]42        end
[192]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)
[11]61end
62
Note: See TracBrowser for help on using the repository browser.