Mercurial > hg > ltpda
comparison m-toolbox/classes/@LTPDAworkbench/cb_saveObjects.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_SAVEOBJECTS save the outputs of the currently selected blocks | |
2 % | |
3 % CALL: LTPDAworkbench.cb_saveObjects | |
4 % | |
5 % M Hewitson 13-11-08 | |
6 % | |
7 % $Id: cb_saveObjects.m,v 1.3 2010/08/06 19:10:48 ingo Exp $ | |
8 % | |
9 function cb_saveObjects(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 | |
35 % Check if each var exists in the workspace, and then save them | |
36 | |
37 out = {}; | |
38 try | |
39 if ~isempty(outvars) | |
40 for kk=1:numel(outvars) | |
41 disp(sprintf('** adding %s [%s] to collection', outvars{kk}, evalin('base', ['class(' outvars{kk} ')']) )); | |
42 cmd = 'out = [out '; | |
43 cmd = [cmd '{evalin(''base'', ''' outvars{kk} ''')}];']; | |
44 | |
45 eval(cmd); | |
46 end | |
47 | |
48 if ~isempty(out) | |
49 % get file name from user | |
50 [filename, pathname] = uiputfile('*.xml','Pick an XML-file'); | |
51 if isequal(filename,0) || isequal(pathname,0) | |
52 else | |
53 fname = fullfile(pathname,filename); | |
54 save(plist('collection', out), fname); | |
55 disp(sprintf('*** Saved plist with %d AOs to %s', numel(out), fname)); | |
56 end | |
57 end | |
58 end | |
59 | |
60 catch err | |
61 disp(err.message) | |
62 utils.helper.errorDlg('Unable to save selected objects. Has the pipeline been executed? Are all the objects AOs?', 'Save block outputs error'); | |
63 end | |
64 | |
65 end | |
66 |