[11] | 1 | %'keyboard_callback:' function activated when a key is pressed on the keyboard |
---|
| 2 | %----------------------------------- |
---|
| 3 | function keyboard_callback(hObject,eventdata,handleshaxes) |
---|
| 4 | xx=double(get(hObject,'CurrentCharacter')); %get the keyboard character |
---|
| 5 | cur_axes=get(gcbf,'CurrentAxes'); |
---|
| 6 | if ~isempty(cur_axes) |
---|
| 7 | xlimit=get(cur_axes,'XLim'); |
---|
| 8 | ylimit=get(cur_axes,'Ylim'); |
---|
| 9 | dx=(xlimit(2)-xlimit(1))/10; |
---|
| 10 | dy=(ylimit(2)-ylimit(1))/10; |
---|
| 11 | |
---|
| 12 | if isequal(xx,29)%move arrow right |
---|
| 13 | xlimit=xlimit+dx; |
---|
| 14 | elseif isequal(xx,28)%move arrow left |
---|
| 15 | xlimit=xlimit-dx; |
---|
| 16 | elseif isequal(xx,30)%move arrow up |
---|
| 17 | ylimit=ylimit+dy; |
---|
| 18 | elseif isequal(xx,31)%move arrow down |
---|
| 19 | ylimit=ylimit-dy; |
---|
| 20 | end |
---|
| 21 | set(cur_axes,'XLim',xlimit) |
---|
| 22 | set(cur_axes,'YLim',ylimit) |
---|
| 23 | end |
---|
| 24 | if ismember(xx,[8 127]) %if the delete or suppr key is pressed, delete the current object |
---|
| 25 | currentobject=gco; |
---|
[71] | 26 | huvmat=findobj(allchild(0),'tag','uvmat'); |
---|
[11] | 27 | % UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface |
---|
[71] | 28 | hlist_object=findobj(huvmat,'Tag','list_object_1'); |
---|
[40] | 29 | ObjIndex=get(hlist_object,'Value') |
---|
[71] | 30 | if ObjIndex>1 |
---|
[11] | 31 | delete_object(ObjIndex) |
---|
| 32 | end |
---|
| 33 | if ishandle(currentobject) |
---|
| 34 | tag=get(currentobject,'Tag');%tag of the current selected object |
---|
| 35 | if isequal(tag,'proj_object') |
---|
| 36 | delete_object(currentobject) |
---|
| 37 | end |
---|
| 38 | end |
---|
| 39 | elseif isequal(xx,112)% key 'p' |
---|
| 40 | uvmat('runplus_Callback',hObject,eventdata,handleshaxes) |
---|
| 41 | elseif isequal(xx,109)% key 'm' |
---|
| 42 | uvmat('runmin_Callback',hObject,eventdata,handleshaxes) |
---|
| 43 | end |
---|
| 44 | |
---|
| 45 | AxeData=get(cur_axes,'UserData'); |
---|
| 46 | if isfield(AxeData,'ParentRect')% update the position of the parent rectangle represneting the field |
---|
| 47 | hparentrect=AxeData.ParentRect; |
---|
| 48 | rect([1 2])=[xlimit(1) ylimit(1)]; |
---|
| 49 | rect([3 4])=[xlimit(2)-xlimit(1) ylimit(2)-ylimit(1)]; |
---|
| 50 | set(hparentrect,'Position',rect) |
---|
| 51 | end |
---|