Mercurial > hg > ltpda
diff m-toolbox/classes/@LTPDAworkbench/plot.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/plot.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,69 @@ +% PLOT plot the outputs of the currently selected blocks. +% +% CALL: wb.plot +% +% M Hewitson 13-11-08 +% +% $Id: plot.m,v 1.8 2010/08/06 19:10:49 ingo Exp $ +% +function plot(varargin) + + wb = varargin{1}; + + % Get all selected blocks + sbs = awtinvoke(wb.mp, 'getSelectedBlocks'); + + outvars = {}; + 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); + outvars = [outvars {outvar}]; + end + end + end + + % Check if each var exists in the workspace, and then launch in + % ltpda_explorer + + if ~isempty(outvars) + + cmd = 'iplot('; + for kk=1:numel(outvars) + + % Check if the user have execute the pipeline. + if (evalin('base', ['exist(''' strtok(outvars{kk}, '.') ''')']) ~= 1) || ... + isempty(evalin('base', strtok(outvars{kk}, '.'))) + utils.helper.errorDlg('Unable to plot selected objects. Has the pipeline been executed?', 'Plot block outputs error'); + return + end + + if isa(evalin('base', outvars{kk}), 'ao') + cmd = [cmd outvars{kk} ',']; + else + utils.helper.errorDlg(sprintf('Please select only analysis objects (AOs) because you selected a %s object.', class(evalin('base', outvars{kk}))), 'Plot block outputs error'); + return + end + end + + if cmd(end)==',' + cmd = cmd(1:end-1); + end + cmd = [cmd ')']; + try + evalin('base', cmd); + catch + utils.helper.errorDlg('Unable to plot selected objects. Has the pipeline been executed?', 'Plot block outputs error'); + end + end + +end +