summaryrefslogtreecommitdiffstats
path: root/kpovmodeler/pmcolor.h
blob: 61fd4c635f3aa37f40ffc8175dba48ac40db534e (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
//-*-C++-*-
/*
**************************************************************************
                                 description
                             --------------------
    copyright            : (C) 2000-2001 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 PMCOLOR_H
#define PMCOLOR_H

#include <tqstring.h>
#include <tqcolor.h>

class PMVector;

/**
 * Class for povray colors (red, green, blue, filter and transmit amount)
 */
class PMColor
{
public:
   /**
    * Creates a color with all values set to 0.0
    */
   PMColor( );
   /**
    * Creates a color
    */
   PMColor( const double red, const double green, const double blue,
            const double filter, const double transmit );
   /**
    * Creates a color with filter and transmit set to 0
    */
   PMColor( const double red, const double green, const double blue );
   /**
    * Creates a color from a @ref PMVector. The vector has to be of size 5
    */
   PMColor( const PMVector& v );
   /**
    * Creates a color from a @ref TQColor object.
    * filter and transmit are set to 0
    */
   PMColor( const TQColor& c );

   /**
    * Sets the red value
    */
   void setRed( double d ) { m_colorValue[0] = d; }
   /**
    * Returns the red value
    */
   double red( ) const { return m_colorValue[0]; }
   /**
    * Sets the green value
    */
   void setGreen( double d ) { m_colorValue[1] = d; }
   /**
    * Returns the green value
    */
   double green( ) const { return m_colorValue[1]; }
   /**
    * Sets the blue value
    */
   void setBlue( double d ) { m_colorValue[2] = d; }
   /**
    * Returns the red value
    */
   double blue( ) const { return m_colorValue[2]; }
   /**
    * Sets the filter value
    */
   void setFilter( double d ) { m_colorValue[3] = d; }
   /**
    * Returns the filter value
    */
   double filter( ) const { return m_colorValue[3]; }
   /**
    * Sets the transmit value
    */
   void setTransmit( double d ) { m_colorValue[4] = d; }
   /**
    * Returns the transmit value
    */
   double transmit( ) const { return m_colorValue[4]; }

   /**
    * Returns the rgb value as TQColor
    */
   TQColor toTQColor( ) const;
   
   /**
    * Returns a string for serialization
    */
   TQString serialize( bool addColorKeyword = false ) const;
   /**
    * Returns a string for xml output
    */
   TQString serializeXML( ) const;
   /**
    * loads the color data from the xml string
    */
   bool loadXML( const TQString& str );

   /**
    * Returns true if the colors are equal*/
   bool operator== ( const PMColor& p ) const;
   /**
    * Returns false if the colors are equal
    */
   bool operator!= ( const PMColor& p ) const;
private:
   /**
    * The color values. Index 0 is red, 1 green, 2 blue, 3 filter, 4 transmit
    */
   double m_colorValue[5];
   
};

#endif