Main MRPT website > C++ reference for MRPT 1.5.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 
17  bool use_standard_colors_first/* = true */):
18  color_thresh(255) {
19 
20  this->reset();
21  this->use_standard_colors_first = use_standard_colors_first;
22 } // end of TColorManager (ctor)
23 
25 
27 
29  // pick and return a random color triad
30  return TColor(
31  rand() % (color_thresh + 1),
32  rand() % (color_thresh + 1),
33  rand() % (color_thresh + 1));
34  }
35 
36  // start updating by the step if we don't use (or have already used) the
37  // standard colors
39  this->advanceRGBCounters();
40  }
41  else {
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) {
50  }
51  else if (!used_green) {
53  }
54  else if (!used_blue) {
57  }
58  }
59 
61  return curr_color;
62 } // end of getNextTColor
63 
65  return TColorf(this->getNextTColor());
66 } // end of getNextTColor
67 
69  // method is used only when we either don't use or have already used the
70  // standard colors.
71  ASSERT_(
74 
75  THROW_EXCEPTION("Not yet implemented.");
76  // if standard colors have already been used then at first color is TColor::blue
77  if (curr_color == TColor::blue) {
78  curr_color = TColor();
79 
81  }
82 
83  // first advance blue until we reach the limit 255
84  // then advance green until we reach the limit 255
85  // finally advance red until we reach the limit 255
86 
87  // TODO - how do i do this?
89 
90 
91  // if the standard colors are to be used first make sure that the color we
92  // end up on is not a standard one.
94  (curr_color == TColor::red ||
97  this->advanceRGBCounters();
98  }
99 
100 } // end of advanceRGBCounters
101 
103 
104  using namespace std;
106  used_colors.insert(color);
107 
108  // Should always return True as element shouldn't exist prior to this call
109  ASSERT_(ret.second);
110 }
111 
113  used_colors.clear();
114 
115  curr_color = TColor();
116  color_step_triad = TColor(0, 0, 50);
117 
118  have_exceeded_colors = false;
121 }
122 
124  bool ret =
125  used_colors.find(TColor::red) != used_colors.end() &&
126  used_colors.find(TColor::green) != used_colors.end() &&
127  used_colors.find(TColor::blue) != used_colors.end();
128 
129  return ret;
130 }
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
Definition: zip.h:16
std::set< mrpt::utils::TColor > used_colors
Definition: TColorManager.h:45
#define THROW_EXCEPTION(msg)
STL namespace.
static TColor blue
Predefined colors.
Definition: TColor.h:67
const Scalar * const_iterator
Definition: eigen_plugins.h:24
GLuint color
Definition: glext.h:7093
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:26
bool have_used_standard_colors
Indicates if the standard colors have already been used.
Definition: TColorManager.h:58
mrpt::utils::TColor color_step_triad
Definition: TColorManager.h:72
void reset()
Reset all class properties to their default values.
static TColor red
Predefined colors.
Definition: TColor.h:65
mrpt::utils::TColor curr_color
Definition: TColorManager.h:44
#define ASSERT_(f)
A RGB color - floats in the range [0,1].
Definition: TColor.h:80
mrpt::utils::TColor getNextTColor()
Get the next RGB triad in TColor form.
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:48
TColorManager(bool use_standard_colors_first=true)
Constructor.
static TColor green
Predefined colors.
Definition: TColor.h:66



Page generated by Doxygen 1.8.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020