www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/+cageview/+optim/FrameWork.m

    classdef FrameWork < mbcmodelview.FrameWork
    %FrameWork Optimization view framework
    
    %  Copyright 2005-2016 The MathWorks, Inc. and Ford Global Technologies, Inc.

    properties (SetAccess=private)
       ObjectiveList 
       ConstraintList
       InputValueTable
    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
            obj.MessageService.sendEvent('all');
            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.optim.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;
        
        obj.Workflow = mbcWorkflowPanel(hParent);
        
        % Optimization Information pane
        optimInfoPanel = mbcgui.container.titlebarpanel(...
            'Parent', hParent, ...
            'BarTitle','Optimization Information');
        ms = obj.MessageService;
        obj.InfoPane = cageview.optim.SetupInfoView('Parent', optimInfoPanel, ...
            'MessageService', ms);
        set(optimInfoPanel,'ContentHandle',obj.InfoPane);
        
        topRight = xreggridbaglayout(hParent,...
            'dimension',[2 1],...
            'rowsizes',[160 -1],...
            'elements',{obj.Workflow,optimInfoPanel});
        % Objective List Panel
        objectiveListPanel = mbcgui.container.titlebarpanel(...
            'Parent', hParent, ...
            'BarTitle','Objectives');
        obj.ObjectiveList = cageview.optim.ObjectiveListView('Parent', objectiveListPanel, ...
            'MessageService', ms);
        set(objectiveListPanel,'ContentHandle',obj.ObjectiveList);
        
        % Constraint List Panel
        constraintListPanel = mbcgui.container.titlebarpanel(...
            'Parent', hParent, ...
            'BarTitle','Constraints');
        obj.ConstraintList = cageview.optim.ConstraintListView('Parent', constraintListPanel, ...
            'MessageService', ms);
        set(constraintListPanel,'ContentHandle',obj.ConstraintList);

        objectivesAndConstraintsSplit = xregsplitlayout(hParent, ...
            'orientation', 'ud', ...
            'dividerwidth', 4, ...
            'dividerstyle', 'flat', ...
            'top', objectiveListPanel, ...
            'bottom', constraintListPanel);
        
        

        
        % Optimization Point Sets Panel
        optimizationPointSetsPanel = mbcgui.container.titlebarpanel(...
            'Parent', hParent, ...
            'BorderType', 'none', ...
            'BarTitle','Optimization Point Set');
        obj.InputValueTable = cageview.optim.InputValuesTableView('Parent', optimizationPointSetsPanel, ...
            'MessageService', ms);
        set(optimizationPointSetsPanel,'ContentHandle',obj.InputValueTable);
        
        % splitter for objectivesAndConstraints and optimInfoPanel
        topSplit = xregsnapsplitlayout(hParent, ...
            'Style', 'toright', ...
            'BarStyle', 1, ...
            'MinWidthUnits', 'pixels', ...
            'Split', [.98 .02], ...
            'MinWidth', [200 250], ...
            'left', objectivesAndConstraintsSplit, ...
            'right', topRight);
        
        % splitter better top and optimizationPointSetsPanel
        LYT = xregsplitlayout(hParent, ...
            'dividerwidth', 4, ...
            'dividerstyle', 'flat', ...
            'orientation', 'ud', ...
            'split', [.5 .5], ...
            'top', topSplit, ...
            'bottom', optimizationPointSetsPanel);
        
        obj.MainLayout = LYT;
        
        % 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 = {'&Optimization'};
        if isInBrowser(obj)
            % create menus in Model Browser
            hMainMenus=createmenu(obj.Browser,guid(obj.MessageService.Node),length(Labels));
            set(hMainMenus,{'Label'},Labels);
            
        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     
        % actions method create menus and toolbar
        createMenu(obj.Actions,hMainMenus)
        
        createToolbar(obj.Actions,obj.Toolbar)
        
        createWorkflowItems(obj.Actions,obj.Workflow)

        end
    end
    
    methods (Static)
        function obj = createFigure(pNode)
        %createFigure make view in a separate figure for testing
        obj = cageview.optim.FrameWork();
        initialize(obj.MessageService, pNode);
        
        figure(obj);
        
        end
        
        function [lyt, tblyt, obj]=creategui(cgnode,parentInfo)
        %create view for inside the model browser
        
        obj = cageview.optim.FrameWork();
        initialize(obj.MessageService, address(cgnode));
        
        create(obj,parentInfo);
        lyt = obj.MainLayout;
        tblyt = obj.Toolbar;
        
        end
        
    end
    
end