www.gusucode.com > mbctools 工具箱 matlab 源码程序 > mbctools/+mbcmodelview/+global/InfoPane.m
classdef InfoPane < mbcgui.multiview.View %mbcmodelview.InfoPane statistics and other information % Copyright 2015-2015 The MathWorks, Inc. and Ford Global Technologies, Inc. properties (SetAccess=private) %SummaryStats summary stats component (xregtools.SummaryStatsTable) SummaryStats %OutlierList listbox for outliers OutlierList %Comments edit box for model comments Comments end methods function obj= InfoPane(varargin) %InfoPane constructor obj@mbcgui.multiview.View(varargin{:}) ViewParent = obj.Parent; create(obj,ViewParent) addMessageServiceListener(obj, 'NodeUpdated',@obj.onNodeUpdated) end function update(obj) %update main update method % update the SummaryStats Table with this modeldev (it figures out what % stats to show) mdev = obj.MessageService.ModelDev; updateTable( obj.SummaryStats, mdev ); % model comments set(obj.Comments,'String',comments(obj.MessageService.Model)); % update outlier list displayed list=OutlierList(mdev); %#ok<CPROP> X= testnum(getdata(mdev)); X= X(outliers(mdev)); Lstr= cell(size(list)); if ~isempty(list) for i=1:length(list) if ~any(list(i)==X) Lstr{i} = sprintf('%d*',list(i)); else Lstr{i} = sprintf('%d',list(i)); end end end set(obj.OutlierList,'String',Lstr,'Value',min(length(list),1)) if modelstage(mdev)==1 set(obj.OutlierList,'TooltipString','','Callback',[]); else set(obj.OutlierList,'TooltipString','double-click to see test data',... 'Callback',@obj.onPlotSweep); end end end methods function create(obj,ViewParent) %create create graphical components Fstats= mbcgui.container.layoutpanel(... 'Parent', ViewParent,... 'Title','Summary table',... 'BorderType', 'etchedin'); obj.SummaryStats = xregtools.SummaryStatsTable( 'Parent', Fstats ); lyt = xreglayerlayout(Fstats, 'border', [5 5 5 5], 'elements', {obj.SummaryStats}); set(Fstats, 'LayoutComponent', {lyt}); %====== The list of outliers ====== F{1}= mbcgui.container.layoutpanel(... 'Parent', ViewParent,... 'Title','Removed data',... 'BorderType', 'etchedin', ... 'LayoutBorder',[3 3 3 2]); obj.OutlierList=uicontrol('Parent',F{1},... 'Style','listbox',... 'BackgroundColor','w',... 'TooltipString','double-click to see test data',... 'String',''); txt=uicontrol('Parent',F{1},... 'Style','text',... 'HorizontalAlignment','left',... 'String','* Data not restorable'); tolyt= xreggridbaglayout(F{1},... 'dimension',[2,1],... 'rowsizes',[-1 15],... 'elements',{obj.OutlierList,txt}); set(F{1}, 'LayoutComponent', {tolyt}); F{2}= mbcgui.container.layoutpanel(... 'Parent', ViewParent,... 'title','Model comments',... 'BorderType', 'etchedin', ... 'LayoutBorder',[3 3 3 2]); %====== The edit box for Model Comments ====== obj.Comments= uicontrol('Parent',F{2},... 'Style','edit',... 'HorizontalAlignment','left',... 'Min',0,'Max',2,... 'Callback',@obj.onCommentsChanged,... 'BackgroundColor','w'); set(F{2}, 'LayoutComponent', obj.Comments); % put these together editGrid = xreggridbaglayout(ViewParent,... 'dimension',[2,1],... 'rowsizes',[-1,60],... 'elements',F); %===== RIGHT of split: stats + notes + outliers ====== lyt = xreggridbaglayout(ViewParent,... 'dimension',[3,1],... 'rowsizes',[210,30, -1],... 'gapy',5,... 'elements',{Fstats,[], editGrid}); attachContentHandle(obj,lyt); end function onNodeUpdated(obj,~,~) %onNodeUpdated message service updated update(obj) end function onCommentsChanged(obj,h,~) % update comments in model ms = obj.MessageService; m = comments(ms.Model,get(h,'String')); model(ms.ModelDev,m); % no need to broadcast this change as this is the only place where % comments are displayed end function onPlotSweep(obj,hCtrl,~) %onPlotSweep plot sweep for outlier line ms = obj.MessageService; if isRespFeat(ms.ModelDev) % only available for response features seltype=get(ancestor(hCtrl,'figure'),'SelectionType'); % double click on point switch seltype case 'open' y= double(ms.YData); y(~ms.DataOK)= NaN; str = get(hCtrl,'String'); ind = get(hCtrl,'Value'); if isempty(str) || ind==0 return end str= strrep(str{ind},'*',''); TN = str2double(str); SelectedIndex = find(testnum(ms.XData)==TN); % observed y data yobs= y(SelectedIndex); % predicted y x=double(ms.XData); xp= x(SelectedIndex,:); plotSweep(ms,xp,yobs,SelectedIndex); end end end end end