summaryrefslogtreecommitdiffstats
path: root/kpovmodeler/pmpolynomexponents.h
blob: cd2b39b6b639956e9cbb79f0e4c4363a95f81e51 (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
//-*-C++-*-
/*
**************************************************************************
                                 description
                             --------------------
    copyright            : (C) 2002 by Andreas Zehender
    email                : zehender@kde.org
**************************************************************************

**************************************************************************
*                                                                        *
*  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.                                   *
*                                                                        *
**************************************************************************/


#ifndef PMPOLYNOMEXPONENTS_H
#define PMPOLYNOMEXPONENTS_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <tqptrlist.h>
#include <tqvaluelist.h>

/**
 * Helper class for the @ref PMPolynomBaseEdit widget
 */
class PMPolynomExponents
{
public:
   /**
    * All exponents are initialized with 0
    */
   PMPolynomExponents( )
   {
      m_exponents[0] = m_exponents[1] = m_exponents[2] = 0;
   }
   /**
    * The exponents are initialized with x, y, z
    */
   PMPolynomExponents( int x, int y, int z )
   {
      m_exponents[0] = x;
      m_exponents[1] = y;
      m_exponents[2] = z;
   }

   /**
    * Returns the ith exponent
    */
   int exponent( int i ) const { return m_exponents[i]; }
   /**
    * Sets the ith exponent
    */
   void setExponent( int i, int exp ) { m_exponents[i] = exp; }

   /**
    * Returns the x exponent
    */
   int xExponent( ) const { return m_exponents[0]; }
   /**
    * Sets the x exponent
    */
   void setXExponent( int exp ) { m_exponents[0] = exp; }
   /**
    * Returns the y exponent
    */
   int yExponent( ) const { return m_exponents[1]; }
   /**
    * Sets the y exponent
    */
   void setYExponent( int exp ) { m_exponents[1] = exp; }
   /**
    * Returns the z exponent
    */
   int zExponent( ) const { return m_exponents[2]; }
   /**
    * Sets the z exponent
    */
   void setZExponent( int exp ) { m_exponents[2] = exp; }

   bool operator== ( const PMPolynomExponents& e ) const
   {
      return ( m_exponents[0] == e.m_exponents[0] ) &&
             ( m_exponents[1] == e.m_exponents[1] ) &&
             ( m_exponents[2] == e.m_exponents[2] );
   }
   bool operator!= ( const PMPolynomExponents& e ) const
   {
      return !( *this == e );
   }
   PMPolynomExponents& operator= ( const PMPolynomExponents& p )
   {
      m_exponents[0] = p.m_exponents[0];
      m_exponents[1] = p.m_exponents[1];
      m_exponents[2] = p.m_exponents[2];
      return *this;
   }
   friend PMPolynomExponents operator+ ( const PMPolynomExponents& p1,
                                         const PMPolynomExponents& p2 );

   /**
    * Returns the sum of the exponents
    */
   int sum( ) const { return m_exponents[0] + m_exponents[1] + m_exponents[2]; }

private:
   int m_exponents[3];

   // static stuff
public:
   /**
    * Returns the exponents for a polynom with order n ( 2 <= n <= 7 )
    */
   static TQValueList<PMPolynomExponents>& polynom( int n );
   
private:
   static TQValueList<PMPolynomExponents> //...
   recPolynom( const PMPolynomExponents& base, int xyz, int n, int rem );
   static bool m_created[6];
   static TQValueList<PMPolynomExponents> m_lists[6];
};

#endif