source: trunk/src/keyboard_callback.m

Last change on this file was 1154, checked in by sommeria, 3 weeks ago

various improvements

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