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

    function setnewnode(h,nd,subitem)
%SETNEWNODE Set a new node current node and/or subitem
%
% SETNEWNODE(CGB, nd, subitem) sets a new node and/or subitem in h. This
% method will ensure that redraw only occurs once if it is necessary.

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


if h.GUIExists && (isnull(nd) || ~isequal([h.CurrentNode h.CurrentSubItem] ,[nd subitem]))
    
    if h.RootNode.isblank
        % Get Started
        selectHome(h,1);
    elseif  get(h.Hand.HomeCardLayout,'CurrentCard')==1
        % Browser
        selectHome(h,2);
    end
    
    PR = xregGui.PointerRepository;
    ptrID = PR.stackSetPointer(h.Figure,'watch');
    
    % Temporarily remove user's right to close GUI via the "x" in the corner
    cbfcn = get(h.Figure,'CloseRequestFcn');
    set(h.Figure,'CloseRequestFcn','');
    
    % Set the new node and subitem into the public properties so that other
    % routines can access them
    h.CurrentNode = nd;
    h.CurrentSubItem = subitem;
    
    % Ensure view is created for node being selected
    ind = h.CreateView(nd, subitem);
    
    % Ensure current view is hidden correctly
    OK = h.HideNode;
    
    if ~OK
        % The old view prevented the switch - revert to previous node and
        % subnode
        h.CurrentNode = h.SelNode;
        h.CurrentSubItem = h.SelSubItem;
        h.doDrawTree(h.CurrentNode,'select');
        h.doDrawList('select');
    else
        if ind~=1
            h.doDrawTree(h.CurrentNode,'select');
            h.doDrawList('select');
        end

        % Configure and display new node view
        h.ShowNode(nd,subitem,ind);
        h.doDrawList('uicontextmenu');

        % Refresh new view
        h.ViewNode;
        
    end
    PR.stackRemovePointer(h.Figure,ptrID);
    drawnow('expose');
    set(h.Figure,'CloseRequestFcn',cbfcn);
    
elseif ~isnull(h.CurrentNode)
    h.ViewNode;
end