📄 fm_plotsel.m
字号:
function fig = fm_plotsel(varargin)% FM_PLOTSEL create GUI to select plotting variables%% HDL = FM_PLOTSEL()%%Author: Federico Milano%Date: 21-Dec-2005%Version: 1.0.0%%E-mail: fmilano@thunderbox.uwaterloo.ca%Web-site: http://thunderbox.uwaterloo.ca/~fmilano%% Copyright (C) 2002-2006 Federico Milanoglobal Fig Theme Varname Settings File% check for data fileif isempty(File.data) fm_disp('Set a data file before selecting plot variables.',2) returnend% check for initial power flow solutionif ~Settings.init fm_disp('Solve base case power flow...') Settings.show = 0; fm_set lf Settings.show = 1; if ~Settings.init, return, endendif nargin switch varargin{1} case 'selvars' values = get(gcbo,'Value'); hdl = findobj(gcf,'Tag','listbox2'); Varname.idx = values; nidx = length(Varname.idx); toplist = max(1,nidx-8); set(hdl,'String',Varname.uvars(Varname.idx), ... 'Value',nidx, ... 'ListboxTop',toplist) case 'selection' if isempty(Varname.idx) set(gcbo,'String','<Empty>','Value',1) elseif Varname.idx(end) > Varname.nvars set(gcbo,'String','<Empty>','Value',1) Varname.idx = []; else nidx = length(Varname.idx); toplist = max(1,nidx-8); set(gcbo,'String',Varname.uvars(Varname.idx), ... 'Value',nidx, ... 'ListboxTop',toplist) end case 'remove' hdl = findobj(gcf,'Tag','listbox2'); values = get(hdl,'Value'); Varname.idx(values) = []; if isempty(Varname.idx) set(hdl,'String','<Empty>') else nidx = length(Varname.idx); toplist = max(1,nidx-8); set(hdl,'String',Varname.uvars(Varname.idx), ... 'Value',min(max(values),nidx), ... 'ListboxTop',toplist) end case 'create_custom' setarea(0,1,'on','off') case 'creates_fixed' setarea(1,0,'off','on') case 'custom' setarea(0,1,'on','off') setidx case 'fixed' setarea(1,0,'off','on') setidx case 'setx' Varname.x = get(gcbo,'Value'); setidx case 'setV' Varname.V = get(gcbo,'Value'); setidx case 'setPQ' Varname.PQ = get(gcbo,'Value'); setidx case 'setPij' Varname.Pij = get(gcbo,'Value'); setidx end returnendif Fig.plotsel > 0, figure(Fig.plotsel), return, endh0 = figure(... 'Units','normalized',... 'Color',Theme.color01,... 'Colormap',[], ... 'MenuBar','none',... 'Name','Select Plot Variables',... 'NumberTitle','off',... 'Position',sizefig(0.508,0.684), ... 'FileName','fm_plotsel', ... 'HandleVisibility','callback',... 'Tag','figure1',... 'CreateFcn','Fig.plotsel = gcf;', ... 'DeleteFcn','Fig.plotsel = 0;', ... 'UserData',[],... 'Visible','on');% Menu Fileh1 = uimenu('Parent',h0, ... 'Label','File', ... 'Tag','MenuFile');h2 = uimenu('Parent',h1, ... 'Callback','close(gcf)', ... 'Label','Exit', ... 'Tag','PlotSelExit', ... 'Accelerator','x');h1 = uicontrol(... 'Parent',h0, ... 'Units','normalized',... 'Style','frame', ... 'Tag','uipanel1',... 'Clipping','on',... 'Position',[0.075 0.211 0.386 0.716]);idx = Varname.idx;if isempty(idx), idx = 1; endh1 = uicontrol(... 'Parent',h0, ... 'BackgroundColor',Theme.color03, ... 'Callback','fm_plotsel selvars', ... 'FontName',Theme.font01, ... 'Max',20, ... 'ForegroundColor',Theme.color06, ... 'Units','normalized',... 'Position',[0.111 0.24 0.314 0.616],... 'String',Varname.uvars,... 'Style','listbox',... 'Value',idx,... 'Tag','listbox1');h1 = uicontrol(... 'Parent',h0, ... 'Units','normalized',... 'Style','frame', ... 'Tag','uipanel2',... 'Clipping','on',... 'Position',[0.537 0.534 0.386 0.393]);h5 = uicontrol(... 'Parent',h0, ... 'Units','normalized',... 'BackgroundColor',Theme.color03, ... 'CreateFcn','fm_plotsel selection', ... 'Max',20, ... 'FontName',Theme.font01, ... 'ForegroundColor',Theme.color06, ... 'Position',[0.578 0.569 0.305 0.287],... 'String',{ '<Empty>' },... 'Style','listbox',... 'Value',1,... 'Tag','listbox2');set(h5,'Value',max(1,length(Varname.idx)-8))h1 = uicontrol( ... 'Parent',h0, ... 'Units', 'normalized', ... 'BackgroundColor',Theme.color02, ... 'HorizontalAlignment','left', ... 'Position',[0.117 0.874 0.285 0.039], ... 'String','Variable List', ... 'Style','text', ... 'Tag','StaticText1');h1 = uicontrol( ... 'Parent',h0, ... 'Units', 'normalized', ... 'BackgroundColor',Theme.color02, ... 'HorizontalAlignment','left', ... 'Position',[0.58 0.874 0.285 0.039], ... 'String','Custom Selection', ... 'Style','text', ... 'Tag','StaticText2');h8 = uicontrol(... 'Parent',h0, ... 'Units','normalized',... 'BackgroundColor',Theme.color03, ... 'FontWeight','bold', ... 'ForegroundColor',Theme.color09, ... 'Callback','close(gcf);', ... 'Position',[0.614 0.069 0.232 0.073],... 'String','Close',... 'Tag','Pushbutton1');h9 = uicontrol(... 'Parent',h0, ... 'Units','normalized',... 'Tag','uipanel4',... 'Clipping','on',... 'Style','frame',... 'Position',[0.537 0.211 0.386 0.287]);h1 = uicontrol( ... 'Parent',h0, ... 'Units', 'normalized', ... 'BackgroundColor',Theme.color02, ... 'HorizontalAlignment','left', ... 'Position',[0.58 0.44 0.285 0.039], ... 'String','Fixed Selection', ... 'Style','text', ... 'Tag','StaticText3');h10 = uicontrol(... 'Parent',h0, ... 'Units','normalized',... 'Callback','fm_plotsel setx', ... 'HorizontalAlignment','left', ... 'Position',[0.614 0.39 0.234 0.04],... 'String','State Variables',... 'Value',Varname.x,... 'Style','radiobutton',... 'Tag','radiobutton1');h11 = uicontrol(... 'Parent',h0, ... 'Units','normalized',... 'Callback','fm_plotsel setV', ... 'HorizontalAlignment','left', ... 'Position',[0.614 0.3415 0.234 0.04],... 'String','Bus Voltages',... 'Value',Varname.V,... 'Style','radiobutton',... 'Tag','radiobutton2');h12 = uicontrol(... 'Parent',h0, ... 'Units','normalized',... 'Callback','fm_plotsel setPQ', ... 'Position',[0.614 0.294 0.234 0.04],... 'HorizontalAlignment','left', ... 'String','Power Injections',... 'Value',Varname.PQ,... 'Style','radiobutton',... 'Tag','radiobutton3');h13 = uicontrol(... 'Parent',h0, ... 'Units','normalized',... 'Callback','fm_plotsel setPij', ... 'Position',[0.614 0.2455 0.234 0.04],... 'HorizontalAlignment','left', ... 'String','Power Flows',... 'Style','radiobutton',... 'Value',Varname.Pij,... 'Tag','radiobutton4');h6 = uicontrol(... 'Parent',h0, ... 'Units','normalized',... 'Callback','fm_plotsel fixed', ... 'CreateFcn','fm_plotsel create_fixed', ... 'Position',[0.075 0.119 0.292 0.04],... 'HorizontalAlignment','left', ... 'String','Fixed Selection',... 'Value',Varname.fixed,... 'Style','checkbox',... 'Tag','checkbox_fixed');h7 = uicontrol(... 'Parent',h0, ... 'Units','normalized',... 'Callback','fm_plotsel custom', ... 'CreateFcn','fm_plotsel create_custom', ... 'Position',[0.075 0.069 0.292 0.04],... 'HorizontalAlignment','left', ... 'String','Selection',... 'Value',Varname.custom,... 'Style','checkbox',... 'Tag','checkbox_custom');h1 = uicontrol( ... 'Parent',h0, ... 'CData',fm_mat('main_exit'), ... 'Units','normalized', ... 'BackgroundColor',Theme.color02, ... 'Callback','fm_plotsel remove', ... 'Position',[0.8341 0.863 0.05 0.05], ... 'Tag','PushRemove');if nargout > 0, fig = h0; end% ===============================================function setarea(s1,s2,s3,s4)% ===============================================global Varnamevalue = get(gcbo,'Value');hdl_fix = findobj(gcf,'Tag','checkbox_fixed');hdl_cus = findobj(gcf,'Tag','checkbox_custom');hdl_list1 = findobj(gcf,'Tag','listbox1');hdl_list2 = findobj(gcf,'Tag','listbox2');hdl_rad1 = findobj(gcf,'Tag','radiobutton1');hdl_rad2 = findobj(gcf,'Tag','radiobutton2');hdl_rad3 = findobj(gcf,'Tag','radiobutton3');hdl_rad4 = findobj(gcf,'Tag','radiobutton4');hdl_text1 = findobj(gcf,'Tag','StaticText1');hdl_text2 = findobj(gcf,'Tag','StaticText2');hdl_text3 = findobj(gcf,'Tag','StaticText3');if value set(hdl_fix,'Value',s1); set(hdl_cus,'Value',s2); set(hdl_list1,'Enable',s3) set(hdl_rad1,'Enable',s4) set(hdl_rad2,'Enable',s4) set(hdl_rad3,'Enable',s4) set(hdl_rad4,'Enable',s4) set(hdl_text1,'Enable',s3) set(hdl_text3,'Enable',s4) Varname.custom = s2; Varname.fixed = s1;else set(hdl_fix,'Value',s2); set(hdl_cus,'Value',s1); set(hdl_list1,'Enable',s4) set(hdl_rad1,'Enable',s3) set(hdl_rad2,'Enable',s3) set(hdl_rad3,'Enable',s3) set(hdl_rad4,'Enable',s3) set(hdl_text1,'Enable',s4) set(hdl_text3,'Enable',s3) Varname.custom = s1; Varname.fixed = s2;end% ===============================================function setidx% ===============================================global Varname Bus Syn DAE Oxl Exc Lineif Varname.fixed Varname.idx = []; if Varname.x Varname.idx = [1:DAE.n]'; end if Varname.V idx0 = DAE.n; Varname.idx = [Varname.idx; idx0+[1:2*Bus.n]']; end if Varname.PQ idx0 = DAE.n+2*Syn.n+Oxl.n+Exc.n+2*Bus.n; Varname.idx = [Varname.idx; idx0+[1:2*Bus.n]']; end if Varname.Pij idx0 = DAE.n+2*Syn.n+Oxl.n+Exc.n+4*Bus.n; Varname.idx = [Varname.idx; idx0+[1:4*Line.n]']; endelseif Varname.custom Varname.idx = get(findobj(gcf,'Tag','listbox1'),'Value');endhdl_list2 = findobj(gcf,'Tag','listbox2');if isempty(Varname.idx) set(hdl_list2,'String','<Empty>','Value',1)else nidx = length(Varname.idx); toplist = max(1,nidx-8); set(hdl_list2,'String',Varname.uvars(Varname.idx), ... 'Value',nidx, ... 'ListboxTop',toplist)end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -