Skip to content

Commit

Permalink
Use the new preference class. (#54)
Browse files Browse the repository at this point in the history
* Created @swpref class

* Added static properties

* Added documentation to @swpref

* Pref class (#53)

* Created @swpref class

* Created @swpref class (#51)

* Added static properties

* Added documentation to @swpref

* cosmetic changes

- updated help strings

* More cosmetic changes

* Fix recursion error
  • Loading branch information
Simon Ward authored and tsdev committed Dec 1, 2017
1 parent 46fb74a commit 611f084
Show file tree
Hide file tree
Showing 63 changed files with 988 additions and 330 deletions.
5 changes: 3 additions & 2 deletions dev/@spinw/corespec.m
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,13 @@
% whether the structure is incommensurate
incomm = any(abs(km-round(km)) > param.tol);

fid = swpref.getpref('fid',true);
pref = swpref;
fid = pref.fid;

nHkl = size(hkl,2);

% use mex file by default?
useMex = swpref.getpref('usemex',[]);
useMex = pref.usemex;

% Create the interaction matrix and atomic positions in the extended
% magnetic unit cell.
Expand Down
3 changes: 2 additions & 1 deletion dev/@spinw/phonon.m
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@

% solve the eigenvalue problem
%[ea,om2] = eigenshuffle(Dab);
[ea,om2] = eigorth(Dab, param.omega_tol, swpref.getpref('usemex',[]));
pref = swpref;
[ea,om2] = eigorth(Dab, param.omega_tol, pref.usemex);

om = sqrt(real(om2));

Expand Down
4 changes: 3 additions & 1 deletion dev/@spinw/scga.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@
spectra.datestart = datestr(now);
end

pref = swpref;

if param.fid == -1
fid = swpref.getpref('fid',true);
fid = pref.fid;
else
fid = param.fid;
end
Expand Down
4 changes: 3 additions & 1 deletion dev/@spinw/scga3.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
param.plot = false;
end

fid = swpref.getpref('fid',true);
pref = swpref;
fid = pref.fid;


kBT = param.T*obj.unit.kB;
beta = 1./kBT;
Expand Down
6 changes: 3 additions & 3 deletions docs/docgenerator/docgen.m
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
%% setup help generator options

swPath = {'swfiles/@spinw' 'swfiles' 'swfiles/+swplot' 'swfiles/+swpref' 'swfiles/+swsym' 'swfiles/+swfunc' 'swfiles/+ndbase'};
swPath = {'swfiles/@spinw' 'swfiles' 'swfiles/+swplot' 'swfiles/@swpref' 'swfiles/+swsym' 'swfiles/+swfunc' 'swfiles/+ndbase'};
swr = sw_rootdir;
swPath = cellfun(@(C)[swr C],swPath,'UniformOutput',false);
swver = sw_version;
outPath = '~/spinwdoc_git';
docPath = '~/spinw_git/docs';
upload = true;
recalc = true;
upload = false;
recalc = false;

%% generate help

Expand Down
3 changes: 2 additions & 1 deletion swfiles/+ndbase/pso.m
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,10 @@
inpForm.size = [inpForm.size {[1 1] [1 1] [1 Np] [1 Np] [1 1] [1 1]}];

param = sw_readparam(inpForm, varargin{:});
pref = swpref;

if param.tid == -1
param.tid = swpref.getpref('tid',[]);
param.tid = pref.tid;
end

% parameter boundaries
Expand Down
3 changes: 2 additions & 1 deletion swfiles/+swplot/activefigure.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
end

% tag for active figure
activeTag = swpref.getpref('tag',[]);
pref = swpref;
activeTag = pref.tag;

% tag for inactive figures
inactiveTag = ['inactive_' activeTag];
Expand Down
4 changes: 3 additions & 1 deletion swfiles/+swplot/arrow.m
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,10 @@

end

pref = swpref;

if isempty(nPatch)
nPatch = swpref.getpref('npatch',[]);
nPatch = pref.npatch;
end

if numel(rStart)==3
Expand Down
4 changes: 3 additions & 1 deletion swfiles/+swplot/circle.m
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,12 @@
argExt = {varargin{4:end}};
end

pref = swpref;

if nArgExt > 0
N = argExt{1};
else
N = swpref.getpref('npatch',[]);
N = pref.npatch;
end

if numel(r0) == 3
Expand Down
7 changes: 5 additions & 2 deletions swfiles/+swplot/close.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ function close(varargin)
% [swplot.figure]
%

pref = swpref;


if nargin == 0
% check if there is any swplot figure
activeTag = swpref.getpref('tag',[]);
activeTag = pref.tag;
inactiveTag = ['inactive_' activeTag];
if isempty([findobj('tag',activeTag) findobj('tag',inactiveTag)])
% nothing to close
Expand All @@ -45,7 +48,7 @@ function close(varargin)
close(hFigure);
else
% close all swplot figure
activeTag = swpref.getpref('tag',[]);
activeTag = pref.tag;
% tag for inactive figures
inactiveTag = ['inactive_' activeTag];

Expand Down
4 changes: 3 additions & 1 deletion swfiles/+swplot/cylinder.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@
% [swplot.arrow]
%

pref = swpref;

if nargin == 0
swhelp swplot.cylinder
return
Expand Down Expand Up @@ -102,7 +104,7 @@
end

if isempty(nPatch)
nPatch = swpref.getpref('npatch',[]);
nPatch = pref.npatch;
end

if nArgExt > 1
Expand Down
3 changes: 2 additions & 1 deletion swfiles/+swplot/ellipsoid.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
%
% [matlab.triangulation] \| [swplot.icomesh]
%
pref = swpref;

if nargin == 0
swhelp swplot.ellipsoid
Expand Down Expand Up @@ -95,7 +96,7 @@

if isnumeric(mesh)
% limit the largest mesh to plot to avoid slowing down Matlab too much
mesh = min(mesh,swpref.getpref('maxmesh',[]));
mesh = min(mesh,pref.maxmesh);
% generate mesh
mesh = swplot.icomesh(mesh);
end
Expand Down
3 changes: 2 additions & 1 deletion swfiles/+swplot/figure.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
% if ~isempty(get(0,'CurrentFigure'))
% oldAxis = get(gcf,'CurrentAxes');
% end
pref = swpref;

if nargin == 0
mode = 'hg';
Expand Down Expand Up @@ -76,7 +77,7 @@
'Name', 'swplot',...
'DockControls', 'off',...
'PaperType', 'A4',...
'Tag', swpref.getpref('tag',[]),...
'Tag', pref.tag,...
'Toolbar', 'figure',...
'DeleteFcn', @closeSubFigs...
);
Expand Down
3 changes: 2 additions & 1 deletion swfiles/+swplot/legend.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
% : Handle of the swplot figure, default value is the handle of the active
% figure.
%
pref = swpref;

if nargin == 0
switch0 = 'on';
Expand Down Expand Up @@ -123,7 +124,7 @@
lColor = lDat.color;

% get the stored fontsize
fontSize = swpref.getpref('fontsize',[]);
fontSize = pref.fontsize;

for ii = 1:numel(lType)
switch lType(ii)
Expand Down
7 changes: 4 additions & 3 deletions swfiles/+swplot/plot.m
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,10 @@
% [swplot.color] \| [swplot.add]
%

P0 = swpref.getpref('npatch',[]);
M0 = swpref.getpref('nmesh',[]);
fontSize0 = swpref.getpref('fontsize',[]);
pref = swpref;
P0 = pref.npatch;
M0 = pref.nmesh;
fontSize0 = pref.fontsize;

inpForm.fname = {'type' 'name' 'text' 'position' 'label' 'legend' 'color' 'unit' 'figure' 'lineStyle'};
inpForm.defval = {[] [] '' [] [] [] [] 'lu' [] '-' };
Expand Down
8 changes: 5 additions & 3 deletions swfiles/+swplot/plotatom.m
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,12 @@
% sObject = swplot.findobj(hFigure,'name','atom')`.
%

pref = swpref;

% default values
fontSize0 = swpref.getpref('fontsize',[]);
nMesh0 = swpref.getpref('nmesh',[]);
nPatch0 = swpref.getpref('npatch',[]);
fontSize0 = pref.fontsize;
nMesh0 = pref.nmesh;
nPatch0 = pref.npatch;

inpForm.fname = {'range' 'legend' 'label' 'dtext' 'fontsize' 'radius0'};
inpForm.defval = {[] true false 0.1 fontSize0 0.3 };
Expand Down
5 changes: 3 additions & 2 deletions swfiles/+swplot/plotbase.m
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,11 @@
%

% default values
pref = swpref;
col0 = swplot.color({'red' 'green' 'blue'});
d0 = ones(1,3);
nMesh0 = swpref.getpref('nmesh',[]);
nPatch0 = swpref.getpref('npatch',[]);
nMesh0 = pref.nmesh;
nPatch0 = pref.npatch;

inpForm.fname = {'range' 'mode' 'figure' 'color' 'R' 'alpha' 'lhead' 'shift'};
inpForm.defval = {[] 'abc' [] col0 0.06 30 0.5 [0;0;0]};
Expand Down
5 changes: 3 additions & 2 deletions swfiles/+swplot/plotbond.m
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,9 @@

% default values
%fontSize0 = swpref.getpref('fontsize',[]);
nMesh0 = swpref.getpref('nmesh',[]);
nPatch0 = swpref.getpref('npatch',[]);
pref = swpref;
nMesh0 = pref.nmesh;
nPatch0 = pref.npatch;

inpForm.fname = {'range' 'legend' 'label' 'zero' 'scale' 'radius0' 'mode2' 'linewidth'};
inpForm.defval = {[] true true true 1/3 0.05 [] 'fix' };
Expand Down
5 changes: 3 additions & 2 deletions swfiles/+swplot/plotcell.m
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@
%

% default values
nMesh0 = swpref.getpref('nmesh',[]);
nPatch0 = swpref.getpref('npatch',[]);
pref = swpref;
nMesh0 = pref.nmesh;
nPatch0 = pref.npatch;

inpForm.fname = {'range' 'mode' 'figure' 'color' 'linestyle' 'linewidth'};
inpForm.defval = {[] 'single' [] 'auto' '--' 1 };
Expand Down
5 changes: 3 additions & 2 deletions swfiles/+swplot/plotchem.m
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,9 @@
%

% default values
nMesh0 = swpref.getpref('nmesh',[]);
nPatch0 = swpref.getpref('npatch',[]);
pref = swpref;
nMesh0 = pref.nmesh;
nPatch0 = pref.npatch;

inpForm.fname = {'range' 'legend' 'label' 'unit' 'mode' 'atom1' 'atom2' 'copy'};
inpForm.defval = {[] true true 'lu' 'poly' 1 2 false };
Expand Down
5 changes: 3 additions & 2 deletions swfiles/+swplot/plotion.m
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,9 @@

% default values
%fontSize0 = swpref.getpref('fontsize',[]);
nMesh0 = swpref.getpref('nmesh',[]);
nPatch0 = swpref.getpref('npatch',[]);
pref = swpref;
nMesh0 = pref.nmesh;
nPatch0 = pref.npatch;

inpForm.fname = {'range' 'legend' 'label' 'scale' 'linewidth' 'alpha'};
inpForm.defval = {[] true true 1/3 0.5 0.3 };
Expand Down
7 changes: 4 additions & 3 deletions swfiles/+swplot/plotmag.m
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,10 @@


% default values
fontSize0 = swpref.getpref('fontsize',[]);
nMesh0 = swpref.getpref('nmesh',[]);
nPatch0 = swpref.getpref('npatch',[]);
pref = swpref;
fontSize0 = pref.fontsize;
nMesh0 = pref.nmesh;
nPatch0 = pref.npatch;

inpForm.fname = {'range' 'legend' 'label' 'dtext' 'fontsize' 'radius0' };
inpForm.defval = {[] true true 0.1 fontSize0 0.06 };
Expand Down
3 changes: 2 additions & 1 deletion swfiles/+swplot/text.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
end

fontSize = [];
pref = swpref;

if numel(varargin{1}) == 1
% first input figure handle
Expand Down Expand Up @@ -73,7 +74,7 @@
end

if isempty(fontSize)
fontSize = swpref.getpref('fontsize',[]);
fontSize = pref.fontsize;
end

hText = gobjects(1,nText);
Expand Down
4 changes: 2 additions & 2 deletions swfiles/+swplot/tooltip.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
if nargin == 0
text0 = 'on';
end

fontSize = swpref.getpref('fontsize',[]);
pref = swpref;
fontSize = pref.fontsize;

if nargin < 2 || isempty(hFigure)
% find active figure
Expand Down
49 changes: 0 additions & 49 deletions swfiles/+swpref/getpref.m

This file was deleted.

Loading

0 comments on commit 611f084

Please sign in to comment.