SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RGBColor.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // A RGB-color definition
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef RGBColor_h
23 #define RGBColor_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <iostream>
37 
38 
39 // ===========================================================================
40 // class definitions
41 // ===========================================================================
47 class RGBColor {
48 public:
51  RGBColor();
52 
53 
59  RGBColor(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha = 255);
60 
61 
64  RGBColor(const RGBColor& col);
65 
66 
68  ~RGBColor();
69 
70 
71 
75  unsigned char red() const {
76  return myRed;
77  }
78 
79 
83  unsigned char green() const {
84  return myGreen;
85  }
86 
87 
91  unsigned char blue() const {
92  return myBlue;
93  }
94 
95 
99  unsigned char alpha() const {
100  return myAlpha;
101  }
102 
103 
110  void set(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
111 
112 
118  friend std::ostream& operator<<(std::ostream& os, const RGBColor& col);
119 
120 
121  bool operator==(const RGBColor& c) const;
122  bool operator!=(const RGBColor& c) const;
123 
124 
129  RGBColor changedBrightness(const char change);
130 
131 
143  static RGBColor parseColor(std::string coldef);
144 
145 
161  static RGBColor parseColorReporting(const std::string& coldef, const std::string& objecttype,
162  const char* objectid, bool report, bool& ok);
163 
164 
175  static RGBColor interpolate(const RGBColor& minColor, const RGBColor& maxColor, SUMOReal weight);
176 
177 
185  static RGBColor fromHSV(SUMOReal h, SUMOReal s, SUMOReal v);
186 
187 
188  static const RGBColor RED;
189  static const RGBColor GREEN;
190  static const RGBColor BLUE;
191  static const RGBColor YELLOW;
192  static const RGBColor CYAN;
193  static const RGBColor MAGENTA;
194  static const RGBColor WHITE;
195  static const RGBColor BLACK;
196  static const RGBColor GREY;
198  static const RGBColor DEFAULT_COLOR;
199 
200 
202  static const std::string DEFAULT_COLOR_STRING;
203 
204 
205 private:
207  unsigned char myRed, myGreen, myBlue, myAlpha;
208 
209 };
210 
211 
212 #endif
213 
214 /****************************************************************************/
215 
static const RGBColor BLUE
Definition: RGBColor.h:190
static RGBColor parseColor(std::string coldef)
Parses a color information.
Definition: RGBColor.cpp:154
~RGBColor()
Destructor.
Definition: RGBColor.cpp:81
static RGBColor fromHSV(SUMOReal h, SUMOReal s, SUMOReal v)
Converts the given hsv-triplet to rgb.
Definition: RGBColor.cpp:273
static const RGBColor WHITE
Definition: RGBColor.h:194
static RGBColor parseColorReporting(const std::string &coldef, const std::string &objecttype, const char *objectid, bool report, bool &ok)
Parses a color information.
Definition: RGBColor.cpp:231
bool operator==(const RGBColor &c) const
Definition: RGBColor.cpp:133
static RGBColor interpolate(const RGBColor &minColor, const RGBColor &maxColor, SUMOReal weight)
Interpolates between two colors.
Definition: RGBColor.cpp:257
friend std::ostream & operator<<(std::ostream &os, const RGBColor &col)
Writes the color to the given stream.
Definition: RGBColor.cpp:94
static const RGBColor BLACK
Definition: RGBColor.h:195
unsigned char blue() const
Returns the blue-amount of the color.
Definition: RGBColor.h:91
bool operator!=(const RGBColor &c) const
Definition: RGBColor.cpp:139
static const RGBColor GREEN
Definition: RGBColor.h:189
static const RGBColor GREY
Definition: RGBColor.h:196
unsigned char myAlpha
Definition: RGBColor.h:207
unsigned char myRed
The color amounts.
Definition: RGBColor.h:207
void set(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
assigns new values
Definition: RGBColor.cpp:85
static const RGBColor DEFAULT_COLOR
The default color (for vehicle types and vehicles)
Definition: RGBColor.h:198
unsigned char alpha() const
Returns the alpha-amount of the color.
Definition: RGBColor.h:99
unsigned char myGreen
Definition: RGBColor.h:207
static const RGBColor MAGENTA
Definition: RGBColor.h:193
static const RGBColor YELLOW
Definition: RGBColor.h:191
static const RGBColor RED
Definition: RGBColor.h:188
static const RGBColor CYAN
Definition: RGBColor.h:192
RGBColor changedBrightness(const char change)
Returns a new color with altered brightness.
Definition: RGBColor.cpp:145
unsigned char myBlue
Definition: RGBColor.h:207
unsigned char green() const
Returns the green-amount of the color.
Definition: RGBColor.h:83
#define SUMOReal
Definition: config.h:221
RGBColor()
Constructor.
Definition: RGBColor.cpp:69
unsigned char red() const
Returns the red-amount of the color.
Definition: RGBColor.h:75
static const std::string DEFAULT_COLOR_STRING
The string description of the default color.
Definition: RGBColor.h:202