2 * KmPlot - a math. function plotter for the KDE-Desktop
4 * Copyright (C) 1998, 1999 Klaus-Dieter Möller
5 * 2000, 2002 kd.moeller@t-online.de
7 * This file is part of the KDE Project.
8 * KmPlot is part of the KDE-EDU Project.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 #ifndef xparser_included
27 #define xparser_included
29 #define SLIDER_COUNT 4
39 * @short Extended parser class.
41 * This class extends the parser class to support derivatives,
42 * draw options like color and line width and so on.
44 class XParser
: public Parser
49 /// Evaluates the 1st dreivative of the function with intex \a ix
50 double a1fkt( Ufkt
*u_item
, double, double h
= 1e-3 );
51 /// Evaluates the 2nd dreivative of the function with intex \a ix
52 double a2fkt( Ufkt
*, double, double h
= 1e-3 );
53 /// calculate euler's method when drawing a numeric prime-function
54 double euler_method(const double, const QValueVector
<Ufkt
>::iterator
);
56 /// Line width default
58 QRgb
defaultColor(int function
);
60 enum { Function
, Polar
, ParametricX
, ParametricY
}; ///types of functions
61 ///Returns an unused function name if it is needed
62 void fixFunctionName(QString
&, int const = XParser::Function
, int const=-1);
64 /// Returns the index for the next function.
66 /// Fill item with default values (e.g color, linewidth )
67 void prepareAddingFunction(Ufkt
*item
);
69 /// Interpretates the extended function string (only used by the old file format)
70 bool getext( Ufkt
*, const QString
);
72 /// Send a function to an other instance of Kmplot. Returns true if it success, otherwise false
73 bool sendFunction(int id
, const QString
&dcopclient_target
="");
75 /// Functions for the DCOP interface:
77 /// Returns a list with all functions
78 QStringList
listFunctionNames();
80 /// Returns true if the graph is visible, otherwise false.
81 bool functionFVisible(uint id
);
82 bool functionF1Visible(uint id
);
83 bool functionF2Visible(uint id
);
84 bool functionIntVisible(uint id
);
85 /// Set the visible of the function. Returns true if it succeeds, otherwise false.
86 bool setFunctionFVisible(bool visible
, uint id
);
87 bool setFunctionF1Visible(bool visible
, uint id
);
88 bool setFunctionF2Visible(bool visible
, uint id
);
89 bool setFunctionIntVisible(bool visible
, uint id
);
91 /// Returns the function expression, or an empty string if the function couldn't be found
92 QString
functionStr(uint id
);
93 /// Returns the complete function string including the extensions of a function, or an empty string if the function couldn't be found
95 /// Get the color of a graph
96 QColor
functionFColor(uint id
);
97 QColor
functionF1Color(uint id
);
98 QColor
functionF2Color(uint id
);
99 QColor
functionIntColor(uint id
);
100 /// Set the color of a graph. Returns true if it succeeds, otherwise false.
101 bool setFunctionFColor(const QColor
&color
, uint id
);
102 bool setFunctionF1Color(const QColor
&color
, uint id
);
103 bool setFunctionF2Color(const QColor
&color
, uint id
);
104 bool setFunctionIntColor(const QColor
&color
, uint id
);
106 /// Get the line width of a graph
107 int functionFLineWidth(uint id
);
108 int functionF1LineWidth(uint id
);
109 int functionF2LineWidth(uint id
);
110 int functionIntLineWidth(uint id
);
111 /// Set the line width of a graph. Returns true if it succeeds, otherwise false.
112 bool setFunctionFLineWidth(int linewidth
, uint id
);
113 bool setFunctionF1LineWidth(int linewidth
, uint id
);
114 bool setFunctionF2LineWidth(int linewidth
, uint id
);
115 bool setFunctionIntLineWidth(int linewidth
, uint id
);
117 /// Returns the function's parameter list
118 QStringList
functionParameterList(uint id
);
119 bool functionAddParameter(const QString
&new_parameter
, uint id
);
120 bool functionRemoveParameter(const QString
&remove_parameter
, uint id
);
121 int addFunction(const QString
&f_str
);
122 bool addFunction(const QString
&extstr
, bool f_mode
, bool f1_mode
, bool f2_mode
, bool integral_mode
, bool integral_use_precision
, int linewidth
, int f1_linewidth
, int f2_linewidth
, int integral_linewidth
, const QString
&str_dmin
, const QString
&str_dmax
, const QString
&str_startx
, const QString
&str_starty
, double integral_precision
, QRgb color
, QRgb f1_color
, QRgb f2_color
, QRgb integral_color
, QStringList str_parameter
, int use_slider
);
123 bool setFunctionExpression(const QString
&f_str
, uint id
);
125 /// Get the min and max value of a graph
126 QString
functionMinValue(uint id
);
127 QString
functionMaxValue(uint id
);
128 /// Set the min and max values of a graph. Returns true if it succeeds, otherwise false.
129 bool setFunctionMinValue(const QString
&min
, uint id
);
130 bool setFunctionMaxValue(const QString
&max
, uint id
);
132 /// Get the startx and starty value of a graph
133 QString
functionStartXValue(uint id
);
134 QString
functionStartYValue(uint id
);
135 /// Set the startx and starty values of a graph. Returns true if it succeeds, otherwise false.
136 bool setFunctionStartXValue(const QString
&x
, uint id
);
137 bool setFunctionStartYValue(const QString
&y
, uint id
);
140 /// finds a free function name
141 void findFunctionName(QString
&, int const, int const);
142 /// indicates if the widget is changed
146 #endif //xparser_included