summaryrefslogtreecommitdiffstats
path: root/kmplot/kmplot/xparser.h
blob: 5f4f05d528e45dfad05f5a7223dc52a8e26b2ad4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*
* KmPlot - a math. function plotter for the KDE-Desktop
*
* Copyright (C) 1998, 1999  Klaus-Dieter Möller
*               2000, 2002 kd.moeller@t-online.de
*               
* This file is part of the KDE Project.
* KmPlot is part of the KDE-EDU Project.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* 
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*
*/

#ifndef xparser_included
#define xparser_included

#define SLIDER_COUNT 4

// TQt includes
#include <kdebug.h>

// local includes
#include "parser.h"
#include "settings.h"

/**
 * @short Extended parser class.
 *
 * This class extends the parser class to support derivatives, 
 * draw options like color and line width and so on.
 */
class XParser : public Parser
{
public:
	XParser(bool &);
	~XParser();
	/// Evaluates the 1st dreivative of the function with intex \a ix
	double a1fkt( Ufkt *u_item , double, double h = 1e-3 );
	/// Evaluates the 2nd dreivative of the function with intex \a ix
	double a2fkt( Ufkt *, double, double h = 1e-3 );
        /// calculate euler's method when drawing a numeric prime-function
        double euler_method(const double, const TQValueVector<Ufkt>::iterator);
        
        /// Line width default
        int linewidth0;
        TQRgb defaultColor(int function);
	
	enum { Function, Polar, ParametricX, ParametricY }; ///types of functions
	///Returns an unused function name if it is needed
	void fixFunctionName(TQString &, int const = XParser::Function , int const=-1);
        
        /// Returns the index for the next function.
        int getNextIndex();
        /// Fill item with default values (e.g color, linewidth )
        void prepareAddingFunction(Ufkt *item);
        
        /// Interpretates the extended function string (only used by the old file format)
	bool getext( Ufkt *, const TQString );
	
	/// Send a function to an other instance of Kmplot. Returns true if it success, otherwise false
	bool sendFunction(int id, const TQString &dcopclient_target="");
	
	/// Functions for the DCOP interface:

	/// Returns a list with all functions
	TQStringList listFunctionNames();

	/// Returns true if the graph is visible, otherwise false.
	bool functionFVisible(uint id);
	bool functionF1Visible(uint id);
	bool functionF2Visible(uint id);
	bool functionIntVisible(uint id);
	/// Set the visible of the function. Returns true if it succeeds, otherwise false.
	bool setFunctionFVisible(bool visible, uint id);
	bool setFunctionF1Visible(bool visible, uint id);
	bool setFunctionF2Visible(bool visible, uint id);
	bool setFunctionIntVisible(bool visible, uint id);
	
	/// Returns the function expression, or an empty string if the function couldn't be found
	TQString functionStr(uint id);
	/// Returns the complete function string including the extensions of a function, or an empty string if the function couldn't be found
	
	/// Get the color of a graph
	TQColor functionFColor(uint id);
	TQColor functionF1Color(uint id);
	TQColor functionF2Color(uint id);
	TQColor functionIntColor(uint id);
	/// Set the color of a graph. Returns true if it succeeds, otherwise false.
	bool setFunctionFColor(const TQColor &color, uint id);
	bool setFunctionF1Color(const TQColor &color, uint id);
	bool setFunctionF2Color(const TQColor &color, uint id);
	bool setFunctionIntColor(const TQColor &color, uint id);
	
	/// Get the line width of a graph
	int functionFLineWidth(uint id);
	int functionF1LineWidth(uint id);
	int functionF2LineWidth(uint id);
	int functionIntLineWidth(uint id);
	/// Set the line width of a graph. Returns true if it succeeds, otherwise false.
	bool setFunctionFLineWidth(int linewidth, uint id);
	bool setFunctionF1LineWidth(int linewidth, uint id);
	bool setFunctionF2LineWidth(int linewidth, uint id);
	bool setFunctionIntLineWidth(int linewidth, uint id);
		
	/// Returns the function's parameter list
	TQStringList functionParameterList(uint id);
	bool functionAddParameter(const TQString &new_parameter, uint id);
	bool functionRemoveParameter(const TQString &remove_parameter, uint id);
	int addFunction(const TQString &f_str);
	bool addFunction(const TQString &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 TQString &str_dmin, const TQString &str_dmax, const TQString &str_startx, const TQString &str_starty, double integral_precision, TQRgb color, TQRgb f1_color, TQRgb f2_color, TQRgb integral_color, TQStringList str_parameter, int use_slider);
	bool setFunctionExpression(const TQString &f_str, uint id);
	
	/// Get the min and max value of a graph
	TQString functionMinValue(uint id);
	TQString functionMaxValue(uint id);
	/// Set the min and max values of a graph. Returns true if it succeeds, otherwise false.
	bool setFunctionMinValue(const TQString &min, uint id);
	bool setFunctionMaxValue(const TQString &max, uint id);
	
	/// Get the startx and starty value of a graph
	TQString functionStartXValue(uint id);
	TQString functionStartYValue(uint id);
	/// Set the startx and starty values of a graph. Returns true if it succeeds, otherwise false.
	bool setFunctionStartXValue(const TQString &x, uint id);
	bool setFunctionStartYValue(const TQString &y, uint id);
private:
        
	/// finds a free function name 
	void findFunctionName(TQString &, int const, int const);
	/// indicates if the widget is changed
	bool &m_modified;
};

#endif //xparser_included