www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgtools/@cgbrowser/CreateView.m

    function ind = CreateView(h, pNode, pSubItem)
%CREATEVIEW Ensure a view has been created
%
%  IND = CREATEVIEW(CGB, node, subitem) ensures a view has been created and
%  returns the internal index which refers to the view.

%  Copyright 2000-2016 The MathWorks, Inc. and Ford Global Technologies, Inc.


if h.GUIExists
    
    if ~isvalid(pNode)
        ind = 1;   % the empty card
    else
        % Perform card-switching.
        node = pNode.info;
        ThisGUID = guid(node, pSubItem);
        ind = locateview(h, ThisGUID);
        if isempty(ind)
            msgID = h.addStatusMsg(['Generating display for ' name(node) '...']);
            
            % create a slot in our data for new view
            ind = length(h.ViewData)+1;
            h.ViewGUIDs = char(h.ViewGUIDs, ThisGUID);
            set(h.ViewCardObj,'numcards',ind);
            set(h.ViewToolbarCard,'numcards',ind);
            pnew = xregGui.RunTimePointer;
            pnew.LinkToObject(h.Figure);
            h.ViewData = [h.ViewData; pnew];
            h.ViewMenus = [h.ViewMenus, {[]}];
            
            % Construct view
            info = struct(...
                'Figure', h.Figure, ...
                'browserH',h, ...
                'ViewID', ThisGUID,...
                'ViewParent',h.Hand.BrowserParent ,...
                'ToolbarParent',h.Hand.Toolbar.Panel);
            [lyt, tblyt, vwdata] = creategui(node,info);
            
            % Capture view data
            h.ViewData(ind).info = vwdata;
 
            attach(h.ViewCardObj,lyt,ind);
            attach(h.ViewToolbarCard, tblyt, ind);
            h.removeStatusMsg(msgID);
        end
    end
else
    ind = 0;
end