www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgpointconstraint/generateEditorPages.m

    function hInfo = generateEditorPages(obj, hPageGroup, pProj, varargin)
%GENERATEEDITORPAGES Generate standard editor pages for the item
%
%  HINFO = GENERATEEDITORPAGES(OBJ, HGROUP, PPROJ, OPTIM) creates
%  DialogPageInfo objects for the editor pages of the point objective.

%  Copyright 2005-2015 The MathWorks, Inc. and Ford Global Technologies, Inc.


% Get the editors for the contained constraint
pCon = getConstraintExpression(obj);
if isvalid(pCon)
    hInfo = generateEditorPages(pCon.info, hPageGroup, pProj.info, varargin{:});

    % Add interface functions that will provide the constraint
    [getfcn, setfcn, finalfcn] = i_cachedconinterface(obj);
    for n = 1:length(hInfo)
        hInfo(n).addObjectInterface(getfcn, setfcn);
    end

    % Add a listener that will update the object's pointer to the current
    % constraint
    L = event.listener(hPageGroup, 'Finalize', @(src, evt) finalfcn(obj));
    hPageGroup.UserData = L;
else
    hInfo = generateEditorPages(obj.cgoptimconstraint, hPageGroup, pProj, varargin{:});
end

end



function [gf, sf, final] = i_cachedconinterface(obj)
% Variable that will cache the cgconstraint for this point constraint
con = info(getConstraintExpression(obj));
    function c = i_getcon(~)
        c = con;
    end

    function obj = i_setcon(obj, c)
        % Cache the new value and update the optim object to use it.
        con = c;
    end

    function i_finalizeobj(obj)
        pCon = getConstraintExpression(obj);
        pCon.info = con;
    end

gf = @i_getcon;
sf = @i_setcon;
final = @i_finalizeobj;
end