OpendTect  6.6
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  RCS: $Id$
10 ________________________________________________________________________
11 
12 -*/
13 
14 
15 #include "basicmod.h"
16 #include "gendefs.h"
17 class BufferStringSet;
18 
19 
26 {
27 public:
28 
29  Color( unsigned char r_=255, unsigned char g_=255,
30  unsigned char b_=255, unsigned char t_=0 );
31  Color( unsigned int rgbval );
32 
33  bool operator ==( const Color& c ) const;
34  bool operator !=( const Color& c ) const;
35 
36  unsigned char r() const;
37  unsigned char g() const;
38  unsigned char b() const;
39  unsigned char t() const;
40  float rF() const { return getFloat( r() ); }
41  float gF() const { return getFloat( g() ); }
42  float bF() const { return getFloat( b() ); }
43  float tF() const { return getFloat( t() ); }
44 
45  bool isVisible() const;
46 
47  unsigned int rgb() const;
48  unsigned int& rgb();
49 
50  void set( unsigned char r_, unsigned char g_,
51  unsigned char b_, unsigned char t_=0 );
52 
53  float average() const { return ((float) r()+g()+b())/3.0f; }
56  Color lighter(float fac) const;
57  Color darker( float fac ) const
58  { return lighter( -fac ); }
59  float contrast(const Color&) const;
60 
61  float getRelLuminance() const;
62  void setRgb( unsigned int rgb_ );
63  void setTransparency( unsigned char t_ );
64  void setTransparencyF( float tf );
65  void setHSV(unsigned char h,unsigned char s,unsigned char v);
66  void getHSV(unsigned char&,unsigned char&,
67  unsigned char&) const;
68  void setStdStr(const char*);
69  const char* getStdStr(bool withhash=true,
70  int transpopt=0) const;
75 
76  void fill(BufferString&) const;
77  bool use(const char*);
78 
79  static Color NoColor() { return Color(0,0,0,255); }
80 
81  static Color Anthracite() { return Color(50, 50, 50, 0); }
82  static Color Black() { return Color(0,0,0,0); }
83  static Color Blue() { return Color(0,0,255,0); }
84  static Color DgbColor() { return Color(2,240,4,0); }
85  static Color Green() { return Color(0,255,0,0); }
86  static Color LightGrey() { return Color(211,211,211,0); }
87  static Color Orange() { return Color(255,170,0); }
88  static Color Peach() { return Color(255,218,185,0); }
89  static Color Red() { return Color(255,0,0,0); }
90  static Color White() { return Color(255,255,255,0); }
91  static Color Yellow() { return Color(255,255,0,0); }
92 
93  static Color interpolate(const Color&,const Color&,float frac=0.5);
94 
95  static unsigned char getUChar( float v );
96  static float getFloat(unsigned char);
97 
98  static int nrStdDrawColors();
99  static Color stdDrawColor(int);
100 
101  const char* largeUserInfoString() const;
102  const char* getDescription() const;
103  bool fromDescription(const char*);
104  static const BufferStringSet& descriptions();
106 
107 protected:
108 
109  unsigned int col_;
110 };
111 
112 
113 namespace Values {
114 
119 template<>
121 {
122 public:
123  static Color val() { return Color::NoColor(); }
124  static bool hasUdf() { return false; }
125  static bool isUfd(Color&) { return false; }
126  static void setUdf(Color&) {}
127 };
128 
129 }
130 
131 
Values::Undef< Color >::val
static Color val()
Definition: color.h:123
Color::convertFromStr
static void convertFromStr(const BufferStringSet &, TypeSet< Color > &)
Color::Yellow
static Color Yellow()
Definition: color.h:91
Color::getFloat
static float getFloat(unsigned char)
sKey::Color
FixedString Color()
Definition: keystrs.h:45
Color::Anthracite
static Color Anthracite()
Definition: color.h:81
Color::NoColor
static Color NoColor()
Definition: color.h:79
Color::Black
static Color Black()
Definition: color.h:82
BufferStringSet
Set of BufferString objects.
Definition: bufstringset.h:26
Color::getDescription
const char * getDescription() const
Color::b
unsigned char b() const
Color::nrStdDrawColors
static int nrStdDrawColors()
mExpClass
#define mExpClass(module)
Definition: commondefs.h:177
Color::setHSV
void setHSV(unsigned char h, unsigned char s, unsigned char v)
Color::lighter
Color lighter(float fac) const
Color::bF
float bF() const
Definition: color.h:42
Color::gF
float gF() const
Definition: color.h:41
Color::Green
static Color Green()
Definition: color.h:85
Color::Color
Color(unsigned char r_=255, unsigned char g_=255, unsigned char b_=255, unsigned char t_=0)
Color::getRelLuminance
float getRelLuminance() const
operator==
bool operator==(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:81
Color::Red
static Color Red()
Definition: color.h:89
Color::getUChar
static unsigned char getUChar(float v)
Color::t
unsigned char t() const
Color::set
void set(unsigned char r_, unsigned char g_, unsigned char b_, unsigned char t_=0)
Values::Undef< Color >
Undefined Color.
Definition: color.h:121
Color::rgb
unsigned int & rgb()
Color::setTransparency
void setTransparency(unsigned char t_)
Color::Orange
static Color Orange()
Definition: color.h:87
Color::isVisible
bool isVisible() const
Color::getStdStr
const char * getStdStr(bool withhash=true, int transpopt=0) const
Color::tF
float tF() const
Definition: color.h:43
Color::LightGrey
static Color LightGrey()
Definition: color.h:86
operator!=
bool operator!=(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:90
mClass
#define mClass(module)
Definition: commondefs.h:181
Values::Undef< Color >::isUfd
static bool isUfd(Color &)
Definition: color.h:125
gendefs.h
Color::darker
Color darker(float fac) const
Definition: color.h:57
Color::fill
void fill(BufferString &) const
Color::Peach
static Color Peach()
Definition: color.h:88
Color::col_
unsigned int col_
Definition: color.h:109
Values::Undef< Color >::setUdf
static void setUdf(Color &)
Definition: color.h:126
Color::average
float average() const
Definition: color.h:53
Color::complementaryColor
Color complementaryColor() const
Color::Blue
static Color Blue()
Definition: color.h:83
Color::setTransparencyF
void setTransparencyF(float tf)
BufferString
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size.
Definition: bufstring.h:40
Values::Undef< Color >::hasUdf
static bool hasUdf()
Definition: color.h:124
Color::setStdStr
void setStdStr(const char *)
e.g. "#00ff32"
Color::getHSV
void getHSV(unsigned char &, unsigned char &, unsigned char &) const
Color::rgb
unsigned int rgb() const
Color::use
bool use(const char *)
Color::g
unsigned char g() const
Color::r
unsigned char r() const
Color::rF
float rF() const
Definition: color.h:40
Color::contrast
float contrast(const Color &) const
Color::complimentaryColors
TypeSet< Color > complimentaryColors(int) const
Values
Templatized undefined and initialisation (i.e. null) values.
Definition: color.h:113
Color::fromDescription
bool fromDescription(const char *)
Color::largeUserInfoString
const char * largeUserInfoString() const
Color::stdDrawColor
static Color stdDrawColor(int)
Color::Color
Color(unsigned int rgbval)
Color::setRgb
void setRgb(unsigned int rgb_)
Color
Color is an RGB color object, with a transparancy. The storage is in a 4-byte integer,...
Definition: color.h:26
Color::convertToStr
static void convertToStr(const TypeSet< Color > &, BufferStringSet &)
Color::White
static Color White()
Definition: color.h:90
Color::DgbColor
static Color DgbColor()
Definition: color.h:84
Color::descriptions
static const BufferStringSet & descriptions()
TypeSet< Color >
Color::interpolate
static Color interpolate(const Color &, const Color &, float frac=0.5)
Color::descriptionCenters
static const TypeSet< Color > & descriptionCenters()

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