📄 pplane7.m
字号:
'kk = str2num(get(me,''string''));',...
'if isempty(kk),',...
' set(me,''string'',''?'');',...
' kk = NaN;',...
'else,',...
' kk = floor(kk);',...
' [m,N] = computer;'...
' if (N <= 8192),',...
' N = 32;',...
' else,',...
' N = 50;',...
' end,'...
' kk = min([N,max([5,kk])]);'...
' set(me,''string'',num2str(kk));'...
'end,'...
'ud.c.npts = kk;',...
'set(ppset,''user'',ud);'];
npos = [textleft+(textw -30*rr)/2,winbot5 30*rr,texth];
ud.h.npts = uicontrol('style','edit',...
'pos',npos,...
'string',ud.o.npts,...
'call',callnfpts,...
'backgroundcolor','w',...
'visible','off');
delgall = ['sud = get(gcf,''user'');',...
'mh = get(sud.h.gallery,''children'');',...
'add = findobj(sud.h.gallery,''tag'',''add system'');',...
'mh(find(mh == add)) = [];',...
'delete(mh);',...
'set(sud.h.gallery,''user'',[]);',...
'set(findobj(''tag'',''load default''),''enable'',''on'')'];
% Menus
hhsetup = get(0,'showhiddenhandles');
set(0,'showhiddenhandles','on');
mefile = findobj(ppset,'label','&File');
meedit = findobj(ppset,'label','&Edit');
delete(findobj(ppset,'label','&Tools'));
delete(findobj(ppset,'label','&View'));
delete(findobj(ppset,'label','&Insert'));
% File menu
meexp = findobj(mefile,'label','&Export...');
meprev = findobj(mefile,'label','Print Pre&view...');
mepset = findobj(mefile,'label','Pa&ge Setup...');
set(get(mefile,'child'),'vis','off');
meload = uimenu(mefile,'label','Load a system ...',...
'call','pplane7(''loadsyst'',''system'');',...
'pos',1);
mesave = uimenu(mefile,'label','Save the current system ...',...
'call','pplane7(''savesyst'',''system'');',...
'pos',2);
meloadg = uimenu(mefile,'label','Load a gallery ...',...
'call','pplane7(''loadsyst'',''gallery'');',...
'separator','on','pos',3);
mesaveg = uimenu(mefile,'label','Save a gallery ...',...
'call','pplane7(''savesyst'',''gallery'');',...
'tag','savegal','pos',4);
medelg = uimenu(mefile,'label','Delete the current gallery',...
'call',delgall,'pos',5);
melddg = uimenu(mefile,'label','Load the default gallery',...
'call','pplane7(''loadsyst'',''default'');',...
'enable','on',...
'tag','load default','pos',6);
merevert = uimenu(mefile,'label','Revert','call',...
'pplane7(''revert'')',...
'separator','on','pos',7);
meproceed = uimenu(mefile,...
'label','Proceed',...
'call','pplane7(''proceed'')',...
'separator','off',...
'accelerator','G','pos',8);
set(mepset,'vis','on','pos',9);
set(meprev,'vis','on','pos',10);
set(meexp,'vis','on','pos',11,'separator','off');
merestart = uimenu(mefile,'label',...
'Restart pplane7',...
'call','pplane7(''restart'')',...
'separator','on','pos',12);
mequit = uimenu(mefile,...
'label','Quit pplane7',...
'call','pplane7(''quit'')',...
'separator','off','pos',13);
% Edit menu
set(get(meedit,'child'),'vis','off');
meclrf = uimenu(meedit,'label','Clear equations',...
'call',['ud = get(gcf,''user'');h = ud.h;',...
'set([h.xvar,h.xder,h.yvar,h.yder],''string'','''');'],...
'accelerator','E');
pclear = [
'ud = get(gcf,''user'');h = ud.h;',...
'set([h.pname,h.pval],''string'','''');',...
'ud.c.pname = {'''','''','''','''','''','''',''''};',...
'ud.c.pval = {'''','''','''','''','''','''',''''};',...
'set(gcf,''user'',ud);',...
];
meclrp = uimenu(meedit,'label','Clear parameters',...
'call',pclear,...
'accelerator','N');
meclrwind = uimenu(meedit,'label','Clear display window',...
'call',['ud = get(gcf,''user'');',...
'set(ud.h.wind,''string'','''');'],...
'accelerator','D');
allclear = [
'ud = get(gcf,''user'');h = ud.h;',...
'set([h.xvar,h.xder,h.yvar,h.yder],''string'','''');',...
'set([h.pname,h.pval,h.wind],''string'','''');',...
'ud.c.pname = {'''','''','''','''','''','''',''''};',...
'ud.c.pval = {'''','''','''','''','''','''',''''};',...
'set(gcf,''user'',ud);',...
];
meclrall = uimenu(meedit,'label','Clear all',...
'call',allclear,...
'accelerator','A',...
'separator','on');
% Gallery menu.
sysmenu = uimenu('label','Gallery','visible','off','pos',3);
meadd = uimenu(sysmenu,'label','Add current system to the gallery',...
'call','pplane7(''addgall'');','tag','add system');
sep = 'on';
for kk = 1:length(system)
kkk = num2str(kk);
if kk == 2, sep = 'off';end
sysmen(kk) = uimenu(sysmenu,'label',system(kk).name,...
'call',['pplane7(''system'',',kkk,')'],...
'separator',sep,'visible','off');
end
set(sysmenu,'user',system);
ud.h.gallery = sysmenu;
ud.flag = 0;
ud.egg = (exist('EASTEREGG') ==2);
% Record the handles in the User Data of the Set Up figure.
set(ppset,'user',ud);
hhhh = findobj(ppset,'type','uicontrol');
set(hhhh,'units','normal')
set(ppset,'visible','on','resize','on');
set(get(ppset,'children'),'visible','on');
set(get(sysmenu,'children'),'visible','on');
%end
set(0,'showhiddenhandles',hhsetup);
elseif strcmp(action,'savesyst')
ppset = findobj('name','pplane7 Setup');
type = input1;
sud = get(ppset,'user');
switch type
case 'system'
systems = get(sud.h.gallery,'user');
newsyst = sud.c;
fn = newsyst.name;
if ~isempty(fn)
fn(find(abs(fn)==32))='_'; % Replace spaces by underlines.
end
fn = [fn, '.pps'];
comp = computer;
switch comp
case 'PCWIN'
filter = [sud.ppdir, '\',fn];
case 'MAC2'
filter = [sud.ppdir,':', fn];
otherwise
filter = [sud.ppdir,'/', fn];
end
[fname,pname] = uiputfile(filter,'Save the system as:');
if fname == 0,return;end
if ~strcmp(fname,fn)
ll = length(fname);
if (ll>4 & strcmp(fname(ll-3:ll),'.pps'))
fn = fname;
else
fn = [fname, '.pps'];
end
newsyst.name = fn;
sud.c.name = fn;
set(ppset,'user',sud);
end
newsysts = newsyst;
case 'gallery'
systems = get(sud.h.gallery,'user');
ll = length(systems);
if ll == 0
warndlg(['There are no systems to make up a gallery.'],'Warning');
return
end
names = cell(ll,1);
for j=1:ll
names{j} = systems(j).name;
end
[sel,ok] = listdlg('PromptString','Select the systems',...
'Name','Gallery selection',...
'ListString',names);
if isempty(sel)
return
else
newsysts = systems(sel);
end
comp = computer;
switch comp
case 'PCWIN'
prompt = [sud.ppdir,'\*.ppg'];
case 'MAC2'
prompt = [sud.ppdir,':*.ppg'];
otherwise
prompt = [sud.ppdir,':/.ppg'];
end
[fname,pname] = uiputfile(prompt,'Save the gallery as:');
ll = length(fname);
if (ll>4 & strcmp(fname(ll-3:ll),'.ppg'))
fn = fname;
else
fn = [fname, '.ppg'];
end
newsyst.name = fn(1:ll-4);
sud.c.name = fn(1:ll-4);
set(ppset,'user',sud);
end % switch type
ll = length(newsysts);
fid = fopen([pname fn],'w');
ppstring = '%%%% PPLANE file %%%%';
fprintf(fid,[ppstring,'\n']);
for k = 1:ll
fprintf(fid,'\n');
nstr = newsysts(k).name;
nstr = strrep(nstr,'''','''''');
nstr = ['H.name = ''', nstr, ''';\n'];
fprintf(fid,nstr);
xname = newsysts(k).xvar;
xnstr = ['H.xvar = ''', xname];
xnstr = strrep(xnstr,'\','\\');
xnstr = [xnstr, ''';\n'];
fprintf(fid,xnstr);
yname = newsysts(k).yvar;
ynstr = ['H.yvar = ''', yname];
ynstr = strrep(ynstr,'\','\\');
ynstr = [ynstr, ''';\n'];
fprintf(fid,ynstr);
xder = newsysts(k).xder;
xdstr = ['H.xder = ''', xder];
xdstr = strrep(xdstr,'\','\\');
xdstr = [xdstr, ''';\n'];
fprintf(fid,xdstr);
yder = newsysts(k).yder;
ydstr = ['H.yder = ''', yder];
ydstr = strrep(ydstr,'\','\\');
ydstr = [ydstr, ''';\n'];
fprintf(fid,ydstr);
pname = strrep(newsysts(k).pname,'\','\\');
pval = strrep(newsysts(k).pval,'\','\\');
pnl = length(pname);
pvl = length(pval);
for kk = 1:6
if kk <= pnl
pns = pname{kk};
else
pns = '';
end
if kk <= pvl
pvs = pval{kk};
else
pvs = '';
end
if kk == 1
pnstr = ['H.pname = {''', pns, ''''];
pvstr = ['H.pval = {''', pvs, ''''];
else
pnstr = [pnstr, ',''',pns, ''''];
pvstr = [pvstr, ',''',pvs, ''''];
end
end
pnstr = [pnstr, '};\n'];
pvstr = [pvstr, '};\n'];
fprintf(fid,pnstr);
fprintf(fid,pvstr);
ftstr = ['H.fieldtype = ''', newsysts(k).fieldtype];
ftstr - strrep(ftstr,'\','\\');
ftstr = [ftstr, ''';\n'];
fprintf(fid,ftstr);
nstr = ['H.npts = ', num2str(newsysts(k).npts),';\n'];
fprintf(fid,nstr);
wind = newsysts(k).wind;
wstr = ['H.wind = [', num2str(wind),'];\n'];
fprintf(fid,wstr);
end
fclose(fid);
elseif strcmp(action,'loadsyst') % This loads either a system or a gallery.
sud = get(gcf,'user');
pos = get(gcf,'pos');
wpos = [pos(1),pos(2)+pos(4)+20,300,20];
waith = figure('pos',wpos,...
'numb','off',...
'vis','off',...
'next','replace',...
'menubar','none',...
'resize','off',...
'createfcn','');
axes('pos',[0.01,0.01,0.98,0.98],...
'vis','off');
xp = [0 0 0 0];
yp = [0 0 1 1];
xl = [1 0 0 1 1];
yl = [0 0 1 1 0];
patchh = patch(xp,yp,'r','edgecolor','r','erase','none');
lineh = line(xl,yl,'erase','none','color','k');
type = input1;
set(sud.h.gallery,'enable','off');
if strcmp(type,'default')
set(waith,'name','Loading the default gallery.','vis','on');
set(findobj('tag','load default'),'enable','off');
megall = sud.h.gallery;
mh = get(megall,'children');
add = findobj(megall,'tag','add system');
mh(find(mh == add)) = [];
delete(mh);
newsysstruct = get(megall,'user');
system = sud.system;
ll = length(system);
x = 1/(ll+2);
xp = [xp(2),x,x,xp(2)];
set(patchh,'xdata',xp);
set(lineh,'xdata',xl);
drawnow;
sep = 'on';
for kk = 1:length(system)
kkk = num2str(kk);
if kk ==2, sep = 'off';end
uimenu(megall,'label',system(kk).name,...
'call',['pplane7(''system'',',kkk,')'],...
'separator',sep);
end % for
set(megall,'user',system);
else
comp = computer;
switch comp
case 'PCWIN'
prompt = [sud.ppdir,'\'];
case 'MAC2'
prompt = [sud.ppdir,':'];
otherwise
prompt = [sud.ppdir,'/'];
end
if strcmp(type,'system')
prompt = [prompt,'*.pps'];
[fname,pname] = uigetfile(prompt,'Select a system to load.');
elseif strcmp(type,'gallery')
prompt = [prompt,'*.ppg'];
[fname,pname] = uigetfile(prompt,'Select a gallery to load.');
end % if strcmp
if fname == 0
delete(waith);
set(sud.h.gallery,'enable','on');
return;
end
set(waith,'name',['Loading ',fname],'vis','on');
fid = fopen([pname fname],'r');
sline = fgetl(fid);
if strcmp(sline,'%% PPLANE file %%')
date = 'new';
else
date = 'old';
end
newsysts = {};
switch date
case 'old'
newsysts{1} = sline;
kk = 1;
case 'new'
kk = 0;
end
while ~feof(fid)
kk = kk + 1;
newsysts{kk} = fgetl(fid);
end
fclose(fid);
newsysts = newsysts([1:kk]);
false = 0;
switch date
case 'old'
if mod(kk,19)
false = 1;
end
case 'new'
if mod(kk,11)
false = 1;
end
end %switch date
if false
if strcmp(type,'system')
warndlg(['The file ',fname, ' does not define a proper system.'],...
'Warning');
elseif strcmp(type,'gallery')
warndlg(['The file ',fname, ' does not define a proper gallery.'],...
'Warning');
end
set(sud.h.gallery,'enable','on');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -