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