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

📄 guidata.cpp

📁 matlab的可执行程序
💻 CPP
📖 第 1 页 / 共 2 页
字号:
//
// function data = guidata(h, data_in)
//
static mwArray Mguidata(int nargout_, mwArray h, mwArray data_in) {
    mwLocalFunctionTable save_local_function_table_
      = &_local_function_table_guidata;
    int nargin_ = nargin(2, mwVarargin(h, data_in));
    mwArray data = mwArray::UNDEFINED;
    mwArray fig = mwArray::UNDEFINED;
    mwArray ans = mwArray::UNDEFINED;
    mwArray PROP_NAME = mwArray::UNDEFINED;
    //
    // %GUIDATA Store or retrieve application data.
    // %   GUIDATA(H, DATA) stores the specified data in the figure's
    // %   application data.
    // %
    // %   H is a handle that identifies the figure - it can be the figure
    // %   itself, or any object contained in the figure.
    // %
    // %   DATA can be anything an application wishes to store for later
    // %   retrieval.
    // %
    // %   DATA = GUIDATA(H) returns previously stored data, or an empty
    // %   matrix if nothing was previously stored.
    // %
    // %   GUIDATA provides application authors with a convenient interface
    // %   to a figure's application data. You can access the data from a
    // %   callback subfunction using the component's handle, without needing
    // %   to find the figure's handle.  You can also avoid having to create
    // %   and maintain a hardcoded property name for the application data
    // %   throughout your source code.  GUIDATA is particularly useful in
    // %   conjunction with GUIHANDLES, which returns a structure containing
    // %   handles of all the components in a GUI listed by tag.
    // %
    // %   Example:
    // %
    // %   Suppose an application creates a figure with handle F, containing
    // %   a slider and an editable text uicontrol whose tags are
    // %   'valueSlider' and 'valueEdit' respectively.  The following
    // %   excerpts from the application's M-file illustrate the use of
    // %   GUIDATA to access a structure containing handles returned by
    // %   GUIHANDLES, plus additional application-specific data added during
    // %   initialization and callbacks:
    // %
    // %   ... excerpt from the GUI setup code ...
    // %
    // %   f = openfig('mygui.fig');
    // %   data = guihandles(f); % initialize it to contain handles
    // %   data.errorString = 'Total number of mistakes: ';
    // %   data.numberOfErrors = 0;
    // %   guidata(f, data);  % store the structure
    // %
    // %   ... excerpt from the slider's callback ...
    // %
    // %   data = guidata(gcbo); % get the struct, use the handles:
    // %   set(data.valueEdit, 'String',...
    // %       num2str(get(data.valueSlider, 'Value')));
    // %
    // %   ... excerpt from the edit's callback ...
    // %
    // %   data = guidata(gcbo); % need handles, may need error info
    // %   val = str2double(get(data.valueEdit,'String'));
    // %   if isnumeric(val) & length(val)==1 & ...
    // %      val >= get(data.valueSlider, 'Min') & ...
    // %      val <= get(data.valueSlider, 'Max')
    // %     set(data.valueSlider, 'Value', val);
    // %   else
    // %     % increment the error count, and display it
    // %     data.numberOfErrors = data.numberOfErrors + 1;
    // %     set(handles.valueEdit, 'String',...
    // %      [ data.errorString, num2str(data.numberOfErrors) ]);
    // %     guidata(gcbo, data); % store the changes...
    // %   end
    // %
    // %   Note that GUIDE generates callback functions to which a structure
    // %   of handles is passed automatically as an input argument.  This
    // %   eliminates the need to call "data = guidata(gcbo);" in callbacks
    // %   written using GUIDE, unlike the example above.
    // %
    // %  See also GUIHANDLES, GUIDE, OPENFIG, GETAPPDATA, SETAPPDATA.
    // 
    // %   Damian T. Packer 6-8-2000
    // %   Copyright 1984-2002 The MathWorks, Inc.
    // %   $Revision: 1.7 $  $Date: 2002/04/09 01:36:02 $
    // 
    // % choose a unique name for our application data property.
    // % This M-file should be the only place using it.
    // PROP_NAME = 'UsedByGUIData_m';
    //
    PROP_NAME = _mxarray0_;
    //
    // 
    // error(nargchk(1, 2, nargin));
    //
    error(mwVarargin(nargchk(_mxarray2_, _mxarray3_, nargin_)));
    //
    // if (nargin == 2)
    //
    if (nargin_ == 2) {
        //
        // error(nargoutchk(0, 0, nargout));
        //
        error(mwVarargin(nargoutchk(_mxarray4_, _mxarray4_, nargout_)));
    //
    // end
    //
    }
    //
    // 
    // fig = [];
    //
    fig = _mxarray5_;
    //
    // if ishandle(h) & length(h) == 1
    //
    {
        mwArray a_ = ishandle(mwVa(h, "h"));
        if (tobool(a_) && tobool(a_ & mclLengthInt(mwVa(h, "h")) == 1)) {
            //
            // fig = getParentFigure(h);
            //
            fig = guidata_getParentFigure(mwVa(h, "h"));
        } else {
        }
    //
    // end
    //
    }
    //
    // if isempty(fig)
    //
    if (tobool(isempty(mwVv(fig, "fig")))) {
        //
        // error('H must be the handle to a figure or figure descendent.');
        //
        error(mwVarargin(_mxarray6_));
    //
    // end
    //
    }
    //
    // 
    // if nargin == 1 % GET
    //
    if (nargin_ == 1) {
        //
        // data = getappdata(fig, PROP_NAME);
        //
        data = getappdata(mwVv(fig, "fig"), mwVv(PROP_NAME, "PROP_NAME"));
    //
    // else % (nargin == 2) SET
    //
    } else {
        //
        // setappdata(fig, PROP_NAME, data_in);
        //
        setappdata(
          mwVarargin(
            mwVv(fig, "fig"),
            mwVv(PROP_NAME, "PROP_NAME"),
            mwVa(data_in, "data_in")));
    //
    // end
    //
    }
    mwValidateOutput(data, 1, nargout_, "data", "guidata");
    return data;
    //
    // 
    // 
    //
}

//
// The function "Mguidata_getParentFigure" is the implementation version of the
// "guidata/getParentFigure" M-function from file
// "e:\matlab6.5\toolbox\matlab\uitools\guidata.m" (lines 99-105). It contains
// the actual compiled code for that M-function. It is a static function and
// must only be called from one of the interface functions, appearing below.
//
//
// function fig = getParentFigure(fig)
//
static mwArray Mguidata_getParentFigure(int nargout_, mwArray fig_in) {
    mwLocalFunctionTable save_local_function_table_
      = &_local_function_table_guidata;
    mwArray fig = mwArray::UNDEFINED;
    fig.CopyInputArg(fig_in);
    //
    // % if the object is a figure or figure descendent, return the
    // % figure.  Otherwise return [].
    // while ~isempty(fig) & ~strcmp('figure', get(fig,'type'))
    //
    for (;;) {
        mwArray a_ = ~ isempty(mwVa(fig, "fig"));
        if (tobool(a_)
            && tobool(
                 a_
                 & ~ strcmp(
                       _mxarray8_,
                       Nget(1, mwVarargin(mwVa(fig, "fig"), _mxarray10_))))) {
        } else {
            break;
        }
        //
        // fig = get(fig,'parent');
        //
        fig = Nget(1, mwVarargin(mwVa(fig, "fig"), _mxarray12_));
    //
    // end
    //
    }
    mwValidateOutput(fig, 1, nargout_, "fig", "guidata/getParentFigure");
    return fig;
}

⌨️ 快捷键说明

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