comparison m-toolbox/classes/@LTPDAworkbench/cb_exportWS.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 % CB_EXPORTWS stores the selected blocks outputs to the workspace
2 %
3 % CALL: LTPDAworkbench.cb_exportWS
4 %
5 % M Hewitson 13-11-08
6 %
7 % $Id: cb_exportWS.m,v 1.5 2010/08/06 19:10:48 ingo Exp $
8 %
9 function cb_exportWS(varargin)
10
11 wb = varargin{1};
12
13 % Get all selected blocks
14 sbs = awtinvoke(wb.mp, 'getSelectedBlocks');
15
16 outvars = {};
17 for ii=0:sbs.size()-1
18 block = sbs.get(ii);
19
20 % if this is a MElementWithPorts
21 if isa(block, 'mpipeline.canvas.MElementWithPorts')
22
23 % loop over all outputs
24 outports = block.getOutputs();
25 for kk=0:outports.size()-1
26 op = outports.get(kk);
27 % get variable name
28 outvar = LTPDAworkbench.getWS_VarName(wb.UUID, block, op.getNumber);
29 outvars = [outvars {outvar}];
30 end
31 end
32 end
33
34 % Check if each var exists in the workspace, and then store in workspace
35 try
36 for kk=1:numel(outvars)
37
38 % get class of the object
39 cl = evalin('base', [ 'class(' outvars{kk} ')']);
40
41 % get new var name
42 % - this means split the outvar at the last '.'
43 nv = getVar(outvars{kk});
44
45 if ismember(cl, utils.helper.ltpda_userclasses)
46 % cmd = [nv ' = ' cl '(' outvars{kk} ');'];
47 cmd = [nv ' = copy(' outvars{kk} ',1);'];
48 else
49 cmd = [nv ' = ' outvars{kk} ';'];
50 end
51 evalin('base', cmd);
52 end
53 catch
54 utils.helper.errorDlg('Unable to export selected objects. Has the pipeline been executed?', 'Export to workspace error');
55 end
56
57
58 end
59
60 function nv = getVar(ov)
61
62 nv = '';
63
64 for kk=length(ov):-1:1
65 if ov(kk) == '.'
66 break
67 else
68 nv = [nv ov(kk)];
69 end
70 end
71
72 nv = nv(end:-1:1);
73
74 end