source: trunk/src/keyboard_callback.m @ 1186

Last change on this file since 1186 was 1184, checked in by sommeria, 4 weeks ago

bed-scan updated and many updates

File size: 5.4 KB
Line 
1%'keyboard_callback:' function activated when a key is pressed on the keyboard
2%-----------------------------------
3
4%=======================================================================
5% Copyright 2008-2024, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France
6%   http://www.legi.grenoble-inp.fr
7%   Joel.Sommeria - Joel.Sommeria (A) univ-grenoble-alpes.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
22function keyboard_callback(hObject,eventdata,handleshaxes)
23cur_axes=get(hObject,'CurrentAxes');%current plotting axes of the figure with handle hObject
24xx=double(get(hObject,'CurrentCharacter')); %get the keyboard character
25if ~isempty(xx)
26    switch xx
27        case {29,28,30,31,8592,8593,8594,8595}  %arrows for displacement (linux or windows)
28            hhh=get(hObject,'CurrentObject');
29            AxeData=get(cur_axes,'UserData');
30            if isfield(AxeData,'ZoomAxes')&&ishandle(AxeData.ZoomAxes)
31                cur_axes=AxeData.ZoomAxes;% move the field of the zoom sub-plot instead of the main axes  if it exsits
32                axes(cur_axes)
33            end
34            if ~isempty(cur_axes) && ~strcmp(get(hhh,'Type'),'uicontrol')
35                xlimit=get(cur_axes,'XLim');
36                ylimit=get(cur_axes,'Ylim');
37                dx=(xlimit(2)-xlimit(1))/10;
38                dy=(ylimit(2)-ylimit(1))/10;
39                switch xx
40                    case{29,8594}%move arrow right
41                        xlimit=xlimit+dx;
42                    case{28,8592}%move arrow left
43                        xlimit=xlimit-dx;
44                    case {30,8593}%move arrow up
45                        ylimit=ylimit+dy;
46                    case{31,8595}%move arrow down%move arrow down
47                        ylimit=ylimit-dy;
48                end
49                set(cur_axes,'XLim',xlimit)
50                set(cur_axes,'YLim',ylimit)
51                hfig=hObject; %master figure
52                AxeData=get(cur_axes,'UserData');
53                if isfield(AxeData,'ParentRect')% update the position of the parent rectangle representing the field
54                    hparentrect=AxeData.ParentRect;
55                    rect([1 2])=[xlimit(1) ylimit(1)];
56                    rect([3 4])=[xlimit(2)-xlimit(1) ylimit(2)-ylimit(1)];
57                    set(hparentrect,'Position',rect)
58                elseif isfield(AxeData,'LimEditBox')&& isequal(AxeData.LimEditBox,1)% update display of the GUI containing the axis (uvmat or view_field)
59                    hh=guidata(hfig);
60                    if isfield(hh,'num_MinX')
61                        set(hh.num_MinX,'String',num2str(xlimit(1)))
62                        set(hh.num_MaxX,'String',num2str(xlimit(2)))
63                        set(hh.num_MinY,'String',num2str(ylimit(1)))
64                        set(hh.num_MaxY,'String',num2str(ylimit(2)))
65                    end
66                end
67            end
68        case 112%  key 'p'
69            huvmat=findobj(allchild(0),'Tag','uvmat');
70            if ~isempty(huvmat)
71            hhuvmat=guidata(huvmat);
72            uvmat('runplus_Callback',hObject,eventdata,hhuvmat)
73            end
74        case 109%  key 'm'
75                      huvmat=findobj(allchild(0),'Tag','uvmat');
76                      if ~isempty(huvmat)
77            hhuvmat=guidata(huvmat);
78            uvmat('runmin_Callback',hObject,eventdata,handleshaxes)
79                      end
80        otherwise
81            if ischar(get(gco,'Tag'))
82                switch get(gco,'tag')% tag of the current edit box
83                    case {'RootPath', 'SubDir','RootFile','FileExt','RootPath_1', 'SubDir_1','RootFile_1','FileExt_1'}
84                        set(handleshaxes.InputFileREFRESH,'BackgroundColor',[1 0 1])%indicat that REFRESH must be activated (introduce the whole series)
85                    case 'num_IndexIncrement'% no action
86                    otherwise
87                        if isfield(handleshaxes,'REFRESH')
88                            set(handleshaxes.REFRESH,'BackgroundColor',[1 0 1])%indicat that run0 must be activated
89                            if isfield(handleshaxes,'movie_pair')% stop movie pair in uvmat
90                                set(handleshaxes.movie_pair,'value',0);
91                                set(handleshaxes.movie_pair,'BusyAction','Cancel')%stop movie pair if button is 'off'
92                                set(handleshaxes.num_i2,'String','')% the second i index display is suppressed
93                                set(handleshaxes.num_j2,'String','')% the second j index display is suppressed
94                                set(handleshaxes.Dt_txt,'String','')% the time interval indication is suppressed
95                            end
96                        elseif strcmp(get(gco,'Type'),'uicontrol')
97                            set(gco,'BackgroundColor',[1 0 1])%indicate that the edition  must be validated by carriage return
98                        end
99                end
100            end
101    end
102end
Note: See TracBrowser for help on using the repository browser.