source: trunk/src/keyboard_callback.m @ 644

Last change on this file since 644 was 625, checked in by sommeria, 8 years ago

system of object creation by mouse ilmproved

File size: 2.9 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
6switch xx
7    case {29,28,30,31}    %arrows for displacement
8        AxeData=get(cur_axes,'UserData');
9        if isfield(AxeData,'ZoomAxes')&&ishandle(AxeData.ZoomAxes)
10           cur_axes=AxeData.ZoomAxes;% move the field of the zoom sub-plot instead of the main axes  if it exsits
11           axes(cur_axes)
12        end
13        if ~isempty(cur_axes)
14            xlimit=get(cur_axes,'XLim');
15            ylimit=get(cur_axes,'Ylim');
16            dx=(xlimit(2)-xlimit(1))/10;
17            dy=(ylimit(2)-ylimit(1))/10;
18            if isequal(xx,29)%move arrow right
19                xlimit=xlimit+dx;
20            elseif isequal(xx,28)%move arrow left
21                xlimit=xlimit-dx;
22            elseif isequal(xx,30)%move arrow up
23                ylimit=ylimit+dy;
24            elseif isequal(xx,31)%move arrow down
25                ylimit=ylimit-dy;
26            end
27            set(cur_axes,'XLim',xlimit)
28            set(cur_axes,'YLim',ylimit)
29            hfig=hObject; %master figure
30            AxeData=get(cur_axes,'UserData');
31            if isfield(AxeData,'ParentRect')% update the position of the parent rectangle representing the field
32                hparentrect=AxeData.ParentRect;
33                rect([1 2])=[xlimit(1) ylimit(1)];
34                rect([3 4])=[xlimit(2)-xlimit(1) ylimit(2)-ylimit(1)];
35                set(hparentrect,'Position',rect)
36            elseif isfield(AxeData,'LimEditBox')&& isequal(AxeData.LimEditBox,1)% update display of the GUI containing the axis (uvmat or view_field)
37                hh=guidata(hfig);
38                if isfield(hh,'num_MinX')
39                    set(hh.num_MinX,'String',num2str(xlimit(1)))
40                    set(hh.num_MaxX,'String',num2str(xlimit(2)))
41                    set(hh.num_MinY,'String',num2str(ylimit(1)))
42                    set(hh.num_MaxY,'String',num2str(ylimit(2)))
43                end
44            end
45        end
46    case {8, 127} %if the delete or suppr key is pressed, delete the current object
47        currentobject=gco;
48        huvmat=findobj(allchild(0),'tag','uvmat');
49        hlist_object=findobj(huvmat,'Tag','list_object_1');
50        ObjIndex=get(hlist_object,'Value');
51        if ObjIndex>1
52            delete_object(ObjIndex)
53        end
54        if ishandle(currentobject)
55            tag=get(currentobject,'Tag');%tag of the current selected object
56            if isequal(tag,'proj_object')
57                delete_object(currentobject)
58            end
59        end
60    case 112%  key 'p'
61        uvmat('runplus_Callback',hObject,eventdata,handleshaxes)
62    case 109%  key 'm'
63        uvmat('runmin_Callback',hObject,eventdata,handleshaxes)
64end
65
Note: See TracBrowser for help on using the repository browser.