Main MRPT website > C++ reference for MRPT 1.9.9
TColorManager.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "base-precomp.h" // Precompiled headers
12 
13 using namespace mrpt::utils;
14 using namespace std;
15 
16 TColorManager::TColorManager(bool use_standard_colors_first /* = true */)
17  : color_thresh(255)
18 {
19  this->reset();
20  this->use_standard_colors_first = use_standard_colors_first;
21 } // end of TColorManager (ctor)
22 
25 {
27  {
28  // pick and return a random color triad
29  return TColor(
30  rand() % (color_thresh + 1), rand() % (color_thresh + 1),
31  rand() % (color_thresh + 1));
32  }
33 
34  // start updating by the step if we don't use (or have already used) the
35  // standard colors
37  {
38  this->advanceRGBCounters();
39  }
40  else
41  {
42  bool used_red = used_colors.find(TColor::red()) != used_colors.end();
43  bool used_green = used_colors.find(TColor::green()) != used_colors.end();
44  bool used_blue = used_colors.find(TColor::blue()) != used_colors.end();
45 
46  // fixed order of usage
47  // red -> green -> blue
48  if (!used_red)
49  {
51  }
52  else if (!used_green)
53  {
55  }
56  else if (!used_blue)
57  {
60  }
61  }
62 
64  return curr_color;
65 } // end of getNextTColor
66 
68 {
69  return TColorf(this->getNextTColor());
70 } // end of getNextTColor
71 
73 {
74  // method is used only when we either don't use or have already used the
75  // standard colors.
77 
78  THROW_EXCEPTION("Not yet implemented.");
79  // if standard colors have already been used then at first color is
80  // TColor::blue
81  if (curr_color == TColor::blue())
82  {
83  curr_color = TColor();
84 
86  }
87 
88  // first advance blue until we reach the limit 255
89  // then advance green until we reach the limit 255
90  // finally advance red until we reach the limit 255
91 
92  // TODO - how do i do this?
94 
95  // if the standard colors are to be used first make sure that the color we
96  // end up on is not a standard one.
100  {
101  this->advanceRGBCounters();
102  }
103 
104 } // end of advanceRGBCounters
105 
107 {
108  using namespace std;
110 
111  // Should always return True as element shouldn't exist prior to this call
112  ASSERT_(ret.second);
113 }
114 
116 {
117  used_colors.clear();
118 
119  curr_color = TColor();
120  color_step_triad = TColor(0, 0, 50);
121 
122  have_exceeded_colors = false;
125 }
126 
128 {
129  bool ret = used_colors.find(TColor::red()) != used_colors.end() &&
130  used_colors.find(TColor::green()) != used_colors.end() &&
131  used_colors.find(TColor::blue()) != used_colors.end();
132 
133  return ret;
134 }
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
std::set< mrpt::utils::TColor > used_colors
Definition: TColorManager.h:46
#define THROW_EXCEPTION(msg)
STL namespace.
const Scalar * const_iterator
Definition: eigen_plugins.h:27
GLuint color
Definition: glext.h:8300
static constexpr TColor green()
Definition: TColor.h:64
mrpt::utils::TColorf getNextTColorf()
Get the next RGB triad in TColorf form.
bool checkStdColorsUsed()
Check if the standard colors have already been used.
A RGB color - 8bit.
Definition: TColor.h:25
bool have_used_standard_colors
Indicates if the standard colors have already been used.
Definition: TColorManager.h:59
mrpt::utils::TColor color_step_triad
Definition: TColorManager.h:73
void reset()
Reset all class properties to their default values.
static constexpr TColor red()
Predefined colors.
Definition: TColor.h:63
mrpt::utils::TColor curr_color
Definition: TColorManager.h:45
#define ASSERT_(f)
A RGB color - floats in the range [0,1].
Definition: TColor.h:78
mrpt::utils::TColor getNextTColor()
Get the next RGB triad in TColor form.
static constexpr TColor blue()
Definition: TColor.h:65
void markColorAsUsed(mrpt::utils::TColor color)
Mark the given color as used.
bool use_standard_colors_first
Indicates if the standard colors are to be returned first.
Definition: TColorManager.h:49
TColorManager(bool use_standard_colors_first=true)
Constructor.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019