function EditLabel(command, subcommand) % function EditLabel(command, subcommand) % % Abstract: % Edit labels of current axes % % % Commands and subcommands: % initialize % editlabel % title % xlabel % ylabel % zlabel % gtext % reset % done % reset % cancel % show % newaxestouched % info % % % History: % % global LASTAXIS axestr = ['XYZ']; if nargin < 1 command = 'initialize'; end if strcmp(command, 'initialize') EditLabelFig=findobj(0,'Type','figure','Tag','EditLabelFig'); if ~isempty(EditLabelFig),return,end curfig=gcf; curfig = watchon; if isempty(LASTAXIS) curaxes=gca; else curaxes=LASTAXIS; end EditLabelFig = figure('Position',[150 350 335 250],... 'NumberTitle','off',... 'Name','Edit Labels',... 'NextPlot','new',... 'Tag','EditLabelFig'); LabelFrame=uicontrol('Parent',EditLabelFig, ... 'CallBack','', ... 'Style','frame',... 'String','Axes Limits', ... 'Horiz', 'center', ... 'Position',[13 63 310 175], ... 'Tag','LabelFrame'); LabText1=uicontrol('Parent',EditLabelFig,... 'Style', 'text', ... 'Position',[13+5 63+150 300 20],... 'String','LABELS',... 'Horiz','center',... 'Tag','LabText1'); TLabO=uicontrol('Parent',EditLabelFig,... 'Style', 'text', ... 'Position',[13+5 63+125 50 20],... 'String','Title: ',... 'Horiz','Right',... 'Tag','TLabO'); XLabO=uicontrol('Parent',EditLabelFig,... 'Style', 'text', ... 'Position',[13+5 63+100 50 20],... 'String','X-Axis: ',... 'HorizontalAlignment','Right',... 'Tag','XLabO'); YLabO=uicontrol('Parent',EditLabelFig,... 'Style', 'text', ... 'Position',[13+5 63+75 50 20],... 'String','Y-Axis: ',... 'Horiz','Right',... 'Tag','YLabO'); ZLabO=uicontrol('Parent',EditLabelFig,... 'Style', 'text', ... 'Position',[13+5 63+50 50 20],... 'String','Z-Axis: ',... 'Horiz','Right',... 'Tag','ZLabO'); GLabO=uicontrol('Parent',EditLabelFig,... 'Style', 'text', ... 'Position',[13+5 63+25 50 20],... 'String','Gtext: ',... 'Horiz','Right',... 'Tag','GLabO'); TLabOe=uicontrol('Parent',EditLabelFig,... 'CallBack','EditLabel(''editlabel'',''title'')',... 'BackgroundColor','w',... 'ForegroundColor','r',... 'Position',[13+5+50 63+125 247 20],... 'String',get(get(curaxes,'title'),'string'),... 'Style','edit',... 'Tag','TLabOe'); XLabOe=uicontrol('Parent',EditLabelFig,... 'CallBack','EditLabel(''editlabel'',''xlabel'')',... 'BackgroundColor','w',... 'ForegroundColor','r',... 'Position',[13+5+50 63+100 247 20],... 'String',get(get(curaxes,'xlabel'),'string'),... 'Style','edit',... 'Tag','XLabOe'); YLabOe=uicontrol('Parent',EditLabelFig,... 'CallBack','EditLabel(''editlabel'',''ylabel'')',... 'BackgroundColor','w',... 'ForegroundColor','r',... 'Position',[13+5+50 63+75 247 20],... 'String',get(get(curaxes,'ylabel'),'string'),... 'Style','edit',... 'Tag','YLabOe'); ZLabOe=uicontrol('Parent',EditLabelFig,... 'CallBack','EditLabel(''editlabel'',''zlabel'')',... 'BackgroundColor','w',... 'ForegroundColor','r',... 'Position',[13+5+50 63+50 247 20],... 'String',get(get(curaxes,'zlabel'),'string'),... 'Style','edit',... 'Tag','ZLabOe'); GLabOe=uicontrol('Parent',EditLabelFig,... 'CallBack','EditLabel(''editlabel'',''gtext'')',... 'BackgroundColor','w',... 'ForegroundColor','r',... 'Position',[13+5+50 63+25 247 20],... 'String','',... 'Style','edit',... 'Tag','GLabOe'); % Done, cancel, and reset buttons DoneButton = uicontrol('Parent',EditLabelFig,... 'BackgroundColor',[0;1;0],... 'Style','pushbutton',... 'String','Done',... 'Position',[23 35 50 20],... 'Callback','EditLabel(''reset'',''done'')',... 'Tag','DoneButton'); ResetButton = uicontrol('Parent',EditLabelFig,... 'BackgroundColor',[1;1;0],... 'Style','pushbutton',... 'String','Reset',... 'Position',[23+63 35 50 20],... 'Callback','EditLabel(''reset'',''reset'')',... 'Tag','ResetButton'); CancelButton = uicontrol('Parent',EditLabelFig,... 'BackgroundColor',[1;0;0],... 'Style','pushbutton',... 'String','Cancel',... 'Position',[23+63+63 35 50 20],... 'Callback','EditLabel(''reset'',''cancel'')',... 'Tag','CancelButton'); HelpButton = uicontrol('Parent',EditLabelFig,... 'BackgroundColor',[1;1;1],... 'ForegroundColor',[0;0;0],... 'Style','pushbutton',... 'String','HELP',... 'Position',[23+63 10 50 20],... 'Callback','EditLabel(''info'')',... 'Tag','HelpButton'); % Use hidden axes (non-visible) to store original data about the limits % so that original limits can be restored by user if it is desired HiddenLabels = axes('Parent',EditLabelFig,... 'Visible', 'off', ... 'Tag', 'HiddenLabels'); title=get(get(curaxes, 'Title'), 'String'); set(get(HiddenLabels, 'Title'), 'String', title); % for each axis get label and set in Hidden Axes for i=1:3 label=get(get(curaxes, [axestr(i) 'Label']), 'String'); set(get(HiddenLabels, [axestr(i) 'Label']), 'String', label); end % for each axis watchoff(curfig); elseif strcmp(command, 'editlabel') EditLabelFig=findobj(0,'Type','figure','Tag','EditLabelFig'); XLabOe = findobj(0,'Type', 'uicontrol', 'Tag', 'XLabOe'); YLabOe = findobj(0,'Type', 'uicontrol', 'Tag', 'YLabOe'); ZLabOe = findobj(0,'Type', 'uicontrol', 'Tag', 'ZLabOe'); TLabOe = findobj(0,'Type', 'uicontrol', 'Tag', 'TLabOe'); GLabOe = findobj(0,'Type', 'uicontrol', 'Tag', 'GLabOe'); if isempty(LASTAXIS) curaxes=gca; else curaxes=LASTAXIS; end if strcmp(subcommand, 'xlabel') XLabOe=findobj(EditLabelFig,'Type','uicontrol','Tag','XLabOe'); str=get(XLabOe,'String'); set(get(curaxes,'Xlabel'),'String',str); elseif strcmp(subcommand, 'ylabel') YLabOe=findobj(EditLabelFig,'Type','uicontrol','Tag','YLabOe'); str=get(YLabOe,'String'); set(get(curaxes,'Ylabel'),'String',str); elseif strcmp(subcommand, 'zlabel') YLabOe=findobj(EditLabelFig,'Type','uicontrol','Tag','ZLabOe'); str=get(ZLabOe,'String'); set(get(curaxes,'Zlabel'),'String',str); elseif strcmp(subcommand, 'title') TLabOe=findobj(EditLabelFig,'Type','uicontrol','Tag','TLabOe'); str=get(TLabOe,'String'); set(get(curaxes,'Title'),'String',str); elseif strcmp(subcommand, 'gtext') GLabOe=findobj(EditLabelFig,'Type','uicontrol','Tag','GLabOe'); str=get(GLabOe,'String'); axes(curaxes); h=gtext(str); end elseif strcmp(command, 'reset') EditLabelFig=findobj(0,'Type','figure','Tag','EditLabelFig'); XLabOe = findobj(0,'Type', 'uicontrol', 'Tag', 'XLabOe'); YLabOe = findobj(0,'Type', 'uicontrol', 'Tag', 'YLabOe'); ZLabOe = findobj(0,'Type', 'uicontrol', 'Tag', 'ZLabOe'); TLabOe = findobj(0,'Type', 'uicontrol', 'Tag', 'TLabOe'); GLabOe = findobj(0,'Type', 'uicontrol', 'Tag', 'GLabOe'); HiddenLabels=findobj(0,'Type','axes','Tag','HiddenLabels'); if isempty(LASTAXIS) curaxes=gca; else curaxes=LASTAXIS; end if strcmp(subcommand, 'done') %close Edit Label Figure and retain changes made delete(EditLabelFig); elseif strcmp(subcommand, 'reset') % get data from hidden axes title=get(get(HiddenLabels, 'title'), 'String'); set(get(curaxes, 'title'), 'String', title); % for each axis set Hidden label back to curaxes for i=1:3 label=get(get(HiddenLabels, [axestr(i) 'Label']), 'String'); set(get(curaxes, [axestr(i) 'Label']), 'String', label); end % for each axis % show reset data back in Edit Labels EditLabel('reset','show'); elseif strcmp(subcommand, 'cancel') title=get(get(HiddenLabels, 'title'), 'String'); set(get(curaxes, 'title'), 'String', title); % for each axis set Hidden label back to curaxes for i=1:3 label=get(get(HiddenLabels, [axestr(i) 'Label']), 'String'); set(get(curaxes, [axestr(i) 'Label']), 'String', label); end % for each axis delete(EditLabelFig); elseif strcmp(subcommand, 'show') set(TLabOe, 'String', get(get(curaxes, 'title'), 'String')); set(XLabOe, 'String', get(get(curaxes, 'xlabel'), 'String')); set(YLabOe, 'String', get(get(curaxes, 'ylabel'), 'String')); set(ZLabOe, 'String', get(get(curaxes, 'zlabel'), 'String')); elseif strcmp(subcommand, 'newaxestouched') title=get(get(curaxes, 'Title'), 'String'); set(get(HiddenLabels, 'Title'), 'String', title); % for each axis get label and set in Hidden Axes for i=1:3 label=get(get(curaxes, [axestr(i) 'Label']), 'String'); set(get(HiddenLabels, [axestr(i) 'Label']), 'String', label); end % for each axis EditLabel('reset', 'show'); end elseif strcmp(command,'info'); ttlStr='Edit Labels Help'; hlpStr= ... [' ' ' ' ' ']; PrHelp(ttlStr,hlpStr); end