www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgnormnode/creategui.m

    function [LYT,TBLYT,ud] = creategui(node,info)
%CREATEGUI

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


h=info.browserH;
menus=h.createmenu(guid(node),2);
set(menus,{'Label'},{'&View';'&Normalizer'});
ViewMenuH=menus(1);
ToolsMenuH=menus(2);
cbs = callbacks( node, 'gethandles');

ud.Handles.ViewParent = info.ViewParent;
ud.Handles.Figure = info.Figure;
ud.Handles.MessageID = []; % ID of current status bar message

ud.Handles.Menus = i_create_menus(ViewMenuH, ToolsMenuH, cbs);

ud.NormCount = 0; % no normalisers visible yet

% The three important components
T1 = cgtools.breakpointeditor(ud.Handles.ViewParent);
T2 = cgtools.breakpointeditor(ud.Handles.ViewParent);
ud.Handles.ComparisonPane = cgtools.normcomp('parent', ud.Handles.ViewParent, ...
    'visible', 'off');

listeners = [...
    handle.listener(T1,'TableCellsSelected',{cbs.ClearTableSelection,T2}),...
    handle.listener(T1,'ShowHistory',{cbs.PopupViewHistory,1}),...
    handle.listener(T1,'DataChanged',{cbs.DataChanged}),...
    handle.listener(T2,'TableCellsSelected',{cbs.ClearTableSelection,T1}),...
    handle.listener(T2,'ShowHistory',{cbs.PopupViewHistory,2}),...
    handle.listener(T2,'DataChanged',{cbs.DataChanged}) ];

ud.Handles.TablePane = [T1 T2];
ud.Handles.TableListeners = listeners;


[ud.Handles.ToolBarPane , ud.ToolBar.Handles] = i_create_toolbar(h, cbs);
TBLYT = ud.Handles.ToolBarPane; % we need to return this

two_norm=xreggridbaglayout(ud.Handles.ViewParent,...
    'dimension',[2,1],...
    'gapy',4,...
    'elements',{T1,T2});

ud.Handles.TableSplit = xregcardlayout(ud.Handles.ViewParent,...
    'numcards',3,...
    'visible','off',...
    'drawonselect','on');

% card layout in which we show two, one or none of the breakpointeditor components.
nullview = uipanel('Parent', ud.Handles.ViewParent, ...
    'Visible', 'off', ...
    'Units', 'pixels');
attach(ud.Handles.TableSplit,nullview,1);  % blank pane
attach(ud.Handles.TableSplit,T1,2); % single normaliser view
attach(ud.Handles.TableSplit,two_norm,3); % dual normaliser view

% the main layout
ud.Handles.Display = xregsnapsplitlayout(ud.Handles.ViewParent,...
    'elements',{ud.Handles.TableSplit,ud.Handles.ComparisonPane},...
    'barstyle',1,...
    'split',[0.6 0.4],...
    'orientation','ud',...
    'state','bottom',...
    'split',[0.6 0.4],...
    'style','tobottom',...
    'snapstyle','tozero',...
    'minwidth',[300 150],...
    'visible','off',...
    'callback',{cbs.DisplaySplitChange});

LYT = ud.Handles.Display; % we return this
setBoolPackstatus(LYT,true);

% set up internal flags that govern how initialisation and optimisation behave.
ud.FunctionFlags.InitialisationFlag = 1; % Will tell us which of the initialisation algorithms to implement.
ud.FunctionFlags.EndPointFlag = 1; % Will tell us whether endpoints are to be fixed or movable.
ud.FunctionFlags.OptimisationAlgFlag = 1; % Will tell us which optimisation algorithm to use (should there ever
% be more than one).
ud.FunctionFlags.OptimisationFlag = 1; % Will tell us whether we are to try to moveboth BP's and 
% Values or just BP's alone.

ud.Store.VarPtrs = []; % create these so that we can safely test them later
ud.Store.ConstPtrs = [];
ud.FeatureData = [];
ud.TablePtr = [];



% -------------------------------------------------------
function d = i_create_menus(VMH, TMH, cbs)
% -------------------------------------------------------
% Function that will set up menus. This might be taking modularisation to extremes but right now
% it gives a way of keeping related code in the same place. Plan is that all uimenus and context 
% menus will be created here. May adjust later if it proves that certain things belong elsewhere.
% Also when this thing is up and running we need to examine whether a separate Subfunction is really required.


d.Autospace = uimenu(TMH,'Label','&Initialize...',...
    'Callback',cbs.Initialize);

d.Initialise = uimenu(TMH,'Label','&Fill...',...
    'Callback',cbs.Fill);

d.Optimise = uimenu(TMH,'Label','&Optimize...',...
    'Callback',cbs.Optimize);

d.history = uimenu(VMH,'Label','&History...',...
    'Callback',cbs.ViewHistory);
d.comparison = uimenu(VMH,'Label','&Comparison',...
    'Checked','off',...
    'Callback',cbs.ViewComparison);



% -------------------------------------------------------
function [pane , d] = i_create_toolbar(cgb, cbs)
% -------------------------------------------------------
% Make our toolbar

icons{1,1} = cgresload('autospace.bmp','bmp');
icons{2,1} = cgresload('fill.bmp','bmp');
icons{3,1} = cgresload('optimise.bmp','bmp');

d.ToolBar = cgb.createToolbar();
[~,btns]= xregtoolbar(d.ToolBar,{'uipush','uipush','uipush'},...
    {'cdata'},icons,...
    {'ClickedCallBack'},{cbs.Initialize;cbs.Fill;cbs.Optimize},...
    {'ToolTipString'},{'Initialize';'Fill';'Optimize'},...
    {'Transparentcolor'},{[255 255 0];[255 255 0];[255 255 0]});

d.Autospace = btns(1);
d.Initialise = btns(2);
d.Optimise = btns(3);
pane = d.ToolBar;

return