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-2014 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 
130  RGBColor changedBrightness(int change, int toChange = 3) const;
131 
132 
144  static RGBColor parseColor(std::string coldef);
145 
146 
162  static RGBColor parseColorReporting(const std::string& coldef, const std::string& objecttype,
163  const char* objectid, bool report, bool& ok);
164 
165 
176  static RGBColor interpolate(const RGBColor& minColor, const RGBColor& maxColor, SUMOReal weight);
177 
178 
186  static RGBColor fromHSV(SUMOReal h, SUMOReal s, SUMOReal v);
187 
188 
189  static const RGBColor RED;
190  static const RGBColor GREEN;
191  static const RGBColor BLUE;
192  static const RGBColor YELLOW;
193  static const RGBColor CYAN;
194  static const RGBColor MAGENTA;
195  static const RGBColor WHITE;
196  static const RGBColor BLACK;
197  static const RGBColor GREY;
199  static const RGBColor DEFAULT_COLOR;
200 
201 
203  static const std::string DEFAULT_COLOR_STRING;
204 
205 
206 private:
208  unsigned char myRed, myGreen, myBlue, myAlpha;
209 
210 };
211 
212 
213 #endif
214 
215 /****************************************************************************/
216