The DCOP interface allows to control Kpl by other KDE applications and scripts.
For a KDE application which should make use of the DCOP interface of Kpl you should include the header file kpl_stub.h, which is installed in the directory $KDEDIR/include. You also need to compile the file kpl_stub.cpp in $KDEDIR/share/apps/kpl and link it to your application. These two files provide the DCOP interface functions of Kpl as methods of the class KplApp_stub. A C++ example demo1.cpp which makes use of them is installed in $KDEDIR/share/apps/kpl.
The KDE XmlRpc Daemon (kxmlrpcd) provides a way to use the DCOP interface of Kpl from scripts written in several languages by remote procedure calls (RPC) with XML and HTTP, even running on another platform. An example demo1.py written in Python is installed in $KDEDIR/share/apps/kpl. It essentially does the same as the C++ example. To run it, you need to unzip the Python XML-RPC library http://www.pythonware.com/downloads/xmlrpc-0.9.8-990621.zip into your Python directory (/usr/lib/python1.5, for instance). Note that the authentification mechanism of kxmlrpcd needs the authentification string as the very first parameter of each interface function call.
To test the DCOP interface of Kpl you also can use the KDE DCOP utilities dcop (command line) and kdcop (GUI).
Unfortunately on several installations the XmlRpc Daemon of KDE 2.1.1 still fails resulting in errors due to uncomplete remote procedure calls, when more than 1 Kbytes have to be transferred. This will happen when using functions with very long parameter lists like newFrameItem() (see below). As a workaround, until the problem is fixed in a more profound way, you can apply a patch to the source code of kxmlrpcd. The patch file named kxmlrpcserver-patch is installed in $KDEDIR/share/apps/kpl. It simply increases the size of a buffer from 1 K to 4 K. You will have to unpack the source package of kdebase-2.1.1 (available on ftp://ftp.kde.org/pub/kde/) and to apply the patch in the directory kdebase-2.1.1/kxmlrpc by running
% patch -p0 < kxmlrpcserver-patch |
After that you should run
% ./configure |
in the directory kdebase-2.1.1 and (at least in the directory kdebase-2.1.1/kxmlrpc)
% make |
and (as root)
% make install |
The patched version of kxmlrpc then will be active when you login next time.
The DCOP interface of Kpl provides the following functions:
bool openPlot(const QString& url); |
Opens a plot file.
Parameters:
URL of the file.
Returns: true when succeeded.
bool openData(const QString& url); |
Opens a data file.
Parameters:
URL of the file.
Returns: true when succeeded.
bool savePlot(const QString& url); |
Saves a plot file.
Parameters:
URL of the file.
Returns: true when succeeded.
bool savePS(const QString& url, int landscape); |
Generates a PostScript file.
Parameters:
URL of the file.
true for landscape orientation.
Returns: true when succeeded.
bool printPlot(const QString& printerName, const QString& fileName, int landscape, int numCopies); |
Prints current plot.
Parameters:
name of the printer.
name of the output file (empty for output to printer).
true for landscape orientation.
number of copies.
Returns: true when succeeded.
void setAutoplotOption(int setting); |
Sets autoplot option.
Parameters:
true to plot automatically after changes.
void setAddFilesOption(int setting); |
Sets add files option.
Parameters:
true to add plot and data files to existing plots.
void setPathOption(int setting); |
Sets path saving option.
Parameters:
true to save absolute paths.
void setBoundingBoxOption(int setting); |
Sets calculate PS bounding box option.
Parameters:
true to calculate automatically the box.
void setPageFormat(double w, double h); |
Sets page size.
Parameters:
width in cm.
height in cm.
void setColors(const QString& colFrame, const QString& colGrid, const QString& colData); |
Sets default colors (hex-encoded RGB strings, example: "ff" for red).
Parameters:
color for frame and labels.
color for ticks and grid lines.
color for lines and markers.
void setOutputFormat(const QString& pres, int prec); |
Sets format for numeric output.
Parameters:
printf() presentation character.
precision.
void setAutoplot(double x0, double w, double y0, double h, int gridmode, const QString& sx, const QString& sy, const QString& sh, int pathHeading, int ix, int iy, int ie, int logx, int logy, int errbars, int symb, int autoNorm, int autoFit); |
Sets Autoplot options.
Parameters:
left page margin in centimeters.
width of the data window in centimeters.
bottom page margin in centimeters.
height of the data window in centimeters.
0 for frame only, 1 for axes with tics, 2 for axes with tics and labels, 3 for grid, 4 for grid with labels.
x axis text.
y axis text.
heading text.
true for heading = path.
x column index.
y column index.
y error column index.
true for logarithmic scaling of x axis.
true for logarithmic scaling of y axis.
true to plot error bars.
0 for circles, < 0 for different markers, >0 for different line types.
true for automatic normalization.
true for automatic parameter fit.
void setAutofit(const QString& path, const QString& name, int nonLin, int errCol, const QString& errModPath, const QString& errModName, int itMax, double tol, int symb, const QString& color, int showDlg, int savePar, int follow); |
Sets Autofit parameters.
Parameters:
absolute path of the library for the fit function.
fit function name.
true for nonlinear parameter fits.
true for data weighing by error column, false for weighing by error model function.
absolute path of the library for the error model function.
error model function name.
maximum number of iterations (nonlinear fits only).
tolerance level (nonlinear fits only).
function plot: 0 for circles, < 0 for different markers, >0 for different line types.
color for function plot.
true to display parameter fit dialog.
true to save resulting parameter files.
true to follow parameter sets in fit series.
bool loadAutofitPar(const QString& url); |
Loads Autofit function parameters from file.
Parameters:
URL of the file.
Returns: true when succeeded.
bool setAutofitPar(int iPar, double value); |
Sets Autofit function parameter value.
Parameters:
parameter index.
parameter value.
Returns: true when succeeded.
bool enableFitPar(int iPar, int fit); |
Enables/disables (Auto)fit function parameter.
Parameters:
parameter index.
true enables parameter fitting.
Returns: true when succeeded.
bool loadErrModPar(const QString& url, int iArr); |
Loads error model function parameters from file.
Parameters:
URL of the file.
array list index.
Returns: true when succeeded.
bool setErrModPar(int iPar, double value, int iArr); |
Sets error model function parameter value.
Parameters:
parameter index.
parameter value.
array list index.
Returns: true when succeeded.
bool deleteItem(int iItem); |
Deletes plot item.
Parameters:
item index.
Returns: true when succeeded.
bool moveItem(int is, int id); |
Moves plot item.
Parameters:
source item index.
destination item index.
Returns: true when succeeded.
void newFrameItem(double x0, double w, double y0, double h, double xmin, double xmax, double ymin, double ymax, int logx, int logy, int ndigx, int ndigy, const QString& colFrame, const QString& colGrid, double xtic, double ytic, int mticx, int mticy, int gridmode, int iex, int iey, const QString& sx, const QString& sy, const QString& sh, double relSize, int active); |
Appends new frame item.
Parameters:
left page margin in centimeters.
width in centimeters.
bottom page margin in centimeters.
height in centimeters.
x value of left data window margin in user units.
x value of right data window margin in user units.
y value of bottom data window margin in user units.
y value of top window data margin in user units.
true for logarithmic scaling of x axis.
true for logarithmic scaling of y axis.
number of digits for x axis.
number of digits for y axis.
color for frame and labels.
color for grids and tics.
distance between major tics of x axis.
distance between major tics of y axis.
number of intervals between major tics of x axis.
number of intervals between major tics of y axis.
0 for frame only, 1 for axes with tics, 2 for axes with tics and labels, 3 for grid, 4 for grid with labels.
logarithm of normalization factor for x axis.
logarithm of normalization factor for y axis.
x axis text.
y axis text.
heading text.
relative size of text, markers and lines.
true for visible item.
bool newArrayItem(const QString& path, int ix, int iy, int ie, int istart, int n, int errbars, int symb, const QString& color, double fx, double fy, int active); |
Appends new array item.
Parameters:
absolute path of the data file.
x column index.
y column index.
y error column index.
start row index.
number of data points.
true to plot error bars.
0 for circles, < 0 for different markers, >0 for different line types.
color for data plot.
normalization factor for x values.
normalization factor for y values.
true for visible item.
Returns: true when succeeded.
bool newFunItem(const QString& path, const QString& name, double xmin, double xmax, double dx, int symb, const QString& color, double fx, double fy, int active); |
Appends new function item.
Parameters:
absolute path of the function library.
function name.
minimum argument value.
maximum argument value.
argument stepsize.
0 for circles, < 0 for different markers, >0 for different line types.
color for function plot.
normalization factor for x values.
normalization factor for y values.
true for visible item.
Returns: true when succeeded.
bool newParFunItem(const QString& pathx, const QString& namex, const QString& pathy, const QString& namey, double tmin, double tmax, double dt, int symb, const QString& color, double fx, double fy, int active); |
Appends new parametric function item.
Parameters:
absolute path of the x function library.
x function name.
absolute path of the y function library.
y function name.
minimum argument value.
maximum argument value.
argument stepsize.
0 for circles, < 0 for different markers, >0 for different line types.
color for function plot.
normalization factor for x values.
normalization factor for y values.
true for visible item.
Returns: true when succeeded.
void newLegendItem(int symb, const QString& colSymb, double x, double y, const QString& text, const QString& colText, double xoff, double yoff, double relSize, int active); |
Appends new legend item.
Parameters:
0 for circles, < 0 for different markers, >0 for different line types.
color for marker or line.
x position in cm.
y position in cm.
legend text.
color for text.
x offset for text in cm.
y offset for text in cm.
relative size of text.
true for visible item.
void newTextItem(const QString& text, const QString& color, int align, double x, double y, double dir, double relSize, int active); |
Appends new text item.
Parameters:
text.
color for text.
1: left aligned, 2: centered, 3: right aligned.
x position in cm.
y position in cm.
direction in degree.
relative size of text.
true for visible item.
void newLineItem(int symb, const QString& color, double x, double y, double dir, double len, double relSize, int active); |
Appends new line item.
Parameters:
1 to 9 for different line types.
color for line.
x start position in cm.
y start position in cm.
direction in degree.
length in cm.
relative width.
true for visible item.
void newArrowItem(const QString& color, double x, double y, double dir, double len, double relSize, int active); |
Appends new arrow item.
Parameters:
color for arrow.
x position of head in cm.
y position of head in cm.
direction in degree.
total length in cm.
relative size of arrow head.
true for visible item.
void newRectangleItem(const QString& color, double x, double y, double w, double h, double relSize, int fill, int active); |
Appends new rectangle item.
Parameters:
color for rectangle.
x position of left side in cm.
y position of bottom side in cm.
width in cm.
height in cm.
relative line width.
true for rectangle filled with color.
true for visible item.
void newEllipseItem(const QString& color, double x, double y, double w, double h, double relSize, int fill, int active); |
Appends new ellipse item.
Parameters:
color for ellipse.
x position of center in cm.
y position of center in cm.
width in cm.
height in cm.
relative line width.
true for ellipse filled with color.
true for visible item.
bool autoScaleFrame(int iItem, int autoNorm); |
Scales frame automatically corresponding to all child items.
Parameters:
item index.
true for automatic normalization.
Returns: true when succeeded.
bool loadPar(const QString& url, int iItem, int yFun); |
Loads function parameters from file.
Parameters:
URL of the file.
item index.
true for y function parameter, false for x function parameter (only for parametric functions).
Returns: true when succeeded.
bool setPar(int iItem, int iPar, double value, int yFun); |
Sets function parameter value.
Parameters:
item index.
parameter index.
parameter value.
true for y function parameter, false for x function parameter (only for parametric functions).
Returns: true when succeeded.
bool setArrayRange(int iItem, int iStart, int n); |
Sets array row range.
Parameters:
item index.
start row index.
number of data points.
Returns: true when succeeded.
bool addFitItems(int erase, int iArr, int iFun, int errCol, const QString& errModPath, const QString& errModName); |
Adds array and function items to item lists for (multidimensional) parameter fitting.
Parameters:
erases lists first when true.
array item index.
function item index.
true for data weighing by error column, false for weighing by error model function.
absolute path of the library for the error model function.
error model function name.
Returns: true when succeeded.
bool fit(int nonLin, int savePar, int follow); |
Performs parameter fit.
Parameters:
true for nonlinear parameter fits.
true to save resulting parameter files.
true to follow parameter sets in fit series.
Returns: true when succeeded.
bool saveFitPar(const QString& url); |
Saves parameters and their errors resulting from a fit to a file.
Parameters:
URL of the file.
Returns: true when succeeded.
bool exportValues(const QString& url, int iItem); |
Exports function value table to file.
Parameters:
URL of the file.
item index.
Returns: true when succeeded.