Visual Servoing Platform  version 3.0.0
vpColor.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2015 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ViSP with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * See http://visp.inria.fr for more information.
17  *
18  * This software was developed at:
19  * Inria Rennes - Bretagne Atlantique
20  * Campus Universitaire de Beaulieu
21  * 35042 Rennes Cedex
22  * France
23  *
24  * If you have questions regarding the use of this file, please contact
25  * Inria at visp@inria.fr
26  *
27  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29  *
30  * Description:
31  * Color definition.
32  *
33  * Authors:
34  * Eric Marchand
35  * Fabien Spindler
36  *
37  *****************************************************************************/
38 
39 
40 #ifndef vpColor_hh
41 #define vpColor_hh
42 
43 
44 #include <visp3/core/vpConfig.h>
45 #include <visp3/core/vpRGBa.h>
46 
121 class VISP_EXPORT vpColor : public vpRGBa
122 {
123  public:
125  typedef enum {
126  id_black=0,
145  id_unknown
150  } vpColorIdentifier;
151 
156  /* Predefined colors. */
157  static const vpColor black ;
158  static const vpColor white ;
159  static const vpColor lightGray;
160  static const vpColor gray;
161  static const vpColor darkGray;
162  static const vpColor lightRed;
163  static const vpColor red ;
164  static const vpColor darkRed;
165  static const vpColor lightGreen;
166  static const vpColor green;
167  static const vpColor darkGreen;
168  static const vpColor lightBlue;
169  static const vpColor blue ;
170  static const vpColor darkBlue;
171  static const vpColor yellow ;
172  static const vpColor cyan;
173  static const vpColor orange;
174  static const vpColor purple;
175  static const vpColor none;
176 
177  static const unsigned int nbColors;
178  static const vpColor allColors[];
179 
187  inline vpColor()
188  : vpRGBa(), id(id_unknown)
189  {};
200  inline vpColor(unsigned char r, unsigned char g, unsigned char b,
202  : vpRGBa(r, g, b), id(cid)
203  {};
205  inline virtual ~vpColor() {};
206 
207  friend VISP_EXPORT bool operator==( const vpColor &c1, const vpColor &c2 );
208  friend VISP_EXPORT bool operator!=( const vpColor &c1, const vpColor &c2 );
220  inline void setColor(unsigned char r, unsigned char g, unsigned char b) {
221  this->R = r;
222  this->G = g;
223  this->B = b;
224  this->A = 0;
225  id = id_unknown;
226  };
227 
234  static inline vpColor getColor(const unsigned int &i) {
236  };
237 
238 };
239 
240 // In this file if windows
241 #if defined(VISP_USE_MSVC) && defined(visp_EXPORTS)
242 
243 vpColor const __declspec(selectany) vpColor::black = vpColor(0, 0, 0, id_black);
245 vpColor const __declspec(selectany) vpColor::white = vpColor(255, 255, 255, id_white);
247 vpColor const __declspec(selectany) vpColor::lightGray = vpColor(192, 192, 192, id_lightGray);
249 vpColor const __declspec(selectany) vpColor::gray = vpColor(128, 128, 128, id_gray);
251 vpColor const __declspec(selectany) vpColor::darkGray = vpColor(64, 64, 64, id_darkGray);
254 vpColor const __declspec(selectany) vpColor::lightRed = vpColor(255, 140, 140, id_lightRed);
257 vpColor const __declspec(selectany) vpColor::red = vpColor(255, 0, 0, id_red);
260 vpColor const __declspec(selectany) vpColor::darkRed = vpColor(128, 0, 0, id_darkRed);
263 vpColor const __declspec(selectany) vpColor::lightGreen = vpColor(140, 255, 140, id_lightGreen);
266 vpColor const __declspec(selectany) vpColor::green = vpColor(0, 255, 0, id_green);
269 vpColor const __declspec(selectany) vpColor::darkGreen = vpColor(0, 128, 0, id_darkGreen);
272 vpColor const __declspec(selectany) vpColor::lightBlue = vpColor(140, 140, 255, id_lightBlue);
275 vpColor const __declspec(selectany) vpColor::blue = vpColor(0, 0, 255, id_blue);
278 vpColor const __declspec(selectany) vpColor::darkBlue = vpColor(0, 0, 128, id_darkBlue);
281 vpColor const __declspec(selectany) vpColor::yellow = vpColor(255, 255, 0, id_yellow);
284 vpColor const __declspec(selectany) vpColor::cyan = vpColor(0, 255, 255, id_cyan);
287 vpColor const __declspec(selectany) vpColor::orange = vpColor(255, 165, 0, id_orange);
290 vpColor const __declspec(selectany) vpColor::purple = vpColor(128, 0, 128, id_purple);
292 vpColor const __declspec(selectany) vpColor::none = vpColor(0, 0, 0, id_unknown);
293 
294 const __declspec(selectany) unsigned int vpColor::nbColors = 18;
295 
297 vpColor const __declspec(selectany) vpColor::allColors[vpColor::nbColors] = {
298  vpColor::blue , // 12
299  vpColor::green , // 9
300  vpColor::red , // 6
301  vpColor::cyan , // 15
302  vpColor::purple , // 4
303  vpColor::yellow , // 14
304  vpColor::orange , // 16
305  vpColor::lightBlue ,// 11
307  vpColor::lightRed , // 5
308  vpColor::darkBlue , // 13
309  vpColor::darkGreen ,// 10
310  vpColor::darkRed , // 7
311  vpColor::lightGray ,// 2
312  vpColor::gray , // 3
313  vpColor::darkGray , // 4
314  vpColor::black , // 0
315  vpColor::white}; // 17
316 
317 #endif
318 
319 #endif
vpColor()
Definition: vpColor.h:187
void setColor(unsigned char r, unsigned char g, unsigned char b)
Definition: vpColor.h:220
static const vpColor allColors[]
Definition: vpColor.h:178
static const vpColor black
Definition: vpColor.h:157
static const vpColor darkRed
Definition: vpColor.h:164
Class to define colors available for display functionnalities.
Definition: vpColor.h:121
static const vpColor none
Definition: vpColor.h:175
static const vpColor lightGray
Definition: vpColor.h:159
static const vpColor darkBlue
Definition: vpColor.h:170
static const vpColor green
Definition: vpColor.h:166
static const vpColor lightRed
Definition: vpColor.h:162
Class that defines a RGB 32 bits structure.
Definition: vpRGBa.h:64
static const vpColor red
Definition: vpColor.h:163
static const vpColor orange
Definition: vpColor.h:173
vpColorIdentifier id
Definition: vpColor.h:152
bool operator==(const vpRGBa &v)
Definition: vpRGBa.cpp:108
static const vpColor cyan
Definition: vpColor.h:172
static const vpColor lightGreen
Definition: vpColor.h:165
vpColorIdentifier
Definition: vpColor.h:125
static const vpColor gray
Definition: vpColor.h:160
static const vpColor darkGray
Definition: vpColor.h:161
virtual ~vpColor()
Definition: vpColor.h:205
static const vpColor darkGreen
Definition: vpColor.h:167
static vpColor getColor(const unsigned int &i)
Definition: vpColor.h:234
static const vpColor yellow
Definition: vpColor.h:171
static const vpColor lightBlue
Definition: vpColor.h:168
static const vpColor purple
Definition: vpColor.h:174
static const vpColor white
Definition: vpColor.h:158
bool operator!=(const vpRGBa &v)
Definition: vpRGBa.cpp:126
static const unsigned int nbColors
Definition: vpColor.h:177
static const vpColor blue
Definition: vpColor.h:169
vpColor(unsigned char r, unsigned char g, unsigned char b, vpColor::vpColorIdentifier cid=vpColor::id_unknown)
Definition: vpColor.h:200