<chapter id="dcop">
	<title>Scripting &kmplot;</title>
	<para>A new feature in &kde; 3.4 is that you can write scripts for &kmplot; using &DBus; in &kde; 4. For example, if you want to define a new function <userinput>f(x)=2sin x+3cos 
x</userinput>, set its line width to 20 and then draw it, you type in a console:</para>
	<para><command>qdbus org.kde.kmplot-PID /parser org.kde.kmplot.Parser.addFunction "f(x)=2sin x+3cos x" ""</command>
		As a result, the new function's id number will be returned, or -1 if the function could not be defined.</para>
	<para><command>qdbus org.kde.kmplot-PID /parser org.kde.kmplot.Parser.setFunctionFLineWidth ID 20</command>
		This command sets the function with the id number ID the line width to 20.</para>
	<para><command>qdbus org.kde.kmplot-PID /view org.kde.kmplot.View.drawPlot</command>
	This command repaints the window so that the function get visible.</para>
<para>
	A list of the available functions:
	<variablelist>
		<varlistentry>
			<term>
				/kmplot org.kde.kmplot.KmPlot.fileOpen url
			</term>
			<listitem>
				<para>Load the file <parameter>url</parameter>.</para>
			</listitem>
		</varlistentry>
		<varlistentry>
			<term>
				/maindlg org.kde.kmplot.MainDlg.isModified
			</term>
			<listitem>
				<para>Returns true if any changes are done.</para>
			</listitem>
		</varlistentry>
		<varlistentry>
			<term>
				/maindlg org.kde.kmplot.MainDlg.checkModified
			</term>
			<listitem>
				<para>If there are any unsaved changes, a dialog appears to save, discard or cancel the plots.</para>
			</listitem>
		</varlistentry>
		<varlistentry>
			<term>
				/maindlg org.kde.kmplot.MainDlg.editAxes
			</term>
			<listitem>
				<para>Opens the coordinate system edit dialog.</para>
			</listitem>
		</varlistentry>
		<varlistentry>
			<term>
				/maindlg org.kde.kmplot.MainDlg.toggleShowSlider
			</term>
			<listitem>
				<para>Shows/hides parameter slider window.</para>
			</listitem>
		</varlistentry>
		<varlistentry>
			<term>
				/maindlg org.kde.kmplot.MainDlg.slotSave
			</term>
			<listitem>
				<para>Saves the functions (opens the save dialog if it is a new file).</para>
			</listitem>
		</varlistentry>
		<varlistentry>
			<term>
				/maindlg org.kde.kmplot.MainDlg.slotSaveas
			</term>
			<listitem>
				<para>The same as choosing <menuchoice><guimenu>File</guimenu><guimenuitem>Save As</guimenuitem></menuchoice> in the menu.</para>
			</listitem>
		</varlistentry>
		<varlistentry>
			<term>
				/maindlg org.kde.kmplot.MainDlg.slotPrint
			</term>
			<listitem>
				<para>Opens the print dialog.</para>
			</listitem>
		</varlistentry>
		<varlistentry>
			<term>
				/maindlg org.kde.kmplot.MainDlg.slotResetView
			</term>
			<listitem>
				<para>The same as choosing <menuchoice><guimenu>View</guimenu><guimenuitem>Reset View</guimenuitem></menuchoice> in the menu.</para>
			</listitem>
		</varlistentry>
		<varlistentry>
			<term>
				/maindlg org.kde.kmplot.MainDlg.slotExport
			</term>
			<listitem>
				<para>Opens the export dialog.</para>
			</listitem>
		</varlistentry>
		<varlistentry>
			<term>
				/maindlg org.kde.kmplot.MainDlg.slotSettings
			</term>
			<listitem>
				<para>Opens the settings dialog.</para>
			</listitem>
		</varlistentry>
		<varlistentry>
			<term>
				/maindlg org.kde.kmplot.MainDlg.slotNames
			</term>
			<listitem>
				<para>Shows the predefined math functions in the handbook.</para>
			</listitem>
		</varlistentry>
		<varlistentry>
			<term>
				/maindlg org.kde.kmplot.MainDlg.findMinimumValue
			</term>
			<listitem>
				<para>The same as choosing <menuchoice><guimenu>Tools</guimenu><guimenuitem>Minimum Value...</guimenuitem></menuchoice> in the menu.</para>
			</listitem>
		</varlistentry>
		<varlistentry>
			<term>
				/maindlg org.kde.kmplot.MainDlg.findMaximumValue
			</term>
			<listitem>
				<para>The same as choosing <menuchoice><guimenu>Tools</guimenu><guimenuitem>Maximum Value...</guimenuitem></menuchoice> in the menu.</para>
			</listitem>
		</varlistentry>
		<varlistentry>
			<term>
				/maindlg org.kde.kmplot.MainDlg.graphArea
			</term>
			<listitem>
				<para>The same as choosing <menuchoice><guimenu>Tools</guimenu><guimenuitem>Plot Area</guimenuitem></menuchoice> in the menu.</para>
			</listitem>
		</varlistentry>
		<varlistentry>
			<term>
				/maindlg org.kde.kmplot.MainDlg.calculator
			</term>
			<listitem>
				<para>The same as choosing <menuchoice><guimenu>Tools</guimenu><guimenuitem>Calculator</guimenuitem></menuchoice> in the menu.</para>
			</listitem>
		</varlistentry>
		<varlistentry>
			<term>
				/parser org.kde.kmplot.Parser.addFunction f_str0 f_fstr1
			</term>
			<listitem>
				<para>Adds a new function with the expressions <parameter>f_str0</parameter> and <parameter>f_str1</parameter>. If the expression does not contain a function name, it will be auto-generated. The id number of the new function is returned, or -1 if the function could not be defined.</para>
			</listitem>
		</varlistentry>
		<varlistentry>
			<term>
				/parser org.kde.kmplot.Parser.removeFunction id
			</term>
			<listitem>
				<para>Removes the function with the id number <parameter>id</parameter>. If the function could not be deleted, false is returned, otherwise true.</para>
			</listitem>
		</varlistentry>
		<varlistentry>
			<term>
				/parser org.kde.kmplot.Parser.setFunctionExpression id eq f_str
			</term>
			<listitem>
				<para>Sets the expression for the function with the id number <parameter>id</parameter> to <parameter>f_str</parameter>. Returns true if it succeed, otherwise false.</para>
			</listitem>
		</varlistentry>
		<varlistentry>
			<term>
				/parser org.kde.kmplot.Parser.countFunctions
			</term>
			<listitem>
				<para>Returns the number of functions (parametric functions are calculated as two).</para>
			</listitem>
		</varlistentry>
<!-- method double org.kde.kmplot.Parser.fkt(uint id, uint eq, double eq) what is this?-->
		<varlistentry>
		  <term>
		    /parser org.kde.kmplot.Parser.listFunctionNames
		  </term>
		  <listitem>
		    <para>Returns a list with all functions.</para>
		  </listitem>
		</varlistentry>
		<varlistentry>
		  <term>
		    /parser org.kde.kmplot.Parser.fnameToID f_str
		  </term>
		  <listitem>
		    <para>Returns the id number of <parameter>f_str</parameter> or -1 if the function name <parameter>f_str</parameter> was not found.</para>
		  </listitem>
		</varlistentry>
		<varlistentry>
		  <term>
		    /parser org.kde.kmplot.Parser.functionFVisible id
		  </term>
		  <listitem>
		    <para>Returns true if the function with the ID <parameter>id</parameter> is visible, otherwise false.</para>
		  </listitem>
		</varlistentry>
		<varlistentry>
		  <term>
		    /parser org.kde.kmplot.Parser.functionF1Visible id
		  </term>
		  <listitem>
		    <para>Returns true if the first derivative of the function with the ID <parameter>id</parameter> is visible, otherwise false.</para>
		  </listitem>
		</varlistentry>
		<varlistentry>
		  <term>
		    /parser org.kde.kmplot.Parser.functionF2Visible id
		  </term>
		  <listitem>
		    <para>Returns true if the second derivative of the function with the ID <parameter>id</parameter> is visible, otherwise false.</para>
		  </listitem>
		</varlistentry>
		<varlistentry>
		  <term>
		    /parser org.kde.kmplot.Parser.functionIntVisible id
		  </term>
		  <listitem>
		    <para>Returns true if the integral of the function with the ID <parameter>id</parameter> is visible, otherwise false.</para>
		  </listitem>
		</varlistentry>
		<varlistentry>
		  <term>
		    /parser org.kde.kmplot.Parser.setFunctionFVisible id visible
		  </term>
		  <listitem>
		    <para>Shows the function with the ID <parameter>id</parameter> if <parameter>visible</parameter> is true. If <parameter>visible</parameter> is false, the function will be hidden. True is returned if the function exists, otherwise false</para>
		  </listitem>
		</varlistentry>
		<varlistentry>
		  <term>
		    /parser org.kde.kmplot.Parser.setFunctionF1Visible id visible
		  </term>
		  <listitem>
		    <para>Shows the first derivative of the function with the ID <parameter>id</parameter> if <parameter>visible</parameter> is true. If <parameter>visible</parameter> is false, the function will be hidden. True is returned if the function exists, otherwise false.</para>
		  </listitem>
		</varlistentry>
		<varlistentry>
		  <term>
		    /parser org.kde.kmplot.Parser.setFunctionF2Visible id visible
		  </term>
		  <listitem>
		    <para>Shows the second derivative of the function with the ID <parameter>id</parameter> if <parameter>visible</parameter> is true. If <parameter>visible</parameter> is false, the function will be hidden. True is returned if the function exists, otherwise false.</para>
		  </listitem>
		</varlistentry>
		<varlistentry>
		  <term>
		    /parser org.kde.kmplot.Parser.setFunctionIntVisible id visible
		  </term>
		  <listitem>
		    <para>Shows the integral of the function with the ID <parameter>id</parameter> if <parameter>visible</parameter> is true. If <parameter>visible</parameter> is false, the function will be hidden. True is returned if the function exists, otherwise false.</para>
		  </listitem>
		</varlistentry>
		<varlistentry>
		  <term>
		    /parser org.kde.kmplot.Parser.functionStr id eq <!-- what is eq?-->
		  </term>
		  <listitem>
		    <para>Returns the function expression of the function with the ID <parameter>id</parameter>. If the function not exists, an empty string is returned instead.</para>
		  </listitem>
		</varlistentry>
		<varlistentry>
		  <term>
		    /parser org.kde.kmplot.Parser.functionFLineWidth id
		  </term>
		  <listitem>
		    <para>Returns the line width of the function with the ID <parameter>id</parameter>. If the function not exists, 0 is returned.</para>
		  </listitem>
		</varlistentry>
		<varlistentry>
		  <term>
		    /parser org.kde.kmplot.Parser.functionF1LineWidth id
		  </term>
		  <listitem>
		    <para>Returns the line width of the first derivative of the function with the ID <parameter>id</parameter>. If the function not exists, 0 is returned.</para>
		  </listitem>
		</varlistentry>
		<varlistentry>
		  <term>
		    /parser org.kde.kmplot.Parser.functionF2LineWidth id
		  </term>
		  <listitem>
		    <para>Returns the line width of the second derivative of the function with the ID <parameter>id</parameter>. If the function not exists, 0 is returned.</para>
		  </listitem>
		</varlistentry>
		<varlistentry>
		  <term>
		    /parser org.kde.kmplot.Parser.functionIntLineWidth id
		  </term>
		  <listitem>
		    <para>Returns the line width of the integral of the function with the ID <parameter>id</parameter>. If the function not exists, 0 is returned.</para>
		  </listitem>
		</varlistentry>
		<varlistentry>
		  <term>
		    /parser org.kde.kmplot.Parser.setFunctionFLineWidth id linewidth
		  </term>
		  <listitem>
		    <para>Sets the line width of the function with the ID <parameter>id</parameter> to <parameter>linewidth</parameter>. True is returned if the function exists, otherwise false.</para>
		  </listitem>
		</varlistentry>
		<varlistentry>
		  <term>
		    /parser org.kde.kmplot.Parser.setFunctionF1LineWidth id linewidth
		  </term>
		  <listitem>
		    <para>Sets the line width of the first derivative of the function with the ID <parameter>id</parameter> to <parameter>linewidth</parameter>. True is returned if the function exists, otherwise false.</para>
		  </listitem>
		</varlistentry>
		<varlistentry>
		  <term>
		    /parser org.kde.kmplot.Parser.setFunctionF2LineWidth id linewidth
		  </term>
		  <listitem>
		    <para>Sets the line width of the second derivative of the function with the ID <parameter>id</parameter> to <parameter>linewidth</parameter>. True is returned if the function exists, otherwise false.</para>
		  </listitem>
		</varlistentry>
		<varlistentry>
		  <term>
		    /parser org.kde.kmplot.Parser.setFunctionIntLineWidth id linewidth
		  </term>
		  <listitem>
		    <para>Sets the line width of the integral of the function with the ID <parameter>id</parameter> to <parameter>linewidth</parameter>. True is returned if the function exists, otherwise false.</para>
		  </listitem>
		</varlistentry>
		<varlistentry>
		  <term>
		    /parser org.kde.kmplot.Parser.functionParameterList id
		  </term>
		  <listitem>
		    <para>Returns a list with all the parameter values for the function with the ID <parameter>id</parameter>.</para>
		  </listitem>
		</varlistentry>
		<varlistentry>
		  <term>
		    /parser org.kde.kmplot.Parser.functionAddParameter id new_parameter
		  </term>
		  <listitem>
		    <para>Adds the parameter value  <parameter>new_parameter</parameter> to the function with the ID <parameter>id</parameter>. True is returned if the operation succeed, otherwise false.</para>
		  </listitem>
		</varlistentry>
		<varlistentry>
		  <term>
		    /parser org.kde.kmplot.Parser.functionRemoveParameter id remove_parameter
		  </term>
		  <listitem>
		    <para>Removes the parameter value <parameter>remove_parameter</parameter> from the function with the ID <parameter>id</parameter>. True is returned if the operation succeed, otherwise false.</para>
		  </listitem>
		</varlistentry>
		<varlistentry>
		  <term>
		    /parser org.kde.kmplot.Parser.functionMinValue id
		  </term>
		  <listitem>
		    <para>Returns the minimum plot range value of the function with the ID <parameter>id</parameter>. If the function not exists or if the minimum value is not defined, an empty string is returned.</para>
		  </listitem>
		</varlistentry>
		<varlistentry>
		  <term>
		    /parser org.kde.kmplot.Parser.functionMaxValue id
		  </term>
		  <listitem>
		    <para>Returns the maximum plot range value of the function with the ID <parameter>id</parameter>. If the function not exists or if the maximum value is not defined, an empty string is returned.</para>
		  </listitem>
		</varlistentry>
		<varlistentry>
		  <term>
		    /parser org.kde.kmplot.Parser.setFunctionMinValue id min
		  </term>
		  <listitem>
		    <para>Sets the minimum plot range value of the function with the ID <parameter>id</parameter> to <parameter>min</parameter>. True is returned if the function exists and the expression is valid, otherwise false.</para>
		  </listitem>
		</varlistentry>
		<varlistentry>
		  <term>
		    /parser org.kde.kmplot.Parser.setFunctionMaxValue id max
		  </term>
		  <listitem>
		    <para>Sets the maximum plot range value of the function with the ID <parameter>id</parameter> to <parameter>max</parameter>. True is returned if the function exists and the expression is valid, otherwise false.</para>
		  </listitem>
		</varlistentry>
		
		<varlistentry>
		  <term>
		    /parser org.kde.kmplot.Parser.functionStartXValue id
		  </term>
		  <listitem>
		    <para>Returns the initial x point for the integral of the function with the ID <parameter>id</parameter>. If the function not exists or if the x-point-expression is not defined, an empty string is returned.</para>
		  </listitem>
		</varlistentry>
		<varlistentry>
		  <term>
		    /parser org.kde.kmplot.Parser.functionStartYValue id
		  </term>
		  <listitem>
		    <para>Returns the initial y point for the integral of the function with the ID <parameter>id</parameter>. If the function not exists or if the y-point-expression is not defined, an empty string is returned.</para>
		  </listitem>
		</varlistentry>
		<varlistentry>
		  <term>
		    /parser org.kde.kmplot.Parser.setFunctionStartValue id x y
		  </term>
		  <listitem>
		    <para>Sets the initial x and y point for the integral of the function with the ID <parameter>id</parameter> to <parameter>x</parameter> and  <parameter>y</parameter>. True is returned if the function exists and the expression is valid, otherwise false.</para>
		  </listitem>
		</varlistentry>
		<varlistentry>
			<term>
			/view org.kde.kmplot.View.stopDrawing
			</term>
			<listitem>
				<para>If &kmplot; currently is drawing a function, the procedure will stop.</para>
			</listitem>
		</varlistentry>
		<varlistentry>
			<term>
			/view org.kde.kmplot.View.drawPlot
			</term>
			<listitem>
				<para>Redraws all functions.</para>
			</listitem>
		</varlistentry>
	</variablelist>
</para>
</chapter>

<!--
    Local Variables:
    mode: sgml
    sgml-minimize-attributes:nil
    sgml-general-insert-case:lower
    sgml-indent-step:0
    sgml-indent-data:nil
    sgml-parent-document:("index.docbook" "BOOK" "CHAPTER")
    End:
    -->
