summaryrefslogtreecommitdiffstats
path: root/kpovmodeler/pmlight.h
blob: df40ec0ae1342b108517b495a1a267ff68b3144f (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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
//-*-C++-*-
/*
**************************************************************************
                                 description
                             --------------------
    copyright            : (C) 2000-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 PMLIGHT_H
#define PMLIGHT_H

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

#include "pmnamedobject.h"
#include "pmvector.h"
#include "pmcolor.h"

class PMViewStructure;

/**
 * Class for povray light sources.
 */

class PMLight : public PMNamedObject
{
   typedef PMNamedObject Base;
public:
   enum PMLightType { PointLight=0, SpotLight=1, CylinderLight=2, ShadowlessLight=3 };
   enum PMAreaType { Rectangular=0, Circular=1 };
   /**
    * Creates an empty PMLight
    */
   PMLight( PMPart* part );
   /**
    * Copy constructor
    */
   PMLight( const PMLight& l );
   /**
    * deletes the PMLight
    */
   virtual ~PMLight( );

   /** */
   virtual PMObject* copy( ) const { return new PMLight( *this ); }
   /** */
   virtual QString description( ) const;

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

   /** */
   virtual void serialize( QDomElement& e, QDomDocument& doc ) const;
   /** */
   virtual void readAttributes( const PMXMLHelper& h );

   /**
    * Returns a new @ref PMLightEdit
    */
   virtual PMDialogEditBase* editWidget( QWidget* parent ) const;
   /**
    * Returns the name of the pixmap that is displayed in the tree view
    * and dialog view
    */
   virtual QString pixmap( ) const { return QString( "pmlight" ); }

   /**
    * Returns the type
    */
   PMLightType lightType( ) const { return m_type; }
   /**
    * Sets the type
    */
   void setLightType( PMLightType t );

   /**
    * Returns the location
    */
   PMVector location( ) const { return m_location; }
   /**
    * Sets the location
    */
   void setLocation( const PMVector& p );

   /**
    * Returns the color
    */
   PMColor color( ) const { return m_color; }
   /**
    * Sets the color
    */
   void setColor( const PMColor& c );

   /**
    * Returns the radius for cylinder and spot lights
    */
   double radius( ) const { return m_radius; }
   /**
    * Sets the radius for cylinder and spot lights
    */
   void setRadius( double r );

   /**
    * Returns the falloff for cylinder and spot lights
    */
   double falloff( ) const { return m_falloff; }
   /**
    * Sets the falloff for cylinder and spot lights
    */
   void setFalloff( double f );

   /**
    * Returns the tightness for cylinder and spot lights
    */
   double tightness( ) const { return m_tightness; }
   /**
    * Sets the tightness for cylinder and spot lights
    */
   void setTightness( double r );

   /**
    * Returns the pointAt point for cylinder and spot lights
    */
   PMVector pointAt( ) const { return m_pointAt; }
   /**
    * Sets the pointAt for cylinder and spot lights
    */
   void setPointAt( const PMVector& p );

   /**
    * Return true if the light is a parallel light
    */
   bool parallel( ) const { return m_parallel; }
   /**
    * Sets the parallel light flag
    */
   void setParallel( bool p );

   /**
    * Returns true if the light is a area light
    */
   bool isAreaLight( ) const { return m_bAreaLight; }
   /**
    * Sets the area light flag
    */
   void setAreaLight( bool yes );

   /**
    * Returns the area light type
    */
   PMAreaType areaType( ) const { return m_areaType; }
   /**
    * Sets the area light type
    */
   void setAreaType( PMAreaType at );

   /**
    * Returns the axis1 for area lights
    */
   PMVector axis1( ) const { return m_areaAxis1; }
   /**
    * Sets the axis1 for area lights
    */
   void setAxis1( const PMVector& v );

   /**
    * Returns the axis2 for area lights
    */
   PMVector axis2( ) const { return m_areaAxis2; }
   /**
    * Sets the axis2 for area lights
    */
   void setAxis2( const PMVector& v );

   /**
    * Returns the size1 for area lights
    */
   int size1( ) const { return m_areaSize1; }
   /**
    * Sets the size1 for area lights
    */
   void setSize1( int s );

   /**
    * Returns the size2 for area lights
    */
   int size2( ) const { return m_areaSize2; }
   /**
    * Sets the size2 for area lights
    */
   void setSize2( int s );

   /**
    * Returns the adaptive parameter for area lights
    */
   int adaptive( ) const { return m_adaptive; }
   /**
    * Sets the adaptive parameter for area lights
    */
   void setAdaptive( int s );

   /**
    * Returns if the area light is orientated
    */
   bool orient( ) const { return m_orient; }
   /**
    * Sets the orient flag
    */
   void setOrient( bool o );

   /**
    * Returns the jitter parameter for area lights
    */
   bool jitter( ) const { return m_jitter; }
   /**
    * Sets the jitter parameter for area lights
    */
   void setJitter( bool j );

   /**
    * Returns true if light fading is enabled
    */
   bool fading( ) const { return m_bFading; }
   /**
    * Enables/Disables light fading
    */
   void setFading( bool yes );

   /**
    * Returns the fading distance
    */
   double fadeDistance( ) const { return m_fadeDistance; }
   /**
    * Sets the fading distance
    */
   void setFadeDistance( double d );

   /**
    * Returns the fading power
    */
   int fadePower( ) const { return m_fadePower; }
   /**
    * Sets the fading power
    */
   void setFadePower( int p );

   /**
    * Returns the media interaction flag
    */
   bool mediaInteraction( ) const { return m_bMediaInteraction; }
   /**
    * Sets the media interaction flag
    */
   void setMediaInteraction( bool yes );

   /**
    * Returns the media attenuation flag
    */
   bool mediaAttenuation( ) const { return m_bMediaAttenuation; }
   /**
    * Sets the media attenuation flag
    */
   void setMediaAttenuation( 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( ) { return false; }
   /** */
   virtual void createViewStructure( );
   /** */
   virtual PMViewStructure* defaultViewStructure( ) const { return 0; }

private:
   /**
    * Creates and returns the default view structure for point lights
    */
   PMViewStructure* defaultPointStructure( ) const;
   /**
    * Creates and returns the default view structure for spot lights
    */
   PMViewStructure* defaultSpotStructure( ) const;
   /**
    * Creates and returns the default view structure for cylindrical lights
    */
   PMViewStructure* defaultCylindricalStructure( ) const;

   /**
    * IDs for @ref PMMementoData
    */
   enum PMLightMementoID
   { PMLocationID, PMColorID, PMRadiusID, PMFalloffID, PMTightnessID,
     PMPointAtID, PMParallelID, PMAreaLightID, PMAreaTypeID, PMAreaAxis1ID,
     PMAreaAxis2ID, PMAreaSize1ID, PMAreaSize2ID, PMAdaptiveID, PMOrientID,
     PMJitterID, PMTypeID, PMFadingID, PMFadeDistanceID, PMFadePowerID,
     PMInteractionID, PMAttenuationID };

   PMLightType m_type;
   PMVector m_location;
   PMColor m_color;
   double m_radius;
   double m_falloff;
   double m_tightness;
   PMVector m_pointAt;
   bool m_parallel;
   bool m_bAreaLight;
   PMAreaType m_areaType;
   PMVector m_areaAxis1, m_areaAxis2;
   int m_areaSize1, m_areaSize2;
   int m_adaptive;
   bool m_orient;
   bool m_jitter;
   bool m_bFading;
   double m_fadeDistance;
   int m_fadePower;
   bool m_bMediaInteraction;
   bool m_bMediaAttenuation;

   /**
    * The default view structure for point lights
    */
   static PMViewStructure* s_pDefaultPointStructure;
   /**
    * The default view structure for spot lights
    */
   static PMViewStructure* s_pDefaultSpotStructure;
   /**
    * The default view structure for cylindrical lights
    */
   static PMViewStructure* s_pDefaultCylindricalStructure;

   /**
    * The size of the point light for 3d views
    */
   static double s_pointLightSize;
   /**
    * Number of lines around the cylinder
    */
   static int s_nCylinderLines;
   /**
    * Number of lines around the spot
    */
   static int s_nSpotLines;
   /**
    * Length of the spot and cylinder
    */
   static double s_length;

   static PMMetaObject* s_pMetaObject;
};

#endif