XGraph
class provides an interface for the xgraph
program for plotting data on an X window system display. The modified xgraph
program provided with the Ptolemy distribution should be used, not the contributed version from the X11R5 tape. The constructor for XGraph
does not completely initialize the object; initialization is completed by the initialize()
method:
void initialize(Block* parent, int noGraphs,The
const char* options, const char* title,
const char* saveFile = 0, int ignore = 0);
parent
argument is the name of a Block
that is associated with the XGraph
object; this Block
is used in Error::abortRun
messages to report errors. noGraphs
specifies the number of data sets that the graph will contain. Each data set is a separate stream and is plotted in a different color (a different line style for B/W displays). options
is a series of command line options that will be passed unmodified to the xgraph
program. It is subject to expansion by the Unix shell. title
is the title for the graph; it can contain special characters (it is not
subjected to expansion by the Unix shell). saveFile
is the name of a file to save the graph data into, in ASCII form. If it is not given, the data are not saved, and a faster binary format is used. ignore
specifies the number of initial points to ignore from each data set.
void setIgnore(int n);Reset the "ignore" parameter to
n.
void addPoint(float y);Add a single point to the first data set whose X value is automatically generated (0, 1, 2, 3... on successive calls) and whose Y value is
y.
void addPoint(float x,float y);Add the point (
x,
y)
to the first data set.
void addPoint(int dataSet,float x,float y);Add the point (
x,
y)
to the data set indicated by dataSet.
Data sets start with 1.
void newTrace(int dataSet = 1);Start a new trace for the nth dataset. This means that there will be no connecting line between the last point plotted and the next point plotted.
void terminate();This function flushes the data out to disk, closes the files, and invokes the
xgraph
program. If the destructor is called before terminate,
it will close and delete the temporary files.