38 auto clamp = [](
double rgba){
return std::clamp(rgba, 0., 1.);};
43red(clamp(r)), green(clamp(gr)), blue(clamp(b)), alpha(clamp(a))
47red(clamp(v.x())), green(clamp(v.y())), blue(clamp(v.z())), alpha (1.)
61 os <<
'(' << c.red <<
',' << c.green <<
',' << c.blue
62 <<
',' << c.alpha <<
')';
65 std::map<G4String, G4Colour>::const_reverse_iterator ri;
66 for (ri = colourMap.rbegin(); ri != colourMap.rend(); ++ri) {
67 if (c == ri->second) {
68 os <<
" (" << ri->first <<
')';
77 return (red != c.red) ||
83std::map<G4String, G4Colour> G4Colour::fColourMap;
84G4bool G4Colour::fInitColourMap =
false;
90 static G4bool first =
true;
94 (
"G4Colour::AddToMap(const G4String& key, const G4Colour& colour)",
96 "Attempt to add to colour map from non-master thread.");
107 if (fColourMap.find(myKey) == fColourMap.end()) fColourMap[myKey] = colour;
110 ed <<
"G4Colour with key " << myKey <<
" already exists." <<
G4endl;
112 (
"G4Colour::AddToMap(const G4String& key, const G4Colour& colour)",
114 "Colour key exists");
120 if (fInitColourMap)
return;
122 fInitColourMap =
true;
152 std::map<G4String, G4Colour>::const_iterator iter = fColourMap.find(myKey);
155 if (iter == fColourMap.cend()) {
157 ed <<
"Colour \"" << key <<
"\" not found. No action taken.";
162 result = iter->second;
177 if (red < rhs.red)
return true;
178 if (red == rhs.red) {
179 if (green < rhs.green)
return true;
180 if (green == rhs.green) {
181 if (blue < rhs.blue)
return true;
182 if (blue == rhs.blue) {
183 if (alpha < rhs.alpha)
return true;
std::ostream & operator<<(std::ostream &os, const G4Colour &c)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
CLHEP::Hep3Vector G4ThreeVector
static G4bool GetColour(const G4String &key, G4Colour &result)
static void AddToMap(const G4String &key, const G4Colour &colour)
static void InitialiseColourMap()
G4Colour(G4double r=1., G4double gr=1., G4double b=1., G4double a=1.)
static const std::map< G4String, G4Colour > & GetMap()
G4bool operator!=(const G4Colour &c) const
static G4Colour Magenta()
G4bool operator<(const G4Colour &rhs) const
G4String to_lower_copy(G4String str)
Return lowercased copy of string.
T clamp(T value, T lo, T hi)