📄 fm_dirset.m
字号:
function fm_dirset(type)% FM_DIRSET define settings and actions for the data format% conversion GUI%% FM_DIRSET(TYPE)% TYPE action indentifier%%see also FM_DIR%%Author: Federico Milano%Date: 11-Nov-2002%Update: 05-Jul-2003%Update: 31-Jul-2003%Update: 07-Oct-2003%Version: 1.1.0%%E-mail: fmilano@thunderbox.uwaterloo.ca%Web-site: http://thunderbox.uwaterloo.ca/~fmilano%% Copyright (C) 2002-2005 Federico Milano%% This toolbox is free software; you can redistribute it and/or modify% it under the terms of the GNU General Public License as published by% the Free Software Foundation; either version 2.0 of the License, or% (at your option) any later version.%% This toolbox is distributed in the hope that it will be useful, but% WITHOUT ANY WARRANTY; without even the implied warranty of% MERCHANDABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU% General Public License for more details.%% You should have received a copy of the GNU General Public License% along with this toolbox; if not, write to the Free Software% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,% USA.global Path Fig Settings Themehdl = findobj(Fig.dir,'Tag','PopupMenu1');formato = get(hdl,'Value');hdl_dir = findobj(Fig.dir,'Tag','EditText1');folder1 = get(hdl_dir,'String');if ischar(folder1), eval(['cd(''',folder1,''')'],' '); endswitch type %================================================================== case 'chndir' hdl = findobj(Fig.dir,'Tag','Listbox1'); cdir = get(hdl,'String'); ndir = get(hdl,'Value'); namedir = cdir{ndir(1),1}; if strcmp(namedir,'..') eval('cd ..'); elseif ~strcmp(namedir,'.') if ~isempty(dir(namedir)) cd(namedir); end end a = dir; cdir = []; numdir = find([a.isdir] == 1); for i = 1:length(numdir) cdir{i,1} = a(numdir(i)).name; end if isempty(cdir), cdir = {' '}; else, cdir = sort(cdir); end set(hdl,'String',[cdir;get(hdl,'UserData')],'Value',1); hdl = findobj(Fig.dir,'Tag','EditText1'); set(hdl,'String',pwd); set(Fig.dir,'UserData',pwd); hdl = findobj(Fig.dir,'Tag','Listbox2'); cfile = uform(formato); if isempty(cfile), cfile = 'empty'; else, cfile = sort(cfile); end set(hdl,'String',cfile,'Value',1); %================================================================== case 'chformat' hdlf = findobj(Fig.dir,'Tag','PopupMenu1'); formato = get(hdlf,'Value'); hdl = findobj(Fig.dir,'Tag','Listbox2'); hdlc = findobj(Fig.dir,'Tag','Pushbutton1'); hdl1 = findobj(Fig.dir,'Tag','Checkbox1'); hdl2 = findobj(Fig.dir,'Tag','Checkbox2'); hdl3 = findobj(Fig.dir,'Tag','Checkbox3'); hdl4 = findobj(Fig.dir,'Tag','StaticText2'); cfile = uform(formato); switch formato case 1, file = 'ieee'; case 2, file = 'cyme'; case 3, file = 'pserc'; case 4, file = 'psat'; case 5, file = 'cherry'; case 6, file = 'wecc'; case 7, file = 'pti'; case 8, file = 'pjm'; case 9, file = 'eurostag'; case 10, file = 'bpa'; case 11, file = 'th'; case 12, file = 'enel'; case 13, file = 'cepe'; case 14, file = 'simpow'; case 15, file = 'neplan'; case 16, file = 'digsilent'; case 17, file = 'powerworld'; case 18, file = 'pet'; case 19, file = 'eeh'; case 20, file = 'ge'; case 21, file = 'vitruvio'; end if formato == 21, % all files set(hdlc,'Enable','off') set(hdl1,'Enable','off') set(hdl2,'Enable','off') set(hdl3,'Enable','off') set(hdl4,'Enable','off') elseif formato == 4 % PSAT format set(hdlc,'Enable','on') set(hdl1,'Enable','off','Value',0) set(hdl2,'Enable','on') set(hdl3,'Enable','off') set(hdl4,'Enable','on') else % all other formats set(hdlc,'Enable','on') set(hdl1,'Enable','inactive','Value',1) set(hdl2,'Enable','off') set(hdl3,'Enable','on') set(hdl4,'Enable','off') end a = imread([Path.images,'logo_',file,'.jpg'],'jpg'); [yl,xl,zl] = size(a); set(Fig.dir,'Units','pixels') figdim = get(Fig.dir,'Position'); set(Fig.dir,'Units','normalized') dimx = figdim(3)*0.2616; dimy = figdim(4)*0.3468; rl = xl/yl; if dimx > xl & dimy > yl xd = xl/figdim(3); yd = yl/figdim(4); set(gca,'Position',[0.8358-xd/2, 0.5722-yd/2, xd, yd]); elseif xl > yl, xd = 0.2616; yd = 0.3468/rl; set(gca,'Position',[0.7050, 0.5722-0.1734/rl, xd, yd]); else, xd = 0.2616*rl; yd = 0.3468; set(gca,'Position',[0.8358-0.1308*rl, 0.3988, xd, yd]); end xd = round(xd*figdim(3)); yd = round(yd*figdim(4)); %disp([xl yl xd yd]) if xd ~= xl & yd ~= yl try a = imresize(a,[yd xd],'bilinear',11); catch % imresize is not available!!! end end set(gca,'XLim',[0.5 xd+0.5],'YLim',[0.5 yd+0.5]); set(get(gca,'Children'),'CData',a,'XData',[1 xd],'YData',[1 yd]); set(gca,'XTick',[],'XTickLabel','','XColor',Theme.color01); set(gca,'YTick',[],'YTickLabel','','YColor',Theme.color01); if isempty(cfile), cfile = 'empty'; else, cfile = sort(cfile); end set(hdl,'String',cfile,'Value',1); %================================================================== case 'dirinit' devices = getdevices; set(gcbo,'UserData',devices) a = dir; for i = 1:length(a) is_dir(i,1) = a(i).isdir; end numdir = find(is_dir == 1); for i = 1:length(numdir) cdir{i,1} = a(numdir(i)).name; end if isempty(cdir) cdir = {' '}; else cdir = sort(cdir); end set(findobj(Fig.dir,'Tag','Listbox1'),'String',[cdir; devices]); %================================================================== case 'dirsel' values = get(gcbo,'Value'); set(gcbo,'Value',values(end)); if strcmp(get(Fig.dir,'SelectionType'),'open') fm_dirset chndir end %================================================================== case 'diredit' hdl = findobj(Fig.dir,'Tag','EditText1'); cartella = get(hdl,'String'); try cd(cartella); hdl = findobj(Fig.dir,'Tag','Listbox1'); a = dir; cdir = []; is_dir = []; for i = 1:length(a), is_dir(i,1) = a(i).isdir; end numdir = find(is_dir == 1); for i = 1:length(numdir), cdir{i,1} = a(numdir(i)).name; end if isempty(cdir), cdir = ' '; else, cdir = sort(cdir); end set(hdl,'String',cdir,'Value',1); hdl = findobj(Fig.dir,'Tag','Listbox2'); cfile = uform(formato); if isempty(cfile), cfile = 'empty'; else, cfile = sort(cfile); end set(hdl,'String',cfile,'Value',1); set(Fig.dir,'UserData',cartella); catch fm_disp(lasterr,2) set(hdl_dir,'String',get(Fig.dir,'UserData')); end %================================================================== case 'getfolder' pathname = get(Fig.dir,'UserData'); cartella = uigetdir(pathname); if cartella hdl = findobj(Fig.dir,'Tag','EditText1'); set(hdl,'String',cartella); fm_dirset diredit end %================================================================== case 'convert' hdl = findobj(Fig.dir,'Tag','Listbox2'); numfile = get(hdl,'Value'); nomefile = get(hdl,'String'); if ~iscell(nomefile), nomefile = cellstr(nomefile); end hdl = findobj(Fig.dir,'Tag','Checkbox3'); pres_fm = get(hdl, 'Value'); hdl = findobj(Fig.dir,'Tag','PopupMenu1'); if numfile == 1 & strcmp(nomefile{1},'empty') fm_disp('Current folder does not contain files in the selected Data Format.',2) cd(Path.local) return end for i = 1:length(numfile) lasterr(''); filename = nomefile{numfile(i),1}; check = 0; switch get(hdl,'Value') case 1, % IEEE CDF check = fm_perl('IEEE CDF','ieee2psat',filename,pres_fm); case 2, % CYME Format check = fm_cymflow(filename,pwd,pres_fm); case 3, % Matpower Format check = fm_matpower(filename,pwd,pres_fm); case 4, % PSAT Format hdl = findobj(Fig.dir,'Tag','Checkbox2'); switch get(hdl,'Value') case 1, check = fm_m2cdf(filename,pwd); case 2, check = fm_m2wscc(filename,pwd); end case 5, % PST Format check = fm_pst(filename,pwd,pres_fm); case 6, % BPA/WSCC Format check = fm_wscc(filename,pwd,pres_fm); case 7, % PSS/E format check = fm_perl('PSS/E','psse2psat',filename,0); case 8, % PSAP format check = fm_perl('PSAP','psap2psat',filename,0); case 9, % EUROSTAG format fm_choice(['Filter for EUROSTAG data format has not been implemeted ' ... 'yet.'],2) break case 10, % BPA/China format check = fm_wscc(filename,pwd,pres_fm); case 11, % TH format check = fm_perl('TH','th2psat',filename,0); case 12, % INPTC1 format fm_choice(['Filter for INPTC1 data format has not been implemeted ' ... 'yet.'],2) break case 13, % VST Format check = fm_vst(filename,pwd,pres_fm); case 14, % SIMPOW format fm_choice(['Filter for SIMPOW data format has not been implemeted ' ... 'yet.'],2) break case 15, % NEPLAN format check = fm_perl('NEPLAN','neplan2psat',filename,0); case 16, % DigSilent format fm_choice(['Filter for DigSilent data format has not been implemeted ' ... 'yet.'],2) break case 17, % PowerWorld format fm_choice(['Filter for PowerWorld data format has not been implemeted ' ... 'yet.'],2) break case 18, % PET format
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -