summaryrefslogtreecommitdiffstats
path: root/kpovmodeler/pmtriangle.h
blob: aeb590d237338311cc034e4c8427d14c37836628 (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
//-*-C++-*-
/*
**************************************************************************
                                 description
                             --------------------
    copyright            : (C) 2001 by 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 PMTRIANGLE_H
#define PMTRIANGLE_H

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

#include "pmgraphicalobject.h"
#include "pmvector.h"

class PMViewStructure;

/**
 * Class for povray triangles.
 */

class PMTriangle : public PMGraphicalObject
{
   typedef PMGraphicalObject Base;
public:
   /**
    * Creates an empty PMTriangle
    */
   PMTriangle( PMPart* part );
   /**
    * Copy constructor
    */
   PMTriangle( const PMTriangle& t );
   /**
    * deletes the PMTriangle
    */
   virtual ~PMTriangle( );

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

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

   /** */
   virtual void serialize( TQDomElement& e, TQDomDocument& doc ) const;
   /** */
   virtual void readAttributes( const PMXMLHelper& h );
   /**
    * Returns a new @ref PMTriangleEdit
    */
   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( "pmtriangle" ); }

   /**
    * Returns true if the triangle is a smooth triangle
    */
   bool isSmoothTriangle( ) const { return m_smooth; }
   /**
    * Enables/disables the normal vectors
    */
   void setSmoothTriangle( bool on );

   /**
    * Returns the point with index i
    */
   PMVector point( int i ) const;
   /**
    * Sets the point with index i
    */
   void setPoint( int i, const PMVector& p );
   /**
    * Returns the normal vector with index i
    */
   PMVector normal( int i ) const;
   /**
    * Sets the mormal vector with index i
    */
   void setNormal( int i, const PMVector& n );

   /**
    * Returns the uv vector with index i
    */
   PMVector uvVector( int i ) const;
   /**
    * Sets the uv vector with index i
    */
   void setUVVector( int i, const PMVector& v );
   /**
    * Return true if triangle has uv vectors
    */
   bool isUVEnabled( ) const { return m_uvEnabled; }
   /**
    * Enables/disable the uv vectors
    */
   void enableUV( bool yes );

   /** */
   virtual void restoreMemento( PMMemento* s );
   /** */
   virtual void controlPoints( PMControlPointList& list );
   /** */
   virtual void controlPointsChanged( PMControlPointList& list );
   /** */
   virtual void cleanUp( ) const;

protected:
   /** */
   virtual bool isDefault( );
   /** */
   virtual void createViewStructure( );
   /** */
   virtual PMViewStructure* defaultViewStructure( ) const;

protected:
   /**
    * IDs for @ref PMMementoData
    */
   enum PMTriangleMementoID { PMPoint0ID, PMPoint1ID, PMPoint2ID,
                              PMNormal0ID, PMNormal1ID, PMNormal2ID,
                              PMSmoothID,
                              PMUVVector0ID, PMUVVector1ID, PMUVVector2ID,
                              PMUVEnabledID };
   PMVector m_point[3];
   PMVector m_normal[3];
   PMVector m_uvVector[3];
   bool m_smooth;
   bool m_uvEnabled;

   /**
    * The default view structure. It can be shared between triangles
    */
   static PMViewStructure* s_pDefaultViewStructure;

   static PMMetaObject* s_pMetaObject;
};

#endif