blob: 628d6689a41a931f7b1a0a2bea6cb4cde2705f70 (
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
|
/*
**************************************************************************
description
--------------------
copyright : (C) 2000-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 PMVALUE_H
#define PMVALUE_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "pmvector.h"
enum PMValueType { PMVFloat, PMVVector, PMVColor };
/**
* Helper class for parsing numeric expressions because wo don't know
* at begin of an expression, which type it is.
*
* Colors are stored as 5D vectors.
*/
class PMValue
{
public:
/**
* Creates a PMValue with type PMVFloat and value 0.0
*/
PMValue( ) : m_v( 0 ) { m_d = 0.0; m_type = PMVFloat; }
/**
* Copy constructor
*/
PMValue( const PMValue& v )
{
m_type = v.m_type;
m_d = v.m_d;
m_v = v.m_v;
}
/**
* Returns the type of the value.
* Values can be PMVFloat, PMVVector, PMVColor
*/
PMValueType type( ) const { return m_type; }
/**
* Sets the float value and sets the type to PMVFloat
*/
void setFloat( const double d ) { m_d = d; m_type = PMVFloat; }
/**
* Sets the vector value and sets the type to PMVVector
*/
void setVector( const PMVector& v ) { m_v = v; m_type = PMVVector; }
/**
* Sets the color value and sets the type to PMVColor
*/
void setColor( const PMVector& v ) { m_v = v; m_type = PMVColor; }
/**
* Returns the float value
*/
double floatValue( ) const { return m_d; }
/**
* Returns the vector value
*/
PMVector vector( ) const { return m_v; }
/**
* Returns the color value
*/
PMVector color( ) const { return m_v; }
/**
* Assigns v to the value
*/
PMValue& operator= ( const PMValue& v )
{
m_type = v.m_type;
m_d = v.m_d;
m_v = v.m_v;
return *this;
}
private:
PMValueType m_type;
double m_d;
PMVector m_v;
};
#endif
|