⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fm_plotsel.m

📁 电力系统分析计算程序
💻 M
📖 第 1 页 / 共 2 页
字号:
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:    Federico.Milano@uclm.es%Web-site:  http://www.uclm.es/area/gsee/Web/Federico%% Copyright (C) 2002-2008 Federico Milanoglobal Fig Theme Varname Settings File Path% 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 'area'    values = get(gcbo,'Value')-1;    if ~values(1)      values = 0;      set(gcbo,'Value',1)    end    Varname.areas = values;    setidx   case 'region'    values = get(gcbo,'Value')-1;    if ~values(1)      values = 0;      set(gcbo,'Value',1)    end    Varname.regions = values;    setidx   case 'selvars'    values = get(gcbo,'Value');    hdl = findobj(gcf,'Tag','listbox2');    Varname.idx = values;    setidx   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      set(gcbo,'String',Varname.uvars(Varname.idx),'Value',1)    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 'sety'    Varname.y = get(gcbo,'Value');    setidx   case 'setP'    Varname.P = get(gcbo,'Value');    setidx   case 'setQ'    Varname.Q = get(gcbo,'Value');    setidx   case 'setPij'    Varname.Pij = get(gcbo,'Value');    setidx   case 'setQij'    Varname.Qij = get(gcbo,'Value');    setidx   case 'setIij'    Varname.Iij = get(gcbo,'Value');    setidx   case 'setSij'    Varname.Sij = get(gcbo,'Value');    setidx   case 'appendidx'    if isempty(File.data),      fm_disp('No data file loaded.',2),      return,    end    filedata = strrep(File.data,'@ ','');    if Settings.init == 0,      fm_disp('Run power flow before saving plot variable indexes.',2),      return,    end    if isempty(strfind(filedata,'(mdl)'))      fid = fopen([Path.data,filedata,'.m'],'r+');      count = fseek(fid,0,1);      count = fprintf(fid, '\n\nVarname.idx = [...\n');      nidx = length(Varname.idx);      count = fprintf(fid,'%5d; %5d; %5d; %5d; %5d; %5d; %5d;\n',Varname.idx);      if rem(nidx,7) ~= 0,        count = fprintf(fid,'\n');      end      count = fprintf(fid,'   ];\n');      count = fprintf(fid, '\nVarname.areas = [...\n');      nidx = length(Varname.areas);      count = fprintf(fid,'%5d; %5d; %5d; %5d; %5d; %5d; %5d;\n',Varname.areas);      if rem(nidx,7) ~= 0,        count = fprintf(fid,'\n');      end      count = fprintf(fid,'   ];\n');      count = fprintf(fid, '\nVarname.regions = [...\n');      nidx = length(Varname.regions);      count = fprintf(fid,'%5d; %5d; %5d; %5d; %5d; %5d; %5d;\n',Varname.regions);      if rem(nidx,7) ~= 0,        count = fprintf(fid,'\n');      end      count = fprintf(fid,'   ];\n');      fclose(fid);      fm_disp(['Plot variable indexes appended to file "',Path.data,File.data,'"'])    else      % load Simulink Library and add Varname block      load_system('fm_lib');      cd(Path.data);      filedata = filedata(1:end-5);      open_sys = find_system('type','block_diagram');      if ~sum(strcmp(open_sys,filedata))        open_system(filedata);      end      cur_sys = get_param(filedata,'Handle');      blocks = find_system(cur_sys,'MaskType','Varname');      if ~isempty(blocks)        if iscell(blocks)          varblock = blocks{1};          % remove duplicate 'Varname' blocks          for i = 2:length(blocks)            delete_block(blocks{i});          end        else          varblock = blocks;        end        vec = Varname.idx;        if size(vec,1) > 1, vec = vec'; end         set_param( ...            varblock, 'pxq', ...            ['[',regexprep(num2str(vec),'\s*','  '),']'])      else        vec = Varname.idx;        if size(vec,1) > 1, vec = vec'; end         add_block( ...            'fm_lib/Connections/Varname',[filedata,'/Varname'], 'pxq', ...            ['[',regexprep(num2str(vec),'\s*','  '),']'], ...            'Position',[20,20,105,57])      end      cd(Path.local);    end  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.75,0.69), ...    '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 = uipanel(...    'Parent',h0, ...    'Title','Variables', ...    'BackgroundColor',Theme.color02, ...    'Units','normalized',...    'Tag','uipanel1',...    'Clipping','on',...    'Position',[0.0611 0.2717 0.2506 0.6359]);idx = Varname.idx;if isempty(idx), idx = 1; endh1 = uicontrol(...    'Parent',h1, ...    'BackgroundColor',Theme.color03, ...    'Callback','fm_plotsel selvars', ...    'FontName',Theme.font01, ...    'Max',20, ...    'ForegroundColor',Theme.color06, ...    'Units','normalized',...    'Position',[0.1015 0.0597 0.8071 0.8985],...    'String',Varname.uvars,...    'Style','listbox',...    'Value',idx,...    'Tag','listbox1');h1 = uipanel(...    'Parent',h0, ...    'Title','Selection', ...    'BackgroundColor',Theme.color02, ...    'Units','normalized',...    'Tag','uipanel2',...    'Clipping','on',...    'Position',[0.6833 0.2717 0.2506 0.6359]);h5 = uicontrol(...    'Parent',h1, ...    'Units','normalized',...    'BackgroundColor',Theme.color03, ...    'CreateFcn','fm_plotsel selection', ...    'Max',20, ...    'FontName',Theme.font01, ...    'ForegroundColor',Theme.color06, ...    'Position',[0.1015 0.0597 0.8071 0.9015],...    'String',{  '<Empty>' },...    'Style','listbox',...    'Value',1,...    'Tag','listbox2');set(h5,'Value',max(1,length(Varname.idx)-8))h4 = uipanel(...    'Parent',h0,...    'Title','Region',...    'BackgroundColor',Theme.color02, ...    'Tag','uipanel2',...    'Clipping','on',...    'Position',[0.3728 0.6341 0.2506 0.2736]);h5 = uicontrol(...    'Parent',h4,...    'BackgroundColor',Theme.color03, ...    'ForegroundColor',Theme.color06, ...    'CreateFcn','set(gcbo,''String'',[{''<all>''};Regions.names])', ...    'Callback','fm_plotsel region', ...    'Max',20, ...    'FontName',Theme.font01, ...    'Units','normalized',...    'Position',[0.1015 0.1333 0.8020 0.7630],...    'String',{ '<empty>' },...    'Style','listbox',...    'Value',1,...    'Tag','listbox3');if ~Varname.regions(1)  Varname.regions = 0;  set(h5,'Value',1)else  set(h5,'Value',Varname.regions+1);endh6 = uipanel(...    'Parent',h0,...    'Title','Area',...    'BackgroundColor',Theme.color02, ...    'Tag','uipanel3',...    'Clipping','on',...    'Position',[0.3716 0.2736 0.2506 0.2736]);h7 = uicontrol(...    'Parent',h6,...    'BackgroundColor',Theme.color03, ...    'ForegroundColor',Theme.color06, ...    'CreateFcn','set(gcbo,''String'',[{''<all>''};Areas.names])', ...    'Callback','fm_plotsel area', ...    'Max',20, ...    'FontName',Theme.font01, ...    'Units','normalized',...

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -