source: trunk/src/keyboard_callback.m @ 810

Last change on this file since 810 was 809, checked in by g7moreau, 10 years ago
  • Add license
File size: 4.9 KB
RevLine 
[11]1%'keyboard_callback:' function activated when a key is pressed on the keyboard
2%-----------------------------------
[809]3
4%=======================================================================
5% Copyright 2008-2014, LEGI UMR 5519 / CNRS UJF G-INP, Grenoble, France
6%   http://www.legi.grenoble-inp.fr
7%   Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.fr
8%
9%     This file is part of the toolbox UVMAT.
10%
11%     UVMAT is free software; you can redistribute it and/or modify
12%     it under the terms of the GNU General Public License as published
13%     by the Free Software Foundation; either version 2 of the license,
14%     or (at your option) any later version.
15%
16%     UVMAT is distributed in the hope that it will be useful,
17%     but WITHOUT ANY WARRANTY; without even the implied warranty of
18%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19%     GNU General Public License (see LICENSE.txt) for more details.
20%=======================================================================
21
[11]22function keyboard_callback(hObject,eventdata,handleshaxes)
[192]23cur_axes=get(hObject,'CurrentAxes');%current plotting axes of the figure with handle hObject
[11]24xx=double(get(hObject,'CurrentCharacter')); %get the keyboard character
[681]25if ~isempty(xx)
[710]26    switch xx
27        case {29,28,30,31}    %arrows for displacement
28            AxeData=get(cur_axes,'UserData');
29            if isfield(AxeData,'ZoomAxes')&&ishandle(AxeData.ZoomAxes)
30                cur_axes=AxeData.ZoomAxes;% move the field of the zoom sub-plot instead of the main axes  if it exsits
31                axes(cur_axes)
[192]32            end
[710]33            if ~isempty(cur_axes)
34                xlimit=get(cur_axes,'XLim');
35                ylimit=get(cur_axes,'Ylim');
36                dx=(xlimit(2)-xlimit(1))/10;
37                dy=(ylimit(2)-ylimit(1))/10;
38                if isequal(xx,29)%move arrow right
39                    xlimit=xlimit+dx;
40                elseif isequal(xx,28)%move arrow left
41                    xlimit=xlimit-dx;
42                elseif isequal(xx,30)%move arrow up
43                    ylimit=ylimit+dy;
44                elseif isequal(xx,31)%move arrow down
45                    ylimit=ylimit-dy;
[192]46                end
[710]47                set(cur_axes,'XLim',xlimit)
48                set(cur_axes,'YLim',ylimit)
49                hfig=hObject; %master figure
50                AxeData=get(cur_axes,'UserData');
51                if isfield(AxeData,'ParentRect')% update the position of the parent rectangle representing the field
52                    hparentrect=AxeData.ParentRect;
53                    rect([1 2])=[xlimit(1) ylimit(1)];
54                    rect([3 4])=[xlimit(2)-xlimit(1) ylimit(2)-ylimit(1)];
55                    set(hparentrect,'Position',rect)
56                elseif isfield(AxeData,'LimEditBox')&& isequal(AxeData.LimEditBox,1)% update display of the GUI containing the axis (uvmat or view_field)
57                    hh=guidata(hfig);
58                    if isfield(hh,'num_MinX')
59                        set(hh.num_MinX,'String',num2str(xlimit(1)))
60                        set(hh.num_MaxX,'String',num2str(xlimit(2)))
61                        set(hh.num_MinY,'String',num2str(ylimit(1)))
62                        set(hh.num_MaxY,'String',num2str(ylimit(2)))
63                    end
64                end
[192]65            end
[710]66        case 112%  key 'p'
67            uvmat('runplus_Callback',hObject,eventdata,handleshaxes)
68        case 109%  key 'm'
69            uvmat('runmin_Callback',hObject,eventdata,handleshaxes)
70        otherwise
[726]71            if ischar(get(gco,'Tag'))
[764]72                switch get(gco,'tag')% tag of the current edit box
73                    case {'RootPath', 'SubDir','RootFile','FileExt','RootPath_1', 'SubDir_1','RootFile_1','FileExt_1'}
74                        set(handleshaxes.InputFileREFRESH,'BackgroundColor',[1 0 1])%indicat that REFRESH must be activated (introduce the whole series)
75                    case 'num_IndexIncrement'% no action
76                    otherwise
77                        if isfield(handleshaxes,'REFRESH')
78                            set(handleshaxes.REFRESH,'BackgroundColor',[1 0 1])%indicat that run0 must be activated
79                            if isfield(handleshaxes,'movie_pair')% stop movie pair in uvmat
80                                set(handleshaxes.movie_pair,'value',0);
81                                set(handleshaxes.movie_pair,'BusyAction','Cancel')%stop movie pair if button is 'off'
82                                set(handleshaxes.i2,'String','')% the second i index display is suppressed
83                                set(handleshaxes.j2,'String','')% the second j index display is suppressed
84                                set(handleshaxes.Dt_txt,'String','')% the time interval indication is suppressed
85                            end
86                        elseif strcmp(get(gco,'Type'),'uicontrol')
87                            set(gco,'BackgroundColor',[1 0 1])%indicate that the edition  must be validated by carriage return
88                        end
89                end
[710]90            end
91    end
[11]92end
Note: See TracBrowser for help on using the repository browser.