source: trunk/src/keyboard_callback.m @ 681

Last change on this file since 681 was 681, checked in by sommeria, 11 years ago

mouse action improved for translations, use of magenta color to indicate that REFRESH is needed

File size: 3.1 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)
7switch 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 {8, 127} %if the delete or suppr key is pressed, delete the current object
48%         currentobject=gco;
49%         huvmat=findobj(allchild(0),'tag','uvmat');
50%         hlist_object=findobj(huvmat,'Tag','list_object_1');
51%         ObjIndex=get(hlist_object,'Value');
52%         if ObjIndex>1
53%             delete_object(ObjIndex)
54%         end
55%         if ishandle(currentobject)
56%             tag=get(currentobject,'Tag');%tag of the current selected object
57%             if isequal(tag,'proj_object')
58%                 delete_object(currentobject)
59%             end
60%         end
61    case 112%  key 'p'
62        uvmat('runplus_Callback',hObject,eventdata,handleshaxes)
63    case 109%  key 'm'
64        uvmat('runmin_Callback',hObject,eventdata,handleshaxes)
65    otherwise
66        set(handleshaxes.run0,'BackgroundColor',[1 0 1])%indicat that Run must be activated (todo: rplace by REFRESH)
67end
68end
Note: See TracBrowser for help on using the repository browser.