35 #include <visp3/gui/vpColorBlindFriendlyPalette.h>
36 #include <visp3/core/vpIoTools.h>
38 #if (VISP_CXX_STANDARD > VISP_CXX_STANDARD_98)
54 std::vector<vpColor> vpColorBlindFriendlyPalette::s_palette = {
91 return s_palette[to_uint(m_colorID)];
96 vpColor color = s_palette[to_uint(m_colorID)];
97 std::vector<unsigned char> v_rgb;
98 v_rgb.push_back(color.
R);
99 v_rgb.push_back(color.
G);
100 v_rgb.push_back(color.
B);
106 vpColor color = s_palette[to_uint(m_colorID)];
107 std::vector<double> v_rgb;
108 v_rgb.push_back((
double)color.
R / 255.0);
109 v_rgb.push_back((
double)color.
G / 255.0);
110 v_rgb.push_back((
double)color.
B / 255.0);
117 std::string nameLowerCase = nameColor;
118 bool wasFound(
false);
119 for (
unsigned int i = 0; i < to_uint(
Palette::COUNT) && !wasFound; i++) {
121 if (
to_string(candidate) == nameLowerCase) {
122 m_colorID = candidate;
131 std::string nameColor =
to_string(m_colorID);
137 std::string list(prefix);
138 const unsigned int nbAvailableColors = (
unsigned int)
Palette::COUNT;
139 for (
unsigned int i = 0; i < nbAvailableColors - 1; i++) {
141 list += nameCandidateID + separator;
147 unsigned int vpColorBlindFriendlyPalette::to_uint(
const Palette &colorID)
149 const unsigned int nbAvailableColors = (
unsigned int)
Palette::COUNT;
150 unsigned int ID = nbAvailableColors;
151 std::string nameSearchedColor =
to_string(colorID);
152 bool wasFound =
false;
153 for (
unsigned int i = 0; i < nbAvailableColors && !wasFound; i++) {
155 if (
to_string(candidate) == nameSearchedColor) {
165 std::string nameColor;
201 os << color.to_string();
207 std::string nameColor;
209 color.set_fromString(nameColor);
213 void dummy_vpColorBlindFriendlyPalette() { }
friend std::ostream & operator<<(std::ostream &s, const vpArray2D< Type > &A)
Class that furnishes a set of colors that color blind people should be able to distinguish one from a...
std::vector< unsigned char > to_RGB() const
Cast a vpColorBlindFriendlyPalette in a vector {R, G, B}. A vpColorBlindFriendlyPalette::Palette::COU...
Palette
Enum that list the different available colors.
std::string to_string() const
Get the name of the vpColorBlindFriendlyPalette object.
vpColor to_vpColor() const
Cast a vpColorBlindFriendlyPalette in a vpColor object. A vpColorBlindFriendlyPalette::Palette::COUNT...
static std::string getAvailableColorsNames(const std::string &prefix="", const std::string &separator=" ", const std::string &suffix="")
Get the list of available colors names.
static std::vector< std::string > s_paletteNames
bool set_fromString(const std::string &nameColor)
Set the fromString object.
std::vector< double > to_colorRatio() const
Cast the object in a vector of doubles that belong to the range [0; 1]. The initial R,...
Palette get_colorID() const
Get the vpColorBlindFriendlyPalette::Palette the object corresponds to.
vpColorBlindFriendlyPalette()
Construct a new vp Color Blind Friendly Palette. The default value vpColorBlindFriendlyPalette::Palet...
Class to define RGB colors available for display functionalities.
unsigned char B
Blue component.
unsigned char R
Red component.
unsigned char G
Green component.