📄 fm_axesdlg.m
字号:
'Tag', [col 'DirNormal'],... 'ToolTip',[col 'Dir=''normal''']); set(rnormal,'UserData',rnormal2,'Tag',''); end Y = Y-RowH*2/3; rreverse = uicontrol(radioProps,... 'Position', [X+ColW/2 Y ColW/2 uiH],... 'String', 'Reverse',... 'Value', ~radioProps.Value,... 'Tag', [col 'DirReverse'],... 'ToolTip',[col 'Dir=''reverse''']); if MultDirs rreverse2 = uicontrol(radioProps,... 'ButtonDownFcn','fm_axesdlg radio me', ... 'Enable','off', ... 'Position', [X+ColW/2 Y 3 uiH],... 'String', '',... 'Tag', [col 'DirReverse'],... 'ToolTip',[col 'Dir=''reverse''']); set(rreverse,'UserData',rreverse2,'Tag',''); set(rreverse2,'UserData',... struct('Value',0,'Sibling',rreverse,'OtherRadio',rnormal2)); set(rnormal2,'UserData',... struct('Value',0,'Sibling',rnormal,'OtherRadio',rreverse2)); end Y = Y-RowH*1/3; iGroup = iGroup+1; localData.LimGroup{iGroup} = [rnormal]; localData.LimCheck(iGroup) = rreverse; localData.Enable{iGroup} = []; localData.Disable{iGroup} = []; iGroup = iGroup+1; localData.LimGroup{iGroup} = [rreverse]; localData.LimCheck(iGroup) = rnormal; localData.Enable{iGroup} = []; localData.Disable{iGroup} = []; if MultDirs iGroup = iGroup+1; localData.LimGroup{iGroup} = [rnormal2]; localData.LimCheck(iGroup) = rreverse2; localData.Enable{iGroup} = []; localData.Disable{iGroup} = []; iGroup = iGroup+1; localData.LimGroup{iGroup} = [rreverse2]; localData.LimCheck(iGroup) = rnormal2; localData.Enable{iGroup} = []; localData.Disable{iGroup} = []; end % grid % Check if all axes grids are on AllGrids = strcmpi(get(ax,[col 'Grid']),'on'); MultGrids = 0; if all(~AllGrids) checkProps.Value = 0; elseif all(AllGrids) checkProps.Value = 1; else MultGrids = 1; checkProps.Value = length(find(AllGrids))>=length(find(~AllGrids)); end Y = Y-RowH; g = uicontrol(checkProps,... 'String', 'On',... 'Tag', [col 'Grid'],... 'ToolTip', [col 'Grid'],... 'Position', [X Y ColW/3 uiH],... 'Callback', 'fm_axesdlg toggle me'); iGroup = iGroup+1; localData.LimGroup{iGroup} = []; localData.LimCheck(iGroup) = g; localData.Enable{iGroup} = []; localData.Disable{iGroup} = []; if MultGrids g2 = uicontrol(checkProps,... 'ButtonDownFcn','fm_axesdlg toggle me', ... 'Enable','off', ... 'String', '',... 'Tag', [col 'Grid'],... 'ToolTip', [col 'Grid'],... 'UserData',struct('Value',checkProps.Value,'Sibling',g), ... 'Position', [X Y 3 uiH],... 'Callback', 'fm_axesdlg toggle me'); set(g,'UserData',g2,'Tag',''); iGroup = iGroup+1; localData.LimGroup{iGroup} = []; localData.LimCheck(iGroup) = g2; localData.Enable{iGroup} = []; localData.Disable{iGroup} = []; end iGroup = iGroup+1; end buttonX(1) = (figPos(3)-4*buttonW-3*buttonPad)/2; for ib = 2:4 buttonX(ib) = buttonX(ib-1) + buttonW + buttonPad; end buttonProps = struct(... 'Parent',f,... 'Units','character',... 'BackgroundColor', bgcolor,... 'ForegroundColor', fgcolor,... 'Position', [0 BotMarginH buttonW buttonH],... 'Style', 'pushbutton'); buttonProps.Position(1) = buttonX(1); u = uicontrol(buttonProps,... 'Interruptible', 'off',... 'String', 'OK',... 'Callback', 'fm_axesdlg button ok'); buttonProps.Position(1) = buttonX(2); uicontrol(buttonProps,... 'Interruptible', 'off',... 'String', 'Cancel',... 'Callback', 'fm_axesdlg button cancel'); buttonProps.Position(1) = buttonX(3); uicontrol(buttonProps,... 'Interruptible', 'off',... 'String', 'Help',... 'Callback', 'fm_axesdlg showhelp me'); buttonProps.Position(1) = buttonX(4); uicontrol(buttonProps,... 'Interruptible', 'on',... 'String', 'Apply',... 'Callback', 'fm_axesdlg button apply'); % finish opening axes dialog box set(fig,'Pointer',oldPointer); set(f,'Visible','on','Pointer','arrow'); localData.axes = ax; catch set(fig,'Pointer',oldPointer); if exist('f') delete(f); end errordlg({'Couldn''t open axes properties dialog:' ... lasterr},... 'Error',... 'modal'); end function [val,setflag] = getval(f,tag) uic = findobj(f,'Tag',tag); setflag = 1; % Flag for setting properties on multiple axes switch get(uic,'Style') case 'edit' val = get(uic, 'String'); if isempty(val) setflag = 0; end case {'checkbox' 'radiobutton'} val = get(uic, 'Value'); setflag = ~strcmp(get(uic,'Enable'),'off'); if setflag & isstruct(get(uic,'UserData')); %---Making a previously non-common property, common LdeleteControl(uic) end end function val = setval(f,tag,val) uic = findobj(f,'Tag',tag); switch get(uic,'Style') case 'edit' set(uic, 'String',val); case {'checkbox' 'radiobutton'} set(uic, 'Value',val); end function localData = LApplySettings(f, localData) % get the values and set props: ax = localData.axes; iProp = 0; try % title val = getval(f,'Title'); switch class(val) case 'char' if ~isempty(val) & size(val,1)>1 % title returns as a string matrix % check for blank line at end of multiline title nTitleLines = size(val,1); if val(nTitleLines,:)==32 % true if all spaces val(nTitleLines,:) = []; setval(f,'Title',val); end end case 'cell' if length(val)>1 nTitleLines = length(val); if isempty(val{nTitleLines}) | val{nTitleLines}==32 val(nTitleLines) = []; end end end CommonTitle = get(findobj(f,'Tag','Title'),'UserData'); if ~(isempty(val) & length(ax)>1) | CommonTitle | length(ax)==1, t = get(ax,{'Title'}); set([t{:}],'String',val); if ~CommonTitle, % They are common, now set(findobj(f,'Tag','Title'),'UserData',1) end end data = getappdata(f,'ScribeAxesDialogData'); cols = 'XYZ'; for i = 1:data.nCols col = cols(i); %label CommonLabel = get(findobj(f,'Tag',[col 'Label']),'UserData'); val = getval(f,[col 'Label']); if ~(isempty(val) & length(ax)>1) | CommonLabel | length(ax)==1, t = get(ax,{[col 'Label']}); set([t{:}],'String',val) if ~CommonLabel, % They are common, now set(findobj(f,'Tag',[col 'Label']),'UserData',1) end end % scale [mode,setflag] = getval(f,[col 'ScaleLinear']); if setflag, iProp = iProp+1; axProps{iProp} = [col 'Scale']; modeswitch = {'log' 'linear'}; axVals{iProp} = modeswitch{mode+1}; % update immediately so that we get updated limits and ticks set(ax,axProps(iProp),axVals(iProp)); end % if setflag linearScale = mode; %limitmode [manual,setflag] = getval(f,[col 'LimMode']); valMax=[]; valMin=[]; limits=[]; if setflag iProp = iProp+1; axProps{iProp} = [col 'LimMode']; modeswitch = {'auto' 'manual'}; axVals{iProp} = modeswitch{manual+1}; if manual %limits valMin = str2double(getval(f,[col 'LimMin'])); valMax = str2double(getval(f,[col 'LimMax'])); % ranges checked on callbacks if ~(isnan(valMax) | isnan(valMin)), iProp = iProp+1; axProps{iProp} = [col 'Lim']; limits = [valMin valMax]; axVals{iProp} = limits; end else % auto set(ax,[col 'LimMode'],'auto'); % Check for common limits lim = get(ax,{[col 'Lim']}); lim = cat(1,lim{:}); Umin = unique(lim(:,1)); Umax = unique(lim(:,2)); if length(Umin)>1, uminStr = ''; else, uminStr = num2str(Umin); end if length(Umax)>1, umaxStr = ''; else, umaxStr = num2str(Umax); end setval(f, [col 'LimMin'], uminStr); setval(f, [col 'LimMax'], umaxStr); end % if manual end % if setflag %tickmode TickInd=[]; [manual,setflag] = getval(f,[col 'TickMode']); if setflag, iProp = iProp+1; axProps{iProp} = [col 'TickMode']; modeswitch = {'auto' 'manual'}; axVals{iProp} = modeswitch{manual+1}; if linearScale if manual tickstep = str2double(getval(f,[col 'TickStep'])); if ~isempty(tickstep), % Make sure something is there if ~isempty(limits), % Only preset ticks when everything is the same iProp = iProp+1; axProps{iProp} = [col 'Tick']; ticks = limits(1):tickstep:limits(2); % ranges checked on callbacks axVals{iProp} = ticks; else TickInd = iProp; end end else % auto set(ax,[col 'TickMode'],'auto'); if length(ax)==1 ticks = get(ax,[col 'Tick']); setval(f, [col 'TickStep'], ticks(2)-ticks(1)); end end % if manual else % log scale % manual mode disabled for log scale set(ax,[col 'TickMode'],'auto'); setval(f, [col 'TickStep'], ''); end end % if setflag % scale direction [mode,setflag] = getval(f,[col 'DirNormal']); if setflag, iProp = iProp+1; axProps{iProp} = [col 'Dir']; modeswitch = {'reverse' 'normal'}; axVals{iProp} = modeswitch{mode+1}; end % grid [mode,setflag] = getval(f,[col 'Grid']); if setflag, iProp = iProp+1; axProps{iProp} = [col 'Grid']; modeswitch = {'off' 'on'}; axVals{iProp} = modeswitch{mode+1}; end % if setflag if ~isempty(TickInd) | isnan(valMax) | isnan(valMin) % Going to have to loop thru to set limits/ticks individually for ct = 1:length(ax) limits = get(ax(ct),[col 'Lim']); axPropsCustom{1} = [col 'Lim']; if ~isnan(valMax), limits(2) = valMax; end if ~isnan(valMin), limits(1) = valMin; end axValsCustom{1} = limits; if ~isempty(TickInd); axPropsCustom{2} = [col 'Tick']; ticks = limits(1):tickstep:limits(2); % ranges checked on callbacks axValsCustom{2} = ticks; end % if ~isempty(TickInd) set(ax(ct),axPropsCustom,axValsCustom); end % for ct end end % for col set(ax,axProps,axVals) catch % error somewhere in there... end % try/catch function LdeleteControl(OldControl) ud = get(OldControl,'UserData'); set(ud.Sibling,'Value',get(OldControl,'Value'), ... 'Tag',get(OldControl,'Tag'),'UserData',[]) if isfield(ud,'OtherRadio'), ud2 = get(ud.OtherRadio,'UserData'); set(ud2.Sibling,'Value',get(ud.OtherRadio,'Value'), ... 'Tag',get(ud.OtherRadio,'Tag'),'UserData',[]) delete(ud.OtherRadio) end delete(OldControl) function LNoAxesError errordlg(['No axes are selected. Click on an axis to select it.']);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -