OpendTect  6.3
color.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*+
4 ________________________________________________________________________
5 
6  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
7  Author: A.H. Bril
8  Date: 22-3-2000
9 ________________________________________________________________________
10 
11 -*/
12 
13 
14 #include "basicmod.h"
15 #include "gendefs.h"
16 class BufferStringSet;
17 
18 
25 {
26 public:
27 
28  Color( unsigned char r_=255, unsigned char g_=255,
29  unsigned char b_=255, unsigned char t_=0 );
30  Color( unsigned int rgbval );
31 
32  bool operator ==( const Color& c ) const;
33  bool operator !=( const Color& c ) const;
34 
35  unsigned char r() const;
36  unsigned char g() const;
37  unsigned char b() const;
38  unsigned char t() const;
39  float rF() const { return getFloat( r() ); }
40  float gF() const { return getFloat( g() ); }
41  float bF() const { return getFloat( b() ); }
42  float tF() const { return getFloat( t() ); }
43 
44  bool isVisible() const;
45 
46  unsigned int rgb() const;
47  unsigned int& rgb();
48 
49  void set( unsigned char r_, unsigned char g_,
50  unsigned char b_, unsigned char t_=0 );
51 
52  float average() const { return ((float) r()+g()+b())/3.0f; }
53  Color complementaryColor() const;
54  Color lighter(float fac) const;
55  Color darker( float fac ) const
56  { return lighter( -fac ); }
57  static Color between(Color,Color,float relpos=0.5f);
58 
59  void setRgb( unsigned int rgb_ );
60  void setTransparency( unsigned char t_ );
61  void setTransparencyF( float tf );
62  void setHSV(unsigned char h,unsigned char s,unsigned char v);
63  void getHSV(unsigned char&,unsigned char&,
64  unsigned char&) const;
65  void setStdStr(const char*);
66  BufferString getStdStr(bool withhash=true,
67  int transpopt=0) const;
70 
71  void fill(BufferString&) const;
72  bool use(const char*);
73 
74  static Color NoColor() { return Color(0,0,0,255); }
75 
76  static Color Black() { return Color(0,0,0,0); }
77  static Color Blue() { return Color(0,0,255,0); }
78  static Color DgbColor() { return Color(2,240,4,0); }
79  static Color Green() { return Color(0,255,0,0); }
80  static Color LightGrey() { return Color(211,211,211,0); }
81  static Color Orange() { return Color(255,170,0); }
82  static Color Peach() { return Color(255,218,185,0); }
83  static Color Pink() { return Color(255,0,255,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  // Std draw colors are distinct colors for data series
92  static int nrStdDrawColors();
93  static Color stdDrawColor(int);
94  static Color stdDrawColor(const char*);
95 
96  // The 'description' uses the standard Html color names
97  // if the color is not exactly on one, you will see
98  // a tilde '~' in front of the color
99  BufferString getDescription() const;
100  bool fromDescription(const char*);
101  static Color getColorFromDescription(const char*);
102  static void getDescriptions(BufferStringSet&);
103  static void getDescriptionCenters(TypeSet<Color>&);
104 
105  BufferString largeUserInfoString() const;
106 
107 protected:
108 
109  unsigned int col_;
110 };
111 
112 
113 namespace Values {
114 
117 template<>
119 {
120 public:
121  static Color val() { return Color::NoColor(); }
122  static bool hasUdf() { return false; }
123  static bool isUfd(Color& col) { return false; }
124  static void setUdf(Color& col) {}
125 };
126 
127 }
#define mExpClass(module)
Definition: commondefs.h:157
bool operator==(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:51
static bool hasUdf()
Definition: color.h:122
Templatized undefined and initialisation (i.e. null) values.
Definition: color.h:113
static Color Green()
Definition: color.h:79
static Color val()
Definition: color.h:121
float gF() const
Definition: color.h:40
static Color Red()
Definition: color.h:84
float average() const
Definition: color.h:52
void fill(uiStringSet &) const
Set of BufferString objects.
Definition: bufstringset.h:25
static bool isUfd(Color &col)
Definition: color.h:123
unsigned int col_
Definition: color.h:109
static Color Pink()
Definition: color.h:83
FixedString Color()
Definition: keystrs.h:44
float bF() const
Definition: color.h:41
float rF() const
Definition: color.h:39
void use(const uiStringSet &)
float tF() const
Definition: color.h:42
bool operator!=(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:60
static Color LightGrey()
Definition: color.h:80
static Color DgbColor()
Definition: color.h:78
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:38
static Color Orange()
Definition: color.h:81
Color darker(float fac) const
Definition: color.h:55
static Color Blue()
Definition: color.h:77
Color is an RGB color object, with a transparancy. The storage is in a 4-byte integer, similar to Qt.
Definition: color.h:24
static Color Peach()
Definition: color.h:82
#define mClass(module)
Definition: commondefs.h:161
static Color Yellow()
Definition: color.h:86
static void setUdf(Color &col)
Definition: color.h:124
static Color NoColor()
Definition: color.h:74
static Color Black()
Definition: color.h:76
Templatized undefined values.
Definition: undefval.h:49

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