⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fm_axesdlg.m

📁 这是一个很适合研究和学习用的电力系统仿真软件
💻 M
📖 第 1 页 / 共 3 页
字号:
function fm_axesdlg(varargin)
%SCRIBEAXESDLG   Axes property dialog helper function for Plot Editor
%   SCRIBEAXESDLG(A)  opens axes property dialog for axes A
%
%   If the plot editor is active, the SCRIBEAXESDLG edits all
%   currently selected axes.  Alternatively, SCRIBEAXESDLG(S)
%   explicitly passes a selection list S, a row vector
%   of scribehandle objects, to SCRIBEAXESDLG for editing.
%
%   Copyright 1984-2001 The MathWorks, Inc.
%   $Revision: 1.27 $  $Date: 2001/04/15 12:01:20 $
%   j. H. Roh
%
%Modified by:    Federico Milano
%Date:      11-Nov-2002
%Version:   1.0.0
%
%E-mail:    fmilano@thunderbox.uwaterloo.ca
%Web-site:  http://thunderbox.uwaterloo.ca/~fmilano

persistent localData;

switch nargin
case 1
    arg1 = varargin{1};

    if isempty(arg1) | ishandle(arg1) | isa(arg1(1),'scribehandle')
        localData = LInitFig(arg1,localData);
        return
    elseif ischar(arg1)
        action = arg1;
        parameter = [];
    end

case 2
    action = varargin{1};
    parameter = varargin{2};

end

if strcmp(parameter,'me')
    parameter = gcbo;
end


localData = feval(action,parameter,localData);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function localData = showhelp(selection, localData)
try
    helpview([docroot '/mapfiles/plotedit.map'], ...
        'pe_ax_props', 'PlotEditPlain');
catch
    errordlg(['Unable to display help for Axes Properties:' ...
            sprintf('\n') lasterr ]);
end

function localData = button(selection, localData);
switch selection
case 'cancel'
    close(gcbf);
case 'ok'
    set(gcbf,'Pointer','watch');
    localData = LApplySettings(gcbf,localData);
    close(gcbf);
case 'apply'
    set(gcbf,'Pointer','watch');
    localData = LApplySettings(gcbf,localData);
    set(gcbf,'Pointer','arrow');
end

function localData = verifynumber(uic, localData)
iGroup = find(uic==localData.LimCheck);
val = str2double(get(uic,'String'));
if ~isnan(val)
    if length(val)==1
        localData.OldVal{iGroup} = val;
        return
    end
end
% trap errors
set(uic,'String',num2str(localData.OldVal{iGroup}));
fieldName = get(uic,'ToolTip');
errordlg([fieldName ' field requires a single numeric input'],'Error','modal');





function localData = key(fig,localData);
theKey = get(fig,'CurrentCharacter');
if isempty(theKey), return, end

switch theKey
case 13 % return
    fm_axesdlg button ok;
case 27 % escape
    fm_axesdlg button cancel;
case 9 % tab
    % next field
end
% manage state of controls


function localData = toggle(uic,localData);

iGroup = find(uic==localData.LimCheck);
Sibling = get(uic,'UserData');

enable = {'off' 'on'};
if isempty(Sibling),
    % Perform as before
    value = get(uic,'Value');
    if ~isempty(iGroup),
        set(localData.LimGroup{iGroup},'Enable',enable{value+1});
    end
else
    % See if the extra checkbox was pressed
    if isempty(get(uic,'String')),
        Sibling=uic; % Reset the Sibling as the current UIcontrol
    end
    SibUd = get(Sibling,'UserData');
    % Toggle the extra check box state
    if strcmp(get(Sibling,'enable'),'off');
        set(Sibling,'enable','inactive');
        value = get(Sibling,'Value');
    elseif isequal(SibUd.Value,get(Sibling,'Value')),
        set(Sibling,'value',~get(Sibling,'Value'))
        value = get(Sibling,'Value');
    else
        set(Sibling,'enable','off','Value',SibUd.Value);
        value = 0;
    end
    if ~isempty(iGroup),
        set(localData.LimGroup{iGroup},'Enable',enable{value+1});
    end
end % if/else isempty(Sibling)


function localData = radio(uic,localData);
iGroup = find(uic==localData.LimCheck);

Sibling = get(uic,'UserData');

enableflag = 1;
if isempty(Sibling),
    % Perform as before
    set(uic,'Value',1);
    set(localData.LimGroup{iGroup},'Value',0);
else
    if ~isempty(get(uic,'String')),
        iGroup = iGroup+2;
        ActiveButton = localData.LimCheck(iGroup);
        value = ~get(ActiveButton,'Value');
    else
        ActiveButton = uic;
        value = get(ActiveButton,'Value');
    end
    udAB = get(ActiveButton,'UserData');
    udLimGroup = get(localData.LimGroup{iGroup},'UserData');
    udLimGroup.Value = 0;

    % Toggle the active radio button's state
    if strcmp(get(ActiveButton,'enable'),'off');
        udAB.Value = 1;
        set(ActiveButton,'enable','on','Value',1,'UserData',udAB);
        set(localData.LimGroup{iGroup},'Enable','on');
    elseif udAB.Value,
        udAB.Value = 0;
        set(ActiveButton,'Value',0, ...
            'Enable','off','UserData',udAB)
        set(localData.LimGroup{iGroup},'Value',0, ...
            'Enable','off','UserData',udLimGroup)

        % Store the checkbox state,
        if ~isempty(localData.Enable{iGroup}),
            localData.Disable{iGroup-1}.CheckValue = get(localData.Enable{iGroup}(1),'Value');
        end
        enableflag = 0;
    else
        udAB.Value = 1;
        set(ActiveButton,'Value',1,'UserData',udAB);
        set(localData.LimGroup{iGroup},'Value',0,'UserData',udLimGroup)
    end % if/else strcmp(Sibling,'enable'...)
end % if/else length(localData.axes...

% for the linear/log switches
disableGroup = localData.Disable{iGroup};
if ~isempty(disableGroup) & enableflag,
    if any(strcmp(get(disableGroup.Controls,'Enable'),'on')) ,
        set(disableGroup.Controls,'Enable','off');
        % Save the checkbox value
        localData.Disable{iGroup}.CheckValue = get(disableGroup.Controls(1),'Value');
    end
    set(disableGroup.Controls(1),'Value',0);           % uncheck
    Sibling = get(disableGroup.Controls(1),'UserData');
    if ~isempty(Sibling),
        set(Sibling,'Value',0,'Enable','off','HitTest','off');
    end
end
enableGroup = localData.Enable{iGroup};
if ~isempty(enableGroup) & enableflag,
    Sibling = get(enableGroup(1),'UserData');
    if ~isempty(Sibling),
        value = get(Sibling,'Value');
    else
        value = get(enableGroup(1),'Value');
    end
    if ~value
        set(enableGroup(1),'Enable','on',...
            'Value',localData.Disable{iGroup-1}.CheckValue);     % enable checkbox
    else
        set(enableGroup,'Enable','on');  % enable both
        set(enableGroup(1),'Value',localData.Disable{iGroup-1}.CheckValue);
    end % if/else value
    if ~isempty(Sibling),
        set(Sibling,'HitTest','on','Value',localData.Disable{iGroup-1}.CheckValue);
    end
else
    set(enableGroup,'Enable','off'); % disable both
end


function localData = LInitFig(ax,localData)

if isempty(ax)
    LNoAxesError;
    return
end

try
    if ishandle(ax)
        fig = get(ax(1),'Parent');
    else
        % might be any selected object
        fig = get(ax(1),'Figure');
    end
catch
    errordlg(['Unable to edit axes properties: invalid axes' ...
            ' handles.']);
    return
end

oldPointer = get(fig,'Pointer');
set(fig,'Pointer','watch');

try
    % look for a list of selected objects
    HG = [];
    if ~plotedit(fig,'isactive')
        % plotedit has not been activated and we have a list of HG handles
        HG = ax;     % take the original handle list

    else
        % call from the Figure Tools menu or from context menu
        % ax is a selection list
        for aObj = ax
            aHG = get(aObj,'MyHGHandle');
            if strcmp('axes',get(aHG,'Type'))
                HG(end+1) = aHG;
            end
        end
    end
catch
    set(fig,'Pointer',oldPointer);
    errordlg(['Unable to open Axes Properties dialog. ' ...
            'Selection list is invalid:' ...
            10 lasterr]);
    return
end

if isempty(HG)
    LNoAxesError;
    set(fig,'Pointer',oldPointer);
    return
end

%--temporary:  redirect to Property Editor
%propedit(HG);
%set(fig,'Pointer',oldPointer);
%return

ax = HG;

try
    % Property constants
    White = [1 1 1];
    Black = [0 0 0];

    % Check each axes, if one is 3D
    allViews = get(ax,{'view'});
    f2D = isequal(allViews{:},[0 90]);

    bgcolor = get(0,'DefaultUIControlBackgroundColor');
    if bgcolor==Black
        fgcolor = White;
    else
        fgcolor = get(0,'DefaultUIControlForegroundColor');
    end

    % adjustment factors for character units
    % work in character units.
    fx = 5;
    fy = 13;

    fProps = struct(...
        'Units', get(fig,'Units'),...
        'NumberTitle', 'off',...
        'IntegerHandle', 'off',...
        'Pointer','watch', ...
        'Resize', 'on',...
        'Color', bgcolor,...
        'Visible', 'off',...
        'KeyPressFcn', 'fm_axesdlg key me',...
        'WindowStyle', 'modal',...
        'Name', 'Edit Axes Properties', ...
        'Position', get(fig,'Position'));
    f = figure(fProps);
    set(f,'Units','character');
    figPos = get(f,'Position');

    figWidth = 550/fx;
    figHeight = 325/fy;

    % center dialog over the calling window
    figPos(1:2) = figPos(1:2) + (figPos(3:4)-[figWidth, figHeight])/2;
    figPos(3:4) = [figWidth, figHeight];
    set(f,'Position',figPos);

    enable = {'off' 'on'};

    % geometry
    LMarginW = 15/fx;
    RMarginW = 25/fx;
    ColPadW = 20/fx;
    RowPadH = 9/fy;

    RowLabelW = 70/fx;
    if f2D
        nCols = 2;
    else
        nCols = 3;
    end
    data.nCols = nCols;
    setappdata(f,'ScribeAxesDialogData',data);

    ColW = (figPos(3)-RowLabelW-LMarginW-RMarginW-nCols*ColPadW)/nCols;

    TopMarginH = 20/fy;
    BotMarginH = 20/fy;
    TitleH = 25/fy;
    HeaderH = 30/fy;
    RowH = 30/fy;

    buttonW = 72/fx;
    buttonH = RowH-RowPadH;
    buttonPad = 7/fx;

    XCol(1) = LMarginW;
    XCol(2) = XCol(1) + RowLabelW + ColPadW;
    XCol(3) = XCol(2) + ColW + ColPadW;
    XCol(4) = XCol(3) + ColW + ColPadW;


    % defaults for each style
    editProps = struct(...
        'Parent', f,...
        'Style', 'edit',...
        'Units', 'character',...
        'BackgroundColor', White,...
        'ForegroundColor', Black,...
        'HorizontalAlignment', 'left',...
        'Callback', 'fm_axesdlg verifynumber me');

    checkProps = struct(...
        'Parent', f,...
        'Style', 'checkbox',...
        'Units', 'character',...
        'HorizontalAlignment', 'left',...
        'BackgroundColor', bgcolor,...
        'ForegroundColor', fgcolor,...
        'Callback', 'fm_axesdlg toggle me');

    radioProps = struct(...
        'Parent', f,...
        'Style', 'radio',...
        'Units', 'character',...
        'HorizontalAlignment', 'left',...
        'BackgroundColor', bgcolor,...
        'ForegroundColor', fgcolor,...
        'Callback', 'fm_axesdlg radio me');

    tProps = struct(...
        'Parent', f,...
        'Style', 'text',...
        'Units', 'character',...
        'HorizontalAlignment', 'right',...
        'BackgroundColor', bgcolor,...
        'ForegroundColor', fgcolor);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -