3 %> <h3>Inheriting the
"irobj" class
5 %> @arg Check
for descendants,
as there may be a more suitable
class to be inherited
6 %> @arg Create a GUI to edit properties from @ref
objtool or @ref datatool. This step is optional, but make sure you set @ref flag_ui or @ref flag_params to 0 at the constructor
8 %> @warning From my own experience, it is common to start by duplicating an existing
class file, but forget to rename the constructor
9 %> The constructor of the
new class must have the same name
as the class itself.
11 %> <h3>Properties to set in the constructor of
new object class</h3>
13 %> The following properties within @ref
irobj define how the GUI will handle the
class
20 %> <h3>Creating a properties Dialog Box</h3>
21 %> Properties GUI names follow the following pattern: <code>uip_<corresponding class name>.m</code>, and
22 %> <code>uip_<corresponding class name>.fig</code>. The latter is the FIG created
using GUIDE.
24 %> @arg set <code>flag_ui=1</code> and <code>flag_params=1</code> at the constructor
25 %> @arg Use an existing GUI
as template. Open an existing properties GUI in GUIDE, e.g <code>guide uip_fcon_pca</code>, and save it with the appropriate name.
26 %> @arg Make the necessary changes to the GUI and its source code.
28 %> <h3>To make it appear in
objtool, type</h3>
37 %> =[0, .8, 0]. multipurpose feature, routines may use it
for different things. Major use is to change the background of
objtool and
42 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43 %%% Considering reconfiguring these properties when inheriting from
irobj or one or its descendants
44 properties (SetAccess=
protected)
45 %> Class Title. Should have a descriptive name,
as short as possible.
46 classtitle =
'Base Object';
47 %> Short
for the method name
49 %> =1. (GUI setting) Whether to call a GUI when the
block is selected in @ref
blockmenu.m . If
true, a routine
50 %> called
"uip_"<
class name> will be called.
52 %> (GUI setting) Whether to
"publish" in @ref
blockmenu and @ref datatool. Note that a
class can be "published" without a GUI (set flag_params=0 in
this case, at the
class constructor).
54 %> (GUI setting) String cell containing names of methods that may be called from the GUIs
59 methods (Access=
protected)
61 function s = do_get_report(o)
65 %> Abstract. HTML inner body
66 function s = do_get_html(o)
67 s = ['<h1 style=''background-color:
#', color2hex(o.color), '''>', o.classtitle, '</h1>', 10, '<pre>', o.get_report(), '</pre>', 10];
72 %> Returns description
string
74 %> Precedence according with flag_short:
75 %> @arg 0: title >
short > classtitle
76 %> @arg 1:
short > title > classtitle
78 %> @param flag_short=0
80 %> I am sealing
this to make sure that no
class will try to improvise on this function.
81 function s = get_description(o, flag_short)
82 if nargin < 2 || isempty(flag_short)
86 ff = {
'short',
'title',
'classtitle'};
88 ff = {
'title',
'short',
'classtitle'};
96 % Note that classtitle is always non-empty, so s will be always set
101 %>@brief Sets several properties of an
object at once
103 %>@param params Cell followint the pattern @verbatim {
'property1', value1,
'property2', value2, ...}
@endverbatim
105 for i = 1:length(params)/2
106 varname = params{i*2-1};
113 %> This is used only to compose sequence
string e.g. xxx->yyy->zzz
114 %> @param flag_short=0
115 function s = get_methodname(o, flag_short)
116 if nargin < 2 || isempty(flag_short)
119 s = o.get_description(flag_short);
122 %> Object reports are plain text. HTML would be cool but c'mon, we don't need that sophistication
123 function s = get_report(o)
124 s = o.do_get_report();
127 %> @param flag_stylesheet=1 Whether to include the
stylesheet in the HTML
128 function s = get_html(o, flag_stylesheet)
130 if nargin < 2 || isempty(flag_stylesheet)
139 s = cat(2, s, '<h1>', o.get_description(), '</h1>', o.do_get_html());
140 % s = [s, '</body></html>', 10];
143 %> @brief Calls Parameters GUI
145 %> If @c flag_params, tries uip_<class>.m. If fails, tries uip_<ancestor>.m and so on
146 function result = get_params(o, data)
156 func = eval(['@(o, data) uip_' sclass '(o, data);']); %> Builds function pointer based on the
block class
157 result = func(o, data);
160 irverbose([
'irobj::get_params() Caught exception ', ME.message]);
161 % disp(ME.getReport());
167 if isempty(mc.SuperClasses)
170 mc = mc.SuperClasses{1};
175 irerror(sprintf(
'Couldn''t find a parameters GUI for class "%s"!',
class(o)));
178 irerror(sprintf('Result from %s properties GUI not a structure', sclass));
180 if ~isfield(result, 'flag_ok')
181 irerror(sprintf('Result from %s properties GUI does not have a flag_ok', sclass));
191 function [o, log] = extract_log(o)
193 irerror('Cannot extract log, log is empty!');
199 % %> Default behaviour: returns class of
object plus
object's title
200 % function s = get_description(o)
202 % if ~isempty(o.title)
205 % a = {o.get_methodname(),
class(o)};
209 % s = [s,
iif(qtd > 0,
' ~ ',
''), a{i}];
221 %> @param flag_title=1
222 function s = get_ancestry(o, flag_title)
226 ss = superclasses(o);
228 for i = numel(ss):-1:1
231 stemp = o2.classtitle;
239 stemp = o.classtitle;
function irverbose(in s, in level)
function classmap_compile()
Property moreactions
(GUI setting) String cell containing names of methods that may be called from the GUIs ...
function setbatch(in o, in params)
function iif(in cond, in x1, in x2)
function replace_underscores(in s)
Property flag_ui
(GUI setting) Whether to "publish" in blockmenu and datatool. Note that a class can be "published" wi...
Property classtitle
Class Title. Should have a descriptive name, as short as possible.
Analysis Session (AS) base class.
function get_matlab_output(in o, in flag_cell)