OpendTect-6_4  6.4
color.h
Go to the documentation of this file.
1 #ifndef color_h
2 #define color_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: A.H. Bril
9  Date: 22-3-2000
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 
16 #include "basicmod.h"
17 #include "gendefs.h"
18 class BufferStringSet;
19 
20 
27 {
28 public:
29 
30  Color( unsigned char r_=255, unsigned char g_=255,
31  unsigned char b_=255, unsigned char t_=0 );
32  Color( unsigned int rgbval );
33 
34  bool operator ==( const Color& c ) const;
35  bool operator !=( const Color& c ) const;
36 
37  unsigned char r() const;
38  unsigned char g() const;
39  unsigned char b() const;
40  unsigned char t() const;
41  float rF() const { return getFloat( r() ); }
42  float gF() const { return getFloat( g() ); }
43  float bF() const { return getFloat( b() ); }
44  float tF() const { return getFloat( t() ); }
45 
46  bool isVisible() const;
47 
48  unsigned int rgb() const;
49  unsigned int& rgb();
50 
51  void set( unsigned char r_, unsigned char g_,
52  unsigned char b_, unsigned char t_=0 );
53 
54  float average() const { return ((float) r()+g()+b())/3.0f; }
55  Color complementaryColor() const;
56  Color lighter(float fac) const;
57  Color darker( float fac ) const
58  { return lighter( -fac ); }
59 
60  void setRgb( unsigned int rgb_ );
61  void setTransparency( unsigned char t_ );
62  void setTransparencyF( float tf );
63  void setHSV(unsigned char h,unsigned char s,unsigned char v);
64  void getHSV(unsigned char&,unsigned char&,
65  unsigned char&) const;
66  void setStdStr(const char*);
67  const char* getStdStr(bool withhash=true,
68  int transpopt=0) const;
71 
72  void fill(BufferString&) const;
73  bool use(const char*);
74 
75  static Color NoColor() { return Color(0,0,0,255); }
76 
77  static Color Black() { return Color(0,0,0,0); }
78  static Color Blue() { return Color(0,0,255,0); }
79  static Color DgbColor() { return Color(2,240,4,0); }
80  static Color Green() { return Color(0,255,0,0); }
81  static Color LightGrey() { return Color(211,211,211,0); }
82  static Color Orange() { return Color(255,170,0); }
83  static Color Peach() { return Color(255,218,185,0); }
84  static Color Red() { return Color(255,0,0,0); }
85  static Color White() { return Color(255,255,255,0); }
86  static Color Yellow() { return Color(255,255,0,0); }
87 
88  static unsigned char getUChar( float v );
89  static float getFloat(unsigned char);
90 
91  static int nrStdDrawColors();
92  static Color stdDrawColor(int);
93 
94  const char* largeUserInfoString() const;
95  const char* getDescription() const;
96  bool fromDescription(const char*);
97  static const BufferStringSet& descriptions();
98  static const TypeSet<Color>& descriptionCenters();
99 
100 protected:
101 
102  unsigned int col_;
103 };
104 
105 
106 namespace Values {
107 
112 template<>
114 {
115 public:
116  static Color val() { return Color::NoColor(); }
117  static bool hasUdf() { return false; }
118  static bool isUfd(Color& col) { return false; }
119  static void setUdf(Color& col) {}
120 };
121 
122 }
123 
124 
125 #endif
#define mExpClass(module)
Definition: commondefs.h:160
bool operator==(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:53
static bool hasUdf()
Definition: color.h:117
Templatized undefined and initialisation (i.e. null) values.
Definition: color.h:106
static Color Green()
Definition: color.h:80
static Color val()
Definition: color.h:116
float gF() const
Definition: color.h:42
static Color Red()
Definition: color.h:84
float average() const
Definition: color.h:54
void fill(uiStringSet &) const
Set of BufferString objects.
Definition: bufstringset.h:28
static bool isUfd(Color &col)
Definition: color.h:118
unsigned int col_
Definition: color.h:102
FixedString Color()
Definition: keystrs.h:46
float bF() const
Definition: color.h:43
float rF() const
Definition: color.h:41
void use(const uiStringSet &)
float tF() const
Definition: color.h:44
bool operator!=(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:62
static Color LightGrey()
Definition: color.h:81
static Color DgbColor()
Definition: color.h:79
static Color White()
Definition: color.h:85
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:40
static Color Orange()
Definition: color.h:82
Color darker(float fac) const
Definition: color.h:57
static Color Blue()
Definition: color.h:78
Color is an RGB color object, with a transparancy. The storage is in a 4-byte integer, similar to Qt.
Definition: color.h:26
static Color Peach()
Definition: color.h:83
#define mClass(module)
Definition: commondefs.h:164
static Color Yellow()
Definition: color.h:86
static void setUdf(Color &col)
Definition: color.h:119
static Color NoColor()
Definition: color.h:75
static Color Black()
Definition: color.h:77
Templatized undefined values.
Definition: undefval.h:51

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2019