IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
setup_write.m
Go to the documentation of this file.
1 %> @file
2 %> @ingroup globals setupgroup
3 %> @brief writes MATLAB M file irootlab_setup.m
4 %>
5 %> Writes several global variables into a MATLAB source file called <code>irootlab_setup.m</code>. This file can be later executed to restore
6 %> the setup conditions.
7 %>
8 %> The variables written are the graphics globals, database globals, and verbose globals.
9 %>
10 %> For a list of written variables to setup, please check the source code of this file.
11 %>
12 %> @sa verbose_assert.m, db_assert.m, fig_assert.m, path_assert.m, more_assert.m, datatool.m, objtool.m, mergetool.m, scenebuilder.m
13 
14 function setup_write()
15 
16 s0 = [sprintf('verbose_assert();\ndb_assert();\nfig_assert();\npath_assert();\nmore_assert();\n')]; %#ok<NBRAK>
17 eval(s0);
18 
20 
21 which = {'SCALE', 'COLORS', 'MARKERS', 'MARKERSIZES', 'FONT', 'FONTSIZE', 'LINESTYLES', ...
22  'VERBOSE.minlevel', 'VERBOSE.flag_file', ...
23  'DB.host', 'DB.name', 'DB.user', 'DB.pass', ...
24  'PATH.data_load', 'PATH.data_save', 'PATH.data_spectra', 'PATH.doc', ...
25  'MORE.pd_maxpeaks', 'MORE.pd_mindist_units', 'MORE.pd_minheight', 'MORE.pd_minaltitude', ...
26  'MORE.ssp_stabilitythreshold', 'MORE.ssp_minhits_perc', 'MORE.ssp_nf4gradesmode', 'MORE.bc_halfheight', ...
27  'MORE.flag_postpr_grag', 'COLORS_STACKEDHIST'};
28 
29 whichglobals = {};
30 for i = 1:numel(which)
31  fi = find(which{i} == '.');
32  if fi
33  whichglobals{end+1} = which{i}(1:fi-1); %#ok<*AGROW>
34  else
35  whichglobals{end+1} = which{i};
36  end;
37 end;
38 whichglobals = unique(whichglobals);
39 
40 s1 = 'global ';
41 for i = 1:numel(whichglobals)
42  if i > 1
43  s1 = cat(2, s1, ' ');
44  end;
45  s1 = cat(2, s1, whichglobals{i});
46 end;
47 s1 = cat(2, s1, ';', 10);
48 
49 
50 eval(s1);
51 
52 
53 s2 = '';
54 for i = 1:numel(which)
55  try
56  syma = eval(which{i});
57  catch ME
58  irerror(sprintf('Problem trying to evaluate "%s": %s', which{i}, ME.message));
59  end;
60  s2 = cat(2, s2, which{i}, ' = ', convert_to_str(syma), ';', 10);
61 end;
62 
63 
64 
65 ss = ['% V V', 10, '% vvvO8 8Ovvv', 10, '% IRootLab setup generated at ', datestr(now()), '.', 10, '% Please note that this file may be automatically re-generated by IRootLab.', 10, '% Do not add comments, as these will not be kept.', 10, s0, 10, s1, s2];
66 
67 h = fopen('irootlab_setup.m', 'w');
68 fwrite(h, ss);
69 fclose(h);
70 irverbose('Wrote file "irootlab_setup.m"', 1);
71 
72 %%%%%%%%%%
73 % Converts colors to 0-255 range
74 function convert_colors()
75 global COLORS COLORS_STACKEDHIST;
76 
77 COLORS = convert_(COLORS);
78 COLORS_STACKEDHIST = convert_(COLORS_STACKEDHIST);
79 
80 %%%%%%%%%%
81 function C = convert_(C)
82 
83 % Converts to 0-1 if COLORS has values above 0-1
84 cc = cell2mat(C);
85 if all(cc(:) <= 1)
86  C = cellfun(@(x) round(x*255), C, 'UniformOutput', 0);
87 end;
function irverbose(in s, in level)
function verbose_assert()
function convert_to_str(in c)
function more_assert()
function convert_(in C)
function irerror(in s)
function objtool(in varargin)
function db_assert()
function setup_write()
function convert_colors()
function path_assert()
function fig_assert()