source: trunk/src/keyboard_callback.m @ 726

Last change on this file since 726 was 726, checked in by sommeria, 10 years ago

various improvements for interactive use

File size: 3.4 KB
Line 
1%'keyboard_callback:' function activated when a key is pressed on the keyboard
2%-----------------------------------
3function keyboard_callback(hObject,eventdata,handleshaxes)
4cur_axes=get(hObject,'CurrentAxes');%current plotting axes of the figure with handle hObject
5xx=double(get(hObject,'CurrentCharacter')); %get the keyboard character
6if ~isempty(xx)
7    switch xx
8        case {29,28,30,31}    %arrows for displacement
9            AxeData=get(cur_axes,'UserData');
10            if isfield(AxeData,'ZoomAxes')&&ishandle(AxeData.ZoomAxes)
11                cur_axes=AxeData.ZoomAxes;% move the field of the zoom sub-plot instead of the main axes  if it exsits
12                axes(cur_axes)
13            end
14            if ~isempty(cur_axes)
15                xlimit=get(cur_axes,'XLim');
16                ylimit=get(cur_axes,'Ylim');
17                dx=(xlimit(2)-xlimit(1))/10;
18                dy=(ylimit(2)-ylimit(1))/10;
19                if isequal(xx,29)%move arrow right
20                    xlimit=xlimit+dx;
21                elseif isequal(xx,28)%move arrow left
22                    xlimit=xlimit-dx;
23                elseif isequal(xx,30)%move arrow up
24                    ylimit=ylimit+dy;
25                elseif isequal(xx,31)%move arrow down
26                    ylimit=ylimit-dy;
27                end
28                set(cur_axes,'XLim',xlimit)
29                set(cur_axes,'YLim',ylimit)
30                hfig=hObject; %master figure
31                AxeData=get(cur_axes,'UserData');
32                if isfield(AxeData,'ParentRect')% update the position of the parent rectangle representing the field
33                    hparentrect=AxeData.ParentRect;
34                    rect([1 2])=[xlimit(1) ylimit(1)];
35                    rect([3 4])=[xlimit(2)-xlimit(1) ylimit(2)-ylimit(1)];
36                    set(hparentrect,'Position',rect)
37                elseif isfield(AxeData,'LimEditBox')&& isequal(AxeData.LimEditBox,1)% update display of the GUI containing the axis (uvmat or view_field)
38                    hh=guidata(hfig);
39                    if isfield(hh,'num_MinX')
40                        set(hh.num_MinX,'String',num2str(xlimit(1)))
41                        set(hh.num_MaxX,'String',num2str(xlimit(2)))
42                        set(hh.num_MinY,'String',num2str(ylimit(1)))
43                        set(hh.num_MaxY,'String',num2str(ylimit(2)))
44                    end
45                end
46            end
47        case 112%  key 'p'
48            uvmat('runplus_Callback',hObject,eventdata,handleshaxes)
49        case 109%  key 'm'
50            uvmat('runmin_Callback',hObject,eventdata,handleshaxes)
51        otherwise
52            if ischar(get(gco,'Tag'))
53            switch get(gco,'tag')% tag of the current edit box
54                case {'RootPath', 'SubDir','RootFile','FileExt','RootPath_1', 'SubDir_1','RootFile_1','FileExt_1'}
55                    set(handleshaxes.InputFileREFRESH,'BackgroundColor',[1 0 1])%indicat that REFRESH must be activated (introduce the whole series)
56                case 'num_IndexIncrement'% no action
57                otherwise
58                    if isfield(handleshaxes,'REFRESH')
59                    set(handleshaxes.REFRESH,'BackgroundColor',[1 0 1])%indicat that run0 must be activated
60                    elseif strcmp(get(gco,'Type'),'uicontrol')
61                       set(gco,'BackgroundColor',[1 0 1])%indicate that the edition  must be validated by carriage return
62                    end
63            end
64            end
65    end
66end
Note: See TracBrowser for help on using the repository browser.