www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/+cageview/+optimoutput/FrameWork.m
classdef FrameWork < mbcmodelview.FrameWork %FrameWork Optimization output view framework % Copyright 2005-2016 The MathWorks, Inc. and Ford Global Technologies, Inc. properties (SetAccess=private) %RetainOutputCard card for RetainOutput controls so they can be hidden RetainOutputCard %Indexer constrols Indexer %MultiViewSurface MultiViewSurface %TopFrameGrid layout for top of view TopFrameGrid %Table main output table Table end methods function show(obj,cgnode) %show initialize view in browser initialize(obj.MessageService,address(cgnode)) obj.ForceReset = true; end function view(obj) %view update optimization view if ~obj.ForceReset ms = obj.MessageService; ms.setOptimOutput(info(ms.pOptimOut), 'ObjectChanged'); obj.ForceReset=false; end end function OK = hide(obj) %hide current view OK = obj.MessageService.leaveNode; end end methods (Access=private) function obj = FrameWork %FrameWork constructor (should be called from static creation function) ms = cageview.optimoutput.MessageService; obj@mbcmodelview.FrameWork(cgbrowser,ms) end end methods (Access=protected) function create(obj,parentInfo) %create create graphical components % create(obj,parentInfo) hParent = parentInfo.ViewParent; obj.ViewParent = hParent; ms = obj.MessageService; TopPanel = mbcgui.container.layoutpanel(... 'Parent', hParent, ... 'Visible', 'off', ... 'BorderType', 'beveledin'); % output index selector panel IndexPanel = mbcgui.container.layoutpanel(... 'Parent', TopPanel, ... 'BorderType', 'beveledout'); obj.Indexer = cageview.optimoutput.IndexerView('Parent', IndexPanel, ... 'MessageService', ms); hAccept = cageview.optimoutput.AcceptView('Parent', TopPanel, ... 'MessageService', ms); % Preserved indicator items RetainPanel = mbcgui.container.layoutpanel(... 'Parent', TopPanel, ... 'BorderType', 'beveledout'); hPreservedControl = mbcgui.widget.IconText('Parent', RetainPanel, ... 'Style', 'item', ... 'String', 'Retained', ... 'TooltipString', sprintf('%s\n%s', ... 'This optimization output is being retained and will not ', ... 'be overwritten when the optimization is re-run'), ... 'ImageFile', 'cglock.bmp'); set(RetainPanel, 'LayoutComponent', {hPreservedControl}); obj.RetainOutputCard = xregcardlayout(TopPanel, ... 'numcards', 2); attach(obj.RetainOutputCard, RetainPanel, 2); IndexGrid = xreggridbaglayout(IndexPanel, ... 'dimension', [1 2], ... 'colsizes', [550 -1], ... 'gapx', 7, ... 'border', [7 4 0 4], ... 'elements', {obj.Indexer, []}); set(IndexPanel, 'LayoutComponent', {IndexGrid}); obj.TopFrameGrid = xreggridbaglayout(TopPanel, ... 'dimension', [1 2], ... 'colsizes', [-1 60], ... 'elements', {hAccept,obj.RetainOutputCard}); obj.Workflow = mbcWorkflowPanel(TopPanel); hTop = xreggridbaglayout(TopPanel,... 'dimension',[2 3],... 'rowsizes',[50 -1],... 'colsizes',[140 -1 200],... 'elements',{IndexPanel,[],obj.Workflow obj.TopFrameGrid,[],[]},... 'MergeBlock',{[1 1],[1 2]},... 'MergeBlock',{[1 2],[3 3]}); set(TopPanel, 'LayoutComponent', {hTop }); solutionTablePanel = mbcgui.container.titlebarpanel(... 'Parent', hParent,... 'Visible', 'off'); obj.Table = cageview.optimoutput.ValuesTableView('Parent', solutionTablePanel, ... 'MessageService', ms); set(solutionTablePanel,'BarTitle',obj.Table.gettitle,... 'ContentHandle', obj.Table); % Create a MultiViewPanel for the Optimization Output Values: Surface and % Contour views obj.MultiViewSurface = obj.createMultiViewSurface(obj.ViewParent,obj.MessageService); % top row contains table optimValuesSplit = xregsplitlayout(hParent, ... 'Orientation', 'lr', ... 'DividerWidth', 4, ... 'DividerStyle', 'flat', ... 'left', solutionTablePanel, ... 'right', obj.MultiViewSurface); top = xreggridbaglayout(hParent, ... 'dimension', [2 1], ... 'gap', 2, ... 'rowsizes', [100 -1], ... 'elements', {TopPanel, optimValuesSplit}); % multiview plots obj.MultiView = obj.createMultiView(obj.ViewParent,obj.MessageService); % main layout has multiview plots at the bottom obj.MainLayout = xregsplitlayout(hParent, ... 'Visible', 'on', ... 'Orientation', 'ud', ... 'DividerWidth', 4, ... 'DividerStyle', 'flat', ... 'top', top, ... 'bottom', obj.MultiView); % Listener that updates enable status of "Preserve output" menus obj.Listeners = [obj.Listeners(:);... event.listener(obj.MessageService, 'PreserveChanged',@obj.onCheckRetainState);... event.listener(obj.MessageService, 'ObjectChanged',@obj.onCheckRetainState);... ]; % create menu and toolbar controls obj.Toolbar = xregGui.uitoolbar(parentInfo.ToolbarParent,'ResourceLocation',xregrespath); createControls(obj) end function createControls(obj) %createControls create menu and toolbar controls % create menu, toolbar Labels = {'&View';'&Solution'}; if isInBrowser(obj) % create menus in Model Browser hMainMenus=createmenu(obj.Browser,guid(obj.MessageService.Node),length(Labels)); set(hMainMenus,{'Label'},Labels); % base context menu has RetainOutput obj.NodeContextMenu = obj.Browser.makeContextMenuBase; hm = createMenuItem(obj.Actions.RetainOutput,obj.NodeContextMenu); hm.Separator = 'on'; else % create main menus in figure hMainMenus = gobjects(size(Labels)); for i=1:length(Labels) hMainMenus(i) = uimenu('Parent',obj.Figure,... 'Label',Labels{i}); end end % create view and solution menus createViewMenu(obj.Actions,hMainMenus(1),obj.MultiView) createSolutionMenu(obj.Actions,hMainMenus(2)) createToolbar(obj.Actions,obj.Toolbar,obj.MultiView) createWorkflowItems(obj.Actions,obj.Workflow); end function onCheckRetainState(obj,~,~) %onCheckRetainState display the retain output icons if the output is retained ms = obj.MessageService; pNode = ms.Pointer; if pNode.isPreserved % Can't "preserve" an already preserved node PresIndSize = 60; PresCard = 2; else PresIndSize = 0; PresCard = 1; end % needs to be in framework or Indexer set(obj.RetainOutputCard, 'CurrentCard', PresCard); CS = get(obj.TopFrameGrid, 'colsizes'); CS(end) = PresIndSize; set(obj.TopFrameGrid, 'colsizes', CS); end end methods (Static) function obj = createFigure(pNode) %createFigure make view in a separate figure for testing obj = cageview.optimoutput.FrameWork(); initialize(obj.MessageService, pNode); figure(obj); set(obj.Figure.LayoutManager,'Visible','on'); end function [lyt, tblyt, obj]=creategui(mdev,parentInfo) %create view for inside the model browser obj = cageview.optimoutput.FrameWork(); initialize(obj.MessageService, address(mdev)); create(obj,parentInfo); lyt = obj.MainLayout; tblyt = obj.Toolbar; end function mv = createMultiView(hParent,ms,LayoutName) %createMultiView create multiview panel % MultiView = createMultiView(ViewParent,MessageService,LayoutName) % % The multiview can be created independently of the rest of the % FrameWork/Model Browser for testing if nargin<3 %The default layout name is stored in preferences to give a %surface viewer and scatter plot by default LayoutName = 'OptimOutput'; end % Create a MultiViewPanel that is setup for the remaining available views vl = mbcgui.multiview.ViewList(... { ... @cageview.optimoutput.ObjGraphView, ... @cageview.optimoutput.ObjContourView, ... @cageview.optimoutput.ParetoView, ... @cageview.optimoutput.ConGraphView, ... @cageview.optimoutput.ConSummaryView, ... @cageview.optimoutput.FreeValuesView, ... @cageview.optimoutput.StatsView, ... }, ... { ... '&Objective Graphs', ... 'Objective &Contour Plot', ... '&Pareto Graphs', ... '&Constraint Graphs', ... 'Constraint &Summary', ... '&Free Variables', ... 'Solution &Information', ... }, ... { ... cgrespath('optimview_solution.bmp'), ... cgrespath('optimview_contour.bmp'), ... cgrespath('optimview_pareto.bmp'), ... cgrespath('optimview_congraph.bmp'), ... cgrespath('optimview_consummary.bmp'), ... cgrespath('optimview_freevar.bmp'), ... cgrespath('optimview_solinfo.bmp'), ... }, ... { ... 'Objective slice graphs', ... 'Objective contour plot', ... 'Pareto front graphs', ... 'Constraint slice graphs', ... 'Constraint summary table', ... 'Free variable values table', ... 'Solution information table', ... }, ... [1 1 1 1 1 1 1]); mv = mbcgui.multiview.MultiViewPanel('Parent', hParent, ... 'Visible', 'off', ... 'MessageService', ms, ... 'ViewLayoutName', LayoutName, ... 'ViewList', vl); end function mv = createMultiViewSurface(hParent,ms,LayoutName) %createMultiViewSurface create multiview panel % MultiView = createMultiViewSurface(ViewParent,MessageService,LayoutName) % % The multiview can be created independently of the rest of the % FrameWork/Model Browser for testing if nargin<3 %The default layout name is stored in preferences to give a %surface viewer and scatter plot by default LayoutName = 'OptimOutputValues2d'; end % Create a MultiViewPanel for the Optimization Output Values: Surface and % Contour views vl = mbcgui.multiview.ViewList(... { ... @cageview.optimoutput.ValuesContourView, ... @cageview.optimoutput.ValuesSurfaceView, ... }, ... { ... 'Results &Contour', ... 'Results &Surface', ... }, ... { ... cgrespath('optimview_solution.bmp'), ... cgrespath('optimview_solution.bmp'), ... }, ... { ... 'Results contour', ... 'Results surface', ... }, ... [1 1]); mv = mbcgui.multiview.MultiViewPanel('Parent', hParent, ... 'Visible', 'off', ... 'MessageService', ms, ... 'ViewLayoutName', LayoutName, ... 'ViewList', vl); end end end