comparison m-toolbox/classes/@ltpda_uoh/viewHistory.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 % VIEWHISTORY Displays the history of an object as a dot-view or a MATLAB figure.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: VIEWHISTORY Displays the history of an object depending of
5 % the parameter values as a dot-view or a MATLAB history
6 % figure.
7 %
8 % CALL: viewHistory(obj);
9 % viewHistory(obj, pl);
10 %
11 % INPUTS: obj: Single object with history
12 % pl: parameter list with different parameters.
13 %
14 % <a href="matlab:utils.helper.displayMethodInfo('ltpda_uoh', 'viewHistory')">Parameters Description</a>
15 %
16 % VERSION: $Id: viewHistory.m,v 1.9 2011/04/08 08:56:30 hewitson Exp $
17 %
18 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19
20 function varargout = viewHistory(varargin)
21
22 % Check if this is a call for parameters
23 if utils.helper.isinfocall(varargin{:})
24 varargout{1} = getInfo(varargin{3});
25 return
26 end
27
28 % Collect all AOs
29 obj = utils.helper.collect_objects(varargin(:), '');
30 pl = utils.helper.collect_objects(varargin(:), 'plist');
31
32 % Check that the input object is only a single object
33 if numel(obj) ~= 1
34 error('### This methods works only with one single object');
35 end
36
37 % Check that the input object effectively contains history information
38 if isempty(obj.hist)
39 warning('### The object has no history!');
40 else
41 % be sure that pl is a single plist.
42 pl = combine(pl, plist());
43
44 app = pl.find('application');
45 if isempty(app)
46 app = 'default';
47 end
48
49 % Combine input plist with dedfault plist
50 pl = combine(pl, getDefaultPlist(app));
51
52 switch lower(pl.find('application'))
53 case 'dot view'
54 try
55 dotview(obj.hist, pl);
56 catch err
57 warning('### The DOT view fails. Using the MATLAB view');
58 plot(obj.hist);
59 end
60 case 'matlab plot'
61 plot(obj.hist, pl);
62 otherwise
63 error('### Unknown application to show the history [%s]', pl.find('application'));
64 end
65 end
66 end
67
68 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
69 % Local Functions %
70 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
71
72 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73 %
74 % FUNCTION: getInfo
75 %
76 % DESCRIPTION: Get Info Object
77 %
78 % HISTORY: 11-07-07 M Hewitson
79 % Creation.
80 %
81 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
82
83 function ii = getInfo(varargin)
84 if nargin == 1 && strcmpi(varargin{1}, 'None')
85 sets = {};
86 pls = [];
87 elseif nargin == 1 && ~isempty(varargin{1}) && ischar(varargin{1})
88 sets{1} = varargin{1};
89 pls = getDefaultPlist(sets{1});
90 else
91 sets = {...
92 'Default', ...
93 'DOT View', ...
94 'MATLAB plot'};
95
96 pls = [];
97 for kk=1:numel(sets)
98 pls = [pls getDefaultPlist(sets{kk})];
99 end
100 end
101 % Build info object
102 ii = minfo(mfilename, 'ltpda_uoh', 'ltpda', utils.const.categories.output, '$Id: viewHistory.m,v 1.9 2011/04/08 08:56:30 hewitson Exp $', sets, pls);
103 ii.setModifier(false);
104 ii.setOutmin(0);
105 end
106
107 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
108 %
109 % FUNCTION: getDefaultPlist
110 %
111 % DESCRIPTION: Get Default Plist
112 %
113 % HISTORY: 11-07-07 M Hewitson
114 % Creation.
115 %
116 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
117
118 function plout = getDefaultPlist(set)
119 persistent pl;
120 persistent lastset;
121 if exist('pl', 'var')==0 || isempty(pl) || ~strcmp(lastset, set)
122 pl = buildplist(set);
123 lastset = set;
124 end
125 plout = pl;
126 end
127
128 function pl = buildplist(set)
129
130 pl = plist();
131
132 p = param({'application', 'Application which should display the history'}, {1, {'DOT View', 'MATLAB plot'}, paramValue.SINGLE});
133 pl.append(p);
134
135 switch lower(set)
136 case 'default'
137 pl = getDefaultPlist('dot view');
138
139 case 'dot view'
140 pl.setDefaultForParam('application', 'dot view');
141
142 p = param({'filename', ''}, paramValue.EMPTY_STRING);
143 pl.append(p);
144
145 p = param({'view', ''}, paramValue.TRUE_FALSE);
146 pl.append(p);
147
148 p = param({'format', ''}, paramValue.STRING_VALUE('pdf'));
149 pl.append(p);
150
151 case 'matlab plot'
152 pl.setDefaultForParam('application', 'matlab plot');
153
154 p = param({'stop_option','Stop option'}, {1, {'full', 'File', 'Repo', 'File Repo', 1, 2, 3, 4}, paramValue.SINGLE});
155 pl.append(p);
156
157 otherwise
158 error('### Unknown parameter set [%s].', set);
159 end
160 end
161