diff m-toolbox/classes/@LTPDAworkbench/cb_table.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/@LTPDAworkbench/cb_table.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,62 @@
+% CB_TABLE show the outputs of the currently selected blocks in a table.
+%
+% CALL: LTPDAworkbench.cb_table
+%
+% M Hewitson 13-11-08
+%
+% $Id: cb_table.m,v 1.4 2010/08/06 19:10:49 ingo Exp $
+%
+function cb_table(varargin)
+  
+  wb = varargin{1};
+  
+  % Get all selected blocks
+  sbs = awtinvoke(wb.mp, 'getSelectedBlocks');
+  
+  failed = false;
+  skipped = 0;
+  for ii=0:sbs.size()-1
+    block = sbs.get(ii);
+    
+    % if this is a MElementWithPorts
+    if isa(block, 'mpipeline.canvas.MElementWithPorts')
+      
+      % loop over all outputs
+      outports = block.getOutputs();
+      for kk=0:outports.size()-1
+        op = outports.get(kk);
+        % get variable name
+        outvar = LTPDAworkbench.getWS_VarName(wb.UUID, block, op.getNumber);
+        
+        % Check if the user have execute the pipeline.
+        if (evalin('base', ['exist(''' strtok(outvar, '.') ''')']) ~= 1) || ...
+            isempty(evalin('base', strtok(outvar, '.')))
+          utils.helper.errorDlg('Failed to show one or more of the selected objects in tables. Has the pipeline been executed?', 'Table block outputs error');
+          return
+        end
+        
+        if evalin('base', ['isa(' outvar ', ''ao'')'])
+          try
+            cmd = ['table(' outvar ')'];
+            evalin('base', cmd);
+          catch
+            failed = true;
+          end
+        else
+          warning('!!! Skipping block output [%s] since it''s not an AO', outvar);
+          skipped = skipped + 1;
+        end
+      end
+    end
+  end
+  
+  if failed
+    utils.helper.errorDlg('Failed to show one or more of the selected objects in tables. Has the pipeline been executed?', 'Table block outputs error');
+  end
+  
+  if skipped > 0
+    utils.helper.warnDlg('Not all selected blocks could be tabulated. Check the MATLAB terminal for further warnings.');
+  end
+  
+end
+