Coin Logo http://www.sim.no/
http://www.coin3d.org/

SbColor4f.h
1 #ifndef COIN_SBCOLOR4F_H
2 #define COIN_SBCOLOR4F_H
3 
4 /**************************************************************************\
5  *
6  * This file is part of the Coin 3D visualization library.
7  * Copyright (C) by Kongsberg Oil & Gas Technologies.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * ("GPL") version 2 as published by the Free Software Foundation.
12  * See the file LICENSE.GPL at the root directory of this source
13  * distribution for additional information about the GNU GPL.
14  *
15  * For using Coin with software that can not be combined with the GNU
16  * GPL, and for taking advantage of the additional benefits of our
17  * support services, please contact Kongsberg Oil & Gas Technologies
18  * about acquiring a Coin Professional Edition License.
19  *
20  * See http://www.coin3d.org/ for more information.
21  *
22  * Kongsberg Oil & Gas Technologies, Bygdoy Alle 5, 0257 Oslo, NORWAY.
23  * http://www.sim.no/ sales@sim.no coin-support@coin3d.org
24  *
25 \**************************************************************************/
26 
27 #include <Inventor/system/inttypes.h>
28 #include <Inventor/SbVec4f.h>
29 #include <Inventor/SbColor.h>
30 
31 class SbVec4f;
32 
33 class COIN_DLL_API SbColor4f : public SbVec4f {
34 public:
35  SbColor4f(void);
36  SbColor4f(const SbColor &rgb, const float alpha);
37  SbColor4f(const SbVec4f& v);
38  SbColor4f(const float* const rgba);
39  SbColor4f(const float r, const float g, const float b, const float a = 1.0f);
40 
41  void setValue(const float r, const float g, const float b,
42  const float a = 1.0f);
43  void setValue(const float col[4]);
44  const float *getValue() const;
45  void getValue(float &r, float &g, float &b, float &a);
46 
47  SbColor4f& setRGB(const SbColor &col);
48  void getRGB(SbColor &color);
49  SbColor4f& setHSVValue(float h, float s, float v, float a = 1.0f);
50  SbColor4f& setHSVValue(const float hsv[3], float alpha = 1.0f);
51  void getHSVValue(float &h, float &s, float &v) const;
52  void getHSVValue(float hsv[3]) const;
53  SbColor4f& setPackedValue(const uint32_t rgba);
54  uint32_t getPackedValue() const;
55 
56  float operator[](const int idx) const;
57  float &operator[](const int idx);
58 
59  SbColor4f &operator*=(const float d);
60  SbColor4f &operator/=(const float d);
61  SbColor4f &operator+=(const SbColor4f &c);
62  SbColor4f &operator-=(const SbColor4f &c);
63 
64  friend COIN_DLL_API SbColor4f operator *(const SbColor4f &c, const float d);
65  friend COIN_DLL_API SbColor4f operator *(const float d, const SbColor4f &c);
66  friend COIN_DLL_API SbColor4f operator /(const SbColor4f &c, const float d);
67  friend COIN_DLL_API SbColor4f operator +(const SbColor4f &v1, const SbColor4f &v2);
68  friend COIN_DLL_API SbColor4f operator -(const SbColor4f &v1, const SbColor4f &v2);
69  friend COIN_DLL_API int operator ==(const SbColor4f &v1, const SbColor4f &v2);
70  friend COIN_DLL_API int operator !=(const SbColor4f &v1, const SbColor4f &v2);
71 
72 private:
73  float red() const { return this->vec[0]; }
74  float green() const { return this->vec[1]; }
75  float blue() const { return this->vec[2]; }
76  float alpha() const { return this->vec[3]; }
77 };
78 
79 COIN_DLL_API SbColor4f operator *(const SbColor4f &c, const float d);
80 COIN_DLL_API SbColor4f operator *(const float d, const SbColor4f &c);
81 COIN_DLL_API SbColor4f operator /(const SbColor4f &c, const float d);
82 COIN_DLL_API SbColor4f operator +(const SbColor4f &v1, const SbColor4f &v2);
83 COIN_DLL_API SbColor4f operator -(const SbColor4f &v1, const SbColor4f &v2);
84 COIN_DLL_API int operator ==(const SbColor4f &v1, const SbColor4f &v2);
85 COIN_DLL_API int operator !=(const SbColor4f &v1, const SbColor4f &v2);
86 
87 typedef class SbColor4f SbColorRGBA; // TGS compatibility
88 
89 #endif // !COIN_SBCOLOR4F_H

Copyright © 1998-2010 by Kongsberg Oil & Gas Technologies. All rights reserved.

Generated on Tue Dec 4 2012 01:50:15 for Coin by Doxygen 1.8.2.