[4] | 1 | function axismenu(FigureNumber) |
---|
| 2 | %AXISMENU - Creates a menu for opening axisgui |
---|
| 3 | % axismenu(FigureHandle) |
---|
| 4 | % |
---|
| 5 | % Creates a menu on the figure referenced by FigureHandle which |
---|
| 6 | % will open the axis GUI (axisgui) and control the grid property. |
---|
| 7 | % If FigureHandle is empty, the current figure will be used (gcf). |
---|
| 8 | % |
---|
| 9 | % See also axisgui |
---|
| 10 | % |
---|
| 11 | % Written by Greg Portmann (May 1997) |
---|
| 12 | |
---|
| 13 | % Calls: axisgui |
---|
| 14 | |
---|
| 15 | if nargin < 1 |
---|
| 16 | Cfig = gcf; |
---|
| 17 | else |
---|
| 18 | Cfig = FigureNumber; |
---|
| 19 | end |
---|
| 20 | |
---|
| 21 | FigureList = findobj('Type','figure'); |
---|
| 22 | ResizeFigureList = get(findobj('Tag','Close'),'Parent'); |
---|
| 23 | |
---|
| 24 | if isempty(ResizeFigureList) |
---|
| 25 | FigureNumber=Cfig; |
---|
| 26 | elseif find(Cfig==ResizeFigureList) |
---|
| 27 | FigureNumber=figure; |
---|
| 28 | else |
---|
| 29 | % if an axis menu already exists, then return |
---|
| 30 | if strcmp(get(findobj(Cfig,'tag','MenuAxis'),'label'),'&Axis')==1 |
---|
| 31 | return |
---|
| 32 | end |
---|
| 33 | end |
---|
| 34 | |
---|
| 35 | b = uimenu('Parent',FigureNumber, ... |
---|
| 36 | 'Label','&Axis', ... |
---|
| 37 | 'Tag','MenuAxis'); |
---|
| 38 | |
---|
| 39 | |
---|
| 40 | CallbackAxisTool = [... |
---|
| 41 | 'if strcmp(lower(get(findobj(gcbf,''Tag'',''MenuAxisTool''),''Checked'')),''on'')==1;', ... |
---|
| 42 | ' set(findobj(gcbf,''Tag'',''MenuAxisTool''),''Checked'',''off'');', ... |
---|
| 43 | ' FigHandle = get(findobj(gcbf,''Tag'',''MenuAxisTool''),''Userdata'');', ... |
---|
| 44 | ' close(FigHandle);', ... |
---|
| 45 | 'else;', ... |
---|
| 46 | ' FigHandle = axisgui(gca);', ... |
---|
| 47 | ' set(findobj(gcbf,''Tag'',''MenuAxisTool''),''Checked'',''on'');', ... |
---|
| 48 | ' set(findobj(gcbf,''Tag'',''MenuAxisTool''),''Userdata'',FigHandle);', ... |
---|
| 49 | 'end;', ... |
---|
| 50 | ]; |
---|
| 51 | |
---|
| 52 | % Userdata contains the handle for the resize figure |
---|
| 53 | c = uimenu('Parent',b, ... |
---|
| 54 | 'Callback', CallbackAxisTool, ... |
---|
| 55 | 'CreateFcn','set(findobj(gcbf,''Tag'',''MenuAxisTool''),''Checked'',''off'');', ... |
---|
| 56 | 'DeleteFcn','if strcmp(lower(get(findobj(gcbf,''Tag'',''MenuAxisTool''),''Checked'')),''on'')==1;FigHandle=get(findobj(gcbf,''Tag'',''MenuAxisTool''),''Userdata'');close(FigHandle);end;', ... |
---|
| 57 | 'Label','Axis Tool', ... |
---|
| 58 | 'Userdata', [], ... |
---|
| 59 | 'Tag','MenuAxisTool'); |
---|
| 60 | |
---|
| 61 | c = uimenu('Parent',b, ... |
---|
| 62 | 'Callback','grid on;set(findobj(gcbf,''Tag'',''MenuGridOn''),''Checked'',''on'');set(findobj(gcbf,''Tag'',''MenuGridOff''),''Checked'',''off'');', ... |
---|
| 63 | 'CreateFcn','set(findobj(gcbf,''Tag'',''MenuGridOn''),''Checked'',''off'');', ... |
---|
| 64 | 'Label','Grid On', ... |
---|
| 65 | 'Separator','on', ... |
---|
| 66 | 'Tag','MenuGridOn'); |
---|
| 67 | c = uimenu('Parent',b, ... |
---|
| 68 | 'Callback','grid off;set(findobj(gcbf,''Tag'',''MenuGridOn''),''Checked'',''off'');set(findobj(gcbf,''Tag'',''MenuGridOff''),''Checked'',''on'');', ... |
---|
| 69 | 'CreateFcn','grid off;set(findobj(gcbf,''Tag'',''MenuGridOff''),''Checked'',''on'');', ... |
---|
| 70 | 'Label','Grid Off', ... |
---|
| 71 | 'Tag','MenuGridOff'); |
---|