D-Bus Interface |
Prev | Developer's Guide to Kpl | Next |
The D-Bus interface allows to control Kpl by other KDE applications and scripts.
A C++ example demo1.cpp
for a KDE application using the
D-Bus interface of Kpl is provided in the directory
$KDEDIR
/lib/qt5/plugins/kpl
or
$KDEDIR
/lib64/qt5/plugins/kpl
in case of
32 or 64 bit installations, respectively, together with
a cmake project file
CMakeLists.txt
. To compile it, copy these two files to
some directory and run cmake ./ and
make there.
An example demo1.py
for a Python script using the
D-Bus interface of Kpl is also provided in that directory.
It essentially does the same as the C++ example.
To test the D-Bus interface of Kpl you also can use the D-Bus utilities qdbus (command line) and qdbusviewer (GUI).
The D-Bus interface of Kpl provides the following functions:
bool openPlot(const QString& url
);
Opens a plot file.
Parameters:
url
URL of the file.
Returns: true when succeeded.
bool openData(const QString& url
);
Opens a data file.
Parameters:
url
URL of the file.
Returns: true when succeeded.
bool savePlot(const QString& url
);
Saves a plot file.
Parameters:
url
URL of the file.
Returns: true when succeeded.
bool savePS(const QString&url
, boollandscape
);
Generates a PostScript file.
Parameters:
url
URL of the file.
landscape
true for landscape orientation.
Returns: true when succeeded.
bool exportImage(const QString& url
);
Exports as a PDF, PNG, PPM, BMP, JPEG, TIFF, or SVG image file.
Parameters:
url
URL of the file.
Returns: true when succeeded.
bool printPlot(const QString&printerName
, const QString&fileName
, boollandscape
, intnumCopies
);
Prints current plot.
Parameters:
printerName
name of the printer.
fileName
name of the output file (empty for output to printer).
landscape
true for landscape orientation.
numCopies
number of copies.
Returns: true when succeeded.
void setAddFilesOption(bool add
);
Sets add files option.
Parameters:
add
true to add plot and data files to existing plots.
void setPathOption(bool absolute
);
Sets path saving option.
Parameters:
absolute
true to save absolute paths.
void setBoundingBoxOption(bool calculate
);
Sets calculate bounding box option.
Parameters:
calculate
true to calculate automatically the box.
void setPageFormat(doublew
, doubleh
);
Sets page size.
Parameters:
w
width in cm.
h
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:
colFrame
color for frame and labels.
colGrid
color for ticks and grid lines.
colData
color for lines and markers.
void setOutputFormat(const QString&pres
, intprec
);
Sets format for numeric output.
Parameters:
pres
printf()
presentation character.
prec
precision.
void setAutoplot(doublex0
, doublew
, doubley0
, doubleh
, intgridmode
, const QString&sx
, const QString&sy
, const QString&sh
, boolpathHeading
, intix
, intiy
, intie
, boollogx
, boollogy
, boolerrbars
, intsymb
, boolautoNorm
, boolautoFit
, doublerelSize
);
Sets Autoplot options.
Parameters:
x0
left page margin in centimeters.
w
width of the data window in centimeters.
y0
bottom page margin in centimeters.
h
height of the data window in centimeters.
gridmode
0 for frame only, 1 for axes with tics, 2 for axes with tics and labels, 3 for grid, 4 for grid with labels.
sx
x axis text.
sy
y axis text.
sh
heading text.
pathHeading
true for heading = path.
ix
x column index.
iy
y column index.
ie
y error column index.
logx
true for logarithmic scaling of x axis.
logy
true for logarithmic scaling of y axis.
errbars
true to plot error bars.
symb
0 for circles, < 0 for different markers, > 0 for different line types.
autoNorm
true for automatic normalization.
autoFit
true for automatic parameter fit.
relSize
relative size of text, markers and lines.
void setAutofit(const QString&path
, const QString&name
, boolnonLin
, boolerrCol
, const QString&errModPath
, const QString&errModName
, intitMax
, doubletol
, intsymb
, const QString&color
, boolshowDlg
, boolsavePar
, boolfollow
);
Sets Autofit parameters.
Parameters:
path
absolute path of the library for the fit function.
name
fit function name.
nonLin
true for nonlinear parameter fits.
errCol
true for data weighing by error column, false for weighing by error model function.
errModPath
absolute path of the library for the error model function.
errModName
error model function name.
itMax
maximum number of iterations (nonlinear fits only).
tol
tolerance level (nonlinear fits only).
symb
function plot: 0 for circles, < 0 for different markers, > 0 for different line types.
color
color for function plot.
showDlg
true to display parameter fit dialog.
savePar
true to save resulting parameter files.
follow
true to follow parameter sets in fit series.
bool loadAutofitPar(const QString& url
);
Loads Autofit function parameters from file.
Parameters:
url
URL of the file.
Returns: true when succeeded.
bool setAutofitPar(intiPar
, doublevalue
);
Sets Autofit function parameter value.
Parameters:
iPar
parameter index.
value
parameter value.
Returns: true when succeeded.
bool enableFitPar(intiPar
, boolfit
);
Enables/disables (Auto)fit function parameter.
Parameters:
iPar
parameter index.
fit
true enables parameter fitting.
Returns: true when succeeded.
bool loadErrModPar(const QString&url
, int iArr);
Loads error model function parameters from file.
Parameters:
url
URL of the file.
iArr
array list index.
Returns: true when succeeded.
bool setErrModPar(intiPar
, doublevalue
, int iArr);
Sets error model function parameter value.
Parameters:
iPar
parameter index.
value
parameter value.
iArr
array list index.
Returns: true when succeeded.
bool deleteItem(int i
);
Deletes plot item.
Parameters:
i
item index.
Returns: true when succeeded.
bool moveItem(intis
, intid
);
Moves plot item.
Parameters:
is
source item index.
id
destination item index.
Returns: true when succeeded.
bool activateItem(inti
, boolactive
);
Sets activation state of plot item.
Parameters:
i
item index.
active
true for visible item.
Returns: true when succeeded.
void newFrameItem(doublex0
, doublew
, doubley0
, doubleh
, doublexmin
, doublexmax
, doubleymin
, doubleymax
, boollogx
, boollogy
, intndigx
, intndigy
, const QString&colFrame
, const QString&colGrid
, doublextic
, doubleytic
, intmticx
, intmticy
, intgridmode
, intiex
, intiey
, const QString&sx
, const QString&sy
, const QString&sh
, doublerelSize
, doublexOff
, doubleyOff
, boolxBottom
, boolxTop
, boolyLeft
, boolyRight
, boolcollapsed
, boolactive
);
Appends new frame item.
Parameters:
x0
left page margin in centimeters.
w
width in centimeters.
y0
bottom page margin in centimeters.
h
height in centimeters.
xmin
x value of left data window margin in user units.
xmax
x value of right data window margin in user units.
ymin
y value of bottom data window margin in user units.
ymax
y value of top window data margin in user units.
logx
true for logarithmic scaling of x axis.
logy
true for logarithmic scaling of y axis.
ndigx
number of digits for x axis.
ndigy
number of digits for y axis.
colFrame
color for frame and labels.
colGrid
color for grids and tics.
xtic
distance between major tics of x axis.
ytic
distance between major tics of y axis.
mticx
number of intervals between major tics of x axis.
mticy
number of intervals between major tics of y axis.
gridmode
0 for frame only, 1 for axes with tics, 2 for axes with tics and labels, 3 for grid, 4 for grid with labels.
iex
logarithm of normalization factor for x axis.
iey
logarithm of normalization factor for y axis.
sx
x axis text.
sy
y axis text.
sh
heading text.
relSize
relative size of text, markers and lines.
xOff
offset for first major x tic.
yOff
offset for first major y tic.
xBottom
true for x axis labels on bottom side.
xTop
true for x axis labels on top side.
yLeft
true for y axis labels on left side.
yRight
true for y axis labels on right side.
collapsed
true for collapsed in list view.
active
true for visible item.
void newAutoFrameItem();
Appends new frame item corresponding to the autoplot settings.
bool newArrayItem(const QString&path
, intix
, intiy
, intie
, intistart
, intn
, boolerrbars
, inttype
, const QString&color
, doublefx
, doublefy
, intiDec
, intfillStyle
, doublexOff
, doubleyOff
, doublerelSize
, boolactive
);
Appends new array item.
Parameters:
path
absolute path of the data file.
ix
x column index.
iy
y column index.
ie
y error column index.
istart
start row index.
n
number of data points.
errbars
true to plot error bars.
type
0 for circles, < 0 for different markers, > 0 for different line types.
color
color for data plot.
fx
normalization factor for x values.
fy
normalization factor for y values.
iDec
0 for decimal point, 1 for comma.
fillStyle
> 0 for filled polygon representation.
xOff
offset for x values.
yOff
offset for y values.
relSize
relative size of lines or symbols.
active
true for visible item.
Returns: true when succeeded.
bool newFunItem(const QString&path
, const QString&name
, doublexmin
, doublexmax
, doubledx
, inttype
, const QString&color
, doublefx
, doublefy
, intfillStyle
, doublexOff
, doubleyOff
, doublerelSize
, boolactive
);
Appends new function item.
Parameters:
path
absolute path of the function library.
name
function name.
xmin
minimum argument value.
xmax
maximum argument value.
dx
argument stepsize.
type
0 for circles, < 0 for different markers, > 0 for different line types.
color
color for function plot.
fx
normalization factor for x values.
fy
normalization factor for y values.
fillStyle
> 0 for filled polygon representation.
xOff
offset for x values.
yOff
offset for y values.
relSize
relative size of lines or symbols.
active
true for visible item.
Returns: true when succeeded.
bool newParFunItem(const QString&pathx
, const QString&namex
, const QString&pathy
, const QString&namey
, doubletmin
, doubletmax
, doubledt
, inttype
, const QString&color
, doublefx
, doublefy
, intfillStyle
, doublexOff
, doubleyOff
, doublerelSize
, boolactive
);
Appends new parametric function item.
Parameters:
pathx
absolute path of the x function library.
namex
x function name.
pathy
absolute path of the y function library.
namey
y function name.
tmin
minimum argument value.
tmax
maximum argument value.
dt
argument stepsize.
type
0 for circles, < 0 for different markers, > 0 for different line types.
color
color for function plot.
fx
normalization factor for x values.
fy
normalization factor for y values.
fillStyle
> 0 for filled polygon representation.
xOff
offset for x values.
yOff
offset for y values.
relSize
relative size of lines or symbols.
active
true for visible item.
Returns: true when succeeded.
void newSplineItem(intderiv
, doublelow
, doublexmin
, doublexmax
, doubledx
, inttype
, const QString&color
, doublefx
, doublefy
, intk
, intfillStyle
, doublexOff
, doubleyOff
, doublerelSize
, boolactive
);
Appends new spline item.
Parameters:
deriv
order of the derivative, 0 for function itself, -1 for integral.
low
lower limit for spline integral.
xmin
minimum argument value.
xmax
maximum argument value.
dx
argument step size.
type
0 for circles, < 0 for different markers, > 0 for different line types.
color
color for spline function plot.
fx
normalization factor for x values.
fy
normalization factor for y values.
k
degree of spline.
fillStyle
> 0 for filled polygon representation.
xOff
offset for x values.
yOff
offset for y values.
relSize
relative size of lines or symbols.
active
true for visible item.
bool newArray3DItem(doublex0
, doublew
, doubley0
, doubleh
, doublexmin
, doublexmax
, doubleymin
, doubleymax
, doublezmin
, doublezmax
, boollogx
, boollogy
, boollogz
, intndigx
, intndigy
, intndigz
, const QString&colFrame
, const QString&colGrid
, const QString&colData
, doublextic
, doubleytic
, doubleztic
, intmticx
, intmticy
, intmticz
, boolframe
, intgridmode
, intgridmode3D
, doublexBox
, doubleyBox
, doublezBox
, doublexRef
, doubleyRef
, doublephi
, doubletheta
, intiex
, intiey
, intiez
, const QString&sx
, const QString&sy
, const QString&sz
, const QString&sh
, doublerelSize
, const QString&path
, intix
, intiy
, intiz
, intie
, intistart
, intn
, boolerrbars
, doublesmf
, doubledx
, doubledz
, doublefx
, doublefy
, doublefz
, intiDec
, boolcollapsed
, boolactive
);
Appends new 3D array item.
Parameters:
x0
left page margin in centimeters.
w
width in centimeters.
y0
bottom page margin in centimeters.
h
height in centimeters.
xmin
minimum x value.
xmax
maximum x value.
ymin
minimum y value.
ymax
maximum y value.
zmin
minimum z value.
zmax
maximum z value.
logx
true for logarithmic scaling of x axis.
logy
true for logarithmic scaling of y axis.
logz
true for logarithmic scaling of z axis.
ndigx
number of digits for x axis.
ndigy
number of digits for y axis.
ndigz
number of digits for z axis.
colFrame
color for frame and labels.
colGrid
color for tics.
colData
color for surface.
xtic
distance between major tics of x axis.
ytic
distance between major tics of y axis.
ztic
distance between major tics of z axis.
mticx
number of intervals between major tics of x axis.
mticy
number of intervals between major tics of y axis.
mticz
number of intervals between major tics of z axis.
frame
true to show frame.
gridmode
0 for frame only, 1 for axes with tics, 2 for axes with tics and labels.
gridmode3D
0 for lines parallel to x, 1 for lines parallel to z, 2 for grid.
xBox
x box width in cm.
yBox
y box width in cm.
zBox
z box width in cm.
xRef
x position of center of box bottom plane.
yRef
y position of center of box bottom plane.
phi
angle of rotation about y axis in deg.
theta
tilt angle of y axis in deg.
iex
logarithm of normalization factor for x axis.
iey
logarithm of normalization factor for y axis.
iez
logarithm of normalization factor for z axis.
sx
x axis text.
sy
y axis text.
sz
z axis text.
sh
heading text.
relSize
relative size of text and lines.
path
absolute path of the data file.
ix
x column index.
iy
y column index.
iz
z column index.
ie
y error column index.
istart
start row index.
n
number of data points.
errbars
true to use error bars for weighing y values.
smf
smoothing factor.
dx
x grid stepsize.
dz
z grid stepsize.
fx
normalization factor for x values.
fy
normalization factor for y values.
fz
normalization factor for z values.
iDec
0 for decimal point, 1 for comma.
collapsed
true for collapsed in list view.
active
true for visible item.
Returns: true when succeeded.
bool newFun3DItem(doublex0
, doublew
, doubley0
, doubleh
, doublexmin
, doublexmax
, doubleymin
, doubleymax
, doublezmin
, doublezmax
, boollogx
, boollogy
, boollogz
, intndigx
, intndigy
, intndigz
, const QString&colFrame
, const QString&colGrid
, const QString&colData
, doublextic
, doubleytic
, doubleztic
, intmticx
, intmticy
, intmticz
, boolframe
, intgridmode
, intgridmode3D
, doublexBox
, doubleyBox
, doublezBox
, doublexRef
, doubleyRef
, doublephi
, doubletheta
, intiex
, intiey
, intiez
, const QString&sx
, const QString&sy
, const QString&sz
, const QString&sh
, doublerelSize
, const QString&path
, const QString&name
, doubledx
, doubledz
, doublefx
, doublefy
, doublefz
, boolcollapsed
, boolactive
);
Appends new 3D function item.
Parameters:
x0
left page margin in centimeters.
w
width in centimeters.
y0
bottom page margin in centimeters.
h
height in centimeters.
xmin
minimum x value.
xmax
maximum x value.
ymin
minimum y value.
ymax
maximum y value.
zmin
minimum z value.
zmax
maximum z value.
logx
true for logarithmic scaling of x axis.
logy
true for logarithmic scaling of y axis.
logz
true for logarithmic scaling of z axis.
ndigx
number of digits for x axis.
ndigy
number of digits for y axis.
ndigz
number of digits for z axis.
colFrame
color for frame and labels.
colGrid
color for tics.
colData
color for surface.
xtic
distance between major tics of x axis.
ytic
distance between major tics of y axis.
ztic
distance between major tics of z axis.
mticx
number of intervals between major tics of x axis.
mticy
number of intervals between major tics of y axis.
mticz
number of intervals between major tics of z axis.
frame
true to show frame.
gridmode
0 for frame only, 1 for axes with tics, 2 for axes with tics and labels.
gridmode3D
0 for lines parallel to x, 1 for lines parallel to z, 2 for grid.
xBox
x box width in cm.
yBox
y box width in cm.
zBox
z box width in cm.
xRef
x position of center of box bottom plane.
yRef
y position of center of box bottom plane.
phi
angle of rotation about y axis in deg.
theta
tilt angle of y axis in deg.
iex
logarithm of normalization factor for x axis.
iey
logarithm of normalization factor for y axis.
iez
logarithm of normalization factor for z axis.
sx
x axis text.
sy
y axis text.
sz
z axis text.
sh
heading text.
relSize
relative size of text and lines.
path
absolute path of the function library.
name
function name.
dx
x argument stepsize.
dz
z argument stepsize.
fx
normalization factor for x values.
fy
normalization factor for y values.
fz
normalization factor for z values.
collapsed
true for collapsed in list view.
active
true for visible item.
Returns: true when succeeded.
void newImageItem(const QString&path
, doublex
, doubley
, doublefx
, doublefy
, doubledir
, boolactive
);
Appends new image item.
Parameters:
path
absolute path of the EPS file.
x
x position in cm.
y
y position in cm.
fx
horizontal scaling factor.
fy
vertical scaling factor.
dir
rotation angle in degree.
active
true for visible item.
void newLegendItem(inttype
, const QString&colSymb
, doublex
, doubley
, const QString&text
, const QString&colText
, doublexoff
, doubleyoff
, doublerelSize
, doublesymbolSize
, boolactive
);
Appends new legend item.
Parameters:
type
0 for circles, < 0 for different markers, > 0 for different line types.
colSymb
color for marker or line.
x
x position in cm.
y
y position in cm.
text
legend text.
colText
color for text.
xoff
x offset for text in cm.
yoff
y offset for text in cm.
relSize
relative size of text.
symbolSize
relative size of symbol.
active
true for visible item.
void newTextItem(const QString&text
, const QString&color
, intalign
, doublex
, doubley
, doubledir
, doublerelSize
, boolactive
);
Appends new text item.
Parameters:
text
text.
color
color for text.
align
1: left aligned, 2: centered, 3: right aligned.
x
x position in cm.
y
y position in cm.
dir
direction in degree.
relSize
relative size of text.
active
true for visible item.
void newLineItem(inttype
, const QString&color
, doublex
, doubley
, doubledir
, doublelen
, doublerelSize
, boolactive
);
Appends new line item.
Parameters:
type
1 to 9 for different line types.
color
color for line.
x
x start position in cm.
y
y start position in cm.
dir
direction in degree.
len
length in cm.
relSize
relative width.
active
true for visible item.
void newArrowItem(inttype
, const QString&color
, doublex
, doubley
, doubledir
, doublelen
, doublerelSize
, booldoubleHeaded
, boolactive
);
Appends new arrow item.
Parameters:
type
1 to 9 for different line types.
color
color for arrow.
x
x position of head in cm.
y
y position of head in cm.
dir
direction in degree.
len
length in cm.
relSize
relative width.
doubleHeaded
true for doubleheaded arrow.
active
true for visible item.
Returns: true when succeeded.
void newArcItem(inttype
, const QString&color
, doublex
, doubley
, doublew
, doubleh
, doublestart
, doublespan
, doublerelSize
, doubledir
, boolactive
);
Appends new elliptic arc item.
Parameters:
type
1 to 9 for different line types.
color
color of the arc.
x
x position of center in cm.
y
y position of center in cm.
w
width of ellipse in cm.
h
height of ellipse in cm.
start
start angle in degree.
span
length in degree.
relSize
relative line width.
dir
rotation angle in degree.
active
true for visible item.
void newRectangleItem(inttype
, const QString&color
, doublex
, doubley
, doublew
, doubleh
, doublerelSize
, intfillStyle
, doubledir
, boolactive
);
Appends new rectangle item.
Parameters:
type
1 to 9 for different line types.
color
color of the rectangle.
x
x position of left side in cm.
y
y position of bottom side in cm.
w
width in cm.
h
height in cm.
relSize
relative line width.
fillStyle
> 0 for filled polygon representation.
dir
rotation angle in degree.
active
true for visible item.
void newEllipseItem(inttype
, const QString&color
, doublex
, doubley
, doublew
, doubleh
, doublerelSize
, intfillStyle
, doubledir
, boolactive
);
Appends new ellipse item.
Parameters:
type
1 to 9 for different line types.
color
color of the ellipse.
x
x position of center in cm.
y
y position of center in cm.
w
width in cm.
h
height in cm.
relSize
relative line width.
fillStyle
> 0 for filled ellipse representation.
dir
rotation angle in degree.
active
true for visible item.
void newScaleBarItem(const QString&str
, const QString&color
, doublex
, doubley
, doublelen
, doublerelSize
, boolvertical
, boolactive
);
Appends new scale bar item.
Parameters:
str
Text.
color
color of the scale bar.
x
x position in cm.
y
y position in cm.
len
length in cm.
relSize
relative line width.
vertical
false for horizontal, true for vertical.
active
true for visible item.
bool autoScaleFrame(inti
, boolautoNorm
);
Scales frame automatically according to all items belonging to it.
Parameters:
i
index of frame item.
autoNorm
true for additional automatic normalization.
Returns: true when succeeded.
bool loadPar(const QString&url
, inti
, boolyFun
);
Loads set of function parameters from file.
Parameter:
url
URL of file.
i
Index of function item.
yFun
true for y function parameters, false for x function parameters (only for parametric functions).
Returns: true when succeeded.
bool setPar(inti
, intiPar
, doublevalue
, boolyFun
);
Sets value of a function parameter.
Parameter:
i
index of function item.
iPar
index of parameter.
value
value of parameter.
yFun
true for y function parameters, false for x function parameters (only for parametric functions).
Returns: true when succeeded.
bool setArrayRange(inti
, intiStart
, intn
);
Sets range of rows of an array.
Parameter:
i
Index of array item.
iStart
start index of rows.
n
number of data points.
Returns: true when succeeded.
bool addFitItems(boolerase
, intiArr
, intiFun
, boolerrCol
, const QString&errModPath
, const QString&errModName
);
Adds array and function items to a list for (multidimensional) parameter fits.
Parameter:
erase
true: clears list first.
iArr
index of array item.
iFun
index of function item.
errCol
true for weighing of data points by error column, false for weighing by error model function.
errModPath
absolute path of library containing the error model function.
errModName
name of the error model function.
Returns: true when succeeded.
bool addFunFitItem(int iFun
);
Adds a function item to a list for (multidimensional) parameter fits.
Parameter:
iFun
index of function item.
Returns: true when succeeded.
bool fit(boolnonLin
, boolsavePar
, boolfollow
);
Performs parameter fit.
Parameters:
nonLin
true for nonlinear parameter fits.
savePar
true to save resulting parameter files.
follow
true to follow parameter sets in fit series.
Returns: true when succeeded.
bool addSplineFitItem(boolerase
, intiSpl
);
Adds a spline item to a list for spline fitting.
Parameter:
erase
true: clears list first.
iSpl
index of spline item.
Returns: true when succeeded.
bool splineFit(intiArr
, intdeg
, doublesmf
, doublexmin
, doublexmax
, boolerrCol
, const QString&errModPath
, const QString&errModName
);
Performs smoothing spline fit.
Parameters:
iArr
array item index.
deg
degree of spline.
smf
smoothing factor.
xmin
lower boundary of approximation interval.
xmax
upper boundary of approximation interval.
errCol
true for data weighing by error column, false for weighing by error model function.
errModPath
absolute path of the library for the error model function.
errModName
error model function name.
Returns: true when succeeded.
bool saveFitPar(const QString& url
);
Saves parameters and their errors resulting from a fit to a file.
Parameters:
url
URL of the file.
Returns: true when succeeded.
Prev | Contents | Next |
Developer's Guide to Kpl | Up | Class Library libkpl |