Visual Servoing Platform  version 3.6.1 under development (2024-10-09)
vpColorBlindFriendlyPalette Class Reference

#include <visp3/gui/vpColorBlindFriendlyPalette.h>

Public Types

enum class  Palette {
  Black = 0 , Orange = 1 , SkyBlue = 2 , Green = 3 ,
  Yellow = 4 , Blue = 5 , Vermillon = 6 , Purple = 7 ,
  COUNT = 8
}
 
typedef enum vpColorBlindFriendlyPalette::Palette Palette
 

Public Member Functions

 vpColorBlindFriendlyPalette ()
 
 vpColorBlindFriendlyPalette (const Palette &colorID)
 
 vpColorBlindFriendlyPalette (const std::string &nameColor)
 
Palette get_colorID () const
 
vpColor to_vpColor () const
 
std::vector< unsigned char > to_RGB () const
 
std::vector< double > to_colorRatio () const
 
bool set_fromString (const std::string &nameColor)
 
std::string to_string () const
 

Static Public Member Functions

static std::string getAvailableColorsNames (const std::string &prefix="", const std::string &separator=" ", const std::string &suffix="")
 

Static Public Attributes

static std::vector< std::string > s_paletteNames
 

Detailed Description

Class that furnishes a set of colors that color blind people should be able to distinguish one from another.

Examples
ClassUsingPclViewer.cpp.

Definition at line 51 of file vpColorBlindFriendlyPalette.h.

Member Typedef Documentation

◆ Palette

Enum that list the different available colors.

Member Enumeration Documentation

◆ Palette

Enum that list the different available colors.

Enumerator
Black 

Color that looks like black for non-colorblind people.

Orange 

Color that looks like orange for non-colorblind people.

SkyBlue 

Color that looks like sky blue for non-colorblind people.

Green 

Color that looks like green for non-colorblind people.

Yellow 

Color that looks like yellow for non-colorblind people.

Blue 

Color that looks like blue for non-colorblind people.

Vermillon 

Color that looks like vermilion for non-colorblind people.

Purple 

Color that looks like purple for non-colorblind people.

COUNT 

Number of colors the palette proposes.

Definition at line 57 of file vpColorBlindFriendlyPalette.h.

Constructor & Destructor Documentation

◆ vpColorBlindFriendlyPalette() [1/3]

vpColorBlindFriendlyPalette::vpColorBlindFriendlyPalette ( )

Construct a new vp Color Blind Friendly Palette. The default value vpColorBlindFriendlyPalette::Palette::COUNT is affected.

Definition at line 66 of file vpColorBlindFriendlyPalette.cpp.

◆ vpColorBlindFriendlyPalette() [2/3]

vpColorBlindFriendlyPalette::vpColorBlindFriendlyPalette ( const Palette colorID)

Construct a new vp Color Blind Friendly Palette object.

Parameters
colorIDvpColorBlindFriendlyPalette::Palette that permits to determine the RGB values that we must affect to it.

Definition at line 72 of file vpColorBlindFriendlyPalette.cpp.

◆ vpColorBlindFriendlyPalette() [3/3]

vpColorBlindFriendlyPalette::vpColorBlindFriendlyPalette ( const std::string &  nameColor)

Construct a new vp Color Blind Friendly Palette object from the name of the color. WARNING: if the color is not found, it will be set to vpColorBlindFriendlyPalette::Palette::COUNT.

Parameters
nameColor

Definition at line 78 of file vpColorBlindFriendlyPalette.cpp.

References set_fromString().

Member Function Documentation

◆ get_colorID()

vpColorBlindFriendlyPalette::Palette vpColorBlindFriendlyPalette::get_colorID ( ) const

Get the vpColorBlindFriendlyPalette::Palette the object corresponds to.

Returns
Palette Return vpColorBlindFriendlyPalette::_colorID.

Definition at line 84 of file vpColorBlindFriendlyPalette.cpp.

◆ getAvailableColorsNames()

std::string vpColorBlindFriendlyPalette::getAvailableColorsNames ( const std::string &  prefix = "",
const std::string &  separator = " ",
const std::string &  suffix = "" 
)
static

Get the list of available colors names.

Parameters
prefixOptional prefix that will be written before starting the list.
separatorOptional separator between each member of the list.
suffixOptional suffix that will be written after ending the list.
Returns
std::string The list of names of the available colors.

Definition at line 135 of file vpColorBlindFriendlyPalette.cpp.

References COUNT, and s_paletteNames.

◆ set_fromString()

bool vpColorBlindFriendlyPalette::set_fromString ( const std::string &  nameColor)

Set the fromString object.

Parameters
nameColor
Returns
true if a match was found and it was possible to set _colorID correctly.
false if the input string nameColor did not match any known names.

Definition at line 114 of file vpColorBlindFriendlyPalette.cpp.

References COUNT, and to_string().

Referenced by vpColorBlindFriendlyPalette().

◆ to_colorRatio()

std::vector< double > vpColorBlindFriendlyPalette::to_colorRatio ( ) const

Cast the object in a vector of doubles that belong to the range [0; 1]. The initial R, G, B values are divided by 255. For instance a pixel whose RGB values would be {0; 127.5; 255.} would be transformed in a vector {0.; 0.5; 1.0}.

Returns
std::vector<double> R, G, B values normalized in doubles in the range [0; 1.] by dividing the original values by 255.

Definition at line 104 of file vpColorBlindFriendlyPalette.cpp.

References vpRGBa::B, vpRGBa::G, and vpRGBa::R.

◆ to_RGB()

std::vector< unsigned char > vpColorBlindFriendlyPalette::to_RGB ( ) const

Cast a vpColorBlindFriendlyPalette in a vector {R, G, B}. A vpColorBlindFriendlyPalette::Palette::COUNT object is set as white, i.e. {255, 255, 255}.

Returns
std::vector<unsigned char> A vector containing the R, g, B components (in his order), expressed as an unsigned char (so between 0 and 255).

Definition at line 94 of file vpColorBlindFriendlyPalette.cpp.

References vpRGBa::B, vpRGBa::G, and vpRGBa::R.

Referenced by ClassUsingPclViewer::blockingMode(), and ClassUsingPclViewer::threadedMode().

◆ to_string()

std::string vpColorBlindFriendlyPalette::to_string ( ) const

Get the name of the vpColorBlindFriendlyPalette object.

Returns
std::string The name of the color.

Definition at line 129 of file vpColorBlindFriendlyPalette.cpp.

Referenced by set_fromString().

◆ to_vpColor()

vpColor vpColorBlindFriendlyPalette::to_vpColor ( ) const

Cast a vpColorBlindFriendlyPalette in a vpColor object. A vpColorBlindFriendlyPalette::Palette::COUNT object is set as white (255, 255, 255).

Returns
vpColor The vpColor corresponding to the RGB values of the vpColorBlindFriendlyPalette .

Definition at line 89 of file vpColorBlindFriendlyPalette.cpp.

Member Data Documentation

◆ s_paletteNames

BEGIN_VISP_NAMESPACE std::vector< std::string > vpColorBlindFriendlyPalette::s_paletteNames
static
Initial value:
=
{
"black" ,
"orange" ,
"sky-blue" ,
"green" ,
"yellow" ,
"blue" ,
"vermillon" ,
"purple" ,
"unknown"
}

Vector that lists the names of the different available colors.

Definition at line 70 of file vpColorBlindFriendlyPalette.h.

Referenced by getAvailableColorsNames().