Next: Older C APIs, Previous: C Programming, Up: C Programming
GNU libplot
has bindings for several programming languages.
Regardless of which binding is used, the concepts behind libplot
(Plotters, and a fixed set of operations that may be applied to any
Plotter) remain the same. However, the ways in which Plotters are
manipulated (created, selected for use, and deleted) may differ
between bindings. This section discusses the current C binding.
For information on older C bindings, see Older C APIs.
In the C binding, a Plotter is implemented as an opaque datatype,
plPlotter
, which must be accessed through a pointer. Each
drawing operation takes a pointer to a plPlotter
as its first
argument. The functions pl_newpl_r
and pl_deletepl_r
are
the constructor and destructor for the plPlotter
datatype. The
final argument of pl_newpl_r
must be a pointer to a
plPlotterParams
object, which specifies Plotter parameters.
pl_newpl_r
returns a pointer to a plPlotter
.
You should always call pl_deletepl_r
when you are finished using
a Plotter. In general, Plotters that do not plot graphics in real time
(Postscript Plotters and CGM Plotters in particular) write out
graphics only when pl_deletepl_r
is called.
The following tables summarize the action of the Plotter manipulation functions in the C binding.
All Plotter parameters will be copied from the plPlotterParams
object pointed to by params. A NULL return value indicates
the Plotter could not be created.
The functions pl_newplparams
, pl_deleteplparams
, and
pl_copyplparams
are the constructor, destructor, and copy
constructor for the plPlotterParams
datatype. The function
pl_setplparam
sets any single Plotter parameter in a
plPlotterParams
object.
char *
, i.e., a string. If value is NULL,
the parameter is unset.
For a list of recognized parameters and their meaning, see Plotter Parameters. Unrecognized parameters are ignored.
The reason why the plPlotterParams
datatype exists is that even
though the Plotter interface is largely Plotter-independent, it is
useful to be able to specify certain aspects of a Plotter's behavior at
creation time. If a a parameter has been set in the specified
plPlotterParams
object, that will be the value used by the
Plotter. If a parameter is not set, the Plotter will use a
default value for it, unless the parameter is string-valued and
there is an environment variable of the same name, in which case the
value of that environment variable will be used. This rule increases
run-time flexibility: an application programmer may allow
non-critical Plotter parameters to be specified by the user via
environment variables.
In the C binding, each drawing operation that may be invoked on a
Plotter is represented by a function whose name begins with "pl_" and
ends with "_r". For example, the openpl
operation is invoked on
a Plotter by calling the function pl_openpl_r
, the first argument
of which is a pointer to the corresponding plPlotter
object.