1 // SPDX-FileCopyrightText: 2005 Pino Toscano <toscano.pino@tiscali.it>
2 
3 // SPDX-License-Identifier: GPL-2.0-or-later
4 
5 #ifndef KIG_EQUATIONSTRING_H
6 #define KIG_EQUATIONSTRING_H
7 
8 #include <QString>
9 
10 /**
11  * Simple class that represents an equation.
12  *
13  * It does not do any calculation, it serves only as a helper to write
14  * equations like \f$ 7 xy + 3 y^2 - 5 x - 2 y + 8 = 0 \f$ in a pretty form.
15  * It can handle equations of max two variables (named \em x and \em y ) with
16  * no limits on the grade of the terms. (well, the limit is 15, but I doubt
17  * anyone will ever use such a factor for a power...)
18  */
19 
20 // * Use the addTerm() method to add a term to the equation, and removeTerm() to
21 // * remove one. After that, use prettyString() to get the equation written in a
22 // * nice form.
23 // *
24 // * \note
25 // * If you want to use only the \em x variable, you can unspecify the last
26 // * parameters in the term manipulation methods, like addTerm(), term() and
27 // * removeTerm().
28 // *
29 // * @author Pino Toscano
30 // */
31 
32  /*
33   * What follows is based on code by Maurizio Paolini
34   */
35 
36 class EquationString
37  : public QString
38 {
39 public:
40   EquationString( const QString& string );
41   double trunc( double );
42   void prettify( void );
43   void addTerm( double coeff, const QString& unknowns, bool& needsign );
44 
45   const QString x3() const;
46   const QString y3() const;
47   const QString x2y() const;
48   const QString xy2() const;
49   const QString x2() const;
50   const QString y2() const;
51   const QString xy() const;
52   const QString x() const;
53   const QString y() const;
54   const QString xnym(int n, int m) const;
55 };
56 
57 #endif
58