xxsimAddCurveToPlot

PURPOSE ^

xxsimAddCurveToPlot - Add a new curve to the specified plot

SYNOPSIS ^

function retval = xxsimAddCurveToPlot(window,plot,yPath,labelName,varargin)

DESCRIPTION ^

 xxsimAddCurveToPlot - Add a new curve to the specified plot

 Syntax: 
   retval = xxsimAddCurveToPlot(window,plot,'yPath')

 Inputs:
   window   =  Name or ID from the plot window where the curve is added to.
   plot     =  Name or ID from the plot where the curve is added to.
   yPath    =  Path of the 20-sim variable that is plotted in the curve.
   labelName=    Label given to the curve, as shown in the legend of the plot (optional, default is yPath).
   varargin =  Specify key-value pairs as needed (optional, default is no key-value pair).

   Keys supported for the key-value pairs are:
   colorR   =  The red component of the RGB colour that the curve should have (if colorG or colorB is specified, the default value will be 0) [0-255].
   colorG   =  The green component of the RGB colour that the curve should have (if colorR or colorB is specified, the default value will be 0) [0-255].
   colorB   =  The blue component of the RGB colour that the curve should have (if colorR or colorG is specified, the default value will be 0) [0-255].
   thickness=  The thickness of the line [1-50].

 Outputs: 
   retval = returns a unique ID corresponding to the curve that was created.
 
 Example:
   retval = xxsimAddCurveToPlot(1,2,'MotionProfile.x')
   
     - Adds a curve to plot 2 in window 1 with MotionProfile.x on its y-axis.
     - retval now contains an ID that is uniquely coupled to this
       newly added curve.
     - Note: The simulator should be open before calling this function.  
   retval = xxsimAddCurveToPlot(1,2,'MotionProfile.x','Position','colorR',255)
   
     - Adds a curve to plot 2 in window 1 with MotionProfile.x on its y-axis with label "Position".
     - The curve will now be red.

 See also: xxsimRemoveCurveFromPlot, xxsimOpenSimulator, xxsimAddPlotToWindow, xxsimGetCurvesFromPlot

 Author: Controllab Products B.V.
 email: info@controllab.nl
 Website: http://www.controllab.nl
 December 2017

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function retval = xxsimAddCurveToPlot(window,plot,yPath,labelName,varargin)
0002 % xxsimAddCurveToPlot - Add a new curve to the specified plot
0003 %
0004 % Syntax:
0005 %   retval = xxsimAddCurveToPlot(window,plot,'yPath')
0006 %
0007 % Inputs:
0008 %   window   =  Name or ID from the plot window where the curve is added to.
0009 %   plot     =  Name or ID from the plot where the curve is added to.
0010 %   yPath    =  Path of the 20-sim variable that is plotted in the curve.
0011 %   labelName=    Label given to the curve, as shown in the legend of the plot (optional, default is yPath).
0012 %   varargin =  Specify key-value pairs as needed (optional, default is no key-value pair).
0013 %
0014 %   Keys supported for the key-value pairs are:
0015 %   colorR   =  The red component of the RGB colour that the curve should have (if colorG or colorB is specified, the default value will be 0) [0-255].
0016 %   colorG   =  The green component of the RGB colour that the curve should have (if colorR or colorB is specified, the default value will be 0) [0-255].
0017 %   colorB   =  The blue component of the RGB colour that the curve should have (if colorR or colorG is specified, the default value will be 0) [0-255].
0018 %   thickness=  The thickness of the line [1-50].
0019 %
0020 % Outputs:
0021 %   retval = returns a unique ID corresponding to the curve that was created.
0022 %
0023 % Example:
0024 %   retval = xxsimAddCurveToPlot(1,2,'MotionProfile.x')
0025 %
0026 %     - Adds a curve to plot 2 in window 1 with MotionProfile.x on its y-axis.
0027 %     - retval now contains an ID that is uniquely coupled to this
0028 %       newly added curve.
0029 %     - Note: The simulator should be open before calling this function.
0030 %   retval = xxsimAddCurveToPlot(1,2,'MotionProfile.x','Position','colorR',255)
0031 %
0032 %     - Adds a curve to plot 2 in window 1 with MotionProfile.x on its y-axis with label "Position".
0033 %     - The curve will now be red.
0034 %
0035 % See also: xxsimRemoveCurveFromPlot, xxsimOpenSimulator, xxsimAddPlotToWindow, xxsimGetCurvesFromPlot
0036 %
0037 % Author: Controllab Products B.V.
0038 % email: info@controllab.nl
0039 % Website: http://www.controllab.nl
0040 % December 2017
0041 
0042 %------------- BEGIN CODE --------------
0043   % Check the obtained amount of input arguments.
0044   if(nargin<3)
0045     error('Too little input arguments were specified.');
0046   end;
0047   
0048   % If no labelName is specified, set it to the yPath.
0049   if(nargin < 4)
0050     labelName = yPath;
0051   end;
0052 
0053   % Create an empty key-value array, if no key-value pairs are specified.
0054   if(nargin<5)
0055     keyValueArray = [];
0056   end;
0057   
0058   % If key-value pairs are given, set it into a struct.
0059   if(nargin > 4)
0060     % If there is an odd number of key-value arguments, give an error, since every key should have a value.
0061     if(mod(length(varargin),2) == 1)
0062       error('Odd number of key-value arguments specified. Please specify each time a key, followed by a value.');
0063     end;
0064     
0065     % Loop through all varargins in pairs of 2.
0066     for i=1:2:length(varargin)
0067       if(~ischar(varargin{i}) || ~ischar(varargin{i+1}))
0068         error('All key-value arguments should be of type string.');
0069       end;
0070       
0071       keyValueStruct = struct('key',varargin{i},'value',varargin{i+1});
0072       keyValueArray(end+1) = keyValueStruct;
0073       
0074     end;
0075     
0076     display(keyValueStruct)
0077     
0078   end;
0079 
0080   % Check if the window and plot are a number or string
0081   if(~isnumeric(window) && ~ischar(window))
0082     error('Please specify the ID of the plot window (numeric) or its name (a string).');
0083   elseif(~ischar(plot) && ~isnumeric(plot))
0084     error('Please specify a string as name for the plot');
0085   end;
0086   
0087   % Check if the path is a string.
0088   if(~ischar(yPath))
0089     error('Please specify the path to the variable you would like to add as a string.');
0090   end;
0091   
0092   % Check if the labelName is a string.
0093   if(~ischar(labelName))
0094     error('Please specify the label name of this curve as a string.');
0095   end;
0096   
0097   % Get the IDs if the input is a string.
0098   windowID = xxsimGetPlotWindowIDFromName(window);
0099   plotID = xxsimGetPlotIDFromName(window,plot);
0100 
0101   % And make the actual call to 20-sim
0102   retval = xrlinvoke('xxsim.plot.addCurveToPlot', struct('windowID',int32(windowID),'plotID',int32(plotID),'xVariablePath','time','yVariablePath',yPath,'zVariablePath','dummy','labelName',labelName,'keyvalues',{{keyValueArray,'array'}}));
0103 
0104 end
0105 %------------- END OF CODE --------------

Generated on Sun 10-Dec-2017 19:24:51