summaryrefslogtreecommitdiffstats
path: root/kpovmodeler/pmtorus.h
blob: a7f1ee6a7bda343a560913cd81509d610c9daf19 (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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/*
 ***************************************************************************
                          pmtorus.h  -  description
                             -------------------
    begin                : Fri Jun 22 2001
    copyright            : (C) 2001 Philippe Van Hecke
    email                : [email protected]
    copyright            : (C) 2002 Andreas Zehender
    email                : [email protected]
 ***************************************************************************

 ***************************************************************************
 *                                                                         *
 *   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 PMTORUS_H
#define PMTORUS_H

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

#include "pmsolidobject.h"
#include "pmvector.h"
#include "pmviewstructure.h"

class PMViewStructure;

/**
 * Class for povray torus.
 */
class PMTorus : public PMSolidObject
{
   typedef PMSolidObject Base;

public:
   /**
    * Create an empty Sphere
    */
   PMTorus( PMPart* part );
   /**
    * Copy constructor
    */
   PMTorus( const PMTorus& t );
   /**
    * Delete the PMTorus
    */
   virtual ~PMTorus( );

   /** */
   virtual PMObject* copy( ) const { return new PMTorus( *this ); }
   /** */
   virtual TQString description( ) const;

   /** */
   virtual PMMetaObject* metaObject( ) const;

   /** */
   virtual void serialize( TQDomElement& e, TQDomDocument& doc ) const;
   /** */
   virtual void readAttributes( const PMXMLHelper& h );
   /**
    * Returns a new @ref PMTrousEdit
    */
   virtual PMDialogEditBase* editWidget( TQWidget* parent ) const;
   /**
    * Returns the name of the pixmap that is displayed in the tree view
    * and dialog view
    */
   virtual TQString pixmap( ) const { return TQString( "pmtorus" ); }
   /**
    * set minor radius see povray documentation about torus
    */
   void setMinorRadius( double minor_radius );
   /**
    * set major radius see povray documentation about torus
    */
   void setMajorRadius( double major_radius );
   /**
    * use sturm algorithme
    */
   void setSturm( bool sturm );
   /**
    * return minor radius see povray documentation about torus
    */
   double minorRadius( ) const { return m_minorRadius; }
   /**
    * return major radius see povray documentation about torus
    */
   double majorRadius( ) const { return m_majorRadius; }
   /**
    * return if we must use sturm algorithm for the torus
    */
   bool sturm( ) const { return m_sturm; }
   /** */
   virtual void restoreMemento( PMMemento* s );
   /** */
   virtual void controlPoints( PMControlPointList& list );
   /** */
   virtual void controlPointsChanged( PMControlPointList& list );
   /** */
   virtual bool hasDisplayDetail( ) const { return true; }
   /** */
   virtual void cleanUp( ) const;

   /**
    * Sets the number of circles
    */
   static void setUSteps( int u );
   /**
    * Sets the number of point for each circle
    */
   static void setVSteps( int v );
   /**
    * Returns the number circles
    */
   static int uSteps( ) { return s_uStep; }
   /**
    * Returns the number of point for each circle
    */
   static int vSteps( ) { return s_vStep; }

protected:
   /** */
   virtual bool isDefault( );
   /** */
   virtual void createViewStructure( );
   /** */
   virtual PMViewStructure* defaultViewStructure( ) const;
   /** */
   virtual int viewStructureParameterKey( ) const { return s_parameterKey + globalDetailKey(); }

private:
   static void createLines( PMLineArray& lines, int uStep, int vStep );
   static void createPoints( PMPointArray& points, double minor_radius,
                             double  major_radius, int uStep, int vStep );
   enum PMTorusMementoID { PMMinorRadiusID, PMMajorRadiusID, PMSturmID };
   /**
    * Minor radius
    */
   double m_minorRadius;
   /**
    * Major radius
    */
   double m_majorRadius;
   /**
    * use sturm algorithm
    */
   bool m_sturm;
   /**
    * default view structure
    */
   static PMViewStructure* s_pDefaultViewStructure;
   static int s_vStep;
   static int s_uStep;
   static int s_parameterKey;

   static PMMetaObject* s_pMetaObject;
};

#endif
/*
x = (major + minor cos(u)) cos(v)
y = (major + minor cos(u)) sin(v)
z = minor sin (u) */