33#include <visp3/gui/vpColorBlindFriendlyPalette.h>
34#include <visp3/core/vpIoTools.h>
36#if (VISP_CXX_STANDARD > VISP_CXX_STANDARD_98)
52std::vector<vpColor> vpColorBlindFriendlyPalette::s_palette = {
89 return s_palette[to_uint(m_colorID)];
94 vpColor color = s_palette[to_uint(m_colorID)];
95 std::vector<unsigned char> v_rgb;
96 v_rgb.push_back(color.R);
97 v_rgb.push_back(color.G);
98 v_rgb.push_back(color.B);
104 vpColor color = s_palette[to_uint(m_colorID)];
105 std::vector<double> v_rgb;
106 v_rgb.push_back(
static_cast<double>(color.R) / 255.0);
107 v_rgb.push_back(
static_cast<double>(color.G) / 255.0);
108 v_rgb.push_back(
static_cast<double>(color.B) / 255.0);
114 m_colorID = Palette::COUNT;
115 std::string nameLowerCase = nameColor;
116 bool wasFound(
false);
117 for (
unsigned int i = 0; i < to_uint(Palette::COUNT) && !wasFound; i++) {
119 if (
to_string(candidate) == nameLowerCase) {
120 m_colorID = candidate;
129 std::string nameColor =
to_string(m_colorID);
135 std::string list(prefix);
136 const unsigned int nbAvailableColors =
static_cast<unsigned int>(Palette::COUNT);
137 for (
unsigned int i = 0; i < nbAvailableColors - 1; i++) {
139 list += nameCandidateID + separator;
145unsigned int vpColorBlindFriendlyPalette::to_uint(
const Palette &colorID)
147 const unsigned int nbAvailableColors =
static_cast<unsigned int>(Palette::COUNT);
148 unsigned int ID = nbAvailableColors;
149 std::string nameSearchedColor =
to_string(colorID);
150 bool wasFound =
false;
151 for (
unsigned int i = 0; i < nbAvailableColors && !wasFound; i++) {
153 if (
to_string(candidate) == nameSearchedColor) {
163 std::string nameColor;
168 case Palette::Orange:
171 case Palette::SkyBlue:
177 case Palette::Yellow:
183 case Palette::Vermillon:
186 case Palette::Purple:
199 os <<
color.to_string();
205 std::string nameColor;
207 color.set_fromString(nameColor);
211void dummy_vpColorBlindFriendlyPalette() { }
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.